From 8461189e9501971288dcc645c27b8832312b5d10 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Sat, 28 Sep 2024 16:10:03 +0200 Subject: [PATCH] code review + text --- client/NetPacksClient.cpp | 2 +- client/windows/CCastleInterface.cpp | 18 +++++++++--------- client/windows/CCastleInterface.h | 2 +- config/gameConfig.json | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/client/NetPacksClient.cpp b/client/NetPacksClient.cpp index 75618089f..d403120a7 100644 --- a/client/NetPacksClient.cpp +++ b/client/NetPacksClient.cpp @@ -176,7 +176,7 @@ void ApplyClientNetPackVisitor::visitSetMovePoints(SetMovePoints & pack) void ApplyClientNetPackVisitor::visitSetResearchedSpells(SetResearchedSpells & pack) { for(const auto & win : GH.windows().findWindows()) - win->updateSpells(); + win->updateSpells(pack.tid); } void ApplyClientNetPackVisitor::visitFoWChange(FoWChange & pack) diff --git a/client/windows/CCastleInterface.cpp b/client/windows/CCastleInterface.cpp index 8bc898ddc..bd129ea4a 100644 --- a/client/windows/CCastleInterface.cpp +++ b/client/windows/CCastleInterface.cpp @@ -1982,11 +1982,14 @@ CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner, const ImagePath & i exit = std::make_shared(Point(748, 556), AnimationPath::builtin("TPMAGE1.DEF"), CButton::tooltip(CGI->generaltexth->allTexts[593]), [&](){ close(); }, EShortcut::GLOBAL_RETURN); - updateSpells(); + updateSpells(townId); } -void CMageGuildScreen::updateSpells() +void CMageGuildScreen::updateSpells(ObjectInstanceID tID) { + if(tID != townId) + return; + OBJECT_CONSTRUCTION; static const std::vector > positions = { @@ -2063,15 +2066,12 @@ void CMageGuildScreen::Scroll::clickPressed(const Point & cursorPosition) pom.emplace_back(AnimationPath::builtin("ibuy30.DEF"), nullptr); pom.emplace_back(AnimationPath::builtin("hsbtns4.DEF"), nullptr); pom.emplace_back(AnimationPath::builtin("ICANCEL.DEF"), nullptr); - auto temp = std::make_shared(CGI->generaltexth->translate("vcmi.spellResearch.pay"), LOCPLINT->playerID, resComps, pom); + auto text = CGI->generaltexth->translate(LOCPLINT->cb->getResourceAmount().canAfford(cost) ? "vcmi.spellResearch.pay" : "vcmi.spellResearch.canNotAfford"); + auto temp = std::make_shared(text, LOCPLINT->playerID, resComps, pom); - temp->buttons[0]->addCallback([this, resComps, town, cost](){ - if(LOCPLINT->cb->getResourceAmount().canAfford(cost)) - LOCPLINT->cb->spellResearch(town, spell->id, true); - else - LOCPLINT->showInfoDialog(CGI->generaltexth->translate("vcmi.spellResearch.canNotAfford"), resComps); - }); + temp->buttons[0]->addCallback([this, resComps, town, cost](){ LOCPLINT->cb->spellResearch(town, spell->id, true); }); temp->buttons[0]->addPopupCallback([](){ CRClickPopup::createAndPush(CGI->generaltexth->translate("vcmi.spellResearch.research")); }); + temp->buttons[0]->setEnabled(LOCPLINT->cb->getResourceAmount().canAfford(cost)); temp->buttons[1]->addCallback([this, town](){ LOCPLINT->cb->spellResearch(town, spell->id, false); }); temp->buttons[1]->addPopupCallback([](){ CRClickPopup::createAndPush(CGI->generaltexth->translate("vcmi.spellResearch.skip")); }); temp->buttons[2]->addPopupCallback([](){ CRClickPopup::createAndPush(CGI->generaltexth->translate("vcmi.spellResearch.abort")); }); diff --git a/client/windows/CCastleInterface.h b/client/windows/CCastleInterface.h index b5fd3d7ab..717c1a748 100644 --- a/client/windows/CCastleInterface.h +++ b/client/windows/CCastleInterface.h @@ -398,7 +398,7 @@ class CMageGuildScreen : public CStatusbarWindow public: CMageGuildScreen(CCastleInterface * owner, const ImagePath & image); - void updateSpells(); + void updateSpells(ObjectInstanceID tID); }; /// The blacksmith window where you can buy available in town war machine diff --git a/config/gameConfig.json b/config/gameConfig.json index 08f2ce659..a2330ec2b 100644 --- a/config/gameConfig.json +++ b/config/gameConfig.json @@ -319,7 +319,7 @@ // Costs depends on level for an spell research "spellResearchCostPerLevel": { "wood" : 2, "mercury": 2, "ore": 2, "sulfur": 2, "crystal": 2, "gems": 2 }, // Exponent for increasing cost for each research - "spellResearchCostExponentPerResearch": 1.5 + "spellResearchCostExponentPerResearch": 1.25 }, "combat":