1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-05 00:49:09 +02:00

Renamed CGuiHandler to GameEngine

- class CGuiHandler is now called GameEngine to better describe its
functionality
- renamed global GH to more clear ENGINE
- GH/ENGINE is now unique_ptr to make construction / deconstruction
order more clear and to allow interface / implementation split
- CGuiHandler.cpp/h is now called GameEngine.cpp/h and located in root
directory of client dir
This commit is contained in:
Ivan Savenko
2025-02-10 21:49:23 +00:00
parent 0c5a560c80
commit cacceda950
144 changed files with 1019 additions and 1021 deletions

View File

@ -14,10 +14,11 @@
#include "Images.h"
#include "../CPlayerInterface.h"
#include "../gui/CGuiHandler.h"
#include "../GameEngine.h"
#include "../windows/CMessage.h"
#include "../windows/InfoWindows.h"
#include "../adventureMap/CInGameConsole.h"
#include "../eventsSDL/InputHandler.h"
#include "../render/Canvas.h"
#include "../render/Graphics.h"
#include "../render/IFont.h"
@ -56,7 +57,7 @@ CLabel::CLabel(int x, int y, EFonts Font, ETextAlignment Align, const ColorRGBA
if(alignment == ETextAlignment::TOPLEFT) // causes issues for MIDDLE
{
const auto & fontPtr = GH.renderHandler().loadFont(font);
const auto & fontPtr = ENGINE->renderHandler().loadFont(font);
pos.w = fontPtr->getStringWidth(visibleText().c_str());
pos.h = fontPtr->getLineHeight();
}
@ -116,7 +117,7 @@ void CLabel::trimText()
{
if(maxWidth > 0)
{
const auto & fontPtr = GH.renderHandler().loadFont(font);
const auto & fontPtr = ENGINE->renderHandler().loadFont(font);
while (fontPtr->getStringWidth(visibleText().c_str()) > maxWidth)
TextOperations::trimRightUnicode(text);
@ -137,7 +138,7 @@ void CLabel::setColor(const ColorRGBA & Color)
size_t CLabel::getWidth()
{
const auto & fontPtr = GH.renderHandler().loadFont(font);
const auto & fontPtr = ENGINE->renderHandler().loadFont(font);
return fontPtr->getStringWidth(visibleText());
}
@ -182,7 +183,7 @@ std::vector<std::string> CMultiLineLabel::getLines()
void CTextContainer::blitLine(Canvas & to, Rect destRect, std::string what)
{
const auto f = GH.renderHandler().loadFont(font);
const auto f = ENGINE->renderHandler().loadFont(font);
Point where = destRect.topLeft();
const std::string delimiters = "{}";
auto delimitersCount = std::count_if(what.cbegin(), what.cend(), [&delimiters](char c)
@ -275,7 +276,7 @@ void CMultiLineLabel::showAll(Canvas & to)
{
CIntObject::showAll(to);
const auto & fontPtr = GH.renderHandler().loadFont(font);
const auto & fontPtr = ENGINE->renderHandler().loadFont(font);
// calculate which lines should be visible
int totalLines = static_cast<int>(lines.size());
@ -312,7 +313,7 @@ void CMultiLineLabel::splitText(const std::string & Txt, bool redrawAfter)
{
lines.clear();
const auto & fontPtr = GH.renderHandler().loadFont(font);
const auto & fontPtr = ENGINE->renderHandler().loadFont(font);
int lineHeight = fontPtr->getLineHeight();
lines = CMessage::breakText(Txt, pos.w, font);
@ -333,7 +334,7 @@ Rect CMultiLineLabel::getTextLocation()
if(pos.h <= textSize.y)
return pos;
const auto & fontPtr = GH.renderHandler().loadFont(font);
const auto & fontPtr = ENGINE->renderHandler().loadFont(font);
Point textSizeComputed(pos.w, fontPtr->getLineHeight() * lines.size()); //FIXME: how is this different from textSize member?
Point textOffset(pos.w - textSizeComputed.x, pos.h - textSizeComputed.y);
@ -433,7 +434,7 @@ void CTextBox::setText(const std::string & text)
label->pos.w = pos.w - 16;
assert(label->pos.w > 0);
label->setText(text);
const auto & fontPtr = GH.renderHandler().loadFont(label->font);
const auto & fontPtr = ENGINE->renderHandler().loadFont(label->font);
OBJECT_CONSTRUCTION;
slider = std::make_shared<CSlider>(Point(pos.w - 16, 0), pos.h, std::bind(&CTextBox::sliderMoved, this, _1),
@ -452,14 +453,14 @@ void CGStatusBar::setEnteringMode(bool on)
{
//assert(enteringText == false);
alignment = ETextAlignment::TOPLEFT;
GH.startTextInput(pos);
ENGINE->input().startTextInput(pos);
setText(consoleText);
}
else
{
//assert(enteringText == true);
alignment = ETextAlignment::CENTER;
GH.stopTextInput();
ENGINE->input().stopTextInput();
setText(hoverText);
}
enteringText = on;
@ -535,7 +536,7 @@ CGStatusBar::CGStatusBar(int x, int y, const ImagePath & name, int maxw)
CGStatusBar::~CGStatusBar()
{
assert(GH.statusbar().get() != this);
assert(ENGINE->statusbar().get() != this);
}
void CGStatusBar::show(Canvas & to)
@ -551,13 +552,13 @@ void CGStatusBar::clickPressed(const Point & cursorPosition)
void CGStatusBar::activate()
{
GH.setStatusbar(shared_from_this());
ENGINE->setStatusbar(shared_from_this());
CIntObject::activate();
}
void CGStatusBar::deactivate()
{
GH.setStatusbar(nullptr);
ENGINE->setStatusbar(nullptr);
if (enteringText)
LOCPLINT->cingconsole->endEnteringText(false);