DayZ 1.24
Loading...
Searching...
No Matches
OptionSelector Class Reference
Collaboration diagram for OptionSelector:
[legend]

Protected Member Functions

void OptionSelectorMultistate (Widget parent, int current_index, ScriptedWidgetEventHandler parent_c, bool disabled, notnull array< string > options)
 
void LoadNewValues (notnull array< string > options, int current_index)
 
override void SetNextOption ()
 
override void SetPrevOption ()
 
void PerformSetOption (int index)
 
void SetCanSwitch (bool value)
 
bool CanSwitch ()
 
void SetValue (int value, bool fire_event=true)
 
void SetValue (string value, bool fire_event=true)
 
void SetRandomValue ()
 
int GetValue ()
 
override void SetStringOption (string option, bool fire_event=true)
 

Protected Attributes

bool m_CanSwitch
 

Detailed Description

Definition at line 1 of file OptionSelectorMultistate.c.

Member Function Documentation

◆ CanSwitch()

bool OptionSelector::CanSwitch ( )
inlineprotected

Definition at line 64 of file OptionSelectorMultistate.c.

65 {
66 return m_CanSwitch;
67 }

References m_CanSwitch.

◆ GetValue()

int OptionSelector::GetValue ( )
inlineprotected

Definition at line 99 of file OptionSelectorMultistate.c.

100 {
101 return m_SelectedOptionIndex;
102 }

◆ LoadNewValues()

void OptionSelector::LoadNewValues ( notnull array< string > options,
int current_index )
inlineprotected

Definition at line 22 of file OptionSelectorMultistate.c.

23 {
24 m_Options = options;
26 }
void SetValue(int value, bool fire_event=true)

References SetValue().

◆ OptionSelectorMultistate()

void OptionSelector::OptionSelectorMultistate ( Widget parent,
int current_index,
ScriptedWidgetEventHandler parent_c,
bool disabled,
notnull array< string > options )
inlineprotected

Definition at line 5 of file OptionSelectorMultistate.c.

6 {
7 m_CanSwitch = true;
8
9 m_SelectorType = 2;
10 m_Options = options;
11 if (options.Count() == 0)
12 Error("Invalid OptionSelectorMultistate options");
13
14 if (current_index < 0 || current_index >= m_Options.Count())
15 m_SelectedOptionIndex = 0;
16 else
17 m_SelectedOptionIndex = current_index;
18
19 m_SelectedOption.SetText(m_Options.Get(m_SelectedOptionIndex));
20 }
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

References Error().

◆ PerformSetOption()

void OptionSelector::PerformSetOption ( int index)
inlineprotected

Definition at line 52 of file OptionSelectorMultistate.c.

53 {
54 m_SelectedOptionIndex = index;
55 m_SelectedOption.SetText(m_Options.Get(index));
56 m_OptionChanged.Invoke(index);
57 }

Referenced by SetNextOption(), and SetPrevOption().

◆ SetCanSwitch()

void OptionSelector::SetCanSwitch ( bool value)
inlineprotected

Definition at line 59 of file OptionSelectorMultistate.c.

60 {
62 }

◆ SetNextOption()

override void OptionSelector::SetNextOption ( )
inlineprotected

Definition at line 28 of file OptionSelectorMultistate.c.

29 {
30 int idx = m_SelectedOptionIndex;
31 idx++;
32 if (idx >= m_Options.Count())
33 idx = 0;
34
35 m_AttemptOptionChange.Invoke(idx);
36 if (m_CanSwitch)
38 }
void PerformSetOption(int index)

References PerformSetOption().

Referenced by OptionSelectorBase::OnClick(), and OptionSelectorBase::OnMouseButtonUp().

◆ SetPrevOption()

override void OptionSelector::SetPrevOption ( )
inlineprotected

Definition at line 40 of file OptionSelectorMultistate.c.

41 {
42 int idx = m_SelectedOptionIndex;
43 idx--;
44 if (idx < 0)
45 idx = m_Options.Count() - 1;
46
47 m_AttemptOptionChange.Invoke(idx);
48 if (m_CanSwitch)
50 }

References PerformSetOption().

Referenced by OptionSelectorBase::OnMouseButtonUp().

◆ SetRandomValue()

void OptionSelector::SetRandomValue ( )
inlineprotected

Definition at line 92 of file OptionSelectorMultistate.c.

93 {
94 m_SelectedOptionIndex = Math.RandomInt(0, m_Options.Count());
95 m_SelectedOption.SetText(m_Options.Get(m_SelectedOptionIndex));
96 m_OptionChanged.Invoke(m_SelectedOptionIndex);
97 }
Definition EnMath.c:7
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].

References Math::RandomInt().

◆ SetStringOption()

override void OptionSelector::SetStringOption ( string option,
bool fire_event = true )
inlineprotected

Definition at line 104 of file OptionSelectorMultistate.c.

105 {
106 int index = m_Options.Find(option);
107 if (index > -1)
108 {
109 m_SelectedOptionIndex = index;
110 m_SelectedOption.SetText(m_Options.Get(m_SelectedOptionIndex));
111
112 if (fire_event)
113 m_OptionChanged.Invoke(m_SelectedOptionIndex);
114 }
115 }

◆ SetValue() [1/2]

void OptionSelector::SetValue ( int value,
bool fire_event = true )
inlineprotected

Definition at line 69 of file OptionSelectorMultistate.c.

70 {
71 if (value < m_Options.Count() && value >= 0)
72 {
73 m_SelectedOptionIndex = value;
74 m_SelectedOption.SetText(m_Options.Get(m_SelectedOptionIndex));
75 if (fire_event)
76 m_OptionChanged.Invoke(m_SelectedOptionIndex);
77 }
78 }

Referenced by LoadNewValues().

◆ SetValue() [2/2]

void OptionSelector::SetValue ( string value,
bool fire_event = true )
inlineprotected

Definition at line 80 of file OptionSelectorMultistate.c.

81 {
82 int index = m_Options.Find(value);
83 if (index >= 0)
84 {
85 m_SelectedOptionIndex = index;
86 m_SelectedOption.SetText(m_Options.Get(m_SelectedOptionIndex));
87 if (fire_event)
88 m_OptionChanged.Invoke(m_SelectedOptionIndex);
89 }
90 }

Member Data Documentation

◆ m_CanSwitch

bool OptionSelector::m_CanSwitch
protected

Definition at line 3 of file OptionSelectorMultistate.c.

Referenced by CanSwitch().


The documentation for this class was generated from the following file: