| 1372 | } |
| 1373 | |
| 1374 | void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override |
| 1375 | { |
| 1376 | switch (widget) { |
| 1377 | /* Toggle size, advanced/simple face selection */ |
| 1378 | case WID_SCMF_TOGGLE_LARGE_SMALL: |
| 1379 | case WID_SCMF_TOGGLE_LARGE_SMALL_BUTTON: |
| 1380 | this->advanced = !this->advanced; |
| 1381 | this->SelectDisplayPlanes(this->advanced); |
| 1382 | this->ReInit(); |
| 1383 | break; |
| 1384 | |
| 1385 | /* OK button */ |
| 1386 | case WID_SCMF_ACCEPT: |
| 1387 | Command<CMD_SET_COMPANY_MANAGER_FACE>::Post(this->face.style, this->face.bits); |
| 1388 | [[fallthrough]]; |
| 1389 | |
| 1390 | /* Cancel button */ |
| 1391 | case WID_SCMF_CANCEL: |
| 1392 | this->Close(); |
| 1393 | break; |
| 1394 | |
| 1395 | /* Load button */ |
| 1396 | case WID_SCMF_LOAD: { |
| 1397 | auto cmf = ParseCompanyManagerFaceCode(_company_manager_face); |
| 1398 | if (cmf.has_value()) this->face = *cmf; |
| 1399 | ShowErrorMessage(GetEncodedString(STR_FACE_LOAD_DONE), {}, WL_INFO); |
| 1400 | this->UpdateData(); |
| 1401 | this->SetDirty(); |
| 1402 | break; |
| 1403 | } |
| 1404 | |
| 1405 | /* 'Company manager face number' button, view and/or set company manager face number */ |
| 1406 | case WID_SCMF_FACECODE: |
| 1407 | ShowQueryString(FormatCompanyManagerFaceCode(this->face), STR_FACE_FACECODE_CAPTION, 128, this, CS_ALPHANUMERAL, {}); |
| 1408 | break; |
| 1409 | |
| 1410 | /* Save button */ |
| 1411 | case WID_SCMF_SAVE: |
| 1412 | _company_manager_face = FormatCompanyManagerFaceCode(this->face); |
| 1413 | ShowErrorMessage(GetEncodedString(STR_FACE_SAVE_DONE), {}, WL_INFO); |
| 1414 | break; |
| 1415 | |
| 1416 | /* Randomize face button */ |
| 1417 | case WID_SCMF_RANDOM_NEW_FACE: |
| 1418 | RandomiseCompanyManagerFace(this->face, _interactive_random); |
| 1419 | this->UpdateData(); |
| 1420 | this->SetDirty(); |
| 1421 | break; |
| 1422 | |
| 1423 | case WID_SCMF_STYLE: { |
| 1424 | bool rtl = _current_text_dir == TD_RTL; |
| 1425 | Rect ir = this->GetWidget<NWidgetCore>(widget)->GetCurrentRect().Shrink(WidgetDimensions::scaled.frametext, RectPadding::zero); |
| 1426 | Rect br = ir.WithWidth(SETTING_BUTTON_WIDTH, rtl); |
| 1427 | |
| 1428 | uint num_styles = GetNumCompanyManagerFaceStyles(); |
| 1429 | this->selected_var = UINT_MAX - 1; |
| 1430 | if (IsInsideBS(pt.x, br.left, SETTING_BUTTON_WIDTH / 2)) { |
| 1431 | SetCompanyManagerFaceStyle(this->face, (this->face.style + num_styles - 1) % num_styles); |
nothing calls this directly
no test coverage detected