Skip to content

Commit

Permalink
more works on custom player files
Browse files Browse the repository at this point in the history
  • Loading branch information
KoloInDaCrib committed Nov 24, 2024
1 parent 43c1779 commit 6194bb5
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class FreeplayDJAnimsDialog extends DefaultPageDialog
return;
}

if (djAnimList.safeSelectedItem.text == djAnimName.text) // update instead of add
if ((djAnimList.safeSelectedItem?.text ?? "") == djAnimName.text) // update instead of add
{
var animData = daPage.djAnims[daPage.currentDJAnimation];

Expand All @@ -70,6 +70,7 @@ class FreeplayDJAnimsDialog extends DefaultPageDialog

djAnimList.dataSource.add({text: djAnimName.text});
djAnimList.selectedIndex = daPage.djAnims.length - 1;
daPage.changeDJAnimation(djAnimList.selectedIndex - daPage.currentDJAnimation);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class AddPlayerFilesDialog extends DefaultWizardDialog

override public function isNextStepAvailable():Bool
{
params.freeplayFile = null;
params.charSelectFile = null;

// we skippin if we aint even doin these
if (addAssetsBox.disabled) return true;

Expand Down Expand Up @@ -73,7 +76,7 @@ class AddPlayerFilesDialog extends DefaultWizardDialog

public function typeCheck(uploadBoxes:Array<UploadAssetsBox>):Bool
{
var allFiles = [params.charSelectFile, params.freeplayFile];
var allFiles = [];

for (i in 0...uploadBoxes.length)
{
Expand Down Expand Up @@ -145,7 +148,7 @@ class AddPlayerFilesDialog extends DefaultWizardDialog
}
}

if (hasAnimData && hasSpritemapData && hasImageData) allFiles[i] = {name: zipPath, bytes: zipBytes};
if (hasAnimData && hasSpritemapData && hasImageData) allFiles.push({name: zipPath, bytes: zipBytes});

if (!(hasAnimData && hasSpritemapData && hasImageData))
{
Expand All @@ -154,6 +157,9 @@ class AddPlayerFilesDialog extends DefaultWizardDialog
}
}

params.charSelectFile = allFiles[0];
params.freeplayFile = allFiles[1];

return true;
}
}
31 changes: 30 additions & 1 deletion source/funkin/ui/debug/char/components/wizard/ConfirmDialog.hx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,42 @@ class ConfirmDialog extends DefaultWizardDialog
while (viewAllAssets.childComponents.length > 0)
viewAllAssets.removeComponent(viewAllAssets.childComponents[0]);

for (file in params.files)
var labelFiles = new Label();
labelFiles.text = "Files:";
viewAllAssets.addComponent(labelFiles);

var allFiles = [];
if (params.files.length > 0) allFiles = allFiles.concat(params.files);
if (params.charSelectFile != null) allFiles.push(params.charSelectFile);
if (params.freeplayFile != null) allFiles.push(params.freeplayFile);

if (allFiles.length == 0) labelFiles.text += " None";

for (file in allFiles)
{
var fname = new Label();
fname.text = file.name;
fname.percentWidth = 100;
viewAllAssets.addComponent(fname);
}

var labelImports = new Label();
labelImports.text = "Imports:" + (params.importedCharacter == null && params.importedPlayerData == null ? " None" : "");
viewAllAssets.addComponent(labelImports);

if (params.importedCharacter != null)
{
var charImport = new Label();
charImport.text = "Character: " + params.importedCharacter;
viewAllAssets.addComponent(charImport);
}

if (params.importedPlayerData != null)
{
var playerImport = new Label();
playerImport.text = "Player Data: " + params.importedPlayerData;
viewAllAssets.addComponent(playerImport);
}
}

override public function isNextStepAvailable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ using StringTools;

@:access(funkin.ui.debug.char.CharCreatorState)
@:access(funkin.ui.debug.char.pages.CharCreatorSelectPage)
@:access(funkin.ui.debug.char.pages.CharCreatorFreeplayPage)
class CharCreatorImportExportHandler
{
public static function importCharacter(state:CharCreatorState, charId:String):Void
Expand Down Expand Up @@ -112,6 +113,18 @@ class CharCreatorImportExportHandler
// zipEntries.push(FileUtil.makeZIPEntryFromBytes('images/freeplay/icons/${Path.withoutDirectory(file.name)}', file.bytes));
// }

var charSelectZipName = Path.withoutDirectory(selectPage.data.charSelectFile.name.replace(".zip", ""));
for (file in FileUtil.readZIPFromBytes(selectPage.data.charSelectFile.bytes))
{
zipEntries.push(FileUtil.makeZIPEntryFromBytes('images/charSelect/${charSelectZipName}/${Path.withoutDirectory(file.fileName)}', file.data));
}

var freeplayDJZipName = Path.withoutDirectory(freeplayPage.data.freeplayFile.name.replace(".zip", ""));
for (file in FileUtil.readZIPFromBytes(freeplayPage.data.freeplayFile.bytes))
{
zipEntries.push(FileUtil.makeZIPEntryFromBytes('images/freeplay/${freeplayDJZipName}/${Path.withoutDirectory(file.fileName)}', file.data));
}

var playerData:PlayerData = new PlayerData();
playerData.name = "Unknown";
playerData.ownedChars = selectPage.ownedCharacters;
Expand All @@ -121,9 +134,11 @@ class CharCreatorImportExportHandler
@:privateAccess
{
playerData.freeplayDJ = new PlayerFreeplayDJData();
playerData.freeplayDJ.assetPath = "freeplay/" + freeplayDJZipName;
playerData.freeplayDJ.text1 = freeplayPage.bgText1;
playerData.freeplayDJ.text2 = freeplayPage.bgText2;
playerData.freeplayDJ.text3 = freeplayPage.bgText3;
playerData.freeplayDJ.animations = freeplayPage.djAnims.copy();
}

playerData.charSelect = new PlayerCharSelectData(selectPage.position);
Expand Down
20 changes: 10 additions & 10 deletions source/funkin/ui/debug/char/pages/CharCreatorFreeplayPage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -144,24 +144,24 @@ class CharCreatorFreeplayPage extends CharCreatorDefaultPage
var dialog:FreeplayDJAnimsDialog = cast dialogMap[FreeplayDJAnimations];
if (dialog.djAnimList.selectedIndex != currentDJAnimation) dialog.djAnimList.selectedIndex = currentDJAnimation;

dialog.djAnimName.text = djAnims[currentDJAnimation].name;
dialog.djAnimPrefix.text = djAnims[currentDJAnimation].prefix;
dialog.djAnimLooped.selected = djAnims[currentDJAnimation].looped;
dialog.djAnimName.text = djAnims[currentDJAnimation]?.name ?? "";
dialog.djAnimPrefix.text = djAnims[currentDJAnimation]?.prefix ?? "";
dialog.djAnimLooped.selected = djAnims[currentDJAnimation]?.looped ?? false;

dialog.djAnimOffsetX.pos = djAnims[currentDJAnimation].offsets[0] ?? 0.0;
dialog.djAnimOffsetY.pos = djAnims[currentDJAnimation].offsets[1] ?? 0.0;
dialog.djAnimOffsetX.pos = djAnims[currentDJAnimation]?.offsets[0] ?? 0.0;
dialog.djAnimOffsetY.pos = djAnims[currentDJAnimation]?.offsets[1] ?? 0.0;

playDJAnimation();
}

function playDJAnimation()
{
labelAnimName.text = djAnims[currentDJAnimation].name;
labelAnimOffsetX.text = "" + (djAnims[currentDJAnimation].offsets[0] ?? 0.0);
labelAnimOffsetY.text = "" + (djAnims[currentDJAnimation].offsets[1] ?? 0.0);
labelAnimName.text = djAnims[currentDJAnimation]?.name ?? "None";
labelAnimOffsetX.text = "" + (djAnims[currentDJAnimation]?.offsets[0] ?? 0.0);
labelAnimOffsetY.text = "" + (djAnims[currentDJAnimation]?.offsets[1] ?? 0.0);

dj.playAnimation(djAnims[currentDJAnimation].prefix, true);
dj.offset.set(djAnims[currentDJAnimation].offsets[0] ?? 0.0, djAnims[currentDJAnimation].offsets[1] ?? 0.0);
dj.playAnimation(djAnims[currentDJAnimation]?.prefix ?? "", true);
dj.offset.set(djAnims[currentDJAnimation]?.offsets[0] ?? 0.0, djAnims[currentDJAnimation]?.offsets[1] ?? 0.0);
}

function changeDJAnimationOffsets(xOff:Float = 0, yOff:Float = 0)
Expand Down

0 comments on commit 6194bb5

Please sign in to comment.