MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / CityView

Method CityView

game/ui/tileview/cityview.cpp:994–1613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

992}
993
994CityView::CityView(sp<GameState> state)
995 : CityTileView(*state->current_city->map, Vec3<int>{TILE_X_CITY, TILE_Y_CITY, TILE_Z_CITY},
996 Vec2<int>{STRAT_TILE_X, STRAT_TILE_Y}, TileViewMode::Isometric,
997 state->current_city->cityViewScreenCenter, *state),
998 baseForm(ui().getForm("city/city")), overlayTab(ui().getForm("city/overlay")),
999 updateSpeed(CityUpdateSpeed::Speed1), lastSpeed(CityUpdateSpeed::Pause), state(state),
1000 followVehicle(false), selectionState(CitySelectionState::Normal)
1001{
1002 weaponType.resize(3);
1003 weaponDisabled.resize(3, false);
1004 weaponAmmo.resize(3, -1);
1005
1006 overlayTab->setVisible(false);
1007 overlayTab->findControlTyped<GraphicButton>("BUTTON_CLOSE")
1008 ->addCallback(FormEventType::ButtonClick,
1009 [this](Event *) { setSelectionState(CitySelectionState::Normal); });
1010 baseForm->findControlTyped<RadioButton>("BUTTON_SPEED1")->setChecked(true);
1011 for (size_t i = 0; i < NUM_TABS; ++i)
1012 {
1013 sp<Form> f = baseForm->findControlTyped<Form>(format("SUBFORM_TAB_%d", i + 1));
1014 f->takesFocus = false;
1015 this->uiTabs.push_back(f);
1016 }
1017 setSelectedTab(this->state->current_city->cityViewPageIndex);
1018
1019 // Refresh base views
1020 resume();
1021
1022 for (size_t i = 0; i < this->uiTabs.size(); ++i)
1023 {
1024 this->baseForm->findControl(format("BUTTON_TAB_%d", i + 1))
1025 ->addCallback(FormEventType::ButtonClick,
1026 [this, i](Event *) { this->setSelectedTab(i); });
1027 }
1028 this->baseForm->findControl("BUTTON_FOLLOW_VEHICLE")
1029 ->addCallback(FormEventType::CheckBoxChange,
1030 [this](FormsEvent *e) {
1031 this->followVehicle =
1032 std::dynamic_pointer_cast<CheckBox>(e->forms().RaisedBy)->isChecked();
1033 });
1034 this->baseForm->findControl("BUTTON_TOGGLE_STRATMAP")
1035 ->addCallback(FormEventType::CheckBoxChange,
1036 [this](FormsEvent *e)
1037 {
1038 bool strategy =
1039 std::dynamic_pointer_cast<CheckBox>(e->forms().RaisedBy)->isChecked();
1040 this->setViewMode(strategy ? TileViewMode::Strategy
1041 : TileViewMode::Isometric);
1042 });
1043 this->baseForm->findControl("BUTTON_SPEED0")
1044 ->addCallback(FormEventType::CheckBoxSelected,
1045 [this](Event *) { this->updateSpeed = CityUpdateSpeed::Pause; });
1046 this->baseForm->findControl("BUTTON_SPEED1")
1047 ->addCallback(FormEventType::CheckBoxSelected,
1048 [this](Event *) { this->updateSpeed = CityUpdateSpeed::Speed1; });
1049 this->baseForm->findControl("BUTTON_SPEED2")
1050 ->addCallback(FormEventType::CheckBoxSelected,
1051 [this](Event *) { this->updateSpeed = CityUpdateSpeed::Speed2; });

Callers

nothing calls this directly

Calls 15

setSelectedTabMethod · 0.95
zoomLastEventMethod · 0.95
formatFunction · 0.85
addCallbackMethod · 0.80
findControlMethod · 0.80
isCheckedMethod · 0.80
setViewModeMethod · 0.80
stageQueueCommandMethod · 0.80
hasMessagesMethod · 0.80
getPlayerMethod · 0.80
setSelectedVehicleMethod · 0.80

Tested by

no test coverage detected