Skip to content

Commit

Permalink
import functionality wip
Browse files Browse the repository at this point in the history
  • Loading branch information
KoloInDaCrib committed Nov 4, 2024
1 parent 6837de5 commit 12c19c5
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 7 deletions.
2 changes: 1 addition & 1 deletion source/funkin/ui/debug/char/CharCreatorCharacter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CharCreatorCharacter extends Bopper

generatedParams = wizardParams;

switch (generatedParams.renderType)
switch (generatedParams?.renderType)
{
case CharacterRenderType.Sparrow | CharacterRenderType.MultiSparrow:
if (generatedParams.files.length < 2) return; // img and data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AddCharFilesDialog extends DefaultWizardDialog
{
super.showDialog(modal);

addAssetsBox.disabled = !params.generateCharacter;
addAssetsBox.disabled = (!params.generateCharacter || params.importedCharacter != null);
if (stupidFuckingRenderCheck == params.renderType) return;

while (addAssetsBox.childComponents.length > 0)
Expand Down
88 changes: 88 additions & 0 deletions source/funkin/ui/debug/char/components/wizard/ImportDataDialog.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package funkin.ui.debug.char.components.wizard;

import funkin.data.character.CharacterData;
import funkin.data.character.CharacterRegistry;
import funkin.data.freeplay.player.PlayerRegistry;
import haxe.ui.components.OptionBox;

@:xml('
<?xml version="1.0" encoding="utf-8"?>
<dialog width="400" height="425" title="Character Creator - Import Data" closable="false">
<vbox width="100%" height="100%">
<label text="Choose the Optional Data to import." width="100%"/>
<hbox width="100%" height="100%">

<vbox id="importCharData" width="50%" height="100%">
<checkbox id="importCharCheck" text="Use Characater Data"/>
<scrollview width="100%" height="100%" contentWidth="100%">
<vbox id="importCharList" width="100%" disabled="true"/>
</scrollview>
</vbox>

<vbox id="importPlayer" width="50%" height="100%">
<checkbox id="importPlayerCheck" text="Use Player Data"/>
<scrollview width="100%" height="100%" contentWidth="100%">
<vbox id="importPlayerList" width="100%" disabled="true"/>
</scrollview>
</vbox>

</hbox>

</vbox>
</dialog>
')
class ImportDataDialog extends DefaultWizardDialog
{
override public function new()
{
super(IMPORT_DATA);

importCharCheck.onChange = function(_) importCharList.disabled = !importCharCheck.selected;
importPlayerCheck.onChange = function(_) importPlayerList.disabled = !importPlayerCheck.selected;

for (id in CharacterRegistry.listCharacterIds())
{
var check = new OptionBox();
check.text = id;
check.selected = (id == selectedData);
check.onChange = _ -> {
selectedData = id;
}
importCharList.addComponent(check);
}

for (id in PlayerRegistry.instance.listEntryIds())
{
var check = new OptionBox();
check.text = id;
check.selected = (id == selectedPlayer);
check.onChange = _ -> {
selectedPlayer = id;
}
importPlayerList.addComponent(check);
}
}

var selectedData:String = Constants.DEFAULT_CHARACTER;
var selectedPlayer:String = "bf"; // eh

override public function showDialog(modal:Bool = true)
{
super.showDialog(modal);

// we dont want to import any data if we don't even generate the character to begin with
importCharData.disabled = !params.generateCharacter;
importPlayer.disabled = !params.generatePlayerData;
}

override public function isNextStepAvailable()
{
if (params.generateCharacter && importCharCheck.selected) params.importedCharacter = selectedData;
else
params.importedCharacter = null;

// same shit for the player, though it's currently not my priority

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class RenderWizardDialog extends DefaultWizardDialog
override public function showDialog(modal:Bool = true)
{
super.showDialog(modal);
renderOptionSparrow.disabled = renderOptionPacker.disabled = renderOptionAtlas.disabled = renderOptionMulti.disabled = !params.generateCharacter;
renderOptionSparrow.disabled = renderOptionPacker.disabled = renderOptionAtlas.disabled = renderOptionMulti.disabled = (!params.generateCharacter
|| params.importedCharacter != null);

renderOptionSparrow.selected = params.renderType == CharacterRenderType.Sparrow;
renderOptionPacker.selected = params.renderType == CharacterRenderType.Packer;
Expand Down
13 changes: 9 additions & 4 deletions source/funkin/ui/debug/char/handlers/CharCreatorStartupWizard.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class CharCreatorStartupWizard
generateCharacter: false,
generatePlayerData: false,
renderType: CharacterRenderType.Sparrow,
files: []
files: [],
importedCharacter: null
}

public static function startWizard(state:CharCreatorState, onComplete:WizardGenerateParams->Void = null, onQuit:Void->Void = null)
Expand Down Expand Up @@ -48,6 +49,7 @@ class CharCreatorStartupWizard
dialogArray = [];

dialogArray.push(new StartWizardDialog());
dialogArray.push(new ImportDataDialog());
dialogArray.push(new RenderWizardDialog());
dialogArray.push(new AddCharFilesDialog());
dialogArray.push(new ConfirmDialog());
Expand All @@ -61,6 +63,8 @@ typedef WizardGenerateParams =
var generatePlayerData:Bool;
var renderType:CharacterRenderType;
var files:Array<WizardFile>;
@:optional
var importedCharacter:String;
}

typedef WizardFile =
Expand All @@ -72,8 +76,9 @@ typedef WizardFile =
enum abstract WizardStep(Int) from Int to Int
{
public var STARTUP = 0;
public var SELECT_CHAR_TYPE = 1;
public var UPLOAD_ASSETS = 2;
public var IMPORT_DATA = 1;
public var SELECT_CHAR_TYPE = 2;
public var UPLOAD_ASSETS = 3;
public var UPLOAD_PLAYER_ASSETS = -1; // not implemented yet!
public var CONFIRM = 3;
public var CONFIRM = 4;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage
Conductor.instance.onBeatHit.add(stageBeatHit);

currentCharacter = new CharCreatorCharacter(wizardParams);
if (wizardParams.importedCharacter != null) daState.importCharacter(wizardParams.importedCharacter);
add(currentCharacter);

ghostCharacter = new CharCreatorCharacter(wizardParams);
Expand Down

0 comments on commit 12c19c5

Please sign in to comment.