Allow to draw steering wheel on the right side

This commit is contained in:
Deve 2017-07-05 21:21:33 +02:00
parent 2cda14686d
commit 9fc1acc4c0
4 changed files with 53 additions and 18 deletions

View File

@ -15,6 +15,14 @@
</div>
</div>
<div width="75%" layout="horizontal-row" proportion="1">
<label proportion="1" align="center" text_align="right" I18N="In the multitouch settings screen" text="Inverted buttons"/>
<div proportion="1" align="center" height="fit" layout="horizontal-row" >
<spacer width="40" height="10" />
<checkbox id="buttons_inverted"/>
</div>
</div>
<div width="75%" layout="horizontal-row" proportion="1">
<label proportion="1" align="center" text_align="right" I18N="In the multitouch settings screen" text="Buttons scale"/>
<div proportion="1" align="center" height="fit" layout="horizontal-row" >

View File

@ -414,6 +414,11 @@ namespace UserConfigParams
&m_multitouch_group,
"Steering mode: 0 = off, 1 = buttons"));
PARAM_PREFIX BoolUserConfigParam m_multitouch_inverted
PARAM_DEFAULT( BoolUserConfigParam(false, "multitouch_inverted",
&m_multitouch_group,
"Draw steering wheel on right side.") );
PARAM_PREFIX IntUserConfigParam m_multitouch_accelerometer
PARAM_DEFAULT( IntUserConfigParam(0, "multitouch_accelerometer",
&m_multitouch_group,

View File

@ -90,6 +90,10 @@ GUIEngine::EventPropagation MultitouchSettingsDialog::processEvent(
assert(buttons_en != NULL);
UserConfigParams::m_multitouch_mode = buttons_en->getState() ? 1 : 0;
CheckBoxWidget* buttons_inv = getWidget<CheckBoxWidget>("buttons_inverted");
assert(buttons_inv != NULL);
UserConfigParams::m_multitouch_inverted = buttons_inv->getState();
SpinnerWidget* accelerometer = getWidget<SpinnerWidget>("accelerometer");
assert(accelerometer != NULL);
@ -146,6 +150,10 @@ void MultitouchSettingsDialog::updateValues()
assert(buttons_en != NULL);
buttons_en->setState(UserConfigParams::m_multitouch_mode != 0);
CheckBoxWidget* buttons_inv = getWidget<CheckBoxWidget>("buttons_inverted");
assert(buttons_inv != NULL);
buttons_inv->setState(UserConfigParams::m_multitouch_inverted);
SpinnerWidget* accelerometer = getWidget<SpinnerWidget>("accelerometer");
assert(accelerometer != NULL);
accelerometer->setValue(UserConfigParams::m_multitouch_accelerometer);

View File

@ -104,33 +104,47 @@ void RaceGUIMultitouch::initMultitouchSteering()
const float btn_size = 0.125f * h * scale;
const float btn2_size = 0.35f * h * scale;
const float margin = 0.075f * h * scale;
const float top_margin = 0.3f * h;
const float margin_top = 0.3f * h;
const float col_size = (btn_size + margin);
const float small_ratio = 0.75f;
const float btn_small_size = small_ratio * btn_size;
const float margin_small = small_ratio * margin;
const float col_small_size = small_ratio * col_size;
float first_column_x = w - 2 * col_size;
float second_column_x = w - 1 * col_size;
float steering_btn_x = 0.5f * margin;
if (UserConfigParams::m_multitouch_inverted)
{
first_column_x = margin + 1 * col_size;
second_column_x = margin;
steering_btn_x = w - btn2_size - 0.5f * margin;
}
m_minimap_bottom = (unsigned int)(h - 2 * col_size);
m_device->addButton(BUTTON_STEERING,
int(0.5f * margin), int(h - 0.5f * margin - btn2_size),
int(steering_btn_x), int(h - 0.5f * margin - btn2_size),
int(btn2_size), int(btn2_size));
m_device->addButton(BUTTON_ESCAPE,
int(top_margin), int(small_ratio * margin),
int(small_ratio * btn_size), int(small_ratio * btn_size));
int(margin_top), int(margin_small),
int(btn_small_size), int(btn_small_size));
m_device->addButton(BUTTON_RESCUE,
int(top_margin + small_ratio * col_size),
int(small_ratio * margin),
int(small_ratio * btn_size), int(small_ratio * btn_size));
int(margin_top + col_small_size), int(margin_small),
int(btn_small_size), int(btn_small_size));
m_device->addButton(BUTTON_NITRO,
int(w - 1 * col_size), int(h - 2 * col_size),
int(second_column_x), int(h - 2 * col_size),
int(btn_size), int(btn_size));
m_device->addButton(BUTTON_SKIDDING,
int(w - 1 * col_size), int(h - 1 * col_size),
int(second_column_x), int(h - 1 * col_size),
int(btn_size), int(btn_size));
m_device->addButton(BUTTON_FIRE,
int(w - 2 * col_size), int(h - 2 * col_size),
int(first_column_x), int(h - 2 * col_size),
int(btn_size), int(btn_size));
m_device->addButton(BUTTON_LOOK_BACKWARDS,
int(w - 2 * col_size), int(h - 1 * col_size),
int(first_column_x), int(h - 1 * col_size),
int(btn_size), int(btn_size));
m_directionnal_wheel_tex = irr_driver->getTexture(FileManager::GUI,