diff --git a/assets/preload/data/events/changeChar.json b/assets/preload/data/events/changeChar.json index a101cdd6..4009d278 100644 --- a/assets/preload/data/events/changeChar.json +++ b/assets/preload/data/events/changeChar.json @@ -6,6 +6,6 @@ "dad", "girlfriend" ], - "bf" + "data/characters:json" ] } \ No newline at end of file diff --git a/assets/preload/data/events/changeStage.hx b/assets/preload/data/events/changeStage.hx index 666ff505..d0749e6e 100644 --- a/assets/preload/data/events/changeStage.hx +++ b/assets/preload/data/events/changeStage.hx @@ -16,52 +16,27 @@ function changeStage(stageName) return; } - State.stage.visible = false; - State.stage.active = false; + var lastStage = State.stage; + lastStage.visible = false; + lastStage.active = false; - if (State.stage.script != null) - State.stage.script.safeCall("hideStage"); + if (lastStage.script != null) + lastStage.script.safeCall("hideStage"); stage.visible = true; stage.active = true; - // Setup the layers crap - stage.__existsAddToLayer("bf", State.boyfriendGroup); - stage.__existsAddToLayer("dad", State.dadGroup); - stage.__existsAddToLayer("gf", State.gfGroup); - - stage.applyData(State.boyfriend, State.dad, State.gf); - repositionChar(State.boyfriend, 770, 450); - repositionChar(State.dad, 100, 450); - repositionChar(State.gf, 400, 360); + // Setup the layers and positions crap + stage.setupPlayState(State); if (stage.script != null) stage.script.safeCall("changeStage"); State.defaultCamZoom = stage.data.zoom; State.stageData = stage.data; - State.stage = stage; } -// Reposition correctly the group elements -function repositionChar(char, x, y) -{ - var ogX = char.x; - var ogY = char.y; - - char.setXY(x, y); - - var diffX = char.x - ogX; - var diffY = char.y - ogY; - - char.group.x += diffX; - char.group.y += diffY; - - char.x -= diffX; - char.y -= diffY; -} - var cachedStages = [ "::" => null ]; @@ -97,7 +72,7 @@ function createPost() { cachedStages.set(stage, stageObject); stageObject.visible = false; stageObject.active = false; - State.add(stageObject); + State.stageGroup.add(stageObject); } } diff --git a/assets/preload/data/events/changeStage.json b/assets/preload/data/events/changeStage.json index b9026a15..c446287b 100644 --- a/assets/preload/data/events/changeStage.json +++ b/assets/preload/data/events/changeStage.json @@ -1,6 +1,6 @@ { "description": "Changes the stage to a new one\n\nValue 1: New stage name", "values": [ - "stage" + "data/stages:json" ] } \ No newline at end of file diff --git a/assets/preload/data/notetypes/types-sort.txt b/assets/preload/data/notetypes/notetypes-sort.txt similarity index 100% rename from assets/preload/data/notetypes/types-sort.txt rename to assets/preload/data/notetypes/notetypes-sort.txt diff --git a/assets/preload/data/stages/stages-sort.txt b/assets/preload/data/stages/stages-sort.txt new file mode 100644 index 00000000..d7a0d38d --- /dev/null +++ b/assets/preload/data/stages/stages-sort.txt @@ -0,0 +1 @@ +stage,spooky,philly,limo,mall,mallEvil,school,schoolEvil,tank \ No newline at end of file diff --git a/source/funkin/objects/Character.hx b/source/funkin/objects/Character.hx index f6fc5358..0141a587 100644 --- a/source/funkin/objects/Character.hx +++ b/source/funkin/objects/Character.hx @@ -95,6 +95,25 @@ class Character extends FlxSpriteExt flipX = isPlayer ? !value : value; } + // Move the whole character with the group too + public function reposition(X:Float, Y:Float) { + var ogX = x; + var ogY = y; + + setXY(X, Y); + + var diffX = x - ogX; + var diffY = y - ogY; + + if (group != null) { + group.x += diffX; + group.y += diffY; + } + + x -= diffX; + y -= diffY; + } + public function loadCharJson(inputJson:CharacterJson):Void { var path:String = inputJson.imagePath.startsWith("characters/") ? inputJson.imagePath : "characters/" + inputJson.imagePath; diff --git a/source/funkin/objects/note/Event.hx b/source/funkin/objects/note/Event.hx index 9575fb70..830de282 100644 --- a/source/funkin/objects/note/Event.hx +++ b/source/funkin/objects/note/Event.hx @@ -15,10 +15,9 @@ class EventUtil static function getList():Array { - var song = PlayState.SONG != null ? PlayState.SONG.song : ""; - var eventSort = CoolUtil.getFileContent(Paths.txt("events/events-sort", null)).split(","); - var eventList = JsonUtil.getSubFolderJsonList('events', [song]); - return CoolUtil.customSort(eventList, eventSort); + var song = PlayState.SONG?.song ?? ""; + song = Song.formatSongFolder(song); + return JsonUtil.getSubFolderJsonList('events', [song]); } public static function initEvents():Void diff --git a/source/funkin/states/PlayState.hx b/source/funkin/states/PlayState.hx index 583bf0e2..6b13af0c 100644 --- a/source/funkin/states/PlayState.hx +++ b/source/funkin/states/PlayState.hx @@ -24,6 +24,7 @@ class PlayState extends MusicBeatState public static var curStage:String = ''; public var stageData:StageJson; public var stage:Stage; + public var stageGroup:TypedGroup; public var dad:Character; public var gf:Character; @@ -47,6 +48,8 @@ class PlayState extends MusicBeatState public var startingSong:Bool = false; public var gfSpeed:Int = 1; + public var gfOpponent:Bool = false; + public var combo:Int = 0; public var health(default, set):Float = 1; function set_health(value:Float) { @@ -157,6 +160,10 @@ class PlayState extends MusicBeatState dad = new Character(0, 0, SONG.players[1]); boyfriend = new Character(0, 0, SONG.players[0], true); + gf.group = gfGroup; + dad.group = dadGroup; + boyfriend.group = boyfriendGroup; + // CACHE GAMEOVER STUFF GameOverSubstate.cacheSounds(); @@ -177,21 +184,17 @@ class PlayState extends MusicBeatState // Stage Script var stageScript = ModdingUtil.addScript(Paths.script('stages/$curStage')); stage = Stage.fromJson(stageData, stageScript); - add(stage); + + stageGroup = new TypedGroup(); + stageGroup.add(stage); + add(stageGroup); if (stageScript != null) stageScript.set("ScriptStage", stage); - + // Set stage character positions - stage.applyData(boyfriend, dad, gf); - boyfriend.setXY(770, 450); - dad.setXY(100, 450); - gf.setXY(400, 360); - - // Set up stuff for scripts - gf.group = gfGroup; - dad.group = dadGroup; - boyfriend.group = boyfriendGroup; + gfOpponent = SONG.players[1] == SONG.players[2] && dad.isGF; + stage.setupPlayState(this); iconGroup = new SpriteGroup(); iconP1 = new HealthIcon(boyfriend.icon, true, true); @@ -226,20 +229,6 @@ class PlayState extends MusicBeatState dadGroup.add(dad); boyfriendGroup.add(boyfriend); - // Make Dad GF - if (SONG.players[1] == SONG.players[2] && dad.isGF) { - dadGroup.setPosition(gf.OG_X - dad.OG_X, gf.OG_Y - dad.OG_Y); - dadGroup.scrollFactor.set(0.95, 0.95); - stage.__existsAddToLayer("gf", dadGroup); - } - else { - gfGroup.scrollFactor.set(0.95, 0.95); - stage.__existsAddToLayer("gf", gfGroup); - stage.__existsAddToLayer("dad", dadGroup); - } - - stage.__existsAddToLayer("bf", boyfriendGroup); - //Cam Follow if (prevCamFollow != null) { camFollow = prevCamFollow; diff --git a/source/funkin/states/editors/ChartingState.hx b/source/funkin/states/editors/ChartingState.hx index 2764b449..2facb612 100644 --- a/source/funkin/states/editors/ChartingState.hx +++ b/source/funkin/states/editors/ChartingState.hx @@ -4,7 +4,6 @@ import openfl.display.BitmapData; import flixel.text.FlxBitmapText; import funkin.states.editors.chart.grid.ChartNote.ChartSustain; import haxe.ds.Vector; -import flixel.util.FlxArrayUtil; import funkin.substates.NotesSubstate; import funkin.substates.PromptSubstate; import flixel.addons.ui.FlxUINumericStepper; @@ -623,7 +622,7 @@ class ChartingState extends MusicBeatState function deselectEvent() { eventID = 0; - FlxArrayUtil.clearArray(selectedEvents); + selectedEvents.clear(); selectedEventObject = null; } diff --git a/source/funkin/states/editors/chart/ChartTabs.hx b/source/funkin/states/editors/chart/ChartTabs.hx index 302b01ce..70750a51 100644 --- a/source/funkin/states/editors/chart/ChartTabs.hx +++ b/source/funkin/states/editors/chart/ChartTabs.hx @@ -53,10 +53,10 @@ class ChartTabs extends FlxUITabMenu instance = null; } - function selectChar(?selectFunction:Void->Void):Void { + function selectChar(?curChar:String, ?selectFunction:Void->Void):Void { ChartingState.instance.stop(); Conductor.setPitch(1, false); - ChartingState.instance.openSubState(new CharSelectSubstate(selectFunction)); + ChartingState.instance.openSubState(new CharSelectSubstate(selectFunction, curChar)); } public var focusList:Array = []; @@ -124,7 +124,7 @@ class ChartTabs extends FlxUITabMenu stepperOffsetVocals.name = 'song_vocals_offset'; p1Button = new FlxUIButton(10, 155, "Boyfriend", function() { - selectChar(function () { + selectChar(p1Button.label.text, () -> { var newChar:String = CharSelectSubstate.lastChar; p1Button.label.text = newChar; ChartingState.SONG.players[0] = newChar; @@ -134,7 +134,7 @@ class ChartTabs extends FlxUITabMenu p1Button.label.text = ChartingState.SONG.players[0]; p2Button = new FlxUIButton(stepperOffsetInst.x, p1Button.y, "Dad", function() { - selectChar(function () { + selectChar(p2Button.label.text, () -> { var newChar:String = CharSelectSubstate.lastChar; p2Button.label.text = newChar; ChartingState.SONG.players[1] = newChar; @@ -144,11 +144,10 @@ class ChartTabs extends FlxUITabMenu p2Button.label.text = ChartingState.SONG.players[1]; p3Button = new FlxUIButton(p2Button.x + 100, p2Button.y, "Girlfriend", function() { - selectChar(function () { + selectChar(p3Button.label.text, () -> { var newChar:String = CharSelectSubstate.lastChar; p3Button.label.text = newChar; ChartingState.SONG.players[2] = newChar; - //ChartingState.instance.updateIcons(); }); }); p3Button.label.text = ChartingState.SONG.players[2]; @@ -375,6 +374,7 @@ class ChartTabs extends FlxUITabMenu else { setCurEvent(newEvent); ChartingState.instance.setEventData(_defValues.copy(), newEvent); // Set defaults + // TODO: fix defaults for values } } @@ -386,8 +386,8 @@ class ChartTabs extends FlxUITabMenu } function addEventUI():Void { - FlxArrayUtil.clearArray(curEventDatas); - FlxArrayUtil.clearArray(curEventNames); + curEventDatas.clear(); + curEventNames.clear(); var tab_group_event = new FlxUI(null, this); tab_group_event.name = 'Event'; diff --git a/source/funkin/states/editors/chart/EventTab.hx b/source/funkin/states/editors/chart/EventTab.hx index 6a769720..79b50a29 100644 --- a/source/funkin/states/editors/chart/EventTab.hx +++ b/source/funkin/states/editors/chart/EventTab.hx @@ -29,58 +29,82 @@ class EventTab extends SpriteGroup clearGroup(); curValues = values.copy(); - var i:Int = 1; - for (v in values) { - final id:Int = i-1; - final X = (i <= 12 ? 0 : 1) * 125; - final Y = (i <= 12 ? id : id-12) * 30; - switch (Type.typeof(v)) { - case TInt | TFloat: - final stepper = new QuickStepper(X, Y,v); - stepper.callback = () -> updateFunc(id, stepper.value); - getValuesArray.push(() -> return stepper.value); - addUI(stepper); - - case TBool: - final checkbox = new FlxUICheckBox(X, Y, null, null, " "); - checkbox.checked = v; - checkbox.callback = () -> updateFunc(id, checkbox.checked); - getValuesArray.push(() -> return checkbox.checked); - addUI(checkbox); - - case TClass(Array): - final dropdown = new FlxUIDropDownMenu(X, Y, FlxUIDropDownMenu.makeStrIdLabelArray(v, true), function(_value:String) { - final value = v.copy()[Std.parseInt(_value)]; - updateFunc(id, value); - }); - dropdown.selectedLabel = v[0]; - getValuesArray.push(() -> return dropdown.selectedLabel); - addUI(dropdown); - - default: //TClass(String) - final input = new FlxUIInputText(X, Y, 100, Std.string(v), 8); - ChartTabs.instance.focusList.push(input); - input.callback = (var1, var2) -> updateFunc(id, input.text); - getValuesArray.push(() -> return input.text); - addUI(input); + for (i in 0...values.length) { + if (i > 23) { + break; } - //add(new FlxText(_X,_Y - 15, 0, 'Value $i:')); - sort(FlxSort.byY, FlxSort.DESCENDING); - i++; - if (i > 24) break; // Why would you need more you psycho? + + makeUIElement(values[i], i); } + sort(FlxSort.byY, FlxSort.DESCENDING); + scrollFactor.set(); } + function makeUIElement(value:Dynamic, ID:Int) + { + var X = (ID < 12 ? 0 : 1) * 125; + var Y = (ID < 12 ? ID : ID - 12) * 30; + + switch (Type.typeof(value)) + { + case TInt | TFloat: + var stepper = new QuickStepper(X, Y, value); + stepper.callback = () -> updateFunc(ID, stepper.value); + getValuesArray.push(() -> return stepper.value); + addUI(stepper); + + case TBool: + var checkbox = new FlxUICheckBox(X, Y, null, null, " "); + checkbox.checked = value; + checkbox.callback = () -> updateFunc(ID, checkbox.checked); + getValuesArray.push(() -> return checkbox.checked); + addUI(checkbox); + + case TClass(Array): + var dropdown = new FlxUIDropDownMenu(X, Y, FlxUIDropDownMenu.makeStrIdLabelArray(value, true), + (v:String) -> { + var item = value.copy()[Std.parseInt(v)]; + updateFunc(ID, item); + }); + dropdown.selectedLabel = value[0]; + getValuesArray.push(() -> return dropdown.selectedLabel); + addUI(dropdown); + + case TClass(String): + var value = Std.string(value); + + // Folder list + if (value.startsWith("")) { + var split = value.substring(6, value.length).split(":"); + var folder = split[0]; + var extension = split[1]; + + var list = Paths.quickFileList(folder, extension, false); + makeUIElement(list, ID); + return; + } + + // Not a list so we make a input text + var input = new FlxUIInputText(X, Y, 100, value, 8); + ChartTabs.instance.focusList.push(input); + input.callback = (var1, var2) -> updateFunc(ID, input.text); + getValuesArray.push(() -> return input.text); + addUI(input); + + default: + } + } + public function setValues(values:Array) { for (i in 0...values.length) { final obj = curUIelements[i]; switch(Type.typeof(obj)) { case TClass(FlxUIDropDownMenu): cast(obj, FlxUIDropDownMenu).selectedLabel = Std.string(values[i]); - case TClass(FlxUIInputText): cast(obj, FlxUIInputText).text = Std.string(values[i]); - case TClass(FlxUICheckBox): cast(obj, FlxUICheckBox).checked = cast(values[i], Bool); - case TClass(QuickStepper): cast(obj, QuickStepper).value = cast(values[i], Float); + case TClass(FlxUIInputText): cast(obj, FlxUIInputText).text = Std.string(values[i]); + case TClass(FlxUICheckBox): cast(obj, FlxUICheckBox).checked = cast(values[i], Bool); + case TClass(QuickStepper): cast(obj, QuickStepper).value = cast(values[i], Float); default: } } diff --git a/source/funkin/substates/CharSelectSubstate.hx b/source/funkin/substates/CharSelectSubstate.hx index 9a752234..6bcf011b 100644 --- a/source/funkin/substates/CharSelectSubstate.hx +++ b/source/funkin/substates/CharSelectSubstate.hx @@ -7,13 +7,14 @@ class CharSelectSubstate extends MusicBeatSubstate var curFolder:Int = 0; var curSelected:Array = []; + var iconArray:Array> = []; var charArray:Array> = []; + var folderTxt:Alphabet; - var textGroup:TypedGroup; - public function new(?selectFunction:()->Void):Void { + public function new(?selectFunction:()->Void, ?openChar:String):Void { super(); this.selectFunction = selectFunction; @@ -29,11 +30,8 @@ class CharSelectSubstate extends MusicBeatSubstate folderTxt.scrollFactor.set(); folderTxt.color = FlxColor.YELLOW; - var vanillaSort = CoolUtil.getFileContent(Paths.txt("characters/characters-sort", null, false)).split(","); - var modSort = CoolUtil.getFileContent(Paths.txt("characters/characters-sort")).split(','); - - var vanillaChars:Array = CoolUtil.customSort(Paths.getFileList(TEXT, false, 'json', 'data/characters'), vanillaSort); - var modChars:Array = CoolUtil.customSort(Paths.getModFileList('data/characters', 'json', false), modSort); + var vanillaChars:Array = Paths.getFileList(TEXT, false, 'json', 'data/characters'); + var modChars:Array = Paths.getModFileList('data/characters', 'json', false); var listsToAdd:Array> = [vanillaChars, modChars]; @@ -62,11 +60,19 @@ class CharSelectSubstate extends MusicBeatSubstate iconArray.unsafeGet(f).push(charIcon); charArray.unsafeGet(f).push(charText); }); + + if (openChar != null) { + var index = folder.indexOf(openChar); + if (index != -1) { + curFolder = f; + curSelected[f] = index; + } + } }); changeFolder(); add(folderTxt); - cameras = [CoolUtil.getTopCam()]; + camera = CoolUtil.getTopCam(); } override public function update(elapsed:Float):Void { diff --git a/source/funkin/util/JsonUtil.hx b/source/funkin/util/JsonUtil.hx index 0f801508..e59d707a 100644 --- a/source/funkin/util/JsonUtil.hx +++ b/source/funkin/util/JsonUtil.hx @@ -32,18 +32,23 @@ typedef JsonSpritesheet = { class JsonUtil { - public static function getSubFolderJsonList(folder:String= 'data/scripts/global', ?subFolders:Array) { - subFolders = subFolders == null ? [] : subFolders; - var subFolderList:Array = []; - for (i in subFolders) - subFolderList = subFolderList.concat(getJsonList(folder + "/" + i)); - return getJsonList(folder).concat(subFolderList); + public static function getSubFolderJsonList(folder:String= 'data/scripts/global', ?subFolders:Array) + { + var subFolderList:Array = []; + + if (subFolders != null) { + subFolders.fastForEach((subFolder, i) -> { + subFolderList = subFolderList.concat(getJsonList('$folder/$subFolder')); + }); + } + + return getJsonList(folder).concat(subFolderList); } inline public static function getJsonList(folder:String = 'scripts/global', assets:Bool = true, globalMod:Bool = true, curMod:Bool = true, allMods:Bool = false, - fullPath:Bool = false, mainFolder:String = 'data'):Array { - + fullPath:Bool = false, mainFolder:String = 'data'):Array + { var assetsList:Array = assets ? Paths.getFileList(TEXT, fullPath, 'json', '/$mainFolder/$folder') : []; var modList:Array = #if desktop Paths.getModFileList('$mainFolder/$folder', 'json', fullPath, globalMod, curMod, allMods); #else []; #end return assetsList.concat(modList); diff --git a/source/funkin/util/NoteUtil.hx b/source/funkin/util/NoteUtil.hx index 1dd20842..0e6d1fc6 100644 --- a/source/funkin/util/NoteUtil.hx +++ b/source/funkin/util/NoteUtil.hx @@ -49,10 +49,9 @@ class NoteUtil static function getList():Array { - var song = PlayState.SONG != null ? PlayState.SONG.song : ""; - var typesList = JsonUtil.getSubFolderJsonList('notetypes', [Song.formatSongFolder(song)]); - var typesSort = CoolUtil.getFileContent(Paths.txt("notetypes/types-sort", null)).split(","); - return CoolUtil.customSort(typesList, typesSort); + var song = PlayState.SONG?.song ?? ""; + song = Song.formatSongFolder(song); + return JsonUtil.getSubFolderJsonList('notetypes', [song]); } public static function initTypes():Void diff --git a/source/funkin/util/Paths.hx b/source/funkin/util/Paths.hx index d42ee4a6..434c8be7 100644 --- a/source/funkin/util/Paths.hx +++ b/source/funkin/util/Paths.hx @@ -315,30 +315,78 @@ class Paths return frames; } + public static function quickFileList(folder:String, extension:String, fullPath:Bool) + { + var assetType:AssetType = switch (extension) { + case "png": IMAGE; + case "ogg": MUSIC; + case _: TEXT; + } + + var assetFiles = getFileList(assetType, fullPath, extension, folder); + var modFiles = getModFileList(folder, extension, fullPath); + + var list = assetFiles.concat(modFiles); + return CoolUtil.removeDuplicates(list); + } + + public static function findSort(dir:String):Array + { + if (dir.endsWith("/")) + dir = dir.substring(0, dir.length - 1); + + var folder = dir.split("/").pop(); + + for (i in ['listSort', '$folder-sort']) { + var sort = CoolUtil.getFileContent('$dir/$i.txt'); + if (sort.length > 0) + return sort.split(","); + } + + // Folder has no sorts :p + return []; + } + + public static function setupSort(folder:String, ?extension:String, fullPath:Bool = true) + { + var sort:Array = findSort(folder); + sort.fastForEach((file, i) -> { + var prefix = fullPath ? '$folder/' : ''; + var suffix = ((extension == null) || !fullPath) ? "" : '.$extension'; + sort.unsafeSet(i, prefix + file + suffix); + }); + return sort; + } + static public function getFileList(type:AssetType = IMAGE, fullPath:Bool = true, extension:String = "", folder:String = ""):Array { - if (folder.length > 0) if (!folder.endsWith("/")) - folder = '$folder/'; + if (folder.length > 0) { + if (!folder.endsWith("/")) + folder = '$folder/'; + + if (!folder.startsWith('assets/')) + folder = folder.startsWith('/') ? 'assets$folder' : 'assets/$folder'; + } var list:Array = []; - OpenFlAssets.list(type).fastForEach((file, i) -> + + for (file in OpenFlAssets.list(type)) { - if (file.startsWith('assets/')) - { - if (extension.length == 0 || file.endsWith(extension)) - { - if (folder.length == 0 || file.contains(folder)) - { - list.push(fullPath ? file - : file.split('/')[file.split('/').length-1].split('.')[0] - ); - } - } + if (!file.startsWith('assets/')) + continue; + + var validExtension:Bool = (extension.length == 0 || file.endsWith(extension)); + var validFolder:Bool = (folder.length == 0 || file.contains(folder)); + + if (validExtension) if (validFolder) { + list.push(fullPath ? file : file.split('/').pop().split('.')[0]); } - }); + } + + var sort = setupSort(folder, extension, fullPath); + var sortedList = CoolUtil.customSort(list, sort); - list.sort(CoolUtil.sortAlphabetically); - return list; + return sortedList; } public static function getModFileList(folder:String, ?extension:String, fullPath:Bool = true, global:Bool = true, curFolder:Bool = true, allFolders:Bool = false):Array { @@ -348,13 +396,6 @@ class Paths { if (FileSystem.exists(folder)) { - var sort:Array = CoolUtil.getFileContent('$folder/listSort.txt').split(","); - sort.fastForEach((file, i) -> { - var prefix = fullPath ? '$folder/' : ''; - var suffix = ((extension == null) || !fullPath) ? "" : '.$extension'; - sort.unsafeSet(i, prefix + file + suffix); - }); - var folderList:Array = []; FileSystem.readDirectory(folder).fastForEach((path, i) -> { if (extension == null || path.endsWith(extension)) @@ -364,8 +405,9 @@ class Paths } }); + var sort = setupSort(folder, extension, fullPath); var sortedList = CoolUtil.customSort(folderList, sort); - sortedList.fastForEach((file, i) -> fileList.push(file)); + fileList = fileList.concat(sortedList); } }; diff --git a/source/funkin/util/SkinUtil.hx b/source/funkin/util/SkinUtil.hx index df94d593..08da7d76 100644 --- a/source/funkin/util/SkinUtil.hx +++ b/source/funkin/util/SkinUtil.hx @@ -11,7 +11,8 @@ typedef SkinJson = SpriteJson & { var splashData:SpriteJson; } -class SkinUtil { +class SkinUtil +{ public static var curSkin:String = 'default'; public static var curSkinData:SkinJson; public static var dataMap:Map; diff --git a/source/funkin/util/Stage.hx b/source/funkin/util/Stage.hx index 9b08da17..7787d9e4 100644 --- a/source/funkin/util/Stage.hx +++ b/source/funkin/util/Stage.hx @@ -213,15 +213,53 @@ class Stage extends TypedGroup implements IMusicHit return super.set_active(value); } + public function setupPlayState(instance:PlayState) { + final dadOpponent:Bool = !instance.gfOpponent; + + __existsAddToLayer("bf", instance.boyfriendGroup); + + if (dadOpponent) + { + __existsAddToLayer("dad", instance.dadGroup); + __existsAddToLayer("gf", instance.gfGroup); + + applyData( + instance.boyfriend, + instance.dad, + instance.gf + ); + } + else + { + __existsAddToLayer("gf", instance.dadGroup); + + applyData( + instance.boyfriend, + null, + instance.dad + ); + } + } + public function applyData(bf:Character, dad:Character, gf:Character) { - bf.stageOffsets.set(data.bfOffsets[0], data.bfOffsets[1]); - dad.stageOffsets.set(data.dadOffsets[0], data.dadOffsets[1]); - gf.stageOffsets.set(data.gfOffsets[0], data.gfOffsets[1]); + if (bf != null) { + bf.stageOffsets.set(data.bfOffsets[0], data.bfOffsets[1]); + bf.stageCamOffsets.set(data.bfCamOffsets[0], data.bfCamOffsets[1]); + bf.reposition(770, 450); + } - bf.stageCamOffsets.set(data.bfCamOffsets[0], data.bfCamOffsets[1]); - dad.stageCamOffsets.set(data.dadCamOffsets[0], data.dadCamOffsets[1]); - gf.stageCamOffsets.set(data.gfCamOffsets[0], data.gfCamOffsets[1]); + if (dad != null) { + dad.stageOffsets.set(data.dadOffsets[0], data.dadOffsets[1]); + dad.stageCamOffsets.set(data.dadCamOffsets[0], data.dadCamOffsets[1]); + dad.reposition(100, 450); + } + + if (gf != null) { + gf.stageOffsets.set(data.gfOffsets[0], data.gfOffsets[1]); + gf.stageCamOffsets.set(data.gfCamOffsets[0], data.gfCamOffsets[1]); + gf.reposition(400, 360); + } } // Creating the stage