Simplify GUI g_IsController variable init, equivalent to 100be98215
.
Just test if a NetServer is present rather than passing a state boolean from GUI page to GUI page. This was SVN commit r21651.
This commit is contained in:
parent
100be98215
commit
f4749a8e2c
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* Is this user in control of game settings (i.e. is a network server, or offline player).
|
||||
*/
|
||||
const g_IsController = !Engine.HasNetClient() || Engine.HasNetServer();
|
||||
|
||||
var g_PlayerSlot;
|
||||
|
||||
var g_AIDescriptions = [{
|
||||
@ -33,11 +38,11 @@ function init(settings)
|
||||
let control = Engine.GetGUIObjectByName(name);
|
||||
control.list = g_AIControls[name].labels;
|
||||
control.selected = g_AIControls[name].selected(settings);
|
||||
control.hidden = !settings.isController;
|
||||
control.hidden = !g_IsController;
|
||||
|
||||
let label = Engine.GetGUIObjectByName(name + "Text");
|
||||
label.caption = control.list[control.selected];
|
||||
label.hidden = settings.isController;
|
||||
label.hidden = g_IsController;
|
||||
}
|
||||
|
||||
checkBehavior();
|
||||
|
@ -228,9 +228,9 @@ var g_TriggerDifficultyList;
|
||||
const g_IsNetworked = Engine.HasNetClient();
|
||||
|
||||
/**
|
||||
* Is this user in control of game settings (i.e. singleplayer or host of a multiplayergame).
|
||||
* Is this user in control of game settings (i.e. is a network server, or offline player).
|
||||
*/
|
||||
var g_IsController;
|
||||
const g_IsController = !g_IsNetworked || Engine.HasNetServer();
|
||||
|
||||
/**
|
||||
* Whether this is a tutorial.
|
||||
@ -1106,7 +1106,6 @@ function init(attribs)
|
||||
return;
|
||||
}
|
||||
|
||||
g_IsController = attribs.type != "client";
|
||||
g_IsTutorial = !!attribs.tutorial;
|
||||
g_ServerName = attribs.serverName;
|
||||
g_ServerPort = attribs.serverPort;
|
||||
@ -1506,8 +1505,7 @@ function handleGamestartMessage(message)
|
||||
|
||||
Engine.SwitchGuiPage("page_loading.xml", {
|
||||
"attribs": g_GameAttributes,
|
||||
"playerAssignments": g_PlayerAssignments,
|
||||
"isController": g_IsController
|
||||
"playerAssignments": g_PlayerAssignments
|
||||
});
|
||||
}
|
||||
|
||||
@ -2363,7 +2361,6 @@ function openAIConfig(playerSlot)
|
||||
|
||||
Engine.PushGuiPage("page_aiconfig.xml", {
|
||||
"callback": "AIConfigCallback",
|
||||
"isController": g_IsController,
|
||||
"playerSlot": playerSlot,
|
||||
"id": g_GameAttributes.settings.PlayerData[playerSlot].AI,
|
||||
"difficulty": g_GameAttributes.settings.PlayerData[playerSlot].AIDiff,
|
||||
|
@ -44,16 +44,16 @@ var g_Ambient = ["audio/ambient/dayscape/day_temperate_gen_03.ogg"];
|
||||
*/
|
||||
const g_GameAttributes = deepfreeze(Engine.GetInitAttributes());
|
||||
|
||||
/**
|
||||
* Is this user in control of game settings (i.e. is a network server, or offline player).
|
||||
*/
|
||||
var g_IsController;
|
||||
|
||||
/**
|
||||
* True if this is a multiplayer game.
|
||||
*/
|
||||
const g_IsNetworked = Engine.HasNetClient();
|
||||
|
||||
/**
|
||||
* Is this user in control of game settings (i.e. is a network server, or offline player).
|
||||
*/
|
||||
var g_IsController = !g_IsNetworked || Engine.HasNetServer();
|
||||
|
||||
/**
|
||||
* Whether we have finished the synchronization and
|
||||
* can start showing simulation related message boxes.
|
||||
@ -263,7 +263,6 @@ function init(initData, hotloadData)
|
||||
|
||||
if (initData)
|
||||
{
|
||||
g_IsController = initData.isController;
|
||||
g_PlayerAssignments = initData.playerAssignments;
|
||||
g_ReplaySelectionData = initData.replaySelectionData;
|
||||
g_HasRejoined = initData.isRejoining;
|
||||
|
@ -34,9 +34,14 @@ u16 JSI_Network::GetDefaultPort(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
||||
return PS_DEFAULT_PORT;
|
||||
}
|
||||
|
||||
bool JSI_Network::HasNetServer(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
||||
{
|
||||
return g_NetServer;
|
||||
}
|
||||
|
||||
bool JSI_Network::HasNetClient(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
||||
{
|
||||
return !!g_NetClient;
|
||||
return g_NetClient;
|
||||
}
|
||||
|
||||
JS::Value JSI_Network::FindStunEndpoint(ScriptInterface::CxPrivate* pCxPrivate, int port)
|
||||
@ -219,6 +224,7 @@ void JSI_Network::SetTurnLength(ScriptInterface::CxPrivate* UNUSED(pCxPrivate),
|
||||
void JSI_Network::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
|
||||
{
|
||||
scriptInterface.RegisterFunction<u16, &GetDefaultPort>("GetDefaultPort");
|
||||
scriptInterface.RegisterFunction<bool, &HasNetServer>("HasNetServer");
|
||||
scriptInterface.RegisterFunction<bool, &HasNetClient>("HasNetClient");
|
||||
scriptInterface.RegisterFunction<JS::Value, int, &FindStunEndpoint>("FindStunEndpoint");
|
||||
scriptInterface.RegisterFunction<void, CStrW, u16, CStr, bool, &StartNetworkHost>("StartNetworkHost");
|
||||
|
@ -24,6 +24,7 @@
|
||||
namespace JSI_Network
|
||||
{
|
||||
u16 GetDefaultPort(ScriptInterface::CxPrivate* pCxPrivate);
|
||||
bool HasNetServer(ScriptInterface::CxPrivate* pCxPrivate);
|
||||
bool HasNetClient(ScriptInterface::CxPrivate* pCxPrivate);
|
||||
void StartNetworkGame(ScriptInterface::CxPrivate* pCxPrivate);
|
||||
void SetNetworkGameAttributes(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue attribs1);
|
||||
|
Loading…
Reference in New Issue
Block a user