From 2898ad6e9a7eba5d7fea41c093e0ef5a1b45bf54 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Thu, 14 Apr 2022 00:44:44 +0300 Subject: [PATCH] [Client] Make Back button work in character generation Character generation was coded in a strange way by Koncord in the earliest days of the project, but this fixes the main problem with it. --- apps/openmw/mwgui/charactercreation.cpp | 111 ++++++++++++++++++++++++ apps/openmw/mwmp/LocalPlayer.cpp | 1 - 2 files changed, 111 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index 7ebae6b6f..12c3fd9e2 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -17,6 +17,17 @@ #include "../mwworld/esmstore.hpp" #include "../mwworld/player.hpp" +/* + Start of tes3mp addition + + Include additional headers for multiplayer purposes +*/ +#include "../mwmp/Main.hpp" +#include "../mwmp/LocalPlayer.hpp" +/* + End of tes3mp addition +*/ + #include "textinput.hpp" #include "race.hpp" #include "class.hpp" @@ -329,6 +340,16 @@ namespace MWGui MWBase::Environment::get().getWindowManager()->popGuiMode(); MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Birth); + + /* + Start of tes3mp addition + + Decrease the character generation stage tracked for the LocalPlayer + */ + mwmp::Main::get().getLocalPlayer()->charGenState.currentStage--; + /* + End of tes3mp addition + */ } void CharacterCreation::onReviewActivateDialog(int parDialog) @@ -381,6 +402,16 @@ namespace MWGui selectPickedClass(); handleDialogDone(CSE_ClassChosen, GM_Birth); + + /* + Start of tes3mp addition + + Increase the character generation stage tracked for the LocalPlayer + */ + mwmp::Main::get().getLocalPlayer()->charGenState.currentStage++; + /* + End of tes3mp addition + */ } void CharacterCreation::onPickClassDialogBack() @@ -411,6 +442,16 @@ namespace MWGui break; case ClassChoiceDialog::Class_Back: MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Race); + + /* + Start of tes3mp addition + + Decrease the character generation stage tracked for the LocalPlayer + */ + mwmp::Main::get().getLocalPlayer()->charGenState.currentStage--; + /* + End of tes3mp addition + */ break; }; @@ -439,6 +480,16 @@ namespace MWGui } handleDialogDone(CSE_NameChosen, GM_Race); + + /* + Start of tes3mp addition + + Increase the character generation stage tracked for the LocalPlayer + */ + mwmp::Main::get().getLocalPlayer()->charGenState.currentStage++; + /* + End of tes3mp addition + */ } void CharacterCreation::selectRace() @@ -477,6 +528,16 @@ namespace MWGui selectRace(); handleDialogDone(CSE_RaceChosen, GM_Class); + + /* + Start of tes3mp addition + + Increase the character generation stage tracked for the LocalPlayer + */ + mwmp::Main::get().getLocalPlayer()->charGenState.currentStage++; + /* + End of tes3mp addition + */ } void CharacterCreation::selectBirthSign() @@ -498,6 +559,16 @@ namespace MWGui selectBirthSign(); handleDialogDone(CSE_BirthSignChosen, GM_Review); + + /* + Start of tes3mp addition + + Increase the character generation stage tracked for the LocalPlayer + */ + mwmp::Main::get().getLocalPlayer()->charGenState.currentStage++; + /* + End of tes3mp addition + */ } void CharacterCreation::onBirthSignDialogBack() @@ -506,6 +577,16 @@ namespace MWGui MWBase::Environment::get().getWindowManager()->popGuiMode(); MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Class); + + /* + Start of tes3mp addition + + Decrease the character generation stage tracked for the LocalPlayer + */ + mwmp::Main::get().getLocalPlayer()->charGenState.currentStage--; + /* + End of tes3mp addition + */ } void CharacterCreation::selectCreatedClass() @@ -547,6 +628,16 @@ namespace MWGui selectCreatedClass(); handleDialogDone(CSE_ClassChosen, GM_Birth); + + /* + Start of tes3mp addition + + Increase the character generation stage tracked for the LocalPlayer + */ + mwmp::Main::get().getLocalPlayer()->charGenState.currentStage++; + /* + End of tes3mp addition + */ } void CharacterCreation::onCreateClassDialogBack() @@ -556,6 +647,16 @@ namespace MWGui MWBase::Environment::get().getWindowManager()->popGuiMode(); MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Class); + + /* + Start of tes3mp addition + + Decrease the character generation stage tracked for the LocalPlayer + */ + mwmp::Main::get().getLocalPlayer()->charGenState.currentStage--; + /* + End of tes3mp addition + */ } void CharacterCreation::onClassQuestionChosen(int _index) @@ -748,6 +849,16 @@ namespace MWGui selectGeneratedClass(); handleDialogDone(CSE_ClassChosen, GM_Birth); + + /* + Start of tes3mp addition + + Increase the character generation stage tracked for the LocalPlayer + */ + mwmp::Main::get().getLocalPlayer()->charGenState.currentStage++; + /* + End of tes3mp addition + */ } CharacterCreation::~CharacterCreation() diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 019a0c4f0..de496bf97 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -155,7 +155,6 @@ bool LocalPlayer::processCharGen() } getNetworking()->getPlayerPacket(ID_PLAYER_CHARGEN)->setPlayer(this); getNetworking()->getPlayerPacket(ID_PLAYER_CHARGEN)->Send(); - charGenState.currentStage++; return false; }