sarogahtyp 1108 Posted June 22, 2022 On Discord there are some Infos bout GUI creation. I just post it here to have it spread for Non-Discorders (Discord-Link to this post) Spyke — 29.05.2022 GUI Setup 1. Create the following folders in your project: UI/layouts/Modded 2. Create some layout inside the created Modded folder: myNewLayout.layout 3. Create the following folders: Scripts/Game/UI/Modded 4. Create a .c file inside the created Modded folder: myScriptedUI.c 5. Go to ArmaReforge/Configs/System/chimeraMenus.conf and rightclick/override in yourAddon 6. Go to your automatically created path Configs/System/chimeraMenus.conf and add your new GUI at the end with some ID name (myTestGui_ID). 7. Assign the Layout (myNewLayout.layout) 8. Assign the Class (myNewLayoutClass) 9. Return to the previously created: myScriptedUI.c 10. Add this: modded enum ChimeraMenuPreset { myTestGui_ID } 11. In the same file you can add your class to (I will put the code later to make it more clear): class myNewLayoutClass: ChimeraMenuBase { //your GUI code ... } 12. With this done you will be able to Open the GUI using this code somewhere: GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.myTestGui_ID); Adding functionality to your new created GUI (Hint on Button Click): 13. Go to your layout: myNewLayout.layout 14. Add one ButtonWidget and rename it to: SendHint 15. In SendHint/Script add one component called: SCR_ButtonTextComponent (and leave it with his default values for now) 16. Return to your previously created class: myNewLayoutClass and do the following code magic: class SPK_myMenuUI: ChimeraMenuBase { protected Widget m_wRoot; protected SCR_ButtonTextComponent comp; IEntity myCallerEntity; // (Added) this variable will be used only to show how to transfer parameters to the GUI. //------------------------------------------------------------------------------------------------ override void OnMenuOpen() { m_wRoot = GetRootWidget(); // SendHint comp = SCR_ButtonTextComponent.GetButtonText("SendHint", m_wRoot); if (comp) { GetGame().GetWorkspace().SetFocusedWidget(comp.GetRootWidget()); comp.m_OnClicked.Insert(myCustomFunction); } } // myCustomFunction called when SendHint Button is pressed void myCustomFunction() { SCR_HintManagerComponent.GetInstance().ShowCustomHint("This executes when pressing SendHint Button (Using OnClick)", "MY GUI", 3.0); } }; 17. (Added) You will need to change the code in step 12 if you want to be able to pass some variables to the GUI: MenuBase myMenu = GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.SPK_myTestGui); SPK_myMenuUI myMenuUI = SPK_myMenuUI.Cast(myMenu); myMenuUI.myCallerEntity = pOwnerEntity; // pOwnerEntity is the variable we want to be able to use in the GUI on this example. Share this post Link to post Share on other sites
sarogahtyp 1108 Posted June 22, 2022 On Discord there are some Infos bout GUI creation. I just post it here to have it spread for Non-Discorders (Discord-Link to this post) Spyke — 15.06.2022 I made this little tutorial it will be useful fore someone else How to create a ListBox in GUI - Layout 0. Place an OverlayWidget and resize it as you wish. 1. Search the ArmaReforger Prefab: ArmaReforger:UI/layouts/ListBox/ListBox.layout 2. Place the prefab inside the OverlayWidget created at Step 0 and change the Horizontal and Vertical Align to the 4th option. 3. Get sure that the new created ListBox0 (by default) has the component SCR_ListBoxComponent. 4. Get sure that the new created ListBox0 has a ScrollLayoutWidget ("ScrollLayout0" doesn't mater) and a VerticalLayoutWidget ("List" as name, required) created. 5. Steps 3 and 4 should be fine by default if you have used the ListBox Prefab. How to create a ListBox in GUI - Fill and GetIndex 6. Create a menu class script with the following: class SPK_myMenuUI: ChimeraMenuBase { protected Widget m_wRoot; //... OverlayWidget m_ListBoxOverlay; SCR_ListBoxComponent m_ListBoxComponent; //... //------------------------------------------------------------------------------------------------ override void OnMenuOpen() { m_wRoot = GetRootWidget(); //... // MyList m_ListBoxOverlay = OverlayWidget.Cast(m_wRoot.FindAnyWidget("ListBox0")); m_ListBoxComponent = SCR_ListBoxComponent.Cast(m_ListBoxOverlay.FindHandler(SCR_ListBoxComponent)); if (m_ListBoxComponent) { m_ListBoxComponent.AddItem("MyItem0"); m_ListBoxComponent.AddItem("MyItem1"); m_ListBoxComponent.AddItem("MyItem2"); } //... } //... }; 7. In order to get the ListBox Index you can use this: m_ListBoxComponent.GetSelectedItem(); Share this post Link to post Share on other sites
squeeze 22 Posted June 24, 2022 step 12 test in trigger, needed restart of Workbench to work...ver 0.9.5.73 Share this post Link to post Share on other sites
sarogahtyp 1108 Posted June 24, 2022 Closing the complete menu can be done this way: MenuBase teleportMenu = GetGame().GetMenuManager().GetOwnerMenu(widgetRoot); GetGame().GetMenuManager().CloseMenu(teleportMenu); My complete class with 2 working buttons, one button hints something, the second closes the menu: Spoiler modded enum ChimeraMenuPreset { SARO_MHQMenuGUIEnumerator } class SARO_MHQMenuGUI: ChimeraMenuBase { protected Widget widgetRoot; protected SCR_ButtonTextComponent buttonTeleport, buttonCancel; IEntity myCallerEntity; // this variable will be used only to show how to transfer parameters to the GUI. override void OnMenuOpen() { widgetRoot = GetRootWidget(); // SendHint buttonTeleport = SCR_ButtonTextComponent.GetButtonText("Teleport", widgetRoot); buttonCancel = SCR_ButtonTextComponent.GetButtonText("Cancel", widgetRoot); if (buttonTeleport) { GetGame().GetWorkspace().SetFocusedWidget(buttonTeleport.GetRootWidget()); buttonTeleport.m_OnClicked.Insert(DoTeleport); } if (buttonCancel) { GetGame().GetWorkspace().SetFocusedWidget(buttonCancel.GetRootWidget()); buttonCancel.m_OnClicked.Insert(DoCancel); } } // myCustomFunction called when SendHint Button is pressed void DoTeleport() { SCR_HintManagerComponent.GetInstance().ShowCustomHint("This executes when pressing Teleport Button (Using OnClick)", "MY GUI", 3.0); } void DoCancel() { MenuBase teleportMenu = GetGame().GetMenuManager().GetOwnerMenu(widgetRoot); GetGame().GetMenuManager().CloseMenu(teleportMenu); } }; Share this post Link to post Share on other sites