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

Fixed a few CWE-457

This commit is contained in:
AlexVinS 2016-11-27 19:00:16 +03:00
parent 27b853618c
commit 6196ae7fca
10 changed files with 26 additions and 40 deletions

View File

@ -577,6 +577,7 @@ void CTextInput::numberFilter(std::string & text, const std::string & oldText, i
CFocusable::CFocusable()
{
focus = false;
focusables.push_back(this);
}

View File

@ -86,6 +86,7 @@ static void setScrollingCursor(ui8 direction)
CTerrainRect::CTerrainRect()
: fadeSurface(nullptr),
lastRedrawStatus(EMapAnimRedrawStatus::OK),
fadeAnim(new CFadeAnimation()),
curHoveredTile(-1,-1,-1),
currentPath(nullptr)

View File

@ -43,7 +43,7 @@ enum class EAdvMapMode
class CAdventureOptions : public CWindowObject
{
public:
CButton *exit, *viewWorld, *puzzle, *dig, *scenInfo, *replay;
CButton *exit, *viewWorld, *puzzle, *dig, *scenInfo/*, *replay*/;
CAdventureOptions();
static void showScenarioInfo();

View File

@ -1014,6 +1014,7 @@ CCreaInfo::CCreaInfo(Point position, const CGTownInstance *Town, int Level, bool
level = -1;
label = nullptr;
picture = nullptr;
creature = nullptr;
return;//No creature
}
addUsedEvents(LCLICK | RCLICK | HOVER);
@ -1125,6 +1126,8 @@ CTownInfo::CTownInfo(int posX, int posY, const CGTownInstance* Town, bool townHa
pos.y += posY;
int buildID;
picture = nullptr;
if (townHall)
{
buildID = 10 + town->hallLevel();
@ -1134,7 +1137,7 @@ CTownInfo::CTownInfo(int posX, int posY, const CGTownInstance* Town, bool townHa
{
buildID = 6 + town->fortLevel();
if (buildID == 6)
return;
return;//FIXME: suspicious statement, fix or comment
picture = new CAnimImage("ITMCL.DEF", town->fortLevel()-1);
}
building = town->town->buildings.at(BuildingID(buildID));
@ -1302,11 +1305,11 @@ CHallInterface::CBuildingBox::CBuildingBox(int x, int y, const CGTownInstance *
static int panelIndex[12] = { 3, 3, 3, 0, 0, 2, 2, 1, 2, 2, 3, 3};
static int iconIndex[12] = {-1, -1, -1, 0, 0, 1, 2, -1, 1, 1, -1, -1};
picture = new CAnimImage(town->town->clientInfo.buildingsIcons, building->bid, 0, 2, 2);
panel = new CAnimImage("TPTHBAR", panelIndex[state], 0, 1, 73);
if ( iconIndex[state] >=0 )
icon = new CAnimImage("TPTHCHK", iconIndex[state], 0, 136, 56);
label = new CLabel(75, 81, FONT_SMALL, CENTER, Colors::WHITE, building->Name());
new CAnimImage(town->town->clientInfo.buildingsIcons, building->bid, 0, 2, 2);
new CAnimImage("TPTHBAR", panelIndex[state], 0, 1, 73);
if (iconIndex[state] >=0)
new CAnimImage("TPTHCHK", iconIndex[state], 0, 136, 56);
new CLabel(75, 81, FONT_SMALL, CENTER, Colors::WHITE, building->Name());
//todo: add support for all possible states
if(state >= EBuildingState::BUILDING_ERROR)
@ -1427,12 +1430,12 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
std::string tooltipYes = boost::str(boost::format(CGI->generaltexth->allTexts[595]) % building->Name());
std::string tooltipNo = boost::str(boost::format(CGI->generaltexth->allTexts[596]) % building->Name());
buy = new CButton(Point(45, 446), "IBUY30", CButton::tooltip(tooltipYes), [&]{ buyFunc(); }, SDLK_RETURN);
CButton * buy = new CButton(Point(45, 446), "IBUY30", CButton::tooltip(tooltipYes), [&]{ buyFunc(); }, SDLK_RETURN);
buy->borderColor = Colors::METALLIC_GOLD;
cancel = new CButton(Point(290, 445), "ICANCEL", CButton::tooltip(tooltipNo), [&] { close();}, SDLK_ESCAPE);
cancel->borderColor = Colors::METALLIC_GOLD;
buy->block(state!=7 || LOCPLINT->playerID != town->tempOwner);
CButton * cancel = new CButton(Point(290, 445), "ICANCEL", CButton::tooltip(tooltipNo), [&] { close();}, SDLK_ESCAPE);
cancel->borderColor = Colors::METALLIC_GOLD;
}
}
@ -1597,10 +1600,11 @@ CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance *
addUsedEvents(LCLICK | RCLICK | HOVER);//Activate only if dwelling is present
icons = new CPicture("TPCAINFO", 261, 3);
if (getMyBuilding() != nullptr)
{
buildingPic = new CAnimImage(town->town->clientInfo.buildingsIcons, getMyBuilding()->bid, 0, 4, 21);
dwellingName = new CLabel(78, 101, FONT_SMALL, CENTER, Colors::WHITE, getMyBuilding()->Name());
new CAnimImage(town->town->clientInfo.buildingsIcons, getMyBuilding()->bid, 0, 4, 21);
new CLabel(78, 101, FONT_SMALL, CENTER, Colors::WHITE, getMyBuilding()->Name());
if (vstd::contains(town->builtBuildings, getMyBuilding()->bid))
{
@ -1613,8 +1617,8 @@ CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance *
if (getMyCreature() != nullptr)
{
hoverText = boost::str(boost::format(CGI->generaltexth->tcommands[21]) % getMyCreature()->namePl);
creatureAnim = new CCreaturePic(159, 4, getMyCreature(), false);
creatureName = new CLabel(78, 11, FONT_SMALL, CENTER, Colors::WHITE, getMyCreature()->namePl);
new CCreaturePic(159, 4, getMyCreature(), false);
new CLabel(78, 11, FONT_SMALL, CENTER, Colors::WHITE, getMyCreature()->namePl);
Rect sizes(287, 4, 96, 18);
values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[190], CGI->generaltexth->fcommands[0], getMyCreature()->Attack()));

View File

@ -240,12 +240,6 @@ class CHallInterface : public CWindowObject
const CBuilding * building;
ui32 state;//Buildings::EBuildStructure enum
CAnimImage * picture;
CAnimImage * panel;
CAnimImage * icon;
CLabel * label;
public:
CBuildingBox(int x, int y, const CGTownInstance * Town, const CBuilding * Building);
void hover(bool on) override;
@ -270,12 +264,8 @@ class CBuildWindow: public CWindowObject
const CGTownInstance *town;
const CBuilding *building;
CButton *buy;
CButton *cancel;
std::string getTextForState(int state);
void buyFunc();
public:
CBuildWindow(const CGTownInstance *Town, const CBuilding * building, int State, bool rightClick); //c-tor
};
@ -303,14 +293,10 @@ class CFortScreen : public CWindowObject
int level;
std::string hoverText;
CLabel * creatureName;
CLabel * dwellingName;
CLabel * availableCount;
std::vector<LabeledValue*> values;
CPicture *icons;
CAnimImage * buildingPic;
CCreaturePic *creatureAnim;
const CCreature * getMyCreature();
const CBuilding * getMyBuilding();

View File

@ -103,7 +103,7 @@ StackWindowInfo::StackWindowInfo():
void CStackWindow::CWindowSection::createBackground(std::string path)
{
background = new CPicture("stackWindow/" + path);
CPicture * background = new CPicture("stackWindow/" + path);
pos = background->pos;
}

View File

@ -49,8 +49,6 @@ class CStackWindow : public CWindowObject
{
CStackWindow *parent;
CPicture *background;
void createBackground(std::string path);
void createBonusItem(size_t index, Point position);

View File

@ -1771,11 +1771,10 @@ void CObjectListWindow::init(CIntObject * titlePic, std::string _title, std::str
if (titlePic)
{
titleImage = titlePic;
addChild(titleImage);
titleImage->recActions = defActions;
titleImage->pos.x = pos.w/2 + pos.x - titleImage->pos.w/2;
titleImage->pos.y =75 + pos.y - titleImage->pos.h/2;
addChild(titlePic);
titlePic->recActions = defActions;
titlePic->pos.x = pos.w/2 + pos.x - titlePic->pos.w/2;
titlePic->pos.y =75 + pos.y - titlePic->pos.h/2;
}
list = new CListBox(std::bind(&CObjectListWindow::genItem, this, _1), CListBox::DestroyFunc(),
Point(14, 151), Point(0, 25), 9, items.size(), 0, 1, Rect(262, -32, 256, 256) );

View File

@ -161,7 +161,6 @@ class CObjectListWindow : public CWindowObject
CLabel * descr;
CListBox * list;
CIntObject * titleImage;//title image (castle gate\town portal picture)
CButton *ok, *exit;
std::vector< std::pair<int, std::string> > items;//all items present in list
@ -243,7 +242,6 @@ public:
} *h1, *h2; //recruitable heroes
CGStatusBar *bar; //tavern's internal status bar
int selected;//0 (left) or 1 (right)
int oldSelected;//0 (left) or 1 (right)

View File

@ -47,7 +47,6 @@ public:
CTextBox *text;
std::vector<CButton *> buttons;
std::vector<CComponent*> components;
CSlider *slider;
void setDelComps(bool DelComps);
virtual void close();