Browse Source

Fixes after merge, move removeGUI to Client class

Dydzio 2 năm trước cách đây
mục cha
commit
cb3fd24ec0
4 tập tin đã thay đổi với 19 bổ sung50 xóa
  1. 15 1
      client/Client.cpp
  2. 1 0
      client/Client.h
  3. 3 48
      client/ClientCommandManager.cpp
  4. 0 1
      client/ClientCommandManager.h

+ 15 - 1
client/Client.cpp

@@ -46,9 +46,9 @@
 #include "../lib/CThreadHelper.h"
 #include "../lib/registerTypes/RegisterTypes.h"
 #include "gui/CGuiHandler.h"
-#include "CMT.h"
 #include "CServerHandler.h"
 #include "../lib/ScriptHandler.h"
+#include "windows/CAdvmapInterface.h"
 #include <vcmi/events/EventBus.h>
 
 #ifdef VCMI_ANDROID
@@ -761,6 +761,20 @@ void CClient::reinitScripting()
 #endif
 }
 
+void CClient::removeGUI()
+{
+	// CClient::endGame
+	GH.curInt = nullptr;
+	if(GH.topInt())
+		GH.topInt()->deactivate();
+	adventureInt = nullptr;
+	GH.listInt.clear();
+	GH.objsToBlit.clear();
+	GH.statusbar = nullptr;
+	logGlobal->info("Removed GUI.");
+
+	LOCPLINT = nullptr;
+}
 
 #ifdef VCMI_ANDROID
 extern "C" JNIEXPORT void JNICALL Java_eu_vcmi_vcmi_NativeMethods_notifyServerClosed(JNIEnv * env, jobject cls)

+ 1 - 0
client/Client.h

@@ -240,6 +240,7 @@ public:
 
 	void showInfoDialog(InfoWindow * iw) override {};
 	void showInfoDialog(const std::string & msg, PlayerColor player) override {};
+	void removeGUI();
 
 #if SCRIPTING_ENABLED
 	scripting::Pool * getGlobalContextPool() const override;

+ 3 - 48
client/ClientCommandManager.cpp

@@ -57,7 +57,7 @@ void ClientCommandManager::handleGoSolo()
 	else
 	{
 		color = LOCPLINT->playerID;
-		removeGUI();
+		CSH->client->removeGUI();
 		for(auto & elem : CSH->client->gameState()->players)
 		{
 			if(elem.second.human)
@@ -92,7 +92,7 @@ void ClientCommandManager::handleControlAi(const std::string &colorName)
 			continue;
 		}
 
-		removeGUI();
+		CSH->client->removeGUI();
 		CSH->client->installNewPlayerInterface(std::make_shared<CPlayerInterface>(elem.first), elem.first);
 	}
 	GH.totalRedraw();
@@ -169,38 +169,7 @@ void ClientCommandManager::processCommand(const std::string &message, bool calle
 //	}
 	else if(message=="convert txt")
 	{
-		//TODO: to be replaced with "VLC->generaltexth->dumpAllTexts();" due to https://github.com/vcmi/vcmi/pull/1329 merge:
-
-		printCommandMessage("Command accepted.\t");
-
-		const boost::filesystem::path outPath =
-				VCMIDirs::get().userExtractedPath();
-
-		boost::filesystem::create_directories(outPath);
-
-		auto extractVector = [=](const std::vector<std::string> & source, const std::string & name)
-		{
-			JsonNode data(JsonNode::JsonType::DATA_VECTOR);
-			int64_t index = 0;
-			for(auto & line : source)
-			{
-				JsonNode lineNode(JsonNode::JsonType::DATA_STRUCT);
-				lineNode["text"].String() = line;
-				lineNode["index"].Integer() = index++;
-				data.Vector().push_back(lineNode);
-			}
-
-			const boost::filesystem::path filePath = outPath / (name + ".json");
-			boost::filesystem::ofstream file(filePath);
-			file << data.toJson();
-		};
-
-		extractVector(VLC->generaltexth->allTexts, "generalTexts");
-		extractVector(VLC->generaltexth->jktexts, "jkTexts");
-		extractVector(VLC->generaltexth->arraytxt, "arrayTexts");
-
-		printCommandMessage("\rExtracting done :)\n");
-		printCommandMessage("Extracted files can be found in" + outPath.string() + " directory\n");
+		VLC->generaltexth->dumpAllTexts();
 	}
 	else if(message=="get config")
 	{
@@ -459,20 +428,6 @@ void ClientCommandManager::giveTurn(const PlayerColor &colorIdentifier)
 	yt.applyCl(CSH->client);
 }
 
-void ClientCommandManager::removeGUI()
-{
-	// CClient::endGame
-	GH.curInt = nullptr;
-	if(GH.topInt())
-		GH.topInt()->deactivate();
-	GH.listInt.clear();
-	GH.objsToBlit.clear();
-	GH.statusbar = nullptr;
-	printCommandMessage("Removed GUI.", ELogLevel::INFO);
-
-	LOCPLINT = nullptr;
-}
-
 void ClientCommandManager::printInfoAboutInterfaceObject(const CIntObject *obj, int level)
 {
 	std::stringstream sbuffer;

+ 0 - 1
client/ClientCommandManager.h

@@ -20,7 +20,6 @@ class ClientCommandManager //take mantis #2292 issue about account if thinking a
 	static bool currentCallFromIngameConsole;
 
 	static void giveTurn(const PlayerColor &color);
-	static void removeGUI();
 	static void printInfoAboutInterfaceObject(const CIntObject *obj, int level);
 	static void printCommandMessage(const std::string &commandMessage, ELogLevel::ELogLevel messageType = ELogLevel::NOT_SET);
 	static void handleGoSolo();