Skip to content

Commit

Permalink
Info Json Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
poec987 committed Sep 14, 2024
1 parent c502499 commit 517edbd
Show file tree
Hide file tree
Showing 25 changed files with 161 additions and 18 deletions.
5 changes: 5 additions & 0 deletions assets/preload/data/blammed/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dialogues": [
"blammedDialogue"
]
}
5 changes: 5 additions & 0 deletions assets/preload/data/bopeebo/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dialogues": [
"bopeeboDialogue"
]
}
3 changes: 3 additions & 0 deletions assets/preload/data/celebrate/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"gfVersion": "gf-pixelgroove"
}
6 changes: 6 additions & 0 deletions assets/preload/data/cocoa/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"gfVersion": "gf-christmas",
"dialogues": [
"cocoaDialogue"
]
}
5 changes: 5 additions & 0 deletions assets/preload/data/dadbattle/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dialogues": [
"dadbattleDialogue"
]
}
6 changes: 6 additions & 0 deletions assets/preload/data/eggnog/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"gfVersion": "gf-christmas",
"dialogues": [
"eggnogDialogue"
]
}
5 changes: 5 additions & 0 deletions assets/preload/data/fresh/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dialogues": [
"freshDialogue"
]
}
6 changes: 6 additions & 0 deletions assets/preload/data/high/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"gfVersion": "gf-car",
"dialogues": [
"dia"
]
}
6 changes: 6 additions & 0 deletions assets/preload/data/milf/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"gfVersion": "gf-car",
"dialogues": [
"dia"
]
}
7 changes: 7 additions & 0 deletions assets/preload/data/monster/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dialogues": [
"monsterDialogue",
"monsterDialogue1",
"monsterDialogue2"
]
}
5 changes: 5 additions & 0 deletions assets/preload/data/philly/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dialogues": [
"phillyDialogue"
]
}
5 changes: 5 additions & 0 deletions assets/preload/data/pico/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dialogues": [
"picoDialogue"
]
}
2 changes: 0 additions & 2 deletions assets/preload/data/pico/picoDialogue2.txt

This file was deleted.

6 changes: 6 additions & 0 deletions assets/preload/data/roses/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"gfVersion": "gf-pixelgroove",
"dialogues": [
"rosesDialogue"
]
}
6 changes: 6 additions & 0 deletions assets/preload/data/satin-panties/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"gfVersion": "gf-car",
"dialogues": [
"dia"
]
}
3 changes: 3 additions & 0 deletions assets/preload/data/scopophobia/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"gfVersion": "vyst-gf"
}
3 changes: 3 additions & 0 deletions assets/preload/data/senpai-impossible-ver/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"gfVersion": "gf-pixelgroove"
}
6 changes: 6 additions & 0 deletions assets/preload/data/senpai/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"gfVersion": "gf-pixelgroove",
"dialogues": [
"senpaiDialogue"
]
}
6 changes: 6 additions & 0 deletions assets/preload/data/south/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dialogues": [
"southDialogue1",
"southDialogue2"
]
}
6 changes: 6 additions & 0 deletions assets/preload/data/spookeez/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dialogues": [
"spookeezDialogue1",
"spookeezDialogue2"
]
}
6 changes: 6 additions & 0 deletions assets/preload/data/thorns/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"gfVersion": "gf-pixel",
"dialogues": [
"thornsDialogue"
]
}
5 changes: 5 additions & 0 deletions assets/preload/data/tutorial/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dialogues": [
"cocoaDialogue"
]
}
5 changes: 5 additions & 0 deletions assets/preload/data/unfairness-jside/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dialogues": [
"peakwrittenbyjo"
]
}
6 changes: 6 additions & 0 deletions assets/preload/data/winter-horrorland/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"gfVersion": "gf-christmas",
"dialogues": [
"winter-horrorlandDialogue"
]
}
55 changes: 39 additions & 16 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ class PlayState extends MusicBeatState

var songTimer:SongTimer;

var infoJson:Dynamic;
var infoJsonExists:Bool = false;

#if desktop
// Discord RPC variables
var iconRPC:String = "";
Expand Down Expand Up @@ -302,6 +305,20 @@ class PlayState extends MusicBeatState
if (SONG == null)
SONG = Song.loadFromJson('tutorial');

if (FileSystem.exists(Paths.json(SONG.song.toLowerCase().trim()+"/info"))) {
infoJsonExists = true;
var infoJsonRaw = Assets.getText(Paths.json(SONG.song.toLowerCase().trim()+"/info")).trim();

while (!infoJsonRaw.endsWith("}"))
{
infoJsonRaw = infoJsonRaw.substr(0, infoJsonRaw.length - 1);
}

infoJson = Json.parse(infoJsonRaw);
} else {
infoJsonExists = false;
}

// Unlock songs when you play them, aint fucking no one beating unfairness j after other 3 songs
SaveManagement.unlockSong(SONG.song);

Expand All @@ -313,18 +330,16 @@ class PlayState extends MusicBeatState

hasDialogue = false;

var files:Array<String> = sys.FileSystem.readDirectory('assets/data/'+SONG.song.toLowerCase().trim());
var dialogueFiles:Array<String> = [];
for (i in 0...files.length) {
if (files.length != 1) {
if (files[i].endsWith('.txt')) {
dialogueFiles.push(files[i].replace('.txt', '').trim());
hasDialogue = true;
}
} else {
hasDialogue = false;
if (getValueFromInfoJsonKey("dialogues", []).length >= 1) {
hasDialogue = true;
for (i in 0...getValueFromInfoJsonKey("dialogues", []).length) {
dialogueFiles.push(getValueFromInfoJsonKey("dialogues", [])[i]);
}
}
} else {
hasDialogue = false;
}

if (hasDialogue)
dialogue = CoolUtil.coolTextFile(Paths.txt(SONG.song.toLowerCase().trim()+'/'+dialogueFiles[FlxG.random.int(0, dialogueFiles.length-1)]));
#else
Expand Down Expand Up @@ -856,7 +871,7 @@ class PlayState extends MusicBeatState

if (specialgf == false || SONG.song.toLowerCase() == 'tutorial' || SONG.song.toLowerCase() == 'senpai' || SONG.song.toLowerCase() == 'roses' || SONG.song.toLowerCase() == 'thorns')
{
switch (curStage)
/*switch (curStage)
{
case 'limo' | 'limonormal':
gfVersion = 'gf-car';
Expand All @@ -869,9 +884,9 @@ class PlayState extends MusicBeatState
case 'foundation':
gfVersion = 'vyst-gf';
}
if (curStage == 'limo')
gfVersion = 'gf-car';
}*/

gfVersion = getValueFromInfoJsonKey("gfVersion", "gf");
}
else
{
Expand Down Expand Up @@ -2362,8 +2377,9 @@ class PlayState extends MusicBeatState
}

public static function checkForCutscene(vidName:String, nextState:flixel.FlxState) {
FlxG.sound.music.stop();

if (FlxG.sound.music.playing)
FlxG.sound.music.stop();

if (FileSystem.exists(Paths.video(vidName))) {
VideoCutsceneState.videoFile = vidName.trim();
VideoCutsceneState.targetState = nextState;
Expand All @@ -2373,6 +2389,13 @@ class PlayState extends MusicBeatState
}
}

function getValueFromInfoJsonKey(key:String, defaultValue:Dynamic):Dynamic {
if (infoJsonExists && Reflect.hasField(infoJson, key))
return Reflect.field(infoJson, key);
else
return defaultValue;
}

function returnToFreeplay() {
trace('WENT BACK TO FREEPLAY??');
FreeplayState.lastPage = lastFPpage;
Expand Down

0 comments on commit 517edbd

Please sign in to comment.