Пример #1
0
ChatPanel::ChatPanel(wxWindow* parent, IBattle* battle)
    : wxPanel(parent, -1)
    , m_show_nick_list(false)
    , m_votePanel(0)
    , m_nicklist(0)
    , m_chat_tabs(0)
    , m_channel(0)
    , m_server(0)
    , m_user(0)
    , m_battle(battle)
    , m_type(CPT_Battle)
    , m_popup_menu(NULL)
    , m_disable_append(false)
    , m_display_joinitem(true)
    , m_topic_set(false)
    , m_reactOnPromoteEvents(false)
{
	Init(_T("BATTLE"));
	SetBattle(battle);
}
Пример #2
0
BattleRoomTab::BattleRoomTab(wxWindow* parent, IBattle* battle)
    : wxScrolledWindow(parent, -1)
    , m_battle(battle)
    , m_BattleActionSink(this, &UiEvents::GetUiEventSender(UiEvents::OnBattleActionEvent))
{
	GetAui().manager->AddPane(this, wxLEFT, _T( "battleroomtab" ));

	// Create all widgets
	m_splitter = new wxSplitterWindow(this, -1, wxDefaultPosition, wxSize(100, 60));

	m_player_panel = new wxScrolledWindow(m_splitter, -1);
	m_player_panel->SetScrollRate(SCROLL_RATE, SCROLL_RATE);
	m_team_sel = new wxComboBox(m_player_panel, BROOM_TEAMSEL, _T( "1" ), wxDefaultPosition, wxSize(50, CONTROL_HEIGHT), team_choices);
	m_team_sel->SetToolTip(_("Players with the same team number share control of their units."));
	m_ally_sel = new wxComboBox(m_player_panel, BROOM_ALLYSEL, _T( "1" ), wxDefaultPosition, wxSize(50, CONTROL_HEIGHT), ally_choices);
	m_ally_sel->SetToolTip(_("Players with the same ally number work together to achieve victory."));
	m_color_sel = new ColorButton(m_player_panel, BROOM_COLOURSEL, wxColour(0, 0, 0), wxDefaultPosition, wxSize(-1, CONTROL_HEIGHT));
	m_color_sel->SetToolTip(_("Select a color to identify your units in-game"));
	m_side_sel = new wxBitmapComboBox(m_player_panel, BROOM_SIDESEL, wxEmptyString, wxDefaultPosition, wxSize(-1, CONTROL_HEIGHT), wxArrayString(), wxCB_READONLY);
	m_side_sel->SetToolTip(_("Select your faction"));
	m_spec_chk = new wxCheckBox(m_player_panel, BROOM_SPEC, _("Spectator"), wxDefaultPosition, wxSize(-1, CONTROL_HEIGHT));
	m_spec_chk->SetToolTip(_("Spectate (watch) the battle instead of playing"));
	m_auto_unspec_chk = new wxCheckBox(m_player_panel, BROOM_UNSPEC, _("Auto un-spectate"), wxDefaultPosition, wxSize(-1, CONTROL_HEIGHT));
	m_auto_unspec_chk->SetToolTip(_("automatically unspec when there's a free slot"));
	m_ready_chk = new wxCheckBox(m_player_panel, BROOM_IMREADY, _("I'm ready"), wxDefaultPosition, wxSize(-1, CONTROL_HEIGHT));
	m_ready_chk->SetToolTip(_("Click this if you are content with the battle settings."));

	m_team_lbl = new wxStaticText(m_player_panel, -1, _("Team"));
	m_ally_lbl = new wxStaticText(m_player_panel, -1, _("Ally"));
	m_color_lbl = new wxStaticText(m_player_panel, -1, _("Color"));
	m_side_lbl = new wxStaticText(m_player_panel, -1, _("Side"));

	m_ally_setup_lbl = new wxStaticText(m_player_panel, -1, _T("0"));
	m_specs_setup_lbl = new wxStaticText(m_player_panel, -1, _T("0"));
	m_players_setup_lbl = new wxStaticText(m_player_panel, -1, _T("0"));
	m_ok_count_lbl = new wxStaticText(m_player_panel, -1, _T("0"));

	m_map_combo = new wxComboBox(this, BROOM_MAP_SEL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY);

	m_minimap = new MapCtrl(this, 162, m_battle, true, true, false);
	m_minimap->SetToolTip(_("A preview of the selected map.  You can see the starting positions, or (if set) starting boxes."));

	m_browse_map_btn = new wxButton(this, BROOM_MAP_BROWSE, _("Map"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
	//m_browse_map_btn->SetSize( m_browse_map_btn->GetSize().GetWidth() * 2 , m_browse_map_btn->GetSize().GetHeight() ) ; // has 0 effect

	m_players = new BattleroomListCtrl(m_player_panel, m_battle, false, true);
	m_chat = new ChatPanel(m_splitter, m_battle);

	m_command_line = new wxStaticLine(this, -1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL);

	m_host_new_btn = new wxButton(this, BROOM_HOST_NEW, _("Host new"), wxDefaultPosition, wxDefaultSize);
	m_host_new_btn->SetToolTip(_("Host a new battle"));
	m_leave_btn = new wxButton(this, BROOM_LEAVE, _("Leave"), wxDefaultPosition, wxSize(-1, CONTROL_HEIGHT));
	m_leave_btn->SetToolTip(_("Leave the battle and return to the battle list"));
	m_start_btn = new wxButton(this, BROOM_START, _("Start"), wxDefaultPosition, wxSize(-1, CONTROL_HEIGHT));
	m_start_btn->SetToolTip(_("Start the battle"));

	m_manage_players_btn = new wxButton(this, BROOM_MANAGE_MENU, _("Player Management"), wxDefaultPosition, wxSize(-1, CONTROL_HEIGHT));
	m_manage_players_btn->SetToolTip(_("Various functions to make team games simplers to setup"));

	m_addbot_btn = new wxButton(this, BROOM_ADDBOT, _("Add Bot..."), wxDefaultPosition, wxSize(-1, CONTROL_HEIGHT));
	m_addbot_btn->SetToolTip(_("Add a computer-controlled player to the game"));
	m_autolock_chk = new wxCheckBox(this, BROOM_AUTOLOCK, _("Autolock on start"), wxDefaultPosition, wxSize(-1, CONTROL_HEIGHT));
	m_autolock_chk->SetToolTip(_("Automatically locks the battle when the game starts and unlock when it's finished."));
	m_autolock_chk->SetValue(sett().GetLastAutolockStatus());

	m_lock_chk = new wxCheckBox(this, BROOM_LOCK, _("Locked"), wxDefaultPosition, wxSize(-1, CONTROL_HEIGHT));
	m_lock_chk->SetToolTip(_("Prevent additional players from joining the battle"));

	m_manage_users_mnu = new wxMenu();

	m_autohost_mnu = new wxMenuItem(m_manage_users_mnu, BROOM_AUTOHOST, _("Autohost"), _("Toggle autohost mode.  This allows players to control your battle using commands like '!balance' and '!start'."), wxITEM_CHECK);
	m_manage_users_mnu->Append(m_autohost_mnu);
	m_autohost_mnu->Check(false);


	m_autopaste_mnu = new wxMenuItem(m_manage_users_mnu, BROOM_AUTOPASTE, _("AutoPaste Description"), _("Automatically paste battle's descriptoin when a new user joins"), wxITEM_CHECK);
	m_manage_users_mnu->Append(m_autopaste_mnu);
	m_autopaste_mnu->Check(sett().GetBattleLastAutoAnnounceDescription());
	m_autospec_mnu = new wxMenuItem(m_manage_users_mnu, BROOM_AUTOSPECT, _("AutoSpect"), _("Automatically spectate players that don't ready up or become synced within x seconds."), wxITEM_CHECK);
	m_manage_users_mnu->Append(m_autospec_mnu);
	m_autospec_mnu->Check(sett().GetBattleLastAutoSpectTime() > 0);
	m_autocontrol_mnu = new wxMenuItem(m_manage_users_mnu, BROOM_AUTOCONTROL, _("AutoControlBalance"), _("Automatically balance teams and allies and fix colors when all players are ready and synced"), wxITEM_CHECK);
	m_manage_users_mnu->Append(m_autocontrol_mnu);
	m_autocontrol_mnu->Check(sett().GetBattleLastAutoControlState());
	m_autostart_mnu = new wxMenuItem(m_manage_users_mnu, BROOM_AUTOSTART, _("AutoStart"), _("Automatically start the battle when all players are ready and synced"), wxITEM_CHECK);
	m_manage_users_mnu->Append(m_autostart_mnu);
	m_autostart_mnu->Check(sett().GetBattleLastAutoStartState());

	m_lock_balance_mnu = new wxMenuItem(m_manage_users_mnu, BROOM_LOCK_BALANCE, _("Lock Balance"), _("When activated, prevents anyone but the host to change team and ally"), wxITEM_CHECK);
	m_manage_users_mnu->Append(m_lock_balance_mnu);
	m_lock_balance_mnu->Check(false);

	wxMenu* ring_menu = new wxMenu;
	wxMenuItem* ring_unready = new wxMenuItem(ring_menu, BROOM_RING_UNREADY, _("Ring unready"), _("Rings all players that don't have ready status and aren't spectators"));
	ring_menu->Append(ring_unready);
	wxMenuItem* ring_unsynced = new wxMenuItem(ring_menu, BROOM_RING_UNSYNC, _("Ring unsynced"), _("Rings all players that don't have sync status and aren't spectators"));
	ring_menu->Append(ring_unsynced);
	wxMenuItem* ring_unready_unsynced = new wxMenuItem(ring_menu, BROOM_RING_UNREADY_UNSYNC, _("Ring unready and unsynced"), _("Rings all players that don't have sync status or don't have ready status and aren't spectators"));
	ring_menu->Append(ring_unready_unsynced);
	m_manage_users_mnu->Append(wxID_ANY, _("Ring ..."), ring_menu);

	wxMenu* spect_menu = new wxMenu;
	wxMenuItem* spect_unready = new wxMenuItem(spect_menu, BROOM_SPECT_UNREADY, _("Spect unready"), _("Force to spectate all players that don't have ready status"));
	spect_menu->Append(spect_unready);
	wxMenuItem* spect_unsynced = new wxMenuItem(spect_menu, BROOM_SPECT_UNSYNC, _("Spect unsynced"), _("Force to spectate all players that don't have sync status"));
	spect_menu->Append(spect_unsynced);
	wxMenuItem* spect_unready_unsynced = new wxMenuItem(spect_menu, BROOM_SPECT_UNREADY_UNSYNC, _("Force to spectate unready and unsynced"), _("Rings all players that don't have sync status or don't have ready status"));
	spect_menu->Append(spect_unready_unsynced);
	m_manage_users_mnu->Append(wxID_ANY, _("Force spectate ..."), spect_menu);

	wxMenuItem* m_balance_mnu = new wxMenuItem(m_manage_users_mnu, BROOM_BALANCE, _("Balance alliances"), _("Automatically balance players into two or more alliances"));
	m_manage_users_mnu->Append(m_balance_mnu);

	wxMenuItem* m_fix_colours_mnu = new wxMenuItem(m_manage_users_mnu, BROOM_FIXCOLOURS, _("Fix colours"), _("Make player colors unique"));
	m_manage_users_mnu->Append(m_fix_colours_mnu);

	wxMenuItem* m_fix_team_mnu = new wxMenuItem(m_manage_users_mnu, BROOM_FIXID, _("Balance teams"), _("Automatically balance players into control teams, by default none shares control"));
	m_manage_users_mnu->Append(m_fix_team_mnu);

	wxStaticBoxSizer* m_preset_sizer;
	m_preset_sizer = new wxStaticBoxSizer(new wxStaticBox(this, 0, _("Manage Presets")), wxVERTICAL);

	wxBoxSizer* m_preset_btns_sizer;
	m_preset_btns_sizer = new wxBoxSizer(wxHORIZONTAL);

	m_options_preset_sel = new wxComboBox(this, BROOM_PRESETSEL, wxEmptyString, wxDefaultPosition, wxDefaultSize, sett().GetPresetList(), wxCB_READONLY);
	m_options_preset_sel->SetToolTip(_("Load battle preset"));

	m_preset_sizer->Add(m_options_preset_sel, 0, wxEXPAND | wxALL);

	m_save_btn = new wxButton(this, BROOM_SAVEPRES, _("Save"), wxDefaultPosition, wxDefaultSize);
	m_save_btn->SetToolTip(_("Save a set of options."));

	m_preset_btns_sizer->Add(m_save_btn, 0, wxEXPAND);

	m_delete_btn = new wxButton(this, BROOM_DELETEPRES, _("Delete"), wxDefaultPosition, wxDefaultSize);
	m_delete_btn->SetToolTip(_("Delete a set of options."));

	m_preset_btns_sizer->Add(m_delete_btn, 0, wxEXPAND);

	m_default_btn = new wxButton(this, BROOM_SETDEFAULTPRES, _("Set default"), wxDefaultPosition, wxDefaultSize);
	m_default_btn->SetToolTip(_("Use the current set of options as game's default."));

	m_preset_btns_sizer->Add(m_default_btn, 0, wxEXPAND);

	m_preset_sizer->Add(m_preset_btns_sizer, 0, wxEXPAND);


	m_opts_list = new wxListCtrl(this, BROOM_OPTIONLIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT);
	//m_opts_list->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
	m_opts_list->SetFont(wxFont(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT));
	m_opts_list->SetToolTip(_("Activate an element to quickly change it"));

	m_opts_list->InsertColumn(0, _("Option"), wxLIST_FORMAT_LEFT, 160);
	m_opts_list->InsertColumn(1, _("Value"), wxLIST_FORMAT_LEFT, 140);

	// Create Sizers
	m_players_sizer = new wxBoxSizer(wxVERTICAL);
	m_player_sett_sizer = new wxBoxSizer(wxHORIZONTAL);
	wxBoxSizer* m_map_select_sizer = new wxBoxSizer(wxHORIZONTAL);
	m_info_sizer = new wxBoxSizer(wxVERTICAL);
	m_top_sizer = new wxBoxSizer(wxHORIZONTAL);
	m_buttons_sizer = new wxBoxSizer(wxHORIZONTAL);
	//m_info1_sizer = new wxBoxSizer( wxHORIZONTAL );
	m_main_sizer = new wxBoxSizer(wxVERTICAL);

	// Put widgets in place
	m_player_sett_sizer->Add(m_team_lbl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
	m_player_sett_sizer->Add(m_team_sel, 0, wxEXPAND | wxALL, 2);
	m_player_sett_sizer->Add(m_ally_lbl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
	m_player_sett_sizer->Add(m_ally_sel, 0, wxEXPAND | wxALL, 2);
	m_player_sett_sizer->Add(m_color_lbl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
	m_player_sett_sizer->Add(m_color_sel, 0, wxEXPAND | wxALL, 2);
	m_player_sett_sizer->Add(m_side_lbl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
	m_player_sett_sizer->Add(m_side_sel, 0, wxEXPAND | wxALL, 2);
	m_player_sett_sizer->Add(m_spec_chk, 0, wxEXPAND | wxALL, 2);
	m_player_sett_sizer->Add(m_auto_unspec_chk, 0, wxEXPAND | wxALL, 2);
	m_player_sett_sizer->Add(m_ready_chk, 0, wxEXPAND | wxALL, 2);
	m_player_sett_sizer->AddStretchSpacer();
	m_player_sett_sizer->Add((new wxGenericStaticBitmap(m_player_panel, wxID_ANY, icons().GetIcon(icons().ICON_SPECTATOR))), 0, (wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT) | wxALL, 2);
	m_player_sett_sizer->Add(m_specs_setup_lbl, 0, (wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT) | wxALL, 2);
	m_player_sett_sizer->Add((new wxGenericStaticBitmap(m_player_panel, wxID_ANY, icons().GetIcon(icons().ICON_PLAYER))), 0, (wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT) | wxALL, 2);
	m_player_sett_sizer->Add(m_players_setup_lbl, 0, (wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT) | wxALL, 2);
	m_player_sett_sizer->Add((new wxGenericStaticBitmap(m_player_panel, wxID_ANY, icons().GetIcon(icons().ICON_STARTED_GAME))), 0, (wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT) | wxALL, 2);
	m_player_sett_sizer->Add(m_ally_setup_lbl, 0, (wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT) | wxALL, 2);
	m_player_sett_sizer->Add((new wxGenericStaticBitmap(m_player_panel, wxID_ANY, icons().GetIcon(icons().ICON_NREADY))), 0, (wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT) | wxALL, 2);
	m_player_sett_sizer->Add(m_ok_count_lbl, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT, 2);

	m_players_sizer->Add(m_players, 1, wxEXPAND);
	m_players_sizer->Add(m_player_sett_sizer, 0, wxEXPAND);

	m_player_panel->SetSizer(m_players_sizer);

	SplitSizerHorizontally(sett().GetSplitBRoomHorizontally());

	//m_info1_sizer->Add( m_wind_lbl, 1, wxEXPAND );
	//m_info1_sizer->Add( m_size_lbl, 1, wxEXPAND );

	m_info_sizer->Add(m_minimap, 0, wxEXPAND);
	m_map_select_sizer->Add(m_map_combo, 0, wxALL | wxEXPAND, 2);
	m_map_select_sizer->Add(m_browse_map_btn, 0, wxALIGN_RIGHT | wxALL, 2);
	m_info_sizer->Add(m_map_select_sizer, 0, wxEXPAND | wxALL, 2);
	//m_info_sizer->Add( m_info1_sizer, 0, wxEXPAND );
	//m_info_sizer->Add( m_tidal_lbl, 0, wxEXPAND );
	m_info_sizer->Add(m_opts_list, 1, wxEXPAND | wxTOP, 4);
	m_info_sizer->Add(m_preset_sizer, 0, wxEXPAND, 4);


	m_top_sizer->Add(m_splitter, 1, wxEXPAND | wxALL, 2);
	m_top_sizer->Add(m_info_sizer, 0, wxEXPAND | wxALL, 2);

	m_buttons_sizer->AddStretchSpacer();
	m_buttons_sizer->Add(m_host_new_btn, 0, wxEXPAND | wxALL, 2);
	m_buttons_sizer->AddStretchSpacer();
	m_buttons_sizer->Add(m_leave_btn, 0, wxEXPAND | wxALL, 2);
	m_buttons_sizer->Add(m_addbot_btn, 0, wxEXPAND | wxALL, 2);
	m_buttons_sizer->Add(m_autolock_chk, 0, wxEXPAND | wxALL, 2);
	m_buttons_sizer->Add(m_lock_chk, 0, wxEXPAND | wxALL, 2);
	m_buttons_sizer->Add(m_manage_players_btn, 0, wxEXPAND | wxALL, 2);
	m_buttons_sizer->Add(m_start_btn, 0, wxEXPAND | wxALL, 2);

	m_main_sizer->Add(m_top_sizer, 1, wxEXPAND);
	m_main_sizer->Add(m_command_line, 0, wxEXPAND);
	m_main_sizer->Add(m_buttons_sizer, 0, wxEXPAND);

	m_splitter->SetMinimumPaneSize(240);

	SetBattle(battle);

	SetScrollRate(SCROLL_RATE, SCROLL_RATE);
	SetSizer(m_main_sizer);
	Layout();

	ConnectGlobalEvent(this, GlobalEvent::OnUnitsyncReloaded, wxObjectEventFunction(&BattleRoomTab::OnUnitsyncReloaded));
}
Пример #3
0
BattleMapTab::BattleMapTab(wxWindow* parent, IBattle* battle)
    : wxPanel(parent, -1)
    , m_battle(battle)
{
	GetAui().manager->AddPane(this, wxLEFT, _T( "battlemaptab" ));

	wxBoxSizer* m_main_sizer = new wxBoxSizer(wxHORIZONTAL);
	wxBoxSizer* m_map_sizer = new wxBoxSizer(wxVERTICAL);

	m_map_sizer->SetMinSize(wxSize(352, -1));
	m_minimap = new MapCtrl(this, 352, m_battle, true, true, false);

	m_minimap->SetMinSize(wxSize(352, 352));

	m_map_sizer->Add(m_minimap, 1, wxALL | wxEXPAND, 2);

	wxBoxSizer* m_selmap_sizer = new wxBoxSizer(wxHORIZONTAL);

	m_map_combo = new wxChoice(this, BMAP_MAP_SEL, wxDefaultPosition, wxDefaultSize);
	m_selmap_sizer->Add(m_map_combo, 1, wxALL, 2);

	m_browse_btn = new wxButton(this, BMAP_MAP_BROWSE, _("Select"), wxDefaultPosition, wxDefaultSize, 0);

	m_selmap_sizer->Add(m_browse_btn, 0, wxALL, 2);

	m_map_sizer->Add(m_selmap_sizer, 0, wxEXPAND, 5);

	m_main_sizer->Add(m_map_sizer, 1, wxEXPAND, 5);

	wxBoxSizer* m_opts_sizer = new wxBoxSizer(wxVERTICAL);

	//m_opts_sizer->SetMinSize(wxSize( 200,-1 ));
	m_map_opts_list = new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(150, 160), wxLC_NO_HEADER | wxLC_REPORT);
	m_map_opts_list->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
	m_map_opts_list->SetFont(wxFont(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT));

	wxListItem col;

	col.SetText(_("Option"));
	m_map_opts_list->InsertColumn(0, col);
	col.SetText(_("Value"));
	m_map_opts_list->InsertColumn(1, col);
	m_map_opts_list->SetColumnWidth(0, 90);
	m_map_opts_list->SetColumnWidth(1, 50);

	m_map_opts_list->InsertItem(0, _("Size"));
	m_map_opts_list->InsertItem(1, _("Windspeed"));
	m_map_opts_list->InsertItem(2, _("Tidal strength"));
	m_map_opts_list->InsertItem(3, _("Gravity"));
	m_map_opts_list->InsertItem(4, _("Extractor radius"));
	m_map_opts_list->InsertItem(5, _("Max metal"));

	m_opts_sizer->Add(m_map_opts_list, 0, wxALL, 2);


	wxString m_start_radiosChoices[] = {_("Fixed"), _("Random"), _("Choose in game"), _("Chose before game")};
	int m_start_radiosNChoices = sizeof(m_start_radiosChoices) / sizeof(wxString);
	//TODO these need to be tooltipped, no idea how yet
	m_start_radios = new wxRadioBox(this, BMAP_START_TYPE, _("Startpositions"), wxDefaultPosition, wxSize(150, -1), m_start_radiosNChoices, m_start_radiosChoices, 1, wxRA_SPECIFY_COLS);

	m_opts_sizer->Add(m_start_radios, 0, wxALL, 2);

	m_map_desc = new wxStaticText(this, -1, wxEmptyString);
	m_map_desc->Wrap(160);

	m_opts_sizer->Add(m_map_desc, 0, wxALL, 2);

	m_main_sizer->Add(m_opts_sizer, 0, wxEXPAND, 5);
	//m_main_sizer->AddStretchSpacer();
	SetSizer(m_main_sizer);

	SetBattle(battle);

	Layout();
	SUBSCRIBE_GLOBAL_EVENT(GlobalEventManager::OnUnitsyncReloaded, BattleMapTab::OnUnitsyncReloaded);
}
Пример #4
0
BattleroomListCtrl::BattleroomListCtrl( wxWindow* parent, IBattle* battle, bool readonly, bool showingame )
	: CustomVirtListCtrl< User *,BattleroomListCtrl>(parent, BRLIST_LIST, wxDefaultPosition, wxDefaultSize,
													 wxSUNKEN_BORDER | wxLC_REPORT | wxLC_SINGLE_SEL, _T("BattleroomListCtrl"),
													 3, &BattleroomListCtrl::CompareOneCrit,
													true /*highlight*/, UserActions::ActHighlight, !readonly /*periodic sort*/ ),
	m_battle(battle),
	m_popup(0),
    m_sel_user(0),
    m_sides(0),
    m_spec_item(0),
    m_handicap_item(0),
    m_ro(readonly),
	m_showingame(showingame),
	m_status_column_index(-1),
	m_ingame_column_index(-1),
	m_faction_column_index(-1),
	m_colour_column_index(-1),
	m_country_column_index(-1),
	m_rank_column_index(-1),
	m_nick_column_index(-1),
	m_team_column_index(-1),
	m_ally_column_index(-1),
	m_resourcebonus_column_index(-1)
{
	GetAui().manager->AddPane( this, wxLEFT, _T("battleroomlistctrl") );

	wxListItem col;

    const int hd = wxLIST_AUTOSIZE_USEHEADER;

#if defined(__WXMAC__)
/// on mac, autosize does not work at all
    const int widths[11] = {20,20,20,20,170,140,130,110,28,28,28}; //!TODO revise plox
#else
    const int widths[11] = {hd,hd,hd,hd,hd,hd,170,hd,hd,80,130};
#endif
	int count = 0;
    AddColumn( count, widths[count], _T("Status"), _T("Player/Bot") );
	m_status_column_index = count;
	count++;
	if ( m_showingame )
	{
        AddColumn( count, widths[count], _T("Ingame"), _T("Battleroom status") );
		m_ingame_column_index = count;
        count++;
    }

    AddColumn( count, widths[count], _T("Faction"), _T("Faction icon") );
	m_faction_column_index = count;
	count++;
    AddColumn( count, widths[count], _T("Colour"), _T("Teamcolour") );
	m_colour_column_index = count;
	count++;
    AddColumn( count, widths[count], _T("Country"), _T("Country") );
	m_country_column_index = count;
	count++;
    AddColumn( count, widths[count], _T("Rank"), _T("Rank") );
	m_rank_column_index = count;
	count++;
    AddColumn( count, widths[count], _("Nickname"), _T("Ingame name"));
	m_nick_column_index = count;
	count++;
    AddColumn( count, widths[count], _("Team"), _T("Team number") );
	m_team_column_index = count;
	count++;
    AddColumn( count, widths[count], _("Ally"), _T("Ally number") );
	m_ally_column_index = count;
	count++;
    AddColumn( count, widths[count], _("Resource Bonus"), _T("Resource Bonus") );
	m_resourcebonus_column_index = count;

    if ( m_sortorder.size() == 0 ) {
		m_sortorder[0].col = m_team_column_index;
        m_sortorder[0].direction = true;
		m_sortorder[1].col = m_ally_column_index;
        m_sortorder[1].direction = true;
		m_sortorder[2].col = m_nick_column_index;
        m_sortorder[2].direction = true;
    }

  	if ( !m_ro )
	{
		m_popup = new UserMenu(this, this);
		wxMenu* m_teams;
		m_teams = new wxMenu();

		for ( unsigned int i = 0; i < SPRING_MAX_TEAMS; i++ )
		{
			wxMenuItem* team = new wxMenuItem( m_teams, BRLIST_TEAM + i, wxFormat( _T("%d") ) % (i+1), wxEmptyString, wxITEM_NORMAL );
			m_teams->Append( team );
			Connect( BRLIST_TEAM + i, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( BattleroomListCtrl::OnTeamSelect ) );
		}
		m_popup->Append( -1, _("Team"), m_teams );

		wxMenu* m_allies = new wxMenu();
		for ( unsigned int i = 0; i < SPRING_MAX_ALLIES; i++ )
		{
			wxMenuItem* ally = new wxMenuItem( m_allies, BRLIST_ALLY + i, wxFormat( _T("%d") ) % (i+1), wxEmptyString, wxITEM_NORMAL );
			m_allies->Append( ally );
			Connect( BRLIST_ALLY + i, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( BattleroomListCtrl::OnAllySelect ) );
		}
		m_popup->Append( -1, _("Ally"), m_allies );

		m_sides = new wxMenu();
		SetBattle( battle );
		m_popup->Append( -1, _("Side"), m_sides );

		m_popup->AppendSeparator();

		wxMenuItem* m_colours = new wxMenuItem( m_popup, BRLIST_COLOUR, _("Set color"), wxEmptyString, wxITEM_NORMAL );
		m_popup->Append( m_colours );

		m_popup->AppendSeparator();

		m_handicap_item = new wxMenuItem( m_popup, BRLIST_HANDICAP, _("Set Resource Bonus"), wxEmptyString, wxITEM_NORMAL );
		m_popup->Append( m_handicap_item );

		m_popup->AppendSeparator();

		m_spec_item = new wxMenuItem( m_popup, BRLIST_SPEC, wxString( _("Spectator") ) , wxEmptyString, wxITEM_CHECK );
		m_popup->Append( m_spec_item );

		m_popup->AppendSeparator();

		wxMenuItem* kick = new wxMenuItem( m_popup, BRLIST_KICK, wxString( _("Kick") ) , wxEmptyString, wxITEM_NORMAL );
		m_popup->Append( kick );
		wxMenuItem* ring = new wxMenuItem( m_popup, BRLIST_RING, wxString( _("Ring") ) , wxEmptyString, wxITEM_NORMAL );
		m_popup->Append( ring );

	}
}
BattleroomMMOptionsTab<BattleType>::BattleroomMMOptionsTab(  BattleType* battle, wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
: wxScrolledWindow( parent, id, pos, size, style | wxHSCROLL ),m_battle(battle)
{
  GetAui().manager->AddPane( this, wxLEFT, _T("battleroommmoptionstab") );

	m_main_sizer = new wxBoxSizer( wxVERTICAL );

  wxStaticBoxSizer* m_preset_sizer;
  m_preset_sizer = new wxStaticBoxSizer( new wxStaticBox( this, -1, _("Manage Presets") ), wxHORIZONTAL );

  m_options_preset_sel = new wxComboBox( this, BOPTS_CHOSEPRES, _T(""), wxDefaultPosition, wxDefaultSize,  sett().GetPresetList(), wxCB_READONLY );
  m_options_preset_sel->SetToolTip(TE(_("Set name.")));

  m_preset_sizer->Add( m_options_preset_sel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );

  m_load_btn = new wxButton( this, BOPTS_LOADPRES, _("Load..."), wxDefaultPosition, wxDefaultSize, 0 );
  m_load_btn->SetToolTip( TE(_("Load a saved set of options.")) );

  m_preset_sizer->Add( m_load_btn, 0, wxALL, 5 );

  m_save_btn = new wxButton( this, BOPTS_SAVEPRES, _("Save..."), wxDefaultPosition, wxDefaultSize, 0 );
  m_save_btn->SetToolTip( TE(_("Save a set of options.")) );

  m_preset_sizer->Add( m_save_btn, 0, wxALL, 5 );

  m_delete_btn = new wxButton( this, BOPTS_DELETEPRES, _("Delete..."), wxDefaultPosition, wxDefaultSize, 0 );
  m_delete_btn->SetToolTip( TE(_("Delete a set of options.")) );

  m_preset_sizer->Add( m_delete_btn, 0, wxALL, 5 );

  m_default_btn = new wxButton( this, BOPTS_SETDEFAULTPRES, _("Set default..."), wxDefaultPosition, wxDefaultSize, 0 );
  m_default_btn->SetToolTip( TE(_("Use the current set of options as game's default.")) );

  m_preset_sizer->Add( m_default_btn, 0, wxALL, 5 );

  m_preset_sizer->Add( 0, 0, 1, wxEXPAND, 0 );

    m_map_mod_container = new wxBoxSizer( wxVERTICAL );

	m_mod_options_sizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Game Options") ), wxVERTICAL );
	m_mod_layout = new wxBoxSizer( wxVERTICAL);
	setupOptionsSizer(m_mod_layout,OptionsWrapper::ModOption);
	m_mod_options_sizer->Add( m_mod_layout, 1, wxEXPAND, 5 );

	m_map_options_sizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Map Options") ), wxVERTICAL );
	m_map_layout = new wxBoxSizer( wxVERTICAL);
	setupOptionsSizer(m_map_layout,OptionsWrapper::MapOption);
	m_map_options_sizer->Add( m_map_layout, 1, wxEXPAND, 5 );


    m_main_sizer->Add( m_preset_sizer, 0, wxALL|wxEXPAND, 5 );
	m_map_mod_container->Add( m_mod_options_sizer, 0, wxALL|wxEXPAND, 5 );
	m_map_mod_container->Add( m_map_options_sizer, 0, wxALL|wxEXPAND, 5 );
	m_main_sizer->Add( m_map_mod_container, 1, wxALL|wxEXPAND, 5 );


  //m_main_sizer->FitInside(this);

  SetBattle( battle );

    SetScrollRate( SCROLL_RATE, SCROLL_RATE );
	SetSizer( m_main_sizer );
	Layout();


}