diff --git a/planet/System.ocg/LanguageDE.txt b/planet/System.ocg/LanguageDE.txt index 223f2dc16..29c53a4cc 100644 --- a/planet/System.ocg/LanguageDE.txt +++ b/planet/System.ocg/LanguageDE.txt @@ -59,6 +59,8 @@ IDS_CNS_GAMECLOSED=Spiel deinitialisiert. IDS_CNS_GAMEMODE=Spielmodus IDS_CNS_GAMESAVED=Spiel gespeichert. IDS_CNS_HEIGHT=Höhe +IDS_CNS_HOSTASNETWORKGAME=Als Netzwerkspiel hosten +IDS_CNS_HOSTASNETWORKGAMEDESC=Started das Spiel in einer Netzwerklobby, so dass andere Spieler beitreten und mit editieren koennen. IDS_CNS_INDEXSHORT=Idx IDS_CNS_INTERNAL=Intern IDS_CNS_INVALID=Ungültig @@ -542,6 +544,7 @@ IDS_MNU_NEWVIEWPORT=Neues Sichtfenster IDS_MNU_NEXTVIEWPORT=Nächstes Sichtfenster auswählen IDS_MNU_OPEN=Öffnen... IDS_MNU_OPENMATERIALSELECTION=Materialauswahl öffnen +IDS_MNU_OPENNET=Öffnen als Netzwerkspiel... IDS_MNU_OPENWPLRS=Öffnen mit Spielern... IDS_MNU_OPTIONS=Optionen IDS_MNU_OPTIONSINFO=Einstellungen ändern. diff --git a/planet/System.ocg/LanguageUS.txt b/planet/System.ocg/LanguageUS.txt index 202f99c6b..a504ddfc3 100644 --- a/planet/System.ocg/LanguageUS.txt +++ b/planet/System.ocg/LanguageUS.txt @@ -59,6 +59,8 @@ IDS_CNS_GAMECLOSED=Game cleared. IDS_CNS_GAMEMODE=Game mode IDS_CNS_GAMESAVED=Game saved. IDS_CNS_HEIGHT=Height +IDS_CNS_HOSTASNETWORKGAME=Host as network game +IDS_CNS_HOSTASNETWORKGAMEDESC=Starts the scenario in a network lobby, allowing other clients to join. IDS_CNS_INDEXSHORT=Idx IDS_CNS_INTERNAL=Internal IDS_CNS_INVALID=Invalid @@ -542,6 +544,7 @@ IDS_MNU_NEW=New... IDS_MNU_NEWVIEWPORT=New viewport IDS_MNU_OPEN=Open... IDS_MNU_OPENMATERIALSELECTION=Popup material selection +IDS_MNU_OPENNET=Open as network game... IDS_MNU_OPENWPLRS=Open with players... IDS_MNU_OPTIONS=Options IDS_MNU_OPTIONSINFO=Change program options. diff --git a/src/editor/C4Console.cpp b/src/editor/C4Console.cpp index cbdc81f5d..b40a42291 100644 --- a/src/editor/C4Console.cpp +++ b/src/editor/C4Console.cpp @@ -260,9 +260,15 @@ bool C4Console::FileNew() { StdCopyStrBuf filename; #ifdef WITH_QT_EDITOR - if (!C4ConsoleGUI::CreateNewScenario(&filename)) return false; + bool host_in_network = false; + if (!C4ConsoleGUI::CreateNewScenario(&filename, &host_in_network)) return false; Application.ClearCommandLine(); ::Config.Developer.AddRecentlyEditedScenario(filename.getData()); + if (host_in_network) + { + Game.NetworkActive = true; + Game.fLobby = true; + } Application.OpenGame(filename.getData()); return true; #endif @@ -271,7 +277,7 @@ bool C4Console::FileNew() } -bool C4Console::FileOpen(const char *filename) +bool C4Console::FileOpen(const char *filename, bool host_in_network) { // Get scenario file name StdCopyStrBuf c4sfile(""); @@ -285,6 +291,11 @@ bool C4Console::FileOpen(const char *filename) } Application.ClearCommandLine(); ::Config.Developer.AddRecentlyEditedScenario(filename); + if (host_in_network) + { + Game.NetworkActive = true; + Game.fLobby = true; + } // Open game Application.OpenGame(filename); return true; diff --git a/src/editor/C4Console.h b/src/editor/C4Console.h index f8ce9a2fa..a2283c252 100644 --- a/src/editor/C4Console.h +++ b/src/editor/C4Console.h @@ -77,7 +77,7 @@ public: bool FileSaveAs(bool fSaveGame); bool FileSave(); bool FileNew(); - bool FileOpen(const char *filename=nullptr); + bool FileOpen(const char *filename=nullptr, bool host_in_network=false); bool FileOpenWPlrs(); bool FileCommand(); bool FileClose(); diff --git a/src/editor/C4ConsoleGUI.h b/src/editor/C4ConsoleGUI.h index faab803d7..93b20cd6a 100644 --- a/src/editor/C4ConsoleGUI.h +++ b/src/editor/C4ConsoleGUI.h @@ -92,7 +92,7 @@ public: void AddViewport(C4ViewportWindow *cvp); void RemoveViewport(C4ViewportWindow *cvp); void OnObjectSelectionChanged(class C4EditCursorSelection &selection); // selection changed (through other means than creator or object list view) - bool CreateNewScenario(StdStrBuf *out_filename); + bool CreateNewScenario(StdStrBuf *out_filename, bool *out_host_as_network); void OnStartGame(); void ClearGamePointers(); void EnsureDefinitionListInitialized(); @@ -111,6 +111,7 @@ public: void AddViewport(C4ViewportWindow *cvp) { } void RemoveViewport(C4ViewportWindow *cvp) { } void OnObjectSelectionChanged(class C4EditCursorSelection &selection) { } + bool CreateNewScenario(StdStrBuf *out_filename, bool *out_host_as_network) {} void OnStartGame() { } void EnsureDefinitionListInitialized() { } void CloseConsoleWindow() {} diff --git a/src/editor/C4ConsoleQt.cpp b/src/editor/C4ConsoleQt.cpp index d72d86a89..e0981334c 100644 --- a/src/editor/C4ConsoleQt.cpp +++ b/src/editor/C4ConsoleQt.cpp @@ -346,10 +346,10 @@ void C4ConsoleGUI::UpdateMenuText(HMENU hMenu) { /* Translation done through QTr state->RemoveViewport(cvp); } -bool C4ConsoleGUI::CreateNewScenario(StdStrBuf *out_filename) +bool C4ConsoleGUI::CreateNewScenario(StdStrBuf *out_filename, bool *out_host_as_network) { #ifdef WITH_QT_EDITOR - return state->CreateNewScenario(out_filename); + return state->CreateNewScenario(out_filename, out_host_as_network); #else return false #endif diff --git a/src/editor/C4ConsoleQtMainWindow.ui b/src/editor/C4ConsoleQtMainWindow.ui index 102712e40..5451cd436 100644 --- a/src/editor/C4ConsoleQtMainWindow.ui +++ b/src/editor/C4ConsoleQtMainWindow.ui @@ -339,6 +339,7 @@ + @@ -1247,6 +1248,17 @@ - + + + IDS_MNU_OPENNET + + + IDS_MNU_OPENNET + + + IDS_MNU_OPENNET + + @@ -1451,8 +1463,8 @@ DrawSizeChanged(int) - 499 - 69 + 685 + 78 477 @@ -1707,8 +1719,8 @@ WelcomeLinkActivated(QString) - 591 - 216 + 676 + 234 477 @@ -1723,8 +1735,8 @@ WelcomeLinkActivated(QString) - 591 - 235 + 676 + 253 477 @@ -1739,8 +1751,8 @@ WelcomeLinkActivated(QString) - 445 - 248 + 676 + 272 477 @@ -1988,6 +2000,22 @@ + + actionFileOpenInNetwork + triggered() + MainWindow + FileOpenInNetwork() + + + -1 + -1 + + + 477 + 312 + + + PlayPressed(bool) @@ -2035,5 +2063,6 @@ FocusNextViewport() GradeUp() GradeDown() + FileOpenInNetwork() diff --git a/src/editor/C4ConsoleQtNewScenario.cpp b/src/editor/C4ConsoleQtNewScenario.cpp index 1cdd2322d..fc6e4c0c2 100644 --- a/src/editor/C4ConsoleQtNewScenario.cpp +++ b/src/editor/C4ConsoleQtNewScenario.cpp @@ -243,6 +243,11 @@ C4ConsoleQtNewScenarioDlg::C4ConsoleQtNewScenarioDlg(class QMainWindow *parent_w delete m; } +bool C4ConsoleQtNewScenarioDlg::IsHostAsNetwork() const +{ + return ui.startInNetworkCheckbox->isChecked(); +} + bool C4ConsoleQtNewScenarioDlg::SaveScenario(C4Group &grp) { // Save c4s diff --git a/src/editor/C4ConsoleQtNewScenario.h b/src/editor/C4ConsoleQtNewScenario.h index 855967466..ef75495b8 100644 --- a/src/editor/C4ConsoleQtNewScenario.h +++ b/src/editor/C4ConsoleQtNewScenario.h @@ -90,6 +90,7 @@ class C4ConsoleQtNewScenarioDlg : public QDialog public: C4ConsoleQtNewScenarioDlg(class QMainWindow *parent_window); const char *GetFilename() const { return filename.getData(); } + bool IsHostAsNetwork() const; private: bool SaveScenario(class C4Group &grp); diff --git a/src/editor/C4ConsoleQtNewScenario.ui b/src/editor/C4ConsoleQtNewScenario.ui index 3b5faeece..965e70e76 100644 --- a/src/editor/C4ConsoleQtNewScenario.ui +++ b/src/editor/C4ConsoleQtNewScenario.ui @@ -335,6 +335,16 @@ + + + + IDS_CNS_HOSTASNETWORKGAMEDESC + + + IDS_CNS_HOSTASNETWORKGAME + + + diff --git a/src/editor/C4ConsoleQtState.cpp b/src/editor/C4ConsoleQtState.cpp index f5fda95b4..403fbe9ca 100644 --- a/src/editor/C4ConsoleQtState.cpp +++ b/src/editor/C4ConsoleQtState.cpp @@ -335,7 +335,8 @@ void C4ConsoleQtMainWindow::DrawSizeChanged(int newval) // File menu void C4ConsoleQtMainWindow::FileNew() { ::Console.FileNew(); } -void C4ConsoleQtMainWindow::FileOpen() { ::Console.FileOpen(); } +void C4ConsoleQtMainWindow::FileOpen() { ::Console.FileOpen(nullptr, false); } +void C4ConsoleQtMainWindow::FileOpenInNetwork() { ::Console.FileOpen(nullptr, true); } void C4ConsoleQtMainWindow::FileOpenWithPlayers() { Console.FileOpenWPlrs(); } void C4ConsoleQtMainWindow::FileRecord() { ::Console.FileRecord(); } void C4ConsoleQtMainWindow::FileSave() { ::Console.FileSave(); } @@ -1068,13 +1069,14 @@ void C4ConsoleGUIState::OnCreatorCurrentChanged(const QModelIndex & current, con ::Console.EditCursor.SetCreatorDef(new_def); // set or clear def in EditCursor } -bool C4ConsoleGUIState::CreateNewScenario(StdStrBuf *out_filename) +bool C4ConsoleGUIState::CreateNewScenario(StdStrBuf *out_filename, bool *out_host_as_network) { // Show dialogue std::unique_ptr dlg(new C4ConsoleQtNewScenarioDlg(window.get())); if (!dlg->exec()) return false; // Dlg said OK! Scenario created out_filename->Copy(dlg->GetFilename()); + *out_host_as_network = dlg->IsHostAsNetwork(); return true; } diff --git a/src/editor/C4ConsoleQtState.h b/src/editor/C4ConsoleQtState.h index 35f884ed7..894435dfb 100644 --- a/src/editor/C4ConsoleQtState.h +++ b/src/editor/C4ConsoleQtState.h @@ -129,6 +129,7 @@ public slots: // File menu void FileNew(); void FileOpen(); + void FileOpenInNetwork(); void FileOpenWithPlayers(); void FileRecord(); void FileSave(); @@ -254,7 +255,7 @@ public: void OnCreatorCurrentChanged(const QModelIndex & current, const QModelIndex & previous); void UpdateActionObject(C4Object *new_action_object); - bool CreateNewScenario(StdStrBuf *out_filename); // show "new scenario" dialogue; return true if new scenario is created + bool CreateNewScenario(StdStrBuf *out_filename, bool *out_host_as_network); // show "new scenario" dialogue; return true if new scenario is created #ifdef USE_WIN32_WINDOWS bool HandleWin32KeyboardMessage(MSG *msg);