Fix Window Mod TItle, Icon
This commit is contained in:
@@ -26,8 +26,8 @@ class Flags {
|
||||
public static var MOD_DOWNLOAD_LINK:String = "";
|
||||
public static var MOD_DEPENDENCIES:Array<String> = [];
|
||||
|
||||
@:noCompletion public static var MOD_ICON64:String = "";
|
||||
@:noCompletion public static var MOD_ICON32:String = "";
|
||||
@:noCompletion public static var MOD_ICON24:String = "";
|
||||
@:noCompletion public static var MOD_ICON16:String = "";
|
||||
public static var MOD_ICON:String = "";
|
||||
|
||||
@@ -46,6 +46,7 @@ class Flags {
|
||||
public static var COMMIT_HASH:String = GitCommitMacro.commitHash;
|
||||
public static var COMMIT_MESSAGE:String = 'Commit $COMMIT_NUMBER ($COMMIT_HASH)';
|
||||
|
||||
@:bypass public static var WINDOW_TITLE_USE_MOD_NAME:Bool = false;
|
||||
@:lazy public static var TITLE:String = Application.current.meta.get('name');
|
||||
@:lazy public static var VERSION:String = Application.current.meta.get('version');
|
||||
|
||||
@@ -283,6 +284,8 @@ class Flags {
|
||||
else trace('Invalid section $name');
|
||||
}
|
||||
}
|
||||
|
||||
WINDOW_TITLE_USE_MOD_NAME = !flags.exists('TITLE');
|
||||
}
|
||||
|
||||
public static function loadFromDatas(datas:Array<String>) {
|
||||
|
||||
@@ -112,7 +112,7 @@ class MainState extends FlxState {
|
||||
TranslationUtil.setLanguage(Flags.DISABLE_LANGUAGES ? Flags.DEFAULT_LANGUAGE : null);
|
||||
ModsFolder.onModSwitch.dispatch(ModsFolder.currentModFolder); // Loads global.hx
|
||||
MusicBeatTransition.script = Flags.DEFAULT_TRANSITION_SCRIPT;
|
||||
WindowUtils.resetTitle();
|
||||
WindowUtils.resetAffixes(false);
|
||||
WindowUtils.setWindow();
|
||||
Main.refreshAssets();
|
||||
DiscordUtil.init();
|
||||
|
||||
@@ -45,16 +45,17 @@ final class WindowUtils {
|
||||
* Resets the window title to the application name and resets the prefix and suffix.
|
||||
**/
|
||||
public static inline function resetTitle() {
|
||||
title = Flags.TITLE == null ? Lib.application.meta.get('name') : Flags.TITLE;
|
||||
resetAffixes();
|
||||
resetAffixes(false);
|
||||
title = Flags.TITLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the prefix and suffix.
|
||||
* @param update Should it update window title.
|
||||
**/
|
||||
public static inline function resetAffixes() {
|
||||
public static inline function resetAffixes(update = true) {
|
||||
prefix = suffix = "";
|
||||
updateTitle();
|
||||
if (update) updateTitle();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,11 +63,13 @@ final class WindowUtils {
|
||||
* @param title The title to set.
|
||||
* @param image The image to set as the icon.
|
||||
**/
|
||||
public static inline function setWindow(?name:String, ?image:String)
|
||||
public static inline function setWindow(?title:String, ?image:String)
|
||||
{
|
||||
if (Flags.MOD_ICON == null && image == null) return;
|
||||
Lib.application.window.setIcon(lime.graphics.Image.fromBytes(Assets.getBytes(Paths.image(image != null ? image : Flags.MOD_ICON))));
|
||||
title = name != null ? name : Flags.MOD_NAME;
|
||||
// TODO: Implement ICON SIZES in Flags.
|
||||
WindowUtils.title = title != null ? title : (Flags.WINDOW_TITLE_USE_MOD_NAME ? Flags.MOD_NAME : Flags.TITLE);
|
||||
|
||||
var iconPath = image != null ? image : Flags.MOD_ICON;
|
||||
if (Assets.exists(Paths.image(iconPath))) Lib.application.window.setIcon(lime.graphics.Image.fromBytes(Assets.getBytes(Paths.image(iconPath))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user