mirror of
https://github.com/overte-org/overte.git
synced 2025-04-07 00:52:58 +02:00
Android - Virtual Pad - make jump button references generic
This commit is contained in:
parent
1891b0fd81
commit
8839a3b027
5 changed files with 22 additions and 24 deletions
|
@ -76,11 +76,11 @@ void Basic2DWindowOpenGLDisplayPlugin::customizeContext() {
|
|||
|
||||
if (_virtualPadButtons.size() == 0) {
|
||||
_virtualPadButtons.append(VirtualPadButton(
|
||||
dpi * VirtualPad::Manager::JUMP_BTN_FULL_PIXELS / VirtualPad::Manager::DPI,
|
||||
dpi * VirtualPad::Manager::BTN_FULL_PIXELS / VirtualPad::Manager::DPI,
|
||||
PathUtils::resourcesPath() + "images/fly.png",
|
||||
VirtualPad::Manager::Button::JUMP));
|
||||
_virtualPadButtons.append(VirtualPadButton(
|
||||
dpi * VirtualPad::Manager::JUMP_BTN_FULL_PIXELS / VirtualPad::Manager::DPI,
|
||||
dpi * VirtualPad::Manager::BTN_FULL_PIXELS / VirtualPad::Manager::DPI,
|
||||
PathUtils::resourcesPath() + "images/handshake.png",
|
||||
VirtualPad::Manager::Button::HANDSHAKE));
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ void TouchscreenVirtualPadDevice::resize() {
|
|||
_fixedRadius = _screenDPI * 0.5f * VirtualPad::Manager::BASE_DIAMETER_PIXELS / VirtualPad::Manager::DPI;
|
||||
_fixedRadiusForCalc = _fixedRadius - _screenDPI * VirtualPad::Manager::STICK_RADIUS_PIXELS / VirtualPad::Manager::DPI;
|
||||
|
||||
_buttonRadius = _screenDPI * VirtualPad::Manager::JUMP_BTN_TRIMMED_RADIUS_PIXELS / VirtualPad::Manager::DPI;
|
||||
_buttonRadius = _screenDPI * VirtualPad::Manager::BTN_TRIMMED_RADIUS_PIXELS / VirtualPad::Manager::DPI;
|
||||
}
|
||||
|
||||
auto& virtualPadManager = VirtualPad::Manager::instance();
|
||||
|
@ -86,15 +86,15 @@ void TouchscreenVirtualPadDevice::setupControlsPositions(VirtualPad::Manager& vi
|
|||
virtualPadManager.getLeftVirtualPad()->setFirstTouch(_moveRefTouchPoint);
|
||||
|
||||
// Jump button
|
||||
float jumpBtnPixelSize = _screenDPI * VirtualPad::Manager::JUMP_BTN_FULL_PIXELS / VirtualPad::Manager::DPI;
|
||||
float rightMargin = _screenDPI * VirtualPad::Manager::JUMP_BTN_RIGHT_MARGIN_PIXELS / VirtualPad::Manager::DPI;
|
||||
float bottomMargin = _screenDPI * VirtualPad::Manager::JUMP_BTN_BOTTOM_MARGIN_PIXELS/ VirtualPad::Manager::DPI;
|
||||
glm::vec2 jumpButtonPosition = glm::vec2( eventScreen->availableSize().width() - rightMargin - jumpBtnPixelSize, eventScreen->availableSize().height() - bottomMargin - _buttonRadius - _extraBottomMargin);
|
||||
glm::vec2 rbButtonPosition = glm::vec2( eventScreen->availableSize().width() - rightMargin - jumpBtnPixelSize, eventScreen->availableSize().height() - 2 * bottomMargin - 3 * _buttonRadius - _extraBottomMargin);
|
||||
float btnPixelSize = _screenDPI * VirtualPad::Manager::BTN_FULL_PIXELS / VirtualPad::Manager::DPI;
|
||||
float rightMargin = _screenDPI * VirtualPad::Manager::BTN_RIGHT_MARGIN_PIXELS / VirtualPad::Manager::DPI;
|
||||
float bottomMargin = _screenDPI * VirtualPad::Manager::BTN_BOTTOM_MARGIN_PIXELS/ VirtualPad::Manager::DPI;
|
||||
glm::vec2 jumpButtonPosition = glm::vec2( eventScreen->availableSize().width() - rightMargin - btnPixelSize, eventScreen->availableSize().height() - bottomMargin - _buttonRadius - _extraBottomMargin);
|
||||
glm::vec2 rbButtonPosition = glm::vec2( eventScreen->availableSize().width() - rightMargin - btnPixelSize, eventScreen->availableSize().height() - 2 * bottomMargin - 3 * _buttonRadius - _extraBottomMargin);
|
||||
|
||||
// Avoid generating buttons in portrait mode
|
||||
if ( eventScreen->availableSize().width() > eventScreen->availableSize().height() && _buttonsManager.buttonsCount() == 0) {
|
||||
_buttonsManager.addButton(TouchscreenButton(JUMP_BUTTON_PRESS, JUMP, _buttonRadius, jumpButtonPosition, _inputDevice ));
|
||||
_buttonsManager.addButton(TouchscreenButton(JUMP, JUMP_BUTTON, _buttonRadius, jumpButtonPosition, _inputDevice ));
|
||||
_buttonsManager.addButton(TouchscreenButton(RB, RB_BUTTON, _buttonRadius, rbButtonPosition, _inputDevice ));
|
||||
|
||||
virtualPadManager.setButtonPosition(VirtualPad::Manager::Button::JUMP, jumpButtonPosition);
|
||||
|
@ -466,7 +466,7 @@ controller::Input::NamedVector TouchscreenVirtualPadDevice::InputDevice::getAvai
|
|||
Input::NamedPair(makeInput(TouchAxisChannel::LY), "LY"),
|
||||
Input::NamedPair(makeInput(TouchAxisChannel::RX), "RX"),
|
||||
Input::NamedPair(makeInput(TouchAxisChannel::RY), "RY"),
|
||||
Input::NamedPair(makeInput(TouchButtonChannel::JUMP_BUTTON_PRESS), "JUMP_BUTTON_PRESS"),
|
||||
Input::NamedPair(makeInput(TouchButtonChannel::JUMP), "JUMP_BUTTON_PRESS"),
|
||||
Input::NamedPair(makeInput(TouchButtonChannel::RB), "RB")
|
||||
};
|
||||
return availableInputs;
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
};
|
||||
|
||||
enum TouchButtonChannel {
|
||||
JUMP_BUTTON_PRESS,
|
||||
JUMP,
|
||||
RB
|
||||
};
|
||||
|
||||
|
@ -84,7 +84,7 @@ protected:
|
|||
enum TouchType {
|
||||
MOVE = 1,
|
||||
VIEW,
|
||||
JUMP,
|
||||
JUMP_BUTTON,
|
||||
RB_BUTTON
|
||||
};
|
||||
|
||||
|
|
|
@ -38,10 +38,10 @@ namespace VirtualPad {
|
|||
const float Manager::BASE_DIAMETER_PIXELS = 512.0f;
|
||||
const float Manager::BASE_MARGIN_PIXELS = 59.0f;
|
||||
const float Manager::STICK_RADIUS_PIXELS = 105.0f;
|
||||
const float Manager::JUMP_BTN_TRIMMED_RADIUS_PIXELS = 67.0f;
|
||||
const float Manager::JUMP_BTN_FULL_PIXELS = 164.0f;
|
||||
const float Manager::JUMP_BTN_BOTTOM_MARGIN_PIXELS = 80.0f;
|
||||
const float Manager::JUMP_BTN_RIGHT_MARGIN_PIXELS = 13.0f;
|
||||
const float Manager::BTN_TRIMMED_RADIUS_PIXELS = 67.0f;
|
||||
const float Manager::BTN_FULL_PIXELS = 164.0f;
|
||||
const float Manager::BTN_BOTTOM_MARGIN_PIXELS = 80.0f;
|
||||
const float Manager::BTN_RIGHT_MARGIN_PIXELS = 13.0f;
|
||||
|
||||
Manager::Manager() {
|
||||
|
||||
|
|
|
@ -59,21 +59,19 @@ namespace VirtualPad {
|
|||
static const float BASE_DIAMETER_PIXELS;
|
||||
static const float BASE_MARGIN_PIXELS;
|
||||
static const float STICK_RADIUS_PIXELS;
|
||||
static const float JUMP_BTN_TRIMMED_RADIUS_PIXELS;
|
||||
static const float JUMP_BTN_FULL_PIXELS;
|
||||
static const float JUMP_BTN_BOTTOM_MARGIN_PIXELS;
|
||||
static const float JUMP_BTN_RIGHT_MARGIN_PIXELS;
|
||||
static const float BTN_TRIMMED_RADIUS_PIXELS;
|
||||
static const float BTN_FULL_PIXELS;
|
||||
static const float BTN_BOTTOM_MARGIN_PIXELS;
|
||||
static const float BTN_RIGHT_MARGIN_PIXELS;
|
||||
|
||||
signals:
|
||||
void hapticFeedbackRequested(int duration);
|
||||
|
||||
private:
|
||||
Instance _leftVPadInstance;
|
||||
bool _enabled {true};
|
||||
bool _enabled { true };
|
||||
bool _hidden;
|
||||
glm::vec2 _jumpButtonPosition;
|
||||
glm::vec2 _rbButtonPosition;
|
||||
int _extraBottomMargin {0};
|
||||
int _extraBottomMargin { 0 };
|
||||
std::map<Button, glm::vec2> _buttonsPositions;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue