mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
Initial split of BattleOptionsWindow
This commit is contained in:
@@ -93,6 +93,7 @@ set(client_SRCS
|
||||
windows/SystemOptionsWindow.cpp
|
||||
windows/VcmiSettingsWindow.cpp
|
||||
windows/SettingsMainContainer.cpp
|
||||
windows/BattleOptionsWindow.cpp
|
||||
|
||||
CGameInfo.cpp
|
||||
CMT.cpp
|
||||
@@ -206,6 +207,7 @@ set(client_HEADERS
|
||||
windows/SystemOptionsWindow.h
|
||||
windows/VcmiSettingsWindow.h
|
||||
windows/SettingsMainContainer.h
|
||||
windows/BattleOptionsWindow.h
|
||||
|
||||
CGameInfo.h
|
||||
CMT.h
|
||||
|
@@ -422,106 +422,6 @@ HeroInfoWindow::HeroInfoWindow(const InfoAboutHero & hero, Point * position)
|
||||
labels.push_back(std::make_shared<CLabel>(39, 186, EFonts::FONT_TINY, ETextAlignment::CENTER, Colors::WHITE, std::to_string(currentSpellPoints) + "/" + std::to_string(maxSpellPoints)));
|
||||
}
|
||||
|
||||
BattleOptionsWindow::BattleOptionsWindow(BattleInterface * owner):
|
||||
CWindowObject(PLAYER_COLORED, "comopbck.bmp")
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
|
||||
auto viewGrid = std::make_shared<CToggleButton>(Point(25, 56), "sysopchk.def", CGI->generaltexth->zelp[427], [=](bool on)
|
||||
{
|
||||
Settings cellBorders = settings.write["battle"]["cellBorders"];
|
||||
cellBorders->Bool() = on;
|
||||
if(owner)
|
||||
owner->redrawBattlefield();
|
||||
});
|
||||
viewGrid->setSelected(settings["battle"]["cellBorders"].Bool());
|
||||
toggles.push_back(viewGrid);
|
||||
|
||||
auto movementShadow = std::make_shared<CToggleButton>(Point(25, 89), "sysopchk.def", CGI->generaltexth->zelp[428], [=](bool on)
|
||||
{
|
||||
Settings stackRange = settings.write["battle"]["stackRange"];
|
||||
stackRange->Bool() = on;
|
||||
if(owner)
|
||||
owner->redrawBattlefield();
|
||||
});
|
||||
movementShadow->setSelected(settings["battle"]["stackRange"].Bool());
|
||||
toggles.push_back(movementShadow);
|
||||
|
||||
auto mouseShadow = std::make_shared<CToggleButton>(Point(25, 122), "sysopchk.def", CGI->generaltexth->zelp[429], [&](bool on)
|
||||
{
|
||||
Settings shadow = settings.write["battle"]["mouseShadow"];
|
||||
shadow->Bool() = on;
|
||||
});
|
||||
mouseShadow->setSelected(settings["battle"]["mouseShadow"].Bool());
|
||||
toggles.push_back(mouseShadow);
|
||||
|
||||
animSpeeds = std::make_shared<CToggleGroup>([&](int value)
|
||||
{
|
||||
Settings speed = settings.write["battle"]["speedFactor"];
|
||||
speed->Float() = float(value);
|
||||
});
|
||||
|
||||
std::shared_ptr<CToggleButton> toggle;
|
||||
toggle = std::make_shared<CToggleButton>(Point( 28, 225), "sysopb9.def", CGI->generaltexth->zelp[422]);
|
||||
animSpeeds->addToggle(1, toggle);
|
||||
|
||||
toggle = std::make_shared<CToggleButton>(Point( 92, 225), "sysob10.def", CGI->generaltexth->zelp[423]);
|
||||
animSpeeds->addToggle(2, toggle);
|
||||
|
||||
toggle = std::make_shared<CToggleButton>(Point(156, 225), "sysob11.def", CGI->generaltexth->zelp[424]);
|
||||
animSpeeds->addToggle(3, toggle);
|
||||
|
||||
animSpeeds->setSelected(getAnimSpeed());
|
||||
|
||||
setToDefault = std::make_shared<CButton>(Point(246, 359), "codefaul.def", CGI->generaltexth->zelp[393], [&](){ bDefaultf(); });
|
||||
setToDefault->setImageOrder(1, 0, 2, 3);
|
||||
exit = std::make_shared<CButton>(Point(357, 359), "soretrn.def", CGI->generaltexth->zelp[392], [&](){ bExitf();}, SDLK_RETURN);
|
||||
exit->setImageOrder(1, 0, 2, 3);
|
||||
|
||||
//creating labels
|
||||
labels.push_back(std::make_shared<CLabel>(242, 32, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[392]));//window title
|
||||
labels.push_back(std::make_shared<CLabel>(122, 214, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[393]));//animation speed
|
||||
labels.push_back(std::make_shared<CLabel>(122, 293, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[394]));//music volume
|
||||
labels.push_back(std::make_shared<CLabel>(122, 359, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[395]));//effects' volume
|
||||
labels.push_back(std::make_shared<CLabel>(353, 66, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[396]));//auto - combat options
|
||||
labels.push_back(std::make_shared<CLabel>(353, 265, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[397]));//creature info
|
||||
|
||||
//auto - combat options
|
||||
labels.push_back(std::make_shared<CLabel>(283, 86, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[398]));//creatures
|
||||
labels.push_back(std::make_shared<CLabel>(283, 116, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[399]));//spells
|
||||
labels.push_back(std::make_shared<CLabel>(283, 146, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[400]));//catapult
|
||||
labels.push_back(std::make_shared<CLabel>(283, 176, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[151]));//ballista
|
||||
labels.push_back(std::make_shared<CLabel>(283, 206, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[401]));//first aid tent
|
||||
|
||||
//creature info
|
||||
labels.push_back(std::make_shared<CLabel>(283, 285, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[402]));//all stats
|
||||
labels.push_back(std::make_shared<CLabel>(283, 315, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[403]));//spells only
|
||||
|
||||
//general options
|
||||
labels.push_back(std::make_shared<CLabel>(61, 57, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[404]));
|
||||
labels.push_back(std::make_shared<CLabel>(61, 90, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[405]));
|
||||
labels.push_back(std::make_shared<CLabel>(61, 123, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[406]));
|
||||
labels.push_back(std::make_shared<CLabel>(61, 156, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[407]));
|
||||
}
|
||||
|
||||
int BattleOptionsWindow::getAnimSpeed() const
|
||||
{
|
||||
if(settings["session"]["spectate"].Bool() && !settings["session"]["spectate-battle-speed"].isNull())
|
||||
return static_cast<int>(vstd::round(settings["session"]["spectate-battle-speed"].Float()));
|
||||
|
||||
return static_cast<int>(vstd::round(settings["battle"]["speedFactor"].Float()));
|
||||
}
|
||||
|
||||
void BattleOptionsWindow::bDefaultf()
|
||||
{
|
||||
//TODO: implement
|
||||
}
|
||||
|
||||
void BattleOptionsWindow::bExitf()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface & _owner)
|
||||
: owner(_owner)
|
||||
{
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include "../../lib/FunctionList.h"
|
||||
#include "../../lib/battle/BattleHex.h"
|
||||
#include "../windows/CWindowObject.h"
|
||||
#include "gui/InterfaceObjectConfigurable.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
@@ -137,24 +138,6 @@ public:
|
||||
HeroInfoWindow(const InfoAboutHero & hero, Point * position);
|
||||
};
|
||||
|
||||
/// Class which manages the battle options window
|
||||
class BattleOptionsWindow : public CWindowObject
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<CButton> setToDefault;
|
||||
std::shared_ptr<CButton> exit;
|
||||
std::shared_ptr<CToggleGroup> animSpeeds;
|
||||
std::vector<std::shared_ptr<CLabel>> labels;
|
||||
std::vector<std::shared_ptr<CToggleButton>> toggles;
|
||||
|
||||
int getAnimSpeed() const;
|
||||
public:
|
||||
BattleOptionsWindow(BattleInterface * owner);
|
||||
|
||||
void bDefaultf(); //default button callback
|
||||
void bExitf(); //exit button callback
|
||||
};
|
||||
|
||||
/// Class which is responsible for showing the battle result window
|
||||
class BattleResultWindow : public WindowBase
|
||||
{
|
||||
|
@@ -35,6 +35,7 @@
|
||||
#include "../../lib/CStack.h"
|
||||
#include "../../lib/CConfigHandler.h"
|
||||
#include "../../lib/filesystem/ResourceID.h"
|
||||
#include "windows/BattleOptionsWindow.h"
|
||||
|
||||
#include <SDL_surface.h>
|
||||
#include <SDL_events.h>
|
||||
|
108
client/windows/BattleOptionsWindow.cpp
Normal file
108
client/windows/BattleOptionsWindow.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* BattleOptionsWindow.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 "BattleOptionsWindow.h"
|
||||
#include "CConfigHandler.h"
|
||||
#include "gui/CGuiHandler.h"
|
||||
|
||||
#include "../../lib/filesystem/ResourceID.h"
|
||||
#include "../../lib/CGeneralTextHandler.h"
|
||||
#include "../widgets/Buttons.h"
|
||||
#include "../widgets/TextControls.h"
|
||||
#include "CGameInfo.h"
|
||||
|
||||
BattleOptionsWindow::BattleOptionsWindow(BattleInterface * owner):
|
||||
InterfaceObjectConfigurable()
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
||||
|
||||
const JsonNode config(ResourceID("config/widgets/battleOptionsWindow.json"));
|
||||
build(config);
|
||||
|
||||
auto viewGrid = std::make_shared<CToggleButton>(Point(25, 56), "sysopchk.def", CGI->generaltexth->zelp[427], [=](bool on)
|
||||
{
|
||||
Settings cellBorders = settings.write["battle"]["cellBorders"];
|
||||
cellBorders->Bool() = on;
|
||||
if(owner)
|
||||
owner->redrawBattlefield();
|
||||
});
|
||||
viewGrid->setSelected(settings["battle"]["cellBorders"].Bool());
|
||||
toggles.push_back(viewGrid);
|
||||
|
||||
auto movementShadow = std::make_shared<CToggleButton>(Point(25, 89), "sysopchk.def", CGI->generaltexth->zelp[428], [=](bool on)
|
||||
{
|
||||
Settings stackRange = settings.write["battle"]["stackRange"];
|
||||
stackRange->Bool() = on;
|
||||
if(owner)
|
||||
owner->redrawBattlefield();
|
||||
});
|
||||
movementShadow->setSelected(settings["battle"]["stackRange"].Bool());
|
||||
toggles.push_back(movementShadow);
|
||||
|
||||
auto mouseShadow = std::make_shared<CToggleButton>(Point(25, 122), "sysopchk.def", CGI->generaltexth->zelp[429], [&](bool on)
|
||||
{
|
||||
Settings shadow = settings.write["battle"]["mouseShadow"];
|
||||
shadow->Bool() = on;
|
||||
});
|
||||
mouseShadow->setSelected(settings["battle"]["mouseShadow"].Bool());
|
||||
toggles.push_back(mouseShadow);
|
||||
|
||||
animSpeeds = std::make_shared<CToggleGroup>([&](int value)
|
||||
{
|
||||
Settings speed = settings.write["battle"]["speedFactor"];
|
||||
speed->Float() = float(value);
|
||||
});
|
||||
|
||||
std::shared_ptr<CToggleButton> toggle;
|
||||
toggle = std::make_shared<CToggleButton>(Point( 28, 225), "sysopb9.def", CGI->generaltexth->zelp[422]);
|
||||
animSpeeds->addToggle(1, toggle);
|
||||
|
||||
toggle = std::make_shared<CToggleButton>(Point( 92, 225), "sysob10.def", CGI->generaltexth->zelp[423]);
|
||||
animSpeeds->addToggle(2, toggle);
|
||||
|
||||
toggle = std::make_shared<CToggleButton>(Point(156, 225), "sysob11.def", CGI->generaltexth->zelp[424]);
|
||||
animSpeeds->addToggle(3, toggle);
|
||||
|
||||
animSpeeds->setSelected(getAnimSpeed());
|
||||
|
||||
//creating labels
|
||||
labels.push_back(std::make_shared<CLabel>(242, 32, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[392]));//window title
|
||||
labels.push_back(std::make_shared<CLabel>(122, 214, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[393]));//animation speed
|
||||
labels.push_back(std::make_shared<CLabel>(122, 293, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[394]));//music volume
|
||||
labels.push_back(std::make_shared<CLabel>(122, 359, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[395]));//effects' volume
|
||||
labels.push_back(std::make_shared<CLabel>(353, 66, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[396]));//auto - combat options
|
||||
labels.push_back(std::make_shared<CLabel>(353, 265, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[397]));//creature info
|
||||
|
||||
//auto - combat options
|
||||
labels.push_back(std::make_shared<CLabel>(283, 86, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[398]));//creatures
|
||||
labels.push_back(std::make_shared<CLabel>(283, 116, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[399]));//spells
|
||||
labels.push_back(std::make_shared<CLabel>(283, 146, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[400]));//catapult
|
||||
labels.push_back(std::make_shared<CLabel>(283, 176, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[151]));//ballista
|
||||
labels.push_back(std::make_shared<CLabel>(283, 206, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[401]));//first aid tent
|
||||
|
||||
//creature info
|
||||
labels.push_back(std::make_shared<CLabel>(283, 285, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[402]));//all stats
|
||||
labels.push_back(std::make_shared<CLabel>(283, 315, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[403]));//spells only
|
||||
|
||||
//general options
|
||||
labels.push_back(std::make_shared<CLabel>(61, 57, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[404]));
|
||||
labels.push_back(std::make_shared<CLabel>(61, 90, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[405]));
|
||||
labels.push_back(std::make_shared<CLabel>(61, 123, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[406]));
|
||||
labels.push_back(std::make_shared<CLabel>(61, 156, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[407]));
|
||||
}
|
||||
|
||||
int BattleOptionsWindow::getAnimSpeed() const
|
||||
{
|
||||
if(settings["session"]["spectate"].Bool() && !settings["session"]["spectate-battle-speed"].isNull())
|
||||
return static_cast<int>(vstd::round(settings["session"]["spectate-battle-speed"].Float()));
|
||||
|
||||
return static_cast<int>(vstd::round(settings["battle"]["speedFactor"].Float()));
|
||||
}
|
27
client/windows/BattleOptionsWindow.h
Normal file
27
client/windows/BattleOptionsWindow.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* BattleOptionsWindow.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 "gui/InterfaceObjectConfigurable.h"
|
||||
#include "battle/BattleInterface.h"
|
||||
|
||||
class BattleOptionsWindow : public InterfaceObjectConfigurable
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<CToggleGroup> animSpeeds;
|
||||
std::vector<std::shared_ptr<CLabel>> labels;
|
||||
std::vector<std::shared_ptr<CToggleButton>> toggles;
|
||||
|
||||
int getAnimSpeed() const;
|
||||
public:
|
||||
BattleOptionsWindow(BattleInterface * owner = nullptr);
|
||||
};
|
||||
|
||||
|
@@ -15,10 +15,10 @@
|
||||
|
||||
#include "SystemOptionsWindow.h"
|
||||
#include "VcmiSettingsWindow.h"
|
||||
#include "BattleOptionsWindow.h"
|
||||
|
||||
#include "../../lib/filesystem/ResourceID.h"
|
||||
#include "../../lib/CGeneralTextHandler.h"
|
||||
#include "../battle/BattleInterfaceClasses.h"
|
||||
#include "../gui/CGuiHandler.h"
|
||||
#include "../lobby/CSavingScreen.h"
|
||||
#include "../widgets/Images.h"
|
||||
|
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "VcmiSettingsWindow.h"
|
||||
|
||||
#include "../lib/filesystem/ResourceID.h"
|
||||
#include "../../lib/filesystem/ResourceID.h"
|
||||
#include "gui/CGuiHandler.h"
|
||||
|
||||
VcmiSettingsWindow::VcmiSettingsWindow() : InterfaceObjectConfigurable()
|
||||
|
6
config/widgets/battleOptionsWindow.json
Normal file
6
config/widgets/battleOptionsWindow.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"items":
|
||||
[
|
||||
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user