Skip to content

Commit bde666a

Browse files
committed
Updat appearance_colors::handle_controller_input
`c_start_menu_settings_appearance_colors, handle_controller_input_message_`
1 parent 613d9db commit bde666a

File tree

2 files changed

+202
-147
lines changed

2 files changed

+202
-147
lines changed

game/source/interface/gui_screens/start_menu/panes/settings_appearance_colors/start_menu_settings_appearance_colors.cpp

Lines changed: 201 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#include "interface/gui_screens/start_menu/panes/settings_appearance_colors/start_menu_settings_appearance_colors.hpp"
22

33
#include "cseries/cseries.hpp"
4+
#include "cseries/cseries_events.hpp"
45
#include "interface/c_controller.hpp"
56
#include "interface/c_gui_list_item_widget.hpp"
67
#include "interface/c_gui_list_widget.hpp"
78
#include "interface/user_interface_messages.hpp"
89
#include "interface/user_interface_text_parser.hpp"
910
#include "memory/module.hpp"
1011

11-
//HOOK_DECLARE_CLASS_MEMBER(0x00AF9A30, c_start_menu_settings_appearance_colors, handle_controller_input_message_);
12+
HOOK_DECLARE_CLASS_MEMBER(0x00AF9A30, c_start_menu_settings_appearance_colors, handle_controller_input_message_);
1213
HOOK_DECLARE_CLASS_MEMBER(0x00AF9C20, c_start_menu_settings_appearance_colors, initialize_);
1314
HOOK_DECLARE_CLASS_MEMBER(0x00AF9F70, c_start_menu_settings_appearance_colors, set_color_values_from_profile);
1415

@@ -63,151 +64,205 @@ bool __cdecl parse_xml_emblem3(void* this_ptr, wchar_t* buffer, int32 buffer_len
6364
return parse_xml_color((c_gui_screen_widget*)this_ptr, buffer, buffer_length, STRING_ID(gui, color_emblem3));
6465
}
6566

66-
//bool __thiscall c_start_menu_settings_appearance_colors::handle_controller_input_message_(c_controller_input_message const* message)
67-
//{
68-
// //return INVOKE_CLASS_MEMBER(0x00AF9A30, c_start_menu_settings_appearance_colors*, handle_controller_input_message, message);
69-
//
70-
// bool result = false;
71-
//
72-
// e_event_type event_type = message->get_event_type();
73-
// e_controller_component component = message->get_component();
74-
//
75-
// c_gui_list_widget* focused_parent_list_widget = NULL;
76-
// if (c_gui_widget* focused_widget = get_focused_widget())
77-
// focused_parent_list_widget = focused_widget->get_parent_list();
78-
//
79-
// c_gui_list_widget* group_selector_child_list = get_child_list_widget(STRING_ID(gui, group_selector));
80-
// if (focused_parent_list_widget && group_selector_child_list)
81-
// {
82-
// if (focused_parent_list_widget == group_selector_child_list)
83-
// {
84-
// if ((event_type == _event_type_button_press && component == _controller_component_button_a) || event_type == _event_type_tab_right)
85-
// {
86-
// c_gui_list_item_widget* parent_list_item = NULL;
87-
// if (c_gui_widget* focused_widget = get_focused_widget())
88-
// parent_list_item = focused_widget->get_parent_list_item();
89-
//
90-
// int32 parent_list_item_name = parent_list_item->m_name.get_value();
91-
// if (c_gui_list_widget* child_list = get_child_list_widget(parent_list_item_name))
92-
// {
93-
// int32 focused_item_index = child_list->get_focused_item_index();
94-
// for (c_gui_list_item_widget* child_list_item = (c_gui_list_item_widget*)child_list->get_first_child_widget_by_type(_gui_list_item);
95-
// child_list_item;
96-
// child_list_item = get_next_list_item_widget(true))
97-
// {
98-
// if (focused_item_index == child_list_item->get_list_item_index())
99-
// {
100-
// transfer_focus(child_list_item);
101-
// result = true;
102-
// }
103-
// }
104-
// }
105-
//
106-
// }
107-
// else if (event_type == _event_type_button_press && component == _controller_component_button_b)
108-
// {
109-
// close_current_subpane();
110-
// return true;
111-
// }
112-
// }
113-
// else if (event_type == _event_type_button_press && (component == _controller_component_button_a || component == _controller_component_button_b))
114-
// {
115-
// int32 parent_list_name = focused_parent_list_widget->m_name.get_value();
116-
// for (c_gui_list_item_widget* child_list_item = (c_gui_list_item_widget*)group_selector_child_list->get_first_child_widget_by_type(_gui_list_item);
117-
// child_list_item;
118-
// child_list_item = get_next_list_item_widget(true))
119-
// {
120-
// if (child_list_item->m_name.get_value() == parent_list_name)
121-
// {
122-
// group_selector_child_list->set_focused_item_index(child_list_item->get_list_item_index(), false);
123-
// transfer_focus(child_list_item);
124-
// return true;
125-
// }
126-
// }
127-
//
128-
// if (component != _controller_component_button_a)
129-
// {
130-
// set_color_values_from_profile();
131-
// }
132-
// else
133-
// {
134-
// e_controller_index controller_index = get_arbitrary_responding_controller();
135-
// c_player_profile_interface* player_profile = controller_get(controller_index)->get_player_profile_interface();
136-
// int32 focused_item_index = focused_parent_list_widget->get_focused_item_index();
137-
//
138-
// s_emblem_info emblem_info = player_profile->m_emblem_info;
139-
// switch (parent_list_name)
140-
// {
141-
// case STRING_ID(gui, color_armor1):
142-
// player_profile->set_primary_change_color(focused_item_index, true);
143-
// return true;
144-
// case STRING_ID(gui, color_armor2):
145-
// player_profile->set_secondary_change_color(focused_item_index, true);
146-
// return true;
147-
// //case STRING_ID(gui, color_armor3):
148-
// // //player_profile->set_tertiary_change_color(focused_item_index, true);
149-
// // return true;
150-
// case STRING_ID(gui, color_emblem1):
151-
// //emblem_info.emblem_primary_color = focused_item_index;
152-
// //player_profile->set_emblem_info(&emblem_info, true);
153-
// emblem_info.emblem_primary_color = focused_item_index;
154-
// player_profile->m_emblem_info = emblem_info;
155-
// return true;
156-
// case STRING_ID(gui, color_emblem2):
157-
// //emblem_info.emblem_secondary_color = focused_item_index;
158-
// //player_profile->set_emblem_info(&emblem_info, true);
159-
// emblem_info.emblem_secondary_color = focused_item_index;
160-
// player_profile->m_emblem_info = emblem_info;
161-
// return true;
162-
// case STRING_ID(gui, color_emblem3):
163-
// //emblem_info.emblem_background_color = focused_item_index;
164-
// //player_profile->set_emblem_info(&emblem_info, true);
165-
// emblem_info.emblem_background_color = focused_item_index;
166-
// player_profile->m_emblem_info = emblem_info;
167-
// return true;
168-
// default:
169-
// {
170-
// if (parent_list_name == string_id_retrieve("color_armor3"))
171-
// {
172-
// //player_profile->set_tertiary_change_color(focused_item_index, true);
173-
// return true;
174-
// }
175-
//
176-
// return true;
177-
// }
178-
// break;
179-
// }
180-
//
181-
// return true;
182-
// }
183-
// }
184-
// }
185-
//
186-
// if (event_type == _event_type_button_press)
187-
// {
188-
// e_controller_index controller_index = message->get_controller();
189-
// switch (component)
190-
// {
191-
// case _controller_component_button_x:
192-
// //player_emblem_toggle_alternate_emblem_foreground(controller_index);
193-
// return true;
194-
// case _controller_component_button_left_thumb:
195-
// //player_emblem_toggle_flip_emblem_foreground(controller_index);
196-
// return true;
197-
// case _controller_component_button_right_thumb:
198-
// //player_emblem_toggle_flip_emblem_background(controller_index);
199-
// return true;
200-
// }
201-
// }
202-
//
203-
// if (!result)
204-
// {
205-
// //result = c_start_menu_pane_screen_widget::handle_controller_input_message(message);
206-
// result = INVOKE_CLASS_MEMBER(0x00B1F620, c_start_menu_pane_screen_widget, handle_controller_input_message, message);
207-
// }
208-
//
209-
// return result;
210-
//}
67+
void player_emblem_toggle_alternate_emblem_foreground(e_controller_index controller_index)
68+
{
69+
c_controller_interface* controller = controller_get(controller_index);
70+
if (TEST_BIT(controller->m_player_profile.m_flags, 8))
71+
{
72+
event(_event_message, "player_profile: settings change request ignored because player profile is busy with i/o");
73+
return;
74+
}
75+
76+
s_emblem_info emblem_info = controller->m_player_profile.get_emblem_info();
77+
emblem_info.emblem_info_flags.set(_emblem_info_flag_alternate_foreground_channel_off, !emblem_info.emblem_info_flags.test(_emblem_info_flag_alternate_foreground_channel_off));
78+
controller->m_player_profile.set_emblem_info(&emblem_info, true);
79+
}
80+
81+
void player_emblem_toggle_flip_emblem_foreground(e_controller_index controller_index)
82+
{
83+
//c_controller_interface* controller = controller_get(controller_index);
84+
//if (TEST_BIT(controller->m_player_profile.m_flags, 8))
85+
//{
86+
// event(_event_message, "player_profile: settings change request ignored because player profile is busy with i/o");
87+
// return;
88+
//}
89+
//
90+
//s_emblem_info emblem_info = controller->m_player_profile.get_emblem_info();
91+
//emblem_info.emblem_info_flags.set(_emblem_info_flag_flip_foreground, !emblem_info.emblem_info_flags.test(_emblem_info_flag_flip_foreground));
92+
//controller->m_player_profile.set_emblem_info(&emblem_info, true);
93+
}
94+
95+
void player_emblem_toggle_flip_emblem_background(e_controller_index controller_index)
96+
{
97+
//c_controller_interface* controller = controller_get(controller_index);
98+
//if (TEST_BIT(controller->m_player_profile.m_flags, 8))
99+
//{
100+
// event(_event_message, "player_profile: settings change request ignored because player profile is busy with i/o");
101+
// return;
102+
//}
103+
//
104+
//s_emblem_info emblem_info = controller->m_player_profile.get_emblem_info();
105+
//emblem_info.emblem_info_flags.set(_emblem_info_flag_flip_background, !emblem_info.emblem_info_flags.test(_emblem_info_flag_flip_background));
106+
//controller->m_player_profile.set_emblem_info(&emblem_info, true);
107+
}
108+
109+
bool __thiscall c_start_menu_settings_appearance_colors::handle_controller_input_message_(c_controller_input_message const* message)
110+
{
111+
//return INVOKE_CLASS_MEMBER(0x00AF9A30, c_start_menu_settings_appearance_colors*, handle_controller_input_message, message);
112+
113+
bool result = false;
114+
115+
e_event_type event_type = message->get_event_type();
116+
e_controller_component component = message->get_component();
117+
118+
c_gui_list_widget* focused_parent_list_widget = NULL;
119+
if (c_gui_widget* focused_widget = get_focused_widget())
120+
focused_parent_list_widget = focused_widget->get_parent_list();
121+
122+
c_gui_list_widget* group_selector_child_list = get_child_list_widget(STRING_ID(gui, group_selector));
123+
if (focused_parent_list_widget && group_selector_child_list)
124+
{
125+
if (focused_parent_list_widget == group_selector_child_list)
126+
{
127+
if ((event_type == _event_type_button_press && component == _controller_component_button_a) || event_type == _event_type_tab_right)
128+
{
129+
c_gui_list_item_widget* parent_list_item = NULL;
130+
if (c_gui_widget* focused_widget = get_focused_widget())
131+
parent_list_item = focused_widget->get_parent_list_item();
132+
133+
int32 parent_list_item_name = parent_list_item->m_name.get_value();
134+
if (c_gui_list_widget* child_list = get_child_list_widget(parent_list_item_name))
135+
{
136+
int32 focused_item_index = child_list->get_focused_item_index();
137+
for (c_gui_list_item_widget* child_list_item = (c_gui_list_item_widget*)child_list->get_first_child_widget_by_type(_gui_list_item);
138+
child_list_item;
139+
child_list_item = get_next_list_item_widget(true))
140+
{
141+
if (focused_item_index == child_list_item->get_list_item_index())
142+
{
143+
transfer_focus(child_list_item);
144+
result = true;
145+
}
146+
}
147+
}
148+
149+
}
150+
else if (event_type == _event_type_button_press && component == _controller_component_button_b)
151+
{
152+
close_current_subpane();
153+
return true;
154+
}
155+
}
156+
else if (event_type == _event_type_button_press && (component == _controller_component_button_a || component == _controller_component_button_b))
157+
{
158+
int32 parent_list_name = focused_parent_list_widget->m_name.get_value();
159+
for (c_gui_list_item_widget* child_list_item = (c_gui_list_item_widget*)group_selector_child_list->get_first_child_widget_by_type(_gui_list_item);
160+
child_list_item;
161+
child_list_item = get_next_list_item_widget(true))
162+
{
163+
if (child_list_item->m_name.get_value() == parent_list_name)
164+
{
165+
group_selector_child_list->set_focused_item_index(child_list_item->get_list_item_index(), false);
166+
transfer_focus(child_list_item);
167+
return true;
168+
}
169+
}
170+
171+
if (component != _controller_component_button_a)
172+
{
173+
set_color_values_from_profile();
174+
}
175+
else
176+
{
177+
e_controller_index controller_index = get_arbitrary_responding_controller();
178+
c_player_profile_interface* player_profile = controller_get(controller_index)->get_player_profile_interface();
179+
int32 focused_item_index = focused_parent_list_widget->get_focused_item_index();
180+
181+
s_emblem_info emblem_info = player_profile->get_emblem_info();
182+
switch (parent_list_name)
183+
{
184+
case STRING_ID(gui, color_armor1):
185+
{
186+
player_profile->set_primary_change_color(focused_item_index, true);
187+
}
188+
return true;
189+
case STRING_ID(gui, color_armor2):
190+
{
191+
player_profile->set_secondary_change_color(focused_item_index, true);
192+
}
193+
return true;
194+
//case STRING_ID(gui, color_armor3):
195+
//{
196+
// //player_profile->set_tertiary_change_color(focused_item_index, true);
197+
//}
198+
//return true;
199+
case STRING_ID(gui, color_emblem1):
200+
{
201+
emblem_info.primary_color_index = focused_item_index;
202+
player_profile->set_emblem_info(&emblem_info, true);
203+
}
204+
return true;
205+
case STRING_ID(gui, color_emblem2):
206+
{
207+
emblem_info.secondary_color_index = focused_item_index;
208+
player_profile->set_emblem_info(&emblem_info, true);
209+
}
210+
return true;
211+
case STRING_ID(gui, color_emblem3):
212+
{
213+
emblem_info.background_color_index = focused_item_index;
214+
player_profile->set_emblem_info(&emblem_info, true);
215+
}
216+
return true;
217+
default:
218+
{
219+
if (parent_list_name == string_id_retrieve("color_armor3"))
220+
{
221+
//player_profile->set_tertiary_change_color(focused_item_index, true);
222+
return true;
223+
}
224+
225+
return true;
226+
}
227+
break;
228+
}
229+
230+
return true;
231+
}
232+
}
233+
}
234+
235+
if (event_type == _event_type_button_press)
236+
{
237+
e_controller_index controller_index = message->get_controller();
238+
switch (component)
239+
{
240+
case _controller_component_button_x:
241+
{
242+
player_emblem_toggle_alternate_emblem_foreground(controller_index);
243+
}
244+
return true;
245+
case _controller_component_button_left_thumb:
246+
{
247+
player_emblem_toggle_flip_emblem_foreground(controller_index);
248+
}
249+
return true;
250+
case _controller_component_button_right_thumb:
251+
{
252+
player_emblem_toggle_flip_emblem_background(controller_index);
253+
}
254+
return true;
255+
}
256+
}
257+
258+
if (!result)
259+
{
260+
//result = c_start_menu_pane_screen_widget::handle_controller_input_message(message);
261+
result = INVOKE_CLASS_MEMBER(0x00B1F620, c_start_menu_pane_screen_widget, handle_controller_input_message, message);
262+
}
263+
264+
return result;
265+
}
211266

212267
void __thiscall c_start_menu_settings_appearance_colors::initialize_()
213268
{

game/source/interface/gui_screens/start_menu/panes/settings_appearance_colors/start_menu_settings_appearance_colors.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ struct c_start_menu_settings_appearance_colors :
66
public c_start_menu_pane_screen_widget
77
{
88
public:
9-
//bool __thiscall handle_controller_input_message_(c_controller_input_message const* input_message);
9+
bool __thiscall handle_controller_input_message_(c_controller_input_message const* input_message);
1010
void __thiscall initialize_();
1111
void set_color_focused_list_item(int32 name, e_player_color_index player_color_index);
1212
void __thiscall set_color_values_from_profile();

0 commit comments

Comments
 (0)