1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-05-13 22:06:58 +02:00

Merge pull request #3095 from Laserlicht/team_alignment

fix team alignments
This commit is contained in:
Nordsoft91 2023-10-26 23:19:18 +02:00 committed by GitHub
commit 8f2b50a5e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 7 deletions

View File

@ -540,6 +540,7 @@ std::shared_ptr<CFilledTexture> InterfaceObjectConfigurable::buildTexture(const
{
auto result = std::make_shared<FilledTexturePlayerColored>(image, rect);
result->playerColored(playerColor);
return result;
}
return std::make_shared<CFilledTexture>(image, rect);
}

View File

@ -107,7 +107,7 @@ RandomMapTab::RandomMapTab():
//new callbacks available only from mod
addCallback("teamAlignments", [&](int)
{
GH.windows().createAndPushWindow<TeamAlignmentsWidget>(*this);
GH.windows().createAndPushWindow<TeamAlignments>(*this);
});
for(auto road : VLC->roadTypeHandler->objects)
@ -397,6 +397,18 @@ std::vector<int> RandomMapTab::getPossibleMapSizes()
return {CMapHeader::MAP_SIZE_SMALL, CMapHeader::MAP_SIZE_MIDDLE, CMapHeader::MAP_SIZE_LARGE, CMapHeader::MAP_SIZE_XLARGE, CMapHeader::MAP_SIZE_HUGE, CMapHeader::MAP_SIZE_XHUGE, CMapHeader::MAP_SIZE_GIANT};
}
TeamAlignments::TeamAlignments(RandomMapTab & randomMapTab)
: CWindowObject(BORDERED)
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
widget = std::make_shared<TeamAlignmentsWidget>(randomMapTab);
pos = widget->pos;
updateShadow();
center();
}
TeamAlignmentsWidget::TeamAlignmentsWidget(RandomMapTab & randomMapTab):
InterfaceObjectConfigurable()
{
@ -413,8 +425,8 @@ TeamAlignmentsWidget::TeamAlignmentsWidget(RandomMapTab & randomMapTab):
pos.w = variables["windowSize"]["x"].Integer() + totalPlayers * variables["cellMargin"]["x"].Integer();
pos.h = variables["windowSize"]["y"].Integer() + totalPlayers * variables["cellMargin"]["y"].Integer();
variables["backgroundRect"]["x"].Integer() = pos.x;
variables["backgroundRect"]["y"].Integer() = pos.y;
variables["backgroundRect"]["x"].Integer() = 0;
variables["backgroundRect"]["y"].Integer() = 0;
variables["backgroundRect"]["w"].Integer() = pos.w;
variables["backgroundRect"]["h"].Integer() = pos.h;
variables["okButtonPosition"]["x"].Integer() = variables["buttonsOffset"]["ok"]["x"].Integer();
@ -429,14 +441,15 @@ TeamAlignmentsWidget::TeamAlignmentsWidget(RandomMapTab & randomMapTab):
randomMapTab.obtainMapGenOptions().setPlayerTeam(PlayerColor(plId), TeamID(players[plId]->getSelected()));
}
randomMapTab.updateMapInfoByHost();
assert(GH.windows().isTopWindow(this));
GH.windows().popWindows(1);
for(auto & window : GH.windows().findWindows<TeamAlignments>())
GH.windows().popWindow(window);
});
addCallback("cancel", [&](int)
{
assert(GH.windows().isTopWindow(this));
GH.windows().popWindows(1);
for(auto & window : GH.windows().findWindows<TeamAlignments>())
GH.windows().popWindow(window);
});
build(config);

View File

@ -63,3 +63,10 @@ private:
std::vector<std::shared_ptr<CToggleGroup>> players;
std::vector<std::shared_ptr<CIntObject>> placeholders;
};
class TeamAlignments: public CWindowObject
{
std::shared_ptr<TeamAlignmentsWidget> widget;
public:
TeamAlignments(RandomMapTab & randomMapTab);
};