//////////////////////////////////////////////// // ModeratorActionsWnd //////////////////////////////////////////////// ModeratorActionsWnd::ModeratorActionsWnd(GG::X w, GG::Y h) : CUIWnd(UserString("MODERATOR"), GG::X1, GG::Y1, w - 1, h - 1, GG::ONTOP | GG::INTERACTIVE | GG::DRAGABLE | GG::RESIZABLE | CLOSABLE | PINABLE ), m_actions_enabled(true), m_selected_action(MAS_NoAction), m_no_action_button(0), m_create_system_button(0), m_star_type_drop(0), m_create_planet_button(0), m_planet_type_drop(0), m_planet_size_drop(0), m_delete_object_button(0), m_set_owner_button(0), m_empire_drop(0), m_add_starlane_button(0), m_remove_starlane_button(0) { ClientUI* ui = ClientUI::GetClientUI(); GG::Flags<GG::GraphicStyle> style = GG::GRAPHIC_CENTER | GG::GRAPHIC_VCENTER | GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE; boost::filesystem::path button_texture_dir = ClientUI::ArtDir() / "icons" / "buttons"; // button for no action m_no_action_button = new CUIButton( GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "nomoderatoraction.png")), GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "nomoderatoraction_clicked.png")), GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "nomoderatoraction_mouseover.png"))); m_no_action_button->SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay")); m_no_action_button->SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>( new TextBrowseWnd(UserString("MOD_NONE"), UserString("MOD_NONE")))); AttachChild(m_no_action_button); GG::Connect(m_no_action_button->LeftClickedSignal, &ModeratorActionsWnd::NoActionClicked, this); // button for create system and droplist to select system type to create m_create_system_button = new CUIButton( GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addstar.png")), GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addstar_clicked.png")), GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addstar_mouseover.png"))); m_create_system_button->SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay")); m_create_system_button->SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>( new TextBrowseWnd(UserString("MOD_CREATE_SYSTEM"), UserString("MOD_CREATE_SYSTEM")))); AttachChild(m_create_system_button); GG::Connect(m_create_system_button->LeftClickedSignal, &ModeratorActionsWnd::CreateSystemClicked, this); m_star_type_drop = new CUIDropDownList(6); m_star_type_drop->Resize(GG::Pt(DROP_WIDTH, CONTROL_HEIGHT)); for (StarType star_type = STAR_BLUE; star_type != NUM_STAR_TYPES; star_type = StarType(star_type + 1)) { boost::shared_ptr<GG::Texture> disc_texture = ui->GetModuloTexture( ClientUI::ArtDir() / "stars", ClientUI::StarTypeFilePrefixes()[star_type], 0); GG::DropDownList::Row* row = new GG::DropDownList::Row(); GG::StaticGraphic* icon = new GG::StaticGraphic(disc_texture, style); icon->Resize(GG::Pt(CONTROL_WIDTH, CONTROL_HEIGHT)); row->push_back(icon); m_star_type_drop->Insert(row); } m_star_type_drop->Select(m_star_type_drop->begin()); // default select first type GG::Connect(m_star_type_drop->SelChangedSignal, &ModeratorActionsWnd::StarTypeSelected, this); // button for create planet and droplists to select planet type and size m_create_planet_button = new CUIButton( GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addplanet.png")), GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addplanet_clicked.png")), GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addplanet_mouseover.png"))); m_create_planet_button->SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay")); m_create_planet_button->SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>( new TextBrowseWnd(UserString("MOD_CREATE_PLANET"), UserString("MOD_CREATE_PLANET")))); AttachChild(m_create_planet_button); GG::Connect(m_create_planet_button->LeftClickedSignal, &ModeratorActionsWnd::CreatePlanetClicked, this); m_planet_type_drop = new CUIDropDownList(6); m_planet_type_drop->Resize(GG::Pt(DROP_WIDTH, CONTROL_HEIGHT)); for (PlanetType planet_type = PT_SWAMP; planet_type != NUM_PLANET_TYPES; planet_type = PlanetType(planet_type + 1)) { boost::shared_ptr<GG::Texture> texture = ClientUI::PlanetIcon(planet_type); GG::DropDownList::Row* row = new GG::DropDownList::Row(); GG::StaticGraphic* icon = new GG::StaticGraphic(texture, style); icon->Resize(GG::Pt(CONTROL_WIDTH, CONTROL_HEIGHT)); row->push_back(icon); m_planet_type_drop->Insert(row); } m_planet_type_drop->Select(m_planet_type_drop->begin()); // default select first type GG::Connect(m_planet_type_drop->SelChangedSignal, &ModeratorActionsWnd::PlanetTypeSelected, this); m_planet_size_drop = new CUIDropDownList(6); m_planet_size_drop->Resize(GG::Pt(DROP_WIDTH, CONTROL_HEIGHT)); for (PlanetSize planet_size = SZ_TINY; planet_size != NUM_PLANET_SIZES; planet_size = PlanetSize(planet_size + 1)) { boost::shared_ptr<GG::Texture> texture = ClientUI::PlanetSizeIcon(planet_size); GG::DropDownList::Row* row = new GG::DropDownList::Row(); GG::StaticGraphic* icon = new GG::StaticGraphic(texture, style); icon->Resize(GG::Pt(CONTROL_WIDTH, CONTROL_HEIGHT)); row->push_back(icon); m_planet_size_drop->Insert(row); } GG::DropDownList::iterator it = m_planet_size_drop->begin(); std::advance(it, 2); m_planet_size_drop->Select(it); // default select 3rd size (should be medium?) GG::Connect(m_planet_size_drop->SelChangedSignal, &ModeratorActionsWnd::PlanetSizeSelected, this); // button for destroying object m_delete_object_button = new CUIButton( GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "delete.png")), GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "delete_clicked.png")), GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "delete_mouseover.png"))); m_delete_object_button->SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay")); m_delete_object_button->SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>( new TextBrowseWnd(UserString("MOD_DESTROY"), UserString("MOD_DESTROY")))); AttachChild(m_delete_object_button); GG::Connect(m_delete_object_button->LeftClickedSignal, &ModeratorActionsWnd::DeleteObjectClicked, this); // button for setting owner m_set_owner_button = new CUIButton( GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "setowner.png")), GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "setowner_clicked.png")), GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "setowner_mouseover.png"))); m_set_owner_button->SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay")); m_set_owner_button->SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>( new TextBrowseWnd(UserString("MOD_SET_OWNER"), UserString("MOD_SET_OWNER")))); AttachChild(m_set_owner_button); GG::Connect(m_set_owner_button->LeftClickedSignal, &ModeratorActionsWnd::SetOwnerClicked, this); m_empire_drop = new CUIDropDownList(6); m_empire_drop->SetStyle(GG::LIST_NOSORT); // empires added later when gamestate info available GG::Connect(m_empire_drop->SelChangedSignal, &ModeratorActionsWnd::EmpireSelected, this); // button for creating starlane m_add_starlane_button = new CUIButton( GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addstarlane.png")), GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addstarlane_clicked.png")), GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addstarlane_mouseover.png"))); m_add_starlane_button->SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay")); m_add_starlane_button->SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>( new TextBrowseWnd(UserString("MOD_ADD_STARLANE"), UserString("MOD_ADD_STARLANE")))); AttachChild(m_add_starlane_button); GG::Connect(m_add_starlane_button->LeftClickedSignal,&ModeratorActionsWnd::AddStarlane, this); // button for removing starlane m_remove_starlane_button = new CUIButton( GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "removestarlane.png")), GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "removestarlane_clicked.png")), GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "removestarlane_mouseover.png"))); m_remove_starlane_button->SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay")); m_remove_starlane_button->SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>( new TextBrowseWnd(UserString("MOD_REMOVE_STARLANE"), UserString("MOD_REMOVE_STARLANE")))); AttachChild(m_remove_starlane_button); GG::Connect(m_remove_starlane_button->LeftClickedSignal,&ModeratorActionsWnd::RemoveStarlane, this); DoLayout(); }
PlanetType ModeratorActionsWnd::PlanetTypeFromIndex(std::size_t i) const { if (i == static_cast<std::size_t>(-1) || i >= NUM_PLANET_TYPES) return PT_SWAMP; return PlanetType(i); // assumes first enum and first index are value 0, and that items in list are in same order as enum values }
int main(int argc, char *argv[]) { int i, c, rc; char buffer[1000]; struct mtwist_state *mt; enum planet_type pt; int count = 1; int npc_mode = 0; int planet_mode = 0; int robot_mode = 0; int ship_mode = 0; int taunt_mode = 0; int warning_mode = 0; set_random_seed(&mt); while (1) { int option_index; c = getopt_long(argc, argv, "c:nprstw", long_options, &option_index); if (c < 0) { break; } switch (c) { case 'c': rc = sscanf(optarg, "%d", &count); if (rc != 1) count = 0; break; case 'n': npc_mode = 1; break; case 'p': planet_mode = 1; break; case 'r': robot_mode = 1; break; case 's': ship_mode = 1; break; case 't': taunt_mode = 1; break; case 'w': warning_mode = 1; break; default: fprintf(stderr, "%s: Unknown option.\n", argv[0]); usage(argv[0]); } } if (taunt_mode + planet_mode + warning_mode + npc_mode + robot_mode + ship_mode == 0) usage(argv[0]); for (i = 0; i < count; i++) { if (taunt_mode) { infinite_taunt(mt, buffer, sizeof(buffer) - 1); printf("%s\n", buffer); } if (planet_mode) { pt = PlanetType(mt); planet_description(mt, buffer, sizeof(buffer) - 1, 60, pt); printf("%s\n", buffer); } if (warning_mode) { cop_attack_warning(mt, buffer, sizeof(buffer) - 1, 50); printf("%s\n", buffer); } if (npc_mode) { character_name(mt, buffer, sizeof(buffer) - 1); printf("%s\n", buffer); } if (robot_mode) { robot_name(mt, buffer, sizeof(buffer) - 1); printf("%s\n", buffer); } if (ship_mode) { ship_name(mt, buffer, sizeof(buffer) - 1); printf("%s\n", buffer); } } free(mt); return 0; }