Layout Creation – Arma Reforger
Lou Montana (talk | contribs) (Page creation) |
Lou Montana (talk | contribs) m (Text replacement - "{{Link|Arma Reforger:Resource Manager|Resource Manager}}" to "{{Link|Arma Reforger:Resource Manager}}") |
||
(4 intermediate revisions by the same user not shown) | |||
Line 29: | Line 29: | ||
== Create a Layout == | == Create a Layout == | ||
Using {{Link|Arma Reforger: | Using {{Link|Arma Reforger:Resource Manager}}, open the mod's directory and create the directory tree {{hl|UI\layouts}}; | ||
in it, '''right-click > GUI layout''' (or the '''Create button > GUI layout''') to create a {{hl|.layout}} file - this is our new layout. | in it, '''right-click > GUI layout''' (or the '''Create button > GUI layout''') to create a {{hl|.layout}} file - this is our new layout. | ||
Line 43: | Line 43: | ||
The first widget is an important one; this button will be used to close the opened UI. | The first widget is an important one; this button will be used to close the opened UI. | ||
Place a {{Link|enfusion://ResourceManager/~ArmaReforger:UI/layouts/WidgetLibrary/Buttons/WLib_ButtonText.layout|WLib_ButtonText.layout}} button. In the Hierarchy window, name it {{hl|ButtonClose}}. | Place a {{Link|enfusion://ResourceManager/~ArmaReforger:UI/layouts/WidgetLibrary/Buttons/WLib_ButtonText.layout|WLib_ButtonText.layout}} button by dragging the layout file from the Resource Browser into the opened layout. | ||
In the Hierarchy window, name it {{hl|ButtonClose}}. | |||
{{Feature|informative| | {{Feature|informative| | ||
Line 55: | Line 56: | ||
However, as this prefab uses a {{Link/Enfusion|armaR|SCR_ButtonTextComponent}} script component, the displayed value is set within this component. | However, as this prefab uses a {{Link/Enfusion|armaR|SCR_ButtonTextComponent}} script component, the displayed value is set within this component. | ||
Click on '''ButtonClose''' (the prefab's topmost widget) and under | Click on '''ButtonClose''' (the prefab's topmost widget) and in its properties, under {{Link|Arma Reforger:Resource Manager: Layout Editor#Script|Script}}, find this said component to change its {{hl|Text}} property. | ||
=== Add the Title Text === | === Add the Title Text === | ||
Line 73: | Line 74: | ||
Menus and Dialogs share the same first steps: | Menus and Dialogs share the same first steps: | ||
* Add an enum by modding the {{Link/Enfusion|armaR|ChimeraMenuPreset}} enum in a new script file:<enforce> | * Add an enum constant by {{Link|Arma Reforger:Scripting Modding|modding}} the {{Link/Enfusion|armaR|ChimeraMenuPreset}} enum in a new script file:<enforce> | ||
modded enum ChimeraMenuPreset | modded enum ChimeraMenuPreset | ||
{ | { | ||
TAG_LayoutTutorialExample, | TAG_LayoutTutorialExample, | ||
} | } | ||
</enforce> | </enforce> | ||
* ''Override'' chimeraMenus.conf in the mod (right-click → override in LayoutTutorial) | * ''Override'' chimeraMenus.conf in the mod (see {{Link|Arma Reforger:Data Modding Basics#Overriding_assets}} - right-click → {{hl|override in LayoutTutorial}}) | ||
* Declare this new layout in it by adding an entry (clicking the "+" button): | * Declare this new layout in it by adding an entry (clicking the "+" button): | ||
** The entry name ("object name" required on new entry) '''must''' match the enum | ** The entry name ("object name" required on new entry) '''must''' match the enum constant, here {{hl|TAG_LayoutTutorialExample}}, otherwise the engine will not be able to find the menu and will throw an error | ||
** '''Layout''' - the path to the created layout | ** '''Layout''' - the path to the created layout | ||
** '''Action Context''' - ''unused in this tutorial'' | ** '''Action Context''' - ''unused in this tutorial'' | ||
Line 202: | Line 203: | ||
textTitle.SetText(result); | textTitle.SetText(result); | ||
} | } | ||
} | } | ||
</enforce> | </enforce> | ||
</spoiler> | </spoiler> | ||
Line 232: | Line 233: | ||
class TAG_ScriptedUserAction : ScriptedUserAction | class TAG_ScriptedUserAction : ScriptedUserAction | ||
{ | { | ||
[Attribute(defvalue: "{74A4182551CBD740}UI/layouts/TAG_LayoutTutorial.layout")] | [Attribute(defvalue: "{74A4182551CBD740}UI/layouts/TAG_LayoutTutorial.layout")] // setup the created layout here | ||
protected ResourceName m_sLayout; | protected ResourceName m_sLayout; | ||
protected ref Widget m_wDisplay; | protected ref Widget m_wDisplay; | ||
} | } | ||
class TAG_DisplayAction : TAG_ScriptedUserAction | class TAG_DisplayAction : TAG_ScriptedUserAction | ||
Line 261: | Line 262: | ||
return true; | return true; | ||
} | } | ||
} | } | ||
class TAG_MenuAction : TAG_ScriptedUserAction | class TAG_MenuAction : TAG_ScriptedUserAction | ||
Line 287: | Line 288: | ||
return true; | return true; | ||
} | } | ||
} | } | ||
class TAG_DialogAction : TAG_ScriptedUserAction | class TAG_DialogAction : TAG_ScriptedUserAction | ||
Line 313: | Line 314: | ||
return true; | return true; | ||
} | } | ||
} | } | ||
</enforce> | </enforce> | ||
</spoiler> | </spoiler> | ||
Using these actions allow to see the different behaviours of said interface. | Using these actions allow to see the different behaviours of said interface - be sure to set the action's default layout ({{hl|m_sLayout}} either in code or in Action's configuration UI. | ||
Latest revision as of 00:59, 12 January 2024
Definitions
Display
A display is a layout that only provides information to the player; it does not require any input. The player can control his character normally, movement/cursor are not captured.
Menu
A menu is an interface that provides choices or functionality to the player.
Dialog
A dialog is an interface that requires player's input. There can be multiple dialogs at the same time, they are then ordered by priority. It is displayed on top of a menu, if any is present.
Widget
A widget is an element composing a layout - a button, a text, a scrollbar, any "layout part" is a widget.
Create a Mod
See Mod Project Setup.
Create a Layout
Using Resource Manager, open the mod's directory and create the directory tree UI
Double-click on it to open it, using the Layout Editor to edit it.
This first example will sport three features: a title, a change text button and a close button.
- Clicking the change button will change the title
- Clicking the close button will close the UI
- Clicking the title will do nothing.
Add the Close Button
The first widget is an important one; this button will be used to close the opened UI.
Place a WLib_ButtonText.layout button by dragging the layout file from the Resource Browser into the opened layout. In the Hierarchy window, name it ButtonClose.
To change this button's text, one could be tempted to change ButtonClose > SizeLayout > Overlay > Text's Text property.
However, as this prefab uses a SCR_ButtonTextComponent script component, the displayed value is set within this component.
Click on ButtonClose (the prefab's topmost widget) and in its properties, under Script, find this said component to change its Text property.
Add the Title Text
The second widget is the title. Place a RichText_Heading2.layout and name it "TextTitle".
Add the Change Text Button
Place another WLib_ButtonText.layout button and name it ButtonChange.
Menu/Dialog Setup
Menus and Dialogs share the same first steps:
- Add an enum constant by modding the ChimeraMenuPreset enum in a new script file:modded enum ChimeraMenuPreset { TAG_LayoutTutorialExample, }
- Override chimeraMenus.conf in the mod (see Data Modding Basics - Overriding_assets - right-click → override in LayoutTutorial)
- Declare this new layout in it by adding an entry (clicking the "+" button):
- The entry name ("object name" required on new entry) must match the enum constant, here TAG_LayoutTutorialExample, otherwise the engine will not be able to find the menu and will throw an error
- Layout - the path to the created layout
- Action Context - unused in this tutorial
- Class - the script class to be used with the menu/dialog, see the next chapter where we will create the TAG_LayoutTutorialUI class.
- Menu Items - unused in this tutorial
- Preload Count - unused in this tutorial
- Persistent - unused in this tutorial
Class Setup
The menu/dialog class must inherit from at least MenuBase, ChimeraMenuBase or MenuRootBase, depending on the required features.
Here is the example adapted to our earlier layout:
Usage
In order to test more easily, we can place a prefab with an ActionsManagerComponent to add actions that trigger UI creation. Each action targets a specific type (display, menu, dialog and their respective classes, TAG_DisplayAction, TAG_MenuAction and TAG_DialogAction).
Display
Menu
Dialog
Code
Using these actions allow to see the different behaviours of said interface - be sure to set the action's default layout (m_sLayout either in code or in Action's configuration UI.
See Also
MenuManager's various methods, including:
- IsAnyDialogOpen() - check if an existing dialog exists
- GetTopMenu() - get the topmost menu
- CloseAllMenus() - close all opened menus