void BattleRoomTab::RegenerateOptionsList() { long pos = 0; m_opts_list->DeleteAllItems(); m_opts_list->InsertItem( pos, _( "Size" ) ); m_opt_list_map[ _( "Size" ) ] = pos; pos++; m_opts_list->InsertItem( pos , _( "Windspeed" ) ); m_opt_list_map[ _( "Windspeed" ) ] = pos; pos++; m_opts_list->InsertItem( pos, _( "Tidal strength" ) ); m_opt_list_map[ _( "Tidal strength" ) ] = pos; pos++; m_opts_list->InsertItem( pos, wxEmptyString ); pos++; pos = AddMMOptionsToList( pos, OptionsWrapper::EngineOption ); // AddMMOptionsToList already increments pos by itself m_opts_list->InsertItem( pos, wxEmptyString ); pos++; m_mod_opts_index = pos; pos = AddMMOptionsToList( m_mod_opts_index, OptionsWrapper::ModOption ); // AddMMOptionsToList already increments pos by itself m_opts_list->InsertItem( pos, wxEmptyString ); pos++; m_map_opts_index = pos; pos = AddMMOptionsToList( m_map_opts_index, OptionsWrapper::MapOption ); }
void AddBotDialog::ShowAIOptions() { m_opts_list->DeleteAllItems(); m_opt_list_map.clear(); m_battle.CustomBattleOptions().loadAIOptions(m_battle.GetHostGameName(), GetAIType(), STD_STRING(GetNick())); AddMMOptionsToList(0, m_battle.CustomBattleOptions().GetAIOptionIndex(STD_STRING(GetNick()))); m_opts_list->SetColumnWidth(0, wxLIST_AUTOSIZE); m_opts_list->SetColumnWidth(1, wxLIST_AUTOSIZE); Layout(); SetSize(wxDefaultSize); }
void BattleRoomTab::RegenerateOptionsList() { long pos = 0; m_opts_list->DeleteAllItems(); m_opts_list->InsertItem(pos, _("Size")); m_opt_list_map.clear(); m_opt_list_map[_("Size")] = pos; pos++; m_opts_list->InsertItem(pos, _("Windspeed")); m_opt_list_map[_("Windspeed")] = pos; pos++; m_opts_list->InsertItem(pos, _("Tidal strength")); m_opt_list_map[_("Tidal strength")] = pos; pos++; m_opts_list->InsertItem(pos, wxEmptyString); pos++; pos = AddMMOptionsToList(pos, LSL::Enum::EngineOption); // AddMMOptionsToList already increments pos by itself m_opts_list->InsertItem(pos, wxEmptyString); pos++; m_mod_opts_index = pos; pos = AddMMOptionsToList(m_mod_opts_index, LSL::Enum::ModOption); // AddMMOptionsToList already increments pos by itself m_opts_list->InsertItem(pos, wxEmptyString); pos++; m_map_opts_index = pos; pos = AddMMOptionsToList(m_map_opts_index, LSL::Enum::MapOption); m_side_sel->Clear(); if (m_battle != NULL) { try { const wxArrayString sides = lslTowxArrayString(LSL::usync().GetSides(m_battle->GetHostModName())); for (unsigned int i = 0; i < sides.GetCount(); i++) { m_side_sel->Append(sides[i], icons().GetBitmap(icons().GetSideIcon(m_battle->GetHostModName(), i))); } wxSize s = m_side_sel->GetEffectiveMinSize(); s.SetWidth(s.GetWidth() + 16); // HACK without this additional place, the image overflows the text on wxGtk m_side_sel->SetMinSize(s); } catch (...) { } } }
void BattleRoomTab::UpdateBattleInfo(const wxString& Tag) { if (!m_battle) return; const long index = m_opt_list_map[Tag]; if (index >= m_opts_list->GetItemCount()) { wxLogDebug(_T("UpdateBattleInfo: Invalid index %d %d %s"), index, m_opts_list->GetItemCount(), Tag.c_str()); return; } LSL::Enum::GameOption type = (LSL::Enum::GameOption)FromwxString(Tag.BeforeFirst('_')); wxString key = Tag.AfterFirst('_'); if ((type == LSL::Enum::MapOption) || (type == LSL::Enum::ModOption) || (type == LSL::Enum::EngineOption)) { LSL::Enum::OptionType DataType = m_battle->CustomBattleOptions().GetSingleOptionType(STD_STRING(key)); wxString value = TowxString(m_battle->CustomBattleOptions().getSingleValue(STD_STRING(key), (LSL::Enum::GameOption)type)); if (TowxString(m_battle->CustomBattleOptions().getDefaultValue(STD_STRING(key), type)) == value) { m_opts_list->SetItemFont(index, wxFont(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT)); } else { m_opts_list->SetItemFont(index, wxFont(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD)); } if (DataType == LSL::Enum::opt_bool) { value = bool2yn(FromwxString(value)); // convert from 0/1 to literal Yes/No } else if (DataType == LSL::Enum::opt_list) { value = TowxString(m_battle->CustomBattleOptions().GetNameListOptValue(STD_STRING(key), type)); // get the key full name not short key } m_opts_list->SetItem(index, 1, value); } else // if ( type == OptionsWrapper::PrivateOptions ) { if (key == _T( "mapname" )) // the map has been changed { UpdateMapInfoSummary(); wxString mapname = TowxString(m_battle->GetHostMapName()); int index_ = m_map_combo->FindString(mapname); if (index_ != wxNOT_FOUND) m_map_combo->SetSelection(index_); else m_map_combo->SetValue(mapname); //delete any eventual map option from the list and add options of the new map for (int i = m_map_opts_index; i < m_opts_list->GetItemCount();) { m_opts_list->DeleteItem(i); } AddMMOptionsToList(m_map_opts_index, LSL::Enum::MapOption); m_minimap->UpdateMinimap(); } else if (key == _T( "restrictions" )) { m_opts_list->SetItem(index, 1, bool2yn(m_battle->RestrictedUnits().size() > 0)); } } }
void AddBotDialog::ShowAIOptions() { if ( !usync().VersionSupports( IUnitSync::USYNC_GetSkirmishAI ) ) return; m_opts_list->DeleteAllItems(); m_opt_list_map.clear(); m_battle.CustomBattleOptions().loadAIOptions( m_battle.GetHostModName(), GetAIType(), GetNick() ); AddMMOptionsToList( 0, m_battle.CustomBattleOptions().GetAIOptionIndex( GetNick() ) ); m_opts_list->SetColumnWidth( 0, wxLIST_AUTOSIZE ); m_opts_list->SetColumnWidth( 1, wxLIST_AUTOSIZE ); Layout(); SetSize( wxDefaultSize ); }
void BattleRoomTab::RegenerateOptionsList() { long pos = 0; m_opts_list->DeleteAllItems(); m_opts_list->InsertItem( pos, _( "Size" ) ); m_opt_list_map[ _( "Size" ) ] = pos; pos++; m_opts_list->InsertItem( pos , _( "Windspeed" ) ); m_opt_list_map[ _( "Windspeed" ) ] = pos; pos++; m_opts_list->InsertItem( pos, _( "Tidal strength" ) ); m_opt_list_map[ _( "Tidal strength" ) ] = pos; pos++; m_opts_list->InsertItem( pos, wxEmptyString ); pos++; pos = AddMMOptionsToList( pos, LSL::OptionsWrapper::EngineOption ); // AddMMOptionsToList already increments pos by itself m_opts_list->InsertItem( pos, wxEmptyString ); pos++; m_mod_opts_index = pos; pos = AddMMOptionsToList( m_mod_opts_index, LSL::OptionsWrapper::ModOption ); // AddMMOptionsToList already increments pos by itself m_opts_list->InsertItem( pos, wxEmptyString ); pos++; m_map_opts_index = pos; pos = AddMMOptionsToList( m_map_opts_index, LSL::OptionsWrapper::MapOption ); m_side_sel->Clear(); if (m_battle != NULL) { try { printf("RegenerateOptionsList\n"); const wxArrayString sides = LSL::Util::vectorToArrayString(LSL::usync().GetSides(STD_STRING(m_battle->GetHostModName()))); for ( unsigned int i = 0; i < sides.GetCount(); i++ ) { m_side_sel->Append(sides[i], icons().GetBitmap( icons().GetSideIcon( m_battle->GetHostModName(), i ) ) ); printf("RegenerateOptionsList %s\n", (const char*)sides[i].mb_str()); } } catch ( ... ) {} } }
void BattleRoomTab::UpdateBattleInfo( const wxString& Tag ) { if ( !m_battle ) return; long index = m_opt_list_map[ Tag ]; OptionsWrapper::GameOption type = ( OptionsWrapper::GameOption )s2l( Tag.BeforeFirst( '_' ) ); wxString key = Tag.AfterFirst( '_' ); wxString value; if ( ( type == OptionsWrapper::MapOption ) || ( type == OptionsWrapper::ModOption ) || ( type == OptionsWrapper::EngineOption ) ) { OptionType DataType = m_battle->CustomBattleOptions().GetSingleOptionType( key ); value = m_battle->CustomBattleOptions().getSingleValue( key, ( OptionsWrapper::GameOption )type ); if ( m_battle->CustomBattleOptions().getDefaultValue( key, type ) == value ) m_opts_list->SetItemFont( index, wxFont( 8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT ) ); else m_opts_list->SetItemFont( index, wxFont( 8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD ) ); if ( DataType == opt_bool ) { value = bool2yn( s2l( value ) ); // convert from 0/1 to literal Yes/No } else if ( DataType == opt_list ) { value = m_battle->CustomBattleOptions().GetNameListOptValue( key, type ); // get the key full name not short key } m_opts_list->SetItem( index, 1, value ); } else if ( type == OptionsWrapper::PrivateOptions ) { if ( key == _T( "mapname" ) ) // the map has been changed { try // updates map info summary { ASSERT_EXCEPTION( m_battle->MapExists(), _( "Map does not exist." ) ); UnitSyncMap map = m_battle->LoadMap(); m_opts_list->SetItem( m_opt_list_map[ _( "Size" ) ] , 1, wxString::Format( _T( "%.0fx%.0f" ), map.info.width / 512.0, map.info.height / 512.0 ) ); m_opts_list->SetItem( m_opt_list_map[ _( "Windspeed" ) ], 1, wxString::Format( _T( "%d-%d" ), map.info.minWind, map.info.maxWind ) ); m_opts_list->SetItem( m_opt_list_map[ _( "Tidal strength" ) ], 1, wxString::Format( _T( "%d" ), map.info.tidalStrength ) ); // m_opts_list->SetItem( 0, 1, ); } catch ( ... ) { m_opts_list->SetItem( m_opt_list_map[ _( "Size" ) ], 1, _T( "?x?" ) ); m_opts_list->SetItem( m_opt_list_map[ _( "Windspeed" ) ], 1, _T( "?-?" ) ); m_opts_list->SetItem( m_opt_list_map[ _( "Tidal strength" ) ], 1, _T( "?" ) ); } wxString mapname =m_battle->GetHostMapName(); int index_ = m_map_combo->FindString( mapname ); if ( index_ != wxNOT_FOUND ) m_map_combo->SetSelection( index_ ); else m_map_combo->SetValue( mapname ); //delete any eventual map option from the list and add options of the new map for ( int i = m_map_opts_index; i < m_opts_list->GetItemCount(); ) { m_opts_list->DeleteItem( i ); } AddMMOptionsToList( m_map_opts_index, OptionsWrapper::MapOption ); m_minimap->UpdateMinimap(); } else if ( key == _T( "restrictions" ) ) { m_opts_list->SetItem( index, 1, bool2yn( m_battle->RestrictedUnits().size() > 0 ) ); } } }