1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fixes after merge, move removeGUI to Client class

This commit is contained in:
Dydzio 2023-01-11 17:11:44 +01:00
parent aac515f64e
commit cb3fd24ec0
4 changed files with 19 additions and 50 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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();