wxListItemAttr* CustomVirtListCtrl<T,L>::HighlightItemUser( const wxString& name ) const { static wxListItemAttr att; if ( m_highlight && useractions().DoActionOnUser( m_highlightAction, name ) ) { att.SetBackgroundColour( useractions().GetGroupHLColor( useractions().GetGroupOfUser( name ) ) ); return &att; } else return NULL; }
void BattleroomListCtrl::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)) { wxString nick = GetSelectedUserNick(); useractions().AddGroup(name); useractions().AddUserToGroup(name, nick); ui().mw().ShowConfigure(MainWindow::OPT_PAGE_GROUPS); } }
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 customMessageBoxNoModal(SL_MAIN_ICON, _("couldn't add user"), _("Error")); } }
void GroupOptionsPanel::OnRemoveGroup( wxCommandEvent& /*unused*/ ) { if (m_current_group == _T("Default")) return; useractions().DeleteGroup( m_current_group ); ReloadGroupsList(); ShowGroup(wxEmptyString); }
void ServerEvents::OnUserQuit(const std::string& nick) { slLogDebugFunc(""); try { User& user = m_serv.GetUser(nick); IBattle* userbattle = user.GetBattle(); if (userbattle) { int battleid = userbattle->GetID(); try { if (&userbattle->GetFounder() == &user) { for (int i = 0; i < int(userbattle->GetNumUsers()); i++) { User& battleuser = userbattle->GetUser(i); OnUserLeftBattle(battleid, battleuser.GetNick()); } OnBattleClosed(battleid); } else OnUserLeftBattle(battleid, user.GetNick()); } catch (...) { } } ui().OnUserOffline(user); m_serv._RemoveUser(nick); if (useractions().DoActionOnUser(UserActions::ActNotifLogin, TowxString(nick))) actNotifBox(SL_MAIN_ICON, TowxString(nick) + _(" just went offline")); } catch (std::runtime_error& except) { } }
void GroupOptionsPanel::ReloadGroupsList() { wxArrayString groupnames = useractions().GetGroupNames(); m_group_list->Clear(); m_group_list->InsertItems(groupnames, 0); m_group_list->SetStringSelection(m_current_group); }
wxString GroupOptionsPanel::GetFirstGroupName() { wxSortedArrayString groupnames = useractions().GetGroupNames(); if (groupnames.Count() <= 0) return wxEmptyString; return groupnames[0]; }
void GroupOptionsPanel::ReloadUsersList() { wxArrayString groupuser = useractions().GetPeopleList(m_current_group); m_user_list->Clear(); m_user_list->Append(groupuser); m_remove_user_button->Enable(false); }
void GroupOptionsPanel::OnAddUsers( wxCommandEvent& /*unused*/ ) { wxSortedArrayString users = SelectUsersDialog::GetUsers(this); for ( unsigned int i = 0; i < users.Count(); i++ ) { useractions().AddUserToGroup( m_current_group, users[i] ); } if ( users.Count() > 0 ) ReloadUsersList(); }
void BattleroomListCtrl::OnUserMenuAddToGroup( wxCommandEvent& event ) { int id = event.GetId(); wxString groupname = m_popup->GetGroupByEvtID(id); wxString nick = GetSelectedUserNick(); useractions().AddUserToGroup( groupname, nick ); Disconnect( GROUP_ID_NEW, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( BattleroomListCtrl::OnUserMenuCreateGroup), 0, this ); }
void GroupOptionsPanel::OnHighlightColorClick(wxCommandEvent& event) { ColorButton* origin = (ColorButton*)event.GetEventObject(); wxColour c = GetColourFromUser(this, origin->GetColor()); if (c.IsOk()) { origin->SetColor(c); useractions().SetGroupColor(m_current_group, c); } }
void ServerEvents::OnChannelAction(const std::string& channel, const std::string& who, const std::string& action) { slLogDebugFunc(""); try { if ((m_serv.GetMe().GetNick() == who) || !useractions().DoActionOnUser(UserActions::ActIgnoreChat, TowxString(who))) m_serv.GetChannel(channel).DidAction(m_serv.GetUser(who), action); } catch (std::runtime_error& except) { } }
void ServerEvents::OnPrivateMessageEx(User& chan, User& who, const std::string& action) { slLogDebugFunc(""); try { if (!useractions().DoActionOnUser(UserActions::ActIgnorePM, TowxString(who.GetNick()))) ui().OnUserSaidEx(chan, who, TowxString(action)); } catch (std::runtime_error& except) { } }
void GroupOptionsPanel::OnGroupListSelectionChange( wxCommandEvent& /*unused*/ ) { wxString newgroup = m_group_list->GetStringSelection(); wxSortedArrayString groupnames = useractions().GetGroupNames(); if ( groupnames.Index(newgroup) == wxNOT_FOUND ) { return; } ShowGroup(newgroup); }
void GroupOptionsPanel::OnGroupActionsChange( wxCommandEvent& ) { useractions().ChangeAction( m_current_group, UserActions::ActNotifLogin, m_login_notify_check->GetValue() ); useractions().ChangeAction( m_current_group, UserActions::ActIgnoreChat, m_ignore_chat_check->GetValue() ); useractions().ChangeAction( m_current_group, UserActions::ActNotifBattle, m_notify_host_check->GetValue() ); useractions().ChangeAction( m_current_group, UserActions::ActIgnorePM, m_ignore_pm_check->GetValue() ); useractions().ChangeAction( m_current_group, UserActions::ActNotifStatus, m_notify_status_check->GetValue() ); useractions().ChangeAction( m_current_group, UserActions::ActAutokick, m_autokick_check->GetValue() ); useractions().ChangeAction( m_current_group, UserActions::ActAllowJuggler, m_allow_juggler_check->GetValue() ); useractions().ChangeAction( m_current_group, UserActions::ActHighlight, m_highlight_check->GetValue() ); }
void GroupOptionsPanel::OnRemoveUser( wxCommandEvent& /*unused*/ ) { wxArrayInt sel; int num = m_user_list->GetSelections( sel ); for ( int i = 0; i < num; i++ ) { wxString name = m_user_list->GetString(sel[i]); useractions().RemoveUser( name ); } ReloadUsersList(); }
void ChatPanelMenu::OnUserMenuAddToGroup(wxCommandEvent& event) { int id = event.GetId(); if (m_user_menu) { wxString groupname = m_user_menu->GetGroupByEvtID(id); const User* user = m_chatpanel->GetSelectedUser(); if (user) useractions().AddUserToGroup(groupname, TowxString(user->GetNick())); } }
void GroupOptionsPanel::OnAddNewGroup( wxCommandEvent& /*unused*/ ) { wxTextEntryDialog* ted = new wxTextEntryDialog(this, _("Name of new group:"), _("Add New Group")); if ( ted->ShowModal() == wxID_OK ) { wxString newgroup = ted->GetValue(); //!TODO: Check if group exists already. if ( newgroup != wxEmptyString ) useractions().AddGroup( newgroup ); ReloadGroupsList(); ShowGroup(newgroup); } delete ted; }
void SimpleServerEvents::OnChannelSaid( const wxString& channel, const wxString& who, const wxString& message ) { wxLogDebugFunc( _T("") ); try { if ( ( m_serv.GetMe().GetNick() == who ) || !useractions().DoActionOnUser( UserActions::ActIgnoreChat, who ) ) m_serv.GetChannel( channel ).Said( m_serv.GetUser( who ), message ); } catch (std::runtime_error &except) { } }
void ServerEvents::OnPrivateMessageEx( const wxString& user, const wxString& action, bool fromme ) { wxLogDebugFunc( _T("") ); try { User& who = m_serv.GetUser( user ); if (!useractions().DoActionOnUser( UserActions::ActIgnorePM, who.GetNick() ) ) ui().OnUserSaidEx( who, action, fromme ); } catch (std::runtime_error &except) { } }
void ServerEvents::OnSaidBattle( int battleid, const wxString& nick, const wxString& msg ) { try { Battle& battle = m_serv.GetBattle( battleid ); if ( ( m_serv.GetMe().GetNick() == nick ) || !useractions().DoActionOnUser( UserActions::ActIgnoreChat, nick ) ) { ui().OnSaidBattle( battle, nick, msg ); } battle.GetAutoHost().OnSaidBattle( nick, msg ); } catch (assert_exception) {} }
void ServerEvents::OnSaidBattle(int battleid, const std::string& nick, const std::string& msg) { try { IBattle& battle = m_serv.GetBattle(battleid); if ((m_serv.GetMe().GetNick() == nick) || !useractions().DoActionOnUser(UserActions::ActIgnoreChat, TowxString(nick))) { ui().OnSaidBattle(battle, TowxString(nick), TowxString(msg)); } AutoHost* ah = battle.GetAutoHost(); if (ah != NULL) { ah->OnSaidBattle(TowxString(nick), TowxString(msg)); } } catch (assert_exception) { } }
void GroupOptionsPanel::ShowGroup( const wxString& group ) { if ( group == wxEmptyString ) m_current_group = GetFirstGroupName(); else m_current_group = group; m_group_list->SetStringSelection(m_current_group); UserActions::ActionType act = useractions().GetGroupAction( m_current_group ); m_login_notify_check->SetValue( (act & UserActions::ActNotifLogin) != 0 ); m_ignore_chat_check->SetValue( (act & UserActions::ActIgnoreChat) != 0 ); m_notify_host_check->SetValue( (act & UserActions::ActNotifBattle) != 0 ); m_ignore_pm_check->SetValue( (act & UserActions::ActIgnorePM) != 0 ); m_notify_status_check->SetValue( (act & UserActions::ActNotifStatus) != 0 ); m_autokick_check->SetValue( (act & UserActions::ActAutokick) != 0 ); m_allow_juggler_check->SetValue( (act & UserActions::ActAllowJuggler) != 0 ); m_highlight_check->SetValue( (act & UserActions::ActHighlight) != 0 ); m_highlight_color_button->SetColor( useractions().GetGroupColor(m_current_group) ); ReloadUsersList(); m_remove_group_button->Enable( m_group_list->GetStringSelection() != wxEmptyString ); }
void ServerEvents::OnChannelSaid(const std::string& channel, const std::string& who, const std::string& message) { slLogDebugFunc(""); try { if ((m_serv.GetMe().GetNick() == who) || !useractions().DoActionOnUser(UserActions::ActIgnoreChat, TowxString(who))) { if (m_serv.UserExists(who)) { m_serv.GetChannel(channel).Said(m_serv.GetUser(who), message); } else { User u(who); m_serv.GetChannel(channel).Said(u, message); // offline message } } } catch (std::runtime_error& except) { } }
void ServerEvents::OnUserStatus( const wxString& nick, UserStatus status ) { wxLogDebugFunc( _T("") ); try { wxLogMessage( _T("calling m_serv.GetUser( nick ) ") ); User& user = m_serv.GetUser( nick ); wxLogMessage( _T("calling user.SetStatus( status ) ") ); UserStatus oldStatus = user.GetStatus(); user.SetStatus( status ); if ( useractions().DoActionOnUser( UserActions::ActNotifStatus, nick ) ) { wxString diffString = status.GetDiffString( oldStatus ) ; if ( diffString != wxEmptyString ) actNotifBox( SL_MAIN_ICON, nick + _(" is now ") + diffString ); } wxLogMessage( _T("calling ui().OnUserStatusChanged( user ) ") ); ui().OnUserStatusChanged( user ); wxLogMessage( _T("updating battles ") ); if ( user.GetBattle() != 0 ) { Battle& battle = *user.GetBattle(); try { if ( battle.GetFounder().GetNick() == user.GetNick() ) { if ( status.in_game != battle.GetInGame() ) { battle.SetInGame( status.in_game ); if ( status.in_game ) battle.StartSpring(); else BattleEvents::GetBattleEventSender( BattleEvents::BattleInfoUpdate ).SendEvent( std::make_pair(user.GetBattle(),wxString()) ); } } }catch(...){} } } catch (...) { wxLogWarning( _("OnUserStatus() failed ! (exception)") ); } }
void ServerEvents::OnNewUser( const wxString& nick, const wxString& country, int cpu, const wxString& id ) { wxLogDebugFunc( _T("") ); try { ASSERT_LOGIC( !m_serv.UserExists( nick ), _T("New user from server, but already exists!") ); } catch (...) { return; } User& user = m_serv._AddUser( nick ); if ( useractions().DoActionOnUser( UserActions::ActNotifLogin, nick ) ) actNotifBox( SL_MAIN_ICON, nick + _(" is online") ); user.SetCountry( country ); user.SetCpu( cpu ); user.SetID( id ); ui().OnUserOnline( user ); }
void ServerEvents::OnBattleOpened(int id, BattleType type, NatType nat, const std::string& nick, const std::string& host, int port, int maxplayers, bool haspass, int rank, const std::string& maphash, const std::string& engineName, const std::string& engineVersion, const std::string& map, const std::string& title, const std::string& mod) { slLogDebugFunc(""); try { ASSERT_EXCEPTION(!m_serv.BattleExists(id), _T("New battle from server, but already exists!")); IBattle& battle = m_serv._AddBattle(id); User& user = m_serv.GetUser(nick); battle.OnUserAdded(user); battle.SetBattleType(type); battle.SetNatType(nat); battle.SetFounder(nick); battle.SetHostIp(host); battle.SetHostPort(port); battle.SetMaxPlayers(maxplayers); battle.SetIsPassworded(haspass); battle.SetRankNeeded(rank); battle.SetHostMap(map, maphash); battle.SetDescription(title); battle.SetHostGame(mod, ""); battle.SetEngineName(engineName); battle.SetEngineVersion(engineVersion); if (useractions().DoActionOnUser(UserActions::ActNotifBattle, TowxString(user.GetNick()))) { actNotifBox(SL_MAIN_ICON, TowxString(user.GetNick()) + _(" opened battle ") + TowxString(title)); } if (!m_serv.IsOnline()) { //login info isn't complete yet return; } ui().OnBattleOpened(battle); if (user.Status().in_game) { battle.SetInGame(true); battle.StartSpring(); } } catch (std::runtime_error& except) { } }
void ServerEvents::OnNewUser(const std::string& nick, const std::string& country, int cpu, int id) { slLogDebugFunc(""); if (m_serv.UserExists(nick)) { wxLogWarning("New user from server, but already exists: %s", nick.c_str()); return; } User& user = m_serv._AddUser(nick); user.SetCountry(country); user.SetCpu(cpu); user.SetID(id); if (!m_serv.IsOnline()) { //login info isn't complete yet return; } ui().OnUserOnline(user); if (useractions().DoActionOnUser(UserActions::ActNotifLogin, TowxString(nick))) { actNotifBox(SL_MAIN_ICON, TowxString(nick) + _(" just connected")); } }
void ServerEvents::OnBattleOpened( int id, BattleType type, NatType nat, const wxString& nick, const wxString& host, int port, int maxplayers, bool haspass, int rank, const wxString& maphash, const wxString& map, const wxString& title, const wxString& mod ) { wxLogDebugFunc( _T("") ); try { ASSERT_EXCEPTION( !m_serv.BattleExists( id ), _T("New battle from server, but already exists!") ); Battle& battle = m_serv._AddBattle( id ); User& user = m_serv.GetUser( nick ); battle.OnUserAdded( user ); battle.SetBattleType( type ); battle.SetNatType( nat ); battle.SetFounder( nick ); battle.SetHostIp( host ); battle.SetHostPort( port ); battle.SetMaxPlayers( maxplayers ); battle.SetIsPassworded( haspass ); battle.SetRankNeeded( rank ); battle.SetHostMap( map, maphash ); battle.SetDescription( title ); battle.SetHostMod( mod, wxEmptyString ); if ( useractions().DoActionOnUser( UserActions::ActNotifBattle, user.GetNick() ) ) actNotifBox( SL_MAIN_ICON, user.GetNick() + _(" opened battle ") + title ); ui().OnBattleOpened( battle ); if ( user.Status().in_game ) { battle.SetInGame( true ); battle.StartSpring(); } } catch (std::runtime_error &except) { } }
void ServerEvents::OnUserStatus(const std::string& nick, UserStatus status) { slLogDebugFunc(""); try { User& user = m_serv.GetUser(nick); UserStatus oldStatus = user.GetStatus(); user.SetStatus(status); if (useractions().DoActionOnUser(UserActions::ActNotifStatus, TowxString(nick))) { wxString diffString = TowxString(status.GetDiffString(oldStatus)); if (diffString != wxEmptyString) actNotifBox(SL_MAIN_ICON, TowxString(nick) + _(" is now ") + diffString); } if (m_serv.IsOnline()) { //login info isn't complete yet ui().OnUserStatusChanged(user); } if (user.GetBattle() != 0) { IBattle& battle = *user.GetBattle(); try { if (battle.GetFounder().GetNick() == user.GetNick()) { if (status.in_game != battle.GetInGame()) { battle.SetInGame(status.in_game); if (m_serv.IsOnline()) { if (status.in_game) { battle.StartSpring(); } else { ui().OnBattleInfoUpdated(battle, wxEmptyString); } } } } } catch (...) { } } } catch (...) { wxLogWarning(_("OnUserStatus() failed ! (exception)")); } }