3 #ifdef PLATFORM_CONSOLE
5 protected bool m_CharacterSaved;
10 const int TOOLTIP_ID_SAVE = 1;
11 const int TOOLTIP_ID_APPLY = 2;
13 protected Widget m_CharacterRotationFrame;
16 protected Widget m_RandomizeCharacter;
17 protected Widget m_BackButton;
18 protected Widget m_PlayedCharacterInfo;
20 protected Widget m_DetailsRoot;
25 protected ref OptionSelectorEditbox m_NameSelector;
32 int m_OriginalCharacterID;
34 void CharacterCreationMenu()
36 MissionMainMenu
mission = MissionMainMenu.Cast(
GetGame().GetMission());
38 #ifdef PLATFORM_CONSOLE
39 m_Scene =
mission.GetIntroSceneXbox();
41 m_Scene =
mission.GetIntroScenePC();
44 m_Scene.ResetIntroCamera();
49 return m_Scene.GetIntroCharacter().GetCharacterObj();
54 #ifdef PLATFORM_CONSOLE
65 #ifdef PLATFORM_CONSOLE
66 layoutRoot =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/character_creation/xbox/character_creation.layout");
67 m_CharacterSaved =
false;
69 layoutRoot =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/character_creation/pc/character_creation.layout");
72 m_CharacterRotationFrame = layoutRoot.FindAnyWidget(
"character_rotation_frame");
73 m_Apply = layoutRoot.FindAnyWidget(
"apply");
74 m_Save = layoutRoot.FindAnyWidget(
"save");
75 m_RandomizeCharacter = layoutRoot.FindAnyWidget(
"randomize_character");
76 m_BackButton = layoutRoot.FindAnyWidget(
"back");
77 m_Version =
TextWidget.Cast(layoutRoot.FindAnyWidget(
"version"));
78 m_DetailsRoot = layoutRoot.FindAnyWidget(
"menu_details_tooltip");
79 m_DetailsLabel =
TextWidget.Cast(m_DetailsRoot.FindAnyWidget(
"menu_details_label"));
80 m_DetailsText =
RichTextWidget.Cast(m_DetailsRoot.FindAnyWidget(
"menu_details_tooltip_content"));
81 m_CharacterHeaderText =
TextWidget.Cast(layoutRoot.FindAnyWidget(
"char_header_text"));
82 m_PlayedCharacterInfo = layoutRoot.FindAnyWidget(
"played_char_info");
86 #ifdef PLATFORM_CONSOLE
87 version =
"#main_menu_version" +
" " + version +
" (" +
g_Game.GetDatabaseID() +
")";
89 version =
"#main_menu_version" +
" " + version;
91 m_Version.SetText(version);
93 if (m_Scene && m_Scene.GetIntroCharacter())
95 m_OriginalCharacterID = m_Scene.GetIntroCharacter().GetCharacterID();
98 m_NameSelector =
new OptionSelectorEditbox(layoutRoot.FindAnyWidget(
"character_name_setting_option"), m_Scene.GetIntroCharacter().GetCharacterName(),
null,
false);
99 m_GenderSelector =
new OptionSelectorMultistateCharacterMenu(layoutRoot.FindAnyWidget(
"character_gender_setting_option"), 0,
null,
false, m_Scene.GetIntroCharacter().GetCharGenderList());
100 if (m_Scene.GetIntroCharacter().IsCharacterFemale())
102 m_GenderSelector.SetValue(
"Female");
107 m_GenderSelector.SetValue(
"Male");
120 m_TopSelector.SetValue(obj.GetType(),
false);
122 obj = scene_char.GetInventory().FindAttachment(
InventorySlots.LEGS);
124 m_BottomSelector.SetValue(obj.GetType(),
false);
126 obj = scene_char.GetInventory().FindAttachment(
InventorySlots.FEET);
128 m_ShoesSelector.SetValue(obj.GetType(),
false);
130 m_SkinSelector.SetValue(scene_char.GetType());
133 m_GenderSelector.m_OptionChanged.Insert(GenderChanged);
134 m_SkinSelector.m_OptionChanged.Insert(SkinChanged);
135 m_TopSelector.m_OptionChanged.Insert(TopChanged);
136 m_BottomSelector.m_OptionChanged.Insert(BottomChanged);
137 m_ShoesSelector.m_OptionChanged.Insert(ShoesChanged);
148 void ~CharacterCreationMenu()
150 m_GenderSelector.m_OptionChanged.Remove(GenderChanged);
151 m_SkinSelector.m_OptionChanged.Remove(SkinChanged);
152 m_TopSelector.m_OptionChanged.Remove(TopChanged);
153 m_BottomSelector.m_OptionChanged.Remove(BottomChanged);
154 m_ShoesSelector.m_OptionChanged.Remove(ShoesChanged);
161 if (!m_Scene.GetIntroCharacter().IsDefaultCharacter())
163 string name = m_NameSelector.GetValue();
167 m_Scene.GetIntroCharacter().SaveCharName(
name);
170 MainMenu menu_main = MainMenu.Cast(
GetGame().GetUIManager().FindMenu(
MENU_MAIN));
173 menu_main.OnChangeCharacter(
false);
175 GetGame().GetUIManager().Back();
181 if (m_Scene.GetIntroCharacter().IsDefaultCharacter())
183 string name = m_NameSelector.GetValue();
187 m_Scene.GetIntroCharacter().SaveCharName(
name);
188 m_Scene.GetIntroCharacter().SaveDefaultCharacter();
189 m_Scene.GetIntroCharacter().SetToDefaultCharacter();
190 SetCharacterSaved(
true);
197 GetGame().GetMenuData().RequestGetDefaultCharacterData();
198 #ifdef PLATFORM_CONSOLE
199 if (m_OriginalCharacterID !=
GameConstants.DEFAULT_CHARACTER_MENU_ID && m_CharacterSaved)
201 m_OriginalCharacterID =
GameConstants.DEFAULT_CHARACTER_MENU_ID;
204 m_Scene.GetIntroCharacter().SetCharacterID(m_OriginalCharacterID);
205 m_Scene.GetIntroCharacter().CreateNewCharacterById(m_Scene.GetIntroCharacter().GetCharacterID());
206 GetGame().GetUIManager().Back();
211 if (m_Scene.GetIntroCharacter().IsDefaultCharacter())
213 GetGame().GetMenuDefaultCharacterData().EquipDefaultCharacter(m_Scene.GetIntroCharacter().GetCharacterObj());
217 void RandomizeCharacter()
219 m_Scene.GetIntroCharacter().SetToDefaultCharacter();
222 m_Scene.GetIntroCharacter().SetCharacterGender(
Math.RandomInt(0, 2));
224 if (m_Scene.GetIntroCharacter().IsCharacterFemale())
226 m_GenderSelector.SetValue(
"Female");
227 m_SkinSelector.LoadNewValues(m_Scene.GetIntroCharacter().GetCharList(
ECharGender.Female), 0);
228 m_SkinSelector.SetRandomValue();
232 m_GenderSelector.SetValue(
"Male");
233 m_SkinSelector.LoadNewValues(m_Scene.GetIntroCharacter().GetCharList(
ECharGender.Male), 0);
234 m_SkinSelector.SetRandomValue();
237 GetGame().GetMenuDefaultCharacterData().GenerateRandomEquip();
240 m_BottomSelector.SetValue(
GetGame().GetMenuDefaultCharacterData().GetAttachmentMap().
Get(
InventorySlots.LEGS),
false);
241 m_ShoesSelector.SetValue(
GetGame().GetMenuDefaultCharacterData().GetAttachmentMap().
Get(
InventorySlots.FEET),
false);
254 if (m_GenderSelector.GetStringValue() ==
"Female")
259 m_Scene.GetIntroCharacter().SetCharacterGender(gender);
261 m_SkinSelector.LoadNewValues(m_Scene.GetIntroCharacter().GetCharList(gender) , 0);
262 m_SkinSelector.SetRandomValue();
263 SetCharacterSaved(
false);
268 m_Scene.GetIntroCharacter().CreateNewCharacterByName(m_SkinSelector.GetStringValue(),
false);
269 SetCharacterSaved(
false);
274 GetGame().GetMenuDefaultCharacterData().SetDefaultAttachment(
InventorySlots.BODY,m_TopSelector.GetStringValue());
275 GetGame().GetMenuDefaultCharacterData().EquipDefaultCharacter(m_Scene.GetIntroCharacter().GetCharacterObj());
276 SetCharacterSaved(
false);
281 GetGame().GetMenuDefaultCharacterData().SetDefaultAttachment(
InventorySlots.LEGS,m_BottomSelector.GetStringValue());
282 GetGame().GetMenuDefaultCharacterData().EquipDefaultCharacter(m_Scene.GetIntroCharacter().GetCharacterObj());
283 SetCharacterSaved(
false);
288 GetGame().GetMenuDefaultCharacterData().SetDefaultAttachment(
InventorySlots.FEET,m_ShoesSelector.GetStringValue());
289 GetGame().GetMenuDefaultCharacterData().EquipDefaultCharacter(m_Scene.GetIntroCharacter().GetCharacterObj());
290 SetCharacterSaved(
false);
293 override bool OnKeyPress(
Widget w,
int x,
int y,
int key)
295 super.OnKeyPress(w,
x,
y, key);
306 else if (w == m_Save)
309 GetGame().GetUIManager().Back();
312 else if (w == m_RandomizeCharacter)
314 RandomizeCharacter();
317 else if (w == m_BackButton)
327 #ifndef PLATFORM_CONSOLE
328 if (w == m_CharacterRotationFrame)
340 #ifndef PLATFORM_CONSOLE
349 string tooltip_header =
"";
350 string tooltip_text =
"";
352 switch (w.GetUserID())
354 case TOOLTIP_ID_APPLY:
355 tooltip_header =
"#layout_main_menu_rename";
356 tooltip_text =
"#layout_character_creation_apply_tooltip";
359 case TOOLTIP_ID_SAVE:
360 tooltip_header =
"#layout_character_creation_save_character_alt";
361 tooltip_text =
"#layout_character_creation_save_tooltip";
364 SetTooltipTexts(w, tooltip_header, tooltip_text);
378 string tooltip_header =
"";
379 string tooltip_text =
"";
383 switch (w.GetUserID())
385 case TOOLTIP_ID_APPLY:
386 tooltip_header =
"#layout_main_menu_rename";
387 tooltip_text =
"#layout_character_creation_apply_tooltip";
390 case TOOLTIP_ID_SAVE:
391 tooltip_header =
"#layout_character_creation_save_character_alt";
392 tooltip_text =
"#layout_character_creation_save_tooltip";
395 SetTooltipTexts(w, tooltip_header, tooltip_text);
416 return (w == m_Apply || w == m_Save || w == m_RandomizeCharacter || w == m_BackButton);
421 void SetTooltipTexts(
Widget w,
string header =
"",
string desc =
"")
423 #ifndef PLATFORM_CONSOLE
424 bool show = header !=
"" && desc !=
"";
425 m_DetailsRoot.Show(show);
426 m_DetailsLabel.SetText(header);
427 m_DetailsText.SetText(desc);
432 float parent_pos_x, parent_pos_y;
433 float parent_size_x, parent_size_y;
434 float layout_size_x, layout_size_y;
436 w.GetScreenPos(parent_pos_x,parent_pos_y);
437 w.GetScreenSize(parent_size_x,parent_size_y);
438 layoutRoot.GetScreenSize(layout_size_x,layout_size_y);
440 float set_x = layout_size_x - parent_pos_x;
441 float set_y = layout_size_y - parent_pos_y - parent_size_y;
442 m_DetailsRoot.SetPos(set_x,set_y,
true);
445 m_DetailsText.Update();
446 m_DetailsLabel.Update();
447 m_DetailsRoot.Update();
451 void CheckNewOptions()
453 bool show_widgets = m_Scene.GetIntroCharacter().IsDefaultCharacter();
454 bool was_visible = layoutRoot.FindAnyWidget(
"character_gender_button").IsVisible();
455 layoutRoot.FindAnyWidget(
"character_gender_button").Show(show_widgets);
456 layoutRoot.FindAnyWidget(
"character_head_button").Show(show_widgets);
457 layoutRoot.FindAnyWidget(
"character_top_button").Show(show_widgets);
458 layoutRoot.FindAnyWidget(
"character_bottom_button").Show(show_widgets);
459 layoutRoot.FindAnyWidget(
"character_shoes_button").Show(show_widgets);
461 if (!was_visible && show_widgets)
462 m_GenderSelector.Focus();
469 #ifdef PLATFORM_CONSOLE
470 m_GenderSelector.Focus();
479 #ifdef PLATFORM_CONSOLE
480 if (
GetGame().GetUserManager() &&
GetGame().GetUserManager().GetSelectedUser())
482 name =
GetGame().GetUserManager().GetSelectedUser().GetName();
483 if (
name.LengthUtf8() > 16)
490 name = m_Scene.GetIntroCharacter().GetCharacterName();
495 m_NameSelector.SetValue(
name);
499 #ifdef PLATFORM_CONSOLE
500 version =
"#main_menu_version" +
" " + version +
" (" +
g_Game.GetDatabaseID() +
")";
502 m_Apply.Show(m_CharacterSaved || !m_Scene.GetIntroCharacter().IsDefaultCharacter());
503 m_Save.Show(!m_CharacterSaved && m_Scene.GetIntroCharacter().IsDefaultCharacter());
505 version =
"#main_menu_version" +
" " + version;
506 m_Apply.Show(!m_Scene.GetIntroCharacter().IsDefaultCharacter());
507 m_Save.Show(m_Scene.GetIntroCharacter().IsDefaultCharacter());
509 m_PlayedCharacterInfo.Show(!m_Scene.GetIntroCharacter().IsDefaultCharacter());
511 if (m_Scene.GetIntroCharacter().IsDefaultCharacter())
513 m_CharacterHeaderText.SetText(
"#character_menu_header");
517 m_CharacterHeaderText.SetText(
"#server_browser_prev_play_filter");
520 m_Version.SetText(version);
522 #ifdef PLATFORM_CONSOLE
528 override void Update(
float timeslice)
530 if (
GetUApi().GetInputByID(UAUIBack).LocalPress())
535 if (
GetUApi().GetInputByID(UAUICtrlX).LocalPress())
537 RandomizeCharacter();
540 #ifdef PLATFORM_CONSOLE
541 if (
GetUApi().GetInputByID(UAUICtrlY).LocalPress())
543 if (m_Scene.GetIntroCharacter().IsDefaultCharacter() && !m_CharacterSaved)
558 if (w.IsInherited(ButtonWidget))
560 ButtonWidget button = ButtonWidget.Cast(w);
561 button.SetTextColor(
ARGB(255, 200, 0, 0));
564 w.SetColor(
ARGB(255, 0, 0, 0));
569 ImageWidget image = ImageWidget.Cast(w.FindAnyWidget(w.GetName() +
"_image"));
570 Widget option =
Widget.Cast(w.FindAnyWidget(w.GetName() +
"_option_wrapper"));
571 Widget option_label = w.FindAnyWidget(
"option_label");
575 text1.SetColor(
ARGB(255, 255, 0, 0));
580 text2.SetColor(
ARGB(255, 255, 0, 0));
585 text3.SetColor(
ARGB(255, 255, 0, 0));
591 image.SetColor(
ARGB(255, 200, 0, 0));
596 option.SetColor(
ARGB(255, 255, 0, 0));
599 #ifndef PLATFORM_CONSOLE
602 option_label.SetColor(
ARGB(255, 255, 0, 0));
609 if (w.IsInherited(ButtonWidget))
611 ButtonWidget button = ButtonWidget.Cast(w);
618 ImageWidget image = ImageWidget.Cast(w.FindAnyWidget(w.GetName() +
"_image"));
619 Widget option = w.FindAnyWidget(w.GetName() +
"_option_wrapper");
620 Widget option_label = w.FindAnyWidget(
"option_label");
645 option.SetColor(
ARGB(150, 255, 255, 255));
648 #ifndef PLATFORM_CONSOLE
658 #ifndef PLATFORM_CONSOLE
664 ButtonWidget button = ButtonWidget.Cast(w);
674 ImageWidget image = ImageWidget.Cast(w.FindAnyWidget(w.GetName() +
"_image"));
675 Widget option =
Widget.Cast(w.FindAnyWidget(w.GetName() +
"_option_wrapper"));
676 Widget option_label = w.FindAnyWidget(
"option_label");
704 #ifndef PLATFORM_CONSOLE
707 option_label.SetColor(
ColorManager.COLOR_DISABLED_TEXT);
712 void SetCharacterSaved(
bool state)
714 #ifdef PLATFORM_CONSOLE
715 m_CharacterSaved = state;
722 #ifdef PLATFORM_CONSOLE
725 if (!m_CharacterSaved && m_Scene.GetIntroCharacter().IsDefaultCharacter())
727 text +=
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUICtrlY",
"#layout_character_creation_save_character_alt", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
729 text +=
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUICtrlX",
"#layout_character_creation_toolbar_randomize", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
730 if (m_Scene.GetIntroCharacter().IsDefaultCharacter())
732 text +=
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUISelect",
"#layout_character_creation_toolbar_select", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
734 text +=
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUIBack",
"#layout_character_creation_toolbar_back", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
735 toolbar_text.SetText(text);
742 string saveTextIcon =
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUICtrlY",
"", EUAINPUT_DEVICE_CONTROLLER);
743 toolbar_b2.SetText(
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUIBack",
"", EUAINPUT_DEVICE_CONTROLLER));
744 toolbar_x2.SetText(
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUICtrlX",
"", EUAINPUT_DEVICE_CONTROLLER));
745 toolbar_y2.SetText(saveTextIcon);
746 toolbar_y2_2.SetText(saveTextIcon);
752 #ifdef PLATFORM_CONSOLE
753 bool toolbarShow = !
GetGame().GetInput().IsEnabledMouseAndKeyboard() ||
GetGame().GetInput().GetCurrentInputDevice() ==
EInputDeviceType.CONTROLLER;
754 layoutRoot.FindAnyWidget(
"toolbar_bg").Show(toolbarShow);
755 layoutRoot.FindAnyWidget(
"play_panel_root").Show(!toolbarShow);