bool HousePalettePanel::SelectBrush(const Brush* whatbrush) { const HouseBrush* house_brush = dynamic_cast<const HouseBrush*>(whatbrush); const SpawnBrush* spawn_brush = dynamic_cast<const SpawnBrush*>(whatbrush); if(house_brush && map != nullptr) { for(HouseMap::iterator house_iter = map->houses.begin(); house_iter != map->houses.end(); ++house_iter) { if(house_iter->second->id == house_brush->getHouseID()) { for(uint32_t i = 0; i < town_choice->GetCount(); ++i) { Town* town = reinterpret_cast<Town*>(town_choice->GetClientData(i)); // If it's "No Town" (nullptr) select it, or if it has the same town ID as the house if(town == nullptr || town->getID() == house_iter->second->townid) { SelectTown(i); for(uint32_t j = 0; j < house_list->GetCount(); ++j) { if(house_iter->second->id == reinterpret_cast<House*>(house_list->GetClientData(j))->id) { SelectHouse(j); return true; } } return true; } } } } } else if(spawn_brush) { SelectExitBrush(); } return false; }
void HousePalettePanel::OnUpdate() { if(map == nullptr) return; int old_town_selection = town_choice->GetSelection(); town_choice->Clear(); house_list->Clear(); if(map->towns.count() != 0) { // Create choice control for(TownMap::iterator town_iter = map->towns.begin(); town_iter != map->towns.end(); ++town_iter) { town_choice->Append(wxstr(town_iter->second->getName()), town_iter->second); } town_choice->Append(wxT("No Town"), (void*)(nullptr)); if(old_town_selection <= 0) SelectTown(0); else if((size_t)old_town_selection <= town_choice->GetCount()) SelectTown(old_town_selection); else SelectTown(old_town_selection-1); house_list->Enable(true); } else { town_choice->Append(wxT("No Town"), (void*)(nullptr)); select_position_button->Enable(false); select_position_button->SetValue(false); house_brush_button->Enable(false); house_brush_button->SetValue(false); add_house_button->Enable(false); edit_house_button->Enable(false); remove_house_button->Enable(false); SelectTown(0); } }
void HousePalettePanel::OnTownChange(wxCommandEvent& event) { SelectTown(event.GetSelection()); gui.SelectBrush(); }