Overthrow's UI system is built on top of Arma Reforger's UI framework, using a context-based approach for managing different screens and interfaces.
Every player entity has a OVT_UIManagerComponent that handles UI context management. This component:
Any screen in Overthrow defines a context class extending OVT_UIContext and is registered with the UI Manager on the player prefab. The base class has a ResourceName m_Layout member property that defines a .layout file configured in the workbench and shown automatically when the context is activated.
class OVT_ExampleContext : OVT_UIContext
{
// Layout file reference
override ResourceName GetLayout() { return "{path-to-layout-file}"; }
// Context initialization
override void OnCreate()
{
super.OnCreate();
// Initialize context-specific data
}
// Context activation
override void OnShow()
{
super.OnShow();
// Update UI elements when shown
}
// Context deactivation
override void OnHide()
{
super.OnHide();
// Clean up when hidden
}
}
Example of activating a context to show a screen:
OVT_UIManagerComponent ui = OVT_Global.GetUI();
if(!ui) return;
OVT_ShopContext context = OVT_ShopContext.Cast(ui.GetContext(OVT_ShopContext));
if(!context) return;
// Configure context with data
context.SetShop(shop);
// Show the context
ui.ShowContext(OVT_ShopContext);
UI contexts must be registered with the UI Manager component on the player prefab. This is typically done in the component's configuration in the Arma Reforger Tools.
Layout files (.layout) are created in the Arma Reforger Workbench and define the visual structure of UI screens. They contain:
UI contexts interact with widgets through:
// Finding widgets
Widget widget = GetRootWidget().FindAnyWidget("WidgetName");
// Casting to specific widget types
ButtonWidget button = ButtonWidget.Cast(widget);
TextWidget text = TextWidget.Cast(widget);
// Setting widget properties
button.SetText("Click Me");
text.SetText("Hello World");
// Binding events
button.m_OnClicked.Insert(OnButtonClicked);
The UI system integrates with other Overthrow systems through:
UI contexts can access manager components through OVT_Global:
OVT_ShopManagerComponent shopManager = OVT_Global.GetShops();
OVT_PlayerManagerComponent playerManager = OVT_Global.GetPlayers();
UI contexts can communicate with server components through the Overthrow Controller:
OVT_OverthrowController controller = OVT_Global.GetController();
OVT_ShopServerComponent shopServer = OVT_ShopServerComponent.Cast(controller.FindComponent(OVT_ShopServerComponent));
shopServer.PurchaseItem(itemId, quantity);
UI-related files are organized in:
Scripts/Game/UI/: UI contexts and widgetsUI/layouts/: Layout files created in WorkbenchUI/imagesets/: Image resourcesUI/fonts/: Font definitions// Show confirmation dialog
ui.ShowConfirmationDialog("Are you sure?", this, "OnConfirmed");
void OnConfirmed(bool confirmed)
{
if (confirmed)
{
// Perform action
}
}
// Update progress bar
ProgressBarWidget progress = ProgressBarWidget.Cast(widget);
progress.SetCurrent(currentValue);
progress.SetMax(maxValue);
// Clear list
SCR_ListBoxComponent listBox = SCR_ListBoxComponent.Cast(widget.FindHandler(SCR_ListBoxComponent));
listBox.Clear();
// Add items
foreach (ItemData item : items)
{
listBox.AddItem(item.GetName(), item);
}