#ifdef WORKBENCH modded class ERR_GameMode { protected Widget m_CheckpointMenu; protected override void StartScenario() {} protected override void EOnInit(IEntity owner) { super.EOnInit(owner); if (!SCR_Global.IsEditMode()) GetGame().GetCallqueue().CallLater(CheckpointMenuProbe, 8000, false); } void CheckpointMenuProbe() { ERR_Settings settings = new ERR_Settings("$profile:checkpoint-settings-test.json"); if (settings.Get("largeRoadblockCount") != 4 || settings.Get("mainRoadWidthMetres") != 6 || !settings.Set("roadblockCount", 7) || !settings.Set("largeRoadblockCount", 3) || !settings.Set("mainRoadWidthMetres", 8)) { Print("ERR SMOKE FAIL: checkpoint settings save", LogLevel.ERROR); return; } ERR_Settings reloaded = new ERR_Settings("$profile:checkpoint-settings-test.json"); if (reloaded.Get("roadblockCount") != 7 || reloaded.Get("largeRoadblockCount") != 3 || reloaded.Get("mainRoadWidthMetres") != 8) { Print("ERR SMOKE FAIL: independent settings reload", LogLevel.ERROR); return; } Print("ERR SMOKE PASS: independent checkpoint settings save and reload through native JSON"); m_CheckpointMenu = GetGame().GetWorkspace().CreateWidgets("{AE761C0439D25FB8}UI/layouts/ERR/AdminMenu.layout"); m_CheckpointMenu.SetZOrder(10000); foreach (string page : ERR_AdminMenuPages.Pages()) m_CheckpointMenu.FindAnyWidget(page).SetVisible(page == "CheckpointsPage"); foreach (string sidebar : ERR_AdminMenuPages.Sidebars()) m_CheckpointMenu.FindAnyWidget(sidebar).SetVisible(sidebar == "Sidebar_Forces"); foreach (string nav : ERR_AdminMenuPages.Navigation()) m_CheckpointMenu.FindAnyWidget("Selected_" + nav).SetVisible(nav == "OpenCheckpoints"); foreach (string main : ERR_AdminMenuPages.MainButtons()) m_CheckpointMenu.FindAnyWidget("Selected_" + main).SetVisible(main == "Main_Forces"); foreach (string key : {"roadblockCount", "largeRoadblockCount", "mainRoadWidthMetres"}) { SCR_EditBoxComponent edit = SCR_EditBoxComponent.GetEditBoxComponent(key, m_CheckpointMenu); if (!edit) { Print("ERR SMOKE FAIL: checkpoint numeric control", LogLevel.ERROR); return; } edit.SetValue(reloaded.Get(key).ToString()); TextWidget.Cast(m_CheckpointMenu.FindAnyWidget("Saved_" + key)).SetText("Saved: " + reloaded.Get(key).ToString() + " (next round)"); } GetGame().GetCallqueue().CallLater(CheckpointMenuCheck, 500, false); } void CheckpointMenuCheck() { m_CheckpointMenu.Update(); foreach (string name : {"CheckpointsHelp", "Label_roadblockCount", "Help_roadblockCount", "Label_largeRoadblockCount", "Help_largeRoadblockCount", "Label_mainRoadWidthMetres", "Help_mainRoadWidthMetres"}) { TextWidget text = TextWidget.Cast(m_CheckpointMenu.FindAnyWidget(name)); float width, height, textWidth, textHeight; text.GetScreenSize(width, height); text.GetTextSize(textWidth, textHeight); width = GetGame().GetWorkspace().DPIUnscale(width); height = GetGame().GetWorkspace().DPIUnscale(height); if (textWidth > width + 2 || textHeight > height + 2) { Print("ERR SMOKE FAIL: checkpoint text overflow " + name, LogLevel.ERROR); return; } } Print("ERR SMOKE PASS: checkpoint page controls and text fit native rendered widgets"); System.MakeScreenshot("$logs:err-checkpoints-menu"); GetGame().GetCallqueue().CallLater(CheckpointMenuDone, 1200, false); } void CheckpointMenuDone() { m_CheckpointMenu.RemoveFromHierarchy(); Print("ERR SMOKE COMPLETE: checkpoints-menu"); } } #endif