From 0446f4255399096881b7a29822589328878d68bd Mon Sep 17 00:00:00 2001 From: Kolo <67389779+JustKolosaki@users.noreply.github.com> Date: Thu, 7 Nov 2024 20:17:39 +0100 Subject: [PATCH] starting to work on player data pages --- art | 2 +- .../funkin/ui/debug/char/CharCreatorState.hx | 4 +- .../char/handlers/CharCreatorStartupWizard.hx | 4 + .../char/pages/CharCreatorGameplayPage.hx | 207 ++++++++-------- .../debug/char/pages/CharCreatorSelectPage.hx | 228 +++++++++++++++++- 5 files changed, 333 insertions(+), 112 deletions(-) diff --git a/art b/art index fbd3e3df77..66572f85d8 160000 --- a/art +++ b/art @@ -1 +1 @@ -Subproject commit fbd3e3df77734606d88516770b71b56e6fa04bce +Subproject commit 66572f85d826ce2ec1d45468c12733b161237ffa diff --git a/source/funkin/ui/debug/char/CharCreatorState.hx b/source/funkin/ui/debug/char/CharCreatorState.hx index 8ccb71126c..e4a3b6f407 100644 --- a/source/funkin/ui/debug/char/CharCreatorState.hx +++ b/source/funkin/ui/debug/char/CharCreatorState.hx @@ -100,6 +100,7 @@ class CharCreatorState extends UIState function setupUICallbacks() { menubarOptionGameplay.onChange = function(_) switchToPage(Gameplay); + menubarOptionCharSelect.onChange = function(_) switchToPage(CharacterSelect); menubarItemExport.onClick = _ -> this.exportCharacter(); } @@ -126,6 +127,7 @@ class CharCreatorState extends UIState pages.clear(); if (params.generateCharacter) pages.set(Gameplay, new CharCreatorGameplayPage(this, params)); + if (params.generatePlayerData) pages.set(CharacterSelect, new CharCreatorSelectPage(this, params)); menubarOptionGameplay.disabled = !params.generateCharacter; menubarOptionCharSelect.disabled = menubarOptionFreeplay.disabled = menubarOptionResults.disabled = !params.generatePlayerData; @@ -150,7 +152,7 @@ class CharCreatorState extends UIState for (box in [bottomBarLeftBox, bottomBarMiddleBox, bottomBarRightBox, menubarMenuSettings]) { while (box.childComponents.length > 0) - box.removeComponent(box.childComponents[0]); + box.removeComponent(box.childComponents[0], false); } remove(selectedPage); diff --git a/source/funkin/ui/debug/char/handlers/CharCreatorStartupWizard.hx b/source/funkin/ui/debug/char/handlers/CharCreatorStartupWizard.hx index 5762d9dedc..f7669142af 100644 --- a/source/funkin/ui/debug/char/handlers/CharCreatorStartupWizard.hx +++ b/source/funkin/ui/debug/char/handlers/CharCreatorStartupWizard.hx @@ -21,6 +21,8 @@ class CharCreatorStartupWizard generatePlayerData: false, renderType: CharacterRenderType.Sparrow, files: [], + charSelectFile: null, + freeplayFile: null, importedCharacter: null } @@ -63,6 +65,8 @@ typedef WizardGenerateParams = var generatePlayerData:Bool; var renderType:CharacterRenderType; var files:Array; + var charSelectFile:WizardFile; + var freeplayFile:WizardFile; @:optional var importedCharacter:String; } diff --git a/source/funkin/ui/debug/char/pages/CharCreatorGameplayPage.hx b/source/funkin/ui/debug/char/pages/CharCreatorGameplayPage.hx index c35fe02050..f6a8a311d8 100644 --- a/source/funkin/ui/debug/char/pages/CharCreatorGameplayPage.hx +++ b/source/funkin/ui/debug/char/pages/CharCreatorGameplayPage.hx @@ -59,13 +59,9 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage dialogMap.set(Ghost, new GhostSettingsDialog(this)); dialogMap.set(Health, new HealthIconDialog(this, currentCharacter)); - // defaults for UI - labelAnimName.text = "None"; - labelAnimOffsetX.text = labelAnimOffsetY.text = "0"; - labelCharType.text = "BF"; - var animDialog = cast(dialogMap[Animation], AddAnimDialog); animDialog.updateDropdown(); + generateUI(); } override public function onDialogUpdate(dialog:DefaultPageDialog) @@ -97,104 +93,33 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage var labelAnimOffsetX:Label = new Label(); var labelAnimOffsetY:Label = new Label(); var labelCharType:Label = new Label(); + var stageDropdown:DropDown = new DropDown(); + + final RULE_HEIGHT:Int = 80; override public function fillUpBottomBar(left:Box, middle:Box, right:Box) { // ==================left================== - labelAnimName.styleNames = "infoText"; - labelAnimName.verticalAlign = "center"; - labelAnimName.tooltip = "Left Click to play the Next Animation"; - left.addComponent(labelAnimName); - var leftRule1 = new VerticalRule(); - leftRule1.percentHeight = 80; - left.addComponent(leftRule1); + var leftRule2 = new VerticalRule(); - labelAnimOffsetX.styleNames = "infoText"; - labelAnimOffsetX.verticalAlign = "center"; - labelAnimOffsetX.tooltip = "Left/Right Click to Increase/Decrease the Horizontal Offset."; - left.addComponent(labelAnimOffsetX); + leftRule1.percentHeight = leftRule2.percentHeight = RULE_HEIGHT; - var leftRule2 = new VerticalRule(); - leftRule2.percentHeight = 80; + left.addComponent(labelAnimName); + left.addComponent(leftRule1); + left.addComponent(labelAnimOffsetX); left.addComponent(leftRule2); - - labelAnimOffsetY.styleNames = "infoText"; - labelAnimOffsetY.verticalAlign = "center"; - labelAnimOffsetY.tooltip = "Left/Right Click to Increase/Decrease the Vertical Offset."; left.addComponent(labelAnimOffsetY); // ==================middle================== // ==================right================== - var typesArray = [BF, GF, DAD]; + var rightRule = new VerticalRule(); + rightRule.percentHeight = RULE_HEIGHT; - labelCharType.styleNames = "infoText"; - labelCharType.verticalAlign = "center"; - labelCharType.tooltip = "Left Click/Right Click to switch to the Next/Previous Character Mode."; right.addComponent(labelCharType); - - var rightRule = new VerticalRule(); - rightRule.percentHeight = 80; right.addComponent(rightRule); - - var dropdown = new DropDown(); - dropdown.text = "Select Stage"; - dropdown.dropdownVerticalPosition = "top"; - dropdown.width = 125; - dropdown.selectedItem = curStage; - right.addComponent(dropdown); - - var stages = StageRegistry.instance.listEntryIds(); - stages.sort(funkin.util.SortUtil.alphabetically); - for (aught in stages) - dropdown.dataSource.add({text: aught}); - - // ==================callback bs================== - - labelAnimName.onClick = function(_) { - var drop = cast(dialogMap[Animation], AddAnimDialog).charAnimDropdown; - if (drop.selectedIndex == -1) return; - - var id = drop.selectedIndex + 1; - if (id >= drop.dataSource.size) id = 0; - drop.selectedIndex = id; - currentCharacter.playAnimation(currentCharacter.animations[drop.selectedIndex].name); - } - - labelAnimName.onRightClick = function(_) { - var drop = cast(dialogMap[Animation], AddAnimDialog).charAnimDropdown; - if (drop.selectedIndex == -1) return; - - var id = drop.selectedIndex - 1; - if (id < 0) id = drop.dataSource.size - 1; - drop.selectedIndex = id; - currentCharacter.playAnimation(currentCharacter.animations[drop.selectedIndex].name); - } - - labelAnimOffsetX.onClick = _ -> changeCharAnimOffset(5); - labelAnimOffsetX.onRightClick = _ -> changeCharAnimOffset(-5); - labelAnimOffsetY.onClick = _ -> changeCharAnimOffset(0, 5); - labelAnimOffsetY.onRightClick = _ -> changeCharAnimOffset(0, -5); - - labelCharType.onClick = function(_) { - var idx = typesArray.indexOf(currentCharacter.characterType); - idx++; - if (idx >= typesArray.length) idx = 0; - updateCharPerStageData(typesArray[idx]); - labelCharType.text = Std.string(currentCharacter.characterType); - } - labelCharType.onRightClick = function(_) { - var idx = typesArray.indexOf(currentCharacter.characterType); - idx--; - if (idx < 0) idx = typesArray.length - 1; - updateCharPerStageData(typesArray[idx]); - labelCharType.text = Std.string(currentCharacter.characterType); - } - dropdown.onChange = function(_) { - curStage = dropdown.selectedItem?.text ?? curStage; - updateCharPerStageData(currentCharacter.characterType); - } + right.addComponent(stageDropdown); } function changeCharAnimOffset(changeX:Int = 0, changeY:Int = 0) @@ -217,27 +142,14 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage labelAnimOffsetY.text = "" + newOffsets[1]; } + var checkAnim:MenuCheckBox = new MenuCheckBox(); + var checkHealth:MenuCheckBox = new MenuCheckBox(); + var checkGhost:MenuCheckBox = new MenuCheckBox(); + override public function fillUpPageSettings(item:haxe.ui.containers.menus.Menu) { - var checkAnim = new MenuCheckBox(); - checkAnim.text = "Animation Data"; - checkAnim.onChange = function(_) { - dialogMap[Animation].hidden = !checkAnim.selected; - } item.addComponent(checkAnim); - - var checkHealth = new MenuCheckBox(); - checkHealth.text = "Health Icon Data"; - checkHealth.onChange = function(_) { - dialogMap[Health].hidden = !checkHealth.selected; - } item.addComponent(checkHealth); - - var checkGhost = new MenuCheckBox(); - checkGhost.text = "Ghost Settings"; - checkGhost.onChange = function(_) { - dialogMap[Ghost].hidden = !checkGhost.selected; - } item.addComponent(checkGhost); } @@ -304,6 +216,93 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage sortAssets(); } + function generateUI() + { + // defaults for UI + labelAnimName.text = "None"; + labelAnimOffsetX.text = labelAnimOffsetY.text = "0"; + labelCharType.text = "BF"; + + labelAnimName.styleNames = labelAnimOffsetX.styleNames = labelAnimOffsetY.styleNames = labelCharType.styleNames = "infoText"; + labelAnimName.verticalAlign = labelAnimOffsetX.verticalAlign = labelAnimOffsetY.verticalAlign = labelCharType.verticalAlign = "center"; + + labelAnimName.tooltip = "Left Click to play the Next Animation"; + labelAnimOffsetX.tooltip = "Left/Right Click to Increase/Decrease the Horizontal Offset."; + labelAnimOffsetY.tooltip = "Left/Right Click to Increase/Decrease the Vertical Offset."; + labelCharType.tooltip = "Left Click/Right Click to switch to the Next/Previous Character Mode."; + + stageDropdown.text = "Select Stage"; + stageDropdown.dropdownVerticalPosition = "top"; + stageDropdown.width = 125; + stageDropdown.selectedItem = curStage; + + var stages = StageRegistry.instance.listEntryIds(); + stages.sort(funkin.util.SortUtil.alphabetically); + for (aught in stages) + stageDropdown.dataSource.add({text: aught}); + + checkAnim.text = "Animation Data"; + checkHealth.text = "Health Icon Data"; + checkGhost.text = "Ghost Settings"; + + // ==================callback bs================== + + labelAnimName.onClick = function(_) { + var drop = cast(dialogMap[Animation], AddAnimDialog).charAnimDropdown; + if (drop.selectedIndex == -1) return; + + var id = drop.selectedIndex + 1; + if (id >= drop.dataSource.size) id = 0; + drop.selectedIndex = id; + currentCharacter.playAnimation(currentCharacter.animations[drop.selectedIndex].name); + } + + labelAnimName.onRightClick = function(_) { + var drop = cast(dialogMap[Animation], AddAnimDialog).charAnimDropdown; + if (drop.selectedIndex == -1) return; + + var id = drop.selectedIndex - 1; + if (id < 0) id = drop.dataSource.size - 1; + drop.selectedIndex = id; + currentCharacter.playAnimation(currentCharacter.animations[drop.selectedIndex].name); + } + + labelAnimOffsetX.onClick = _ -> changeCharAnimOffset(5); + labelAnimOffsetX.onRightClick = _ -> changeCharAnimOffset(-5); + labelAnimOffsetY.onClick = _ -> changeCharAnimOffset(0, 5); + labelAnimOffsetY.onRightClick = _ -> changeCharAnimOffset(0, -5); + + var typesArray = [BF, GF, DAD]; + labelCharType.onClick = function(_) { + var idx = typesArray.indexOf(currentCharacter.characterType); + idx++; + if (idx >= typesArray.length) idx = 0; + updateCharPerStageData(typesArray[idx]); + labelCharType.text = Std.string(currentCharacter.characterType); + } + labelCharType.onRightClick = function(_) { + var idx = typesArray.indexOf(currentCharacter.characterType); + idx--; + if (idx < 0) idx = typesArray.length - 1; + updateCharPerStageData(typesArray[idx]); + labelCharType.text = Std.string(currentCharacter.characterType); + } + stageDropdown.onChange = function(_) { + curStage = stageDropdown.selectedItem?.text ?? curStage; + updateCharPerStageData(currentCharacter.characterType); + } + + checkAnim.onChange = function(_) { + dialogMap[Animation].hidden = !checkAnim.selected; + } + checkHealth.onChange = function(_) { + dialogMap[Health].hidden = !checkHealth.selected; + } + checkGhost.onChange = function(_) { + dialogMap[Ghost].hidden = !checkGhost.selected; + } + } + function sortAssets() { sort(funkin.util.SortUtil.byZIndex, flixel.util.FlxSort.ASCENDING); diff --git a/source/funkin/ui/debug/char/pages/CharCreatorSelectPage.hx b/source/funkin/ui/debug/char/pages/CharCreatorSelectPage.hx index 591e349071..1bd8f58128 100644 --- a/source/funkin/ui/debug/char/pages/CharCreatorSelectPage.hx +++ b/source/funkin/ui/debug/char/pages/CharCreatorSelectPage.hx @@ -1,16 +1,80 @@ package funkin.ui.debug.char.pages; +import funkin.audio.FunkinSound; +import funkin.data.freeplay.player.PlayerData; +import funkin.data.freeplay.player.PlayerRegistry; import funkin.graphics.adobeanimate.FlxAtlasSprite; +import funkin.graphics.FunkinSprite; +import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup; +import flixel.group.FlxSpriteGroup; +import flixel.tweens.FlxEase; +import flixel.tweens.FlxTween; import flixel.FlxSprite; import openfl.display.BlendMode; +import openfl.filters.ShaderFilter; class CharCreatorSelectPage extends CharCreatorDefaultPage { - override public function new(state:CharCreatorState) + var data:WizardGenerateParams; + + var nametag:FlxSprite; + var transitionGradient:FlxSprite; + var autoFollow:Bool = false; + var availableChars:Map = new Map(); + var fadeShader:funkin.graphics.shaders.BlueFade = new funkin.graphics.shaders.BlueFade(); + + override public function new(state:CharCreatorState, data:WizardGenerateParams) { super(state); + loadAvailableCharacters(); + this.data = data; // copied sum code LOL + initBackground(); + + // gf and player code doodoo + + nametag = new FlxSprite(); + add(nametag); + + nametag.scrollFactor.set(); + + initCursors(); + initSounds(); + + initLocks(); + + FlxTween.color(cursor, 0.2, 0xFFFFFF00, 0xFFFFCC00, {type: PINGPONG}); + + // FlxG.debugger.track(cursor); + + var fadeShaderFilter:ShaderFilter = new ShaderFilter(fadeShader); + FlxG.camera.filters = [fadeShaderFilter]; + + var temp:FlxSprite = new FlxSprite(); + temp.loadGraphic(Paths.image('charSelect/placement')); + add(temp); + temp.alpha = 0.0; + + // FlxG.debugger.track(temp, "tempBG"); + + transitionGradient = new FlxSprite(0, 0).loadGraphic(Paths.image('freeplay/transitionGradient')); + transitionGradient.scale.set(1280, 1); + transitionGradient.flipY = true; + transitionGradient.updateHitbox(); + FlxTween.tween(transitionGradient, {y: -720}, 1, {ease: FlxEase.expoOut}); + add(transitionGradient); + + fadeShader.fade(0.0, 1.0, 0.8, {ease: FlxEase.quadOut}); + + var blackScreen = new FunkinSprite().makeSolidColor(FlxG.width * 2, FlxG.height * 2, 0xFF000000); + blackScreen.x = -(FlxG.width * 0.5); + blackScreen.y = -(FlxG.height * 0.5); + add(blackScreen); + } + + function initBackground() + { var bg:FlxSprite = new FlxSprite(-153, -140); bg.loadGraphic(Paths.image('charSelect/charSelectBG')); bg.scrollFactor.set(0.1, 0.1); @@ -51,9 +115,10 @@ class CharCreatorSelectPage extends CharCreatorDefaultPage var charLightGF:FlxSprite = new FlxSprite(180, 240); charLightGF.loadGraphic(Paths.image('charSelect/charLight')); add(charLightGF); + } - // gf and player code doodoo - + function initForeground() + { var speakers:FlxAtlasSprite = new FlxAtlasSprite(0, 0, Paths.animateAtlas("charSelect/charSelectSpeakers")); speakers.anim.play(""); speakers.anim.onComplete.add(function() { @@ -88,10 +153,161 @@ class CharCreatorSelectPage extends CharCreatorDefaultPage chooseDipshit.scrollFactor.set(); dipshitBacking.scrollFactor.set(); dipshitBlur.scrollFactor.set(); + } + + var cursor:FlxSprite; + var cursorBlue:FlxSprite; + var cursorDarkBlue:FlxSprite; + var grpCursors:FlxTypedSpriteGroup; // using flxtypedgroup raises an error + var cursorConfirmed:FlxSprite; + var cursorDenied:FlxSprite; + + function initCursors() + { + grpCursors = new FlxTypedSpriteGroup(); + add(grpCursors); + + cursor = new FlxSprite(0, 0); + cursor.loadGraphic(Paths.image('charSelect/charSelector')); + cursor.color = 0xFFFFFF00; + + // FFCC00 + + cursorBlue = new FlxSprite(0, 0); + cursorBlue.loadGraphic(Paths.image('charSelect/charSelector')); + cursorBlue.color = 0xFF3EBBFF; + + cursorDarkBlue = new FlxSprite(0, 0); + cursorDarkBlue.loadGraphic(Paths.image('charSelect/charSelector')); + cursorDarkBlue.color = 0xFF3C74F7; + + cursorBlue.blend = BlendMode.SCREEN; + cursorDarkBlue.blend = BlendMode.SCREEN; + + cursorConfirmed = new FlxSprite(0, 0); + cursorConfirmed.scrollFactor.set(); + cursorConfirmed.frames = Paths.getSparrowAtlas("charSelect/charSelectorConfirm"); + cursorConfirmed.animation.addByPrefix("idle", "cursor ACCEPTED instance 1", 24, true); + cursorConfirmed.visible = false; + add(cursorConfirmed); + + cursorDenied = new FlxSprite(0, 0); + cursorDenied.scrollFactor.set(); + cursorDenied.frames = Paths.getSparrowAtlas("charSelect/charSelectorDenied"); + cursorDenied.animation.addByPrefix("idle", "cursor DENIED instance 1", 24, false); + cursorDenied.visible = false; + add(cursorDenied); + + grpCursors.add(cursorDarkBlue); + grpCursors.add(cursorBlue); + grpCursors.add(cursor); + + cursor.scrollFactor.set(); + cursorBlue.scrollFactor.set(); + cursorDarkBlue.scrollFactor.set(); + } + + var selectSound:FunkinSound; + var lockedSound:FunkinSound; + var staticSound:FunkinSound; + + function initSounds() + { + selectSound = new FunkinSound(); + selectSound.loadEmbedded(Paths.sound('CS_select')); + selectSound.pitch = 1; + selectSound.volume = 0.7; + + FlxG.sound.defaultSoundGroup.add(selectSound); + FlxG.sound.list.add(selectSound); + + lockedSound = new FunkinSound(); + lockedSound.loadEmbedded(Paths.sound('CS_locked')); + lockedSound.pitch = 1; + lockedSound.volume = 1.; + + FlxG.sound.defaultSoundGroup.add(lockedSound); + FlxG.sound.list.add(lockedSound); + + staticSound = new FunkinSound(); + staticSound.loadEmbedded(Paths.sound('static loop')); + staticSound.pitch = 1; + staticSound.looped = true; + staticSound.volume = 0.6; + + FlxG.sound.defaultSoundGroup.add(staticSound); + FlxG.sound.list.add(staticSound); + } + + var grpIcons:FlxSpriteGroup; + final grpXSpread:Float = 107; + final grpYSpread:Float = 127; + + function initLocks():Void + { + grpIcons = new FlxSpriteGroup(); + add(grpIcons); + + for (i in 0...9) + { + if (availableChars.exists(i)) + { + var path:String = availableChars.get(i); + var temp:PixelatedIcon = new PixelatedIcon(0, 0); + temp.setCharacter(path); + temp.setGraphicSize(128, 128); + temp.updateHitbox(); + temp.ID = 0; + grpIcons.add(temp); + } + } + + updateIconPositions(); + grpIcons.scrollFactor.set(); + + for (index => member in grpIcons.members) + { + member.y += 300; + FlxTween.tween(member, {y: member.y - 300}, 1, {ease: FlxEase.expoOut}); + } + } + + function updateIconPositions() + { + grpIcons.x = 450; + grpIcons.y = 120; + for (index => member in grpIcons.members) + { + var posX:Float = (index % 3); + var posY:Float = Math.floor(index / 3); + + member.x = posX * grpXSpread; + member.y = posY * grpYSpread; + + member.x += grpIcons.x; + member.y += grpIcons.y; + } + } + + function loadAvailableCharacters():Void + { + var playerIds:Array = PlayerRegistry.instance.listEntryIds(); + + for (playerId in playerIds) + { + var player:Null = PlayerRegistry.instance.fetchEntry(playerId); + if (player == null) continue; + var playerData = player.getCharSelectData(); + if (playerData == null) continue; - // nametag = new Nametag(); - // add(nametag); + var targetPosition:Int = playerData.position ?? 0; + while (availableChars.exists(targetPosition)) + { + targetPosition += 1; + } - // nametag.scrollFactor.set(); + trace('Placing player ${playerId} at position ${targetPosition}'); + availableChars.set(targetPosition, playerId); + } } }