The UI framework provides the user interface components for the Game Macro application, featuring a modular and extensible design.
| English Version | 中文版本 |
The UI system is built around a main shell with navigation tree and dynamic page loading. It supports:
Main application shell with navigation tree and page management.
UI_ShowMain() - Display main application windowUI_OnNavChange() - Handle navigation tree selectionUI_OnResize_LeftNav() - Handle window resize eventsUI_SwitchPage(key) - Switch between different pagesrootProfile := UI.Nav.Add("概览与配置")
rootData := UI.Nav.Add("数据与检测")
rootAuto := UI.Nav.Add("自动化")
rootAdv := UI.Nav.Add("高级功能")
rootTools := UI.Nav.Add("工具")
rootSet := UI.Nav.Add("设置")
Layout management and responsive design.
Base UI components and framework utilities.
The UI uses a page-based architecture where each functional area is implemented as a separate page.
UI_RegisterPage("profile", "概览与配置", Page_Profile_Build, Page_Profile_Layout, Page_Profile_OnEnter)
UI_RegisterPage("skills", "技能", Page_Skills_Build, Page_Skills_Layout)
UI_RegisterPage("rules", "循环规则", Page_Rules_Build, Page_Rules_Layout, Page_Rules_OnEnter)
The UI includes various modal dialogs for specific tasks:
The UI uses a responsive layout system that adapts to window size changes.
; Left navigation tree
UI.Nav := UI.Main.Add("TreeView", "xm ym w220 h620 +Lines +Buttons")
; Right content area
UI.Content := UI.Main.Add("GroupBox", "x+10 yp w600 h620", "Content")
The UI supports multiple languages through the language system:
; Initialize language system
Lang_Init(AppConfig_Get("Language", "zh-CN"))
; Use translated text
UI.Main.Title := T("app.title", "Game Macro")
Languages/zh-CN.ini - Chinese translationsLanguages/en-US.ini - English translationsThe UI uses AutoHotkey’s event system for user interactions.
; Button click event
myButton.OnEvent("Click", MyButton_Click)
; Tree view selection
UI.Nav.OnEvent("Click", UI_OnNavChange)
; Window close
UI.Main.OnEvent("Close", UI_OnMainClose)
Page_MyPage_Build() {
global UI
; Create controls
UI.MyPage.Label := UI.Content.Add("Text", "xm ym", "My Page Title")
UI.MyPage.Button := UI.Content.Add("Button", "x+10", "Click Me")
; Register events
UI.MyPage.Button.OnEvent("Click", MyPage_ButtonClick)
}
Page_MyPage_Layout() {
global UI
; Position controls
UI.MyPage.Label.Move(10, 10, 200, 20)
UI.MyPage.Button.Move(220, 10, 100, 25)
}
MyPage_ButtonClick(*) {
MsgBox "Button clicked!"
}
UI_OnNavChange(*) {
global UI, UI_NavMap
sel := UI.Nav.GetSelection()
if (!sel || !UI_NavMap.Has(sel)) {
return
}
key := UI_NavMap[sel]
UI_SwitchPage(key)
}
Creates and displays the main application window.
Parameters: None
Returns: Nothing
Switches to the specified page.
Parameters:
key (String): Page identifierReturns: Nothing
Registers a new page with the UI system.
Parameters:
key (String): Unique page identifiername (String): Display namebuildFunc (Function): Function to build page controlslayoutFunc (Function): Function to layout page controlsenterFunc (Function): Optional function called when page is enteredReturns: Nothing