コード例 #1
0
void BattleroomMMOptionsTab<BattleType>::OnSpinCtrlDoubleChange(SlSpinDoubleEvent& event)
{
	if ( !m_battle ) return;
	SlSpinCtrlDouble<ThisType>* box = (SlSpinCtrlDouble<ThisType>*) event.GetEventObject();
	wxString key = (box->GetName()).AfterFirst(sep);
	long gameoption;
	box->GetName().BeforeFirst(sep).ToLong(&gameoption);
	if(m_battle->CustomBattleOptions().setSingleOption( key,wxFormat( _T("%f") ) % box->GetValue(), (OptionsWrapper::GameOption)gameoption ) )
	{
		if (m_battle->IsFounderMe())
		{
		  m_battle->SendHostInfo(  (wxString()<< gameoption) + wxsep + key );
		}
	}
}
コード例 #2
0
ファイル: playbacklistctrl.cpp プロジェクト: N0U/springlobby
wxString PlaybackListCtrl<PlaybackType>::GetItemText(long item, long column) const
{
    if ( m_data[item] == NULL )
        return wxEmptyString;

    const PlaybackType& replay = *m_data[item];
	wxString duration = wxFormat(_T("%02ld:%02ld:%02ld") )
									% (replay.duration / 3600)
									% ((replay.duration%3600)/60)
									% ((replay.duration%60)/60 ) ;

    switch ( column ) {
        case 0: return replay.date_string;
        case 1: return replay.battle.GetHostModName();
        case 2: return replay.battle.GetHostMapName();
		case 3: return wxFormat(_T("%d") ) % ( replay.battle.GetNumUsers() - replay.battle.GetSpectators() );
        case 4: return duration;
        case 5: return replay.SpringVersion;
		case 6: return wxFormat( _T("%d KB") ) % ( replay.size/1024 );
        case 7: return replay.Filename.AfterLast( wxFileName::GetPathSeparator() );

        default: return wxEmptyString;
    }
}
コード例 #3
0
void Battle::LoadMapDefaults( const wxString& mapname )
{
	CustomBattleOptions().setSingleOption( _T("startpostype"), sett().GetMapLastStartPosType( mapname ), OptionsWrapper::EngineOption );
	SendHostInfo( wxFormat( _T("%d_startpostype") ) % OptionsWrapper::EngineOption );

	for( unsigned int i = 0; i <= GetLastRectIdx(); ++i ) if ( GetStartRect( i ).IsOk() ) RemoveStartRect(i); // remove all rects
	SendHostInfo( IBattle::HI_StartRects );

	std::vector<Settings::SettStartBox> savedrects = sett().GetMapLastRectPreset( mapname );
	for ( std::vector<Settings::SettStartBox>::const_iterator itor = savedrects.begin(); itor != savedrects.end(); ++itor )
	{
		AddStartRect( itor->ally, itor->topx, itor->topy, itor->bottomx, itor->bottomy );
	}
	SendHostInfo( IBattle::HI_StartRects );
}
コード例 #4
0
void  PlaybackListFilter<PlaybackTabType>::SaveFilterValues()
{
    PlaybackListFilterValues filtervalues;
    filtervalues.duration = m_filter_duration_edit->GetValue() ;
    filtervalues.map = m_filter_map_edit->GetValue();
    filtervalues.map_show = m_filter_map_show->GetValue();
    filtervalues.map = m_filter_map_edit->GetValue();
    filtervalues.mod = m_filter_mod_edit->GetValue();
    filtervalues.mod_show = m_filter_mod_show->GetValue();
    filtervalues.player_mode = _GetButtonSign(m_filter_player_mode);
	filtervalues.player_num = wxFormat(_("%d") ) % m_filter_player_choice->GetSelection();
    filtervalues.duration_mode = _GetButtonSign(m_filter_duration_mode);
    filtervalues.filesize = m_filter_filesize_edit->GetValue();
    filtervalues.filesize_mode= _GetButtonSign(m_filter_filesize_mode);
    sett().SetReplayFilterValues(filtervalues);
}
コード例 #5
0
bool UpdaterClass::PostMinGW44( const wxString& newdir )
{
	wxString current = GetSpringLobbyVersion(false);
    long minor = std::numeric_limits<long>::max();
    bool convert_ok = current.AfterLast( '.' ).ToLong( &minor );
	wxLogMessage( (wxFormat( _T("Got minor rev %d") ) % minor ).c_str() );
    if ( minor > 43 || !convert_ok   ) //0.43 was the last build on old mingw
        return true; //all is well, we're already on a mingw4.4 build
    wxString base = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) + wxFileName::GetPathSeparator() ;

    //use special copydir to overwrite locked files
    bool success = CopyDirWithFilebackupRename( newdir + wxFileName::GetPathSeparator(), base  );
    if ( !success ) {
        wxLogError( _T("Full dir copy failed") );
    }
    return success;
}
コード例 #6
0
ファイル: addbotdialog.cpp プロジェクト: N0U/springlobby
wxString AddBotDialog::RefineAIName( const wxString& name )
{
  wxString ret = name;
  if ( !LSL::usync().VersionSupports( LSL::USYNC_GetSkirmishAI ) )
  {
		if ( ret.Find(_T('.')) != wxNOT_FOUND ) ret = ret.BeforeLast(_T('.'));
		if ( ret.Find(_T('/')) != wxNOT_FOUND ) ret = ret.AfterLast(_T('/'));
		if ( ret.Find(_T('\\')) != wxNOT_FOUND ) ret = ret.AfterLast(_T('\\'));
		if ( ret.Find(_T("LuaAI:")) != wxNOT_FOUND ) ret = ret.AfterFirst(_T(':'));
  }
  if ( m_ai->FindString( ret ) == wxNOT_FOUND ) return ret;
  wxString ret2;
  int i = 2;
  do {
	ret2 = ret + wxFormat( _T(" (%d)") ) % i;
    i++;
  } while ( m_ai->FindString( ret2 ) != wxNOT_FOUND );
  return ret2;
}
コード例 #7
0
void BattleroomMMOptionsTab<BattleType>::OnReloadControls(OptionsWrapper::GameOption flag)
{
	if ( !m_battle ) return;
	wxString pref = wxFormat( _T("%d%s") ) % flag % wxsep;

	//purgin existing keys from map
	RemovePrefixed(m_chkbox_map,pref);
	RemovePrefixed(m_spinctrl_map,pref);
	RemovePrefixed(m_textctrl_map,pref);
	RemovePrefixed(m_combox_map,pref);
	RemovePrefixed(m_statictext_map,pref);
	RemovePrefixed(m_button_map,pref);

	//reloading the controls
	switch (flag)
	{
		case OptionsWrapper::ModOption:
			m_mod_options_sizer->Remove(m_mod_layout);
			m_mod_layout = new wxBoxSizer( wxVERTICAL);
			setupOptionsSizer(m_mod_layout,OptionsWrapper::ModOption);
			//m_mod_options_sizer->Add( m_mod_options_sizer, 1, wxEXPAND, 5 );
			m_mod_options_sizer->Add( m_mod_layout, 1, wxALL|wxEXPAND, 5 );
			break;
		case OptionsWrapper::MapOption:
			m_map_options_sizer->Remove(m_map_layout);
			m_map_layout = new wxBoxSizer( wxVERTICAL);
			setupOptionsSizer(m_map_layout,OptionsWrapper::MapOption);
			m_map_options_sizer->Add( m_map_layout, 1, wxALL|wxEXPAND, 5 );
			break;
		default:
			break;
	}


	//this->SetSizer( m_main_sizer, true );
	m_main_sizer->FitInside(this);

	this->Layout();
    SetScrollbars( 10, 10, 62, 62 );
}
コード例 #8
0
ファイル: slbook.cpp プロジェクト: renemilk/springlobby
wxString SLNotebook::SavePerspective() {
  // Build list of panes/tabs
  wxString tabs;
  wxAuiPaneInfoArray& all_panes = m_mgr.GetAllPanes();
   const size_t pane_count = all_panes.GetCount();

   for (size_t i = 0; i < pane_count; ++i)
   {
     wxAuiPaneInfo& pane = all_panes.Item(i);
     if (pane.name == wxT("dummy"))
           continue;

       wxTabFrame* tabframe = (wxTabFrame*)pane.window;

	 if (!tabs.empty()) tabs += wxT("|");
	 tabs += pane.name;
	 tabs += wxT("=");

     // add tab id's
     size_t page_count = tabframe->m_tabs->GetPageCount();
	 for (size_t p = 0; p < page_count; ++p)
     {
        wxAuiNotebookPage& page = tabframe->m_tabs->GetPage(p);
        const size_t page_idx = m_tabs.GetIdxFromWindow(page.window);

		if (p) tabs += wxT(",");

		if ((int)page_idx == GetSelection()) tabs += wxT("*");
		else if ((int)p == tabframe->m_tabs->GetActivePage()) tabs += wxT("+");
		tabs += (wxFormat(wxT("%u") ) % page_idx).str();
     }
  }
  tabs += wxT("@");

  // Add frame perspective
  tabs += m_mgr.SavePerspective();

  return tabs;
}
コード例 #9
0
ファイル: spring.cpp プロジェクト: jgleesawn/springlobby
bool Spring::Run( IBattle& battle )
{
	std::string executable = SlPaths::GetSpringBinary(battle.GetEngineVersion());
	if ( !wxFile::Exists(TowxString(executable)) ) {
		executable = SlPaths::GetSpringBinary(SlPaths::GetCompatibleVersion(battle.GetEngineVersion())); //fallback, no exact version found, try fallback version
		if ( !wxFile::Exists(TowxString(executable)) ) {
			customMessageBoxNoModal( SL_MAIN_ICON, wxFormat(_T("The spring executable version '%s' was not found at the set location '%s', please re-check.")) % battle.GetEngineVersion() % executable, _T("Executable not found") );
			ui().mw().ShowConfigure( MainWindow::OPT_PAGE_SPRING );
			return false;
		}
	}

	wxArrayString params;

	const std::string demopath = battle.GetPlayBackFilePath();
	if (!demopath.empty()){
		params.push_back(TowxString(demopath));
		return LaunchEngine(executable, params);
	}

	const wxString scripttxt = TowxString(SlPaths::GetLobbyWriteDir()) + _T("script.txt");
	try {

		wxFile f( scripttxt, wxFile::write );
		battle.DisableHostStatusInProxyMode( true );
		f.Write( WriteScriptTxt(battle) );
		battle.DisableHostStatusInProxyMode( false );
		f.Close();
	} catch ( std::exception& e ) {
		wxLogError( wxString::Format( _T("Couldn't write %s, exception caught:\n %s"), scripttxt.c_str(), TowxString( e.what() ).c_str() ) );
		return false;
	} catch (...) {
		wxLogError( wxString::Format( _T("Couldn't write %s"), scripttxt.c_str()));
		return false;
	}

	params.push_back(scripttxt);
	return LaunchEngine(executable, params);
}
コード例 #10
0
void BattleroomMMOptionsTab<BattleType>::setupOptionsSizer( wxBoxSizer* parent_sizer, OptionsWrapper::GameOption optFlag )
{
		if ( !m_battle ) return;
    const SpringUnitSync::OptionMapSection& sections = m_battle->CustomBattleOptions().m_opts[optFlag].section_map;

    unsigned int num_options = 0;
    SpringUnitSync::OptionMapSectionConstIter it = sections.begin();
    for ( ; it != sections.end(); ++it )
    {
        wxStaticBoxSizer* section_sizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, it->second.name ), wxVERTICAL );
        //only add non-empty sizer
        if ( setupOptionsSectionSizer( it->second, section_sizer, optFlag ) ) {
            parent_sizer->Add( section_sizer, 0 , wxALL, section_sizer->GetChildren().size() > 0 ? 5 : 0 );
            num_options++;
        }
        else
            delete section_sizer;
    }

    //adds options with no asociated section
    mmOptionSection dummy;
    wxBoxSizer* section_sizer = new wxBoxSizer( wxVERTICAL );
    if ( setupOptionsSectionSizer( dummy, section_sizer, optFlag ) == 0 ) {
        if ( num_options == 0 ) {
			wxString name = wxFormat( _T("%d%sno_opts") ) %optFlag % wxsep;
            wxStaticText* none_found = new wxStaticText( this, wxID_ANY, _("no options available"),
                                            wxDefaultPosition, wxDefaultSize, 0, name  );
            m_statictext_map[name] = none_found;
            parent_sizer->Add( none_found, 0, wxALL, 3 );
        }
    }
    else {
        wxStaticBoxSizer* other_section = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("other") ), wxVERTICAL );
        other_section->Add( section_sizer, 0 , wxALL, section_sizer->GetChildren().size() > 0 ? 5 : 0 );
        parent_sizer->Add( other_section, 0 , wxALL, 0 );
    }

}
コード例 #11
0
void MapSelectDialog::OnMapSelected( wxCommandEvent& event )
{
	const wxString& mapname = event.GetString();

	wxLogDebugFunc( mapname );

	const LSL::UnitsyncMap* pMap = m_mapgrid->GetSelectedMap();
	if ( pMap == NULL) return;
	const LSL::UnitsyncMap& map = *pMap;

    m_map_name->SetLabel(TowxString(map.name + "\n\n" + map.info.description));

	// TODO: refactor, this is copied from battlemaptab.cpp
	m_map_opts_list->SetItem( 0, 1, wxFormat( _T("%dx%d") ) % (map.info.width/512) % (map.info.height/512) );
	m_map_opts_list->SetItem( 1, 1, wxFormat( _T("%d-%d") ) % map.info.minWind % map.info.maxWind );
	m_map_opts_list->SetItem( 2, 1, wxFormat( _T("%d") ) % map.info.tidalStrength );
	m_map_opts_list->SetItem( 3, 1, wxFormat( _T("%d") ) % map.info.gravity );
	m_map_opts_list->SetItem( 4, 1, wxFormat( _T("%d") ) % map.info.extractorRadius );
	m_map_opts_list->SetItem( 5, 1, wxFormat( _T("%.3f") ) % map.info.maxMetal );
	m_map_opts_list->SetItem( 6, 1, wxFormat( _T("%d") ) % map.info.positions.size() );
}
コード例 #12
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 );

	}
}
コード例 #13
0
wxString ChannelListctrl::GetInfo()
{
    int displayed = GetItemCount();
    int total = m_data.size();
	return wxFormat( _("Displaying %d out of %d channels") ) % displayed % total;
}
コード例 #14
0
ファイル: customdialogs.cpp プロジェクト: N0U/springlobby
TimedMessageBox::TimedMessageBox(int whichIcon ,wxWindow *parent, const wxString& message,
				 const wxString& caption ,
				 unsigned int delay,
				 long style, const wxPoint& pos )
	: wxDialog(parent,-1,caption,pos,wxDefaultSize,style|wxFRAME_FLOAT_ON_PARENT|wxDEFAULT_DIALOG_STYLE),
	  m_delay( delay ),
	  m_display_hits(0)
{
	wxIcon ico = getIcon(whichIcon);
	SetIcon(ico);

//******** copied from wxsource/generic/msgdlgg.cpp with small modifications***********************************************************


	topsizer = new wxBoxSizer( wxVERTICAL );

	wxBoxSizer *icon_text = new wxBoxSizer( wxHORIZONTAL );


	// 1) icon

	wxBitmap bitmap;
	switch ( style & wxICON_MASK ) {
	default:
		bitmap = wxArtProvider::GetIcon(wxART_INFORMATION, wxART_MESSAGE_BOX);
		break;

	case wxICON_ERROR:
		bitmap = wxArtProvider::GetIcon(wxART_ERROR, wxART_MESSAGE_BOX);
		break;

	case wxICON_INFORMATION:
		bitmap = wxArtProvider::GetIcon(wxART_INFORMATION, wxART_MESSAGE_BOX);
		break;

	case wxICON_WARNING:
		bitmap = wxArtProvider::GetIcon(wxART_WARNING, wxART_MESSAGE_BOX);
		break;

	case wxICON_QUESTION:
		bitmap = wxArtProvider::GetIcon(wxART_QUESTION, wxART_MESSAGE_BOX);
		break;
	}

	wxStaticBitmap *info_icon = new wxStaticBitmap(this, wxID_ANY, bitmap);
	icon_text->Add( info_icon, 0, wxCENTER );

	// 2) text
	icon_text->Add( CreateTextSizer( message ), 0, wxALIGN_TOP| wxLEFT, 10 );

	topsizer->Add( icon_text, 1, wxCENTER | wxLEFT|wxRIGHT|wxTOP, 10 );
	topsizer->Add(0,10);

	// 3) buttons
	int center_flag = wxEXPAND;
	if (style & wxYES_NO)
		center_flag = wxALIGN_CENTRE;
	sizerBtn = CreateButtonSizer(style & slButtonSizerFlags);
	if ( sizerBtn ) {
		topsizer->Add(sizerBtn, 0, center_flag | wxALL, 10 );
		sizerBtn->Show( false );
	}

	m_delay_sizer = new wxBoxSizer( wxHORIZONTAL);
	m_delay_notif = new wxStaticText( this, -1, wxFormat( _("Please standby %d seconds") ) % ( delay / 1000 ) );
	m_delay_sizer->Add( m_delay_notif, 0, center_flag | wxALL, 10 );
	topsizer-> Add( m_delay_sizer );


	SetAutoLayout( true );
	SetSizer( topsizer );

	topsizer->SetSizeHints( this );
	topsizer->Fit( this );
	/*
	wxSize size( GetSize() );
	if (size.x > size.y*3/2)
	{
	    size.x = size.y*3/2;
	    SetSize( size );
	}
	*/
	Centre( wxBOTH | wxCENTER_FRAME);

	wxWindowID delay_timerID = wxNewId();
	wxWindowID display_timerID = wxNewId();
	m_delay_timer.SetOwner( this, delay_timerID );
	m_display_timer.SetOwner( this, display_timerID );
	Connect( delay_timerID, wxEVT_TIMER, wxTimerEventHandler( TimedMessageBox::OnUnlock) );
	Connect( display_timerID, wxEVT_TIMER, wxTimerEventHandler( TimedMessageBox::OnUpdate ) );
	m_delay_timer.Start( m_delay, wxTIMER_ONE_SHOT );
	m_display_timer.Start( m_update_interval, wxTIMER_CONTINUOUS );
	/***************************************************************************************************/
}
コード例 #15
0
void tab_quality_video::updateControls(int what_to_update)
{
	if (what_to_update == UPDATE_ALL)
	{
		//the rest
		for (int i = 5; i < 7; i++) {
			ctrl_qa_Boxes[i]->SetValue(intSettings[QA_CBOX[i].key]);
		}

		for (int i = 0; i < ctrl_vo_Boxes_size; i++) {
			ctrl_vo_Boxes[i]->SetValue(intSettings[VO_CBOX[i].key]);
		}
	}

	if (what_to_update == UPDATE_VIDEO_MODE || what_to_update == UPDATE_ALL)
	{
		ctrl_x_res->SetValue(wxFormat( _("%d") ) % intSettings[RC_TEXT[0].key]);
		ctrl_y_res->SetValue(wxFormat( _("%d") ) % intSettings[RC_TEXT[1].key]);
	}
	if (what_to_update == UPDATE_QA_BOXES || what_to_update == UPDATE_ALL)
	{
		//option 7-9 are not on presets
		//skip 0 == shadows
		for (int i = 1; i < 9; i++) {
			ctrl_qa_Boxes[i]->SetValue(intSettings[QA_CBOX[i].key]);
		}
		for (int i = 10; i < ctrl_qa_Boxes_size; i++) {
			ctrl_qa_Boxes[i]->SetValue(intSettings[QA_CBOX[i].key]);
		}

		ctrl_shadows_CBox->SetValue( SHADOW_CHOICES[ intSettings[ QA_CBOX[0].key] +1 ] );

        m_enable_w4 = false;
		int waterOptIndex = 0;
		const int waterSetting = intSettings[WR_COMBOX[0].key];
		switch (waterSetting)
		{
			case 0:
			case 1: waterOptIndex = waterSetting; break;
			case 2: waterOptIndex = 3; break;
			case 3: waterOptIndex = 2; break;
			case 4: waterOptIndex = 4; m_enable_w4 = true; break;
		}
		ctrl_waterQ_CBox->SetValue(WR_COMBOX_CHOICES[waterOptIndex]);

		int useFSAA = intSettings[VO_SLI_EXT[0].key];
		int FSAALev = intSettings[VO_SLI[0].key];
		ctrl_fsaa_slider->SetValue((useFSAA == 1)? FSAALev: 0);

		switch (intSettings[VO_RBUT[0].key]) {
			case 16: { ctrl_z_radio1->SetValue(1); } break;
			case 24: { ctrl_z_radio2->SetValue(1); } break;
		}

	}
	if (what_to_update == UPDATE_W4_CONTROLS || what_to_update == UPDATE_ALL)
	{
        for ( unsigned int i = 0; i < m_w4_controls.size(); ++i )
        {
            wxControl* tmp  = m_w4_controls[i];
            tmp->Enable( m_enable_w4 );
            switch ( i )
            {
                case 0: case 1: case 2: case 3:
                    ( (wxCheckBox*)tmp )->SetValue( intSettings[W4_CONTROLS[i].key ] );
                    break;
                case 4:{
                        int val = intSettings[W4_CONTROLS[i].key ];
                        for ( unsigned int j = 0; j < sizeof(W4_TEXSIZE_CHOICES)/sizeof(W4_TEXSIZE_CHOICES[0]); ++j){
                            if ( W4_TEXSIZE_CHOICES[j] == towxString( val ) )
                            ( (wxComboBox*)tmp)->SetValue( W4_TEXSIZE_CHOICES[ j ] );
                        }
                    }
                    break;
                case 5:
                    ( (wxComboBox*)tmp)->SetValue( W4_REFRACTION_CHOICES[ intSettings[W4_CONTROLS[i].key ] ] );
                    break;
                case 6:
                    //doesn't work if catsed from wxControl like the others
                    double tmpval = double(floatSettings[W4_CONTROLS[i].key ]) ;
                    m_aniso_spin->SetValue(tmpval);
                    break;
            }
        }

	}


}
コード例 #16
0
ファイル: uiutils.cpp プロジェクト: Mailaender/springlobby
TimerMessageBox::~TimerMessageBox()
{
	wxTimeSpan diff = wxDateTime::Now().Subtract( *m_start );
	customMessageBoxNoModal( SL_MAIN_ICON, wxFormat( m_msg_format ) % diff.Format() );
	delete m_start;
}
コード例 #17
0
HostBattleDialog::HostBattleDialog( wxWindow* parent )
	: wxDialog( parent, -1, _( "Host new battle" ), wxDefaultPosition, wxSize( 410, 441 ), wxRESIZE_BORDER | wxDEFAULT_DIALOG_STYLE ),
	WindowHintsPickle ( _T("hostbattledialog"), this, wxSize( 410, 441 ) ),
    m_last_relayhost( sett().GetLastRelayedHost() )
{
//	this->SetSizeHints( GetSize(), wxDefaultSize );

	m_panel = new wxScrolledWindow( this );
//		m_panel ->SetSizeHints( GetSize(), wxDefaultSize );
	wxBoxSizer* all_sizer = new wxBoxSizer( wxVERTICAL );

	wxFlexGridSizer* topsizer = new wxFlexGridSizer( 2,  0, 10);
//	topsizer->AddGrowableCol( 1, 1 );

//	SetSizeHints( wxDefaultSize, wxDefaultSize );
	wxBoxSizer* m_main_sizer;
	m_main_sizer = new wxBoxSizer( wxVERTICAL );

	m_desc_lbl = new wxStaticText( m_panel, wxID_ANY, _( "Description" ), wxDefaultPosition, wxDefaultSize, 0 );
	m_desc_lbl->Wrap( -1 );
	topsizer->Add( m_desc_lbl, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 );

//    wxBoxSizer* desc_sizer = new wxBoxSizer( wxVERTICAL );
	m_desc_text = new wxTextCtrl( m_panel, wxID_ANY, sett().GetLastHostDescription(), wxDefaultPosition, wxDefaultSize, 0 );
	m_desc_text->SetToolTip( TE( _( "A short description of the game, this will show up in the battle list." ) ) );
	topsizer ->Add( m_desc_text, 1, wxALL | wxEXPAND, 5 );

	m_desc_check = new wxCheckBox( m_panel, wxID_ANY, _( "Autopaste description" ) );
	m_desc_check->SetValue( sett().GetBattleLastAutoAnnounceDescription() );
	m_desc_check->SetToolTip( TE( _( "Automatically write the battle description when a user joins." ) ) );

    topsizer->AddStretchSpacer();
	topsizer->Add( m_desc_check, 0, wxLEFT, 5 );
//	topsizer->Add( desc_sizer , 0, wxEXPAND | wxALL, 0 );

	m_mod_lbl = new wxStaticText( m_panel, wxID_ANY, _( "Game" ), wxDefaultPosition, wxDefaultSize, 0 );
	m_mod_lbl->Wrap( -1 );
	topsizer->Add( m_mod_lbl, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );

	wxArrayString m_mod_picChoices;
	wxBoxSizer* mod_choice_button_sizer = new wxBoxSizer( wxHORIZONTAL );
	m_mod_pic = new wxChoice( m_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_mod_picChoices, 0 );
	m_mod_pic->SetToolTip( TE( _( "Select the game to play." ) ) );
	mod_choice_button_sizer->Add( m_mod_pic, 0, wxALL , 5 );

    wxBitmap mp = charArr2wxBitmap( arrow_refresh_png, sizeof( arrow_refresh_png ) );
	m_refresh_btn = new wxBitmapButton( m_panel, BTN_REFRESH, mp );
	mod_choice_button_sizer->Add( m_refresh_btn, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 );

	topsizer->Add( mod_choice_button_sizer, 0,  wxEXPAND|wxALL ,1 );

	m_pwd_lbl = new wxStaticText( m_panel, wxID_ANY, _( "Password\n(no spaces)" ), wxDefaultPosition, wxDefaultSize, 0 );
	m_pwd_lbl->Wrap( -1 );
	topsizer->Add( m_pwd_lbl, 1, wxALL| wxALIGN_CENTER_VERTICAL, 5 );

	m_pwd_text = new wxTextCtrl( m_panel, wxID_ANY, sett().GetLastHostPassword(), wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD );
	m_pwd_text->SetToolTip( TE( _( "Password needed to join game. Keep empty for no password" ) ) );
	topsizer->Add( m_pwd_text, 1, wxALL| wxEXPAND, 5 );

	m_port_lbl = new wxStaticText( m_panel, wxID_ANY, _( "Port" ), wxDefaultPosition, wxDefaultSize, 0 );
	m_port_lbl->Wrap( -1 );
	topsizer->Add( m_port_lbl, 1, wxALL| wxALIGN_CENTER_VERTICAL, 5 );

	m_port_text = new wxTextCtrl( m_panel, wxID_ANY, wxFormat( _T( "%d" ) ) % sett().GetLastHostPort(), wxDefaultPosition, wxDefaultSize, 0 );
	m_port_text->SetToolTip( TE( _( "UDP port to host game on. Default is 8452." ) ) );
	topsizer->Add( m_port_text, 1, wxALL| wxEXPAND, 5 );

//	m_port_test_check = new wxCheckBox( m_panel, wxID_ANY, _("Test firewall"), wxDefaultPosition, wxDefaultSize, 0 );
//	m_port_test_check->SetValue( sett().GetTestHostPort() );
//	m_port_sizer->Add( m_port_test_check, 1, wxALL|wxEXPAND, 5 );



	m_relayed_host_check = new wxCheckBox( m_panel, CHK_USE_RELAY, _( "Use relayhost" ), wxDefaultPosition, wxDefaultSize, 0 );
	m_relayed_host_check->SetToolTip( TE( _( "host and control game on remote server, helps if you have trouble hosting" ) ) );
	m_relayed_host_pick = new wxButton( m_panel, PICK_RELAYHOST, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
	m_relayed_host_pick->SetLabel( m_last_relayhost.IsEmpty() ? _T("automatic") : m_last_relayhost );

	m_relayhost_list = new wxMenu();
	wxMenuItem* automatic_pick = new wxMenuItem( m_relayhost_list, AUTO_PICK_HOST, _("Chose automatically"), _("Randomly picks an available one"), wxITEM_RADIO );
	m_relayhost_list->Append( automatic_pick );
	automatic_pick->Check( m_last_relayhost.IsEmpty() );
	m_relayhost_list->AppendSeparator();
	wxMenuItem* manual_pick_relay = new wxMenuItem( m_relayhost_list, MANUAL_PICK_HOST, _("Manually enter the manager name"), _("You'll get prompted for the exact manager name"), wxITEM_RADIO );
	m_relayhost_list->Append( manual_pick_relay );
	m_relayhost_list->AppendSeparator();
	m_relayhost_array_list = serverSelector().GetServer().GetRelayHostList();
	for ( unsigned int i = 0; i < m_relayhost_array_list.GetCount(); i++ )
	{
		wxMenuItem* newitem = new wxMenuItem( m_relayhost_list, MANUAL_PICK_HOST + 1 + i, m_relayhost_array_list[i], _T("") , wxITEM_RADIO );
		m_relayhost_list->Append( newitem );
		newitem->Check( m_last_relayhost == m_relayhost_array_list[i] );
	}

	m_relayed_host_check->SetValue( sett().GetLastHostRelayedMode() );
	m_relayed_host_pick->Show( m_relayed_host_check->IsChecked() );

	topsizer->Add(  m_relayed_host_check, 1, wxALL | wxEXPAND, 5 );
	topsizer->Add(  m_relayed_host_pick, 0, wxALL | wxEXPAND, 5);

	m_main_sizer->Add( topsizer, 0, wxEXPAND, 0 );

	wxStaticBoxSizer* m_players_box;
	m_players_box = new wxStaticBoxSizer( new wxStaticBox( m_panel, -1, _( "Number of players" ) ), wxVERTICAL );

	m_players_box->SetMinSize( wxSize( -1, 60 ) );
	m_players_slide = new wxSlider( m_panel, wxID_ANY, sett().GetLastHostPlayerNum(), 2, SPRING_MAX_USERS, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS | wxSL_BOTH | wxSL_HORIZONTAL | wxSL_LABELS );
	m_players_slide->SetToolTip( TE( _( "The maximum number of players to allow in the battle." ) ) );
	m_players_box->Add( m_players_slide, 0, wxALL | wxEXPAND, 5 );

	m_main_sizer->Add( m_players_box, 0, wxALL | wxEXPAND, 5 );

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

	wxString m_nat_radiosChoices[] = { _( "None" ), _( "Hole punching" )/*, _("Fixed source ports")*/ };
	int m_nat_radiosNChoices = sizeof( m_nat_radiosChoices ) / sizeof( wxString );
	m_nat_radios = new wxRadioBox( m_panel, CHOSE_NAT, _( "NAT traversal" ), wxDefaultPosition, wxDefaultSize, m_nat_radiosNChoices, m_nat_radiosChoices, 1, wxRA_SPECIFY_COLS );
	m_nat_radios->SetSelection( sett().GetLastHostNATSetting() );

	//m_nat_radios->Enable( false );
	m_nat_radios->Enable( true );

	m_nat_radios->SetToolTip( TE( _( "NAT traversal to use." ) ) );

	m_pl_nat_sizer->Add( m_nat_radios, 1, wxALL | wxEXPAND, 5 );

	wxStaticBoxSizer* m_rank_box;
	m_rank_box = new wxStaticBoxSizer( new wxStaticBox( m_panel, -1, _( "Rank requirement" ) ), wxVERTICAL );
	wxArrayString rankFilterChoices;
	rankFilterChoices.Add(_("At least"));
	rankFilterChoices.Add(_("No greater than"));
	m_rank_direction = new wxChoice( m_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, rankFilterChoices, 0 );
	m_rank_direction->SetToolTip( TE( _( "Select the type of rank enforcement." ) ) );
	m_rank_box->Add(m_rank_direction);

	wxFlexGridSizer* m_rank_sizer;
	m_rank_sizer = new wxFlexGridSizer( 2, 6, 0, 0 );
	m_rank_sizer->SetFlexibleDirection( wxBOTH );

	m_rank0_radio = new wxRadioButton( m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
	m_rank_sizer->Add( m_rank0_radio, 0, wxALL, 5 );

	m_rank0_img = new wxStaticBitmap( m_panel, wxID_ANY, wxBitmap( rank0_xpm ), wxDefaultPosition, wxSize( 16, 16 ), 0 );
	m_rank_sizer->Add( m_rank0_img, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL, 5 );

	m_rank1_radio = new wxRadioButton( m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
	m_rank_sizer->Add( m_rank1_radio, 0, wxALL, 5 );

	m_rank1_img = new wxStaticBitmap( m_panel, wxID_ANY, wxBitmap( rank1_xpm ), wxDefaultPosition, wxSize( 16, 16 ), 0 );
	m_rank_sizer->Add( m_rank1_img, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL | wxALL, 2 );

	m_rank2_radio = new wxRadioButton( m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
	m_rank_sizer->Add( m_rank2_radio, 0, wxALL, 5 );

	m_rank2_img = new wxStaticBitmap( m_panel, wxID_ANY, wxBitmap( rank2_xpm ), wxDefaultPosition, wxSize( 16, 16 ), 0 );
	m_rank_sizer->Add( m_rank2_img, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL, 2 );

	m_rank3_radio = new wxRadioButton( m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
	m_rank_sizer->Add( m_rank3_radio, 0, wxALL, 5 );

	m_rank3_img = new wxStaticBitmap( m_panel, wxID_ANY, wxBitmap( rank3_xpm ), wxDefaultPosition, wxSize( 16, 16 ), 0 );
	m_rank_sizer->Add( m_rank3_img, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL, 2 );

	m_rank4_radio = new wxRadioButton( m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
	m_rank_sizer->Add( m_rank4_radio, 0, wxALL, 5 );

	m_rank4_img = new wxStaticBitmap( m_panel, wxID_ANY, wxBitmap( rank4_xpm ), wxDefaultPosition, wxSize( 16, 16 ), 0 );
	m_rank_sizer->Add( m_rank4_img, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL, 2 );

	m_rank5_radio = new wxRadioButton( m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
	m_rank_sizer->Add( m_rank5_radio, 0, wxALL, 5 );

	m_rank5_img = new wxStaticBitmap( m_panel, wxID_ANY, wxBitmap( rank5_xpm ), wxDefaultPosition, wxSize( 16, 16 ), 0 );
	m_rank_sizer->Add( m_rank5_img, 0, wxALL | wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL, 5 );

	m_rank6_radio = new wxRadioButton( m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
	m_rank_sizer->Add( m_rank6_radio, 0, wxALL, 5 );

	m_rank6_img = new wxStaticBitmap( m_panel, wxID_ANY, wxBitmap( rank6_xpm ), wxDefaultPosition, wxSize( 16, 16 ), 0 );
	m_rank_sizer->Add( m_rank6_img, 0, wxALL, 5 );

	m_rank7_radio = new wxRadioButton( m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
	m_rank_sizer->Add( m_rank7_radio, 0, wxALL, 5 );

	m_rank7_img = new wxStaticBitmap( m_panel, wxID_ANY, wxBitmap( rank7_xpm ), wxDefaultPosition, wxSize( 16, 16 ), 0 );
	m_rank_sizer->Add( m_rank7_img, 0, wxALL, 5 );

	m_rank_box->Add( m_rank_sizer, 1, wxEXPAND, 5 );

	m_pl_nat_sizer->Add( m_rank_box, 1, wxALL | wxEXPAND, 5 );

	m_main_sizer->Add( m_pl_nat_sizer, 0, wxEXPAND, 5 );
	m_main_sizer->Add( 0, 0, 1, wxEXPAND, 0 );

	m_buttons_sep = new wxStaticLine( m_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
	m_main_sizer->Add( m_buttons_sep, 0, wxALL | wxEXPAND, 2 );

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

	m_cancel_btn = new wxButton( m_panel, HOST_CANCEL, _( "Cancel" ), wxDefaultPosition, wxDefaultSize, 0 );
	m_buttons_sizer->Add( 0, 0, 1, wxEXPAND, 0 );
	m_buttons_sizer->Add( m_cancel_btn, 0, wxALL, 5 );

	m_host_btn = new wxButton( m_panel, HOST_OK, _( "Host" ), wxDefaultPosition, wxDefaultSize, 0 );
	m_host_btn->SetToolTip( TE( _( "Start hosting the battle." ) ) );

	m_buttons_sizer->Add( m_host_btn, 0, wxALL, 5 );

	m_main_sizer->Add( m_buttons_sizer, 0, wxEXPAND, 5 );

	m_panel->SetSizer( m_main_sizer );
	all_sizer->Add( m_panel, 1, wxEXPAND, 0 );
	this->SetSizer( all_sizer );
	m_panel->SetScrollRate( SCROLL_RATE, SCROLL_RATE );
	this->Layout();
	m_host_btn->SetFocus();

	ReloadModList();
}
コード例 #18
0
ファイル: platform.cpp プロジェクト: renemilk/springlobby
wxString IdentityString(const wxString& format, bool lowerCase )
{
	return wxFormat( format ) % TowxString(getSpringlobbyName(lowerCase));
}
コード例 #19
0
void BattleListTab::SetNumDisplayed()
{
	int num = m_battle_list->GetItemCount();
	m_battle_num->SetLabel( wxFormat( _( "%d battles displayed" ) ) % num );
}
コード例 #20
0
ファイル: battleroomtab.cpp プロジェクト: N0U/springlobby
void BattleRoomTab::OnUserJoined( User& user )
{
	if ( !m_battle ) return;
	if ( !user.BattleStatus().IsBot() ) m_chat->Joined( user );
	m_players->AddUser( user );

	UpdateUser(user);

	if ( &user == &m_battle->GetMe() )
	{
		m_players->SetSelectedIndex ( m_players->GetIndexFromData( &user ) );
	}
	UpdateStatsLabels();

	UiEvents::GetStatusEventSender( UiEvents::addStatusMessage ).SendEvent(UiEvents::StatusData( wxFormat(_("%s joined your active battle") ) % user.GetNick(), 1 ) );
}
コード例 #21
0
ファイル: battleroomtab.cpp プロジェクト: N0U/springlobby
void BattleRoomTab::UpdateStatsLabels()
{
	m_ok_count_lbl->SetLabel( wxFormat( _( "Unready: %d" ) ) % ( m_battle->GetNumActivePlayers() - m_battle->GetNumOkPlayers() ) );
	PrintAllySetup();
}
コード例 #22
0
ファイル: battleroomtab.cpp プロジェクト: N0U/springlobby
void BattleRoomTab::SetBattle(Battle* 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( m_battle->GetHostModName() ) );
		m_color_sel->SetColor( 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 ) );
			#ifdef __WXMAC__
			UpdateUser( m_battle->GetUser( i ) );
			#endif
		}

		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( wxFormat( _T( "%d_mapname" ) ) % LSL::OptionsWrapper::PrivateOptions );
		UpdateBattleInfo();
		UpdateStatsLabels();
	}
	else
	{
		m_host_new_btn->Show( true );
	}
}
コード例 #23
0
ファイル: battle.cpp プロジェクト: renemilk/springlobby
void Battle::FixTeamIDs( BalanceType balance_type, bool support_clans, bool strong_clans, int numcontrolteams )
{
    wxLogMessage(_T("Autobalancing teams, type=%d, clans=%d, strong_clans=%d, numcontrolteams=%d"),balance_type, support_clans, strong_clans, numcontrolteams);
    //size_t i;
    //int num_alliances;
    std::vector<ControlTeam> control_teams;

	if ( numcontrolteams == 0 || numcontrolteams == -1 ) numcontrolteams = GetNumUsers() - GetSpectators(); // 0 or -1 -> use num players, will use comshare only if no available team slots
    IBattle::StartType position_type = (IBattle::StartType)
            LSL::Util::FromString<long>(CustomBattleOptions().getSingleValue("startpostype", LSL::OptionsWrapper::EngineOption));
    if ( ( position_type == ST_Fixed ) || ( position_type == ST_Random ) ) // if fixed start pos type or random, use max teams = start pos count
    {
      try
      {
      	int mapposcount = LoadMap().info.positions.size();
        numcontrolteams = std::min( numcontrolteams, mapposcount );
      }
      catch( assert_exception ) {}
    }

    if ( numcontrolteams >= (int)( GetNumUsers() - GetSpectators() ) ) // autobalance behaves weird when trying to put one player per team and i CBA to fix it, so i'll reuse the old code :P
    {
      // apparently tasserver doesnt like when i fix/force ids of everyone.
      std::set<int> allteams;
      size_t numusers = GetNumUsers();
      for( size_t i = 0; i < numusers; ++i )
      {
        User &user = GetUser(i);
        if( !user.BattleStatus().spectator ) allteams.insert( user.BattleStatus().team );
      }
      std::set<int> teams;
      int t = 0;
      for( size_t i = 0; i < GetNumUsers(); ++i )
      {
        User &user = GetUser(i);
        if( !user.BattleStatus().spectator )
        {
          if( teams.count( user.BattleStatus().team ) )
          {
            while( allteams.count(t) || teams.count( t ) ) t++;
            ForceTeam( GetUser(i), t );
            teams.insert( t );
          }
          else
          {
            teams.insert( user.BattleStatus().team );
          }
        }
      }
      return;
    }
    for ( int i = 0; i < numcontrolteams; i++ ) control_teams.push_back( ControlTeam( i ) );

    wxLogMessage(_T("number of teams: %u"), control_teams.size() );

    std::vector<User*> players_sorted;
    players_sorted.reserve( GetNumUsers() );

    int player_team_counter = 0;

    for ( size_t i = 0; i < GetNumUsers(); ++i ) // don't count spectators
    {
        if ( !GetUser(i).BattleStatus().spectator )
        {
            players_sorted.push_back( &GetUser(i) );
            // -- server fail? it doesnt work right.
            //ForceTeam(GetUser(i),player_team_counter);
            player_team_counter++;
        }
    }

    shuffle( players_sorted );

    std::map<wxString, ControlTeam> clan_teams;
    if ( support_clans )
    {
        for ( size_t i = 0; i < players_sorted.size(); ++i )
        {
            wxString clan = TowxString(players_sorted[i]->GetClan());
            if ( !clan.empty() )
            {
                clan_teams[clan].AddPlayer( players_sorted[i] );
            }
        }
    };

    if ( balance_type != balance_random ) std::sort( players_sorted.begin(), players_sorted.end(), PlayerRankCompareFunction );

    if ( support_clans )
    {
        std::map<wxString, ControlTeam>::iterator clan_it = clan_teams.begin();
        while ( clan_it != clan_teams.end() )
        {
            ControlTeam &clan = (*clan_it).second;
            // if clan is too small (only 1 clan member in battle) or too big, dont count it as clan
            if ( ( clan.players.size() < 2 ) || ( !strong_clans && ( clan.players.size() >  ( ( players_sorted.size() + control_teams.size() -1 ) / control_teams.size() ) ) ) )
            {
                wxLogMessage(_T("removing clan %s"),(*clan_it).first.c_str());
                std::map<wxString, ControlTeam>::iterator next = clan_it;
                ++next;
                clan_teams.erase( clan_it );
                clan_it = next;
                continue;
            }
            wxLogMessage( _T("Inserting clan %s"), (*clan_it).first.c_str() );
            std::sort( control_teams.begin(), control_teams.end() );
            float lowestrank = control_teams[0].ranksum;
            int rnd_k = 1; // number of alliances with rank equal to lowestrank
            while ( size_t( rnd_k ) < control_teams.size() )
            {
                if ( fabs( control_teams[rnd_k].ranksum - lowestrank ) > 0.01 ) break;
                rnd_k++;
            }
            wxLogMessage(_T("number of lowestrank teams with same rank=%d"), rnd_k );
            control_teams[my_random( rnd_k )].AddTeam( clan );
            ++clan_it;
        }
    }

    for (size_t i = 0; i < players_sorted.size(); ++i )
    {
        // skip clanners, those have been added already.
        if ( clan_teams.count( TowxString(players_sorted[i]->GetClan()) ) > 0 )
        {
            wxLogMessage( _T("clanner already added, nick=%s"),players_sorted[i]->GetNick().c_str() );
            continue;
        }

        // find teams with lowest ranksum
        // insert current user into random one out of them
        // since performance doesnt matter here, i simply sort teams,
        // then find how many teams in beginning have lowest ranksum
        // note that balance player ranks range from 1 to 1.1 now
        // i.e. them are quasi equal
        // so we're essentially adding to teams with smallest number of players,
        // the one with smallest ranksum.

        std::sort( control_teams.begin(), control_teams.end() );
        float lowestrank = control_teams[0].ranksum;
        int rnd_k = 1; // number of alliances with rank equal to lowestrank
        while ( size_t( rnd_k ) < control_teams.size() )
        {
            if ( fabs ( control_teams[rnd_k].ranksum - lowestrank ) > 0.01 ) break;
            rnd_k++;
        }
        wxLogMessage( _T("number of lowestrank teams with same rank=%d"), rnd_k );
        control_teams[my_random( rnd_k )].AddPlayer( players_sorted[i] );
    }


    for ( size_t i=0; i < control_teams.size(); ++i )
    {
        for ( size_t j = 0; j < control_teams[i].players.size(); ++j )
        {
            ASSERT_LOGIC( control_teams[i].players[j], _T("fail in Autobalance teams, NULL player") );
			wxString msg = wxFormat( _T("setting player %s to team and ally %d") ) % control_teams[i].players[j]->GetNick() % i;
            wxLogMessage( _T("%s"), msg.c_str() );
            ForceTeam( *control_teams[i].players[j], control_teams[i].teamnum );
            ForceAlly( *control_teams[i].players[j], control_teams[i].teamnum );
        }
    }
}
コード例 #24
0
ファイル: customdialogs.cpp プロジェクト: N0U/springlobby
void TimedMessageBox::OnUpdate( wxTimerEvent&  )
{
	m_display_hits++;
	int remainder = ( m_delay - ( m_display_hits * m_update_interval ) ) / 1000;
	m_delay_notif->SetLabel( wxFormat( _("Please standby %d seconds") ) % remainder );
}
コード例 #25
0
void hotkey_parser::writeBindingsToFile( const key_binding& springbindings )
{
	const wxString newTmpFilename = wxFileName::CreateTempFileName( _T("uikeys."));
	wxTextFile newFile( newTmpFilename );

	//open new file for writing
	if ( ( !newFile.Exists() && !newFile.Create() ) || ( newFile.Exists() && !newFile.Open() ) )
	{
		throw HotkeyException( _("Error opening file for writing: ") + newTmpFilename );
	}

	//now read the old uikeys.txt line after line and copy all comments to the new file
	wxTextFile oldFile( this->m_filename );
	if ( !oldFile.Open() )
	{
        throw HotkeyException( _("Error opening file for reading: ") + m_filename );
	}

	for( size_t i = 0; i < oldFile.GetLineCount(); ++i )
	{
		wxString line = oldFile.GetLine( i );
		line.Trim();
		if ( line.StartsWith(wxT("//")) )
		{
			newFile.AddLine( line );
		}
	}
	oldFile.Close();

	//add keysyms
	//key_sym_map keySymRev;
	for( key_sym_map::const_iterator iter = springbindings.getKeySyms().begin(); iter != springbindings.getKeySyms().end(); ++iter )
	{
		newFile.AddLine( wxT("keysym\t\t") + iter->first + wxT("\t\t") + iter->second );
		//keySymRev[ KeynameConverter::convertHexValueToKey( iter->second ) ] = iter->first;
	}

	//add keysyms
	//key_sym_map keySymSetRev;
	for( key_sym_set_map::const_iterator iter = springbindings.getKeySymsSet().begin(); iter != springbindings.getKeySymsSet().end(); ++iter )
	{
		newFile.AddLine( wxT("keyset\t\t") + iter->first + wxT("\t\t") + springbindings.resolveKeySymKey(iter->second ) );
		//keySymSetRev[ iter->second ] = iter->first;
	}

	//add fakemeta
	if ( SpringDefaultProfile::getBindings().getMetaKey() != springbindings.getMetaKey() )
	{
		newFile.AddLine( wxT("fakemeta\t\t") + springbindings.getMetaKey() );
	}

	//check all default bindings if they still exist in current profile
	//do unbind if not
	const key_commands_sorted unbinds = (SpringDefaultProfile::getBindings() - springbindings).getBinds();
	for( key_commands_sorted::const_iterator iter = unbinds.begin(); iter != unbinds.end(); ++iter )
	{
		newFile.AddLine( wxT("unbind\t\t") + springbindings.resolveKeySymKeyAndSet( iter->first ) + wxT("\t\t") + iter->second );
	}

	//add binds, should be ordered
	const key_commands_sorted dobinds = (springbindings - SpringDefaultProfile::getBindings()).getBinds();
	for( key_commands_sorted::const_iterator iter = dobinds.begin(); iter != dobinds.end(); ++iter )
	{
		newFile.AddLine( wxT("bind\t\t") + springbindings.resolveKeySymKeyAndSet( iter->first ) + wxT("\t\t") + iter->second );
	}

	newFile.Write();

	const wxString prevFilenameBak = this->m_filename + wxT(".bak");

	//backup our current uikeys.txt
	{
		if ( wxRenameFile( this->m_filename, prevFilenameBak ) == false )
		{
            throw HotkeyException( (wxFormat(_("Error renaming %s to %s")) % m_filename % prevFilenameBak )  );
		}
	}

	//rename our new tmp file to uikeys.txt. restore backup if failed
	{
		if ( wxRenameFile( newTmpFilename, this->m_filename ) == false )
		{
			wxString msg = _("Error renaming uikeys.txt.tmp to uikeys.txt.");

			//restore backup
			if ( wxRenameFile( prevFilenameBak, this->m_filename ) == false )
			{
				msg += _(" Restoring backup failed also. Good luck!");
			}
			throw HotkeyException( msg );
		}
	}
}
コード例 #26
0
ファイル: platform.cpp プロジェクト: tizbac/springlobby
// ------------------------------------------------------------------------------------------------------------------------
///
/// Read out Host's CPU Speed
///
/// \return Sum of each CPU's Speed of this Computer
///
///
// ------------------------------------------------------------------------------------------------------------------------
wxString GetHostCPUSpeed()
{

    int cpu_count = 0;
    int max_cpu_speed=0;

#ifdef __WXMSW__

    //afaik there is no way to determine the number of sub keys for a given key
    //so i'll hardcode some value here and hope bd doesn't hit me with a stick :P
    for (int i = 0; i< 16; ++i)
    {
		wxRegKey programreg( _T("HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\")+	wxFormat(_T("%d") ) % i);
        long tmp;
        if ( programreg.QueryValue( _T("~MHz"), &tmp ) )
        {
            if ( max_cpu_speed < tmp ) max_cpu_speed = tmp;
            cpu_count++;
        }

    }

#else

    wxTextFile file( _T("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq") );
    if ( file.Exists() )
    {
      file.Open();
      wxString line = file.GetFirstLine();
      cpu_count++;
      int tmp = s2l( line );
      tmp /= 1000;
      if ( max_cpu_speed < tmp ) max_cpu_speed = tmp;
    }
    else {
      wxTextFile file( _T("/proc/cpuinfo") );
      if ( file.Exists() )
      {
        file.Open();
        for ( wxString line = file.GetFirstLine(); !file.Eof(); line = file.GetNextLine() )
        {
          if ( line.Left(7) == _T("cpu MHz") )
          {
            line = line.AfterLast( _T(' ') ).BeforeLast( _T('.') );
            cpu_count++;
            int tmp = s2l( line );
            if ( max_cpu_speed < tmp ) max_cpu_speed = tmp;
          }
        }
      }
    }
#endif
    return TowxString( LSL::Util::Clamp( max_cpu_speed,0,max_cpu_speed ) );
}
コード例 #27
0
void RunHostBattleDialog( wxWindow* parent )
{
	HostBattleDialog dlg( parent );
	if ( dlg.ShowModal() == wxID_OK )
	{
		BattleOptions bo;
		bo.description = sett().GetLastHostDescription();
		bo.port = sett().GetLastHostPort();
		bo.nattype = NatType( sett().GetLastHostNATSetting() );

		if ( bo.nattype == NAT_None && sett().GetTestHostPort() )
		{
			switch ( ui().TestHostPort( bo.port ) )
			{
				case Server::porttest_pass :
					break; // success
				case Server::porttest_pass_WX26 :
					wxLogWarning( _T( "hosting port %d: test aborted (wx26)" ), bo.port  );
					customMessageBoxNoModal( SL_MAIN_ICON, wxFormat( _( "Your using wxWidgets prior to version 2.8,\n "
											 "port testing is not supported.\n Hosting may or may not work." ) ) % bo.port );
					sett().SetTestHostPort( false ); // no need to have it checked anymore
					break;

				case Server::porttest_unreachable :
					wxLogWarning( _T( "hosting port %d: test undetermined" ), bo.port  );
					customMessageBoxNoModal( SL_MAIN_ICON, wxFormat( _( "The server used for testing your port %d "
											 "is unreachable. \nHosting may or may not work with this setting." ) ) % bo.port );
					break; //inconclusive test shouldn't hinder hosting imo (koshi)

				case Server::porttest_timeout :
				case Server::porttest_socketNotOk :
				case Server::porttest_socketError :
					wxLogWarning( _T( "hosting port %d: test unsuccessful, closing battle" ), bo.port  );
					customMessageBoxNoModal( SL_MAIN_ICON, wxFormat( _( "Battle not started because the port you selected (%d) "
											 "is unable to-f /home/kosh/.springlobby/testing.conf recieve incoming packets\n checks your router & firewall configuration again or change port "
											 "in the dialog.\n\nIf everything else fails, enable the Hole Punching NAT Traversal\n "
											 "option in the hosting settings." ) ) % bo.port );
					return;
				default:
					wxLogWarning( _T( "unknonw port forward test result" ) );
					break;

			}
			if ( !ui().TestHostPort( bo.port ) )
			{
				wxLogWarning( _T( "hosting port %d: test unsuccessful, closing battle" ), bo.port  );
				customMessageBoxNoModal( SL_MAIN_ICON, wxFormat( _( "Battle not started because the port you selected (%d) "
										"is unable to recieve incoming packets\n checks your router & firewall configuration "
										"again or change port in the dialog.\n\nIf everything else fails, enable the Hole "
										"Punching NAT Traversal\n option in the hosting settings." ) ) % bo.port );
				return;
			}
		}

		// Get selected mod from unitsync.
		LSL::UnitsyncMod mod;
		try
		{
            mod = LSL::usync().GetMod(STD_STRING(sett().GetLastHostMod()));
            bo.modhash = TowxString(mod.hash);
            bo.modname = TowxString(mod.name);
		}
		catch ( ... )
		{
			wxLogWarning( _T( "can't host: game not found" ) );
			customMessageBoxNoModal( SL_MAIN_ICON, _( "Battle not started beacuse the game you selected could not be found. " ), _( "Error starting battle." ), wxOK );
			return;
		}

		LSL::UnitsyncMap map;
        const auto mname = STD_STRING(sett().GetLastHostMap());
		try {
			if ( LSL::usync().MapExists( mname ) )
				map = LSL::usync().GetMap( mname );
			else if ( LSL::usync().GetNumMaps() <= 0 )
			{
				wxLogWarning( _T( "no maps found" ) );
				customMessageBoxNoModal( SL_MAIN_ICON, _( "Couldn't find any maps in your spring installation. This could happen when you set the Spring settings incorrectly." ), _( "No maps found" ), wxOK );
				return;
			}
			else
			{
				map = LSL::usync().GetMap( 0 );
			}
		}
		catch ( ... )
		{
			wxLogWarning( _T( "no maps found" ) );
			customMessageBoxNoModal( SL_MAIN_ICON, _( "Couldn't find any maps in your spring installation. This could happen when you set the Spring settings incorrectly." ), _( "No maps found" ), wxOK );
			return;
		}
        bo.maphash = TowxString(map.hash);
        bo.mapname = TowxString(map.name);

		bo.rankneeded = sett().GetLastRankLimit();

		bo.maxplayers = sett().GetLastHostPlayerNum();
		bo.userelayhost = sett().GetLastHostRelayedMode();
		if ( bo.userelayhost ) bo.nattype = NAT_None;
		bo.relayhost = sett().GetLastRelayedHost();
		bo.engineName = _T("spring");
		bo.engineVersion = TowxString(LSL::usync().GetSpringVersion());

		serverSelector().GetServer().HostBattle( bo, sett().GetLastHostPassword() );
	}
}
コード例 #28
0
ファイル: platform.cpp プロジェクト: tizbac/springlobby
wxString IdentityString(const wxString& format, bool lowerCase )
{
	return wxFormat( format ) %  GetAppName( lowerCase ) ;
}
コード例 #29
0
int BattleroomMMOptionsTab<BattleType>::setupOptionsSectionSizer(const mmOptionSection& section,
    wxBoxSizer* parent_sizer, OptionsWrapper::GameOption optFlag)
{
	if ( !m_battle ) return -1;
    const int col_gap = 35;
	wxString pref = wxFormat( _T("%d%s") ) % optFlag % wxsep;
	OptionsWrapper optWrap = m_battle->CustomBattleOptions();
	bool enable = m_battle->IsFounderMe();
	wxFlexGridSizer* cbxSizer =  new wxFlexGridSizer( 4, 2, 10, 10 );
	wxFlexGridSizer* spinSizer =  new wxFlexGridSizer( 4, 10, 10 );
	wxFlexGridSizer* textSizer =  new wxFlexGridSizer( 4, 10, 10 );
	wxFlexGridSizer* chkSizer = new wxFlexGridSizer( 4, 10, 10 );

    const int b_gap = 1;

    int total_count = 0;
	int ctrl_count = 0;
	for (SpringUnitSync::OptionMapBoolIter i = optWrap.m_opts[optFlag].bool_map.begin(); i != optWrap.m_opts[optFlag].bool_map.end();++i)
    {
        if ( i->second.section == section.key )
        {
			mmOptionBool current = i->second;
			wxCheckBox* temp = new wxCheckBox(this,BOOL_START_ID+ctrl_count,current.name);
			temp->SetToolTip(TE(current.description));
			m_name_info_map[pref+current.key] = current.description;
			temp->SetName(pref+current.key);
			m_chkbox_map[pref+current.key] = temp;
			temp->SetValue(current.value);
			temp->Enable(enable);
			wxBoxSizer* ct_sizer = new wxBoxSizer( wxHORIZONTAL );
			ct_sizer->Add(temp, 0, wxRIGHT| wxALIGN_CENTER_VERTICAL, b_gap);
			ct_sizer->Add(getButton(BOOL_START_ID+ctrl_count,pref+current.key), 0, wxRIGHT| wxALIGN_CENTER_VERTICAL, col_gap);
			chkSizer->Add( ct_sizer );
			ctrl_count++;
        }
	}

    total_count += ctrl_count;
	ctrl_count = 0;
	for ( SpringUnitSync::OptionMapFloatIter it = optWrap.m_opts[optFlag].float_map.begin(); it != optWrap.m_opts[optFlag].float_map.end(); ++it)
	{
	    wxString seckey = it->second.section;
	    wxString kkey = section.key ;
        if ( it->second.section == section.key )
        {
			mmOptionFloat current = it->second;
			SlSpinCtrlDouble<ThisType>* tempspin = new SlSpinCtrlDouble<ThisType>();
			tempspin->Create(this, FLOAT_START_ID+ctrl_count, _T(""),
					wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, double(current.min), double(current.max),
					double(current.value),double(current.stepping), current.key);
            tempspin->SetSnapToTicks( true );
			tempspin->SetToolTip(TE(current.description));
			m_name_info_map[pref+current.key] = current.description;
			tempspin->Enable(enable);
			tempspin->SetName(pref+current.key);
			m_spinctrl_map[pref+current.key] = tempspin;
			 wxStaticText* tempst = new wxStaticText(this,-1,current.name);
			 m_statictext_map[pref+current.key] = tempst;
			spinSizer->Add(tempst,0, wxALIGN_CENTER_VERTICAL);
			wxBoxSizer* ct_sizer = new wxBoxSizer( wxHORIZONTAL );
			ct_sizer->Add(tempspin, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, b_gap);
			ct_sizer->Add(getButton(FLOAT_START_ID+ctrl_count,pref+current.key), 0, wxRIGHT , col_gap);
			spinSizer->Add( ct_sizer );
			ctrl_count++;
        }
	}

    total_count += ctrl_count;
	ctrl_count = 0;
	for ( SpringUnitSync::OptionMapListIter it = optWrap.m_opts[optFlag].list_map.begin(); it != optWrap.m_opts[optFlag].list_map.end(); ++it)
	{
	    if ( it->second.section == section.key )
        {
            mmOptionList current = it->second;

            int temp = int(current.cbx_choices.GetCount()-1);
            int index = clamp(current.cur_choice_index,0,temp);
            wxComboBox* tempchoice = new wxComboBox(this, LIST_START_ID+ctrl_count, current.cbx_choices[index], wxDefaultPosition,
                    wxDefaultSize, current.cbx_choices, wxCB_READONLY, wxDefaultValidator);
						wxString tooltip = current.description + _T("\n");
						for ( ListItemVec::const_iterator itor = current.listitems.begin(); itor != current.listitems.end(); ++itor )
						{
							tooltip+= _T("\n") + itor->name + _T(": ") + itor->desc;
						}
            tempchoice->SetToolTip(TE(tooltip));
            m_name_info_map[pref+current.key] = tooltip;
            tempchoice->SetName(pref+current.key);
            tempchoice->Enable(enable);
            m_combox_map[pref+current.key] = tempchoice;
            wxStaticText* tempst = new wxStaticText(this,-1,current.name);
            m_statictext_map[pref+current.key] = tempst;
            cbxSizer->Add(tempst,0, wxALIGN_CENTER_VERTICAL);
            wxBoxSizer* ct_sizer = new wxBoxSizer( wxHORIZONTAL );
            ct_sizer->Add(tempchoice, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, b_gap);
            ct_sizer->Add(getButton(LIST_START_ID+ctrl_count,pref+current.key), 0,  wxRIGHT, col_gap);
            cbxSizer->Add( ct_sizer );

            ctrl_count++;
        }
	}

    total_count += ctrl_count;
	ctrl_count = 0;
	for ( SpringUnitSync::OptionMapStringIter it = optWrap.m_opts[optFlag].string_map.begin(); it != optWrap.m_opts[optFlag].string_map.end(); ++it)
	{
	    if ( it->second.section == section.key )
        {
            mmOptionString current = it->second;
            wxTextCtrl* temptext = new wxTextCtrl(this, STRING_START_ID+ctrl_count, current.value, wxDefaultPosition,
                    wxDefaultSize, 0, wxDefaultValidator, current.key);
            temptext->SetToolTip(TE(current.description));
            m_name_info_map[pref+current.key] = current.description;
            temptext->SetName(pref+current.key);
            temptext->Enable(enable);
            m_textctrl_map[pref+current.key] = temptext;
            wxStaticText* tempst = new wxStaticText(this,-1,current.name);
            m_statictext_map[pref+current.key] = tempst;
            textSizer->Add(tempst,0, wxALIGN_CENTER_VERTICAL);
            wxBoxSizer* ct_sizer = new wxBoxSizer( wxHORIZONTAL );
            ct_sizer->Add(temptext,0, wxALIGN_CENTER_VERTICAL | wxRIGHT, b_gap);
            ct_sizer->Add(getButton(STRING_START_ID+ctrl_count,pref+current.key),0, wxRIGHT, col_gap);
            textSizer->Add( ct_sizer );

            ctrl_count++;
        }
	}
    total_count += ctrl_count;

	parent_sizer->Add( chkSizer, 0, wxALL, chkSizer->GetChildren().size() > 0 ? 5 : 0 );
	parent_sizer->Add( spinSizer, 0, wxALL, spinSizer->GetChildren().size() > 0 ? 5 : 0 );
	parent_sizer->Add( cbxSizer, 0, wxALL, cbxSizer->GetChildren().size() > 0 ? 5 : 0 );
	parent_sizer->Add( textSizer, 0, wxALL, textSizer->GetChildren().size() > 0 ? 5 : 0 );

    return total_count;

}
コード例 #30
0
ファイル: ibattle.cpp プロジェクト: johnjianfang/springlobby
bool IBattle::LoadOptionsPreset( const wxString& name )
{
  wxString preset = FixPresetName(name);
  if (preset == _T("")) return false; //preset not found
  m_preset = preset;

  for ( unsigned int i = 0; i < OptionsWrapper::LastOption; i++)
  {
    std::map<wxString,wxString> options = sett().GetHostingPreset( m_preset, i );
    if ( (OptionsWrapper::GameOption)i != OptionsWrapper::PrivateOptions )
    {
	  for ( std::map<wxString,wxString>::const_iterator itor = options.begin(); itor != options.end(); ++itor )
      {
            wxLogWarning( itor->first + _T(" ::: ") + itor->second );
            CustomBattleOptions().setSingleOption( itor->first, itor->second, (OptionsWrapper::GameOption)i );
      }
    }
    else
    {
      if ( !options[_T("mapname")].IsEmpty() )
      {
        if ( usync().MapExists( options[_T("mapname")] ) ) {
            UnitSyncMap map = usync().GetMapEx( options[_T("mapname")] );
            SetLocalMap( map );
            SendHostInfo( HI_Map );
        }
        else if ( !ui().OnPresetRequiringMap( options[_T("mapname")] ) ) {
            //user didn't want to download the missing map, so set to empty to not have it tried to be loaded again
            options[_T("mapname")] = _T("");
            sett().SetHostingPreset( m_preset, i, options );
        }
      }

		for( unsigned int j = 0; j <= GetLastRectIdx(); ++j ) {
			if ( GetStartRect( j ).IsOk() )
				RemoveStartRect(j); // remove all rects that might come from map presets
		}
		SendHostInfo( IBattle::HI_StartRects );

      unsigned int rectcount = s2l( options[_T("numrects")] );
      for ( unsigned int loadrect = 0; loadrect < rectcount; loadrect++)
      {
        int ally = s2l(options[_T("rect_") + TowxString(loadrect) + _T("_ally")]);
        if ( ally == 0 ) continue;
        AddStartRect( ally - 1, s2l(options[_T("rect_") + TowxString(loadrect) + _T("_left")]), s2l(options[_T("rect_") + TowxString(loadrect) + _T("_top")]), s2l(options[_T("rect_") + TowxString(loadrect) + _T("_right")]), s2l(options[_T("rect_") + TowxString(loadrect) + _T("_bottom")]) );
      }
      SendHostInfo( HI_StartRects );

      wxStringTokenizer tkr( options[_T("restrictions")], _T('\t') );
      m_restricted_units.clear();
      while( tkr.HasMoreTokens() )
      {
      	wxString unitinfo = tkr.GetNextToken();
      	RestrictUnit( unitinfo.BeforeLast(_T('=')), s2l( unitinfo.AfterLast(_T('=')) ) );
      }
      SendHostInfo( HI_Restrictions );
	  Update( wxFormat( _T("%d_restrictions") ) % OptionsWrapper::PrivateOptions );

    }
  }
  SendHostInfo( HI_Send_All_opts );
  ui().ReloadPresetList();
  return true;
}