MCPcopy Create free account
hub / github.com/REGoth-project/REGoth / onInputAction

Method onInputAction

src/ui/DialogBox.cpp:112–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void DialogBox::onInputAction(Engine::ActionType action)
113{
114 using Engine::ActionType;
115
116 if (m_Choices.empty())
117 return;
118
119 switch (action)
120 {
121 case ActionType::UI_Up:
122 m_CurrentlySelected = Utils::mod(m_CurrentlySelected - 1, (int)m_Choices.size());
123 break;
124 case ActionType::UI_Down:
125 m_CurrentlySelected = Utils::mod(m_CurrentlySelected + 1, (int)m_Choices.size());
126 break;
127 case ActionType::UI_Left:
128 break;
129 case ActionType::UI_Right:
130 break;
131 case ActionType::UI_0:
132 break;
133 case ActionType::UI_1:
134 case ActionType::UI_2:
135 case ActionType::UI_3:
136 case ActionType::UI_4:
137 case ActionType::UI_5:
138 case ActionType::UI_6:
139 case ActionType::UI_7:
140 case ActionType::UI_8:
141 case ActionType::UI_9:
142 {
143 int index = static_cast<int>(action) - static_cast<int>(ActionType::UI_1);
144 m_CurrentlySelected = std::min(index, (int)m_Choices.size() - 1);
145 }
146 break;
147 case ActionType::UI_HOME:
148 m_CurrentlySelected = 0;
149 break;
150 case ActionType::UI_END:
151 m_CurrentlySelected = static_cast<int>(m_Choices.size()) - 1;
152 break;
153 case ActionType::UI_Close:
154 // closing Dialog-Option-Box when pressing Escape
155 //m_Engine.getMainWorld().get().getDialogManager().performChoice(m_Choices.size()-1);break;
156 // selecting last option in Dialog-Option-Box when pressing Escape
157 //m_CurrentlySelected = m_Choices.size()-1;break;
158 break;
159 case ActionType::UI_Confirm:
160 if (m_CurrentlySelected != -1)
161 m_Engine.getMainWorld().get().getDialogManager().performChoice(static_cast<size_t>(m_CurrentlySelected));
162 break;
163 default:
164 break;
165 }
166}

Callers

nothing calls this directly

Calls 6

modFunction · 0.85
performChoiceMethod · 0.80
getMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
getMainWorldMethod · 0.45

Tested by

no test coverage detected