Skip to content

Commit

Permalink
Bonus Features
Browse files Browse the repository at this point in the history
This should be alright, they're not necessary features but they're nice to have
  • Loading branch information
Sonamaker1 committed Dec 11, 2023
1 parent 37fc46d commit bc1cfc7
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 7 deletions.
40 changes: 38 additions & 2 deletions source/FunkinLua.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1053,8 +1053,26 @@ class FunkinLua {
Reflect.getProperty(getInstance(), obj).remove(Reflect.getProperty(getInstance(), obj)[index]);
});

Lua_helper.add_callback(lua, "getPropertyFromClass", function(classVar:String, variable:String) {
Lua_helper.add_callback(lua, "getPropertyFromClass", function(classVarInput:String, variable:String) {
@:privateAccess
var classVar = classVarInput;
trace("Is clientprefs? " + (classVar.indexOf("backend.ClientPrefs")>=0));

//Is this a 0.7 thing?
var isZeroPointSeven = classVar.indexOf("backend.")>=0 ||
classVar.indexOf("states.")>=0||
classVar.indexOf("substates.")>=0;

//Has this been back-ported already?
var isMapped = classVar.indexOf("substates.GameOverSubstate")>=0 ||
classVar.indexOf("substates.PauseSubState")>=0 ||
classVar.indexOf("backend.ClientPrefs")>=0;

if( isZeroPointSeven && !isMapped ){
var splitIt=classVar.split('.');
classVar = classVar.split('.').slice(1,splitIt.length).join("");
}

var killMe:Array<String> = variable.split('.');
if(killMe.length > 1) {
var coverMeInPiss:Dynamic = getVarInArray(Type.resolveClass(classVar), killMe[0]);
Expand All @@ -1065,8 +1083,26 @@ class FunkinLua {
}
return getVarInArray(Type.resolveClass(classVar), variable);
});
Lua_helper.add_callback(lua, "setPropertyFromClass", function(classVar:String, variable:String, value:Dynamic) {
Lua_helper.add_callback(lua, "setPropertyFromClass", function(classVarInput:String, variable:String, value:Dynamic) {
@:privateAccess
var classVar = classVarInput;
trace("Is clientprefs? " + (classVar.indexOf("backend.ClientPrefs")>=0));

//Is this a 0.7 thing?
var isZeroPointSeven = classVar.indexOf("backend.")>=0 ||
classVar.indexOf("states.")>=0||
classVar.indexOf("substates.")>=0;

//Has this been back-ported already?
var isMapped = classVar.indexOf("substates.GameOverSubstate")>=0 ||
classVar.indexOf("substates.PauseSubState")>=0 ||
classVar.indexOf("backend.ClientPrefs")>=0;

if( isZeroPointSeven && !isMapped ){
var splitIt=classVar.split('.');
classVar = classVar.split('.').slice(1,splitIt.length).join("");
}

var killMe:Array<String> = variable.split('.');
if(killMe.length > 1) {
var coverMeInPiss:Dynamic = getVarInArray(Type.resolveClass(classVar), killMe[0]);
Expand Down
8 changes: 7 additions & 1 deletion source/MusicBeatState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class MusicBeatState extends FlxUIState
inline function get_controls():Controls
return PlayerSettings.player1.controls;


public function new()
{
super();
Expand Down Expand Up @@ -257,4 +256,11 @@ class MusicBeatState extends FlxUIState
if(PlayState.SONG != null && PlayState.SONG.notes[curSection] != null) val = PlayState.SONG.notes[curSection].sectionBeats;
return val == null ? 4 : val;
}

//Hi 7oltan lol
override function draw(){
menuscripts.executeAllFunc("super_draw", []);
super.draw();
menuscripts.executeAllFunc("super_drawPost", []);
}
}
36 changes: 33 additions & 3 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,12 @@ class PlayState extends MusicBeatState
gf.visible = false;
}
//W, TODO: fast cars and flxTrails go here

DialogueUtil.buffer = [];
if(!DialogueUtil.skipNextClear){
DialogueUtil.buffer = [];
}
else{
DialogueUtil.skipNextClear = false;
}
var file:String = Paths.json(songName + '/dialogue'); //Checks for json/Psych Engine dialogue
if (OpenFlAssets.exists(file)) {
dialogueJson = DialogueBoxPsych.parseDialogue(file);
Expand Down Expand Up @@ -1267,6 +1271,24 @@ class PlayState extends MusicBeatState
}
}

public function sayDialogue(?music:String = null):Void {
var shit:DialogueFile = {dialogue: DialogueUtil.buffer};
if(shit.dialogue.length > 0) {
PlayState.instance.startDialogue(shit, music);
return;
} else {
if(PlayState.instance.endingSong) {
PlayState.instance.endSong();
} else {
PlayState.instance.startCountdown();
}
}
}

public function clearDialogue() {
DialogueUtil.buffer = [];
return 0;
}
//Removed intro function stuff lol

var startTimer:FlxTimer;
Expand Down Expand Up @@ -2441,6 +2463,14 @@ class PlayState extends MusicBeatState
}
}

override function draw(){
if(scripts!=null)
scripts.executeAllFunc("onDraw", []);
super.draw();
if(scripts!=null)
scripts.executeAllFunc("onDrawPost", []);
}

function openPauseMenu()
{
persistentUpdate = false;
Expand Down Expand Up @@ -4205,7 +4235,7 @@ class PlayState extends MusicBeatState
scripts.addScript(scriptName).executeString(hxData);
else
{
scripts.getScriptByTag(scriptName).error("Duplacite Script Error!", '$scriptName: Duplicate Script');
scripts.getScriptByTag(scriptName).error("Duplicate Script Error!", '$scriptName: Duplicate Script');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/tools/DialogueUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DialogueUtil extends FlxSpriteGroup
private static var DEFAULT_TEXT:String = "coolswag";
private static var DEFAULT_SPEED:Float = 0.05;
private static var DEFAULT_BUBBLETYPE:String = "normal";

public static var skipNextClear = false;
public static var buffer:Array<DialogueLine> = [];

public static function makeLine(
Expand Down

0 comments on commit bc1cfc7

Please sign in to comment.