From 41a74817f7b785c6a35ce9c5e6bafcf41c913a92 Mon Sep 17 00:00:00 2001 From: Benau Date: Fri, 16 Aug 2019 21:56:21 +0800 Subject: [PATCH] Allow steering wheel following touchscreen control with acceleration indicator --- .../android/steering_wheel_mask_down.png | Bin 0 -> 2475 bytes .../icons/android/steering_wheel_mask_up.png | Bin 0 -> 2967 bytes src/states_screens/race_gui_multitouch.cpp | 33 ++++++++++++++++-- src/states_screens/race_gui_multitouch.hpp | 2 ++ 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 data/gui/icons/android/steering_wheel_mask_down.png create mode 100644 data/gui/icons/android/steering_wheel_mask_up.png diff --git a/data/gui/icons/android/steering_wheel_mask_down.png b/data/gui/icons/android/steering_wheel_mask_down.png new file mode 100644 index 0000000000000000000000000000000000000000..f7f2b1553b474ef693647e67100ac974f221f014 GIT binary patch literal 2475 zcmbVO{W}wi9^Vp?_tO;-5n&NB#throX0sRDjIqsFGt7+5=52;Cd7U%w!bu9HL*dXV zZ{?KZ)=^ilu9DR8QYv-M?UYl<)pP%Y`+c78=ll77p6~N~pYJc<=Tk~11?lfL-wgl& z^l?}e6#xKkQy@TFW4j2tBWM7CCR9d?kWx7r)}qvuIDQh(TAC%|S@SaaaR5N(lT|vi ze#u^MBi4a#_^7dCm#IESoLY=+l9~-c{W^4_GDE*=q_J zbZElZuZ(a?ZHJz9?i1Ce%zdVyk53263tAe-NH2iXW_OlWbfZ3e@tn85al7Vjzmduq zvmrV+WxjQ1(_>&wC+bX6NcVF(^r*gm#d+4>>;|S2OPY8L{wy^w}^3m=qLaM@7%AyvC|iRKy9FfZ6^d< zJatPi*y|LZtfCBk*$Yy~$r*@35m(c524US5j@(G_94Bkzi3jhaejPt#e)&oJrL(K@ zwt&d4GDw(bnm)J7ewuLS_K^|qg+2DqST)VVK{59gD`T$^>Jqlk+LMmU7w3l7%(PEY zid7Kl%pb=6gqE4F{Y2t}vr`cRM!{V!k;0XqmYg8RgdZ+4(`Sc->)$&Fyt>{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|l$_+8(?9cjK?-6OeFD0Qi4{o2m{V<%4ms2c&L0jM^-A@K97f0AP6RuS-Rg z!-ShnSpgc0ke%4BB(G!D{M!<@xdTSq+mJT};ZQS2`qZwi@b$si7gD`&z>D7R7l88m zkLI5{I3HiCaVy`r6R~7A@cPKm;}x3Qbd77%suN~fI=^P4XyTb%97PIKmzdr5nhx_H<*x0ImXeF6QS6VH#8OvTBKlEr?IW{?Q zNEIrRJuVHEz54l26dVkVQQrCKMR3CS>Y}r0bRMp>^-cJn`RAxrhHjCk8dsyxQ*(TW vOjD2lL{+c6-~WY=@>*}?HXrlgetTexture(FileManager::GUI_ICON,"challenge.png"); m_up_tex = irr_driver->getTexture(FileManager::GUI_ICON, "up.png"); m_down_tex = irr_driver->getTexture(FileManager::GUI_ICON, "down.png"); - +#ifndef SERVER_ONLY + if (CVS->isGLSL()) + { + m_steering_wheel_tex_mask_up = irr_driver->getTexture(FileManager::GUI_ICON, + "android/steering_wheel_mask_up.png"); + m_steering_wheel_tex_mask_down = irr_driver->getTexture(FileManager::GUI_ICON, + "android/steering_wheel_mask_down.png"); + } +#endif auto cl = LobbyProtocol::get(); if (cl && cl->isSpectator()) @@ -352,8 +364,23 @@ void RaceGUIMultitouch::draw(const AbstractKart* kart, { video::ITexture* btn_texture = m_steering_wheel_tex; core::rect coords(pos_zero, btn_texture->getSize()); - draw2DImage(btn_texture, btn_pos, coords, NULL, NULL, true); - + draw2DImage(btn_texture, btn_pos, coords, NULL, NULL, true, false/*draw_translucently*/, + (button->axis_y >= 0 ? -1 : 1) * button->axis_x); +#ifndef SERVER_ONLY + AbstractKart* k = NULL; + Camera* c = Camera::getActiveCamera(); + if (c) + k = c->getKart(); + if (CVS->isGLSL() && k) + { + float accel = k->getControls().getAccel(); + core::rect mask_coords(pos_zero, m_steering_wheel_tex_mask_up->getSize()); + draw2DImageCustomAlpha(m_steering_wheel_tex_mask_up, btn_pos, mask_coords, NULL, + (button->axis_y >= 0 ? -1 : 1) * button->axis_x, accel >= 0.0f ? accel * 0.5f : 0.0f); + draw2DImageCustomAlpha(m_steering_wheel_tex_mask_down, btn_pos, mask_coords, NULL, + (button->axis_y >= 0 ? -1 : 1) * button->axis_x, k->getControls().getBrake() ? 0.5f : 0.0f); + } +#endif // float x = (float)(button->x) + (float)(button->width) / 2.0f * // (button->axis_x + 1.0f); // float y = (float)(button->y) + (float)(button->height) / 2.0f * diff --git a/src/states_screens/race_gui_multitouch.hpp b/src/states_screens/race_gui_multitouch.hpp index 3b93cad34..9e39ceb15 100644 --- a/src/states_screens/race_gui_multitouch.hpp +++ b/src/states_screens/race_gui_multitouch.hpp @@ -40,6 +40,8 @@ private: unsigned int m_height; video::ITexture* m_steering_wheel_tex; + video::ITexture* m_steering_wheel_tex_mask_up; + video::ITexture* m_steering_wheel_tex_mask_down; video::ITexture* m_up_down_tex; video::ITexture* m_pause_tex; video::ITexture* m_nitro_tex;