Skip to content

Commit

Permalink
Add Engine Reload/Switch Account to Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Psycast committed Sep 10, 2024
1 parent 9c8dfa7 commit f6fa3a4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 14 deletions.
26 changes: 26 additions & 0 deletions src/GlobalVariables.as
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package
import classes.User;
import classes.chart.Song;
import classes.filter.EngineLevelFilter;
import classes.mp.Multiplayer;
import classes.user.UserSongNotes;
import com.flashfla.loader.DataEvent;
import com.flashfla.net.DynamicURLLoader;
Expand All @@ -30,6 +31,7 @@ package
import flash.net.URLVariables;
import flash.system.Capabilities;
import flash.utils.ByteArray;
import game.GameMenu;
import game.GameOptions;
import game.GameScoreResult;

Expand Down Expand Up @@ -712,6 +714,30 @@ package
}
}

public function reloadEngineData():void
{
if (gameMain.loadComplete && !(gameMain.activePanel is GameMenu))
{
gameMain.removePopup();
Flags.VALUES = {};
Playlist.clearCanon();
gameMain.loadComplete = false;
gameMain.switchTo("none");
}
}

public function switchUserAccount():void
{
if (gameMain.loadComplete && !(gameMain.activePanel is GameMenu))
{
gameMain.removePopup();
Flags.VALUES = {};
Multiplayer.instance.disconnect();
playerUser.refreshUser();
gameMain.switchTo(Main.GAME_LOGIN_PANEL);
}
}

public static function get instance():GlobalVariables
{
if (_instance == null)
Expand Down
16 changes: 2 additions & 14 deletions src/popups/PopupContextMenu.as
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,11 @@ package popups
}
else if (e.target.action == "reload_engine")
{
if (_gvars.gameMain.loadComplete && !(_gvars.gameMain.activePanel is GameMenu))
{
Flags.VALUES = {};
Playlist.clearCanon();
_gvars.gameMain.loadComplete = false;
_gvars.gameMain.switchTo("none");
}
_gvars.reloadEngineData();
}
else if (e.target.action == "switch_profile")
{
if (_gvars.gameMain.loadComplete && !(_gvars.gameMain.activePanel is GameMenu))
{
Flags.VALUES = {};
Multiplayer.instance.disconnect();
_gvars.playerUser.refreshUser();
_gvars.gameMain.switchTo(Main.GAME_LOGIN_PANEL);
}
_gvars.switchUserAccount();
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions src/popups/settings/SettingsTabMisc.as
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ package popups.settings
private var useWebsocketCheckbox:BoxCheck;
private var openWebsocketOverlay:BoxButton;

private var reloadEngineData:BoxButton;
private var switchUserAccount:BoxButton;

private var engineCombo:ComboBox;
private var engineDefaultCombo:ComboBox;
private var engineComboIgnore:Boolean;
Expand Down Expand Up @@ -123,6 +126,14 @@ package popups.settings
openWebsocketOverlay = new BoxButton(container, xOff, yOff, 245, 27, _lang.string("options_overlay_instructions"), 12, clickHandler);
yOff += 30;

yOff += drawSeperator(container, xOff, 266, yOff, 0, 2);

reloadEngineData = new BoxButton(container, xOff, yOff, 245, 27, _lang.string("popup_cm_reload_engine_user"), 12, clickHandler);
yOff += 37;

switchUserAccount = new BoxButton(container, xOff, yOff, 245, 27, _lang.string("popup_cm_switch_profile"), 12, clickHandler);
yOff += 37;

/// Col 2
xOff = 310;
yOff = 15;
Expand Down Expand Up @@ -296,6 +307,17 @@ package popups.settings
navigateToURL(new URLRequest(Constant.WEBSOCKET_OVERLAY_URL), "_blank");
}

//- Engine Reload
else if (e.target == reloadEngineData)
{
_gvars.reloadEngineData();
}

else if (e.target == switchUserAccount)
{
_gvars.switchUserAccount();
}

// Window Position
else if (e.target == windowSavePositionCheck)
{
Expand Down

0 comments on commit f6fa3a4

Please sign in to comment.