void BattleRoomTab::OnMapBrowse( wxCommandEvent& /*unused*/ ) { if ( !m_battle ) return; wxLogDebugFunc( _T( "" ) ); if ( mapSelectDialog().ShowModal() == wxID_OK && mapSelectDialog().GetSelectedMap() != NULL ) { wxString mapname = mapSelectDialog().GetSelectedMap()->name; wxLogDebugFunc( mapname ); if ( !m_battle->IsFounderMe() ) { m_battle->DoAction( _T( "suggests " ) + mapname ); return; } const int idx = m_map_combo->FindString( mapname, true /*case sensitive*/ ); if ( idx != wxNOT_FOUND ) SetMap( idx ); } }
void SinglePlayerTab::OnMapBrowse( wxCommandEvent& /*unused*/ ) { wxLogDebugFunc( wxEmptyString ); const wxString mapname = mapSelectDialog(); if ( !mapname.empty()) { const int idx = m_map_pick->FindString( mapname, true /*case sensitive*/ ); if ( idx != wxNOT_FOUND ) { SetMap( idx ); } } }
void BattleMapTab::OnMapBrowse(wxCommandEvent& /*unused*/) { if (!m_battle) return; slLogDebugFunc(""); wxString mapname = mapSelectDialog(); if (!mapname.empty()) { slLogDebugFunc(""); if (!m_battle->IsFounderMe()) { m_battle->DoAction("suggests " + STD_STRING(mapname)); return; } const int idx = m_map_combo->FindString(mapname, true /*case sensitive*/); if (idx != wxNOT_FOUND) SetMap(idx); } }
void BattleRoomTab::OnMapBrowse(wxCommandEvent& /*unused*/) { if (!m_battle) return; slLogDebugFunc(""); const wxString mapname = mapSelectDialog(); if (!mapname.empty()) { if (!m_battle->IsFounderMe()) { m_battle->m_autohost_manager->GetAutohostHandler().SetMap(STD_STRING(mapname)); //m_battle->DoAction( _T( "suggests " ) + mapname ); return; } const int idx = m_map_combo->FindString(mapname, true /*case sensitive*/); if (idx != wxNOT_FOUND) { SetMap(idx); } } }
MainWindow::MainWindow() : wxFrame(NULL, -1, TowxString(getSpringlobbyName())) , WindowAttributesPickle(_T("MAINWINDOW"), this, wxSize(720, 576)) , m_opts_dialog(NULL) , m_autojoin_dialog(NULL) , se_frame(NULL) , m_channel_chooser(NULL) , m_log_win(NULL) , m_has_focus(true) { SetMinSize(wxSize(720, 576)); m_tab_names.Add(_("Chat")); m_tab_names.Add(_("Battlelist")); m_tab_names.Add(_("Battleroom")); m_tab_names.Add(_("Singleplayer")); // m_tab_names.Add( _("Savegames") ); m_tab_names.Add(_("Replays")); m_tab_names.Add(_("Downloads")); SetIcon(icons().GetIcon(icons().ICON_SPRINGLOBBY)); GetAui().manager = new wxAuiManager(this); wxMenu* menuServer = new wxMenu; menuServer->Append(MENU_CONNECT, _("&Connect...")); menuServer->Append(MENU_DISCONNECT, _("&Disconnect")); menuServer->Append(MENU_SERVER_TAB, _("&Reopen server panel")); menuServer->AppendSeparator(); #ifndef NDEBUG //this is a prime spot to add experimental stuff, or stubs used to test things not really meant to be in mainwindow menuServer->Append(MENU_SAVE_OPTIONS, _("&Save options")); menuServer->AppendSeparator(); #endif menuServer->Append(MENU_QUIT, _("&Quit")); m_menuEdit = new wxMenu; m_menuEdit->Append(MENU_AUTOJOIN_CHANNELS, _("&Autojoin channels")); m_menuEdit->Append(MENU_PREFERENCES, _("&Preferences")); m_menuEdit->Append(MENU_SELECT_LOCALE, _("&Change language")); m_settings_menu = new wxMenuItem(m_menuEdit, MENU_SETTINGSPP, _("&Spring settings"), wxEmptyString, wxITEM_NORMAL); m_menuEdit->Append(MENU_RESET_LAYOUT, _("&Reset layout")); m_menuEdit->Append(m_settings_menu); m_menuEdit->Enable(MENU_SETTINGSPP, LSL::usync().IsLoaded()); //unitsync isn't loaded yet, disable menu entry m_menuTools = new wxMenu; m_menuTools->Append(MENU_JOIN, _("&Join channel...")); m_menuTools->Append(MENU_CHANNELCHOOSER, _("Channel &list")); m_menuTools->Append(MENU_CHAT, _("Open private &chat...")); m_menuTools->Append(MENU_SHOWWRITEABLEDIR, _("&Open Spring DataDir")); m_menuTools->AppendSeparator(); m_menuTools->Append(MENU_DOWNLOAD, _("&Download Archives")); m_menuTools->AppendSeparator(); m_menuTools->Append(MENU_USYNC, _("&Reload maps/games")); m_menuTools->AppendSeparator(); m_menuTools->Append(MENU_VERSION, _("Check for new Version")); wxMenu* menuHelp = new wxMenu; menuHelp->Append(MENU_GENERAL_HELP, _("&Help, tutorial and FAQ")); menuHelp->Append(MENU_ABOUT, _("&About")); menuHelp->Append(MENU_PATHINFO, _("&System Info")); menuHelp->Append(MENU_TRAC, _("&Report a bug...")); menuHelp->Append(MENU_DOC, _("&Documentation")); m_menubar = new wxMenuBar; m_menubar->Append(menuServer, _("&Server")); m_menubar->Append(m_menuEdit, _("&Edit")); m_menubar->Append(m_menuTools, _("&Tools")); m_menubar->Append(menuHelp, _("&Help")); SetMenuBar(m_menubar); m_main_sizer = new wxBoxSizer(wxHORIZONTAL); m_func_tabs = new SLNotebook(this, _T("mainfunctabs"), MAIN_TABS, wxDefaultPosition, wxDefaultSize, wxAUI_NB_WINDOWLIST_BUTTON | wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_MOVE | wxAUI_NB_TAB_EXTERNAL_MOVE | wxAUI_NB_SCROLL_BUTTONS | wxAUI_NB_LEFT); m_func_tabs->SetArtProvider(new wxAuiDefaultTabArt); //IMPORTANT: event handling needs to be disabled while constructing, otherwise deadlock occurs SetEvtHandlerEnabled(false); m_chat_tab = new MainChatTab(m_func_tabs); m_list_tab = new BattleListTab(m_func_tabs); m_join_tab = new MainJoinBattleTab(m_func_tabs); m_sp_tab = new MainSinglePlayerTab(m_func_tabs); // m_savegame_tab = new SavegameTab( m_func_tabs ); m_replay_tab = new PlaybackTab(m_func_tabs, true); m_torrent_tab = new MainDownloadTab(m_func_tabs); //use Insert so no Changepage events are triggered m_func_tabs->InsertPage(PAGE_CHAT, m_chat_tab, m_tab_names[PAGE_CHAT], true); m_func_tabs->InsertPage(PAGE_LIST, m_list_tab, m_tab_names[PAGE_LIST], false); m_func_tabs->InsertPage(PAGE_JOIN, m_join_tab, m_tab_names[PAGE_JOIN], false); m_func_tabs->InsertPage(PAGE_SINGLE, m_sp_tab, m_tab_names[PAGE_SINGLE], false); // m_func_tabs->InsertPage( PAGE_SAVEGAME, m_savegame_tab, m_tab_names[PAGE_SAVEGAME], false ); m_func_tabs->InsertPage(PAGE_REPLAY, m_replay_tab, m_tab_names[PAGE_REPLAY], false); m_func_tabs->InsertPage(PAGE_TORRENT, m_torrent_tab, m_tab_names[PAGE_TORRENT], false); LoadPerspectives(); SetTabIcons(); m_main_sizer->Add(m_func_tabs, 1, wxEXPAND | wxALL, 0); SetSizer(m_main_sizer); Layout(); se_frame_active = false; wxToolTip::Enable(sett().GetShowTooltips()); m_channel_chooser = new ChannelChooserDialog(this, -1, _("Choose channels to join")); m_statusbar = new Statusbar(this); SetStatusBar(m_statusbar); // re-enable eventhandling SetEvtHandlerEnabled(true); UpdateMainAppHasFocus(m_has_focus); Connect(MainwindowMessageEvent, wxCommandEventHandler(MainWindow::OnMessage), NULL, this); //this should take off the firstload time considerably *ie nil it :P ) mapSelectDialog(true, this); Logger::ShowDebugWindow(true); // Logger::ShowDebugWindow(cfg().ReadBool(_T("/debug"))); }
//! @brief Initializes the application. //! //! It will open the main window and connect default to server or open the connect window. bool SpringLobbyApp::OnInit() { wxSetEnv( _T("UBUNTU_MENUPROXY"), _T("0") ); //this triggers the Cli Parser amongst other stuff if (!wxApp::OnInit()) return false; SetAppName( m_appname ); if (!m_crash_handle_disable) { #if wxUSE_ON_FATAL_EXCEPTION wxHandleFatalExceptions( true ); #endif #if defined(__WXMSW__) && defined(ENABLE_DEBUG_REPORT) //this undocumented function acts as a workaround for the dysfunctional // wxUSE_ON_FATAL_EXCEPTION on msw when mingw is used (or any other non SEH-capable compiler ) SetUnhandledExceptionFilter(filter); #endif } //initialize all loggers, we'll use the returned pointer to set correct parent window later wxLogChain* logchain = 0; wxLogWindow *loggerwin = InitializeLoggingTargets( 0, m_log_console, m_log_file_path, m_log_window_show, !m_crash_handle_disable, m_log_verbosity, logchain ); //this needs to called _before_ mainwindow instance is created wxInitAllImageHandlers(); wxFileSystem::AddHandler(new wxZipFSHandler); wxSocketBase::Initialize(); #ifdef __WXMSW__ wxString path = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) + wxFileName::GetPathSeparator() + _T("locale"); #else #if defined(LOCALE_INSTALL_DIR) wxString path ( _T(LOCALE_INSTALL_DIR) ); #else // use a dummy name here, we're only interested in the base path wxString path = wxStandardPaths::Get().GetLocalizedResourcesDir(_T("noneWH"),wxStandardPaths::ResourceCat_Messages); path = path.Left( path.First(_T("noneWH") ) ); #endif #endif m_translationhelper = new wxTranslationHelper( *( (wxApp*)this ), path ); m_translationhelper->Load(); if ( !wxDirExists( GetConfigfileDir() ) ) wxMkdir( GetConfigfileDir() ); #ifdef __WXMSW__ sett().SetSearchSpringOnlyInSLPath( sett().GetSearchSpringOnlyInSLPath() ); #endif sett().SetSpringBinary( sett().GetCurrentUsedSpringIndex(), sett().GetCurrentUsedSpringBinary() ); sett().SetUnitSync( sett().GetCurrentUsedSpringIndex(), sett().GetCurrentUsedUnitSync() ); if ( sett().DoResetPerspectives() ) { //we do this early on and reset the config var a little later so we can save a def. perps once mw is created sett().RemoveLayouts(); sett().SetDoResetPerspectives( false ); ui().mw().SavePerspectives( _T("SpringLobby-default") ); } sett().RefreshSpringVersionList(); //this should take off the firstload time considerably *ie nil it :P ) mapSelectDialog(); if ( !m_customizer_archive_name.IsEmpty() ) {//this needsto happen before usync load sett().SetForcedSpringConfigFilePath( GetCustomizedEngineConfigFilePath() ); } //unitsync first load, NEEDS to be blocking const bool usync_loaded = usync().ReloadUnitSyncLib(); if ( !sett().IsFirstRun() && !usync_loaded ) { customMessageBox( SL_MAIN_ICON, _("Please check that the file given in Preferences->Spring is a proper, readable unitsync library"), _("Coulnd't load required unitsync library"), wxOK ); } #ifndef DISABLE_SOUND //sound sources/buffer init sound(); #endif CacheAndSettingsSetup(); if ( !m_customizer_archive_name.IsEmpty() ) { if ( SLcustomizations().Init( m_customizer_archive_name ) ) { ui().mw().SetIcons( SLcustomizations().GetAppIconBundle() ); } else { customMessageBox( SL_MAIN_ICON, _("Couldn't load customizations for ") + m_customizer_archive_name + _("\nPlease check that that is the correct name, passed in qoutation"), _("Fatal error"), wxOK ); // wxLogError( _("Couldn't load customizations for ") + m_customizer_archive_name + _("\nPlease check that that is the correct name, passed in qoutation"), _("Fatal error") ); exit( OnExit() );//for some twisted reason returning false here does not terminate the app } } notificationManager(); //needs to be initialized too ui().ShowMainWindow(); SetTopWindow( &ui().mw() ); if ( sett().DoResetPerspectives() ) { //now that mainwindow is shown, we can save what is the default layout and remove the flag to reset sett().SetDoResetPerspectives( false ); ui().mw().SavePerspectives( _T("SpringLobby-default") ); } //interim fix for resize crashes on metacity and kwin #ifdef __WXMSW__ mapSelectDialog().Reparent( &ui().mw() ); #endif ui().FirstRunWelcome(); m_timer->Start( TIMER_INTERVAL ); ui().mw().SetLogWin( loggerwin, logchain ); #ifndef NO_TORRENT_SYSTEM plasmaInterface(); // plasmaInterface().InitResourceList(); // plasmaInterface().FetchResourceList(); #endif return true; }