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

Replaced genRect with Rect constructor call

This commit is contained in:
Ivan Savenko 2023-02-03 19:17:59 +02:00
parent 34dcb4127a
commit 62151cd20c
7 changed files with 36 additions and 65 deletions

View File

@ -277,17 +277,17 @@ void CTerrainRect::showPath(const Rect & extRect, SDL_Surface * to)
}
else if(hvx<0)
{
Rect srcRect = CSDL_Ext::genRect(arrow->height() - hvy, arrow->width(), 0, 0);
Rect srcRect (Point(0, 0), Point(arrow->height() - hvy, arrow->width()));
arrow->draw(to, x + moveX, y + moveY, &srcRect);
}
else if (hvy<0)
{
Rect srcRect = CSDL_Ext::genRect(arrow->height(), arrow->width() - hvx, 0, 0);
Rect srcRect (Point(0, 0), Point(arrow->height(), arrow->width() - hvx));
arrow->draw(to, x + moveX, y + moveY, &srcRect);
}
else
{
Rect srcRect = CSDL_Ext::genRect(arrow->height() - hvy, arrow->width() - hvx, 0, 0);
Rect srcRect (Point(0, 0), Point(arrow->height() - hvy, arrow->width() - hvx));
arrow->draw(to, x + moveX, y + moveY, &srcRect);
}
}
@ -299,17 +299,17 @@ void CTerrainRect::showPath(const Rect & extRect, SDL_Surface * to)
}
else if(hvx<0)
{
Rect srcRect = CSDL_Ext::genRect(arrow->height() - hvy, arrow->width(), 0, 0);
Rect srcRect (Point(0, 0), Point(arrow->height() - hvy, arrow->width()));
arrow->draw(to, x, y, &srcRect);
}
else if (hvy<0)
{
Rect srcRect = CSDL_Ext::genRect(arrow->height(), arrow->width() - hvx, 0, 0);
Rect srcRect (Point(0, 0), Point(arrow->height(), arrow->width() - hvx));
arrow->draw(to, x, y, &srcRect);
}
else
{
Rect srcRect = CSDL_Ext::genRect(arrow->height() - hvy, arrow->width() - hvx, 0, 0);
Rect srcRect (Point(0, 0), Point(arrow->height() - hvy, arrow->width() - hvx));
arrow->draw(to, x, y, &srcRect);
}
}

View File

@ -18,24 +18,6 @@
#include <SDL_render.h>
#ifdef VCMI_APPLE
#include <dispatch/dispatch.h>
#endif
#ifdef VCMI_IOS
#include "ios/utils.h"
#endif
Rect CSDL_Ext::genRect(const int & hh, const int & ww, const int & xx, const int & yy)
{
Rect ret;
ret.h=hh;
ret.w=ww;
ret.x=xx;
ret.y=yy;
return ret;
}
Rect CSDL_Ext::fromSDL(const SDL_Rect & rect)
{
return Rect(Point(rect.x, rect.y), Point(rect.w, rect.h));

View File

@ -45,8 +45,6 @@ SDL_Color toSDL(const ColorRGBA & color);
void setColors(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors);
void setAlpha(SDL_Surface * bg, int value);
Rect genRect(const int & hh, const int & ww, const int & xx, const int & yy);
typedef void (*TColorPutter)(uint8_t *&ptr, const uint8_t & R, const uint8_t & G, const uint8_t & B);
typedef void (*TColorPutterAlpha)(uint8_t *&ptr, const uint8_t & R, const uint8_t & G, const uint8_t & B, const uint8_t & A);

View File

@ -517,8 +517,8 @@ CStackWindow::MainSection::MainSection(CStackWindow * owner, int yOffset, bool s
const CStack * battleStack = parent->info->stack;
morale = std::make_shared<MoraleLuckBox>(true, CSDL_Ext::genRect(42, 42, 321, 110));
luck = std::make_shared<MoraleLuckBox>(false, CSDL_Ext::genRect(42, 42, 375, 110));
morale = std::make_shared<MoraleLuckBox>(true, Rect(Point(321, 110), Point(42, 42) ));
luck = std::make_shared<MoraleLuckBox>(false, Rect(Point(375, 110), Point(42, 42) ));
if(battleStack != nullptr) // in battle
{

View File

@ -183,38 +183,25 @@ CSpellWindow::CSpellWindow(const CGHeroInstance * _myHero, CPlayerInterface * _m
mana = std::make_shared<CLabel>(435, 426, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, boost::lexical_cast<std::string>(myHero->mana));
statusBar = CGStatusBar::create(7, 569, "Spelroll.bmp");
Rect temp_rect = CSDL_Ext::genRect(45, 35, 479 + pos.x, 405 + pos.y);
interactiveAreas.push_back(std::make_shared<InteractiveArea>(temp_rect, std::bind(&CSpellWindow::fexitb, this), 460, this));
temp_rect = CSDL_Ext::genRect(45, 35, 221 + pos.x, 405 + pos.y);
interactiveAreas.push_back(std::make_shared<InteractiveArea>(temp_rect, std::bind(&CSpellWindow::fbattleSpellsb, this), 453, this));
temp_rect = CSDL_Ext::genRect(45, 35, 355 + pos.x, 405 + pos.y);
interactiveAreas.push_back(std::make_shared<InteractiveArea>(temp_rect, std::bind(&CSpellWindow::fadvSpellsb, this), 452, this));
temp_rect = CSDL_Ext::genRect(45, 35, 418 + pos.x, 405 + pos.y);
interactiveAreas.push_back(std::make_shared<InteractiveArea>(temp_rect, std::bind(&CSpellWindow::fmanaPtsb, this), 459, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 479 + pos.x, 405 + pos.y, 36, 56), std::bind(&CSpellWindow::fexitb, this), 460, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 221 + pos.x, 405 + pos.y, 36, 56), std::bind(&CSpellWindow::fbattleSpellsb, this), 453, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 355 + pos.x, 405 + pos.y, 36, 56), std::bind(&CSpellWindow::fadvSpellsb, this), 452, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 418 + pos.x, 405 + pos.y, 36, 56), std::bind(&CSpellWindow::fmanaPtsb, this), 459, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 549 + pos.x, 94 + pos.y, 36, 56), std::bind(&CSpellWindow::selectSchool, this, 0), 454, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 549 + pos.x, 151 + pos.y, 45, 35), std::bind(&CSpellWindow::selectSchool, this, 3), 457, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 549 + pos.x, 210 + pos.y, 45, 35), std::bind(&CSpellWindow::selectSchool, this, 1), 455, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 549 + pos.x, 270 + pos.y, 45, 35), std::bind(&CSpellWindow::selectSchool, this, 2), 456, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 549 + pos.x, 330 + pos.y, 45, 35), std::bind(&CSpellWindow::selectSchool, this, 4), 458, this));
temp_rect = CSDL_Ext::genRect(36, 56, 549 + pos.x, 94 + pos.y);
interactiveAreas.push_back(std::make_shared<InteractiveArea>(temp_rect, std::bind(&CSpellWindow::selectSchool, this, 0), 454, this));
temp_rect = CSDL_Ext::genRect(36, 56, 549 + pos.x, 151 + pos.y);
interactiveAreas.push_back(std::make_shared<InteractiveArea>(temp_rect, std::bind(&CSpellWindow::selectSchool, this, 3), 457, this));
temp_rect = CSDL_Ext::genRect(36, 56, 549 + pos.x, 210 + pos.y);
interactiveAreas.push_back(std::make_shared<InteractiveArea>(temp_rect, std::bind(&CSpellWindow::selectSchool, this, 1), 455, this));
temp_rect = CSDL_Ext::genRect(36, 56, 549 + pos.x, 270 + pos.y);
interactiveAreas.push_back(std::make_shared<InteractiveArea>(temp_rect, std::bind(&CSpellWindow::selectSchool, this, 2), 456, this));
temp_rect = CSDL_Ext::genRect(36, 56, 549 + pos.x, 330 + pos.y);
interactiveAreas.push_back(std::make_shared<InteractiveArea>(temp_rect, std::bind(&CSpellWindow::selectSchool, this, 4), 458, this));
temp_rect = CSDL_Ext::genRect(leftCorner->pos.h, leftCorner->pos.w, 97 + pos.x, 77 + pos.y);
interactiveAreas.push_back(std::make_shared<InteractiveArea>(temp_rect, std::bind(&CSpellWindow::fLcornerb, this), 450, this));
temp_rect = CSDL_Ext::genRect(rightCorner->pos.h, rightCorner->pos.w, 487 + pos.x, 72 + pos.y);
interactiveAreas.push_back(std::make_shared<InteractiveArea>(temp_rect, std::bind(&CSpellWindow::fRcornerb, this), 451, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 97 + pos.x, 77 + pos.y, leftCorner->pos.h, leftCorner->pos.w ), std::bind(&CSpellWindow::fLcornerb, this), 450, this));
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 487 + pos.x, 72 + pos.y, rightCorner->pos.h, rightCorner->pos.w ), std::bind(&CSpellWindow::fRcornerb, this), 451, this));
//areas for spells
int xpos = 117 + pos.x, ypos = 90 + pos.y;
for(int v=0; v<12; ++v)
{
temp_rect = CSDL_Ext::genRect(65, 78, xpos, ypos);
spellAreas[v] = std::make_shared<SpellArea>(temp_rect, this);
spellAreas[v] = std::make_shared<SpellArea>( Rect(xpos, ypos, 65, 78), this);
if(v == 5) //to right page
{

View File

@ -504,9 +504,13 @@ void CTradeWindow::getPositionsFor(std::vector<Rect> &poss, bool Left, EType typ
const std::vector<Rect> tmp =
{
CSDL_Ext::genRect(h, w, x, y), CSDL_Ext::genRect(h, w, x + dx, y), CSDL_Ext::genRect(h, w, x + 2*dx, y),
CSDL_Ext::genRect(h, w, x, y + dy), CSDL_Ext::genRect(h, w, x + dx, y + dy), CSDL_Ext::genRect(h, w, x + 2*dx, y + dy),
CSDL_Ext::genRect(h, w, x + dx, y + 2*dy)
Rect(Point(x + 0*dx, y + 0*dx), Point(h, w) ),
Rect(Point(x + 1*dx, y + 0*dx), Point(h, w) ),
Rect(Point(x + 2*dx, y + 0*dx), Point(h, w) ),
Rect(Point(x + 0*dx, y + 1*dy), Point(h, w) ),
Rect(Point(x + 1*dx, y + 1*dy), Point(h, w) ),
Rect(Point(x + 2*dx, y + 1*dy), Point(h, w) ),
Rect(Point(x + 1*dx, y + 2*dy), Point(h, w) )
};
vstd::concatenate(poss, tmp);

View File

@ -1135,9 +1135,9 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
{
primSkillAreas.push_back(std::make_shared<LRClickableAreaWTextComp>());
if (qeLayout)
primSkillAreas[g]->pos = CSDL_Ext::genRect(22, 152, pos.x + 324, pos.y + 12 + 26 * g);
primSkillAreas[g]->pos = Rect(Point(pos.x + 324, pos.y + 12 + 26 * g), Point(22, 152));
else
primSkillAreas[g]->pos = CSDL_Ext::genRect(32, 140, pos.x + 329, pos.y + 19 + 36 * g);
primSkillAreas[g]->pos = Rect(Point(pos.x + 329, pos.y + 19 + 36 * g), Point(32, 140));
primSkillAreas[g]->text = CGI->generaltexth->arraytxt[2+g];
primSkillAreas[g]->type = g;
primSkillAreas[g]->bonusValue = -1;
@ -1157,7 +1157,7 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
int skill = hero->secSkills[g].first,
level = hero->secSkills[g].second; // <1, 3>
secSkillAreas[b].push_back(std::make_shared<LRClickableAreaWTextComp>());
secSkillAreas[b][g]->pos = CSDL_Ext::genRect(32, 32, pos.x + 32 + g*36 + b*454 , pos.y + (qeLayout ? 83 : 88));
secSkillAreas[b][g]->pos = Rect(Point(pos.x + 32 + g*36 + b*454 , pos.y + (qeLayout ? 83 : 88)), Point(32, 32) );
secSkillAreas[b][g]->baseType = 1;
secSkillAreas[b][g]->type = skill;
@ -1172,12 +1172,12 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
heroAreas[b] = std::make_shared<CHeroArea>(257 + 228*b, 13, hero);
specialtyAreas[b] = std::make_shared<LRClickableAreaWText>();
specialtyAreas[b]->pos = CSDL_Ext::genRect(32, 32, pos.x + 69 + 490*b, pos.y + (qeLayout ? 41 : 45));
specialtyAreas[b]->pos = Rect(Point(pos.x + 69 + 490*b, pos.y + (qeLayout ? 41 : 45)), Point(32, 32));
specialtyAreas[b]->hoverText = CGI->generaltexth->heroscrn[27];
specialtyAreas[b]->text = hero->type->getSpecialtyDescriptionTranslated();
experienceAreas[b] = std::make_shared<LRClickableAreaWText>();
experienceAreas[b]->pos = CSDL_Ext::genRect(32, 32, pos.x + 105 + 490*b, pos.y + (qeLayout ? 41 : 45));
experienceAreas[b]->pos = Rect(Point(pos.x + 105 + 490*b, pos.y + (qeLayout ? 41 : 45)), Point(32, 32));
experienceAreas[b]->hoverText = CGI->generaltexth->heroscrn[9];
experienceAreas[b]->text = CGI->generaltexth->allTexts[2];
boost::algorithm::replace_first(experienceAreas[b]->text, "%d", boost::lexical_cast<std::string>(hero->level));
@ -1185,15 +1185,15 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
boost::algorithm::replace_first(experienceAreas[b]->text, "%d", boost::lexical_cast<std::string>(hero->exp));
spellPointsAreas[b] = std::make_shared<LRClickableAreaWText>();
spellPointsAreas[b]->pos = CSDL_Ext::genRect(32, 32, pos.x + 141 + 490*b, pos.y + (qeLayout ? 41 : 45));
spellPointsAreas[b]->pos = Rect(Point(pos.x + 141 + 490*b, pos.y + (qeLayout ? 41 : 45)), Point(32, 32));
spellPointsAreas[b]->hoverText = CGI->generaltexth->heroscrn[22];
spellPointsAreas[b]->text = CGI->generaltexth->allTexts[205];
boost::algorithm::replace_first(spellPointsAreas[b]->text, "%s", hero->getNameTranslated());
boost::algorithm::replace_first(spellPointsAreas[b]->text, "%d", boost::lexical_cast<std::string>(hero->mana));
boost::algorithm::replace_first(spellPointsAreas[b]->text, "%d", boost::lexical_cast<std::string>(hero->manaLimit()));
morale[b] = std::make_shared<MoraleLuckBox>(true, CSDL_Ext::genRect(32, 32, 176 + 490 * b, 39), true);
luck[b] = std::make_shared<MoraleLuckBox>(false, CSDL_Ext::genRect(32, 32, 212 + 490 * b, 39), true);
morale[b] = std::make_shared<MoraleLuckBox>(true, Rect(Point(176 + 490 * b, 39), Point(32, 32)), true);
luck[b] = std::make_shared<MoraleLuckBox>(false, Rect(Point(212 + 490 * b, 39), Point(32, 32)), true);
}
quit = std::make_shared<CButton>(Point(732, 567), "IOKAY.DEF", CGI->generaltexth->zelp[600], std::bind(&CExchangeWindow::close, this), SDLK_RETURN);
@ -1375,7 +1375,7 @@ CPuzzleWindow::CPuzzleWindow(const int3 & GrailPos, double discoveredRatio)
void CPuzzleWindow::showAll(SDL_Surface * to)
{
int3 moveInt = int3(8, 9, 0);
Rect mapRect = CSDL_Ext::genRect(544, 591, pos.x + 8, pos.y + 7);
Rect mapRect = Rect(Point(pos.x + 8, pos.y + 7), Point(544, 591));
int3 topTile = grailPos - moveInt;
MapDrawingInfo info(topTile, LOCPLINT->cb->getVisibilityMap(), mapRect);