1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Remove largely unused defActions member from CIntObject

This commit is contained in:
Ivan Savenko 2024-08-09 14:26:53 +00:00
parent 3f9e57d3f3
commit 00605b5129
18 changed files with 18 additions and 54 deletions

View File

@ -137,7 +137,6 @@ CPlayerInterface::CPlayerInterface(PlayerColor Player):
{
logGlobal->trace("\tHuman player interface for player %s being constructed", Player.toString());
GH.defActionsDef = 0;
LOCPLINT = this;
playerID=Player;
human=true;
@ -1776,7 +1775,6 @@ void CPlayerInterface::proposeLoadingGame()
[]()
{
CSH->endGameplay();
GH.defActionsDef = 63;
CMM->menu->switchToTab("load");
},
nullptr

View File

@ -717,7 +717,6 @@ void CServerHandler::showHighScoresAndEndGameplay(PlayerColor player, bool victo
scenarioHighScores.isCampaign = false;
endGameplay();
GH.defActionsDef = 63;
CMM->menu->switchToTab("main");
GH.windows().createAndPushWindow<CHighScoreInputScreen>(victory, scenarioHighScores);
}
@ -948,7 +947,6 @@ void CServerHandler::onDisconnected(const std::shared_ptr<INetworkConnection> &
if(client)
{
endGameplay();
GH.defActionsDef = 63;
CMM->menu->switchToTab("main");
showServerError(CGI->generaltexth->translate("vcmi.server.errors.disconnected"));
}

View File

@ -325,7 +325,6 @@ void AdventureMapShortcuts::toMainMenu()
[]()
{
CSH->endGameplay();
GH.defActionsDef = 63;
CMM->menu->switchToTab("main");
},
0
@ -339,7 +338,6 @@ void AdventureMapShortcuts::newGame()
[]()
{
CSH->endGameplay();
GH.defActionsDef = 63;
CMM->menu->switchToTab("new");
},
nullptr

View File

@ -37,7 +37,6 @@ CList::CListItem::CListItem(CList * Parent)
parent(Parent),
selection()
{
defActions = 255-DISPOSE;
}
CList::CListItem::~CListItem() = default;

View File

@ -58,14 +58,11 @@ SSetCaptureState::SSetCaptureState(bool allow, ui8 actions)
{
previousCapture = GH.captureChildren;
GH.captureChildren = false;
prevActions = GH.defActionsDef;
GH.defActionsDef = actions;
}
SSetCaptureState::~SSetCaptureState()
{
GH.captureChildren = previousCapture;
GH.defActionsDef = prevActions;
}
void CGuiHandler::init()
@ -139,8 +136,7 @@ void CGuiHandler::renderFrame()
}
CGuiHandler::CGuiHandler()
: defActionsDef(0)
, captureChildren(false)
: captureChildren(false)
, curInt(nullptr)
, fakeStatusBar(std::make_shared<EmptyStatusBar>())
{

View File

@ -89,7 +89,6 @@ public:
IUpdateable *curInt;
ui8 defActionsDef; //default auto actions
bool captureChildren; //all newly created objects will get their parents from stack and will be added to parents children list
std::list<CIntObject *> createdObj; //stack of objs being created
@ -124,14 +123,13 @@ struct SObjectConstruction
struct SSetCaptureState
{
bool previousCapture;
ui8 prevActions;
SSetCaptureState(bool allow, ui8 actions);
~SSetCaptureState();
};
#define OBJ_CONSTRUCTION SObjectConstruction obj__i(this)
#define OBJ_CONSTRUCTION_TARGETED(obj) SObjectConstruction obj__i(obj)
#define OBJECT_CONSTRUCTION_CAPTURING(actions) defActions = actions; SSetCaptureState obj__i1(true, actions); SObjectConstruction obj__i(this)
#define OBJECT_CONSTRUCTION_CAPTURING(actions) SSetCaptureState obj__i1(true, actions); SObjectConstruction obj__i(this)
#define OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(actions) SSetCaptureState obj__i1(true, actions); SObjectConstruction obj__i(this)
#define OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE defActions = 255 - DISPOSE; SSetCaptureState obj__i1(true, 255 - DISPOSE); SObjectConstruction obj__i(this)
#define OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE SSetCaptureState obj__i1(true, 255 - DISPOSE); SObjectConstruction obj__i(this)

View File

@ -24,8 +24,7 @@ CIntObject::CIntObject(int used_, Point pos_):
redrawParent(false),
inputEnabled(true),
used(used_),
recActions(GH.defActionsDef),
defActions(GH.defActionsDef),
recActions(ALL_ACTIONS),
pos(pos_, Point())
{
if(GH.captureChildren)
@ -39,7 +38,7 @@ CIntObject::~CIntObject()
while(!children.empty())
{
if((defActions & DISPOSE) && (children.front()->recActions & DISPOSE))
if(children.front()->recActions & DISPOSE)
delete children.front();
else
removeChild(children.front());
@ -51,20 +50,16 @@ CIntObject::~CIntObject()
void CIntObject::show(Canvas & to)
{
if(defActions & UPDATE)
for(auto & elem : children)
if(elem->recActions & UPDATE)
elem->show(to);
for(auto & elem : children)
if(elem->recActions & UPDATE)
elem->show(to);
}
void CIntObject::showAll(Canvas & to)
{
if(defActions & SHOWALL)
{
for(auto & elem : children)
if(elem->recActions & SHOWALL)
elem->showAll(to);
}
for(auto & elem : children)
if(elem->recActions & SHOWALL)
elem->showAll(to);
}
void CIntObject::activate()
@ -79,10 +74,9 @@ void CIntObject::activate()
assert(isActive());
if(defActions & ACTIVATE)
for(auto & elem : children)
if(elem->recActions & ACTIVATE)
elem->activate();
for(auto & elem : children)
if(elem->recActions & ACTIVATE)
elem->activate();
}
void CIntObject::deactivate()
@ -94,10 +88,9 @@ void CIntObject::deactivate()
assert(!isActive());
if(defActions & DEACTIVATE)
for(auto & elem : children)
if(elem->recActions & DEACTIVATE)
elem->deactivate();
for(auto & elem : children)
if(elem->recActions & DEACTIVATE)
elem->deactivate();
}
void CIntObject::addUsedEvents(ui16 newActions)

View File

@ -73,8 +73,7 @@ public:
void addUsedEvents(ui16 newActions);
void removeUsedEvents(ui16 newActions);
enum {ACTIVATE=1, DEACTIVATE=2, UPDATE=4, SHOWALL=8, DISPOSE=16, SHARE_POS=32};
ui8 defActions; //which calls will be tried to be redirected to children
enum {ACTIVATE=1, DEACTIVATE=2, UPDATE=4, SHOWALL=8, DISPOSE=16, SHARE_POS=32, ALL_ACTIONS=255-DISPOSE};
ui8 recActions; //which calls we allow to receive from parent
/// deactivates if needed, blocks all automatic activity, allows only disposal

View File

@ -993,7 +993,6 @@ OptionsTab::PlayerOptionsEntry::PlayerOptionsEntry(const PlayerSettings & S, con
, name(S.name)
{
OBJ_CONSTRUCTION;
defActions |= SHARE_POS;
int serial = 0;
for(PlayerColor g = PlayerColor(0); g < s->color; ++g)

View File

@ -289,7 +289,6 @@ CMainMenu::CMainMenu()
pos.w = GH.screenDimensions().x;
pos.h = GH.screenDimensions().y;
GH.defActionsDef = 63;
menu = std::make_shared<CMenuScreen>(CMainMenuConfig::get().getConfig()["window"]);
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
backgroundAroundMenu = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), pos);

View File

@ -356,7 +356,6 @@ CButton::CButton(Point position, const AnimationPath &defName, const std::pair<s
hoverable(false),
soundDisabled(false)
{
defActions = 255-DISPOSE;
addUsedEvents(LCLICK | SHOW_POPUP | HOVER | KEYBOARD);
hoverTexts[0] = help.first;
}

View File

@ -442,7 +442,6 @@ void CComponentBox::placeComponents(bool selectable)
for(auto & comp : components)
{
addChild(comp.get());
comp->recActions = defActions; //FIXME: for some reason, received component might have recActions set to 0
comp->moveTo(Point(pos.x, pos.y));
}

View File

@ -625,7 +625,6 @@ MoraleLuckBox::MoraleLuckBox(bool Morale, const Rect &r, bool Small)
small(Small)
{
pos = r + pos.topLeft();
defActions = 255-DISPOSE;
}
CCreaturePic::CCreaturePic(int x, int y, const CCreature * cre, bool Big, bool Animated)

View File

@ -33,7 +33,6 @@ std::shared_ptr<CIntObject> CObjectList::createItem(size_t index)
if(!item)
item = std::make_shared<CIntObject>();
item->recActions = defActions;
addChild(item.get());
if (isActive())
item->activate();
@ -45,7 +44,6 @@ CTabbedInt::CTabbedInt(CreateFunc create, Point position, size_t ActiveID)
activeTab(nullptr),
activeID(ActiveID)
{
defActions &= ~DISPOSE;
pos += position;
reset();
}

View File

@ -339,7 +339,6 @@ Rect CMultiLineLabel::getTextLocation()
CLabelGroup::CLabelGroup(EFonts Font, ETextAlignment Align, const ColorRGBA & Color)
: font(Font), align(Align), color(Color)
{
defActions = 255 - DISPOSE;
}
void CLabelGroup::add(int x, int y, const std::string & text)

View File

@ -41,8 +41,6 @@ CWindowObject::CWindowObject(int options_, const ImagePath & imageName, Point ce
if(!(options & NEEDS_ANIMATED_BACKGROUND)) //currently workaround for highscores (currently uses window as normal control, because otherwise videos are not played in background yet)
assert(parent == nullptr); //Safe to remove, but windows should not have parent
defActions = 255-DISPOSE;
if (options & RCLICK_POPUP)
CCS->curh->hide();
@ -63,8 +61,6 @@ CWindowObject::CWindowObject(int options_, const ImagePath & imageName):
if(!(options & NEEDS_ANIMATED_BACKGROUND)) //currently workaround for highscores (currently uses window as normal control, because otherwise videos are not played in background yet)
assert(parent == nullptr); //Safe to remove, but windows should not have parent
defActions = 255-DISPOSE;
if(options & RCLICK_POPUP)
CCS->curh->hide();

View File

@ -248,8 +248,6 @@ void CRClickPopup::createAndPush(const CGObjectInstance * obj, const Point & p,
CRClickPopupInt::CRClickPopupInt(const std::shared_ptr<CIntObject> & our)
{
CCS->curh->hide();
defActions = 255-DISPOSE;
our->recActions = defActions;
inner = our;
addChild(our.get(), false);
}

View File

@ -144,7 +144,6 @@ void SettingsMainWindow::mainMenuButtonCallback()
{
close();
CSH->endGameplay();
GH.defActionsDef = 63;
CMM->menu->switchToTab("main");
},
0