wxBitmap& IconsCollection::GetColourBmp(const LSL::lslColor& colour) { const wxString key = lslTowxColour(colour).GetAsString(wxC2S_HTML_SYNTAX).AfterFirst('#'); //Search needed colour in collection (cache) and return it if found std::map<wxString, wxBitmap>::iterator itor = m_playerColorBmps.find(key); if (itor != m_playerColorBmps.end()) { return itor->second; //Or add new colour to collection } else { m_playerColorBmps[key] = getColourIcon(lslTowxColour(colour)); return m_playerColorBmps[key]; } }
void test_lslTowxColour(const unsigned char red, const unsigned char green, const unsigned char blue, const unsigned char alpha) { const LSL::lslColor col(red, green, blue, alpha); wxColor wxcol = lslTowxColour(col); BOOST_CHECK(wxcol.Red() == red); BOOST_CHECK(wxcol.Green() == green); BOOST_CHECK(wxcol.Blue() == blue); BOOST_CHECK(wxcol.Alpha() == alpha); }
void SinglePlayerTab::OnColorButton(wxCommandEvent& /*unused*/) { User& u = m_battle.GetMe(); wxColour CurrentColour = lslTowxColour(u.BattleStatus().colour); CurrentColour = GetColourFromUser(this, CurrentColour); if (!CurrentColour.IsOk()) return; sett().SetBattleLastColour(CurrentColour); m_battle.ForceColour(u, wxColourTolsl(CurrentColour)); UpdateMinimap(); }
void BattleroomListCtrl::OnColourSelect(wxCommandEvent& /*unused*/) { slLogDebugFunc(""); wxColour CurrentColour = lslTowxColour(m_sel_user->BattleStatus().colour); CurrentColour = GetColourFromUser(this, CurrentColour); if (!CurrentColour.IsOk()) return; if (m_sel_user) m_battle->ForceColour(*m_sel_user, wxColourTolsl(CurrentColour)); }
void BattleRoomTab::OnColourSel(wxCommandEvent& /*unused*/) { if (!m_battle) return; if (!m_battle) return; User& u = m_battle->GetMe(); wxColour CurrentColour = lslTowxColour(u.BattleStatus().colour); CurrentColour = GetColourFromUser(this, CurrentColour); if (!CurrentColour.IsOk()) return; sett().SetBattleLastColour(CurrentColour); m_battle->ForceColour(u, wxColourTolsl(CurrentColour)); }
void BattleRoomTab::UpdateUser(User& user) { if (!m_battle) return; m_players->UpdateUser(user); m_minimap->UpdateMinimap(); UpdateStatsLabels(); if (&user != &m_battle->GetMe()) return; UserBattleStatus& bs = user.BattleStatus(); m_team_sel->SetSelection(bs.team); m_ally_sel->SetSelection(bs.ally); if (m_side_sel->GetCount() > 0) { m_side_sel->SetSelection(bs.side); } m_spec_chk->SetValue(bs.spectator); m_auto_unspec_chk->SetValue(m_battle->GetAutoUnspec()); m_ready_chk->SetValue(bs.ready); // Enable or disable widgets' sensitivity as appropriate. if (bs.spectator) { m_side_sel->Disable(); m_ally_sel->Disable(); m_team_sel->Disable(); if (m_battle->GetBattleType() != BT_Replay) { m_auto_unspec_chk->Enable(); m_ready_chk->Disable(); } else { m_ready_chk->Enable(); m_auto_unspec_chk->Disable(); } } else { // we are player m_side_sel->Enable(); m_ally_sel->Enable(); m_team_sel->Enable(); m_ready_chk->Enable(); m_auto_unspec_chk->Disable(); //disable and uncheck unspec as we are already a player m_auto_unspec_chk->SetValue(false); m_battle->SetAutoUnspec(false); } icons().SetColourIcon(user.BattleStatus().colour); m_color_sel->SetColor(lslTowxColour(user.BattleStatus().colour)); }
void BattleRoomTab::SetBattle(IBattle* battle) { m_battle = battle; m_team_sel->Enable(m_battle); m_ally_sel->Enable(m_battle); m_color_sel->Enable(m_battle); m_side_sel->Enable(m_battle); m_options_preset_sel->Enable(m_battle); m_minimap->Enable(m_battle); m_player_panel->Enable(m_battle); m_map_combo->Enable(m_battle); m_players->Enable(m_battle); m_leave_btn->Enable(m_battle); m_start_btn->Enable(m_battle); m_addbot_btn->Enable(m_battle); m_manage_players_btn->Enable(m_battle); m_save_btn->Enable(m_battle); m_delete_btn->Enable(m_battle); m_default_btn->Enable(m_battle); m_browse_map_btn->Enable(m_battle); m_ready_chk->Enable(m_battle); m_spec_chk->Enable(m_battle); m_lock_chk->Enable(m_battle); m_autolock_chk->Enable(m_battle); m_opts_list->Enable(m_battle); m_minimap->SetBattle(m_battle); m_players->SetBattle(m_battle); m_chat->SetBattle(m_battle); m_players->Clear(); if (m_battle) { RegenerateOptionsList(); m_options_preset_sel->SetStringSelection(sett().GetModDefaultPresetName(TowxString(m_battle->GetHostModName()))); m_color_sel->SetColor(lslTowxColour(m_battle->GetMe().BattleStatus().colour)); for (UserList::user_map_t::size_type i = 0; i < m_battle->GetNumUsers(); i++) { m_players->AddUser(m_battle->GetUser(i)); } if (!m_battle->IsFounderMe()) { m_options_preset_sel->Disable(); m_save_btn->Disable(); m_delete_btn->Disable(); m_default_btn->Disable(); m_manage_players_btn->Disable(); m_lock_chk->Disable(); m_autolock_chk->Disable(); } m_host_new_btn->Show(false); ReloadMaplist(); UpdateBattleInfo(wxString::Format(_T( "%d_mapname" ), LSL::Enum::PrivateOptions)); UpdateBattleInfo(); UpdateStatsLabels(); } else { m_host_new_btn->Show(true); } }