void SinglePlayerTab::OnModSelect(wxCommandEvent& /*unused*/) { unsigned int index = (unsigned int)m_mod_pick->GetCurrentSelection(); size_t num_bots = m_battle.GetNumBots(); SetMod(index); if (num_bots != m_battle.GetNumBots()) customMessageBoxModal(SL_MAIN_ICON, _("Incompatible bots have been removed after game selection changed."), _("Bots removed")); }
bool UserActions::IsKnown(const wxString& name, bool outputWarning) const { bool ret = m_knownUsers.Index(name) != -1; if (outputWarning) { customMessageBoxModal(SL_MAIN_ICON, _("To prevent logical inconsistencies, adding a user to more than one group is not allowed"), _("Cannot add user to group")); } return ret; }
void SinglePlayerTab::OnStart(wxCommandEvent& /*unused*/) { slLogDebugFunc("SP: "); if (ui().IsSpringRunning()) { wxLogWarning(_T("trying to start spring while another instance is running")); customMessageBoxModal(SL_MAIN_ICON, _("You cannot start a spring instance while another is already running"), _("Spring error"), wxICON_EXCLAMATION); return; } if (ValidSetup()) m_battle.StartSpring(); }
void BattleroomMMOptionsTab::OnSavePreset(wxCommandEvent& /*unused*/) { if (!m_battle) return; wxString presetname; if (!ui().AskText(_("Enter preset name"), _("Enter a name to save the current set of options\nIf a preset with the same name already exist, it will be overwritten"), presetname)) return; if (presetname.empty()) { customMessageBoxModal(SL_MAIN_ICON, _("Cannot save an options set without a name."), _("error"), wxICON_EXCLAMATION | wxOK); return; } m_battle->SaveOptionsPreset(STD_STRING(presetname)); }
void BattleroomMMOptionsTab::OnLoadPreset(wxCommandEvent& /*unused*/) { if (!m_battle) return; std::string presetname = STD_STRING(m_options_preset_sel->GetValue()); if (presetname.empty()) { customMessageBoxModal(SL_MAIN_ICON, _("Cannot load an options set without a name\nPlease select one from the list and try again."), _("error"), wxICON_EXCLAMATION | wxOK); return; } m_battle->LoadOptionsPreset(presetname); m_battle->SendHostInfo(IBattle::HI_Send_All_opts); OnReloadControls(); }
void ChatPanelMenu::OnUserMenuCreateGroup(wxCommandEvent& /*unused*/) { wxString name; if (ui().AskText(_("Enter name"), _("Please enter the name for the new group.\nAfter clicking ok you will be taken to adjust its settings."), name)) { const User* user = m_chatpanel->GetSelectedUser(); if (user) { useractions().AddGroup(name); useractions().AddUserToGroup(name, TowxString(user->GetNick())); ui().mw().ShowConfigure(MainWindow::OPT_PAGE_GROUPS); } else customMessageBoxModal(SL_MAIN_ICON, _("couldn't add user"), _("Error")); } }
void PlaybackDataView::DeletePlayback() { const StoredGame* storedGame = GetSelectedItem(); if (storedGame == nullptr) { return; } try { const int m_sel_replay_id = storedGame->id; if (!replaylist().DeletePlayback(m_sel_replay_id)) { wxString pn(storedGame->battle.GetPlayBackFilePath()); customMessageBoxModal(SL_MAIN_ICON, _("Could not delete Replay: ") + pn, _("Error")); } else { RemovePlayback(*storedGame); } } catch (std::runtime_error&) { //Do nothing } }
void ServerEvents::OnKickedFromBattle() { customMessageBoxModal(SL_MAIN_ICON, _("You were kicked from the battle!"), _("Kicked by Host")); }
bool ChatPanel::Say(const wxString& message) //FIXME: remove all parsing / tokenizing / ... to dedicated file { static const unsigned int flood_threshold = 5; slLogDebugFunc(""); wxStringTokenizer lines(message, _T('\n')); if (lines.CountTokens() > flood_threshold) { PasteDialog dl(this, wxString::Format(_("Are you sure you want to paste %d lines?"), lines.CountTokens())); switch (dl.ShowModal()) { case wxID_NO: return true; case PasteDialog::pasteButtonReturnCode: { wxString url = Paste2Pastebin(message); if (url != wxEmptyString && wxStringTokenizer(url, _T('\n')).CountTokens() <= flood_threshold) { Say(url); return true; } else { customMessageBoxModal(SL_MAIN_ICON, wxString::Format(_("Failed to post to %s"), _T("paste.springfiles.com"))); return false; } } default: break; } } while (lines.HasMoreTokens()) { wxString line = lines.GetNextToken(); wxLogDebug(_T( "line: %s" ), line.c_str()); if (line == "/help") { ui().ConsoleHelp(); return true; } if (line == "/channels") { ui().mw().ShowChannelChooser(); return true; } if (line == _T( "/ver" )) { //!this instance is not replaced with GetAppname for sake of help/debug online OutputLine(wxString::Format(_("You have %s."), GetSpringlobbyAgent()), sett().GetChatColorNormal()); return true; } if (line == _T( "/clear" )) { m_chatlog_text->SetValue(wxEmptyString); return true; } if (m_type == CPT_Channel) { if (m_channel == 0) { OutputError(_("You are not in channel or channel does not exist.")); return true; } if (line.StartsWith(_T( "/" ))) { if (m_channel->ExecuteSayCommand(STD_STRING(line))) return true; if (m_channel->GetServer().ExecuteSayCommand(STD_STRING(line))) return true; OutputError(wxString::Format(_("Command (%s) does not exist, use /help for a list of available commands."), line.c_str())); return true; } m_channel->Say(STD_STRING(line)); } else if (m_type == CPT_Battle) { if (m_battle == 0) { OutputError(_("You are not in battle or battle does not exist, use /help for a list of available commands.")); return true; } if (line.StartsWith(_T( "/" ))) { if (m_battle->ExecuteSayCommand(STD_STRING(line))) return true; if (m_battle->GetServer().ExecuteSayCommand(STD_STRING(line))) return true; OutputError(wxString::Format(_("Command (%s) does not exist, use /help for a list of available commands."), line.c_str())); return true; } m_battle->Say(STD_STRING(line)); } else if (m_type == CPT_User) { if (m_user == 0) { OutputError(_("User is offline.")); return true; } if (line.StartsWith(_T( "/" ))) { if (m_user->ExecuteSayCommand(STD_STRING(line))) return true; if (m_user->GetServer().ExecuteSayCommand(STD_STRING(line))) return true; OutputError(wxString::Format(_("Command (%s) does not exist, use /help for a list of available commands."), line.c_str())); return true; } m_user->Say(STD_STRING(line)); } else if (m_type == CPT_Server) { if (m_server == 0) { OutputError(_("Not connected to server")); return true; } if (line.StartsWith(_T( "/" ))) { if (m_server->ExecuteSayCommand(STD_STRING(line))) return true; OutputError(wxString::Format(_("Command (%s) does not exist, use /help for a list of available commands."), line.c_str())); return true; } m_server->SendCmd(STD_STRING(line), ""); OutputLine(_("Sent: \"") + line + _T("\""), sett().GetChatColorNormal()); } } return true; }