Skip to content

Commit

Permalink
character metadata dialog + healthicon bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KoloInDaCrib committed Nov 19, 2024
1 parent 30e4a05 commit 54654ea
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 0 deletions.
1 change: 1 addition & 0 deletions source/funkin/data/character/CharacterRegistry.hx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class CharacterRegistry
try
{
var charData:CharacterData = parseCharacterData(charId);
charData = validateCharacterData(charId, charData);
if (charData != null)
{
trace(' Loaded character data: ${charId}');
Expand Down
6 changes: 6 additions & 0 deletions source/funkin/ui/debug/char/CharCreatorCharacter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class CharCreatorCharacter extends Bopper
public var holdTimer:Float = 0;
public var characterCameraOffsets:Array<Float> = [0.0, 0.0];
public var animations:Array<AnimationData> = [];
public var deathData:DeathData = null;

public var characterFlipX:Bool = false;
public var characterScale:Float = 1.0; // character scale to be used in the data, ghosts need one
Expand Down Expand Up @@ -303,6 +304,11 @@ class CharCreatorCharacter extends Bopper
renderType: generatedParams.renderType,
healthIcon: healthIcon,
animations: animations,
offsets: globalOffsets,
isPixel: isPixel,
cameraOffsets: characterCameraOffsets,
singTime: holdTimer,
death: deathData
};
}

Expand Down
143 changes: 143 additions & 0 deletions source/funkin/ui/debug/char/components/dialogs/CharMetadataDialog.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package funkin.ui.debug.char.components.dialogs;

@:xml('<?xml version="1.0" encoding="utf-8"?>
<collapsible-dialog title="Character Metadata" width="400" height="400">
<vbox width="100%" height="100%">
<hbox width="100%" height="100%">
<vbox width="50%" height="100%">
<frame text="Offsets" width="100%">
<hbox>
<number-stepper id="charOffsetsX" pos="0"/>
<number-stepper id="charOffsetsY" pos="0"/>
</hbox>
</frame>

<frame text="Camera Offsets" width="100%">
<hbox>
<number-stepper id="charCamOffsetsX" pos="0"/>
<number-stepper id="charCamOffsetsY" pos="0"/>
</hbox>
</frame>

<frame text="Scale" width="100%">
<vbox>
<number-stepper id="charScale" pos="1" min="0.05" step="0.05" precision="2"/>
</vbox>
</frame>

<frame text="Hold Timer" width="100%">
<vbox>
<number-stepper id="charHoldTimer" pos="8" min="0" precision="2"/>
</vbox>
</frame>

<frame text="Flip Horizontally" width="100%">
<vbox>
<checkbox id="charFlipX" text="Enabled"/>
</vbox>
</frame>

<frame text="Pixelated" width="100%">
<vbox>
<checkbox id="charIsPixel" text="Enabled"/>
</vbox>
</frame>
</vbox>

<frame text="Death Data" width="50%" height="100%">
<vbox width="100%">
<checkbox id="charHasDeathData" text="Enabled" />
<vbox id="charDeathBox" width="100%">

<section-header text="Camera Offsets" />
<hbox>
<number-stepper id="charDeathCamOffsetX" pos="0" />
<number-stepper id="charDeathCamOffsetY" pos="0" />
</hbox>

<section-header text="Camera Zoom" />
<number-stepper id="charDeathCamZoom" pos="1" min="0.11" />

<section-header text="Transition Delay" />
<number-stepper id="charDeathTransDelay" pos="0" min="0" />
</vbox>
</vbox>
</frame>
</hbox>
</vbox>
</collapsible-dialog>')
class CharMetadataDialog extends DefaultPageDialog
{
override public function new(daPage:CharCreatorGameplayPage, char:CharCreatorCharacter)
{
super(daPage);

charOffsetsX.pos = char.globalOffsets[0];
charOffsetsY.pos = char.globalOffsets[1];
charCamOffsetsX.pos = char.characterCameraOffsets[0];
charCamOffsetsY.pos = char.characterCameraOffsets[1];
charScale.pos = char.characterScale;
charHoldTimer.pos = char.holdTimer;
charFlipX.selected = char.characterFlipX;
charIsPixel.selected = char.isPixel;
charHasDeathData.selected = (char.deathData != null);
charDeathBox.disabled = !charHasDeathData.selected;

charDeathCamOffsetX.pos = char.deathData?.cameraOffsets[0] ?? 0;
charDeathCamOffsetY.pos = char.deathData?.cameraOffsets[1] ?? 0;
charDeathCamZoom.pos = char.deathData?.cameraZoom ?? 1;
charDeathTransDelay.pos = char.deathData?.preTransitionDelay ?? 0;

// callbaccd
charOffsetsX.onChange = charOffsetsY.onChange = function(_) {
char.globalOffsets = [charOffsetsX.pos, charOffsetsY.pos];
daPage.updateCharPerStageData(char.characterType);
}

charCamOffsetsX.onChange = charCamOffsetsY.onChange = function(_) char.characterCameraOffsets = [charCamOffsetsX.pos, charCamOffsetsY.pos];

charScale.onChange = function(_) {
char.characterScale = charScale.pos;
daPage.updateCharPerStageData(char.characterType);
}

charHoldTimer.onChange = function(_) char.holdTimer = charHoldTimer.pos;

charFlipX.onChange = function(_) {
char.characterFlipX = charFlipX.selected;
daPage.updateCharPerStageData(char.characterType);
}

charIsPixel.onChange = function(_) {
char.isPixel = charIsPixel.selected;

char.antialiasing = !char.isPixel;
char.pixelPerfectRender = char.isPixel;
char.pixelPerfectPosition = char.isPixel;
}

// death
charHasDeathData.onChange = function(_) {
char.deathData = charHasDeathData.selected ?
{
cameraOffsets: [charDeathCamOffsetX.pos, charDeathCamOffsetY.pos],
cameraZoom: charDeathCamZoom.pos,
preTransitionDelay: charDeathTransDelay.pos
} : null;

charDeathBox.disabled = !charHasDeathData.selected;
}

charDeathCamOffsetX.onChange = charDeathCamOffsetY.onChange = function(_) {
if (char.deathData != null) char.deathData.cameraOffsets = [charDeathCamOffsetX.pos, charDeathCamOffsetY.pos];
}

charDeathCamZoom.onChange = function(_) {
if (char.deathData != null) char.deathData.cameraZoom = charDeathCamZoom.pos;
}

charDeathTransDelay.onChange = function(_) {
if (char.deathData != null) char.deathData.preTransitionDelay = charDeathTransDelay.pos;
}
}
}
7 changes: 7 additions & 0 deletions source/funkin/ui/debug/char/pages/CharCreatorGameplayPage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage
updateCharPerStageData();

dialogMap.set(Animation, new AddAnimDialog(this, currentCharacter));
dialogMap.set(Data, new CharMetadataDialog(this, currentCharacter));
dialogMap.set(Ghost, new GhostSettingsDialog(this));
dialogMap.set(Health, new HealthIconDialog(this, currentCharacter));

Expand Down Expand Up @@ -147,12 +148,14 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage
}

var checkAnim:MenuCheckBox = new MenuCheckBox();
var checkData:MenuCheckBox = new MenuCheckBox();
var checkHealth:MenuCheckBox = new MenuCheckBox();
var checkGhost:MenuCheckBox = new MenuCheckBox();

override public function fillUpPageSettings(item:haxe.ui.containers.menus.Menu)
{
item.addComponent(checkAnim);
item.addComponent(checkData);
item.addComponent(checkHealth);
item.addComponent(checkGhost);
}
Expand Down Expand Up @@ -246,6 +249,7 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage
stageDropdown.dataSource.add({text: aught});

checkAnim.text = "Animation Data";
checkData.text = "Character Metadata";
checkHealth.text = "Health Icon Data";
checkGhost.text = "Ghost Settings";

Expand Down Expand Up @@ -299,6 +303,9 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage
checkAnim.onChange = function(_) {
dialogMap[Animation].hidden = !checkAnim.selected;
}
checkData.onChange = function(_) {
dialogMap[Data].hidden = !checkData.selected;
}
checkHealth.onChange = function(_) {
dialogMap[Health].hidden = !checkHealth.selected;
}
Expand Down
7 changes: 7 additions & 0 deletions source/funkin/ui/debug/char/util/CharacterUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ class CharacterUtil
default: // nothing, what the fuck are you even doing
}

char.characterCameraOffsets = other.characterCameraOffsets.copy();
char.globalOffsets = other.globalOffsets.copy();
char.characterFlipX = other.characterFlipX;
char.characterScale = other.characterScale;
char.deathData = other.deathData;

for (anim in other.animations)
{
Expand Down Expand Up @@ -109,9 +113,12 @@ class CharacterUtil
default: // nuthin
}

char.characterCameraOffsets = data.cameraOffsets ?? [0, 0];
char.globalOffsets = data.offsets ?? [0, 0];
char.characterFlipX = data.flipX ?? false;
char.characterScale = data.scale ?? 1;
char.deathData = data.death;
char.holdTimer = data.singTime;

for (anim in data.animations)
{
Expand Down

0 comments on commit 54654ea

Please sign in to comment.