private void _initialise() { Panel = UIView.GetAView().AddUIComponent(typeof(UIPanel)) as UIPanel; Panel.name = "MoveIt_DebugPanel"; Panel.atlas = ResourceLoader.GetAtlas("Ingame"); Panel.backgroundSprite = "SubcategoriesPanel"; Panel.size = new Vector2(300, 107); Panel.absolutePosition = new Vector3(Panel.GetUIView().GetScreenResolution().x - 412, 3); Panel.clipChildren = true; Panel.isVisible = MoveItTool.showDebugPanel; HoverLarge = Panel.AddUIComponent <UILabel>(); HoverLarge.textScale = 0.8f; HoverLarge.text = "None"; HoverLarge.relativePosition = new Vector3(6, 7); HoverLarge.width = HoverLarge.parent.width - 20; HoverLarge.clipChildren = true; HoverLarge.useDropShadow = true; HoverLarge.dropShadowOffset = new Vector2(2, -2); HoverSmall = Panel.AddUIComponent <UILabel>(); HoverSmall.textScale = 0.65f; HoverSmall.text = "No item being hovered\n "; HoverSmall.relativePosition = new Vector3(5, 23); HoverSmall.width = HoverSmall.parent.width - 20; HoverSmall.clipChildren = true; HoverSmall.useDropShadow = true; HoverSmall.dropShadowOffset = new Vector2(1, -1); ToolStatus = Panel.AddUIComponent <UILabel>(); ToolStatus.textScale = 0.65f; ToolStatus.text = ""; ToolStatus.relativePosition = new Vector3(5, 63); ToolStatus.width = HoverSmall.parent.width - 20; ToolStatus.clipChildren = true; ToolStatus.useDropShadow = true; ToolStatus.dropShadowOffset = new Vector2(1, -1); SelectedLarge = Panel.AddUIComponent <UILabel>(); SelectedLarge.textScale = 0.8f; SelectedLarge.text = "Objects Selected: 0"; SelectedLarge.relativePosition = new Vector3(6, 79); SelectedLarge.width = SelectedLarge.parent.width - 20; SelectedLarge.clipChildren = true; SelectedLarge.useDropShadow = true; SelectedLarge.dropShadowOffset = new Vector2(2, -2); SelectedSmall = Panel.AddUIComponent <UILabel>(); SelectedSmall.textScale = 0.65f; SelectedSmall.text = "B:0, P:0, D:0, S:0, T:0, PO:0, N:0, S:0\n "; SelectedSmall.relativePosition = new Vector3(5, 94); SelectedSmall.width = SelectedSmall.parent.width - 20; SelectedSmall.clipChildren = true; SelectedSmall.useDropShadow = true; SelectedSmall.dropShadowOffset = new Vector2(1, -1); }
internal DebugPanel_ModTools(UIPanel parent) { try { Assembly mtAssembly = null; foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { if (assembly.FullName.Length >= 12 && assembly.FullName.Substring(0, 12) == "000_ModTools") { mtAssembly = assembly; break; } } if (mtAssembly == null) { return; } tModTools = mtAssembly.GetType("ModTools.ModTools"); tSceneExplorer = mtAssembly.GetType("ModTools.SceneExplorer"); tReferenceChain = mtAssembly.GetType("ModTools.ReferenceChain"); ModTools = tModTools.GetField("instance", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null); SceneExplorer = tModTools.GetField("sceneExplorer", flags).GetValue(ModTools); //Debug.Log($"\ntModTools:{tModTools}, tSceneExplorer:{tSceneExplorer}, tReferenceChain:{tReferenceChain}"); //Debug.Log($"Fields:{tModTools.GetFields().Length}, Props:{tModTools.GetProperties().Length}, Methods:{tModTools.GetMethods().Length}"); //Debug.Log($"{ModTools} ({ModTools.GetType()})\n{SceneExplorer} ({SceneExplorer.GetType()})"); rcBuildings = Activator.CreateInstance(tReferenceChain); rcBuildings = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(GameObject) }, null).Invoke(rcBuildings, new object[] { BuildingManager.instance.gameObject }); rcBuildings = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(BuildingManager) }, null).Invoke(rcBuildings, new object[] { BuildingManager.instance }); rcBuildings = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(FieldInfo) }, null).Invoke(rcBuildings, new object[] { typeof(BuildingManager).GetField("m_buildings") }); rcBuildings = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(FieldInfo) }, null).Invoke(rcBuildings, new object[] { typeof(Array16 <Building>).GetField("m_buffer") }); //Debug.Log($"rcBuildings:{rcBuildings}"); rcProps = Activator.CreateInstance(tReferenceChain); rcProps = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(GameObject) }, null).Invoke(rcProps, new object[] { PropManager.instance.gameObject }); rcProps = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(PropManager) }, null).Invoke(rcProps, new object[] { PropManager.instance }); rcProps = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(FieldInfo) }, null).Invoke(rcProps, new object[] { typeof(PropManager).GetField("m_props") }); rcProps = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(FieldInfo) }, null).Invoke(rcProps, new object[] { typeof(Array16 <PropInstance>).GetField("m_buffer") }); //Debug.Log($"rcProps:{rcProps}"); rcTrees = Activator.CreateInstance(tReferenceChain); rcTrees = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(GameObject) }, null).Invoke(rcTrees, new object[] { TreeManager.instance.gameObject }); rcTrees = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(TreeManager) }, null).Invoke(rcTrees, new object[] { TreeManager.instance }); rcTrees = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(FieldInfo) }, null).Invoke(rcTrees, new object[] { typeof(TreeManager).GetField("m_trees") }); rcTrees = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(FieldInfo) }, null).Invoke(rcTrees, new object[] { typeof(Array32 <TreeInstance>).GetField("m_buffer") }); //Debug.Log($"rcTrees:{rcTrees}"); rcNodes = Activator.CreateInstance(tReferenceChain); rcNodes = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(GameObject) }, null).Invoke(rcNodes, new object[] { NetManager.instance.gameObject }); rcNodes = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(NetManager) }, null).Invoke(rcNodes, new object[] { NetManager.instance }); rcSegments = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(FieldInfo) }, null).Invoke(rcNodes, new object[] { typeof(NetManager).GetField("m_segments") }); rcSegments = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(FieldInfo) }, null).Invoke(rcSegments, new object[] { typeof(Array16 <NetSegment>).GetField("m_buffer") }); rcNodes = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(FieldInfo) }, null).Invoke(rcNodes, new object[] { typeof(NetManager).GetField("m_nodes") }); rcNodes = tReferenceChain.GetMethod("Add", flags, null, new Type[] { typeof(FieldInfo) }, null).Invoke(rcNodes, new object[] { typeof(Array16 <NetNode>).GetField("m_buffer") }); //Debug.Log($"rcNodes:{rcNodes}\nrcSegments:{rcSegments}"); //rcPO = MoveItTool.PO.GetReferenceChain(tReferenceChain); } catch (ReflectionTypeLoadException) { SceneExplorer = null; Debug.Log($"MoveIt failed to integrate ModTools (ReflectionTypeLoadException)"); } catch (NullReferenceException) { SceneExplorer = null; Debug.Log($"MoveIt failed to integrate ModTools (NullReferenceException)"); } if (SceneExplorer == null) { return; } Id = InstanceID.Empty; Parent = parent; btn = parent.AddUIComponent <UIButton>(); btn.name = "MoveIt_ToModTools"; btn.text = ">"; btn.textScale = 0.7f; btn.tooltip = "Open in ModTools Scene Explorer"; btn.size = new Vector2(20, 20); btn.textPadding = new RectOffset(1, 0, 5, 1); btn.relativePosition = new Vector3(parent.width - 24, 22); btn.eventClicked += _toModTools; btn.atlas = ResourceLoader.GetAtlas("Ingame"); btn.normalBgSprite = "OptionBase"; btn.hoveredBgSprite = "OptionBaseHovered"; btn.pressedBgSprite = "OptionBasePressed"; btn.disabledBgSprite = "OptionBaseDisabled"; }
private void Initialise() { Panel = UIView.GetAView().AddUIComponent(typeof(UIPanel)) as UIPanel; Panel.name = "MoveIt_MoveToPanel"; Panel.atlas = ResourceLoader.GetAtlas("Ingame"); Panel.backgroundSprite = "MenuPanel2"; Panel.size = new Vector2(190, 185); Panel.absolutePosition = new Vector3(Panel.GetUIView().GetScreenResolution().x - 220, Panel.GetUIView().GetScreenResolution().y - 600); Panel.clipChildren = true; Panel.isVisible = false; Panel.anchor = UIAnchorStyle.None; TitleContainer = Panel.AddUIComponent <UISlicedSprite>(); TitleContainer.position = new Vector3(0, 0); TitleContainer.size = new Vector2(Panel.width, 40); TitleIcon = TitleContainer.AddUIComponent(typeof(UISprite)) as UISprite; TitleIcon.relativePosition = new Vector3(4, 4); TitleIcon.size = new Vector2(32, 32); TitleIcon.atlas = UIMoveItButton.GetAtlas(new string[] { "MoveIt" }); TitleIcon.spriteName = "MoveIt"; TitleCaption = TitleContainer.AddUIComponent <UILabel>(); TitleCaption.anchor = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.CenterVertical; TitleCaption.size = new Vector2(Panel.width, 40); TitleCaption.text = Str.setpos_Title; TitleDrag = TitleContainer.AddUIComponent(typeof(UIDragHandle)) as UIDragHandle; TitleDrag.relativePosition = new Vector3(0, 0); TitleDrag.size = new Vector2(Panel.width, 40); TitleDrag.target = Panel; TitleClose = TitleContainer.AddUIComponent <UIButton>(); TitleClose.atlas = ResourceLoader.GetAtlas("Ingame"); TitleClose.normalBgSprite = "buttonclose"; TitleClose.pressedBgSprite = "buttonclosepressed"; TitleClose.hoveredBgSprite = "buttonclosehover"; TitleClose.size = new Vector2(32, 32); TitleClose.relativePosition = new Vector3(Panel.width - 36, 4); TitleClose.eventClicked += (UIComponent c, UIMouseEventParameter p) => { MoveItTool.instance.DeactivateTool(); }; XLabel = Panel.AddUIComponent <UILabel>(); XLabel.relativePosition = new Vector3(8, 52); XLabel.text = "X:"; XInput = UIUtils.CreateTextField(Panel); XInput.relativePosition = new Vector3(30, 48); XInput.size = new Vector2(148, 24); XInput.horizontalAlignment = UIHorizontalAlignment.Left; XInput.tabIndex = 0; XInput.eventLostFocus += (UIComponent c, UIFocusEventParameter f) => { Validate(XInput); }; ZLabel = Panel.AddUIComponent <UILabel>(); ZLabel.relativePosition = new Vector3(8, 86); ZLabel.text = "Y:"; ZInput = UIUtils.CreateTextField(Panel); ZInput.relativePosition = new Vector3(30, 82); ZInput.size = new Vector2(148, 24); ZInput.horizontalAlignment = UIHorizontalAlignment.Left; ZInput.tabIndex = 1; ZInput.eventLostFocus += (UIComponent c, UIFocusEventParameter f) => { Validate(ZInput); }; YLabel = Panel.AddUIComponent <UILabel>(); YLabel.relativePosition = new Vector3(8, 120); YLabel.text = "H:"; YLabel.tooltip = Str.setpos_H_Tooltip; YInput = UIUtils.CreateTextField(Panel); YInput.relativePosition = new Vector3(30, 116); YInput.size = new Vector2(148, 24); YInput.horizontalAlignment = UIHorizontalAlignment.Left; YInput.tabIndex = 2; YInput.eventLostFocus += (UIComponent c, UIFocusEventParameter f) => { Validate(YInput); }; ALabel = Panel.AddUIComponent <UILabel>(); ALabel.relativePosition = new Vector3(8, 154); ALabel.text = "A:"; ALabel.tooltip = Str.setpos_A_Tooltip; AInput = UIUtils.CreateTextField(Panel); AInput.relativePosition = new Vector3(30, 150); AInput.size = new Vector2(100, 24); AInput.horizontalAlignment = UIHorizontalAlignment.Left; AInput.tabIndex = 3; AInput.eventLostFocus += (UIComponent c, UIFocusEventParameter f) => { Validate(AInput); }; Submit = UIUtils.CreateButton(Panel); Submit.relativePosition = new Vector3(138, 146); Submit.size = new Vector2(40, 30); Submit.text = Str.setpos_Go; Submit.tabIndex = 4; Submit.eventClicked += (UIComponent c, UIMouseEventParameter p) => { Go(); }; }