MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / lstOptionsClick

Method lstOptionsClick

src/Menu/OptionsAdvancedState.cpp:189–253  ·  view source on GitHub ↗

* Changes the clicked setting. * @param action Pointer to an action. */

Source from the content-addressed store, hash-verified

187 * @param action Pointer to an action.
188 */
189void OptionsAdvancedState::lstOptionsClick(Action *action)
190{
191 Uint8 button = action->getDetails()->button.button;
192 if (button != SDL_BUTTON_LEFT && button != SDL_BUTTON_RIGHT)
193 {
194 return;
195 }
196 size_t sel = _lstOptions->getSelectedRow();
197 OptionInfo *setting = getSetting(sel);
198 if (!setting) return;
199
200 std::wstring settingText = L"";
201 if (setting->type() == OPTION_BOOL)
202 {
203 bool *b = setting->asBool();
204 *b = !*b;
205 settingText = *b ? tr("STR_YES") : tr("STR_NO");
206 }
207 else if (setting->type() == OPTION_INT) // integer variables will need special handling
208 {
209 int *i = setting->asInt();
210
211 int increment = (button == SDL_BUTTON_LEFT) ? 1 : -1; // left-click increases, right-click decreases
212 if (i == &Options::changeValueByMouseWheel || i == &Options::FPS)
213 {
214 increment *= 10;
215 }
216 *i += increment;
217
218 int min = 0, max = 0;
219 if (i == &Options::battleExplosionHeight)
220 {
221 min = 0;
222 max = 3;
223 }
224 else if (i == &Options::changeValueByMouseWheel)
225 {
226 min = 0;
227 max = 50;
228 }
229 else if (i == &Options::FPS)
230 {
231 min = 0;
232 max = 120;
233 }
234 else if (i == &Options::mousewheelSpeed)
235 {
236 min = 1;
237 max = 7;
238 }
239 if (*i < min)
240 {
241 *i = max;
242 }
243 else if (*i > max)
244 {
245 *i = min;
246 }

Callers

nothing calls this directly

Calls 6

getDetailsMethod · 0.80
getSelectedRowMethod · 0.80
typeMethod · 0.80
asBoolMethod · 0.80
asIntMethod · 0.80
setCellTextMethod · 0.80

Tested by

no test coverage detected