mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Feature and setting implemented
This commit is contained in:
@@ -79,6 +79,8 @@
|
|||||||
"vcmi.battleOptions.animationsSpeed1.help": "Set animation speed to very slow",
|
"vcmi.battleOptions.animationsSpeed1.help": "Set animation speed to very slow",
|
||||||
"vcmi.battleOptions.animationsSpeed5.help": "Set animation speed to very fast",
|
"vcmi.battleOptions.animationsSpeed5.help": "Set animation speed to very fast",
|
||||||
"vcmi.battleOptions.animationsSpeed6.help": "Set animation speed to instantaneous",
|
"vcmi.battleOptions.animationsSpeed6.help": "Set animation speed to instantaneous",
|
||||||
|
"vcmi.battleOptions.touchscreenMode.hover": "Touchscreen mode",
|
||||||
|
"vcmi.battleOptions.touchscreenMode.help": "{Touchscreen mode}\n\nIf enabled, second click is required to confirm and execute action. This is more suitable for touchscreen devices.",
|
||||||
"vcmi.battleOptions.skipBattleIntroMusic.hover": "Skip Intro Music",
|
"vcmi.battleOptions.skipBattleIntroMusic.hover": "Skip Intro Music",
|
||||||
"vcmi.battleOptions.skipBattleIntroMusic.help": "{Skip Intro Music}\n\nAllow actions during the intro music that plays at the beginning of each battle",
|
"vcmi.battleOptions.skipBattleIntroMusic.help": "{Skip Intro Music}\n\nAllow actions during the intro music that plays at the beginning of each battle",
|
||||||
"vcmi.battleWindow.pressKeyToSkipIntro" : "Press any key to start battle immediately",
|
"vcmi.battleWindow.pressKeyToSkipIntro" : "Press any key to start battle immediately",
|
||||||
|
@@ -115,7 +115,9 @@ BattleActionsController::BattleActionsController(BattleInterface & owner):
|
|||||||
owner(owner),
|
owner(owner),
|
||||||
selectedStack(nullptr),
|
selectedStack(nullptr),
|
||||||
heroSpellToCast(nullptr)
|
heroSpellToCast(nullptr)
|
||||||
{}
|
{
|
||||||
|
touchscreenMode = settings["battle"]["touchscreenMode"].Bool();
|
||||||
|
}
|
||||||
|
|
||||||
void BattleActionsController::endCastingSpell()
|
void BattleActionsController::endCastingSpell()
|
||||||
{
|
{
|
||||||
@@ -826,6 +828,10 @@ void BattleActionsController::onHoverEnded()
|
|||||||
|
|
||||||
void BattleActionsController::onHexLeftClicked(BattleHex clickedHex)
|
void BattleActionsController::onHexLeftClicked(BattleHex clickedHex)
|
||||||
{
|
{
|
||||||
|
static BattleHex lastSelectedHex;
|
||||||
|
static BattleHex lastDirectionalHex;
|
||||||
|
static PossiblePlayerBattleAction::Actions lastSelectedAction;
|
||||||
|
|
||||||
if (owner.stacksController->getActiveStack() == nullptr)
|
if (owner.stacksController->getActiveStack() == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -835,10 +841,25 @@ void BattleActionsController::onHexLeftClicked(BattleHex clickedHex)
|
|||||||
|
|
||||||
if (!actionIsLegal(action, clickedHex))
|
if (!actionIsLegal(action, clickedHex))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
auto directionalHex = lastDirectionalHex;
|
||||||
|
if(action.get() == PossiblePlayerBattleAction::ATTACK
|
||||||
|
|| action.get() == PossiblePlayerBattleAction::WALK_AND_ATTACK
|
||||||
|
|| action.get() == PossiblePlayerBattleAction::ATTACK_AND_RETURN)
|
||||||
|
directionalHex = owner.fieldController->fromWhichHexAttack(clickedHex);
|
||||||
|
|
||||||
actionRealize(action, clickedHex);
|
if(!touchscreenMode || (lastSelectedAction == action.get() && lastSelectedHex == clickedHex && lastDirectionalHex == directionalHex))
|
||||||
|
{
|
||||||
|
actionRealize(action, clickedHex);
|
||||||
|
|
||||||
GH.statusbar->clear();
|
GH.statusbar->clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lastSelectedAction = action.get();
|
||||||
|
lastSelectedHex = clickedHex;
|
||||||
|
lastDirectionalHex = directionalHex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleActionsController::tryActivateStackSpellcasting(const CStack *casterStack)
|
void BattleActionsController::tryActivateStackSpellcasting(const CStack *casterStack)
|
||||||
@@ -994,3 +1015,8 @@ void BattleActionsController::pushFrontPossibleAction(PossiblePlayerBattleAction
|
|||||||
{
|
{
|
||||||
possibleActions.insert(possibleActions.begin(), action);
|
possibleActions.insert(possibleActions.begin(), action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BattleActionsController::setTouchScreenMode(bool enabled)
|
||||||
|
{
|
||||||
|
touchscreenMode = enabled;
|
||||||
|
}
|
||||||
|
@@ -34,7 +34,10 @@ enum class MouseHoveredHexContext
|
|||||||
class BattleActionsController
|
class BattleActionsController
|
||||||
{
|
{
|
||||||
BattleInterface & owner;
|
BattleInterface & owner;
|
||||||
|
|
||||||
|
/// mouse or touchscreen click mode
|
||||||
|
bool touchscreenMode = false;
|
||||||
|
|
||||||
/// all actions possible to call at the moment by player
|
/// all actions possible to call at the moment by player
|
||||||
std::vector<PossiblePlayerBattleAction> possibleActions;
|
std::vector<PossiblePlayerBattleAction> possibleActions;
|
||||||
|
|
||||||
@@ -129,4 +132,5 @@ public:
|
|||||||
/// inserts possible action in the beggining in order to prioritize it
|
/// inserts possible action in the beggining in order to prioritize it
|
||||||
void pushFrontPossibleAction(PossiblePlayerBattleAction);
|
void pushFrontPossibleAction(PossiblePlayerBattleAction);
|
||||||
|
|
||||||
|
void setTouchScreenMode(bool enabled);
|
||||||
};
|
};
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include "CConfigHandler.h"
|
#include "CConfigHandler.h"
|
||||||
|
|
||||||
#include "../../battle/BattleInterface.h"
|
#include "../../battle/BattleInterface.h"
|
||||||
|
#include "../../battle/BattleActionsController.h"
|
||||||
#include "../../gui/CGuiHandler.h"
|
#include "../../gui/CGuiHandler.h"
|
||||||
#include "../../../lib/filesystem/ResourceID.h"
|
#include "../../../lib/filesystem/ResourceID.h"
|
||||||
#include "../../../lib/CGeneralTextHandler.h"
|
#include "../../../lib/CGeneralTextHandler.h"
|
||||||
@@ -53,6 +54,10 @@ BattleOptionsTab::BattleOptionsTab(BattleInterface * owner)
|
|||||||
{
|
{
|
||||||
skipBattleIntroMusicChangedCallback(value);
|
skipBattleIntroMusicChangedCallback(value);
|
||||||
});
|
});
|
||||||
|
addCallback("touchscreenModeChanged", [this, owner](bool value)
|
||||||
|
{
|
||||||
|
touchscreenModeChangedCallback(value, owner);
|
||||||
|
});
|
||||||
build(config);
|
build(config);
|
||||||
|
|
||||||
std::shared_ptr<CToggleGroup> animationSpeedToggle = widget<CToggleGroup>("animationSpeedPicker");
|
std::shared_ptr<CToggleGroup> animationSpeedToggle = widget<CToggleGroup>("animationSpeedPicker");
|
||||||
@@ -69,6 +74,9 @@ BattleOptionsTab::BattleOptionsTab(BattleInterface * owner)
|
|||||||
|
|
||||||
std::shared_ptr<CToggleButton> mouseShadowCheckbox = widget<CToggleButton>("mouseShadowCheckbox");
|
std::shared_ptr<CToggleButton> mouseShadowCheckbox = widget<CToggleButton>("mouseShadowCheckbox");
|
||||||
mouseShadowCheckbox->setSelected(settings["battle"]["mouseShadow"].Bool());
|
mouseShadowCheckbox->setSelected(settings["battle"]["mouseShadow"].Bool());
|
||||||
|
|
||||||
|
std::shared_ptr<CToggleButton> touchscreenModeCheckbox = widget<CToggleButton>("touchscreenModeCheckbox");
|
||||||
|
touchscreenModeCheckbox->setSelected(settings["battle"]["touchscreenMode"].Bool());
|
||||||
|
|
||||||
std::shared_ptr<CToggleButton> skipBattleIntroMusicCheckbox = widget<CToggleButton>("skipBattleIntroMusicCheckbox");
|
std::shared_ptr<CToggleButton> skipBattleIntroMusicCheckbox = widget<CToggleButton>("skipBattleIntroMusicCheckbox");
|
||||||
skipBattleIntroMusicCheckbox->setSelected(settings["gameTweaks"]["skipBattleIntroMusic"].Bool());
|
skipBattleIntroMusicCheckbox->setSelected(settings["gameTweaks"]["skipBattleIntroMusic"].Bool());
|
||||||
@@ -136,6 +144,14 @@ void BattleOptionsTab::mouseShadowChangedCallback(bool value)
|
|||||||
shadow->Bool() = value;
|
shadow->Bool() = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BattleOptionsTab::touchscreenModeChangedCallback(bool value, BattleInterface * parentBattleInterface)
|
||||||
|
{
|
||||||
|
Settings touchcreenMode = settings.write["battle"]["touchscreenMode"];
|
||||||
|
touchcreenMode->Bool() = value;
|
||||||
|
if(parentBattleInterface)
|
||||||
|
parentBattleInterface->actionsController->setTouchScreenMode(value);
|
||||||
|
}
|
||||||
|
|
||||||
void BattleOptionsTab::animationSpeedChangedCallback(int value)
|
void BattleOptionsTab::animationSpeedChangedCallback(int value)
|
||||||
{
|
{
|
||||||
Settings speed = settings.write["battle"]["speedFactor"];
|
Settings speed = settings.write["battle"]["speedFactor"];
|
||||||
|
@@ -29,6 +29,7 @@ private:
|
|||||||
void showQueueChangedCallback(bool value, BattleInterface * parentBattleInterface);
|
void showQueueChangedCallback(bool value, BattleInterface * parentBattleInterface);
|
||||||
void queueSizeChangedCallback(int value, BattleInterface * parentBattleInterface);
|
void queueSizeChangedCallback(int value, BattleInterface * parentBattleInterface);
|
||||||
void skipBattleIntroMusicChangedCallback(bool value);
|
void skipBattleIntroMusicChangedCallback(bool value);
|
||||||
|
void touchscreenModeChangedCallback(bool value, BattleInterface * parentBattleInterface);
|
||||||
public:
|
public:
|
||||||
BattleOptionsTab(BattleInterface * owner = nullptr);
|
BattleOptionsTab(BattleInterface * owner = nullptr);
|
||||||
};
|
};
|
||||||
|
@@ -286,7 +286,7 @@
|
|||||||
"type" : "object",
|
"type" : "object",
|
||||||
"additionalProperties" : false,
|
"additionalProperties" : false,
|
||||||
"default": {},
|
"default": {},
|
||||||
"required" : [ "speedFactor", "mouseShadow", "cellBorders", "stackRange", "showQueue", "queueSize" ],
|
"required" : [ "speedFactor", "mouseShadow", "cellBorders", "stackRange", "showQueue", "queueSize", "touchscreenMode" ],
|
||||||
"properties" : {
|
"properties" : {
|
||||||
"speedFactor" : {
|
"speedFactor" : {
|
||||||
"type" : "number",
|
"type" : "number",
|
||||||
@@ -300,6 +300,10 @@
|
|||||||
"type" : "boolean",
|
"type" : "boolean",
|
||||||
"default" : false
|
"default" : false
|
||||||
},
|
},
|
||||||
|
"touchscreenMode" : {
|
||||||
|
"type" : "boolean",
|
||||||
|
"default" : false
|
||||||
|
},
|
||||||
"stackRange" : {
|
"stackRange" : {
|
||||||
"type" : "boolean",
|
"type" : "boolean",
|
||||||
"default" : true
|
"default" : true
|
||||||
|
@@ -5,13 +5,13 @@
|
|||||||
"name": "lineCreatureInfo",
|
"name": "lineCreatureInfo",
|
||||||
"type": "texture",
|
"type": "texture",
|
||||||
"image": "settingsWindow/lineHorizontal",
|
"image": "settingsWindow/lineHorizontal",
|
||||||
"rect": { "x" : 5, "y" : 199, "w": 365, "h": 3}
|
"rect": { "x" : 5, "y" : 229, "w": 365, "h": 3}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "lineAnimationSpeed",
|
"name": "lineAnimationSpeed",
|
||||||
"type": "texture",
|
"type": "texture",
|
||||||
"image": "settingsWindow/lineHorizontal",
|
"image": "settingsWindow/lineHorizontal",
|
||||||
"rect": { "x" : 5, "y" : 289, "w": 365, "h": 3}
|
"rect": { "x" : 5, "y" : 319, "w": 365, "h": 3}
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "core.genrltxt.397", // Creature info
|
"text": "core.genrltxt.397", // Creature info
|
||||||
"position": {"x": 10, "y": 205}
|
"position": {"x": 10, "y": 235}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -104,11 +104,11 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"text": "core.genrltxt.402", // All Stats
|
"text": "core.genrltxt.402", // All Stats
|
||||||
"position": {"x": 45, "y": 235}
|
"position": {"x": 45, "y": 265}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "core.genrltxt.403", // Spells only
|
"text": "core.genrltxt.403", // Spells only
|
||||||
"position": {"x": 45, "y": 265}
|
"position": {"x": 45, "y": 295}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -116,13 +116,13 @@
|
|||||||
"name": "creatureInfoAllPlaceholder",
|
"name": "creatureInfoAllPlaceholder",
|
||||||
"type": "picture",
|
"type": "picture",
|
||||||
"image": "settingsWindow/checkBoxEmpty",
|
"image": "settingsWindow/checkBoxEmpty",
|
||||||
"position": {"x": 10, "y": 233},
|
"position": {"x": 10, "y": 263},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "creatureInfoSpellsPlaceholder",
|
"name": "creatureInfoSpellsPlaceholder",
|
||||||
"type": "picture",
|
"type": "picture",
|
||||||
"image": "settingsWindow/checkBoxEmpty",
|
"image": "settingsWindow/checkBoxEmpty",
|
||||||
"position": {"x": 10, "y": 263},
|
"position": {"x": 10, "y": 293},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -152,6 +152,10 @@
|
|||||||
{
|
{
|
||||||
"text": "vcmi.battleOptions.skipBattleIntroMusic.hover",
|
"text": "vcmi.battleOptions.skipBattleIntroMusic.hover",
|
||||||
"position": {"x": 45, "y": 175}
|
"position": {"x": 45, "y": 175}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "vcmi.battleOptions.touchscreenMode.hover",
|
||||||
|
"position": {"x": 45, "y": 205}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -194,6 +198,14 @@
|
|||||||
"position": {"x": 10, "y": 173},
|
"position": {"x": 10, "y": 173},
|
||||||
"callback": "skipBattleIntroMusicChanged"
|
"callback": "skipBattleIntroMusicChanged"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "touchscreenModeCheckbox",
|
||||||
|
"type": "toggleButton",
|
||||||
|
"image": "sysopchk.def",
|
||||||
|
"help": "vcmi.battleOptions.touchscreenMode",
|
||||||
|
"position": {"x": 10, "y": 203},
|
||||||
|
"callback": "touchscreenModeChanged"
|
||||||
|
},
|
||||||
/////////////////////////////////////// Bottom section - Animation Speed and Turn Order
|
/////////////////////////////////////// Bottom section - Animation Speed and Turn Order
|
||||||
{
|
{
|
||||||
"name": "frameAnimationSpeed",
|
"name": "frameAnimationSpeed",
|
||||||
|
Reference in New Issue
Block a user