Skip to content

Commit

Permalink
more hscript stuff outside of playstate
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Nov 23, 2023
1 parent b9c8b17 commit 0e72590
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 40 deletions.
3 changes: 2 additions & 1 deletion mods/Default Icons/_polymod_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"mod_version": "1.0.0",
"license": "GPL-3.0",
"metadata": {
"auto_enable": "false"
"auto_enable": "false",
"canBeSwitchedTo": "false"
}
}
5 changes: 4 additions & 1 deletion mods/Friday Night Funkin'/_polymod_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
"author":"Ninjamuffin99, PhantomArcade, KawaiiSprite, EvilSk8r",
"api_version":"0.5.0",
"mod_version":"0.2.8",
"license":"Apache 2.0"
"license":"Apache 2.0",
"metadata": {
"canBeDisabled": "false"
}
}
2 changes: 1 addition & 1 deletion source/modding/SwitchModSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class SwitchModSubstate extends MusicBeatSubstate

for(modId in PolymodHandler.metadataArrays)
{
if (ModList.modList.get(modId)){
if (ModList.modList.get(modId) && ModList.modMetadatas.get(modId).metadata.get('canBeSwitchedTo') != 'false'){
var modOption = new ChangeModOption(ModList.modMetadatas.get(modId).title, modId, optionLoopNum);
page.add(modOption);
optionLoopNum++;
Expand Down
4 changes: 3 additions & 1 deletion source/modding/custom/CustomState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import states.MusicBeatState;

class CustomState extends MusicBeatState {
public var script:HScript;
public static var instance:CustomState = null;
override function new(script:String){
instance = this;
this.script = new HScript(Paths.hx("classes/states/" + script));
this.script.start();
super();
}
override function create(){
allScriptCall("create");
super.create();
allScriptCall("createPost");
}
Expand Down
35 changes: 7 additions & 28 deletions source/states/MainMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MainMenuState extends MusicBeatState
var camFollow:FlxObject;
var ui_Skin:Null<String>;
public var scripts:Array<HScript> = [];
var classScripts:HScript;
var script:HScript;

function allScriptCall(func:String, ?args:Array<Dynamic>) {
for (cool_script in scripts) {
Expand All @@ -54,40 +54,19 @@ class MainMenuState extends MusicBeatState

function loadScripts(){
#if sys
var modList = modding.ModList.getActiveMods(modding.PolymodHandler.metadataArrays);

if (modList.length > 0)
{
for (mod in modList)
{
if (sys.FileSystem.exists("mods/" + mod + "/classes/states/MainMenuState"))
{
var modclassScriptss = sys.FileSystem.readDirectory("mods/" + mod + "/classes/states/MainMenuState");

if (modclassScriptss.length > 0)
{
for (file in modclassScriptss)
{
if(file.endsWith('.hx'))
{
classScripts = new HScript("mods/" + mod + "/classes/states/MainMenuState/" + file, true);
classScripts.start();

scripts.push(classScripts);
}
}
}
}
}
if (sys.FileSystem.exists("mods/" + Options.getData("curMod") + "/classes/states/MainMenuState.hx")){
script = new HScript("mods/" + Options.getData("curMod") + "/classes/states/MainMenuState.hx", true);
script.start();
scripts.push(script);
}
#end
}


override function create()
{
instance = this;

loadScripts();
instance = this;

if (ui_Skin == null || ui_Skin == "default")
ui_Skin = Options.getData("uiSkin");
Expand Down
8 changes: 5 additions & 3 deletions source/states/ModsMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,11 @@ class ModsMenu extends MusicBeatState

for(modId in PolymodHandler.metadataArrays)
{
var modOption = new ModOption(ModList.modMetadatas.get(modId).title, modId, optionLoopNum);
page.add(modOption);
optionLoopNum++;
if(ModList.modMetadatas.get(modId).metadata.get('canBeDisabled') != 'false'){
var modOption = new ModOption(ModList.modMetadatas.get(modId).title, modId, optionLoopNum);
page.add(modOption);
optionLoopNum++;
}
}
}

Expand Down
60 changes: 55 additions & 5 deletions source/states/TitleState.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package states;

import modding.scripts.languages.HScript;
#if discord_rpc
import utilities.Discord.DiscordClient;
#end
Expand Down Expand Up @@ -49,7 +50,30 @@ class TitleState extends MusicBeatState {

var swagShader:TitleEffect;

public static var instance:TitleState = null;

public var scripts:Array<HScript> = [];
var script:HScript;

function allScriptCall(func:String, ?args:Array<Dynamic>) {
for (cool_script in scripts) {
cool_script.call(func, args);
}
}

function loadScripts(){
#if sys
if (sys.FileSystem.exists("mods/" + Options.getData("curMod") + "/classes/states/TitleState.hx")){
script = new HScript("mods/" + Options.getData("curMod") + "/classes/states/TitleState.hx", true);
script.start();
scripts.push(script);
}
#end
}

override public function create():Void {

instance = this;

MusicBeatState.windowNameSuffix = "";

Expand Down Expand Up @@ -84,6 +108,8 @@ class TitleState extends MusicBeatState {

curWacky = FlxG.random.getObject(getIntroTextShit());



super.create();

#if discord_rpc
Expand All @@ -103,8 +129,12 @@ class TitleState extends MusicBeatState {


firstTimeStarting = true;

}

loadScripts();


new FlxTimer().start(1, function(tmr:FlxTimer) startIntro());
}

Expand All @@ -127,6 +157,8 @@ class TitleState extends MusicBeatState {
function startIntro() {
if (!initialized) {

allScriptCall("startIntro");

var diamond:FlxGraphic = FlxGraphic.fromClass(GraphicTransTileDiamond);
diamond.persist = true;
diamond.destroyOnNoUse = false;
Expand Down Expand Up @@ -162,6 +194,8 @@ class TitleState extends MusicBeatState {
Main.toggleVers(Options.getData("versionDisplay"));

Main.changeFont(Options.getData("infoDisplayFont"));

allScriptCall("startIntroPost");
}

version = '${MusicBeatState.windowNamePrefix}-git (v${Assets.getText("version.txt")})';
Expand Down Expand Up @@ -261,6 +295,7 @@ class TitleState extends MusicBeatState {
skipIntro();
else
initialized = true;

}

function getIntroTextShit():Array<Array<String>> {
Expand Down Expand Up @@ -342,6 +377,7 @@ class TitleState extends MusicBeatState {

transitioning = true;

allScriptCall("checkForUpdate");
new FlxTimer().start(2, function(tmr:FlxTimer) {
var http = new haxe.Http("https://raw.githubusercontent.com/Vortex2Oblivion/LeatherEngine-Extended-Support/main/version.txt");

Expand Down Expand Up @@ -370,27 +406,34 @@ class TitleState extends MusicBeatState {
skipIntro();

super.update(elapsed);
allScriptCall("update", [elapsed]);
}

function createCoolText(textArray:Array<String>) {
allScriptCall("createCoolText");
for (i in 0...textArray.length) {
addMoreText(textArray[i]);
}
allScriptCall("createCoolTextPost");
}

function addMoreText(text:String) {
allScriptCall("addMoreText");
var coolText:Alphabet = new Alphabet(0, 0, text.toUpperCase(), true, false);
coolText.screenCenter(X);
coolText.y += (textGroup.length * 60) + 200;
credGroup.add(coolText);
textGroup.add(coolText);
allScriptCall("addMoreTextPost");
}

function deleteCoolText() {
allScriptCall("deleteCoolText");
while (textGroup.members.length > 0) {
credGroup.remove(textGroup.members[0], true);
textGroup.remove(textGroup.members[0], true);
}
allScriptCall("deleteCoolTextPost");
}

function textDataText(line:Int) {
Expand All @@ -411,13 +454,17 @@ class TitleState extends MusicBeatState {
super.beatHit();

if (!Options.getData("oldTitle")) {
logoBl.animation.play('bump');
if(logoBl != null){
logoBl.animation.play('bump');
}
danceLeft = !danceLeft;

if (danceLeft)
gfDance.animation.play('danceRight');
else
gfDance.animation.play('danceLeft');
if(gfDance != null){
if (danceLeft)
gfDance.animation.play('danceRight');
else
gfDance.animation.play('danceLeft');
}

switch (curBeat) {
case 1:
Expand Down Expand Up @@ -454,11 +501,13 @@ class TitleState extends MusicBeatState {
skippedIntro = true;
MusicBeatState.windowNameSuffix = "";
}
allScriptCall("beatHit");
}

var skippedIntro:Bool = false;

function skipIntro():Void {
allScriptCall("skipIntro");
if (!skippedIntro) {
MusicBeatState.windowNameSuffix = "";

Expand All @@ -469,5 +518,6 @@ class TitleState extends MusicBeatState {
remove(credGroup);
skippedIntro = true;
}
allScriptCall("skipIntroPost");
}
}

0 comments on commit 0e72590

Please sign in to comment.