Add a Dev Overlay checkbox to activate RejoinTest from the session.
This makes this feature, very useful for checking for OOS, more easily accessible. Differential Revision: https://code.wildfiregames.com/D3199 This was SVN commit r24407.
This commit is contained in:
parent
e22a915351
commit
82d079d06c
@ -6,6 +6,7 @@ class DeveloperOverlayCheckbox
|
||||
constructor(handler, i)
|
||||
{
|
||||
this.handler = handler;
|
||||
this.handler.update = () => this.update();
|
||||
|
||||
this.label = Engine.GetGUIObjectByName("dev_command_label[" + i + "]");
|
||||
this.label.caption = this.handler.label();
|
||||
@ -25,14 +26,15 @@ class DeveloperOverlayCheckbox
|
||||
onPress()
|
||||
{
|
||||
this.handler.onPress(this.checkbox.checked);
|
||||
|
||||
if (this.handler.checked)
|
||||
this.update();
|
||||
this.update();
|
||||
}
|
||||
|
||||
update()
|
||||
{
|
||||
this.checkbox.checked = this.handler.checked();
|
||||
if (this.handler.checked)
|
||||
this.checkbox.checked = this.handler.checked();
|
||||
if (this.handler.enabled)
|
||||
this.checkbox.enabled = this.handler.enabled();
|
||||
}
|
||||
|
||||
setHidden(hidden)
|
||||
|
@ -201,6 +201,46 @@ DeveloperOverlayCheckboxes.prototype.EnableTimeWarp = class
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
DeveloperOverlayCheckboxes.prototype.ActivateRejoinTest = class
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
this.disabled = false;
|
||||
}
|
||||
|
||||
label()
|
||||
{
|
||||
return translate("Activate Rejoin Test");
|
||||
}
|
||||
|
||||
onPress(checked)
|
||||
{
|
||||
let box = new SessionMessageBox();
|
||||
box.Title = "Rejoin Test";
|
||||
box.Caption = "Warning: the rejoin test can't be de-activated and is quite slow. Its only purpose is to check for OOS.";
|
||||
let self = this;
|
||||
box.Buttons = [
|
||||
{ "caption": "Cancel" }, { "caption": "OK", "onPress": () => {
|
||||
Engine.ActivateRejoinTest();
|
||||
this.disabled = true;
|
||||
this.update();
|
||||
} }
|
||||
];
|
||||
box.display();
|
||||
}
|
||||
|
||||
checked()
|
||||
{
|
||||
return this.disabled;
|
||||
}
|
||||
|
||||
enabled()
|
||||
{
|
||||
return !this.disabled && g_GameAttributes.mapType != "random";
|
||||
}
|
||||
};
|
||||
|
||||
DeveloperOverlayCheckboxes.prototype.PromoteSelectedUnits = class
|
||||
{
|
||||
label()
|
||||
|
@ -113,6 +113,13 @@ JS::Value JSI_SavedGame::StartSavedGame(ScriptInterface::CmptPrivate* pCmptPriva
|
||||
return guiContextMetadata;
|
||||
}
|
||||
|
||||
void ActivateRejoinTest(ScriptInterface::CmptPrivate*)
|
||||
{
|
||||
if (!g_Game || !g_Game->GetSimulation2() || !g_Game->GetTurnManager())
|
||||
return;
|
||||
g_Game->GetSimulation2()->ActivateRejoinTest(g_Game->GetTurnManager()->GetCurrentTurn() + 1);
|
||||
}
|
||||
|
||||
void JSI_SavedGame::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
|
||||
{
|
||||
scriptInterface.RegisterFunction<JS::Value, &GetSavedGames>("GetSavedGames");
|
||||
@ -121,5 +128,6 @@ void JSI_SavedGame::RegisterScriptFunctions(const ScriptInterface& scriptInterfa
|
||||
scriptInterface.RegisterFunction<void, std::wstring, std::wstring, JS::HandleValue, &SaveGamePrefix>("SaveGamePrefix");
|
||||
scriptInterface.RegisterFunction<void, JS::HandleValue, &QuickSave>("QuickSave");
|
||||
scriptInterface.RegisterFunction<void, &QuickLoad>("QuickLoad");
|
||||
scriptInterface.RegisterFunction<void, &ActivateRejoinTest>("ActivateRejoinTest");
|
||||
scriptInterface.RegisterFunction<JS::Value, std::wstring, &StartSavedGame>("StartSavedGame");
|
||||
}
|
||||
|
@ -898,6 +898,14 @@ bool CSimulation2::DeserializeState(std::istream& stream)
|
||||
return m->m_ComponentManager.DeserializeState(stream);
|
||||
}
|
||||
|
||||
void CSimulation2::ActivateRejoinTest(int turn)
|
||||
{
|
||||
if (m->m_RejoinTestTurn != -1)
|
||||
return;
|
||||
LOGMESSAGERENDER("Rejoin test will activate in %i turns", turn - m->m_TurnNumber);
|
||||
m->m_RejoinTestTurn = turn;
|
||||
}
|
||||
|
||||
std::string CSimulation2::GenerateSchema()
|
||||
{
|
||||
return m->m_ComponentManager.GenerateSchema();
|
||||
|
@ -229,6 +229,11 @@ public:
|
||||
bool SerializeState(std::ostream& stream);
|
||||
bool DeserializeState(std::istream& stream);
|
||||
|
||||
/**
|
||||
* Activate the rejoin-test feature for turn @param turn.
|
||||
*/
|
||||
void ActivateRejoinTest(int turn);
|
||||
|
||||
std::string GenerateSchema();
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user