Resource Manager: Generate Class From Layout Plugin – Arma Reforger

From Bohemia Interactive Community
Jump to navigation Jump to search

Generate Class from Layout

Resource Manager plugin

Create a script file with member variables pointing to main widgets

File: SCR_GenerateLayoutClassPlugin.c

This plugin generates a scripted class with variables for widgets and code to find widgets by their name. It also generates code to find all widget components.


Usage

  • Open the layout to be exported to script
  • Use Plugins > Generate Class from Layout
  • Confirm the displayed window using the Generate button

The layout needs:

  • to be opened in Resource Manager and its tab focused
  • to carry a SCR_WidgetExportRuleRoot
  • widgets to be exported in script names prefixed with m_ (ideally m_w by convention - widget variables will begin with the m_w prefix anyway)


Example Output

(Used on StatsPanel.layout)

// Autogenerated by the Generate Class from Layout plugin v0.5.1 // Layout file: UI/layouts/HUD/StatsPanel/StatsPanel.layout class SCR_StatsPanelWidgets { protected static const ResourceName LAYOUT = "{0A3C9C22CBDE338F}UI/layouts/HUD/StatsPanel/StatsPanel.layout"; HorizontalLayoutWidget m_wColorOpacity; ImageWidget m_wIconGlow; ImageWidget m_wIcon; TextWidget m_wLabel; TextWidget m_wTextPlaceholder; TextWidget m_wText; //------------------------------------------------------------------------------------------------ bool Init(notnull Widget root) { m_wColorOpacity = HorizontalLayoutWidget.Cast(root.FindAnyWidget("m_wColorOpacity")); m_wIconGlow = ImageWidget.Cast(root.FindAnyWidget("m_wIconGlow")); m_wIcon = ImageWidget.Cast(root.FindAnyWidget("m_wIcon")); m_wLabel = TextWidget.Cast(root.FindAnyWidget("m_wLabel")); m_wTextPlaceholder = TextWidget.Cast(root.FindAnyWidget("m_wTextPlaceholder")); m_wText = TextWidget.Cast(root.FindAnyWidget("m_wText")); return true; } //------------------------------------------------------------------------------------------------ ResourceName GetLayout() { return LAYOUT; } }

↑ Back to spoiler's top