Revert "Add visual feedback to touchscreen D-pad buttons"

This reverts commit e71e99eba1.
master
MoNTE48 2018-08-23 01:43:33 +02:00
parent 4602e0cac8
commit cd029e058b
10 changed files with 63 additions and 74 deletions

View File

@ -39,33 +39,31 @@ using namespace irr::core;
extern Settings *g_settings;
const char *touchgui_button_imagenames[][2] = {
{"up_one.png", "up_one_press.png"},
{"up_two.png", "up_two_press.png"},
{"up_three.png", "up_three_press.png"},
{"down_one.png", "down_one_press.png"},
{"down_two.png", "down_two_press.png"},
{"down_three.png", "down_three_press.png"},
{"left.png", "left_press.png"},
{"right.png", "right_press.png"},
{"inventory.png", "inventory.png"},
{"drop.png", "drop.png"},
{"jump.png", "jump.png"},
{"down.png", "down.png"},
const char* touchgui_button_imagenames[] = {
"up_one.png",
"up_two.png",
"up_three.png",
"down_one.png",
"down_two.png",
"down_three.png",
"left.png",
"right.png",
"inventory.png",
"drop.png",
"jump.png",
"down.png",
/*#ifdef ENABLE_ANDROID_NOCLIP
{"noclip_btn.png", "noclip_btn.png"},
{"fast_btn.png", "fast_btn.png"},
"fly_btn.png",
"noclip_btn.png",
#endif*/
{"minimap_btn.png", "minimap_btn.png"},
{"chat.png", "chat.png"},
// {"camera.png", "camera.png"},
#ifdef __IOS__
{"rangeview_ios.png", "rangeview_ios.png"},
#else
{"rangeview.png", "rangeview.png"},
#endif
{"empty.png", "empty.png"},
{"escape.png", "escape.png"}
"minimap_btn.png",
// "debug_btn.png",
"chat.png",
// "camera.png",
"rangeview.png",
"rangeview_ios.png",
"empty.png",
"escape.png",
};
static irr::EKEY_CODE id2keycode(touch_gui_button_id id)
@ -109,13 +107,19 @@ static irr::EKEY_CODE id2keycode(touch_gui_button_id id)
key = "sneak";
break;
/*#ifdef ENABLE_ANDROID_NOCLIP
case fly_id:
key = "freemove";
break;
case noclip_id:
key = "noclip";
break;
case fast_id:
key = "fast";
break;
#endif*/
#endif
case debug_id:
key = "toggle_debug";
break;*/
case minimap_id:
key = "minimap";
break;
@ -128,6 +132,9 @@ static irr::EKEY_CODE id2keycode(touch_gui_button_id id)
case range_id:
key = "rangeselect";
break;
case range_ios_id:
key = "rangeselect";
break;
case empty_id:
key = "forward";
break;
@ -158,34 +165,22 @@ TouchScreenGUI::TouchScreenGUI(IrrlichtDevice *device, IEventReceiver* receiver)
m_screensize = device->getVideoDriver()->getScreenSize();
}
void TouchScreenGUI::loadButtonTexture(button_info* btn,
touch_gui_button_id id, rect<s32> button_rect)
void TouchScreenGUI::loadButtonTexture(button_info* btn, const char* path, rect<s32> button_rect)
{
const char *path = touchgui_button_imagenames[id][0];
const char *path_pressed = touchgui_button_imagenames[id][1];
unsigned int tid;
video::ITexture *texture = guiScalingImageButton(m_device->getVideoDriver(),
m_texturesource->getTexture(path, &tid), button_rect.getWidth(),
button_rect.getHeight());
video::ITexture *texture_pressed = texture;
if (strcmp(path, path_pressed) != 0) {
texture_pressed = guiScalingImageButton(m_device->getVideoDriver(),
m_texturesource->getTexture(path_pressed, &tid),
button_rect.getWidth(), button_rect.getHeight());
texture_pressed = (texture_pressed) ? texture_pressed : texture;
}
if (texture) {
btn->guibutton->setUseAlphaChannel(true);
if (g_settings->getBool("gui_scaling_filter")) {
rect<s32> txr_rect = rect<s32>(0, 0, button_rect.getWidth(), button_rect.getHeight());
btn->guibutton->setImage(texture, txr_rect);
btn->guibutton->setPressedImage(texture_pressed, txr_rect);
btn->guibutton->setPressedImage(texture, txr_rect);
btn->guibutton->setScaleImage(false);
} else {
btn->guibutton->setImage(texture);
btn->guibutton->setPressedImage(texture_pressed);
btn->guibutton->setPressedImage(texture);
btn->guibutton->setScaleImage(true);
}
btn->guibutton->setDrawBorder(false);
@ -206,7 +201,7 @@ void TouchScreenGUI::initButton(touch_gui_button_id id, rect<s32> button_rect,
btn->immediate_release = immediate_release;
btn->ids.clear();
loadButtonTexture(btn, id, button_rect);
loadButtonTexture(btn,touchgui_button_imagenames[id],button_rect);
}
static int getMaxControlPadSize(float density) {
@ -241,7 +236,7 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
1 4 7
2 5 8
*/
int number = 0;
for (int y = 0; y < 3; ++y)
for (int x = 0; x < 3; ++x, ++number) {
@ -327,14 +322,22 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
L"x", false, SLOW_BUTTON_REPEAT);
/*#ifdef ENABLE_ANDROID_NOCLIP
// init noclip button
// init fly button
initButton(fly_id,
rect<s32>(m_screensize.X - (0.75*button_size),
m_screensize.Y - (3.25*button_size),
m_screensize.X,
m_screensize.Y - (button_size*2.5)),
L"fly", false, SLOW_BUTTON_REPEAT);
// init noclip button
initButton(noclip_id,
rect<s32>(m_screensize.X - (0.75*button_size),
m_screensize.Y - (4.75*button_size),
m_screensize.X,
m_screensize.Y - (button_size*4)),
L"clip", false, SLOW_BUTTON_REPEAT);
// init fast button
// init fast button
initButton(fast_id,
rect<s32>(m_screensize.X - (0.75*button_size),
m_screensize.Y - (4*button_size),
@ -343,6 +346,9 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
L"fast", false, SLOW_BUTTON_REPEAT);
#endif*/
#ifdef __IOS__
// iOS bar
/* init pause button */
@ -351,9 +357,9 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
m_screensize.X / 2,
(button_size * 0.75)),
L"Exit", false, SLOW_BUTTON_REPEAT);
/* init rangeselect button */
initButton(range_id,
initButton(range_ios_id,
rect<s32>(m_screensize.X / 2, 0,
m_screensize.X / 2 + (button_size * 0.75),
(button_size * 0.75)),
@ -364,7 +370,7 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
m_screensize.X / 2 + (button_size * 1.5),
(button_size * 0.75)),
L"Chat", false, SLOW_BUTTON_REPEAT);
#else
// Android and Windows bar
/* init rangeselect button */
@ -373,14 +379,14 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
m_screensize.X / 2 - (button_size * 0.375),
(button_size * 0.75)),
L"far", false, SLOW_BUTTON_REPEAT);
/* init minimap button */
initButton(minimap_id,
rect<s32>(m_screensize.X / 2 - (button_size * 0.375), 0,
m_screensize.X / 2 + (button_size * 0.375),
(button_size * 0.75)),
L"minimap", false, SLOW_BUTTON_REPEAT);
/* init chat button */
initButton(chat_id,
rect<s32>(m_screensize.X / 2 + (button_size * 0.375), 0,
@ -389,7 +395,7 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
L"Chat", false, SLOW_BUTTON_REPEAT);
#endif
/* init camera button */
/* init camera button */
/*initButton(camera_id,
rect<s32>(0, 0,
0.75*button_size, 0.75*button_size),
@ -477,19 +483,6 @@ bool TouchScreenGUI::isReleaseHUDButton(size_t eventID)
return false;
}
void TouchScreenGUI::setButtonState(touch_gui_button_id id, bool is_pressed)
{
/*if (id == forward_one || id == forward_three) {
m_buttons[forward_two].guibutton->setPressed(is_pressed);
}
else if (id == backward_one || id == backward_three) {
m_buttons[backward_two].guibutton->setPressed(is_pressed);
}*/
//else {
m_buttons[id].guibutton->setPressed(is_pressed);
//}
}
void TouchScreenGUI::handleButtonEvent(touch_gui_button_id button,
size_t eventID, bool action)
{
@ -511,8 +504,6 @@ void TouchScreenGUI::handleButtonEvent(touch_gui_button_id button,
if (btn->ids.size() > 1) return;
btn->repeatcounter = 0;
setButtonState(button, true);
translated->KeyInput.PressedDown = true;
translated->KeyInput.Key = btn->keycode;
m_receiver->OnEvent(*translated);
@ -528,7 +519,6 @@ void TouchScreenGUI::handleButtonEvent(touch_gui_button_id button,
if (btn->ids.size() > 0) { return; }
setButtonState(button, false);
translated->KeyInput.PressedDown = false;
btn->repeatcounter = -1;
m_receiver->OnEvent(*translated);

View File

@ -48,14 +48,17 @@ typedef enum {
drop_id,
jump_id,
crunch_id,
/*#ifdef ENABLE_ANDROID_NOCLIP
#ifdef ENABLE_ANDROID_NOCLIP
fly_id,
noclip_id,
fast_id,
#endif*/
#endif
minimap_id,
// debug_id,
chat_id,
// camera_id,
range_id,
range_ios_id,
empty_id,
escape_id,
after_last_element_id
@ -152,9 +155,6 @@ private:
/* gui button by eventID */
touch_gui_button_id getButtonID(size_t eventID);
/* set button pressed state */
void setButtonState(touch_gui_button_id id, bool is_pressed);
/* check if a button has changed */
void handleChangedButton(const SEvent &event);
@ -164,8 +164,7 @@ private:
float repeat_delay = BUTTON_REPEAT_DELAY);
/* load texture */
void loadButtonTexture(button_info *btn, touch_gui_button_id id,
rect<s32> button_rect);
void loadButtonTexture(button_info *btn, const char *path, rect<s32> button_rect);
struct id_status
{

Binary file not shown.

Before

Width:  |  Height:  |  Size: 649 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 644 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 595 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 602 B