1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Adding macros for targeted object binding

This commit is contained in:
nordsoft
2022-12-22 00:54:06 +04:00
parent d7b0770b71
commit 521328addd
3 changed files with 5 additions and 4 deletions

View File

@@ -165,6 +165,7 @@ struct 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_CUSTOM_CAPTURING(actions) SSetCaptureState obj__i1(true, actions); SObjectConstruction obj__i(this)

View File

@@ -27,7 +27,7 @@
InterfaceObjectConfigurable::InterfaceObjectConfigurable(const JsonNode & config, int used, Point offset):
CIntObject(used, offset)
InterfaceObjectConfigurable(used, offset)
{
init(config);
}
@@ -202,7 +202,7 @@ std::shared_ptr<CToggleGroup> InterfaceObjectConfigurable::buildToggleGroup(cons
group->pos += position;
if(!config["items"].isNull())
{
SObjectConstruction obj__i(group.get());
OBJ_CONSTRUCTION_TARGETED(group.get());
int itemIdx = -1;
for(const auto & item : config["items"].Vector())
{

View File

@@ -533,7 +533,7 @@ TeamAlignmentsWidget::TeamAlignmentsWidget(RandomMapTab & randomMapTab):
players.push_back(std::make_shared<CToggleGroup>([&, totalPlayers, plId](int sel)
{
variables["player_id"].Integer() = plId;
SObjectConstruction obj__i(players[plId].get());
OBJ_CONSTRUCTION_TARGETED(players[plId].get());
for(int teamId = 0; teamId < totalPlayers; ++teamId)
{
auto button = std::dynamic_pointer_cast<CToggleButton>(players[plId]->buttons[teamId]);
@@ -549,7 +549,7 @@ TeamAlignmentsWidget::TeamAlignmentsWidget(RandomMapTab & randomMapTab):
}
}));
SObjectConstruction obj__i(players.back().get());
OBJ_CONSTRUCTION_TARGETED(players.back().get());
for(int teamId = 0; teamId < totalPlayers; ++teamId)
{
variables["point"]["x"].Integer() = variables["cellOffset"]["x"].Integer() + plId * variables["cellMargin"]["x"].Integer();