mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Merge pull request #928 from kambala-decapitator/quick-recruit-no-creatures
show message instead of the Quick Recruit dialog when there're no creatures in town
This commit is contained in:
commit
43a1a8b76d
@ -10,10 +10,11 @@
|
||||
#include "StdInc.h"
|
||||
#include "CAnimation.h"
|
||||
|
||||
#include "SDL_Extensions.h"
|
||||
#include "SDL_Pixels.h"
|
||||
|
||||
#include "../CBitmapHandler.h"
|
||||
#include "../Graphics.h"
|
||||
#include "../gui/SDL_Extensions.h"
|
||||
#include "../gui/SDL_Pixels.h"
|
||||
|
||||
#include "../lib/filesystem/Filesystem.h"
|
||||
#include "../lib/filesystem/ISimpleResourceLoader.h"
|
||||
|
@ -9,9 +9,10 @@
|
||||
*/
|
||||
|
||||
#include "StdInc.h"
|
||||
#include "../mainmenu/CMainMenu.h"
|
||||
#include "CCampaignScreen.h"
|
||||
|
||||
#include "CMainMenu.h"
|
||||
|
||||
#include "../CGameInfo.h"
|
||||
#include "../CMessage.h"
|
||||
#include "../CBitmapHandler.h"
|
||||
|
@ -9,6 +9,8 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../windows/CWindowObject.h"
|
||||
|
||||
class CLabel;
|
||||
class CPicture;
|
||||
class CButton;
|
||||
|
@ -9,9 +9,10 @@
|
||||
*/
|
||||
|
||||
#include "StdInc.h"
|
||||
|
||||
#include "CreditsScreen.h"
|
||||
#include "../mainmenu/CMainMenu.h"
|
||||
|
||||
#include "CMainMenu.h"
|
||||
|
||||
#include "../gui/CGuiHandler.h"
|
||||
#include "../widgets/TextControls.h"
|
||||
#include "../widgets/ObjectLists.h"
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "MiscWidgets.h"
|
||||
#include "CComponent.h"
|
||||
#include "Images.h"
|
||||
|
||||
#include "../CGameInfo.h"
|
||||
#include "../CMusicHandler.h"
|
||||
@ -26,8 +27,6 @@
|
||||
#include "../gui/SDL_Pixels.h"
|
||||
#include "../gui/SDL_Compat.h"
|
||||
|
||||
#include "../widgets/Images.h"
|
||||
|
||||
#include "../windows/InfoWindows.h"
|
||||
#include "../windows/CAdvmapInterface.h"
|
||||
#include "../windows/GUIClasses.h"
|
||||
|
@ -10,6 +10,9 @@
|
||||
#include "StdInc.h"
|
||||
#include "CComponent.h"
|
||||
|
||||
#include "CArtifactHolder.h"
|
||||
#include "Images.h"
|
||||
|
||||
#include <vcmi/spells/Service.h>
|
||||
#include <vcmi/spells/Spell.h>
|
||||
|
||||
@ -18,8 +21,6 @@
|
||||
|
||||
#include "../CMessage.h"
|
||||
#include "../CGameInfo.h"
|
||||
#include "../widgets/Images.h"
|
||||
#include "../widgets/CArtifactHolder.h"
|
||||
#include "../windows/CAdvmapInterface.h"
|
||||
|
||||
#include "../../lib/CArtHandler.h"
|
||||
|
@ -10,12 +10,13 @@
|
||||
#include "StdInc.h"
|
||||
#include "CGarrisonInt.h"
|
||||
|
||||
#include "Buttons.h"
|
||||
#include "TextControls.h"
|
||||
|
||||
#include "../gui/CGuiHandler.h"
|
||||
|
||||
#include "../CGameInfo.h"
|
||||
#include "../CPlayerInterface.h"
|
||||
#include "../widgets/Buttons.h"
|
||||
#include "../widgets/TextControls.h"
|
||||
#include "../windows/CCreatureWindow.h"
|
||||
#include "../windows/GUIClasses.h"
|
||||
|
||||
|
@ -14,8 +14,9 @@
|
||||
#include "CHeroWindow.h"
|
||||
#include "CKingdomInterface.h"
|
||||
#include "CSpellWindow.h"
|
||||
#include "GUIClasses.h"
|
||||
#include "CTradeWindow.h"
|
||||
#include "GUIClasses.h"
|
||||
#include "InfoWindows.h"
|
||||
|
||||
#include "../CBitmapHandler.h"
|
||||
#include "../CGameInfo.h"
|
||||
@ -35,7 +36,6 @@
|
||||
#include "../gui/CGuiHandler.h"
|
||||
#include "../gui/SDL_Extensions.h"
|
||||
#include "../widgets/MiscWidgets.h"
|
||||
#include "../windows/InfoWindows.h"
|
||||
|
||||
#include "../../CCallback.h"
|
||||
|
||||
@ -1217,7 +1217,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
||||
if(itr != LOCPLINT->towns.end())
|
||||
LOCPLINT->showThievesGuildWindow(*itr);
|
||||
else
|
||||
LOCPLINT->showInfoDialog("No available town with tavern!");
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->localizedTexts["adventureMap"]["noTownWithTavern"].String());
|
||||
}
|
||||
return;
|
||||
case SDLK_i:
|
||||
@ -1249,7 +1249,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
||||
case SDLK_r:
|
||||
if(isActive() && LOCPLINT->ctrlPressed())
|
||||
{
|
||||
LOCPLINT->showYesNoDialog("Are you sure you want to restart game?",
|
||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->localizedTexts["adventureMap"]["confirmRestartGame"].String(),
|
||||
[](){ LOCPLINT->sendCustomEvent(EUserEvent::RESTART_GAME); }, nullptr);
|
||||
}
|
||||
return;
|
||||
@ -1308,7 +1308,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
||||
if(townWithMarket) //if any town has marketplace, open window
|
||||
GH.pushIntT<CMarketplaceWindow>(townWithMarket);
|
||||
else //if not - complain
|
||||
LOCPLINT->showInfoDialog("No available marketplace!");
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->localizedTexts["adventureMap"]["noTownWithMarket"].String());
|
||||
}
|
||||
else if(isActive()) //no ctrl, advmapint is on the top => switch to town
|
||||
{
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "CAdvmapInterface.h"
|
||||
#include "CHeroWindow.h"
|
||||
#include "CTradeWindow.h"
|
||||
#include "InfoWindows.h"
|
||||
#include "GUIClasses.h"
|
||||
#include "QuickRecruitmentWindow.h"
|
||||
|
||||
@ -24,7 +25,6 @@
|
||||
#include "../Graphics.h"
|
||||
#include "../gui/CGuiHandler.h"
|
||||
#include "../gui/SDL_Extensions.h"
|
||||
#include "../windows/InfoWindows.h"
|
||||
#include "../widgets/MiscWidgets.h"
|
||||
#include "../widgets/CComponent.h"
|
||||
|
||||
@ -842,7 +842,16 @@ void CCastleBuildings::enterDwelling(int level)
|
||||
|
||||
void CCastleBuildings::enterToTheQuickRecruitmentWindow()
|
||||
{
|
||||
GH.pushIntT<QuickRecruitmentWindow>(town, pos);
|
||||
const auto beginIt = town->creatures.cbegin();
|
||||
const auto afterLastIt = town->creatures.size() > GameConstants::CREATURES_PER_TOWN
|
||||
? std::next(beginIt, GameConstants::CREATURES_PER_TOWN)
|
||||
: town->creatures.cend();
|
||||
const auto hasSomeoneToRecruit = std::any_of(beginIt, afterLastIt,
|
||||
[](const auto & creatureInfo) { return creatureInfo.first > 0; });
|
||||
if(hasSomeoneToRecruit)
|
||||
GH.pushIntT<QuickRecruitmentWindow>(town, pos);
|
||||
else
|
||||
CInfoWindow::showInfoDialog(CGI->generaltexth->localizedTexts["townHall"]["noCreaturesToRecruit"].String(), {});
|
||||
}
|
||||
|
||||
void CCastleBuildings::enterFountain(const BuildingID & building, BuildingSubID::EBuildingSubID subID, BuildingID::EBuildingID upgrades)
|
||||
@ -1235,9 +1244,9 @@ void CCastleInterface::recreateIcons()
|
||||
hall = std::make_shared<CTownInfo>(80, 413, town, true);
|
||||
fort = std::make_shared<CTownInfo>(122, 413, town, false);
|
||||
|
||||
fastArmyPurhase = std::make_shared<CButton>(Point(122, 413), "itmcl.def", CButton::tooltip(), [&](){builds->enterToTheQuickRecruitmentWindow();});
|
||||
fastArmyPurhase->setImageOrder(town->fortLevel()-1, town->fortLevel()-1, town->fortLevel()-1, town->fortLevel()-1);
|
||||
fastArmyPurhase->setAnimateLonelyFrame(true);
|
||||
fastArmyPurchase = std::make_shared<CButton>(Point(122, 413), "itmcl.def", CButton::tooltip(), [&](){ builds->enterToTheQuickRecruitmentWindow(); });
|
||||
fastArmyPurchase->setImageOrder(town->fortLevel() - 1, town->fortLevel() - 1, town->fortLevel() - 1, town->fortLevel() - 1);
|
||||
fastArmyPurchase->setAnimateLonelyFrame(true);
|
||||
|
||||
creainfo.clear();
|
||||
|
||||
|
@ -209,7 +209,7 @@ class CCastleInterface : public CStatusbarWindow, public CGarrisonHolder
|
||||
|
||||
std::shared_ptr<CButton> exit;
|
||||
std::shared_ptr<CButton> split;
|
||||
std::shared_ptr<CButton> fastArmyPurhase;
|
||||
std::shared_ptr<CButton> fastArmyPurchase;
|
||||
|
||||
std::vector<std::shared_ptr<CCreaInfo>> creainfo;//small icons of creatures (bottom-left corner);
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "CAdvmapInterface.h"
|
||||
#include "CCastleInterface.h"
|
||||
#include "InfoWindows.h"
|
||||
|
||||
#include "../CGameInfo.h"
|
||||
#include "../CMT.h"
|
||||
@ -19,7 +20,6 @@
|
||||
#include "../gui/CGuiHandler.h"
|
||||
#include "../widgets/CComponent.h"
|
||||
#include "../widgets/MiscWidgets.h"
|
||||
#include "../windows/InfoWindows.h"
|
||||
|
||||
#include "../../CCallback.h"
|
||||
|
||||
|
@ -562,7 +562,7 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
|
||||
if(!texts.empty())
|
||||
owner->myInt->showInfoDialog(texts.front());
|
||||
else
|
||||
owner->myInt->showInfoDialog("Unknown problem with this spell, no more information available.");
|
||||
owner->myInt->showInfoDialog(CGI->generaltexth->localizedTexts["adventureMap"]["spellUnknownProblem"].String());
|
||||
}
|
||||
}
|
||||
else //adventure spell
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "StdInc.h"
|
||||
#include "CWindowObject.h"
|
||||
|
||||
#include "CAdvmapInterface.h"
|
||||
|
||||
#include "../widgets/MiscWidgets.h"
|
||||
|
||||
#include "../gui/SDL_Pixels.h"
|
||||
@ -26,7 +28,6 @@
|
||||
#include "../CPlayerInterface.h"
|
||||
#include "../CMessage.h"
|
||||
#include "../CMusicHandler.h"
|
||||
#include "../windows/CAdvmapInterface.h"
|
||||
|
||||
#include "../../CCallback.h"
|
||||
|
||||
@ -251,4 +252,4 @@ void CStatusbarWindow::activate()
|
||||
{
|
||||
CIntObject::activate();
|
||||
GH.statusbar = statusbar;
|
||||
}
|
||||
}
|
||||
|
@ -54,14 +54,14 @@ void CreaturePurchaseCard::switchCreatureLevel()
|
||||
void CreaturePurchaseCard::initAmountInfo()
|
||||
{
|
||||
availableAmount = std::make_shared<CLabel>(pos.x + 25, pos.y + 146, FONT_SMALL, CENTER, Colors::YELLOW);
|
||||
purhaseAmount = std::make_shared<CLabel>(pos.x + 76, pos.y + 146, FONT_SMALL, CENTER, Colors::WHITE);
|
||||
purchaseAmount = std::make_shared<CLabel>(pos.x + 76, pos.y + 146, FONT_SMALL, CENTER, Colors::WHITE);
|
||||
updateAmountInfo(0);
|
||||
}
|
||||
|
||||
void CreaturePurchaseCard::updateAmountInfo(int value)
|
||||
{
|
||||
availableAmount->setText(boost::lexical_cast<std::string>(maxAmount-value));
|
||||
purhaseAmount->setText(boost::lexical_cast<std::string>(value));
|
||||
purchaseAmount->setText(boost::lexical_cast<std::string>(value));
|
||||
}
|
||||
|
||||
void CreaturePurchaseCard::initSlider()
|
||||
|
@ -43,7 +43,7 @@ private:
|
||||
void initCostBox();
|
||||
|
||||
std::shared_ptr<CButton> maxButton, minButton, creatureSwitcher;
|
||||
std::shared_ptr<CLabel> availableAmount, purhaseAmount;
|
||||
std::shared_ptr<CLabel> availableAmount, purchaseAmount;
|
||||
std::shared_ptr<CCreaturePic> picture;
|
||||
std::shared_ptr<CreatureCostBox> cost;
|
||||
std::vector<CreatureID> upgradesID;
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "CCreatureWindow.h"
|
||||
#include "CHeroWindow.h"
|
||||
#include "CreatureCostBox.h"
|
||||
#include "InfoWindows.h"
|
||||
|
||||
#include "../CBitmapHandler.h"
|
||||
#include "../CGameInfo.h"
|
||||
@ -36,7 +37,6 @@
|
||||
|
||||
#include "../widgets/CComponent.h"
|
||||
#include "../widgets/MiscWidgets.h"
|
||||
#include "../windows/InfoWindows.h"
|
||||
|
||||
#include "../lobby/CSavingScreen.h"
|
||||
|
||||
|
@ -9,13 +9,13 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "CWindowObject.h"
|
||||
#include "../lib/GameConstants.h"
|
||||
#include "../lib/ResourceSet.h"
|
||||
#include "../lib/CConfigHandler.h"
|
||||
#include "../widgets/CArtifactHolder.h"
|
||||
#include "../widgets/CGarrisonInt.h"
|
||||
#include "../widgets/Images.h"
|
||||
#include "../windows/CWindowObject.h"
|
||||
|
||||
class CGDwelling;
|
||||
class CreatureCostBox;
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "StdInc.h"
|
||||
#include "InfoWindows.h"
|
||||
|
||||
#include "CAdvmapInterface.h"
|
||||
|
||||
#include "../CBitmapHandler.h"
|
||||
#include "../Graphics.h"
|
||||
#include "../CGameInfo.h"
|
||||
@ -17,7 +19,6 @@
|
||||
#include "../CMessage.h"
|
||||
#include "../CMusicHandler.h"
|
||||
|
||||
#include "../windows/CAdvmapInterface.h"
|
||||
#include "../widgets/CComponent.h"
|
||||
#include "../widgets/MiscWidgets.h"
|
||||
|
||||
|
@ -35,7 +35,7 @@ void QuickRecruitmentWindow::setCancelButton()
|
||||
|
||||
void QuickRecruitmentWindow::setBuyButton()
|
||||
{
|
||||
buyButton = std::make_shared<CButton>(Point((pos.w/2)-32, 418), "IBY6432.DEF", CButton::tooltip(), [&](){ purhaseUnits(); }, SDLK_RETURN);
|
||||
buyButton = std::make_shared<CButton>(Point((pos.w / 2) - 32, 418), "IBY6432.DEF", CButton::tooltip(), [&](){ purchaseUnits(); }, SDLK_RETURN);
|
||||
cancelButton->assignedKeys.insert(SDLK_ESCAPE);
|
||||
buyButton->setImageOrder(0, 1, 2, 3);
|
||||
}
|
||||
@ -46,7 +46,7 @@ void QuickRecruitmentWindow::setMaxButton()
|
||||
maxButton->setImageOrder(0, 1, 2, 3);
|
||||
}
|
||||
|
||||
void QuickRecruitmentWindow::setCreaturePurhaseCards()
|
||||
void QuickRecruitmentWindow::setCreaturePurchaseCards()
|
||||
{
|
||||
int availableAmount = getAvailableCreatures();
|
||||
Point position = Point((pos.w - 100*availableAmount - 8*(availableAmount-1))/2,64);
|
||||
@ -99,7 +99,7 @@ void QuickRecruitmentWindow::maxAllCards(std::vector<std::shared_ptr<CreaturePur
|
||||
}
|
||||
|
||||
|
||||
void QuickRecruitmentWindow::purhaseUnits()
|
||||
void QuickRecruitmentWindow::purchaseUnits()
|
||||
{
|
||||
for(auto selected : cards)
|
||||
{
|
||||
@ -154,6 +154,6 @@ QuickRecruitmentWindow::QuickRecruitmentWindow(const CGTownInstance * townd, Rec
|
||||
|
||||
initWindow(startupPosition);
|
||||
setButtons();
|
||||
setCreaturePurhaseCards();
|
||||
setCreaturePurchaseCards();
|
||||
maxAllCards(cards);
|
||||
}
|
||||
|
@ -31,11 +31,11 @@ private:
|
||||
void setBuyButton();
|
||||
void setMaxButton();
|
||||
|
||||
void setCreaturePurhaseCards();
|
||||
void setCreaturePurchaseCards();
|
||||
|
||||
void maxAllCards(std::vector<std::shared_ptr<CreaturePurchaseCard>> cards);
|
||||
void maxAllSlidersAmount(std::vector<std::shared_ptr<CreaturePurchaseCard>> cards);
|
||||
void purhaseUnits();
|
||||
void purchaseUnits();
|
||||
|
||||
const CGTownInstance * town;
|
||||
std::shared_ptr<CButton> maxButton, buyButton, cancelButton;
|
||||
|
@ -21,6 +21,10 @@
|
||||
"Impossible"
|
||||
]
|
||||
},
|
||||
"confirmRestartGame" : "Are you sure you want to restart game?",
|
||||
"noTownWithMarket": "No available marketplace!",
|
||||
"noTownWithTavern": "No available town with tavern!",
|
||||
"spellUnknownProblem": "Unknown problem with this spell, no more information available.",
|
||||
"playerAttacked" : "Player has been attacked: %s"
|
||||
},
|
||||
"systemOptions" :
|
||||
@ -44,6 +48,7 @@
|
||||
"townHall" :
|
||||
{
|
||||
"missingBase" : "Base building %s must be built first",
|
||||
"noCreaturesToRecruit" : "There are no creatures to recruit!",
|
||||
"greetingManaVortex" : "As you near the %s your body is filled with new energy. You have doubled your normal spell points.",
|
||||
"greetingKnowledge" : "You study the glyphs on the %s and gain insight into the workings of various magics (+1 Knowledge).",
|
||||
"greetingSpellPower" : "The %s teaches you new ways to focus your magical powers (+1 Power).",
|
||||
|
@ -156,7 +156,7 @@ ISimpleResourceLoader * CResourceHandler::createInitial()
|
||||
|
||||
void CResourceHandler::initialize()
|
||||
{
|
||||
// Create tree-loke structure that looks like this:
|
||||
// Create tree-like structure that looks like this:
|
||||
// root
|
||||
// |
|
||||
// |- initial
|
||||
|
Loading…
Reference in New Issue
Block a user