@@ -125,7 +125,7 @@ int ui::label_percent(int amount, vec2i pos, font_t font) {
125
125
return text_draw_percentage (amount, offset.x + pos.x , offset.y + pos.y , font);
126
126
}
127
127
128
- void ui::image (e_image_id img, vec2i pos) {
128
+ void ui::eimage (e_image_id img, vec2i pos) {
129
129
painter ctx = game.painter ();
130
130
ImageDraw::img_generic (ctx, image_group (img), pos);
131
131
}
@@ -149,12 +149,58 @@ void ui::icon(vec2i pos, e_advisor adv) {
149
149
ImageDraw::img_generic (ctx, image_group (IMG_ADVISOR_ICONS) + (adv - 1 ), offset.x + pos.x , offset.y + pos.y );
150
150
}
151
151
152
-
153
152
arrow_button &ui::arw_button (vec2i pos, bool up, bool tiny) {
154
153
const vec2i offset = g_state.offset ();
155
154
156
155
g_state.arw_buttons .push_back ({pos.x , pos.y , up ? 17 : 15 , 24 , button_none, 0 , 0 });
157
156
arrow_buttons_draw (offset, g_state.arw_buttons .back (), tiny);
158
157
159
158
return g_state.arw_buttons .back ();
160
- }
159
+ }
160
+
161
+ void ui::element::load (archive arch) {
162
+ pos = arch.r_vec2i (" pos" );
163
+ size = arch.r_size2i (" size" );
164
+ }
165
+
166
+ void ui::outer_panel::draw () {
167
+ ui::panel (pos, size, UiFlags_PanelOuter);
168
+ }
169
+
170
+ void ui::outer_panel::load (archive arch) {
171
+ pcstr type = arch.r_string (" type" );
172
+ assert (!strcmp (type, " outer_panel" ));
173
+
174
+ element::load (arch);
175
+ }
176
+
177
+ void ui::widget::draw () {
178
+ for (auto &e : elements) {
179
+ e->draw ();
180
+ }
181
+ }
182
+
183
+ void ui::widget::load (archive arch) {
184
+ elements.clear ();
185
+ arch.r_objects (" ui" , [this ] (pcstr key, archive elem) {
186
+ pcstr type = elem.r_string (" type" );
187
+ if (!strcmp (type, " outer_panel" )) {
188
+ elements.push_back (std::make_shared<outer_panel>());
189
+ elements.back ()->load (elem);
190
+ } else if (!strcmp (type, " image" )) {
191
+ elements.push_back (std::make_shared<image>());
192
+ elements.back ()->load (elem);
193
+ }
194
+ });
195
+ }
196
+
197
+ void ui::image::draw () {
198
+ ui::icon (pos, ADVISOR_RATINGS);
199
+ }
200
+
201
+ void ui::image::load (archive arch) {
202
+ pcstr type = arch.r_string (" type" );
203
+ assert (!strcmp (type, " image" ));
204
+ img = arch.r_image (" image" );
205
+ element::load (arch);
206
+ }
0 commit comments