mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
commit
648e8c7acb
@ -30,6 +30,11 @@
|
||||
"vcmi.capitalColors.6" : "Teal",
|
||||
"vcmi.capitalColors.7" : "Pink",
|
||||
|
||||
"vcmi.heroOverview.startingArmy" : "Starting Units",
|
||||
"vcmi.heroOverview.warMachine" : "War Machines",
|
||||
"vcmi.heroOverview.secondarySkills" : "Secondary Skills",
|
||||
"vcmi.heroOverview.spells" : "Spells",
|
||||
|
||||
"vcmi.radialWheel.mergeSameUnit" : "Merge same creatures",
|
||||
"vcmi.radialWheel.fillSingleUnit" : "Fill with single creatures",
|
||||
"vcmi.radialWheel.splitSingleUnit" : "Split off single creature",
|
||||
|
@ -30,6 +30,11 @@
|
||||
"vcmi.capitalColors.6" : "Türkis",
|
||||
"vcmi.capitalColors.7" : "Rosa",
|
||||
|
||||
"vcmi.heroOverview.startingArmy" : "Starteinheiten",
|
||||
"vcmi.heroOverview.warMachine" : "Kriegsmaschinen",
|
||||
"vcmi.heroOverview.secondarySkills" : "Sekundäre Skills",
|
||||
"vcmi.heroOverview.spells" : "Zaubersprüche",
|
||||
|
||||
"vcmi.radialWheel.mergeSameUnit" : "Gleiche Kreaturen zusammenführen",
|
||||
"vcmi.radialWheel.splitSingleUnit" : "Wegtrennen einzelner Kreaturen",
|
||||
"vcmi.radialWheel.splitUnitEqually" : "Gleichmäßiges trennen der Kreaturen",
|
||||
|
@ -114,6 +114,7 @@ set(client_SRCS
|
||||
|
||||
windows/CCastleInterface.cpp
|
||||
windows/CCreatureWindow.cpp
|
||||
windows/CHeroOverview.cpp
|
||||
windows/CHeroWindow.cpp
|
||||
windows/CKingdomInterface.cpp
|
||||
windows/CMessage.cpp
|
||||
@ -276,6 +277,7 @@ set(client_HEADERS
|
||||
|
||||
windows/CCastleInterface.h
|
||||
windows/CCreatureWindow.h
|
||||
windows/CHeroOverview.h
|
||||
windows/CHeroWindow.h
|
||||
windows/CKingdomInterface.h
|
||||
windows/CMessage.h
|
||||
|
@ -225,6 +225,8 @@
|
||||
<Unit filename="windows/CCastleInterface.h" />
|
||||
<Unit filename="windows/CCreatureWindow.cpp" />
|
||||
<Unit filename="windows/CCreatureWindow.h" />
|
||||
<Unit filename="windows/CHeroOverview.cpp" />
|
||||
<Unit filename="windows/CHeroOverview.h" />
|
||||
<Unit filename="windows/CHeroWindow.cpp" />
|
||||
<Unit filename="windows/CHeroWindow.h" />
|
||||
<Unit filename="windows/CKingdomInterface.cpp" />
|
||||
|
@ -236,6 +236,7 @@
|
||||
<ClCompile Include="windows\CAdvmapInterface.cpp" />
|
||||
<ClCompile Include="windows\CCastleInterface.cpp" />
|
||||
<ClCompile Include="windows\CCreatureWindow.cpp" />
|
||||
<ClCompile Include="windows\CHeroOverview.cpp" />
|
||||
<ClCompile Include="windows\CHeroWindow.cpp" />
|
||||
<ClCompile Include="windows\CKingdomInterface.cpp" />
|
||||
<ClCompile Include="windows\CQuestLog.cpp" />
|
||||
@ -301,6 +302,7 @@
|
||||
<ClInclude Include="windows\CAdvmapInterface.h" />
|
||||
<ClInclude Include="windows\CCastleInterface.h" />
|
||||
<ClInclude Include="windows\CCreatureWindow.h" />
|
||||
<ClInclude Include="windows\CHeroOverview.h" />
|
||||
<ClInclude Include="windows\CHeroWindow.h" />
|
||||
<ClInclude Include="windows\CKingdomInterface.h" />
|
||||
<ClInclude Include="windows\CQuestLog.h" />
|
||||
|
@ -22,6 +22,9 @@
|
||||
<ClCompile Include="windows\CCreatureWindow.cpp">
|
||||
<Filter>windows</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="windows\CHeroOverview.cpp">
|
||||
<Filter>windows</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="windows\CHeroWindow.cpp">
|
||||
<Filter>windows</Filter>
|
||||
</ClCompile>
|
||||
@ -172,6 +175,9 @@
|
||||
<ClInclude Include="windows\CCreatureWindow.h">
|
||||
<Filter>windows</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="windows\CHeroOverview.h">
|
||||
<Filter>windows</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="windows\CHeroWindow.h">
|
||||
<Filter>windows</Filter>
|
||||
</ClInclude>
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "../widgets/TextControls.h"
|
||||
#include "../windows/GUIClasses.h"
|
||||
#include "../windows/InfoWindows.h"
|
||||
#include "../windows/CHeroOverview.h"
|
||||
#include "../eventsSDL/InputHandler.h"
|
||||
|
||||
#include "../../lib/filesystem/Filesystem.h"
|
||||
@ -274,12 +275,12 @@ size_t OptionsTab::CPlayerSettingsHelper::getImageIndex(bool big)
|
||||
TOWN_RANDOM = 38, TOWN_NONE = 39, // Special frames in ITPA
|
||||
HERO_RANDOM = 163, HERO_NONE = 164 // Special frames in PortraitsSmall
|
||||
};
|
||||
auto factionIndex = settings.castle.getNum() >= CGI->townh->size() ? 0 : settings.castle.getNum();
|
||||
auto factionIndex = playerSettings.castle.getNum() >= CGI->townh->size() ? 0 : playerSettings.castle.getNum();
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case TOWN:
|
||||
switch(settings.castle)
|
||||
switch(playerSettings.castle)
|
||||
{
|
||||
case PlayerSettings::NONE:
|
||||
return TOWN_NONE;
|
||||
@ -289,7 +290,7 @@ size_t OptionsTab::CPlayerSettingsHelper::getImageIndex(bool big)
|
||||
return (*CGI->townh)[factionIndex]->town->clientInfo.icons[true][false] + (big ? 0 : 2);
|
||||
}
|
||||
case HERO:
|
||||
switch(settings.hero)
|
||||
switch(playerSettings.hero)
|
||||
{
|
||||
case PlayerSettings::NONE:
|
||||
return HERO_NONE;
|
||||
@ -297,15 +298,15 @@ size_t OptionsTab::CPlayerSettingsHelper::getImageIndex(bool big)
|
||||
return HERO_RANDOM;
|
||||
default:
|
||||
{
|
||||
if(settings.heroPortrait != HeroTypeID::NONE)
|
||||
return settings.heroPortrait;
|
||||
auto index = settings.hero.getNum() >= CGI->heroh->size() ? 0 : settings.hero.getNum();
|
||||
if(playerSettings.heroPortrait != HeroTypeID::NONE)
|
||||
return playerSettings.heroPortrait;
|
||||
auto index = playerSettings.hero.getNum() >= CGI->heroh->size() ? 0 : playerSettings.hero.getNum();
|
||||
return (*CGI->heroh)[index]->imageIndex;
|
||||
}
|
||||
}
|
||||
case BONUS:
|
||||
{
|
||||
switch(settings.bonus)
|
||||
switch(playerSettings.bonus)
|
||||
{
|
||||
case PlayerSettings::RANDOM:
|
||||
return RANDOM;
|
||||
@ -363,7 +364,7 @@ std::string OptionsTab::CPlayerSettingsHelper::getName()
|
||||
{
|
||||
case TOWN:
|
||||
{
|
||||
switch(settings.castle)
|
||||
switch(playerSettings.castle)
|
||||
{
|
||||
case PlayerSettings::NONE:
|
||||
return CGI->generaltexth->allTexts[523];
|
||||
@ -371,14 +372,14 @@ std::string OptionsTab::CPlayerSettingsHelper::getName()
|
||||
return CGI->generaltexth->allTexts[522];
|
||||
default:
|
||||
{
|
||||
auto factionIndex = settings.castle.getNum() >= CGI->townh->size() ? 0 : settings.castle.getNum();
|
||||
auto factionIndex = playerSettings.castle.getNum() >= CGI->townh->size() ? 0 : playerSettings.castle.getNum();
|
||||
return (*CGI->townh)[factionIndex]->getNameTranslated();
|
||||
}
|
||||
}
|
||||
}
|
||||
case HERO:
|
||||
{
|
||||
switch(settings.hero)
|
||||
switch(playerSettings.hero)
|
||||
{
|
||||
case PlayerSettings::NONE:
|
||||
return CGI->generaltexth->allTexts[523];
|
||||
@ -386,21 +387,21 @@ std::string OptionsTab::CPlayerSettingsHelper::getName()
|
||||
return CGI->generaltexth->allTexts[522];
|
||||
default:
|
||||
{
|
||||
if(!settings.heroName.empty())
|
||||
return settings.heroName;
|
||||
auto index = settings.hero.getNum() >= CGI->heroh->size() ? 0 : settings.hero.getNum();
|
||||
if(!playerSettings.heroName.empty())
|
||||
return playerSettings.heroName;
|
||||
auto index = playerSettings.hero.getNum() >= CGI->heroh->size() ? 0 : playerSettings.hero.getNum();
|
||||
return (*CGI->heroh)[index]->getNameTranslated();
|
||||
}
|
||||
}
|
||||
}
|
||||
case BONUS:
|
||||
{
|
||||
switch(settings.bonus)
|
||||
switch(playerSettings.bonus)
|
||||
{
|
||||
case PlayerSettings::RANDOM:
|
||||
return CGI->generaltexth->allTexts[522];
|
||||
default:
|
||||
return CGI->generaltexth->arraytxt[214 + settings.bonus];
|
||||
return CGI->generaltexth->arraytxt[214 + playerSettings.bonus];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -413,12 +414,12 @@ std::string OptionsTab::CPlayerSettingsHelper::getTitle()
|
||||
switch(type)
|
||||
{
|
||||
case OptionsTab::TOWN:
|
||||
return (settings.castle.getNum() < 0) ? CGI->generaltexth->allTexts[103] : CGI->generaltexth->allTexts[80];
|
||||
return (playerSettings.castle.getNum() < 0) ? CGI->generaltexth->allTexts[103] : CGI->generaltexth->allTexts[80];
|
||||
case OptionsTab::HERO:
|
||||
return (settings.hero.getNum() < 0) ? CGI->generaltexth->allTexts[101] : CGI->generaltexth->allTexts[77];
|
||||
return (playerSettings.hero.getNum() < 0) ? CGI->generaltexth->allTexts[101] : CGI->generaltexth->allTexts[77];
|
||||
case OptionsTab::BONUS:
|
||||
{
|
||||
switch(settings.bonus)
|
||||
switch(playerSettings.bonus)
|
||||
{
|
||||
case PlayerSettings::RANDOM:
|
||||
return CGI->generaltexth->allTexts[86]; //{Random Bonus}
|
||||
@ -435,8 +436,8 @@ std::string OptionsTab::CPlayerSettingsHelper::getTitle()
|
||||
}
|
||||
std::string OptionsTab::CPlayerSettingsHelper::getSubtitle()
|
||||
{
|
||||
auto factionIndex = settings.castle.getNum() >= CGI->townh->size() ? 0 : settings.castle.getNum();
|
||||
auto heroIndex = settings.hero.getNum() >= CGI->heroh->size() ? 0 : settings.hero.getNum();
|
||||
auto factionIndex = playerSettings.castle.getNum() >= CGI->townh->size() ? 0 : playerSettings.castle.getNum();
|
||||
auto heroIndex = playerSettings.hero.getNum() >= CGI->heroh->size() ? 0 : playerSettings.hero.getNum();
|
||||
|
||||
switch(type)
|
||||
{
|
||||
@ -444,14 +445,14 @@ std::string OptionsTab::CPlayerSettingsHelper::getSubtitle()
|
||||
return getName();
|
||||
case HERO:
|
||||
{
|
||||
if(settings.hero.getNum() >= 0)
|
||||
if(playerSettings.hero.getNum() >= 0)
|
||||
return getName() + " - " + (*CGI->heroh)[heroIndex]->heroClass->getNameTranslated();
|
||||
return getName();
|
||||
}
|
||||
|
||||
case BONUS:
|
||||
{
|
||||
switch(settings.bonus)
|
||||
switch(playerSettings.bonus)
|
||||
{
|
||||
case PlayerSettings::GOLD:
|
||||
return CGI->generaltexth->allTexts[87]; //500-1000
|
||||
@ -479,7 +480,7 @@ std::string OptionsTab::CPlayerSettingsHelper::getSubtitle()
|
||||
|
||||
std::string OptionsTab::CPlayerSettingsHelper::getDescription()
|
||||
{
|
||||
auto factionIndex = settings.castle.getNum() >= CGI->townh->size() ? 0 : settings.castle.getNum();
|
||||
auto factionIndex = playerSettings.castle.getNum() >= CGI->townh->size() ? 0 : playerSettings.castle.getNum();
|
||||
|
||||
switch(type)
|
||||
{
|
||||
@ -489,7 +490,7 @@ std::string OptionsTab::CPlayerSettingsHelper::getDescription()
|
||||
return CGI->generaltexth->allTexts[102];
|
||||
case BONUS:
|
||||
{
|
||||
switch(settings.bonus)
|
||||
switch(playerSettings.bonus)
|
||||
{
|
||||
case PlayerSettings::RANDOM:
|
||||
return CGI->generaltexth->allTexts[94]; //Gold, wood and ore, or an artifact is randomly chosen as your starting bonus
|
||||
@ -530,13 +531,13 @@ OptionsTab::CPlayerOptionTooltipBox::CPlayerOptionTooltipBox(CPlayerSettingsHelp
|
||||
{
|
||||
break;
|
||||
case TOWN:
|
||||
value = settings.castle;
|
||||
value = playerSettings.castle;
|
||||
break;
|
||||
case HERO:
|
||||
value = settings.hero;
|
||||
value = playerSettings.hero;
|
||||
break;
|
||||
case BONUS:
|
||||
value = settings.bonus;
|
||||
value = playerSettings.bonus;
|
||||
}
|
||||
|
||||
if(value == PlayerSettings::RANDOM)
|
||||
@ -566,7 +567,7 @@ void OptionsTab::CPlayerOptionTooltipBox::genTownWindow()
|
||||
pos = Rect(0, 0, 228, 290);
|
||||
genHeader();
|
||||
labelAssociatedCreatures = std::make_shared<CLabel>(pos.w / 2 + 8, 122, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[79]);
|
||||
auto factionIndex = settings.castle.getNum() >= CGI->townh->size() ? 0 : settings.castle.getNum();
|
||||
auto factionIndex = playerSettings.castle.getNum() >= CGI->townh->size() ? 0 : playerSettings.castle.getNum();
|
||||
std::vector<std::shared_ptr<CComponent>> components;
|
||||
const CTown * town = (*CGI->townh)[factionIndex]->town;
|
||||
|
||||
@ -583,7 +584,7 @@ void OptionsTab::CPlayerOptionTooltipBox::genHeroWindow()
|
||||
pos = Rect(0, 0, 292, 226);
|
||||
genHeader();
|
||||
labelHeroSpeciality = std::make_shared<CLabel>(pos.w / 2 + 4, 117, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[78]);
|
||||
auto heroIndex = settings.hero.getNum() >= CGI->heroh->size() ? 0 : settings.hero.getNum();
|
||||
auto heroIndex = playerSettings.hero.getNum() >= CGI->heroh->size() ? 0 : playerSettings.hero.getNum();
|
||||
|
||||
imageSpeciality = std::make_shared<CAnimImage>(AnimationPath::builtin("UN44"), (*CGI->heroh)[heroIndex]->imageIndex, 0, pos.w / 2 - 22, 134);
|
||||
labelSpecialityName = std::make_shared<CLabel>(pos.w / 2, 188, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, (*CGI->heroh)[heroIndex]->getSpecialtyNameTranslated());
|
||||
@ -908,7 +909,10 @@ void OptionsTab::SelectionWindow::setElement(int elem, bool doApply)
|
||||
if(!doApply)
|
||||
{
|
||||
CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::HERO);
|
||||
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(helper);
|
||||
if(settings["general"]["enableUiEnhancements"].Bool() && helper.playerSettings.hero.getNum() > PlayerSettings::RANDOM && helper.playerSettings.heroName.empty())
|
||||
GH.windows().createAndPushWindow<CHeroOverview>(helper.playerSettings.hero);
|
||||
else
|
||||
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(helper);
|
||||
}
|
||||
else
|
||||
selectedHero = set.hero;
|
||||
@ -963,9 +967,9 @@ void OptionsTab::SelectionWindow::showPopupWindow(const Point & cursorPosition)
|
||||
setElement(elem, false);
|
||||
}
|
||||
|
||||
OptionsTab::SelectedBox::SelectedBox(Point position, PlayerSettings & settings, SelType type)
|
||||
OptionsTab::SelectedBox::SelectedBox(Point position, PlayerSettings & playerSettings, SelType type)
|
||||
: Scrollable(LCLICK | SHOW_POPUP, position, Orientation::HORIZONTAL)
|
||||
, CPlayerSettingsHelper(settings, type)
|
||||
, CPlayerSettingsHelper(playerSettings, type)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
||||
|
||||
@ -986,30 +990,33 @@ void OptionsTab::SelectedBox::update()
|
||||
void OptionsTab::SelectedBox::showPopupWindow(const Point & cursorPosition)
|
||||
{
|
||||
// cases when we do not need to display a message
|
||||
if(settings.castle.getNum() == PlayerSettings::NONE && CPlayerSettingsHelper::type == TOWN)
|
||||
if(playerSettings.castle.getNum() == PlayerSettings::NONE && CPlayerSettingsHelper::type == TOWN)
|
||||
return;
|
||||
if(settings.hero.getNum() == PlayerSettings::NONE && !SEL->getPlayerInfo(settings.color.getNum()).hasCustomMainHero() && CPlayerSettingsHelper::type == HERO)
|
||||
if(playerSettings.hero.getNum() == PlayerSettings::NONE && !SEL->getPlayerInfo(playerSettings.color.getNum()).hasCustomMainHero() && CPlayerSettingsHelper::type == HERO)
|
||||
return;
|
||||
|
||||
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(*this);
|
||||
if(settings["general"]["enableUiEnhancements"].Bool() && CPlayerSettingsHelper::type == HERO && playerSettings.hero.getNum() > PlayerSettings::RANDOM && playerSettings.heroName.empty())
|
||||
GH.windows().createAndPushWindow<CHeroOverview>(playerSettings.hero);
|
||||
else
|
||||
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(*this);
|
||||
}
|
||||
|
||||
void OptionsTab::SelectedBox::clickReleased(const Point & cursorPosition)
|
||||
{
|
||||
PlayerInfo pi = SEL->getPlayerInfo(settings.color.getNum());
|
||||
const bool foreignPlayer = CSH->isGuest() && !CSH->isMyColor(settings.color);
|
||||
PlayerInfo pi = SEL->getPlayerInfo(playerSettings.color.getNum());
|
||||
const bool foreignPlayer = CSH->isGuest() && !CSH->isMyColor(playerSettings.color);
|
||||
|
||||
if(type == SelType::TOWN && ((pi.allowedFactions.size() < 2 && !pi.isFactionRandom) || foreignPlayer))
|
||||
return;
|
||||
|
||||
if(type == SelType::HERO && ((pi.defaultHero() != -1 || settings.castle.getNum() < 0) || foreignPlayer))
|
||||
if(type == SelType::HERO && ((pi.defaultHero() != -1 || playerSettings.castle.getNum() < 0) || foreignPlayer))
|
||||
return;
|
||||
|
||||
if(type == SelType::BONUS && foreignPlayer)
|
||||
return;
|
||||
|
||||
GH.input().hapticFeedback();
|
||||
GH.windows().createAndPushWindow<SelectionWindow>(settings.color, type);
|
||||
GH.windows().createAndPushWindow<SelectionWindow>(playerSettings.color, type);
|
||||
}
|
||||
|
||||
void OptionsTab::SelectedBox::scrollBy(int distance)
|
||||
@ -1022,13 +1029,13 @@ void OptionsTab::SelectedBox::scrollBy(int distance)
|
||||
switch(CPlayerSettingsHelper::type)
|
||||
{
|
||||
case TOWN:
|
||||
CSH->setPlayerOption(LobbyChangePlayerOption::TOWN, distance, settings.color);
|
||||
CSH->setPlayerOption(LobbyChangePlayerOption::TOWN, distance, playerSettings.color);
|
||||
break;
|
||||
case HERO:
|
||||
CSH->setPlayerOption(LobbyChangePlayerOption::HERO, distance, settings.color);
|
||||
CSH->setPlayerOption(LobbyChangePlayerOption::HERO, distance, playerSettings.color);
|
||||
break;
|
||||
case BONUS:
|
||||
CSH->setPlayerOption(LobbyChangePlayerOption::BONUS, distance, settings.color);
|
||||
CSH->setPlayerOption(LobbyChangePlayerOption::BONUS, distance, playerSettings.color);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -53,11 +53,11 @@ private:
|
||||
|
||||
struct CPlayerSettingsHelper
|
||||
{
|
||||
const PlayerSettings & settings;
|
||||
const PlayerSettings & playerSettings;
|
||||
const SelType type;
|
||||
|
||||
CPlayerSettingsHelper(const PlayerSettings & settings, SelType type)
|
||||
: settings(settings), type(type)
|
||||
CPlayerSettingsHelper(const PlayerSettings & playerSettings, SelType type)
|
||||
: playerSettings(playerSettings), type(type)
|
||||
{}
|
||||
|
||||
/// visible image settings
|
||||
@ -156,7 +156,7 @@ private:
|
||||
std::shared_ptr<CAnimImage> image;
|
||||
std::shared_ptr<CLabel> subtitle;
|
||||
|
||||
SelectedBox(Point position, PlayerSettings & settings, SelType type);
|
||||
SelectedBox(Point position, PlayerSettings & playerSettings, SelType type);
|
||||
void showPopupWindow(const Point & cursorPosition) override;
|
||||
void clickReleased(const Point & cursorPosition) override;
|
||||
void scrollBy(int distance) override;
|
||||
|
@ -580,3 +580,31 @@ void CCreaturePic::setAmount(int newAmount)
|
||||
else
|
||||
amount->setText("");
|
||||
}
|
||||
|
||||
TransparentFilledRectangle::TransparentFilledRectangle(Rect position, ColorRGBA color) :
|
||||
color(color), colorLine(ColorRGBA()), drawLine(false)
|
||||
{
|
||||
pos = position + pos.topLeft();
|
||||
}
|
||||
|
||||
TransparentFilledRectangle::TransparentFilledRectangle(Rect position, ColorRGBA color, ColorRGBA colorLine) :
|
||||
color(color), colorLine(colorLine), drawLine(true)
|
||||
{
|
||||
pos = position + pos.topLeft();
|
||||
}
|
||||
|
||||
void TransparentFilledRectangle::showAll(Canvas & to)
|
||||
{
|
||||
to.drawColorBlended(pos, color);
|
||||
if(drawLine)
|
||||
to.drawBorder(pos, colorLine);
|
||||
}
|
||||
|
||||
SimpleLine::SimpleLine(Point pos1, Point pos2, ColorRGBA color) :
|
||||
pos1(pos1), pos2(pos2), color(color)
|
||||
{}
|
||||
|
||||
void SimpleLine::showAll(Canvas & to)
|
||||
{
|
||||
to.drawLine(pos1 + pos.topLeft(), pos2 + pos.topLeft(), color, color);
|
||||
}
|
@ -226,3 +226,24 @@ public:
|
||||
|
||||
MoraleLuckBox(bool Morale, const Rect &r, bool Small=false);
|
||||
};
|
||||
|
||||
class TransparentFilledRectangle : public CIntObject
|
||||
{
|
||||
ColorRGBA color;
|
||||
ColorRGBA colorLine;
|
||||
bool drawLine;
|
||||
public:
|
||||
TransparentFilledRectangle(Rect position, ColorRGBA color);
|
||||
TransparentFilledRectangle(Rect position, ColorRGBA color, ColorRGBA colorLine);
|
||||
void showAll(Canvas & to) override;
|
||||
};
|
||||
|
||||
class SimpleLine : public CIntObject
|
||||
{
|
||||
Point pos1;
|
||||
Point pos2;
|
||||
ColorRGBA color;
|
||||
public:
|
||||
SimpleLine(Point pos1, Point pos2, ColorRGBA color);
|
||||
void showAll(Canvas & to) override;
|
||||
};
|
237
client/windows/CHeroOverview.cpp
Normal file
237
client/windows/CHeroOverview.cpp
Normal file
@ -0,0 +1,237 @@
|
||||
/*
|
||||
* CHeroOverview.cpp, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
#include "StdInc.h"
|
||||
#include "CHeroOverview.h"
|
||||
|
||||
#include "../CGameInfo.h"
|
||||
#include "../gui/CGuiHandler.h"
|
||||
#include "../render/Canvas.h"
|
||||
#include "../render/Colors.h"
|
||||
#include "../render/Graphics.h"
|
||||
#include "../render/IImage.h"
|
||||
#include "../renderSDL/RenderHandler.h"
|
||||
#include "../widgets/CComponent.h"
|
||||
#include "../widgets/Images.h"
|
||||
#include "../widgets/TextControls.h"
|
||||
#include "../widgets/MiscWidgets.h"
|
||||
|
||||
#include "../../lib/GameSettings.h"
|
||||
#include "../../lib/CGeneralTextHandler.h"
|
||||
#include "../../lib/CCreatureHandler.h"
|
||||
#include "../../lib/CHeroHandler.h"
|
||||
#include "../../lib/CSkillHandler.h"
|
||||
#include "../../lib/spells/CSpellHandler.h"
|
||||
|
||||
CHeroOverview::CHeroOverview(const HeroTypeID & h)
|
||||
: CWindowObject(BORDERED | RCLICK_POPUP), hero { h }
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
||||
|
||||
heroIdx = hero.getNum();
|
||||
|
||||
pos = Rect(0, 0, 600, 485);
|
||||
|
||||
genBackground();
|
||||
genControls();
|
||||
|
||||
center();
|
||||
}
|
||||
|
||||
void CHeroOverview::genBackground()
|
||||
{
|
||||
backgroundTexture = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), pos);
|
||||
updateShadow();
|
||||
}
|
||||
|
||||
void CHeroOverview::genControls()
|
||||
{
|
||||
Rect r = Rect();
|
||||
|
||||
labelTitle = std::make_shared<CLabel>(pos.w / 2 + 8, 21, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[77]);
|
||||
|
||||
// hero image
|
||||
r = Rect(borderOffset, borderOffset + yOffset, 58, 64);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
imageHero = std::make_shared<CAnimImage>(AnimationPath::builtin("PortraitsLarge"), (*CGI->heroh)[heroIdx]->imageIndex, 0, r.x, r.y);
|
||||
|
||||
// hero name
|
||||
r = Rect(64 + borderOffset, borderOffset + yOffset, 220, 64);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
labelHeroName = std::make_shared<CLabel>(r.x + 110, r.y + 20, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, (*CGI->heroh)[heroIdx]->getNameTranslated());
|
||||
labelHeroClass = std::make_shared<CLabel>(r.x + 110, r.y + 45, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, (*CGI->heroh)[heroIdx]->heroClass->getNameTranslated());
|
||||
|
||||
// vertical line
|
||||
backgroundLines.push_back(std::make_shared<SimpleLine>(Point(295, borderOffset + yOffset - 1), Point(295, borderOffset + yOffset - 2 + 439), borderColor));
|
||||
|
||||
// skills header
|
||||
r = Rect(borderOffset, 2 * borderOffset + yOffset + 64, 284, 20);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
for(int i = 0; i < 4; i++)
|
||||
labelSkillHeader.push_back(std::make_shared<CLabel>((r.w / 4) * i + 42, r.y + 10, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->jktexts[1 + i]));
|
||||
|
||||
// skill
|
||||
const int tmp[] = {0, 1, 2, 5};
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
r = Rect((284 / 4) * i + 21, 3 * borderOffset + yOffset + 85, 42, 42);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
imageSkill.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL42"), tmp[i], 0, r.x, r.y));
|
||||
}
|
||||
|
||||
// skills footer
|
||||
r = Rect(borderOffset, 4 * borderOffset + yOffset + 128, 284, 20);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
r = Rect((284 / 4) * i + 42, r.y, r.w, r.h);
|
||||
labelSkillFooter.push_back(std::make_shared<CLabel>(r.x, r.y + 10, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, std::to_string((*CGI->heroh)[heroIdx]->heroClass->primarySkillInitial[i])));
|
||||
}
|
||||
|
||||
// hero biography
|
||||
r = Rect(borderOffset, 5 * borderOffset + yOffset + 148, 284, 130);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
labelHeroBiography = std::make_shared<CMultiLineLabel>(r.resize(-borderOffset), FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, (*CGI->heroh)[heroIdx]->getBiographyTranslated());
|
||||
|
||||
// speciality name
|
||||
r = Rect(2 * borderOffset + 44, 6 * borderOffset + yOffset + 278, 235, 44);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
labelHeroSpeciality = std::make_shared<CLabel>(r.x + borderOffset, r.y + borderOffset, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[78]);
|
||||
labelSpecialityName = std::make_shared<CLabel>(r.x + borderOffset, r.y + borderOffset + 20, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, (*CGI->heroh)[heroIdx]->getSpecialtyNameTranslated());
|
||||
|
||||
// speciality image
|
||||
r = Rect(borderOffset, 6 * borderOffset + yOffset + 278, 44, 44);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
imageSpeciality = std::make_shared<CAnimImage>(AnimationPath::builtin("UN44"), (*CGI->heroh)[heroIdx]->imageIndex, 0, r.x, r.y);
|
||||
|
||||
// speciality description
|
||||
r = Rect(borderOffset, 7 * borderOffset + yOffset + 322, 284, 85);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
labelSpecialityDescription = std::make_shared<CMultiLineLabel>(r.resize(-borderOffset), FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, (*CGI->heroh)[heroIdx]->getSpecialtyDescriptionTranslated());
|
||||
|
||||
// army title
|
||||
r = Rect(302, borderOffset + yOffset, 292, 30);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
labelArmyTitle = std::make_shared<CLabel>(r.x + borderOffset, r.y + borderOffset + 2, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->translate("vcmi.heroOverview.startingArmy"));
|
||||
|
||||
// army numbers
|
||||
r = Rect(302, 3 * borderOffset + yOffset + 62, 292, 32);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
|
||||
auto stacksCountChances = VLC->settings()->getVector(EGameSettings::HEROES_STARTING_STACKS_CHANCES);
|
||||
|
||||
// army
|
||||
int space = (260 - 7 * 32) / 6;
|
||||
for(int i = 0; i < 7; i++)
|
||||
{
|
||||
r = Rect(318 + i * (32 + space), 2 * borderOffset + yOffset + 30, 32, 32);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
}
|
||||
int i = 0;
|
||||
int iStack = 0;
|
||||
for(auto & army : (*CGI->heroh)[heroIdx]->initialArmy)
|
||||
{
|
||||
if((*CGI->creh)[army.creature]->warMachine == ArtifactID::NONE)
|
||||
{
|
||||
imageArmy.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("CPRSMALL"), (*CGI->creh)[army.creature]->getIconIndex(), 0, 302 + i * (32 + space) + 16, 2 * borderOffset + yOffset + 30));
|
||||
labelArmyCount.push_back(std::make_shared<CLabel>(302 + i * (32 + space) + 32, 3 * borderOffset + yOffset + 72, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, (army.minAmount == army.maxAmount) ? std::to_string(army.minAmount) : std::to_string(army.minAmount) + "-" + std::to_string(army.maxAmount)));
|
||||
if(iStack<stacksCountChances.size())
|
||||
labelArmyCount.push_back(std::make_shared<CLabel>(302 + i * (32 + space) + 32, 3 * borderOffset + yOffset + 86, FONT_SMALL, ETextAlignment::CENTER, grayedColor, std::to_string(stacksCountChances[iStack]) + "%"));
|
||||
i++;
|
||||
}
|
||||
iStack++;
|
||||
}
|
||||
|
||||
// war machine title
|
||||
r = Rect(302, 4 * borderOffset + yOffset + 94, 292, 30);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
labelWarMachineTitle = std::make_shared<CLabel>(r.x + borderOffset, r.y + borderOffset + 2, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->translate("vcmi.heroOverview.warMachine"));
|
||||
|
||||
// war machine
|
||||
space = (260 - 4 * 32) / 3;
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
r = Rect(318 + i * (32 + space), 5 * borderOffset + yOffset + 124, 32, 32);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
}
|
||||
i = 0;
|
||||
iStack = 0;
|
||||
for(auto & army : (*CGI->heroh)[heroIdx]->initialArmy)
|
||||
{
|
||||
if(i == 0)
|
||||
{
|
||||
imageWarMachine.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("CPRSMALL"), (*CGI->creh)[army.creature.CATAPULT]->getIconIndex(), 0, 302 + i * (32 + space) + 16, 5 * borderOffset + yOffset + 124));
|
||||
labelArmyCount.push_back(std::make_shared<CLabel>(302 + i * (32 + space) + 51, 5 * borderOffset + yOffset + 144, FONT_SMALL, ETextAlignment::TOPLEFT, grayedColor, "100%"));
|
||||
i++;
|
||||
}
|
||||
if((*CGI->creh)[army.creature]->warMachine != ArtifactID::NONE)
|
||||
{
|
||||
imageWarMachine.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("CPRSMALL"), (*CGI->creh)[army.creature]->getIconIndex(), 0, 302 + i * (32 + space) + 16, 5 * borderOffset + yOffset + 124));
|
||||
if(iStack<stacksCountChances.size())
|
||||
labelArmyCount.push_back(std::make_shared<CLabel>(302 + i * (32 + space) + 51, 5 * borderOffset + yOffset + 144, FONT_SMALL, ETextAlignment::TOPLEFT, grayedColor, std::to_string(stacksCountChances[iStack]) + "%"));
|
||||
i++;
|
||||
}
|
||||
iStack++;
|
||||
}
|
||||
|
||||
// secskill title
|
||||
r = Rect(302, 6 * borderOffset + yOffset + 156, (292 / 2) - 2 * borderOffset, 30);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
labelSecSkillTitle = std::make_shared<CLabel>(r.x + borderOffset, r.y + borderOffset + 2, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->translate("vcmi.heroOverview.secondarySkills"));
|
||||
|
||||
// vertical line
|
||||
backgroundLines.push_back(std::make_shared<SimpleLine>(Point(302 + (292 / 2), 6 * borderOffset + yOffset + 156 - 1), Point(302 + (292 / 2), 6 * borderOffset + yOffset + 156 - 2 + 254), borderColor));
|
||||
|
||||
// spell title
|
||||
r = Rect(302 + (292 / 2) + 2 * borderOffset, 6 * borderOffset + yOffset + 156, (292 / 2) - 2 * borderOffset, 30);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
labelSpellTitle = std::make_shared<CLabel>(r.x + borderOffset, r.y + borderOffset + 2, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->translate("vcmi.heroOverview.spells"));
|
||||
|
||||
// secskill
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
r = Rect(302, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset), 32, 32);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
r = Rect(r.x + 32 + borderOffset, r.y, (292 / 2) - 32 - 3 * borderOffset, r.h);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
}
|
||||
i = 0;
|
||||
for(auto & skill : (*CGI->heroh)[heroIdx]->secSkillsInit)
|
||||
{
|
||||
imageSecSkills.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("SECSK32"), (*CGI->skillh)[skill.first]->getIconIndex() * 3 + skill.second + 2, 0, 302, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset)));
|
||||
labelSecSkillsNames.push_back(std::make_shared<CLabel>(334 + 2 * borderOffset, 8 * borderOffset + yOffset + 186 + i * (32 + borderOffset) - 5, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->levels[skill.second - 1]));
|
||||
labelSecSkillsNames.push_back(std::make_shared<CLabel>(334 + 2 * borderOffset, 8 * borderOffset + yOffset + 186 + i * (32 + borderOffset) + 10, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, (*CGI->skillh)[skill.first]->getNameTranslated()));
|
||||
i++;
|
||||
}
|
||||
|
||||
// spell
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
r = Rect(302 + (292 / 2) + 2 * borderOffset, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset), 32, 32);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
r = Rect(r.x + 32 + borderOffset, r.y, (292 / 2) - 32 - 3 * borderOffset, r.h);
|
||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||
}
|
||||
i = 0;
|
||||
for(auto & spell : (*CGI->heroh)[heroIdx]->spells)
|
||||
{
|
||||
if(i == 0)
|
||||
{
|
||||
if((*CGI->heroh)[heroIdx]->haveSpellBook)
|
||||
{
|
||||
imageSpells.push_back(std::make_shared<CAnimImage>(GH.renderHandler().loadAnimation(AnimationPath::builtin("ARTIFACT")), 0, Rect(302 + (292 / 2) + 2 * borderOffset, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset), 32, 32), 0));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
imageSpells.push_back(std::make_shared<CAnimImage>(GH.renderHandler().loadAnimation(AnimationPath::builtin("SPELLBON")), (*CGI->spellh)[spell]->getIconIndex(), Rect(302 + (292 / 2) + 2 * borderOffset, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset), 32, 32), 0));
|
||||
labelSpellsNames.push_back(std::make_shared<CLabel>(302 + (292 / 2) + 3 * borderOffset + 32 + borderOffset, 8 * borderOffset + yOffset + 186 + i * (32 + borderOffset) + 3, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, (*CGI->spellh)[spell]->getNameTranslated()));
|
||||
i++;
|
||||
}
|
||||
}
|
71
client/windows/CHeroOverview.h
Normal file
71
client/windows/CHeroOverview.h
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* CHeroOverview.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../windows/CWindowObject.h"
|
||||
|
||||
class CLabel;
|
||||
class CMultiLineLabel;
|
||||
class CFilledTexture;
|
||||
class CAnimImage;
|
||||
class CComponentBox;
|
||||
class CTextBox;
|
||||
class TransparentFilledRectangle;
|
||||
class SimpleLine;
|
||||
|
||||
class CHeroOverview : public CWindowObject
|
||||
{
|
||||
const HeroTypeID & hero;
|
||||
int heroIdx;
|
||||
|
||||
const int yOffset = 35;
|
||||
const int borderOffset = 5;
|
||||
const ColorRGBA rectangleColor = ColorRGBA(0, 0, 0, 75);
|
||||
const ColorRGBA borderColor = ColorRGBA(128, 100, 75);
|
||||
const ColorRGBA grayedColor = ColorRGBA(158, 130, 105);
|
||||
|
||||
std::shared_ptr<CFilledTexture> backgroundTexture;
|
||||
std::vector<std::shared_ptr<TransparentFilledRectangle>> backgroundRectangles;
|
||||
std::vector<std::shared_ptr<SimpleLine>> backgroundLines;
|
||||
|
||||
std::shared_ptr<CLabel> labelTitle;
|
||||
std::shared_ptr<CAnimImage> imageHero;
|
||||
std::shared_ptr<CLabel> labelHeroName;
|
||||
std::shared_ptr<CMultiLineLabel> labelHeroBiography;
|
||||
std::shared_ptr<CLabel> labelHeroClass;
|
||||
std::shared_ptr<CLabel> labelHeroSpeciality;
|
||||
std::shared_ptr<CAnimImage> imageSpeciality;
|
||||
std::vector<std::shared_ptr<CLabel>> labelSkillHeader;
|
||||
std::vector<std::shared_ptr<CAnimImage>> imageSkill;
|
||||
std::vector<std::shared_ptr<CLabel>> labelSkillFooter;
|
||||
std::shared_ptr<CLabel> labelSpecialityName;
|
||||
std::shared_ptr<CMultiLineLabel> labelSpecialityDescription;
|
||||
|
||||
std::shared_ptr<CLabel> labelArmyTitle;
|
||||
std::vector<std::shared_ptr<CAnimImage>> imageArmy;
|
||||
std::vector<std::shared_ptr<CLabel>> labelArmyCount;
|
||||
|
||||
std::shared_ptr<CLabel> labelWarMachineTitle;
|
||||
std::vector<std::shared_ptr<CAnimImage>> imageWarMachine;
|
||||
|
||||
std::shared_ptr<CLabel> labelSpellTitle;
|
||||
std::vector<std::shared_ptr<CAnimImage>> imageSpells;
|
||||
std::vector<std::shared_ptr<CLabel>> labelSpellsNames;
|
||||
|
||||
std::shared_ptr<CLabel> labelSecSkillTitle;
|
||||
std::vector<std::shared_ptr<CAnimImage>> imageSecSkills;
|
||||
std::vector<std::shared_ptr<CLabel>> labelSecSkillsNames;
|
||||
|
||||
void genBackground();
|
||||
void genControls();
|
||||
|
||||
public:
|
||||
CHeroOverview(const HeroTypeID & h);
|
||||
};
|
@ -98,6 +98,11 @@ public:
|
||||
return Point(w,h);
|
||||
}
|
||||
|
||||
Rect resize(const int size) const
|
||||
{
|
||||
return Rect(x-size,y-size,w+2*size,h+2*size);
|
||||
}
|
||||
|
||||
void moveTo(const Point & dest)
|
||||
{
|
||||
x = dest.x;
|
||||
|
Loading…
Reference in New Issue
Block a user