mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Only show touchscreen options on systems that have one
This commit is contained in:
@@ -238,6 +238,11 @@ void InputHandler::stopTextInput()
|
||||
textHandler->stopTextInput();
|
||||
}
|
||||
|
||||
bool InputHandler::hasTouchInputDevice() const
|
||||
{
|
||||
return fingerHandler->hasTouchInputDevice();
|
||||
}
|
||||
|
||||
bool InputHandler::isMouseButtonPressed(MouseButton button) const
|
||||
{
|
||||
return mouseHandler->isMouseButtonPressed(button) || fingerHandler->isMouseButtonPressed(button);
|
||||
|
@@ -63,6 +63,9 @@ public:
|
||||
/// Ends any existing text input state
|
||||
void stopTextInput();
|
||||
|
||||
/// returns true if system has active touchscreen
|
||||
bool hasTouchInputDevice() const;
|
||||
|
||||
/// Returns true if selected mouse button is pressed at the moment
|
||||
bool isMouseButtonPressed(MouseButton button) const;
|
||||
|
||||
|
@@ -209,6 +209,11 @@ Point InputSourceTouch::convertTouchToMouse(const SDL_TouchFingerEvent & tfinger
|
||||
return Point(tfinger.x * GH.screenDimensions().x, tfinger.y * GH.screenDimensions().y);
|
||||
}
|
||||
|
||||
bool InputSourceTouch::hasTouchInputDevice() const
|
||||
{
|
||||
return SDL_GetNumTouchDevices() > 0;
|
||||
}
|
||||
|
||||
bool InputSourceTouch::isMouseButtonPressed(MouseButton button) const
|
||||
{
|
||||
if (state == TouchState::TAP_DOWN_LONG)
|
||||
|
@@ -108,5 +108,6 @@ public:
|
||||
|
||||
void handleUpdate();
|
||||
|
||||
bool hasTouchInputDevice() const;
|
||||
bool isMouseButtonPressed(MouseButton button) const;
|
||||
};
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include "../../battle/BattleInterface.h"
|
||||
#include "../../battle/BattleActionsController.h"
|
||||
#include "../../gui/CGuiHandler.h"
|
||||
#include "../../eventsSDL/InputHandler.h"
|
||||
#include "../../../lib/filesystem/ResourceID.h"
|
||||
#include "../../../lib/CGeneralTextHandler.h"
|
||||
#include "../../widgets/Buttons.h"
|
||||
@@ -25,6 +26,8 @@ BattleOptionsTab::BattleOptionsTab(BattleInterface * owner)
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
||||
type |= REDRAW_PARENT;
|
||||
|
||||
addConditional("touchscreen", GH.input().hasTouchInputDevice());
|
||||
|
||||
const JsonNode config(ResourceID("config/widgets/settings/battleOptionsTab.json"));
|
||||
addCallback("viewGridChanged", [this, owner](bool value)
|
||||
{
|
||||
@@ -83,6 +86,7 @@ BattleOptionsTab::BattleOptionsTab(BattleInterface * owner)
|
||||
mouseShadowCheckbox->setSelected(settings["battle"]["mouseShadow"].Bool());
|
||||
|
||||
std::shared_ptr<CToggleButton> touchscreenModeCheckbox = widget<CToggleButton>("touchscreenModeCheckbox");
|
||||
if (touchscreenModeCheckbox)
|
||||
touchscreenModeCheckbox->setSelected(settings["battle"]["touchscreenMode"].Bool());
|
||||
|
||||
std::shared_ptr<CToggleButton> skipBattleIntroMusicCheckbox = widget<CToggleButton>("skipBattleIntroMusicCheckbox");
|
||||
|
@@ -79,11 +79,12 @@ GeneralOptionsTab::GeneralOptionsTab()
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
||||
type |= REDRAW_PARENT;
|
||||
|
||||
addConditional("mobile", false);
|
||||
addConditional("desktop", true);
|
||||
#ifdef VCMI_MOBILE
|
||||
addConditional("mobile", true);
|
||||
addConditional("desktop", false);
|
||||
#else
|
||||
addConditional("mobile", false);
|
||||
addConditional("desktop", true);
|
||||
#endif
|
||||
|
||||
const JsonNode config(ResourceID("config/widgets/settings/generalOptionsTab.json"));
|
||||
|
@@ -114,6 +114,7 @@
|
||||
"text": "vcmi.battleOptions.skipBattleIntroMusic.hover",
|
||||
},
|
||||
{
|
||||
"created" : "touchscreen",
|
||||
"text": "vcmi.battleOptions.touchscreenMode.hover",
|
||||
}
|
||||
]
|
||||
@@ -152,6 +153,7 @@
|
||||
{
|
||||
"name": "touchscreenModeCheckbox",
|
||||
"help": "vcmi.battleOptions.touchscreenMode",
|
||||
"created" : "touchscreen",
|
||||
"callback": "touchscreenModeChanged"
|
||||
},
|
||||
]
|
||||
|
Reference in New Issue
Block a user