Skip to content

Commit 219600d

Browse files
committed
modmenu fixes
1 parent dcd133a commit 219600d

File tree

8 files changed

+79
-19
lines changed

8 files changed

+79
-19
lines changed
503 Bytes
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"antialiasIcon":true,
3+
"antialiasBg": true
4+
}

source/Main.hx

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import Sys;
1818

1919
class Main extends Sprite
2020
{
21-
public static final gameVersionInt = 4;
22-
public static final gameVersionStr = "v1.1.2 I'm Guitarin' (& icons 2)";
21+
public static final gameVersionInt = 5;
22+
public static final gameVersionStr = "v1.1.3 I'm Guitarin' (& fix the modmenu)";
2323

2424
var gameWidth:Int = 1280; // Width of the game in pixels (might be less / more in actual pixels depending on your zoom).
2525
var gameHeight:Int = 720; // Height of the game in pixels (might be less / more in actual pixels depending on your zoom).

source/ModLoad.hx

+11
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class ModLoad
3030
continue;
3131
else if (f.startsWith("1::"))
3232
f = f.substr(3);
33+
if (!modLoadAllowed(f))
34+
continue;
3335
var flashFolder = "mods/"+f+"/noflashing";
3436
var string = "Mod: "+f;
3537
if (!Options.flashingLights) {
@@ -88,6 +90,15 @@ class ModLoad
8890
trace('[${error.severity}] (${Std.string(error.code).toUpperCase()}): ${error.message}');
8991
}
9092

93+
public static function modLoadAllowed(name:String) {
94+
var path = 'mods/${name}/mod.json';
95+
trace("check if "+path+" is allowed to load");
96+
if (!FileSystem.exists(path))
97+
return FileSystem.exists('mods/${name}');
98+
var modInfo:ModInfo = CoolUtil.loadJsonFromString(File.getContent(path));
99+
return modInfo.loadableGameVer == null || modInfo.loadableGameVer <= Main.gameVersionInt;
100+
}
101+
91102
/**
92103
Get all folders in the mods folder, even ones that are inactive
93104
**/

source/ModsMenuState.hx

+52-11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import flixel.tweens.FlxTween;
1616
import flixel.util.FlxColor;
1717
import lime.utils.Assets;
1818
import openfl.display.BitmapData;
19+
import openfl.net.URLLoaderDataFormat;
1920
import sys.FileSystem;
2021
import sys.io.File;
2122

@@ -30,7 +31,14 @@ typedef ModInfo = {
3031
gamebananaId:Null<Int>,
3132
id:Null<String>,
3233
devMode:Null<Bool>,
33-
requiredGameVer:Null<Int>
34+
requiredGameVer:Null<Int>,
35+
loadableGameVer:Null<Int>
36+
}
37+
38+
typedef ModMenuInfo = {
39+
antialiasIcon:Null<Bool>,
40+
antialiasBg:Null<Bool>,
41+
antialiasBlur:Null<Bool>
3442
}
3543

3644
class ModsMenuState extends MusicBeatState {
@@ -59,7 +67,7 @@ class ModsMenuState extends MusicBeatState {
5967
enables = new Map<String, Bool>();
6068
ModLoad.checkNewMods();
6169
for (cool in ModLoad.normalizeModsListFileArr(ModLoad.getModsListFileArr())) {
62-
enables.set(cool, ModLoad.enabledMods.contains(cool));
70+
enables.set(cool, ModLoad.enabledMods.contains(cool) && ModLoad.modLoadAllowed(cool));
6371
loadCreditsJson("mods/"+cool, cool);
6472
if (titleScreenWas == "" && enables.get(cool) && creditsInfo.get(currentCreditsThing.members[currentCreditsThing.length - 1].ID).titleScreen == true)
6573
titleScreenWas = cool;
@@ -74,7 +82,8 @@ class ModsMenuState extends MusicBeatState {
7482
gamebananaId: null,
7583
id: null,
7684
devMode: false,
77-
requiredGameVer: null
85+
requiredGameVer: null,
86+
loadableGameVer: null
7887
}, Paths.image("menu/moreModsIcon"));
7988
updateCheckboxes();
8089
}
@@ -125,16 +134,18 @@ class ModsMenuState extends MusicBeatState {
125134
}
126135
return creditsFile;
127136
} else {
137+
var exists = FileSystem.exists(path + "/");
128138
return {
129139
name: mod,
130-
description: fillDesc ? Translation.getTranslation("default desc", "mods", null, "This mod has no mod.json") : "",
140+
description: fillDesc ? Translation.getTranslation(exists ? "default desc" : "no exist desc", "mods", null, exists ? "This mod has no mod.json" : "This mod folder doesn't exist (possibly deleted?)") : "",
131141
version: 0,
132142
versionStr: "",
133143
titleScreen: false,
134144
gamebananaId: null,
135145
id: mod,
136146
devMode: false,
137-
requiredGameVer: null
147+
requiredGameVer: null,
148+
loadableGameVer: null
138149
};
139150
}
140151
}
@@ -156,7 +167,8 @@ class ModsMenuState extends MusicBeatState {
156167
gamebananaId: null,
157168
id: mod,
158169
devMode: false,
159-
requiredGameVer: null
170+
requiredGameVer: null,
171+
loadableGameVer: null
160172
});
161173
}
162174
}
@@ -231,8 +243,9 @@ class ModsMenuState extends MusicBeatState {
231243
exitingModsChanged = true;
232244
//ModLoad.enabledMods = newModsFile; //let's just hope nothing bad happens from reusing this var
233245
//ModLoad.reloadMods = true;
234-
if (titleThing.modName != titleScreenWas)
235-
return true;
246+
//todo: why does this crash
247+
/*if (titleThing.modName != titleScreenWas)
248+
return true;*/
236249
return false;
237250
}
238251

@@ -241,6 +254,7 @@ class ModsMenuState extends MusicBeatState {
241254
public override function update(elapsed:Float) {
242255
if (controls.BACK) {
243256
var exitingTitleChanged = checkModChanges();
257+
CoolUtil.resetMenuMusic();
244258
switchTo(new TitleState(exitingTitleChanged, true/*,exitingModsChanged || exitingTitleChanged || controls.GTSTRUM*/));
245259
//somehow only TitleState can reload mods. this doesn't make sense lol
246260
}
@@ -321,7 +335,7 @@ class ModsMenuState extends MusicBeatState {
321335
var enby = enables.get(obj.modName) == true;
322336
if (enby)
323337
enableCount++;
324-
obj.members[1].animation.play(needUpdate ? "outdated" : (enby ? "enable" : "disable"));
338+
obj.members[1].animation.play(needUpdate ? (enby ? "outdatedWeak" : "outdated") : (enby ? "enable" : "disable"));
325339
obj.members[0].alpha = enby ? 1 : 0.5;
326340
}
327341
#if desktop
@@ -361,7 +375,7 @@ class ModsMenuState extends MusicBeatState {
361375
//descVersionText.x = descTitleText.x + descTitleText.frameWidth + 2;
362376
}
363377
errorText.visible = theModInfo.requiredGameVer != null && theModInfo.requiredGameVer > Main.gameVersionInt;
364-
setBg(numbrThing.modName);
378+
setBg(numbrThing.modName, numbrThing);
365379
}
366380

367381
//Bg stuff
@@ -371,7 +385,7 @@ class ModsMenuState extends MusicBeatState {
371385
public var newBgCorner = new FlxSprite();
372386
public var bgCornerRect = new FlxRect(230, FlxG.height - 1, FlxG.width - 230, 1);
373387

374-
public inline function setBg(mod:String) {
388+
public inline function setBg(mod:String, ?item:ModMenuItem) {
375389
var bgPath = 'mods/${mod}/modmenu_bg.png';
376390
var bgImg = FileSystem.exists(bgPath) ? BitmapData.fromFile(bgPath) : null;
377391

@@ -401,6 +415,15 @@ class ModsMenuState extends MusicBeatState {
401415
newBgCorner.visible = false;
402416
}
403417

418+
if (item != null) {
419+
if (newBgCorner.visible) {
420+
newBg.antialiasing = item.menuStuff.antialiasBlur != false;
421+
newBgCorner.antialiasing = item.menuStuff.antialiasBg == true;
422+
} else {
423+
newBg.antialiasing = item.menuStuff.antialiasBg == true;
424+
}
425+
}
426+
404427
//FlxTween.tween(bgCornerRect, {y: descText.height + descText.y + 4}, 1, {ease:FlxEase.cubeOut, onUpdate: updateBgRect, onComplete: updateBgRect});
405428
bgCornerRect.y = Math.round((descText.height + descText.y + 4) / newBgCorner.scale.y);
406429
updateBgRect();
@@ -420,6 +443,16 @@ class ModsMenuState extends MusicBeatState {
420443
thisEntry.modName = mod;
421444
thisEntry.order = stuffGroup.length;
422445
thisEntry.needsNewVer = stuff.requiredGameVer > Main.gameVersionInt;
446+
if (modObjects == null) {
447+
if (FileSystem.exists('mods/${mod}/modmenu.json'))
448+
thisEntry.menuStuff = CoolUtil.loadJsonFromString(File.getContent('mods/${mod}/modmenu.json'));
449+
} else {
450+
thisEntry.menuStuff = {
451+
antialiasIcon: true,
452+
antialiasBlur: null,
453+
antialiasBg: null
454+
}
455+
}
423456
var icon = new FlxSprite(0, 0);
424457
if (image != null) {
425458
icon.loadGraphic(image);
@@ -430,13 +463,16 @@ class ModsMenuState extends MusicBeatState {
430463
else
431464
icon.loadGraphic(Paths.image("menu/noModIcon"));
432465
}
466+
icon.antialiasing = thisEntry.menuStuff.antialiasIcon == true;
433467
icon.offset.set((icon.frameWidth - 150) * 0.5, (icon.frameHeight - 150) * 0.5);
434468
thisEntry.add(icon);
435469
if (modObjects == null) {
436470
var checkmark = new FlxSprite(110, 110).loadGraphic(Paths.image("menu/modCheckmark"), true, 40, 40);
437471
checkmark.animation.add("enable", [1]);
438472
checkmark.animation.add("disable", [0]);
439473
checkmark.animation.add("outdated", [2]);
474+
checkmark.animation.add("outdatedWeak", [4]);
475+
checkmark.antialiasing = true;
440476
thisEntry.add(checkmark);
441477
}
442478
thisEntry.y = stuffGroup.length * 100;
@@ -450,4 +486,9 @@ class ModMenuItem extends FlxSpriteGroup {
450486
public var modName:String;
451487
public var order:Int;
452488
public var needsNewVer:Bool = false;
489+
public var menuStuff:ModMenuInfo = {
490+
antialiasBlur: null,
491+
antialiasBg: null,
492+
antialiasIcon: null
493+
};
453494
}

source/TitleState.hx

+5-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ class TitleState extends MusicBeatState {
117117

118118
#if polymod
119119
#if !html5
120-
var modListThing:Array<String> = File.getContent("mods/modList.txt").split("\n");
120+
/*if (!FileSystem.exists("mods/modList.txt")) {
121+
File.saveContent
122+
}*/
123+
//var modListThing:Array<String> = File.getContent("mods/modList.txt").split("\n");
124+
var modListThing:Array<String> = ModLoad.getModsListFileArr();
121125
#else
122126
var modListThing:Array<String> = [ModLoad.primaryMod];
123127
#end

version/vman_engine.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
4
2-
1.1.2
1+
5
2+
1.1.3

version/vman_engine_changelog.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
me when i hotfix twice
2-
3-
this time it fixes a bug with icons that caused basegame freeplay to crash
1+
Fixed crashes related to modList.txt and mods menu
2+
Also removed modList.txt from distributed build
3+
and added the (optional) ability to antialias stuff in mod menu

0 commit comments

Comments
 (0)