options screen will now show current binding
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3537 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
e9a136b556
commit
cc2c62e024
@ -14,67 +14,67 @@
|
||||
<scrollable_ribbon id="devices" proportion="3" text="all" width="100%" square_items="false" align="center" child_width="256" child_height="128" />
|
||||
|
||||
|
||||
<div width="75%" proportion="1" layout="horizontal-row" >
|
||||
<label proportion="2" height="100%" text="Accelerate"/>
|
||||
<spacer width="20" height="100%" />
|
||||
<button id="binding_up" proportion="1" height="100%" text="[none]"/>
|
||||
<div width="85%" proportion="1" layout="horizontal-row" align="center">
|
||||
<label proportion="2" height="100%" text="Accelerate" text_align="right"/>
|
||||
<spacer proportion="1" height="100%" />
|
||||
<button id="binding_up" proportion="2" height="100%" text="[none]"/>
|
||||
</div>
|
||||
<spacer height="5" width="10"/>
|
||||
|
||||
|
||||
<div width="75%" proportion="1" layout="horizontal-row" >
|
||||
<label proportion="2" height="100%" text="Brake"/>
|
||||
<spacer width="20" height="100%" />
|
||||
<button id="binding_down" proportion="1" height="100%" text="[none]"/>
|
||||
<div width="85%" proportion="1" layout="horizontal-row" align="center">
|
||||
<label proportion="2" height="100%" text="Brake" text_align="right"/>
|
||||
<spacer proportion="1" height="100%" />
|
||||
<button id="binding_down" proportion="2" height="100%" text="[none]"/>
|
||||
</div>
|
||||
<spacer height="5" width="10"/>
|
||||
|
||||
<div width="75%" proportion="1" layout="horizontal-row" >
|
||||
<label proportion="2" height="100%" text="Left"/>
|
||||
<spacer width="20" height="100%" />
|
||||
<button id="binding_left" proportion="1" height="100%" text="[none]"/>
|
||||
<div width="85%" proportion="1" layout="horizontal-row" align="center">
|
||||
<label proportion="2" height="100%" text="Left" text_align="right"/>
|
||||
<spacer proportion="1" height="100%" />
|
||||
<button id="binding_left" proportion="2" height="100%" text="[none]"/>
|
||||
</div>
|
||||
<spacer height="5" width="10"/>
|
||||
|
||||
<div width="75%" proportion="1" layout="horizontal-row" >
|
||||
<label proportion="2" height="100%" text="Right"/>
|
||||
<spacer width="20" height="100%" />
|
||||
<button id="binding_right" proportion="1" height="100%" text="[none]"/>
|
||||
<div width="85%" proportion="1" layout="horizontal-row" align="center">
|
||||
<label proportion="2" height="100%" text="Right" text_align="right"/>
|
||||
<spacer proportion="1" height="100%" />
|
||||
<button id="binding_right" proportion="2" height="100%" text="[none]"/>
|
||||
</div>
|
||||
<spacer height="5" width="10"/>
|
||||
|
||||
<div width="75%" proportion="1" layout="horizontal-row" >
|
||||
<label proportion="2" height="100%" text="Fire"/>
|
||||
<spacer width="20" height="100%" />
|
||||
<button id="binding_fire" proportion="1" height="100%" text="[none]"/>
|
||||
<div width="85%" proportion="1" layout="horizontal-row" align="center">
|
||||
<label proportion="2" height="100%" text="Fire" text_align="right"/>
|
||||
<spacer proportion="1" height="100%" />
|
||||
<button id="binding_fire" proportion="2" height="100%" text="[none]"/>
|
||||
</div>
|
||||
<spacer height="5" width="10"/>
|
||||
|
||||
<div width="75%" proportion="1" layout="horizontal-row" >
|
||||
<label proportion="2" height="100%" text="Nitro"/>
|
||||
<spacer width="20" height="100%" />
|
||||
<button id="binding_nitro" proportion="1" height="100%" text="[none]"/>
|
||||
<div width="85%" proportion="1" layout="horizontal-row" align="center" >
|
||||
<label proportion="2" height="100%" text="Nitro" text_align="right"/>
|
||||
<spacer proportion="1" height="100%" />
|
||||
<button id="binding_nitro" proportion="2" height="100%" text="[none]"/>
|
||||
</div>
|
||||
<spacer height="5" width="10"/>
|
||||
|
||||
<div width="75%" proportion="1" layout="horizontal-row" >
|
||||
<label proportion="2" height="100%" text="Sharp Turn"/>
|
||||
<spacer width="20" height="100%" />
|
||||
<button id="binding_drift" proportion="1" height="100%" text="[none]"/>
|
||||
<div width="85%" proportion="1" layout="horizontal-row" align="center">
|
||||
<label proportion="2" height="100%" text="Sharp Turn" text_align="right"/>
|
||||
<spacer proportion="1" height="100%" />
|
||||
<button id="binding_drift" proportion="2" height="100%" text="[none]"/>
|
||||
</div>
|
||||
<spacer height="5" width="10"/>
|
||||
|
||||
<div width="75%" proportion="1" layout="horizontal-row" >
|
||||
<label proportion="2" height="100%" text="Rescue"/>
|
||||
<spacer width="20" height="100%" />
|
||||
<button id="binding_rescue" proportion="1" height="100%" text="[none]"/>
|
||||
<div width="85%" proportion="1" layout="horizontal-row" align="center">
|
||||
<label proportion="2" height="100%" text="Rescue" text_align="right"/>
|
||||
<spacer proportion="1" height="100%" />
|
||||
<button id="binding_rescue" proportion="2" height="100%" text="[none]"/>
|
||||
</div>
|
||||
<spacer height="5" width="10"/>
|
||||
|
||||
<div width="75%" proportion="1" layout="horizontal-row" >
|
||||
<label proportion="2" height="100%" text="Look Back"/>
|
||||
<spacer width="20" height="100%" />
|
||||
<button id="binding_look_back" proportion="1" height="100%" text="[none]"/>
|
||||
<div width="85%" proportion="1" layout="horizontal-row" align="center">
|
||||
<label proportion="2" height="100%" text="Look Back" text_align="right"/>
|
||||
<spacer proportion="1" height="100%" />
|
||||
<button id="binding_look_back" proportion="2" height="100%" text="[none]"/>
|
||||
</div>
|
||||
|
||||
<spacer width="50" height="10" />
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "input/device_manager.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "gui/state_manager.hpp"
|
||||
#include <iostream>
|
||||
|
||||
using namespace GUIEngine;
|
||||
|
||||
@ -17,8 +18,11 @@ using namespace GUIEngine;
|
||||
*/
|
||||
namespace StateManager
|
||||
{
|
||||
void eventInput(Widget* widget, const std::string& name);
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void initAudioVideo(Widget* widget, std::string& name)
|
||||
void initAudioVideo(Widget* widget, const std::string& name)
|
||||
{
|
||||
// ---- sfx volume
|
||||
SpinnerWidget* gauge = getCurrentScreen()->getWidget<SpinnerWidget>("sfx_volume");
|
||||
@ -113,7 +117,7 @@ namespace StateManager
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void eventAudioVideo(Widget* widget, std::string& name)
|
||||
void eventAudioVideo(Widget* widget, const std::string& name)
|
||||
{
|
||||
if(name == "music_volume")
|
||||
{
|
||||
@ -193,7 +197,50 @@ namespace StateManager
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void initInput(Widget* widget, std::string& name)
|
||||
void updateInputButtons(const InputDevice* device)
|
||||
{
|
||||
|
||||
{
|
||||
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_up");
|
||||
btn->setLabel( device->getBindingAsString(PA_ACCEL).c_str() );
|
||||
}
|
||||
{
|
||||
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_down");
|
||||
btn->setLabel( device->getBindingAsString(PA_BRAKE).c_str() );
|
||||
}
|
||||
{
|
||||
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_left");
|
||||
btn->setLabel( device->getBindingAsString(PA_LEFT).c_str() );
|
||||
}
|
||||
{
|
||||
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_right");
|
||||
btn->setLabel( device->getBindingAsString(PA_RIGHT).c_str() );
|
||||
}
|
||||
{
|
||||
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_fire");
|
||||
btn->setLabel( device->getBindingAsString(PA_FIRE).c_str() );
|
||||
}
|
||||
{
|
||||
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_nitro");
|
||||
btn->setLabel( device->getBindingAsString(PA_NITRO).c_str() );
|
||||
}
|
||||
{
|
||||
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_drift");
|
||||
btn->setLabel( device->getBindingAsString(PA_DRIFT).c_str() );
|
||||
}
|
||||
{
|
||||
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_rescue");
|
||||
btn->setLabel( device->getBindingAsString(PA_RESCUE).c_str() );
|
||||
}
|
||||
{
|
||||
ButtonWidget* btn = getCurrentScreen()->getWidget<ButtonWidget>("binding_look_back");
|
||||
btn->setLabel( device->getBindingAsString(PA_LOOK_BACK).c_str() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void initInput(Widget* widget, const std::string& name)
|
||||
{
|
||||
{
|
||||
RibbonGridWidget* devices = getCurrentScreen()->getWidget<RibbonGridWidget>("devices");
|
||||
@ -215,17 +262,48 @@ namespace StateManager
|
||||
|
||||
}
|
||||
devices->updateItemDisplay();
|
||||
|
||||
// trigger displaying bindings for default selected device
|
||||
const std::string name("devices");
|
||||
eventInput(devices, name);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void eventInput(Widget* widget, std::string& name)
|
||||
void eventInput(Widget* widget, const std::string& name)
|
||||
{
|
||||
if(name == "devices")
|
||||
{
|
||||
RibbonGridWidget* devices = dynamic_cast<RibbonGridWidget*>(widget);
|
||||
|
||||
const std::string& selection = devices->getSelectionName();
|
||||
if( selection.find("gamepad") != std::string::npos )
|
||||
{
|
||||
int i = -1, read = 0;
|
||||
read = sscanf( selection.c_str(), "gamepad%i", &i );
|
||||
if(read == 1 && i != -1)
|
||||
{
|
||||
updateInputButtons( input_manager->getDeviceList()->getGamePad(i) );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Cannot read internal input device ID : " << selection.c_str() << std::endl;
|
||||
}
|
||||
}
|
||||
else if(selection == "keyboard")
|
||||
{
|
||||
updateInputButtons( input_manager->getDeviceList()->getKeyboard(0) );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Cannot read internal input device ID : " << selection.c_str() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// main call (from StateManager); dispatches the call to a specialissed function as needed
|
||||
void menuEventOptions(Widget* widget, std::string& name)
|
||||
void menuEventOptions(Widget* widget, const std::string& name)
|
||||
{
|
||||
const std::string& screen_name = getCurrentScreen()->getName();
|
||||
|
||||
|
@ -11,7 +11,7 @@ namespace GUIEngine
|
||||
namespace StateManager
|
||||
{
|
||||
|
||||
void menuEventOptions(GUIEngine::Widget* widget, std::string& name);
|
||||
void menuEventOptions(GUIEngine::Widget* widget, const std::string& name);
|
||||
|
||||
}
|
||||
|
||||
|
@ -228,6 +228,10 @@ void ButtonWidget::add()
|
||||
m_element->setTabOrder(id);
|
||||
m_element->setTabGroup(false);
|
||||
}
|
||||
void ButtonWidget::setLabel(const char* label)
|
||||
{
|
||||
m_element->setText( stringw(label).c_str() );
|
||||
}
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
|
@ -152,6 +152,7 @@ namespace GUIEngine
|
||||
void add();
|
||||
public:
|
||||
virtual ~ButtonWidget() {}
|
||||
void setLabel(const char* label);
|
||||
};
|
||||
|
||||
class LabelWidget : public Widget
|
||||
|
Loading…
Reference in New Issue
Block a user