Skip to content

Commit

Permalink
buncha misc stuff before starting results music
Browse files Browse the repository at this point in the history
i think we're about 90% done with the editor, hooray!!!
  • Loading branch information
KoloInDaCrib committed Dec 7, 2024
1 parent 5ad32ad commit 060bdb3
Show file tree
Hide file tree
Showing 12 changed files with 309 additions and 79 deletions.
4 changes: 2 additions & 2 deletions source/funkin/ui/debug/char/CharCreatorCharacter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ class CharCreatorCharacter extends Bopper
public function addAnimation(name:String, prefix:String, offsets:Array<Float>, indices:Array<Int>, frameRate:Int = 24, looped:Bool = false,
flipX:Bool = false, flipY:Bool = false)
{
if (getAnimationData(name) != null) return true; // i mean i guess???

if (renderType != CharacterRenderType.AnimateAtlas)
{
if (indices.length > 0) animation.addByIndices(name, prefix, indices, "", frameRate, looped, flipX, flipY);
Expand All @@ -157,6 +155,8 @@ class CharCreatorCharacter extends Bopper
if (!atlasCharacter.hasAnimation(prefix)) return false;
}

if (getAnimationData(name) != null) removeAnimation(name);

animations.push(
{
name: name,
Expand Down
16 changes: 7 additions & 9 deletions source/funkin/ui/debug/char/CharCreatorState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import flixel.FlxG;
/**
* also made by kolo
* in collaboration with lemz!
* my second slightly more disappointing son
* most of the functionality is moved to pages so go check them out!
*/
@:build(haxe.ui.ComponentBuilder.build("assets/exclude/data/ui/char-creator/main-view.xml"))
class CharCreatorState extends UIState
Expand Down Expand Up @@ -57,16 +57,13 @@ class CharCreatorState extends UIState

root.scrollFactor.set();
root.cameras = [camHUD];
root.width = FlxG.width;
root.height = FlxG.height;

WindowManager.instance.container = root;
// Screen.instance.addComponent(root);

Cursor.show();

// I feel like there should be more editor themes
// I don't dislike Artistic expression or anythin I had simply heard it a million times while making da editors and I'm getting a bit tired of it
// I don't dislike Artistic Expression or anythin I had simply heard it a million times while making da editors and I'm getting a bit tired of it
// plus it's called *chart*EditorLoop so CHECKMATE liberals hehe -Kolo
Conductor.instance.forceBPM(null);
FunkinSound.playMusic('chartEditorLoop',
Expand Down Expand Up @@ -123,7 +120,6 @@ class CharCreatorState extends UIState
function wizardComplete(params:WizardGenerateParams):Void
{
// clear da pages sorry chat
remove(selectedPage);
selectedPage = null;
this.params = params;

Expand All @@ -133,6 +129,7 @@ class CharCreatorState extends UIState
var page = allPages.pop();
page.performCleanup();
page.kill();
remove(page, true);
page.destroy();
}

Expand All @@ -146,8 +143,9 @@ class CharCreatorState extends UIState
menubarOptionGameplay.disabled = !params.generateCharacter;
menubarOptionCharSelect.disabled = menubarOptionFreeplay.disabled = menubarOptionResults.disabled = !params.generatePlayerData;

menubarOptionGameplay.selected = menubarOptionCharSelect.selected = menubarOptionFreeplay.selected = menubarOptionResults.selected = false;
(params.generateCharacter ? menubarOptionGameplay : menubarOptionCharSelect).selected = true;
menubarOptionGameplay.selected = (params.generateCharacter);
menubarOptionCharSelect.selected = !menubarOptionGameplay.selected;
menubarOptionFreeplay.selected = menubarOptionResults.selected = false;

switchToPage(params.generateCharacter ? Gameplay : CharacterSelect);
}
Expand Down Expand Up @@ -175,7 +173,7 @@ class CharCreatorState extends UIState
box.removeComponent(box.childComponents[0], false);
}

remove(selectedPage);
remove(selectedPage, true);
selectedPage = pages[page];
add(selectedPage);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import funkin.data.freeplay.style.FreeplayStyleRegistry;
import funkin.data.freeplay.player.PlayerRegistry;
import haxe.ui.components.OptionBox;
import haxe.ui.util.Color;
import funkin.ui.freeplay.FreeplayScore;
import funkin.util.FileUtil;
import flixel.graphics.frames.FlxAtlasFrames;
import flixel.util.FlxColor;
Expand Down Expand Up @@ -48,6 +49,20 @@ class FreeplayStyleDialog extends DefaultPageDialog
buttonNumbers.onClick = _ -> buttonCallbackForField(fieldNumbers);
buttonCapsule.onClick = _ -> buttonCallbackForField(fieldCapsule);

var reloadNums = function(num:ScoreNum) {
var numToString = [];
@:privateAccess
numToString = num.numToString;

for (i in 0...10)
num.animation.addByPrefix(numToString[i], '${numToString[i]} DIGITAL', 24, false);

num.animation.play(numToString[num.digit], true);

num.setGraphicSize(Std.int(num.width * 0.4));
num.updateHitbox();
}

buttonApplyStyle.onClick = function(_) {
if (optionUsePreset.selected)
{
Expand All @@ -62,15 +77,23 @@ class FreeplayStyleDialog extends DefaultPageDialog
daPage.arrowRight.animation.play('shine');

daPage.randomCapsule.applyStyle(daStyle);

daPage.scoreNumbers.forEach(function(num:ScoreNum) {
num.frames = Paths.getSparrowAtlas(daStyle?.getNumbersAssetKey() ?? "digital_numbers");
reloadNums(num);
});

daPage.useStyle = styleID;
}
else if (optionMakeNew.selected)
{
var dadBitmap = BitmapData.fromBytes(CharCreatorUtil.gimmeTheBytes(fieldBGAsset.text?.length > 0 ? fieldBGAsset.text : Paths.image('freeplay/freeplayBGdad')));
var arrowBitmap = BitmapData.fromBytes(CharCreatorUtil.gimmeTheBytes(fieldArrow.text?.length > 0 ? fieldArrow.text : Paths.image('freeplay/freeplaySelector')));
var numbersBitmap = BitmapData.fromBytes(CharCreatorUtil.gimmeTheBytes(fieldNumbers.text?.length > 0 ? fieldNumbers.text : Paths.image('digital_numbers')));
var capsuleBitmap = BitmapData.fromBytes(CharCreatorUtil.gimmeTheBytes(fieldCapsule.text?.length > 0 ? fieldCapsule.text : Paths.image('freeplay/freeplayCapsule/capsule/freeplayCapsule')));

var arrowXML = CharCreatorUtil.gimmeTheBytes(fieldArrow.text.replace(".png", ".xml"));
var numbersXML = CharCreatorUtil.gimmeTheBytes(fieldNumbers.text.replace(".png", ".xml"));
var capsuleXML = CharCreatorUtil.gimmeTheBytes(fieldCapsule.text.replace(".png", ".xml"));

daPage.bgDad.loadGraphic(dadBitmap);
Expand All @@ -83,6 +106,11 @@ class FreeplayStyleDialog extends DefaultPageDialog
daPage.arrowLeft.animation.play('shine');
daPage.arrowRight.animation.play('shine');

daPage.scoreNumbers.forEach(function(num:ScoreNum) {
num.frames = FlxAtlasFrames.fromSparrow(numbersBitmap, numbersXML?.toString() ?? Paths.file("images/digital_numbers.xml"));
reloadNums(num);
});

// overcomplicating capsule stuff
daPage.randomCapsule.capsule.frames = FlxAtlasFrames.fromSparrow(capsuleBitmap,
capsuleXML?.toString() ?? Paths.file("images/freeplay/freeplayCapsule/capsule/freeplayCapsule.xml"));
Expand All @@ -106,6 +134,7 @@ class FreeplayStyleDialog extends DefaultPageDialog

daPage.customStyleData.bgAsset = 'freeplay/freeplayBGdad' + (fieldBGAsset.text?.length > 0 ? '_${daPage.data.characterID}' : "");
daPage.customStyleData.selectorAsset = 'freeplay/freeplaySelector' + (fieldArrow.text?.length > 0 ? '_${daPage.data.characterID}' : "");
daPage.customStyleData.numbersAsset = 'digital_numbers' + (fieldNumbers.text?.length > 0 ? '_${daPage.data.characterID}' : "");
daPage.customStyleData.capsuleAsset = 'freeplay/freeplayCapsule/capsule/freeplayCapsule'
+ (fieldCapsule.text?.length > 0 ? '_${daPage.data.characterID}' : "");
daPage.customStyleData.capsuleTextColors = [deselectColor.toHex(), selectColor.toHex()];
Expand All @@ -121,6 +150,11 @@ class FreeplayStyleDialog extends DefaultPageDialog
});
}
if (daPage.customStyleData.selectorAsset != 'freeplay/freeplaySelector')
{
daPage.styleFiles.push({name: '${daPage.customStyleData.selectorAsset}.png', bytes: numbersBitmap.image.encode(PNG)});
daPage.styleFiles.push({name: '${daPage.customStyleData.selectorAsset}.xml', bytes: numbersXML});
}
if (daPage.customStyleData.selectorAsset != 'digital_numbers')
{
daPage.styleFiles.push({name: '${daPage.customStyleData.selectorAsset}.png', bytes: arrowBitmap.image.encode(PNG)});
daPage.styleFiles.push({name: '${daPage.customStyleData.selectorAsset}.xml', bytes: arrowXML});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ class AddAnimDialog extends DefaultPageDialog
charAnimFramerate.pos = 24;
charAnimOffsetX.pos = charAnimOffsetY.pos = 0;

page.onDialogUpdate(this);
return;
}

var animData = char.getAnimationData(charAnimDropdown.selectedItem.text);
var animData = char.getAnimationData(charAnimDropdown.safeSelectedItem.text);
if (animData == null) return;

charAnimName.text = animData.name;
Expand All @@ -61,14 +60,33 @@ class AddAnimDialog extends DefaultPageDialog
charAnimOffsetY.pos = (animData.offsets != null && animData.offsets.length == 2 ? animData.offsets[1] : 0);

char.playAnimation(charAnimName.text);
page.onDialogUpdate(this);
}

charAnimSave.onClick = function(_) {
if ((charAnimName.text ?? "") == "") return;
if ((charAnimPrefix.text ?? "") == "") return;
if ((charAnimName.text ?? "") == "")
{
CharCreatorUtil.error("Add Animation", "Error: Missing name!");
return;
}
if ((charAnimPrefix.text ?? "") == "")
{
CharCreatorUtil.error("Add Animation", "Error: Missing prefix!");
return;
}

if (char.atlasCharacter != null && !char.atlasCharacter.hasAnimation(charAnimPrefix.text))
{
CharCreatorUtil.error("Add Animation", "Error: Missing prefix!");
return;
}

if (char.atlasCharacter != null && !char.atlasCharacter.hasAnimation(charAnimPrefix.text)) return;
if (char.atlasCharacter == null)
{
char.animation.pause();
char.animation.stop();
}
else
char.atlasCharacter.stopAnimation();

var indices = [];
if (charAnimFrames.text != null && charAnimFrames.text != "")
Expand All @@ -82,23 +100,30 @@ class AddAnimDialog extends DefaultPageDialog
var animAdded:Bool = char.addAnimation(charAnimName.text, charAnimPrefix.text, [charAnimOffsetX.pos, charAnimOffsetY.pos],
(shouldDoIndices ? indices : []), Std.int(charAnimFramerate.pos), charAnimLooped.selected, charAnimFlipX.selected, charAnimFlipY.selected);

if (!animAdded) return;
if (!animAdded)
{
CharCreatorUtil.error("Add Animation", "Error: Problem adding the animation.");
return;
}

if (linkedChar.generatedParams.importedCharacter == null)
if (daPage.ghostId == "")
{
daPage.ghostCharacter.addAnimation(charAnimName.text, charAnimPrefix.text, [charAnimOffsetX.pos, charAnimOffsetY.pos],
(shouldDoIndices ? indices : []), Std.int(charAnimFramerate.pos), charAnimLooped.selected, charAnimFlipX.selected, charAnimFlipY.selected);
}

updateDropdown();
charAnimDropdown.selectedIndex = charAnimDropdown.dataSource.size - 1;
char.playAnimation(charAnimName.text);
}

charAnimDelete.onClick = function(_) {
if ((charAnimName.text ?? "") == "") return;

if (!char.removeAnimation(charAnimName.text)) return;
if (linkedChar.generatedParams.importedCharacter == null) daPage.ghostCharacter.removeAnimation(charAnimName.text);
if (!char.removeAnimation(charAnimName.text))
{
CharCreatorUtil.error("Remove Animation", "Error: Problem removing the animation.");
return;
}
if (daPage.ghostId == "") daPage.ghostCharacter.removeAnimation(charAnimName.text);

updateDropdown();
charAnimDropdown.selectedIndex = charAnimDropdown.dataSource.size - 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import haxe.ui.components.VerticalScroll;
import haxe.ui.data.ArrayDataSource;
import funkin.data.character.CharacterRegistry;
import funkin.util.SortUtil;
import funkin.data.freeplay.player.PlayerRegistry;

@:build(haxe.ui.macros.ComponentMacros.build("assets/exclude/data/ui/char-creator/dialogs/select/playable-character-settings-dialog.xml"))
class PlayableCharacterSettingsDialog extends DefaultPageDialog
Expand All @@ -20,32 +21,35 @@ class PlayableCharacterSettingsDialog extends DefaultPageDialog

var ownedCharBox:AddOwnedCharBox;

override public function new(daPage:CharCreatorDefaultPage)
override public function new(daPage:CharCreatorSelectPage)
{
super(daPage);

ownedCharBox = new AddOwnedCharBox();

ownedCharBox = new AddOwnedCharBox(daPage);
ownedCharsView.addComponent(ownedCharBox);
ownedCharBox.addPlayerDropdowns();
}
}

private class AddOwnedCharBox extends HBox
{
var dropDowns:Array<DropDown> = [];
var daPage:CharCreatorSelectPage;

var addButton:Button = new Button();
var removeButton:Button = new Button();

override public function new()
override public function new(page:CharCreatorSelectPage)
{
super();
daPage = page;

styleString = "border:1px solid $normal-border-color";
percentWidth = 100;
height = 25;
verticalAlign = "center";

var addButton = new Button();
addButton.text = "Add New Box";
var removeButton = new Button();
removeButton.text = "Remove Last Box";

addButton.percentWidth = removeButton.percentWidth = 50;
Expand All @@ -55,19 +59,7 @@ private class AddOwnedCharBox extends HBox
var parentList = this.parentComponent;
if (parentList == null) return;

var newDropDown = new DropDown();
newDropDown.dataSource = new ArrayDataSource();
newDropDown.height = 25;
newDropDown.dropdownHeight = 100;
newDropDown.percentWidth = 100;
newDropDown.verticalAlign = "center";
newDropDown.searchable = true;
var ids = CharacterRegistry.listCharacterIds();
ids.sort(SortUtil.alphabetically);
for (id in ids)
{
newDropDown.dataSource.add({text: id, id: id});
}
var newDropDown = createDropdown();
dropDowns.push(newDropDown);

parentList.addComponentAt(newDropDown, parentList.childComponents.length - 1); // considering this box is last
Expand All @@ -89,11 +81,50 @@ private class AddOwnedCharBox extends HBox
addComponent(removeButton);
}

public function addPlayerDropdowns()
{
var playuh = PlayerRegistry.instance.fetchEntry(daPage.data.importedPlayerData ?? "");
if (playuh != null && this.parentComponent != null)
{
for (thing in playuh.getOwnedCharacterIds())
{
var newDropDown = createDropdown(thing);
dropDowns.push(newDropDown);

this.parentComponent.addComponentAt(newDropDown, this.parentComponent.childComponents.length - 1); // considering this box is last
}
}
}

function createDropdown(?selectSumth:String = "")
{
var newDropDown = new DropDown();
newDropDown.dataSource = new ArrayDataSource();
newDropDown.height = 25;
newDropDown.dropdownHeight = 100;
newDropDown.percentWidth = 100;
newDropDown.verticalAlign = "center";
newDropDown.searchable = true;

var ids = CharacterRegistry.listCharacterIds();
if (daPage.data.generateCharacter && !ids.contains(daPage.data.characterID)) ids.push(daPage.data.characterID);
ids.sort(SortUtil.alphabetically);

for (id in ids)
{
newDropDown.dataSource.add({text: id, id: id});
}

if (selectSumth != null && ids.contains(selectSumth)) newDropDown.selectedIndex = ids.indexOf(selectSumth);

return newDropDown;
}

public function listOwnedCharacters():Array<String>
{
return [
for (dropDown in dropDowns)
dropDown.selectedItem.id
dropDown.safeSelectedItem.id
];
}
}
Loading

0 comments on commit 060bdb3

Please sign in to comment.