GUI will now react to user input (though menu navigation is not yet in so even though you can see it got the click nothing will happen)
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3263 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
e158423562
commit
e3fdeaaa8c
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
@ -116,8 +116,7 @@ RaceGUI::~RaceGUI()
|
|||||||
} // ~Racegui
|
} // ~Racegui
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void
|
void RaceGUI::handle(GameAction ga, int value)
|
||||||
RaceGUI::handle(GameAction ga, int value)
|
|
||||||
{
|
{
|
||||||
static int isWireframe = false;
|
static int isWireframe = false;
|
||||||
|
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
#include <irrlicht.h>
|
#include <irrlicht.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#ifndef round
|
#ifndef round
|
||||||
# define round(x) (floor(x+0.5f))
|
# define round(x) (floor(x+0.5f))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace irr;
|
using namespace irr;
|
||||||
using namespace core;
|
using namespace core;
|
||||||
@ -686,7 +686,7 @@ void RibbonGridWidget::add()
|
|||||||
for(int i=0; i<m_col_amount; i++)
|
for(int i=0; i<m_col_amount; i++)
|
||||||
{
|
{
|
||||||
IconButtonWidget* icon = new IconButtonWidget();
|
IconButtonWidget* icon = new IconButtonWidget();
|
||||||
icon->m_properties[PROP_ICON]="track?.png";
|
icon->m_properties[PROP_ICON]="track_random.png";
|
||||||
|
|
||||||
// set size to get proper ratio (as most textures are saved sccaled down to 256x256)
|
// set size to get proper ratio (as most textures are saved sccaled down to 256x256)
|
||||||
icon->m_properties[PROP_WIDTH] = m_properties[PROP_CHILD_WIDTH];
|
icon->m_properties[PROP_WIDTH] = m_properties[PROP_CHILD_WIDTH];
|
||||||
@ -905,9 +905,9 @@ void RibbonGridWidget::updateItemDisplay()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
button->setImage( GUIEngine::getDriver()->getTexture( (file_manager->getGUIDir() + "/track?.png").c_str() ) );
|
button->setImage( GUIEngine::getDriver()->getTexture( (file_manager->getGUIDir() + "/track_random").c_str() ) );
|
||||||
button->setPressedImage( GUIEngine::getDriver()->getTexture( (file_manager->getGUIDir() + "/track?.png").c_str() ) );
|
button->setPressedImage( GUIEngine::getDriver()->getTexture( (file_manager->getGUIDir() + "/track_random").c_str() ) );
|
||||||
icon->m_properties[PROP_ID] = "track?.png";
|
icon->m_properties[PROP_ID] = "track_random";
|
||||||
}
|
}
|
||||||
} // next column
|
} // next column
|
||||||
} // next row
|
} // next row
|
||||||
|
129
src/sdldrv.cpp
129
src/sdldrv.cpp
@ -43,6 +43,7 @@
|
|||||||
#include "karts/kart_properties_manager.hpp"
|
#include "karts/kart_properties_manager.hpp"
|
||||||
#include "gui/font.hpp"
|
#include "gui/font.hpp"
|
||||||
#include "gui/race_gui.hpp"
|
#include "gui/race_gui.hpp"
|
||||||
|
#include "gui/engine.hpp"
|
||||||
#include "gui/state_manager.hpp"
|
#include "gui/state_manager.hpp"
|
||||||
|
|
||||||
#define DEADZONE_MOUSE 150
|
#define DEADZONE_MOUSE 150
|
||||||
@ -229,20 +230,16 @@ void SDLDriver::toggleFullscreen(bool resetTextures)
|
|||||||
{
|
{
|
||||||
m_flags |= SDL_FULLSCREEN;
|
m_flags |= SDL_FULLSCREEN;
|
||||||
|
|
||||||
// TODO - toggle fullscreen / hide/show mouse
|
if(StateManager::isGameState())
|
||||||
/*
|
showPointer();
|
||||||
if(menu_manager->isSomewhereOnStack(MENUID_RACE))
|
|
||||||
showPointer();*/
|
|
||||||
|
|
||||||
// Store settings in user config file in case new video mode
|
// Store settings in user config file in case new video mode
|
||||||
// causes a crash
|
// causes a crash
|
||||||
user_config->m_crashed = true; //set flag.
|
user_config->m_crashed = true; //set flag.
|
||||||
user_config->saveConfig();
|
user_config->saveConfig();
|
||||||
}
|
}
|
||||||
// TODO - toggle fullscreen / hide/show mouse
|
else if(StateManager::isGameState())
|
||||||
/*
|
hidePointer();
|
||||||
else if(menu_manager->isSomewhereOnStack(MENUID_RACE))
|
|
||||||
hidePointer();*/
|
|
||||||
|
|
||||||
setVideoMode(resetTextures);
|
setVideoMode(resetTextures);
|
||||||
} // toggleFullscreen
|
} // toggleFullscreen
|
||||||
@ -327,20 +324,65 @@ SDLDriver::~SDLDriver()
|
|||||||
* Note: It is the obligation of the called menu to switch of the sense mode.
|
* Note: It is the obligation of the called menu to switch of the sense mode.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
#define MAX_VALUE 32768
|
||||||
|
|
||||||
|
void postIrrLichtMouseEvent(irr::EMOUSE_INPUT_EVENT type, const int x, const int y)
|
||||||
|
{
|
||||||
|
irr::SEvent::SMouseInput evt;
|
||||||
|
|
||||||
|
evt.Event = type;
|
||||||
|
evt.X = x;
|
||||||
|
evt.Y = y;
|
||||||
|
|
||||||
|
irr::SEvent wrapper;
|
||||||
|
wrapper.MouseInput = evt;
|
||||||
|
wrapper.EventType = EET_MOUSE_INPUT_EVENT;
|
||||||
|
|
||||||
|
GUIEngine::getDevice()->postEventFromUser(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
void SDLDriver::input(Input::InputType type, int id0, int id1, int id2,
|
void SDLDriver::input(Input::InputType type, int id0, int id1, int id2,
|
||||||
int value)
|
int value)
|
||||||
{
|
{
|
||||||
// TODO - menus handle SDL input
|
if(!StateManager::isGameState())
|
||||||
if(!StateManager::isGameState()) return;
|
|
||||||
|
|
||||||
RaceGUI* menu = getRaceGUI(); // FIXME - input is handled in menu class??
|
|
||||||
|
|
||||||
//BaseGUI* menu = menu_manager->getCurrentMenu();
|
|
||||||
|
|
||||||
GameAction ga = m_action_map->getEntry(type, id0, id1, id2);
|
|
||||||
|
|
||||||
if (menu != NULL)
|
|
||||||
{
|
{
|
||||||
|
//http://irrlicht.sourceforge.net/docu/classirr_1_1_irrlicht_device.html#bf859e39f017b0403c6ed331e48e01df
|
||||||
|
if(type == Input::IT_KEYBOARD)
|
||||||
|
{
|
||||||
|
irr::SEvent::SKeyInput evt;
|
||||||
|
|
||||||
|
if(id0 == 9)
|
||||||
|
evt.Key = irr::KEY_TAB;
|
||||||
|
else if(id0 == 13)
|
||||||
|
evt.Key = irr::KEY_RETURN;
|
||||||
|
else if(id0 == 273)
|
||||||
|
evt.Key = irr::KEY_UP;
|
||||||
|
else if(id0 == 274)
|
||||||
|
evt.Key = irr::KEY_DOWN;
|
||||||
|
else if(id0 == 275)
|
||||||
|
evt.Key = irr::KEY_RIGHT;
|
||||||
|
else if(id0 == 276)
|
||||||
|
evt.Key = irr::KEY_LEFT;
|
||||||
|
else
|
||||||
|
evt.Key = (irr::EKEY_CODE) id0; // FIXME - probably won't work, need better input handling
|
||||||
|
|
||||||
|
|
||||||
|
evt.PressedDown = value > MAX_VALUE/2;
|
||||||
|
|
||||||
|
irr::SEvent wrapper;
|
||||||
|
wrapper.KeyInput = evt;
|
||||||
|
wrapper.EventType = EET_KEY_INPUT_EVENT;
|
||||||
|
|
||||||
|
GUIEngine::getDevice()->postEventFromUser(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RaceGUI* menu = getRaceGUI(); // FIXME - input is handled in menu class??
|
||||||
|
if(menu == NULL) return;
|
||||||
|
|
||||||
|
GameAction ga = m_action_map->getEntry(type, id0, id1, id2);
|
||||||
// Act different in input sensing mode.
|
// Act different in input sensing mode.
|
||||||
if (m_mode >= INPUT_SENSE_PREFER_AXIS &&
|
if (m_mode >= INPUT_SENSE_PREFER_AXIS &&
|
||||||
m_mode <= INPUT_SENSE_PREFER_BUTTON)
|
m_mode <= INPUT_SENSE_PREFER_BUTTON)
|
||||||
@ -361,13 +403,13 @@ void SDLDriver::input(Input::InputType type, int id0, int id1, int id2,
|
|||||||
// The latter is necessary since some gamepads have analog
|
// The latter is necessary since some gamepads have analog
|
||||||
// buttons that can return two different events when pressed
|
// buttons that can return two different events when pressed
|
||||||
bool store_new = abs(value) > m_max_sensed_input ||
|
bool store_new = abs(value) > m_max_sensed_input ||
|
||||||
m_max_sensed_type == Input::IT_NONE ||
|
m_max_sensed_type == Input::IT_NONE ||
|
||||||
( m_mode == INPUT_SENSE_PREFER_AXIS &&
|
( m_mode == INPUT_SENSE_PREFER_AXIS &&
|
||||||
type == Input::IT_STICKMOTION &&
|
type == Input::IT_STICKMOTION &&
|
||||||
m_max_sensed_type != Input::IT_STICKMOTION ) ||
|
m_max_sensed_type != Input::IT_STICKMOTION ) ||
|
||||||
( m_mode == INPUT_SENSE_PREFER_BUTTON &&
|
( m_mode == INPUT_SENSE_PREFER_BUTTON &&
|
||||||
type == Input::IT_STICKBUTTON &&
|
type == Input::IT_STICKBUTTON &&
|
||||||
m_max_sensed_type != Input::IT_STICKBUTTON );
|
m_max_sensed_type != Input::IT_STICKBUTTON );
|
||||||
if(store_new)
|
if(store_new)
|
||||||
{
|
{
|
||||||
m_sensed_input->type = type;
|
m_sensed_input->type = type;
|
||||||
@ -395,11 +437,11 @@ void SDLDriver::input(Input::InputType type, int id0, int id1, int id2,
|
|||||||
y = SDL_GetVideoSurface()->h - y;
|
y = SDL_GetVideoSurface()->h - y;
|
||||||
//menu->inputPointer( x, y );
|
//menu->inputPointer( x, y );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lets the currently active menu handle the GameAction.
|
// Lets the currently active menu handle the GameAction.
|
||||||
menu->handle(ga, value);
|
menu->handle(ga, value);
|
||||||
}
|
}
|
||||||
} // menu!=NULL
|
}
|
||||||
} // input
|
} // input
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -440,18 +482,8 @@ void SDLDriver::input()
|
|||||||
input(Input::IT_KEYBOARD, ev.key.keysym.sym, 0, 0, 0);
|
input(Input::IT_KEYBOARD, ev.key.keysym.sym, 0, 0, 0);
|
||||||
break;
|
break;
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
if (m_mode == LOWLEVEL)
|
// if (m_mode == LOWLEVEL)
|
||||||
{
|
input(Input::IT_KEYBOARD, ev.key.keysym.sym,
|
||||||
// TODO - keyboard handling and GUI
|
|
||||||
/*
|
|
||||||
// Unicode translation in SDL is only done for keydown events.
|
|
||||||
// Therefore for lowlevel keyboard handling we provide no notion
|
|
||||||
// of whether a key was pressed or released.
|
|
||||||
menu_manager->getCurrentMenu()
|
|
||||||
->inputKeyboard(ev.key.keysym.sym,
|
|
||||||
ev.key.keysym.unicode);*/
|
|
||||||
}
|
|
||||||
input(Input::IT_KEYBOARD, ev.key.keysym.sym,
|
|
||||||
#ifdef HAVE_IRRLICHT
|
#ifdef HAVE_IRRLICHT
|
||||||
// FIXME: not sure why this happens: with plib the unicode
|
// FIXME: not sure why this happens: with plib the unicode
|
||||||
// value is 0. Since all values defined in user_config
|
// value is 0. Since all values defined in user_config
|
||||||
@ -465,7 +497,7 @@ void SDLDriver::input()
|
|||||||
#else
|
#else
|
||||||
ev.key.keysym.unicode,
|
ev.key.keysym.unicode,
|
||||||
#endif
|
#endif
|
||||||
0, 32768);
|
0, MAX_VALUE);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -476,14 +508,7 @@ void SDLDriver::input()
|
|||||||
// axis value) while the pointer has two.
|
// axis value) while the pointer has two.
|
||||||
if (!m_mode)
|
if (!m_mode)
|
||||||
{
|
{
|
||||||
// TODO - mouse motion handling and GUI
|
postIrrLichtMouseEvent(irr::EMIE_MOUSE_MOVED, ev.motion.x, ev.motion.y);
|
||||||
/*
|
|
||||||
BaseGUI* menu = menu_manager->getCurrentMenu();
|
|
||||||
#ifndef HAVE_IRRLICHT
|
|
||||||
if (menu != NULL)
|
|
||||||
menu->inputPointer(ev.motion.x, m_main_surface->h - ev.motion.y);
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
// If sensing input mouse movements are made less sensitive in order
|
// If sensing input mouse movements are made less sensitive in order
|
||||||
// to avoid it being detected unwantedly.
|
// to avoid it being detected unwantedly.
|
||||||
@ -514,11 +539,13 @@ void SDLDriver::input()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_MOUSEBUTTONUP:
|
||||||
input(Input::IT_MOUSEBUTTON, ev.button.button, 0, 0, 0);
|
postIrrLichtMouseEvent(irr::EMIE_LMOUSE_LEFT_UP, ev.motion.x, ev.motion.y);
|
||||||
|
//input(Input::IT_MOUSEBUTTON, ev.button.button, 0, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
input(Input::IT_MOUSEBUTTON, ev.button.button, 0, 0, 32768);
|
postIrrLichtMouseEvent(irr::EMIE_LMOUSE_PRESSED_DOWN, ev.motion.x, ev.motion.y);
|
||||||
|
//input(Input::IT_MOUSEBUTTON, ev.button.button, 0, 0, 32768);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_JOYAXISMOTION:
|
case SDL_JOYAXISMOTION:
|
||||||
|
Loading…
Reference in New Issue
Block a user