protected override void OnApplicationTick(float dt) { if (craftingState != null) { if (Input.DebugInput.IsHotKeyPressed("Copy")) { Input.SetClipboardText(craftingState.CraftingLogic.GetXmlCodeForCurrentItem(craftingState.CraftingLogic.GetCurrentCraftedItemObject())); InformationManager.DisplayMessage(new InformationMessage("design copied to clipboard")); } if (Input.DebugInput.IsHotKeyPressed("Paste")) { // alas, this doesn't help: // craftingState.CraftingLogic.SwitchToPiece(WeaponDesignElement.CreateUsablePiece(craftingState.CraftingLogic.CurrentCraftingTemplate.Pieces.First(p => p.StringId == "xxx"), scalePercentage)); // craftingScreen.OnCraftingLogicRefreshed(); // gotta hack it, see WeaponDesignVM.ExecuteRandomize() for the reference var craftingVM = ScreenManager.TopScreen.GetFieldValue <CraftingVM>("_dataSource"); // TopScreen us SandBox.GauntletUI.CraftingGauntletScreen in crafting state if (craftingVM.IsInCraftingMode) { var weaponDesignVM = craftingVM.WeaponDesign; var xmlDocument = new XmlDocument(); try { xmlDocument.LoadXml(Input.GetClipboardText().ToLowerInvariant()); // I know that XML is case-sensitive, but that's what TaleWorlds do in character appearance editor foreach (XmlNode pieceNode in xmlDocument.GetElementsByTagName("piece")) { var pieceType = (CraftingPiece.PieceTypes)Enum.Parse(typeof(CraftingPiece.PieceTypes), pieceNode.Attributes["type"].Value, ignoreCase: true); var pieceId = pieceNode.Attributes["id"].Value; var pieceCraftPartVM = GetCraftPartVM(weaponDesignVM, pieceType, pieceId); pieceCraftPartVM.CraftingPiece.ScalePercentage = int.Parse(pieceNode.Attributes["scale_factor"]?.Value ?? "100"); // apparently the 2nd argument to WeaponDesignVM.OnSetItemPart() has no effect beyond the UI weaponDesignVM.InvokeMethod("OnSetItemPart", pieceCraftPartVM, 0, false); } weaponDesignVM.SetFieldValue("_updatePiece", false); weaponDesignVM.RefreshItem(); weaponDesignVM.InvokeMethod("AddHistoryKey"); weaponDesignVM.SetFieldValue("_updatePiece", true); InformationManager.DisplayMessage(new InformationMessage("design pasted from clipboard")); } catch { } } } #if DEBUG // reference: Crafting.GetXmlCodeForCurrentItem() // opted for more complete representation of internals, as such weaponDesignElement.IsValid is ignored and // weaponDesignElement.CraftingPiece.StringId may be null - this will crash in such a weird way (in actual C code of Imgui // I reckon) that dnSpy is not even able to catch and you can't check backtrace etc Imgui.BeginMainThreadScope(); Imgui.Begin("CraftingLogic.SelectedPieces"); Imgui.Text($"value={craftingState.CraftingLogic.GetCurrentCraftedItemObject().Value}"); Imgui.Columns(3); foreach (var weaponDesignElement in craftingState.CraftingLogic.SelectedPieces) { Imgui.Text(weaponDesignElement.CraftingPiece.PieceType.ToString()); Imgui.NextColumn(); Imgui.Text(weaponDesignElement.CraftingPiece.StringId ?? "null"); Imgui.NextColumn(); Imgui.Text($"{weaponDesignElement.ScalePercentage}%%"); Imgui.NextColumn(); } Imgui.End(); Imgui.EndMainThreadScope(); #endif } }
private void RefreshGUI(float dt) { Imgui.BeginMainThreadScope(); Imgui.Begin("Combat Dev Feedback Reload"); if (Imgui.Button("Reload Managed Core Params")) { ManagedParameters.Instance.Initialize(ModuleInfo.GetXmlPath("CombatDevTest", "managed_core_parameters")); DisplayMessage("Reloaded managed Core Params"); } DrawReloadXMLs(); Imgui.End(); Imgui.Begin("Combat Dev Feedback Cheats"); if (Imgui.Button(" Quit")) { GameStateManager gameStateManager = Game.Current.GameStateManager; if (!(gameStateManager.ActiveState is LobbyState)) { if (gameStateManager.ActiveState is MissionState) { Imgui.End(); Imgui.EndMainThreadScope(); NetworkMain.GameClient.Logout(); return; } gameStateManager.PopState(0); } } ; DrawDevCheats(); Imgui.End(); /*Imgui.Begin(("Console")); * DrawConsole(); * Imgui.End();*/ Imgui.EndMainThreadScope(); }
protected override void OnApplicationTick(float dt) { if (IsActive()) { if (Input.IsKeyPressed(InputKey.NumpadMinus)) // TODO should be configurable { showMsgLog = !showMsgLog; } if (showMsgLog) { // TODO might be a good idea to add some checkboxes and even text input for filtering Imgui.BeginMainThreadScope(); Imgui.Begin("IM message log"); foreach (var msg in messages) { Imgui.Text(msg); } Imgui.End(); Imgui.EndMainThreadScope(); } } }
private void Begin() { Imgui.BeginMainThreadScope(); Imgui.Begin(m_WindowTitle); Imgui.Text("DO NOT MOVE THIS WINDOW! It will crash the game."); }