Skip to content

Commit

Permalink
refactor and small hscript fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Joalor64GH authored Nov 8, 2024
1 parent 24b098c commit def7709
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/05 - adding-custom-credits.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ Explanation:
* `name` - The user's name.
* `iconData` - An array with the filename for their icon, and optional X and Y offsets for positioning the icon.
* `textData` - Includes the user's contribution and an optional description.
* `urlData` - A list of links related to the user. Each entry is an array: the first element is the platform name, and the second is the URL.
* `urlData` - A list of links related to the user. Each entry is an array: the first element is the platform name, and the second is the URL, or you can set it to `nolink`.
* `colors` - An array using RGB values to set the background to a custom color (`[R, G, B]`).
10 changes: 10 additions & 0 deletions source/backend/Utilities.hx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ class Utilities {
}
}

public static function openUrlPlease(url:String) {
#if linux
var cmd = Sys.command("xdg-open", [url]);
if (cmd != 0) cmd = Sys.command("/usr/bin/xdg-open", [url]);
Sys.command('/usr/bin/xdg-open', [url]);
#else
FlxG.openURL(url);
#end
}

public static function wait(milliseconds:Int, callback:Void->Void):Void {
Timer.delay(callback, milliseconds);
}
Expand Down
4 changes: 2 additions & 2 deletions source/modding/Hscript.hx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class Hscript extends FlxBasic {

setVariable('importScript', function(source:String) {
var name:String = StringTools.replace(source, '.', '/');
var script:Hscript = new Hscript(name, false);
script.execute(name, false);
var script:Hscript = new Hscript('$name.hxs', false);
script.execute('$name.hxs', false);
return script.getAll();
});

Expand Down
9 changes: 4 additions & 5 deletions source/states/CreditsState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,10 @@ class CreditsState extends ExtendableState {
updateSocial(Input.justPressed('left') ? -1 : 1);

if (Input.justPressed('accept') && credData.users[curSelected].urlData[curSocial][1] != null) {
#if linux
Sys.command('/usr/bin/xdg-open', [credData.users[curSelected].urlData[curSocial][1]]);
#else
FlxG.openURL(credData.users[curSelected].urlData[curSocial][1]);
#end
if ((credData.users[curSelected].urlData[curSocial][1] == "nolink"))
FlxG.sound.play(Paths.sound('cancel'));
else
Utilities.openUrlPlease(credData.users[curSelected].urlData[curSocial][1]);
}

if (Input.justPressed('exit')) {
Expand Down
9 changes: 1 addition & 8 deletions source/states/UpdateState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,7 @@ class UpdateState extends ExtendableState {
ExtendableState.switchState(new TitleState());
if (!Input.justPressed('exit')) {
FlxG.sound.play(Paths.sound('select'));
var url:String = "https://github.com/Joalor64GH/Rhythmo-SC/releases/latest";
#if linux
var cmd = Sys.command("xdg-open", [url]);
if (cmd != 0) cmd = Sys.command("/usr/bin/xdg-open", [url]);
Sys.command('/usr/bin/xdg-open', [url]);
#else
FlxG.openURL(url);
#end
Utilities.openUrlPlease("https://github.com/Joalor64GH/Rhythmo-SC/releases/latest");
} else
FlxG.sound.play(Paths.sound('cancel'));
}
Expand Down

0 comments on commit def7709

Please sign in to comment.