88
99// Helper function to map C Enums to C++ Enums safely
1010static UIWidgets::ComponentAlignments MapAlign (C_ComponentAlign align) {
11- if (align == C_ALIGN_RIGHT ) return UIWidgets::ComponentAlignments::Right;
11+ if (align == C_ALIGN_RIGHT )
12+ return UIWidgets::ComponentAlignments::Right;
1213 return UIWidgets::ComponentAlignments::Left;
1314}
1415
1516static UIWidgets::LabelPositions MapLabel (C_LabelPos pos) {
16- if (pos == C_LABEL_FAR ) return UIWidgets::LabelPositions::Far;
17+ if (pos == C_LABEL_FAR )
18+ return UIWidgets::LabelPositions::Far;
1719 return UIWidgets::LabelPositions::Near;
1820}
1921
@@ -34,19 +36,22 @@ extern "C" void C_RemoveSidebarEntry(const char* sidebarName) {
3436}
3537
3638extern " C" void C_AddWidget (const char * sidebar, int column, const char * label, C_WidgetConfig* config) {
37- if (!config) return ;
39+ if (!config)
40+ return ;
3841
3942 WidgetPath path = { " Mods" , sidebar, static_cast <SectionColumns>(column) };
4043
4144 // 1. Begin the Widget Builder Chain
4245 WidgetInfo& widget = GhostshipGui::mGhostshipMenu ->AddWidget (path, label, static_cast <WidgetType>(config->type ))
43- .RaceDisable (config->race_disable )
44- .SameLine (config->same_line )
45- .HideInSearch (config->hide_in_search );
46+ .RaceDisable (config->race_disable )
47+ .SameLine (config->same_line )
48+ .HideInSearch (config->hide_in_search );
4649
4750 // 2. Apply Base Attributes
48- if (config->cvar ) widget.CVar (config->cvar );
49- if (config->window_name ) widget.WindowName (config->window_name );
51+ if (config->cvar )
52+ widget.CVar (config->cvar );
53+ if (config->window_name )
54+ widget.WindowName (config->window_name );
5055
5156 // 3. Apply Callbacks
5257 if (config->callback ) {
@@ -67,10 +72,10 @@ extern "C" void C_AddWidget(const char* sidebar, int column, const char* label,
6772 case C_WIDGET_AUDIO_BACKEND :
6873 case C_WIDGET_VIDEO_BACKEND : {
6974 auto opt = UIWidgets::ComboboxOptions ()
70- .Tooltip (config->opts .combo .tooltip ? config->opts .combo .tooltip : " " )
71- .DefaultIndex (config->opts .combo .default_index )
72- .ComponentAlignment (MapAlign (config->opts .combo .alignment ))
73- .LabelPosition (MapLabel (config->opts .combo .label_pos ));
75+ .Tooltip (config->opts .combo .tooltip ? config->opts .combo .tooltip : " " )
76+ .DefaultIndex (config->opts .combo .default_index )
77+ .ComponentAlignment (MapAlign (config->opts .combo .alignment ))
78+ .LabelPosition (MapLabel (config->opts .combo .label_pos ));
7479 widget.Options (opt);
7580 break ;
7681 }
@@ -79,13 +84,14 @@ extern "C" void C_AddWidget(const char* sidebar, int column, const char* label,
7984 case C_WIDGET_SLIDER_INT :
8085 case C_WIDGET_CVAR_SLIDER_INT : {
8186 auto opt = UIWidgets::IntSliderOptions ()
82- .Tooltip (config->opts .slider_int .tooltip ? config->opts .slider_int .tooltip : " " )
83- .Min (config->opts .slider_int .min )
84- .Max (config->opts .slider_int .max )
85- .DefaultValue (config->opts .slider_int .default_val )
86- .Step (config->opts .slider_int .step );
87-
88- if (config->opts .slider_int .format ) opt.Format (config->opts .slider_int .format );
87+ .Tooltip (config->opts .slider_int .tooltip ? config->opts .slider_int .tooltip : " " )
88+ .Min (config->opts .slider_int .min )
89+ .Max (config->opts .slider_int .max )
90+ .DefaultValue (config->opts .slider_int .default_val )
91+ .Step (config->opts .slider_int .step );
92+
93+ if (config->opts .slider_int .format )
94+ opt.Format (config->opts .slider_int .format );
8995 widget.Options (opt);
9096 break ;
9197 }
@@ -94,13 +100,14 @@ extern "C" void C_AddWidget(const char* sidebar, int column, const char* label,
94100 case C_WIDGET_SLIDER_FLOAT :
95101 case C_WIDGET_CVAR_SLIDER_FLOAT : {
96102 auto opt = UIWidgets::FloatSliderOptions ()
97- .Tooltip (config->opts .slider_float .tooltip ? config->opts .slider_float .tooltip : " " )
98- .Min (config->opts .slider_float .min )
99- .Max (config->opts .slider_float .max )
100- .DefaultValue (config->opts .slider_float .default_val )
101- .Step (config->opts .slider_float .step );
102-
103- if (config->opts .slider_float .format ) opt.Format (config->opts .slider_float .format );
103+ .Tooltip (config->opts .slider_float .tooltip ? config->opts .slider_float .tooltip : " " )
104+ .Min (config->opts .slider_float .min )
105+ .Max (config->opts .slider_float .max )
106+ .DefaultValue (config->opts .slider_float .default_val )
107+ .Step (config->opts .slider_float .step );
108+
109+ if (config->opts .slider_float .format )
110+ opt.Format (config->opts .slider_float .format );
104111 widget.Options (opt);
105112 break ;
106113 }
@@ -109,16 +116,16 @@ extern "C" void C_AddWidget(const char* sidebar, int column, const char* label,
109116 case C_WIDGET_CHECKBOX :
110117 case C_WIDGET_CVAR_CHECKBOX : {
111118 widget.Options (UIWidgets::CheckboxOptions ()
112- .Tooltip (config->opts .checkbox .tooltip ? config->opts .checkbox .tooltip : " " )
113- .DefaultValue (config->opts .checkbox .default_val ));
119+ .Tooltip (config->opts .checkbox .tooltip ? config->opts .checkbox .tooltip : " " )
120+ .DefaultValue (config->opts .checkbox .default_val ));
114121 break ;
115122 }
116123
117124 // --- TEXT ---
118125 case C_WIDGET_TEXT :
119126 case C_WIDGET_SEPARATOR_TEXT : {
120127 widget.Options (UIWidgets::TextOptions ()
121- // .Center() or whatever alignment method your UIWidgets uses
128+ // .Center() or whatever alignment method your UIWidgets uses
122129 );
123130 break ;
124131 }
@@ -127,33 +134,30 @@ extern "C" void C_AddWidget(const char* sidebar, int column, const char* label,
127134 case C_WIDGET_COLOR_PICKER :
128135 case C_WIDGET_CVAR_COLOR_PICKER : {
129136 // Assuming Color_RGBA8 or similar constructor for default color
130- widget.Options (UIWidgets::ColorPickerOptions ()
131- . Tooltip ( config->opts .color_picker .tooltip ? config->opts .color_picker .tooltip : " " )
132- // .DefaultColor(Color_RGBA8(config->opts.color_picker.default_r, ...))
137+ widget.Options (UIWidgets::ColorPickerOptions (). Tooltip (
138+ config->opts .color_picker .tooltip ? config->opts .color_picker .tooltip : " " )
139+ // .DefaultColor(Color_RGBA8(config->opts.color_picker.default_r, ...))
133140 );
134141 break ;
135142 }
136143
137144 // --- BUTTONS / WINDOWS / SEPARATORS ---
138145 case C_WIDGET_WINDOW_BUTTON : {
139- widget.Options (UIWidgets::WindowButtonOptions ()
140- .Tooltip (config->opts .generic .tooltip ? config->opts .generic .tooltip : " " )
141- );
146+ widget.Options (UIWidgets::WindowButtonOptions ().Tooltip (
147+ config->opts .generic .tooltip ? config->opts .generic .tooltip : " " ));
142148 break ;
143149 }
144150
145151 case C_WIDGET_BUTTON : {
146- widget.Options (UIWidgets::ButtonOptions ()
147- .Tooltip (config->opts .generic .tooltip ? config->opts .generic .tooltip : " " )
148- );
152+ widget.Options (
153+ UIWidgets::ButtonOptions ().Tooltip (config->opts .generic .tooltip ? config->opts .generic .tooltip : " " ));
149154 break ;
150155 }
151156
152157 // --- DEFAULT FALLBACK ---
153158 default : {
154- widget.Options (UIWidgets::WidgetOptions ()
155- .Tooltip (config->opts .generic .tooltip ? config->opts .generic .tooltip : " " )
156- );
159+ widget.Options (
160+ UIWidgets::WidgetOptions ().Tooltip (config->opts .generic .tooltip ? config->opts .generic .tooltip : " " ));
157161 break ;
158162 }
159163 }
0 commit comments