11#include " interface/c_gui_screen_widget.hpp"
22
3+ #include " cseries/cseries_events.hpp"
4+ #include " interface/c_gui_list_widget.hpp"
5+ #include " interface/c_gui_text_widget.hpp"
36#include " interface/user_interface.hpp"
47#include " interface/user_interface_data.hpp"
8+ #include " interface/user_interface_messages.hpp"
59#include " interface/user_interface_text_parser.hpp"
610#include " interface/user_interface_window_manager.hpp"
711
@@ -105,7 +109,12 @@ void c_gui_screen_widget::dispose()
105109}
106110
107111// .text:00AB0A10 ;
108- // .text:00AB0A20 ; public: void c_gui_screen_widget::dispose_child_screens()
112+
113+ void c_gui_screen_widget::dispose_child_screens ()
114+ {
115+ INVOKE_CLASS_MEMBER (0x00AB0A20 , c_gui_screen_widget, dispose_child_screens);
116+ }
117+
109118// .text:00AB0A90 ; private: void c_gui_screen_widget::dispose_datasource()
110119// .text:00AB0B00 ; private: void c_gui_screen_widget::dispose_display_group(c_gui_group_widget*)
111120// .text:00AB0BC0 ; protected: c_gui_list_item_widget* c_gui_screen_widget::find_list_item(int32, int32, int32)
@@ -122,21 +131,31 @@ c_gui_data* c_gui_screen_widget::get_data(int32 name, int32* datasource_index)
122131{
123132 // return INVOKE_CLASS_MEMBER(0x00AB0DB0, c_gui_screen_widget, get_data, name, datasource_index);
124133
134+ // $TODO: cleanup this function
135+
125136 if (datasource_index)
137+ {
126138 *datasource_index = NONE;
139+ }
127140
128141 if (m_datasource_count <= 0 )
129- return nullptr ;
142+ {
143+ return NULL ;
144+ }
130145
131146 int32 index = 0 ;
132- for (c_gui_data** datasource = m_datasource; (*datasource)->get_name (). get_value () != name; datasource++)
147+ for (c_gui_data** datasource = m_datasource; (*datasource)->get_name () != name; datasource++)
133148 {
134149 if (++index >= m_datasource_count)
135- return nullptr ;
150+ {
151+ return NULL ;
152+ }
136153 }
137154
138155 if (datasource_index)
156+ {
139157 *datasource_index = index;
158+ }
140159
141160 return m_datasource[index];
142161}
@@ -215,7 +234,22 @@ bool c_gui_screen_widget::__funcs53()
215234{
216235 return INVOKE_CLASS_MEMBER (0x00AB1760 , c_gui_screen_widget, __funcs53);
217236
218- int32 render_window_for_screen = window_manager_get ()->get_render_window_for_screen (this );
237+ // c_window_manager* window_manager = window_manager_get();
238+ // e_window_index window_index = window_manager->get_render_window_for_screen(this);
239+ // c_gui_screen_widget* screen_above = window_manager->get_screen_above(window_index, this);
240+ // if (!screen_above)
241+ // {
242+ // return false;
243+ // }
244+ // while (!TEST_BIT(screen_above->m_definition.flags, 4) || screen_above->transitioning_out())
245+ // {
246+ // screen_above = window_manager->get_screen_above(window_index, screen_above);
247+ // if (!screen_above)
248+ // {
249+ // return false;
250+ // }
251+ // }
252+ // return true;
219253}
220254
221255// .text:00AB17D0 ; private: c_gui_group_widget* c_gui_screen_widget::load_display_group(s_runtime_screen_widget_definition const*, c_gui_screen_widget::e_display_group_type, int32)
@@ -234,33 +268,91 @@ void c_gui_screen_widget::play_sound(e_user_interface_sound_effect sound_effect)
234268
235269void c_gui_screen_widget::post_initialize ()
236270{
237- INVOKE_CLASS_MEMBER (0x00AB18E0 , c_gui_screen_widget, post_initialize);
271+ // INVOKE_CLASS_MEMBER(0x00AB18E0, c_gui_screen_widget, post_initialize);
272+
273+ c_gui_screen_widget::set_initial_focused_widget ();
274+ if (m_definition.script_index != 0xFFFFi16)
275+ {
276+ window_manager_get ()->run_screen_hs_script (m_definition.script_index );
277+ }
278+
279+ // if (s_screen_widget_definition const* screen_definition = get_screen_definition())
280+ // {
281+ // if (s_mouse_cursor_definition const* mouse_cursor_definition = mouse_cursor_definition_get(screen_definition->mouse_cursor_tag.index))
282+ // {
283+ // input_set_mouse_cursors_from_tag(mouse_cursor_definition);
284+ // }
285+ // }
286+
287+ c_gui_widget::post_initialize ();
238288}
239289
240290// .text:00AB1910 ; public: void c_gui_screen_widget::post_update()
241291// .text:00AB19E0 ; public: void c_gui_screen_widget::pre_update()
242- // .text:00AB1A60 ;
292+
293+ void __cdecl sub_AB1A60 (c_gui_screen_widget* screen_widget, int32 a2)
294+ {
295+ INVOKE (0x00AB1A60 , sub_AB1A60, screen_widget, a2);
296+ }
243297
244298void c_gui_screen_widget::predict_immediate_resources (int32 a1)
245299{
246- INVOKE_CLASS_MEMBER (0x00AB1AE0 , c_gui_screen_widget, predict_immediate_resources, a1);
300+ // INVOKE_CLASS_MEMBER(0x00AB1AE0, c_gui_screen_widget, predict_immediate_resources, a1);
301+
302+ sub_AB1A60 (this , a1);
247303}
248304
249- // .text:00AB1B00 ;
305+ void __cdecl sub_AB1B00 (c_gui_screen_widget* screen_widget, int32 a2)
306+ {
307+ INVOKE (0x00AB1B00 , sub_AB1B00, screen_widget, a2);
308+ }
250309
251310void c_gui_screen_widget::predict_pending_resources (int32 a1)
252311{
253- INVOKE_CLASS_MEMBER (0x00AB1B80 , c_gui_screen_widget, predict_pending_resources, a1);
312+ // INVOKE_CLASS_MEMBER(0x00AB1B80, c_gui_screen_widget, predict_pending_resources, a1);
313+
314+ sub_AB1B00 (this , a1);
254315}
255316
256317bool c_gui_screen_widget::process_message (c_message const * message)
257318{
258319 return INVOKE_CLASS_MEMBER (0x00AB1BA0 , c_gui_screen_widget, process_message, message);
320+
321+ // bool result = false;
322+ // switch (message->get_type())
323+ // {
324+ // case _message_type_controller_input:
325+ // {
326+ // c_controller_input_message const* controller_input_message = (c_controller_input_message const*)message;
327+ // if (result = handle_controller_input_message(controller_input_message))
328+ // {
329+ // c_window_manager::play_controller_sound(
330+ // m_definition.sound_override_reference_index,
331+ // controller_input_message->get_event_type(),
332+ // controller_input_message->get_component());
333+ // }
334+ // }
335+ // break;
336+ // case _message_type_dialog_result:
337+ // {
338+ // c_dialog_result_message const* dialog_result_message = (c_dialog_result_message const*)message;
339+ // result = handle_dialog_result(dialog_result_message);
340+ // }
341+ // break;
342+ // }
343+ //
344+ // return result;
259345}
260346
261347void c_gui_screen_widget::reconstruct ()
262348{
263- INVOKE_CLASS_MEMBER (0x00AB1C10 , c_gui_screen_widget, reconstruct);
349+ // INVOKE_CLASS_MEMBER(0x00AB1C10, c_gui_screen_widget, reconstruct);
350+
351+ csmemset (&m_animated_state, 0 , sizeof (m_animated_state));
352+ m_current_focused_widget = NULL ;
353+ c_gui_screen_widget::clear_display_groups ();
354+ c_gui_screen_widget::dispose_child_screens ();
355+ c_gui_widget::delete_all_children ();
264356}
265357
266358// .text:00AB1C80 ; private: void c_gui_screen_widget::recover_from_tag_changes()
@@ -272,7 +364,9 @@ void c_gui_screen_widget::reload_assets()
272364
273365void c_gui_screen_widget::reload_next_frame ()
274366{
275- INVOKE_CLASS_MEMBER (0x00AB1DF0 , c_gui_screen_widget, reload_next_frame);
367+ // INVOKE_CLASS_MEMBER(0x00AB1DF0, c_gui_screen_widget, reload_next_frame);
368+
369+ m_reload_next_frame = true ;
276370}
277371
278372// .text:00AB1E00 ; protected: void c_gui_screen_widget::remove_datasource(c_gui_data*)
@@ -285,60 +379,145 @@ bool c_gui_screen_widget::running_in_codeless_mode()
285379
286380// .text:00AB2030 ;
287381// .text:00AB2100 ;
288- // .text:00AB21E0 ; private: void c_gui_screen_widget::set_initial_focused_widget()
289- // .text:00AB22D0 ; public: void c_gui_screen_widget::set_text_widget_string_id(int32, int32)
382+
383+ void c_gui_screen_widget::set_initial_focused_widget ()
384+ {
385+ INVOKE_CLASS_MEMBER (0x00AB21E0 , c_gui_screen_widget, set_initial_focused_widget);
386+ }
387+
388+ void c_gui_screen_widget::set_text_widget_string_id (int32 widget_name, int32 widget_text)
389+ {
390+ // INVOKE_CLASS_MEMBER(0x00AB22D0, c_gui_screen_widget, set_text_widget_string_id, widget_name, widget_text);
391+
392+ if (c_gui_text_widget* child_text_widget = get_child_text_widget (widget_name))
393+ {
394+ child_text_widget->set_text_from_string_id (this , widget_text);
395+ }
396+ }
397+
290398// .text:00AB2300 ; public: void c_gui_screen_widget::set_text_widget_string_id_from_datasource(int32, int32, int32, int32)
291399// .text:00AB23A0 ; public: void c_gui_screen_widget::set_text_widget_string_id_from_focused_list_item(int32, int32, int32)
292- // .text:00AB23E0 ; public: void c_gui_screen_widget::set_text_widget_text(int32, wchar_t const*)
400+
401+ void c_gui_screen_widget::set_text_widget_text (int32 widget_name, wchar_t const * widget_text)
402+ {
403+ // INVOKE_CLASS_MEMBER(0x00AB23E0, c_gui_screen_widget, set_text_widget_text, widget_name, widget_text);
404+
405+ if (c_gui_text_widget* child_text_widget = get_child_text_widget (widget_name))
406+ {
407+ child_text_widget->set_text (widget_text);
408+ }
409+ }
410+
293411// .text:00AB2400 ; public: void c_gui_screen_widget::set_text_widget_text_from_datasource(int32, int32, int32, int32)
294412// .text:00AB24D0 ; public: void c_gui_screen_widget::set_text_widget_text_from_focused_list_item(int32, int32, int32)
295413
296414void c_gui_screen_widget::submenu_invoked (c_gui_list_widget* submenu_widget)
297415{
298- INVOKE_CLASS_MEMBER (0x00AB2510 , c_gui_screen_widget, submenu_invoked, submenu_widget);
416+ // INVOKE_CLASS_MEMBER(0x00AB2510, c_gui_screen_widget, submenu_invoked, submenu_widget);
299417}
300418
301419// .text:00AB2520 ; private: void c_gui_screen_widget::swap_display_group_block(c_gui_screen_widget::e_display_group_type, int32)
302420
303- void c_gui_screen_widget::transfer_focus (c_gui_widget* widget )
421+ void c_gui_screen_widget::transfer_focus (c_gui_widget* new_focused_widget )
304422{
305- INVOKE_CLASS_MEMBER (0x00AB25F0 , c_gui_screen_widget, transfer_focus, widget);
423+ // INVOKE_CLASS_MEMBER(0x00AB25F0, c_gui_screen_widget, transfer_focus, new_focused_widget);
424+
425+ c_gui_screen_widget::transfer_focus_without_animations (new_focused_widget, true , true );
306426}
307427
308428void c_gui_screen_widget::transfer_focus_to_list (c_gui_list_widget* list_widget, int32 element_handle, bool play_received_animation, bool play_lost_animation)
309429{
310430 INVOKE_CLASS_MEMBER (0x00AB2640 , c_gui_screen_widget, transfer_focus_to_list, list_widget, element_handle, play_received_animation, play_lost_animation);
431+
432+ c_gui_data* data = list_widget->get_data ();
433+ if (!data)
434+ {
435+ return ;
436+ }
437+
438+ if (data->contains (element_handle))
439+ {
440+ element_handle = data->get_first_element_handle ();
441+ }
442+
443+ if (element_handle == NONE)
444+ {
445+ return ;
446+ }
311447}
312448
313449// .text:00AB2740 ;
314450
315451void c_gui_screen_widget::transfer_focus_without_animations (c_gui_widget* new_focused_widget, bool play_received_animation, bool play_lost_animation)
316452{
317453 INVOKE_CLASS_MEMBER (0x00AB27D0 , c_gui_screen_widget, transfer_focus_without_animations, new_focused_widget, play_received_animation, play_lost_animation);
454+
455+ ASSERT (new_focused_widget != NULL );
456+
457+ // if (!new_focused_widget->can_receive_focus())
458+ // {
459+ // event(_event_verbose, "ui: tried to give focus to an invalid child widget (type= %s, name= %s)",
460+ // gui_widget_type_to_string(new_focused_widget->m_type),
461+ // c_gui_widget::widget_name_to_string(new_focused_widget->m_name));
462+ // return;
463+ // }
464+ // if (play_received_animation)
465+ // {
466+ // new_focused_widget->start_animation(_control_received_focus, true);
467+ // }
468+ // if (play_lost_animation)
469+ // {
470+ // m_current_focused_widget->start_animation(_control_lost_focus, true);
471+ // }
472+ // m_current_focused_widget = new_focused_widget;
318473}
319474
320- // .text:00AB2830 ; public: void c_gui_screen_widget::transition_out(e_transition_out_type)
475+ void c_gui_screen_widget::transition_out (e_transition_out_type transition_out)
476+ {
477+ // INVOKE_CLASS_MEMBER(0x00AB2830, c_gui_screen_widget, transition_out, transition_out);
478+
479+ transition_out_with_transition_type (transition_out, _screen_transition_type_normal);
480+ }
321481
322482void c_gui_screen_widget::transition_out_with_transition_type (e_transition_out_type transition_out, e_screen_transition_type transition_type)
323483{
324- INVOKE_CLASS_MEMBER (0x00AB2850 , c_gui_screen_widget, transition_out_with_transition_type, transition_out, transition_type);
484+ // INVOKE_CLASS_MEMBER(0x00AB2850, c_gui_screen_widget, transition_out_with_transition_type, transition_out, transition_type);
485+
486+ window_manager_get ()->begin_transition_out (this , transition_type);
325487}
326488
327489// .text:00AB2870 ; private: void c_gui_screen_scoreboard::translate_widget_recursive(c_gui_widget*, int32, int32)
328490
329491bool c_gui_screen_widget::try_and_get_render_data_emblem_info (c_gui_bitmap_widget* bitmap_widget, s_emblem_info* emblem_info)
330492{
331- return INVOKE_CLASS_MEMBER (0x00AB2930 , c_gui_screen_widget, try_and_get_render_data_emblem_info, bitmap_widget, emblem_info);
493+ // return INVOKE_CLASS_MEMBER(0x00AB2930, c_gui_screen_widget, try_and_get_render_data_emblem_info, bitmap_widget, emblem_info);
494+
495+ return NULL ;
332496}
333497
334498void c_gui_screen_widget::update (uns32 current_milliseconds)
335499{
336- INVOKE_CLASS_MEMBER (0x00AB2940 , c_gui_screen_widget, update, current_milliseconds);
500+ // INVOKE_CLASS_MEMBER(0x00AB2940, c_gui_screen_widget, update, current_milliseconds);
501+
502+ c_gui_widget::update (current_milliseconds);
503+
504+ e_controller_index driving_controller = c_gui_widget::get_driving_controller ();
505+ if (driving_controller == k_no_controller || driving_controller == k_any_controller)
506+ {
507+ return ;
508+ }
509+
510+ if (!controller_get (driving_controller)->in_use ())
511+ {
512+ return ;
513+ }
514+
515+ transition_out_with_transition_type (_transition_out_normal, _screen_transition_type_normal);
337516}
338517
339518void c_gui_screen_widget::update_render ()
340519{
341- INVOKE_CLASS_MEMBER (0x00AB29A0 , c_gui_screen_widget, update_render);
520+ // INVOKE_CLASS_MEMBER(0x00AB29A0, c_gui_screen_widget, update_render);
342521}
343522
344523// .text:00AB29B0 ; public: bool s_window_manager_screen_render_data::valid()
0 commit comments