Skip to content

Commit

Permalink
file sorting rework + wip event data file list
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Jun 26, 2024
1 parent f50f8c9 commit 906ce19
Show file tree
Hide file tree
Showing 17 changed files with 264 additions and 167 deletions.
2 changes: 1 addition & 1 deletion assets/preload/data/events/changeChar.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"dad",
"girlfriend"
],
"bf"
"<list>data/characters:json"
]
}
41 changes: 8 additions & 33 deletions assets/preload/data/events/changeStage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
Expand Down Expand Up @@ -97,7 +72,7 @@ function createPost() {
cachedStages.set(stage, stageObject);
stageObject.visible = false;
stageObject.active = false;
State.add(stageObject);
State.stageGroup.add(stageObject);
}
}

Expand Down
2 changes: 1 addition & 1 deletion assets/preload/data/events/changeStage.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"description": "Changes the stage to a new one\n\nValue 1: New stage name",
"values": [
"stage"
"<list>data/stages:json"
]
}
1 change: 1 addition & 0 deletions assets/preload/data/stages/stages-sort.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
stage,spooky,philly,limo,mall,mallEvil,school,schoolEvil,tank
19 changes: 19 additions & 0 deletions source/funkin/objects/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions source/funkin/objects/note/Event.hx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ class EventUtil

static function getList():Array<String>
{
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
Expand Down
39 changes: 14 additions & 25 deletions source/funkin/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Stage>;

public var dad:Character;
public var gf:Character;
Expand All @@ -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) {
Expand Down Expand Up @@ -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();

Expand All @@ -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<Stage>();
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);
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions source/funkin/states/editors/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -623,7 +622,7 @@ class ChartingState extends MusicBeatState

function deselectEvent() {
eventID = 0;
FlxArrayUtil.clearArray(selectedEvents);
selectedEvents.clear();
selectedEventObject = null;
}

Expand Down
16 changes: 8 additions & 8 deletions source/funkin/states/editors/chart/ChartTabs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<FlxUIInputText> = [];
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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];
Expand Down Expand Up @@ -375,6 +374,7 @@ class ChartTabs extends FlxUITabMenu
else {
setCurEvent(newEvent);
ChartingState.instance.setEventData(_defValues.copy(), newEvent); // Set defaults
// TODO: fix defaults for <list> values
}
}

Expand All @@ -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';
Expand Down
Loading

0 comments on commit 906ce19

Please sign in to comment.