internal void ShowError(String modName, String modVersion, Exception error, String where = "") { if (_debugWindow == null) { _errorBeforeLoad.Add(new ExceptionInfo() { ModName = modName, ModVersion = modVersion, Error = error, Where = where }); return; } String msg = "<color=red>"; if (!String.IsNullOrEmpty(where)) { msg += "<b>" + modName + "</b> threw an error during the <i>" + where + " process</i>\n"; } else { msg += "<b>" + modName + "</b> threw an error:\n"; } msg += ExceptionToMessage(error); msg += "</color>"; _debugWindow.Title = "Error - " + modName + (!String.IsNullOrEmpty(modVersion) ? (" (" + modVersion + ")") : ""); GUI.TextArea log = (GUI.TextArea)_debugWindow.Items.First(); log.Text = msg; _debugWindow.Visible = true; }
private void SetupGUI(GameObject mainMenuRight) { _SelectedScenario = null; _ScenarioWindow = new GUI.Window(ModGUI.GetWindowIndex(), "Scenarios") { IsDraggable = true, IsResizeable = true, IsCloseable = true, Rect = new Rect((Screen.width / 2) - 200, (Screen.height / 2) - 200, 400, 400), Visible = false, MinWidth = 200, MinHeight = 200 }; _ScenarioWindow.WindowClosed += _ScenarioWindow_WindowClosed; GUI.Group group = new GUI.Group(GUI.GUIItem.Direction.Vertical); _ScenarioWindow.Items.Add(group); GUI.Group group1 = new GUI.Group(GUI.GUIItem.Direction.Horizontal); group.Items.Add(group1); lstScenarios = new GUI.Group(GUI.GUIItem.Direction.Vertical); group1.Items.Add(lstScenarios); foreach (Scenario scenario in Scenarios) { GUI.Button btn = new GUI.Button(scenario.Name) { Tag = scenario }; btn.Clicked += ScenarioBtn_Clicked; lstScenarios.Items.Add(btn); } _ScenarioInfo = new GUI.Group(GUI.GUIItem.Direction.Vertical) { Visible = false }; group1.Items.Add(_ScenarioInfo); _Name = new GUI.Label(""); _ScenarioInfo.Items.Add(_Name); _Desc = new GUI.TextArea("") { IsEditable = false, IsRichText = true }; _ScenarioInfo.Items.Add(_Desc); _ThumbNail = new GUI.Box("") { Visible = false, MaxWidth = 200, MaxHeight = 200 }; _ScenarioInfo.Items.Add(_ThumbNail); GUI.Group btnGroup = new GUI.Group(GUI.GUIItem.Direction.Horizontal); group.Items.Add(btnGroup); _CancelBtn = new GUI.Button("Cancel"); _CancelBtn.Clicked += CancelBtn_Clicked; btnGroup.Items.Add(_CancelBtn); btnGroup.Items.Add(new GUI.FlexibleSpace()); _LoadBtn = new GUI.Button("Load") { IsEnabled = false }; _LoadBtn.Clicked += LoadBtn_Clicked; btnGroup.Items.Add(_LoadBtn); }