| 265 | } |
| 266 | |
| 267 | void DrawCheatWidget(const Rect &r) const |
| 268 | { |
| 269 | const Rect ir = r; |
| 270 | int y = ir.top; |
| 271 | |
| 272 | bool rtl = _current_text_dir == TD_RTL; |
| 273 | uint button_left = rtl ? ir.right - SETTING_BUTTON_WIDTH : ir.left; |
| 274 | uint text_left = ir.left + (rtl ? 0 : WidgetDimensions::scaled.hsep_wide + SETTING_BUTTON_WIDTH); |
| 275 | uint text_right = ir.right - (rtl ? WidgetDimensions::scaled.hsep_wide + SETTING_BUTTON_WIDTH : 0); |
| 276 | |
| 277 | int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2; |
| 278 | int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2; |
| 279 | int icon_y_offset = (this->line_height - this->icon.height) / 2; |
| 280 | |
| 281 | for (int i = 0; i != lengthof(_cheats_ui); i++) { |
| 282 | const CheatEntry *ce = &_cheats_ui[i]; |
| 283 | |
| 284 | std::string str; |
| 285 | switch (ce->type) { |
| 286 | case SLE_BOOL: { |
| 287 | bool on = (*(bool*)ce->variable); |
| 288 | |
| 289 | DrawBoolButton(button_left, y + button_y_offset, COLOUR_YELLOW, COLOUR_GREY, on, true); |
| 290 | str = GetString(ce->str, on ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF); |
| 291 | break; |
| 292 | } |
| 293 | |
| 294 | default: { |
| 295 | int32_t val = static_cast<int32_t>(ReadValue(ce->variable, ce->type)); |
| 296 | |
| 297 | /* Draw [<][>] boxes for settings of an integer-type */ |
| 298 | DrawArrowButtons(button_left, y + button_y_offset, COLOUR_YELLOW, clicked - (i * 2), true, true); |
| 299 | |
| 300 | switch (ce->str) { |
| 301 | /* Display date for change date cheat */ |
| 302 | case STR_CHEAT_CHANGE_DATE: |
| 303 | str = GetString(ce->str, TimerGameCalendar::date); |
| 304 | break; |
| 305 | |
| 306 | /* Draw coloured flag for change company cheat */ |
| 307 | case STR_CHEAT_CHANGE_COMPANY: { |
| 308 | str = GetString(ce->str, val + 1); |
| 309 | uint offset = WidgetDimensions::scaled.hsep_indent + GetStringBoundingBox(str).width; |
| 310 | DrawCompanyIcon(_local_company, rtl ? text_right - offset - WidgetDimensions::scaled.hsep_indent : text_left + offset, y + icon_y_offset); |
| 311 | break; |
| 312 | } |
| 313 | |
| 314 | default: |
| 315 | str = GetString(ce->str, val); |
| 316 | break; |
| 317 | } |
| 318 | break; |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | DrawString(text_left, text_right, y + text_y_offset, str); |
| 323 | |
| 324 | y += this->line_height; |
nothing calls this directly
no test coverage detected