Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
charactercreationmenu.c
Go to the documentation of this file.
1 class CharacterCreationMenu extends UIScriptedMenu
2 {
3  #ifdef PLATFORM_CONSOLE
4  DayZIntroSceneXbox m_Scene;
5  protected bool m_CharacterSaved;
6  #else
7  DayZIntroScenePC m_Scene;
8  #endif
9 
10  const int TOOLTIP_ID_SAVE = 1;
11  const int TOOLTIP_ID_APPLY = 2;
12 
13  protected Widget m_CharacterRotationFrame;
14  protected Widget m_Apply;
15  protected Widget m_Save;
16  protected Widget m_RandomizeCharacter;
17  protected Widget m_BackButton;
18  protected Widget m_PlayedCharacterInfo;
19  protected TextWidget m_Version;
20  protected Widget m_DetailsRoot; //tooltips
21  protected TextWidget m_DetailsLabel;
22  protected RichTextWidget m_DetailsText;
23  protected TextWidget m_CharacterHeaderText;
24 
25  protected ref OptionSelectorEditbox m_NameSelector;
26  protected ref OptionSelectorMultistateCharacterMenu m_GenderSelector;
27  protected ref OptionSelectorMultistateCharacterMenu m_SkinSelector;
28  protected ref OptionSelectorMultistateCharacterMenu m_TopSelector;
29  protected ref OptionSelectorMultistateCharacterMenu m_BottomSelector;
30  protected ref OptionSelectorMultistateCharacterMenu m_ShoesSelector;
31 
32  int m_OriginalCharacterID;
33 
34  void CharacterCreationMenu()
35  {
36  MissionMainMenu mission = MissionMainMenu.Cast(GetGame().GetMission());
37 
38  #ifdef PLATFORM_CONSOLE
39  m_Scene = mission.GetIntroSceneXbox();
40  #else
41  m_Scene = mission.GetIntroScenePC();
42  #endif
43 
44  m_Scene.ResetIntroCamera();
45  }
46 
47  PlayerBase GetPlayerObj()
48  {
49  return m_Scene.GetIntroCharacter().GetCharacterObj();
50  }
51 
52  protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
53  {
54  #ifdef PLATFORM_CONSOLE
56  if (pInputDeviceType == EInputDeviceType.CONTROLLER)
57  {
58  CheckNewOptions(); //TODO - pick only the 'focus' bit
59  }
60  #endif
61  }
62 
63  override Widget Init()
64  {
65  #ifdef PLATFORM_CONSOLE
66  layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/character_creation/xbox/character_creation.layout");
67  m_CharacterSaved = false;
68  #else
69  layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/character_creation/pc/character_creation.layout");
70  #endif
71 
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");
83 
84  string version;
85  GetGame().GetVersion(version);
86  #ifdef PLATFORM_CONSOLE
87  version = "#main_menu_version" + " " + version + " (" + g_Game.GetDatabaseID() + ")";
88  #else
89  version = "#main_menu_version" + " " + version;
90  #endif
91  m_Version.SetText(version);
92 
93  if (m_Scene && m_Scene.GetIntroCharacter())
94  {
95  m_OriginalCharacterID = m_Scene.GetIntroCharacter().GetCharacterID();
96  }
97 
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())
101  {
102  m_GenderSelector.SetValue("Female");
103  m_SkinSelector = new OptionSelectorMultistateCharacterMenu(layoutRoot.FindAnyWidget("character_head_setting_option"), 0, null, false, m_Scene.GetIntroCharacter().GetCharList(ECharGender.Female));
104  }
105  else
106  {
107  m_GenderSelector.SetValue("Male");
108  m_SkinSelector = new OptionSelectorMultistateCharacterMenu(layoutRoot.FindAnyWidget("character_head_setting_option"), 0, null, false, m_Scene.GetIntroCharacter().GetCharList(ECharGender.Male));
109  }
110 
111  m_TopSelector = new OptionSelectorMultistateCharacterMenu(layoutRoot.FindAnyWidget("character_top_setting_option"), 0, null, false, DefaultCharacterCreationMethods.GetConfigAttachmentTypes(InventorySlots.BODY));
112  m_BottomSelector = new OptionSelectorMultistateCharacterMenu(layoutRoot.FindAnyWidget("character_bottom_setting_option"), 0, null, false, DefaultCharacterCreationMethods.GetConfigAttachmentTypes(InventorySlots.LEGS));
113  m_ShoesSelector = new OptionSelectorMultistateCharacterMenu(layoutRoot.FindAnyWidget("character_shoes_setting_option"), 0, null, false, DefaultCharacterCreationMethods.GetConfigAttachmentTypes(InventorySlots.FEET));
114 
115  PlayerBase scene_char = GetPlayerObj();
116  if (scene_char)
117  {
118  Object obj = scene_char.GetInventory().FindAttachment(InventorySlots.BODY);
119  if (obj)
120  m_TopSelector.SetValue(obj.GetType(), false);
121 
122  obj = scene_char.GetInventory().FindAttachment(InventorySlots.LEGS);
123  if (obj)
124  m_BottomSelector.SetValue(obj.GetType(), false);
125 
126  obj = scene_char.GetInventory().FindAttachment(InventorySlots.FEET);
127  if (obj)
128  m_ShoesSelector.SetValue(obj.GetType(), false);
129 
130  m_SkinSelector.SetValue(scene_char.GetType());
131  }
132 
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);
138 
139  Refresh();
140  SetCharacter();
141  CheckNewOptions();
142 
143  GetGame().GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
144 
145  return layoutRoot;
146  }
147 
148  void ~CharacterCreationMenu()
149  {
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);
155  }
156 
157  //Button Events
159  void Apply()
160  {
161  if (!m_Scene.GetIntroCharacter().IsDefaultCharacter())
162  {
163  string name = m_NameSelector.GetValue();
164  if (name == "")
165  name = GameConstants.DEFAULT_CHARACTER_NAME;
166 
167  m_Scene.GetIntroCharacter().SaveCharName(name);
168  }
169 
170  MainMenu menu_main = MainMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_MAIN));
171  if (menu_main)
172  {
173  menu_main.OnChangeCharacter(false);
174  }
175  GetGame().GetUIManager().Back();
176  }
177 
179  void Save()
180  {
181  if (m_Scene.GetIntroCharacter().IsDefaultCharacter())
182  {
183  string name = m_NameSelector.GetValue();
184  if (name == "")
185  name = GameConstants.DEFAULT_CHARACTER_NAME;
186 
187  m_Scene.GetIntroCharacter().SaveCharName(name);
188  m_Scene.GetIntroCharacter().SaveDefaultCharacter();
189  m_Scene.GetIntroCharacter().SetToDefaultCharacter();
190  SetCharacterSaved(true);
191  }
192  }
193 
194  void Back()
195  {
196  //bring back DefaultCharacter, if it exists (it should), or a previously played one.
197  GetGame().GetMenuData().RequestGetDefaultCharacterData();
198  #ifdef PLATFORM_CONSOLE
199  if (m_OriginalCharacterID != GameConstants.DEFAULT_CHARACTER_MENU_ID && m_CharacterSaved)
200  {
201  m_OriginalCharacterID = GameConstants.DEFAULT_CHARACTER_MENU_ID;
202  }
203  #endif
204  m_Scene.GetIntroCharacter().SetCharacterID(m_OriginalCharacterID);
205  m_Scene.GetIntroCharacter().CreateNewCharacterById(m_Scene.GetIntroCharacter().GetCharacterID());
206  GetGame().GetUIManager().Back();
207  }
208 
209  void SetCharacter()
210  {
211  if (m_Scene.GetIntroCharacter().IsDefaultCharacter())
212  {
213  GetGame().GetMenuDefaultCharacterData().EquipDefaultCharacter(m_Scene.GetIntroCharacter().GetCharacterObj());
214  }
215  }
216 
217  void RandomizeCharacter()
218  {
219  m_Scene.GetIntroCharacter().SetToDefaultCharacter();
220 
221  // make random selection
222  m_Scene.GetIntroCharacter().SetCharacterGender(Math.RandomInt(0, 2));
223 
224  if (m_Scene.GetIntroCharacter().IsCharacterFemale())
225  {
226  m_GenderSelector.SetValue("Female");
227  m_SkinSelector.LoadNewValues(m_Scene.GetIntroCharacter().GetCharList(ECharGender.Female), 0);
228  m_SkinSelector.SetRandomValue();
229  }
230  else
231  {
232  m_GenderSelector.SetValue("Male");
233  m_SkinSelector.LoadNewValues(m_Scene.GetIntroCharacter().GetCharList(ECharGender.Male), 0);
234  m_SkinSelector.SetRandomValue();
235  }
236 
237  GetGame().GetMenuDefaultCharacterData().GenerateRandomEquip();
238 
239  m_TopSelector.SetValue(GetGame().GetMenuDefaultCharacterData().GetAttachmentMap().Get(InventorySlots.BODY),false);
240  m_BottomSelector.SetValue(GetGame().GetMenuDefaultCharacterData().GetAttachmentMap().Get(InventorySlots.LEGS),false);
241  m_ShoesSelector.SetValue(GetGame().GetMenuDefaultCharacterData().GetAttachmentMap().Get(InventorySlots.FEET),false);
242 
243  Refresh();
244  SetCharacter();
245 
246  CheckNewOptions();
247  }
248 
249  //Selector Events
250  void GenderChanged()
251  {
252  ECharGender gender = ECharGender.Male;
253 
254  if (m_GenderSelector.GetStringValue() == "Female")
255  {
256  gender = ECharGender.Female;
257  }
258 
259  m_Scene.GetIntroCharacter().SetCharacterGender(gender);
260 
261  m_SkinSelector.LoadNewValues(m_Scene.GetIntroCharacter().GetCharList(gender) , 0);
262  m_SkinSelector.SetRandomValue();
263  SetCharacterSaved(false);
264  }
265 
266  void SkinChanged()
267  {
268  m_Scene.GetIntroCharacter().CreateNewCharacterByName(m_SkinSelector.GetStringValue(), false);
269  SetCharacterSaved(false);
270  }
271 
272  void TopChanged()
273  {
274  GetGame().GetMenuDefaultCharacterData().SetDefaultAttachment(InventorySlots.BODY,m_TopSelector.GetStringValue());
275  GetGame().GetMenuDefaultCharacterData().EquipDefaultCharacter(m_Scene.GetIntroCharacter().GetCharacterObj());
276  SetCharacterSaved(false);
277  }
278 
279  void BottomChanged()
280  {
281  GetGame().GetMenuDefaultCharacterData().SetDefaultAttachment(InventorySlots.LEGS,m_BottomSelector.GetStringValue());
282  GetGame().GetMenuDefaultCharacterData().EquipDefaultCharacter(m_Scene.GetIntroCharacter().GetCharacterObj());
283  SetCharacterSaved(false);
284  }
285 
286  void ShoesChanged()
287  {
288  GetGame().GetMenuDefaultCharacterData().SetDefaultAttachment(InventorySlots.FEET,m_ShoesSelector.GetStringValue());
289  GetGame().GetMenuDefaultCharacterData().EquipDefaultCharacter(m_Scene.GetIntroCharacter().GetCharacterObj());
290  SetCharacterSaved(false);
291  }
292 
293  override bool OnKeyPress(Widget w, int x, int y, int key)
294  {
295  super.OnKeyPress(w, x, y, key);
296  return false;
297  }
298 
299  override bool OnClick(Widget w, int x, int y, int button)
300  {
301  if (w == m_Apply)
302  {
303  Apply();
304  return true;
305  }
306  else if (w == m_Save)
307  {
308  Save();
309  GetGame().GetUIManager().Back();
310  return true;
311  }
312  else if (w == m_RandomizeCharacter)
313  {
314  RandomizeCharacter();
315  return true;
316  }
317  else if (w == m_BackButton)
318  {
319  Back();
320  return true;
321  }
322  return false;
323  }
324 
325  override bool OnMouseButtonDown(Widget w, int x, int y, int button)
326  {
327  #ifndef PLATFORM_CONSOLE
328  if (w == m_CharacterRotationFrame)
329  {
330  if (m_Scene)
331  DayZIntroScenePC.Cast(m_Scene).CharacterRotationStart();
332  return true;
333  }
334  #endif
335  return false;
336  }
337 
338  override bool OnMouseButtonUp(Widget w, int x, int y, int button)
339  {
340  #ifndef PLATFORM_CONSOLE
341  if (m_Scene)
342  DayZIntroScenePC.Cast(m_Scene).CharacterRotationStop();
343  #endif
344  return false;
345  }
346 
347  override bool OnMouseEnter(Widget w, int x, int y)
348  {
349  string tooltip_header = "";
350  string tooltip_text = "";
351  ColorHighlight(w);
352  switch (w.GetUserID())
353  {
354  case TOOLTIP_ID_APPLY:
355  tooltip_header = "#layout_main_menu_rename";
356  tooltip_text = "#layout_character_creation_apply_tooltip";
357  break;
358 
359  case TOOLTIP_ID_SAVE:
360  tooltip_header = "#layout_character_creation_save_character_alt";
361  tooltip_text = "#layout_character_creation_save_tooltip";
362  break;
363  }
364  SetTooltipTexts(w, tooltip_header, tooltip_text);
365  return true;
366  }
367 
368  override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
369  {
370  ColorNormal(w);
371  SetFocus(null);
372 
373  return true;
374  }
375 
376  override bool OnFocus(Widget w, int x, int y)
377  {
378  string tooltip_header = "";
379  string tooltip_text = "";
380  if (IsFocusable(w))
381  {
382  ColorHighlight(w);
383  switch (w.GetUserID())
384  {
385  case TOOLTIP_ID_APPLY:
386  tooltip_header = "#layout_main_menu_rename";
387  tooltip_text = "#layout_character_creation_apply_tooltip";
388  break;
389 
390  case TOOLTIP_ID_SAVE:
391  tooltip_header = "#layout_character_creation_save_character_alt";
392  tooltip_text = "#layout_character_creation_save_tooltip";
393  break;
394  }
395  SetTooltipTexts(w, tooltip_header, tooltip_text);
396  return true;
397  }
398  SetTooltipTexts(w);
399  return false;
400  }
401 
402  override bool OnFocusLost(Widget w, int x, int y)
403  {
404  if (IsFocusable(w))
405  {
406  ColorNormal(w);
407  return true;
408  }
409  return false;
410  }
411 
412  bool IsFocusable(Widget w)
413  {
414  if (w)
415  {
416  return (w == m_Apply || w == m_Save || w == m_RandomizeCharacter || w == m_BackButton);
417  }
418  return false;
419  }
420 
421  void SetTooltipTexts(Widget w, string header = "", string desc = "")
422  {
423  #ifndef PLATFORM_CONSOLE
424  bool show = header != "" && desc != "";
425  m_DetailsRoot.Show(show);
426  m_DetailsLabel.SetText(header);
427  m_DetailsText.SetText(desc);
428 
429  //moves the widget to parent, setting is relative to widget alignment, case-specific implementation (getter missing!!!)
430  if (show)
431  {
432  float parent_pos_x, parent_pos_y;
433  float parent_size_x, parent_size_y;
434  float layout_size_x, layout_size_y;
435 
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);
439 
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);
443  }
444 
445  m_DetailsText.Update();
446  m_DetailsLabel.Update();
447  m_DetailsRoot.Update();
448  #endif
449  }
450 
451  void CheckNewOptions()
452  {
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);
460 
461  if (!was_visible && show_widgets)
462  m_GenderSelector.Focus();
463  if (!show_widgets)
464  SetFocus(m_RandomizeCharacter);
465  }
466 
467  override void OnShow()
468  {
469 #ifdef PLATFORM_CONSOLE
470  m_GenderSelector.Focus();
472 #endif
473  CheckNewOptions();
474  }
475 
476  override void Refresh()
477  {
478  string name;
479  #ifdef PLATFORM_CONSOLE
480  if (GetGame().GetUserManager() && GetGame().GetUserManager().GetSelectedUser())
481  {
482  name = GetGame().GetUserManager().GetSelectedUser().GetName();
483  if (name.LengthUtf8() > 16)
484  {
485  name = name.SubstringUtf8(0, 16);
486  name += "...";
487  }
488  }
489  #else
490  name = m_Scene.GetIntroCharacter().GetCharacterName();
491  if (name == "")
492  name = GameConstants.DEFAULT_CHARACTER_NAME;
493  #endif
494 
495  m_NameSelector.SetValue(name);
496 
497  string version;
498  GetGame().GetVersion(version);
499  #ifdef PLATFORM_CONSOLE
500  version = "#main_menu_version" + " " + version + " (" + g_Game.GetDatabaseID() + ")";
501 
502  m_Apply.Show(m_CharacterSaved || !m_Scene.GetIntroCharacter().IsDefaultCharacter());
503  m_Save.Show(!m_CharacterSaved && m_Scene.GetIntroCharacter().IsDefaultCharacter());
504  #else
505  version = "#main_menu_version" + " " + version;
506  m_Apply.Show(!m_Scene.GetIntroCharacter().IsDefaultCharacter());
507  m_Save.Show(m_Scene.GetIntroCharacter().IsDefaultCharacter());
508  #endif
509  m_PlayedCharacterInfo.Show(!m_Scene.GetIntroCharacter().IsDefaultCharacter());
510 
511  if (m_Scene.GetIntroCharacter().IsDefaultCharacter())
512  {
513  m_CharacterHeaderText.SetText("#character_menu_header");
514  }
515  else
516  {
517  m_CharacterHeaderText.SetText("#server_browser_prev_play_filter");
518  }
519 
520  m_Version.SetText(version);
521 
522  #ifdef PLATFORM_CONSOLE
525  #endif
526  }
527 
528  override void Update(float timeslice)
529  {
530  if (GetUApi().GetInputByID(UAUIBack).LocalPress())
531  {
532  Back();
533  }
534 
535  if (GetUApi().GetInputByID(UAUICtrlX).LocalPress())
536  {
537  RandomizeCharacter();
538  }
539 
540  #ifdef PLATFORM_CONSOLE
541  if (GetUApi().GetInputByID(UAUICtrlY).LocalPress())
542  {
543  if (m_Scene.GetIntroCharacter().IsDefaultCharacter() && !m_CharacterSaved)
544  {
545  Save();
546  }
547  }
548  #endif
549  }
550 
551  override void OnHide()
552  {
553  }
554 
555  //Coloring functions (Until WidgetStyles are useful)
556  void ColorHighlight(Widget w)
557  {
558  if (w.IsInherited(ButtonWidget))
559  {
560  ButtonWidget button = ButtonWidget.Cast(w);
561  button.SetTextColor(ARGB(255, 200, 0, 0));
562  }
563 
564  w.SetColor(ARGB(255, 0, 0, 0));
565 
566  TextWidget text1 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text"));
567  TextWidget text2 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_label"));
568  TextWidget text3 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text_1"));
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");
572 
573  if (text1)
574  {
575  text1.SetColor(ARGB(255, 255, 0, 0));
576  }
577 
578  if (text2)
579  {
580  text2.SetColor(ARGB(255, 255, 0, 0));
581  }
582 
583  if (text3)
584  {
585  text3.SetColor(ARGB(255, 255, 0, 0));
586  w.SetAlpha(1);
587  }
588 
589  if (image)
590  {
591  image.SetColor(ARGB(255, 200, 0, 0));
592  }
593 
594  if (option)
595  {
596  option.SetColor(ARGB(255, 255, 0, 0));
597  }
598 
599  #ifndef PLATFORM_CONSOLE
600  if (option_label)
601  {
602  option_label.SetColor(ARGB(255, 255, 0, 0));
603  }
604  #endif
605  }
606 
607  void ColorNormal(Widget w)
608  {
609  if (w.IsInherited(ButtonWidget))
610  {
611  ButtonWidget button = ButtonWidget.Cast(w);
612  button.SetTextColor(ColorManager.COLOR_NORMAL_TEXT);
613  }
614 
615  TextWidget text1 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text"));
616  TextWidget text2 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text_1"));
617  TextWidget text3 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_label"));
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");
621 
622  if (text1)
623  {
624  text1.SetColor(ColorManager.COLOR_NORMAL_TEXT);
625  }
626 
627  if (text2)
628  {
629  text2.SetColor(ColorManager.COLOR_NORMAL_TEXT);
630  }
631 
632  if (text3)
633  {
634  text3.SetColor(ColorManager.COLOR_NORMAL_TEXT);
635  w.SetAlpha(0);
636  }
637 
638  if (image)
639  {
640  image.SetColor(ColorManager.COLOR_NORMAL_TEXT);
641  }
642 
643  if (option)
644  {
645  option.SetColor(ARGB(150, 255, 255, 255));
646  }
647 
648  #ifndef PLATFORM_CONSOLE
649  if (option_label)
650  {
651  option_label.SetColor(ColorManager.COLOR_NORMAL_TEXT);
652  }
653  #endif
654  }
655 
656  void ColorDisable(Widget w)
657  {
658  #ifndef PLATFORM_CONSOLE
659  SetFocus(null);
660  #endif
661 
662  if (w)
663  {
664  ButtonWidget button = ButtonWidget.Cast(w);
665  if (button)
666  {
667  button.SetTextColor(ColorManager.COLOR_DISABLED_TEXT);
668  }
669  }
670 
671  TextWidget text1 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text"));
672  TextWidget text2 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_label"));
673  TextWidget text3 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text_1"));
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");
677 
678  if (text1)
679  {
680  text1.SetColor(ColorManager.COLOR_DISABLED_TEXT);
681  }
682 
683  if (text2)
684  {
685  text2.SetColor(ColorManager.COLOR_DISABLED_TEXT);
686  }
687 
688  if (text3)
689  {
690  text3.SetColor(ColorManager.COLOR_DISABLED_TEXT);
691  w.SetAlpha(1);
692  }
693 
694  if (image)
695  {
696  image.SetColor(ColorManager.COLOR_DISABLED_TEXT);
697  }
698 
699  if (option)
700  {
701  option.SetColor(ColorManager.COLOR_DISABLED_TEXT);
702  }
703 
704  #ifndef PLATFORM_CONSOLE
705  if (option_label)
706  {
707  option_label.SetColor(ColorManager.COLOR_DISABLED_TEXT);
708  }
709  #endif
710  }
711 
712  void SetCharacterSaved(bool state)
713  {
714  #ifdef PLATFORM_CONSOLE
715  m_CharacterSaved = state;
716  Refresh();
717  #endif
718  }
719 
720  protected void UpdateControlsElements()
721  {
722  #ifdef PLATFORM_CONSOLE
723  RichTextWidget toolbar_text = RichTextWidget.Cast(layoutRoot.FindAnyWidget("ContextToolbarText"));
724  string text = "";
725  if (!m_CharacterSaved && m_Scene.GetIntroCharacter().IsDefaultCharacter()) //can be saved..
726  {
727  text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUICtrlY", "#layout_character_creation_save_character_alt", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
728  }
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()) //edit options available
731  {
732  text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUISelect", "#layout_character_creation_toolbar_select", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
733  }
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);
736 
737  RichTextWidget toolbar_b2 = RichTextWidget.Cast(layoutRoot.FindAnyWidget("BackIcon0"));
738  RichTextWidget toolbar_x2 = RichTextWidget.Cast(layoutRoot.FindAnyWidget("RandomizeIcon0"));
739  RichTextWidget toolbar_y2 = RichTextWidget.Cast(layoutRoot.FindAnyWidget("SaveIcon0"));
740  RichTextWidget toolbar_y2_2 = RichTextWidget.Cast(layoutRoot.FindAnyWidget("ApplyIcon0"));
741 
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);
747  #endif
748  }
749 
750  protected void UpdateControlsElementVisibility()
751  {
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);
756  #endif
757  }
758 }
GetGame
proto native CGame GetGame()
UIScriptedMenu
Definition: dayzgame.c:63
mission
Mission mission
Definition: displaystatus.c:28
InputUtils
Definition: inpututils.c:1
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
Back
void Back()
Definition: controlsxbox.c:36
OptionSelectorMultistateCharacterMenu
void OptionSelectorMultistateCharacterMenu(Widget parent, int current_index, ScriptedWidgetEventHandler parent_c, bool disabled, notnull array< string > options)
Definition: optionselectormultistate.c:138
UpdateControlsElements
protected void UpdateControlsElements()
Definition: itemdropwarningmenu.c:92
OnHide
override void OnHide()
Definition: inventorymenu.c:141
y
Icon y
Refresh
void Refresh()
Definition: sizetochild.c:108
ColorDisable
void ColorDisable(Widget w)
Definition: serverbrowsertab.c:720
OnInputDeviceChanged
protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Definition: inventory.c:167
EInputDeviceType
EInputDeviceType
Definition: input.c:2
OnMouseLeave
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Definition: uihintpanel.c:276
OnMouseButtonUp
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
Definition: radialmenu.c:668
RichTextWidget
Definition: gameplay.c:315
PlayerBase
Definition: playerbaseclient.c:1
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
DayZIntroSceneXbox
Definition: dayzintroscenexbox.c:1
TextWidget
Definition: enwidgets.c:219
ColorNormal
void ColorNormal(Widget w)
Definition: serverbrowsertab.c:668
UpdateControlsElementVisibility
protected void UpdateControlsElementVisibility()
Definition: itemdropwarningmenu.c:100
DayZIntroScenePC
Definition: dayzintroscenepc.c:1
ColorManager
Definition: colormanager.c:1
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
Object
Definition: objecttyped.c:1
ECharGender
ECharGender
Definition: echargender.c:1
ColorHighlight
void ColorHighlight(Widget w)
Definition: serverbrowsertab.c:619
OnFocusLost
override bool OnFocusLost(Widget w, int x, int y)
Definition: serverbrowsertab.c:235
Get
array< ref PlayerStatBase > Get()
Definition: playerstatspco.c:103
Update
proto native volatile void Update()
Definition: playersoundmanager.c:125
SetFocus
proto native void SetFocus(Widget w)
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
x
Icon x
OnMouseButtonDown
bool OnMouseButtonDown(Widget w, int x, int y, int button)
Definition: pluginitemdiagnostic.c:117
GameConstants
Definition: constants.c:612
OnFocus
override bool OnFocus(Widget w, int x, int y)
Definition: serverbrowsertab.c:217
OnShow
override void OnShow()
Definition: controlsxbox.c:349
Widget
Definition: enwidgets.c:189
GetUApi
proto native UAInputAPI GetUApi()
OnClick
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
Definition: dayzgame.c:146
Math
Definition: enmath.c:6
OnMouseEnter
override bool OnMouseEnter(Widget w, int x, int y)
Definition: uihintpanel.c:267
ARGB
int ARGB(int a, int r, int g, int b)
Definition: proto.c:322
MENU_MAIN
const int MENU_MAIN
Definition: constants.c:172
IsFocusable
bool IsFocusable(Widget w)
Definition: serverbrowsertab.c:284