1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Merge pull request #6156 from Laserlicht/butgen

adventure map config button generation
This commit is contained in:
Ivan Savenko
2025-09-28 18:47:20 +03:00
committed by GitHub
6 changed files with 102 additions and 33 deletions

View File

@@ -21,6 +21,7 @@
#include "../GameInstance.h"
#include "../gui/Shortcut.h"
#include "../mapView/MapView.h"
#include "../render/AssetGenerator.h"
#include "../render/IImage.h"
#include "../render/IRenderHandler.h"
#include "../widgets/Buttons.h"
@@ -153,6 +154,15 @@ std::shared_ptr<CIntObject> AdventureMapWidget::buildMapButton(const JsonNode &
auto help = readHintText(input["help"]);
bool playerColored = input["playerColored"].Bool();
if(!input["generateFromBaseImage"].isNull())
{
bool small = input["generateSmall"].Bool();
auto assetGenerator = ENGINE->renderHandler().getAssetGenerator();
auto layout = assetGenerator->createAdventureMapButton(ImagePath::fromJson(input["generateFromBaseImage"]), small);
assetGenerator->addAnimationFile(AnimationPath::builtin("SPRITES/" + input["image"].String()), layout);
ENGINE->renderHandler().updateGeneratedAssets();
}
auto button = std::make_shared<CButton>(position.topLeft(), image, help, 0, EShortcut::NONE, playerColored);
loadButtonBorderColor(button, input["borderColor"]);