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

code review

This commit is contained in:
Laserlicht 2023-09-25 16:34:36 +02:00 committed by GitHub
parent 28f4046937
commit 7cf654992f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 15 deletions

View File

@ -462,7 +462,7 @@ CGStatusBar::CGStatusBar(int x, int y, const ImagePath & name, int maxw)
OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE);
if(name.empty())
if(name.empty()) // without background
return;
auto backgroundImage = std::make_shared<CPicture>(name);
background = backgroundImage;

View File

@ -125,7 +125,7 @@ class CGStatusBar : public CLabel, public std::enable_shared_from_this<CGStatusB
bool enteringText;
CGStatusBar(std::shared_ptr<CIntObject> background_, EFonts Font = FONT_SMALL, ETextAlignment Align = ETextAlignment::CENTER, const ColorRGBA & Color = Colors::WHITE);
CGStatusBar(int x, int y, const ImagePath & name, int maxw = -1);
CGStatusBar(int x, int y, const ImagePath & name = ImagePath::builtin(""), int maxw = -1);
//make CLabel API private
using CLabel::getText;

View File

@ -103,7 +103,13 @@ CSpellWindow::CSpellWindow(const CGHeroInstance * _myHero, CPlayerInterface * _m
currentPage(0),
myHero(_myHero),
myInt(_myInt),
isBigSpellbook(settings["general"]["enableUiEnhancements"].Bool())
isBigSpellbook(settings["general"]["enableUiEnhancements"].Bool()),
spellsPerPage(24),
offL(-11),
offR(195),
offRM(110),
offT(-37),
offB(56)
{
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
@ -203,19 +209,20 @@ CSpellWindow::CSpellWindow(const CGHeroInstance * _myHero, CPlayerInterface * _m
mana = std::make_shared<CLabel>(435 + (isBigSpellbook ? 159 : 0), 426 + offB, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, std::to_string(myHero->mana));
if(isBigSpellbook)
statusBar = CGStatusBar::create(400, 587, ImagePath::builtin(""));
statusBar = CGStatusBar::create(400, 587);
else
statusBar = CGStatusBar::create(7, 569, ImagePath::builtin("Spelroll.bmp"));
Rect schoolRect( 549 + pos.x + offR, 94 + pos.y, 45, 35);
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 479 + pos.x + (isBigSpellbook ? 175 : 0), 405 + pos.y + offB, isBigSpellbook ? 60 : 36, 56), std::bind(&CSpellWindow::fexitb, this), 460, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 221 + pos.x + (isBigSpellbook ? 43 : 0), 405 + pos.y + offB, isBigSpellbook ? 60 : 36, 56), std::bind(&CSpellWindow::fbattleSpellsb, this), 453, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 355 + pos.x + (isBigSpellbook ? 110 : 0), 405 + pos.y + offB, isBigSpellbook ? 60 : 36, 56), std::bind(&CSpellWindow::fadvSpellsb, this), 452, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 418 + pos.x + (isBigSpellbook ? 142 : 0), 405 + pos.y + offB, isBigSpellbook ? 60 : 36, 56), std::bind(&CSpellWindow::fmanaPtsb, this), 459, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 549 + pos.x + offR, 94 + pos.y, 36, 56), std::bind(&CSpellWindow::selectSchool, this, 0), 454, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 549 + pos.x + offR, 151 + pos.y, 45, 35), std::bind(&CSpellWindow::selectSchool, this, 3), 457, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 549 + pos.x + offR, 210 + pos.y, 45, 35), std::bind(&CSpellWindow::selectSchool, this, 1), 455, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 549 + pos.x + offR, 270 + pos.y, 45, 35), std::bind(&CSpellWindow::selectSchool, this, 2), 456, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 549 + pos.x + offR, 330 + pos.y, 45, 35), std::bind(&CSpellWindow::selectSchool, this, 4), 458, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( schoolRect + Point(0, 0), std::bind(&CSpellWindow::selectSchool, this, 0), 454, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( schoolRect + Point(0, 57), std::bind(&CSpellWindow::selectSchool, this, 3), 457, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( schoolRect + Point(0, 116), std::bind(&CSpellWindow::selectSchool, this, 1), 455, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( schoolRect + Point(0, 176), std::bind(&CSpellWindow::selectSchool, this, 2), 456, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( schoolRect + Point(0, 236), std::bind(&CSpellWindow::selectSchool, this, 4), 458, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 97 + offL + pos.x, 77 + offT + pos.y, leftCorner->pos.h, leftCorner->pos.w ), std::bind(&CSpellWindow::fLcornerb, this), 450, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 487 + offR + pos.x, 72 + offT + pos.y, rightCorner->pos.h, rightCorner->pos.w ), std::bind(&CSpellWindow::fRcornerb, this), 451, this));

View File

@ -81,12 +81,12 @@ class CSpellWindow : public CWindowObject
std::vector<std::shared_ptr<InteractiveArea>> interactiveAreas;
bool isBigSpellbook;
int spellsPerPage = 24;
int offL = -11;
int offR = 195;
int offRM = 110;
int offT = -37;
int offB = 56;
int spellsPerPage;
int offL;
int offR;
int offRM;
int offT;
int offB;
int sitesPerTabAdv[5];
int sitesPerTabBattle[5];