Draw powerup icon on a button when touch steering is enabled
This commit is contained in:
parent
e5feb3d35f
commit
cdd96f67dd
@ -246,10 +246,9 @@ void RaceGUI::renderPlayerView(const Camera *camera, float dt)
|
||||
|
||||
if(!World::getWorld()->isRacePhase()) return;
|
||||
|
||||
drawPowerupIcons(kart, viewport, scaling);
|
||||
|
||||
if (m_multitouch_gui == NULL)
|
||||
{
|
||||
drawPowerupIcons(kart, viewport, scaling);
|
||||
drawSpeedEnergyRank(kart, viewport, scaling, dt);
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,11 @@ using namespace irr;
|
||||
#include "graphics/camera.hpp"
|
||||
#include "graphics/2dutils.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/material.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
#include "input/multitouch_device.hpp"
|
||||
#include "items/powerup.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "states_screens/race_gui_base.hpp"
|
||||
|
||||
@ -141,16 +144,17 @@ void RaceGUIMultitouch::drawMultitouchSteering(const AbstractKart* kart,
|
||||
{
|
||||
MultitouchButton* button = m_device->getButton(i);
|
||||
|
||||
core::rect<s32> pos(button->x, button->y, button->x + button->width,
|
||||
button->y + button->height);
|
||||
core::rect<s32> btn_pos(button->x, button->y, button->x + button->width,
|
||||
button->y + button->height);
|
||||
|
||||
if (button->type == MultitouchButtonType::BUTTON_STEERING)
|
||||
{
|
||||
video::ITexture* tex = irr_driver->getTexture(FileManager::GUI,
|
||||
"blue_plus.png");
|
||||
core::rect<s32> coords(core::position2d<s32>(0,0), tex->getSize());
|
||||
video::ITexture* btn_texture = irr_driver->getTexture(
|
||||
FileManager::GUI, "blue_plus.png");
|
||||
core::rect<s32> coords(core::position2d<s32>(0,0),
|
||||
btn_texture->getSize());
|
||||
|
||||
draw2DImage(tex, pos, coords, NULL, NULL, true);
|
||||
draw2DImage(btn_texture, btn_pos, coords, NULL, NULL, true);
|
||||
|
||||
float x = (float)(button->x) + (float)(button->width) / 2.0f *
|
||||
(button->axis_x + 1.0f);
|
||||
@ -162,30 +166,30 @@ void RaceGUIMultitouch::drawMultitouchSteering(const AbstractKart* kart,
|
||||
core::rect<s32> pos2(int(round(x - w)), int(round(y - h)),
|
||||
int(round(x + w)), int(round(y + h)) );
|
||||
|
||||
draw2DImage(tex, pos2, coords, NULL, NULL, true);
|
||||
draw2DImage(btn_texture, pos2, coords, NULL, NULL, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (button->pressed)
|
||||
{
|
||||
core::rect<s32> pos2(int(button->x - button->width * 0.2f),
|
||||
int(button->y - button->height * 0.2f),
|
||||
int(button->x + button->width * 1.2f),
|
||||
int(button->y + button->height * 1.2f) );
|
||||
|
||||
video::ITexture* tex = irr_driver->getTexture(FileManager::GUI,
|
||||
"icons-frame.png");
|
||||
core::rect<s32> coords(core::position2d<s32>(0,0), tex->getSize());
|
||||
|
||||
draw2DImage(tex, pos2, coords, NULL, NULL, true);
|
||||
}
|
||||
|
||||
video::ITexture* tex;
|
||||
bool can_be_pressed = true;
|
||||
video::ITexture* btn_texture = NULL;
|
||||
|
||||
if (button->type == MultitouchButtonType::BUTTON_SKIDDING)
|
||||
{
|
||||
tex = irr_driver->getTexture(FileManager::TEXTURE,
|
||||
"skid-particle1.png");
|
||||
btn_texture = irr_driver->getTexture(FileManager::TEXTURE,
|
||||
"skid-particle1.png");
|
||||
}
|
||||
else if (button->type == MultitouchButtonType::BUTTON_FIRE)
|
||||
{
|
||||
const Powerup* powerup = kart->getPowerup();
|
||||
if (powerup->getType() != PowerupManager::POWERUP_NOTHING &&
|
||||
!kart->hasFinishedRace())
|
||||
{
|
||||
btn_texture = powerup->getIcon()->getTexture();
|
||||
}
|
||||
else
|
||||
{
|
||||
can_be_pressed = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -212,11 +216,30 @@ void RaceGUIMultitouch::drawMultitouchSteering(const AbstractKart* kart,
|
||||
break;
|
||||
}
|
||||
|
||||
tex = irr_driver->getTexture(FileManager::GUI, name);
|
||||
btn_texture = irr_driver->getTexture(FileManager::GUI, name);
|
||||
}
|
||||
|
||||
core::rect<s32> coords(core::position2d<s32>(0,0), tex->getSize());
|
||||
draw2DImage(tex, pos, coords, NULL, NULL, true);
|
||||
if (can_be_pressed && button->pressed)
|
||||
{
|
||||
core::rect<s32> pos2((int)(button->x - button->width * 0.2f),
|
||||
(int)(button->y - button->height * 0.2f),
|
||||
(int)(button->x + button->width * 1.2f),
|
||||
(int)(button->y + button->height * 1.2f));
|
||||
|
||||
video::ITexture* pressed = irr_driver->getTexture(
|
||||
FileManager::GUI, "icons-frame.png");
|
||||
core::rect<s32> coords(core::position2d<s32>(0,0),
|
||||
pressed->getSize());
|
||||
|
||||
draw2DImage(pressed, pos2, coords, NULL, NULL, true);
|
||||
}
|
||||
|
||||
if (btn_texture)
|
||||
{
|
||||
core::rect<s32> coords(core::position2d<s32>(0,0),
|
||||
btn_texture->getSize());
|
||||
draw2DImage(btn_texture, btn_pos, coords, NULL, NULL, true);
|
||||
}
|
||||
|
||||
if (button->type == MultitouchButtonType::BUTTON_NITRO)
|
||||
{
|
||||
@ -231,6 +254,21 @@ void RaceGUIMultitouch::drawMultitouchSteering(const AbstractKart* kart,
|
||||
core::vector2df(scale, scale));
|
||||
}
|
||||
}
|
||||
else if (button->type == MultitouchButtonType::BUTTON_FIRE)
|
||||
{
|
||||
if (kart->getPowerup()->getNum() > 1)
|
||||
{
|
||||
gui::ScalableFont* font = GUIEngine::getHighresDigitFont();
|
||||
core::rect<s32> btn_pos((int)(button->x),
|
||||
(int)(button->y),
|
||||
(int)(button->x + button->width/2),
|
||||
(int)(button->y + button->height/2));
|
||||
font->setScale(UserConfigParams::m_multitouch_scale);
|
||||
font->draw(core::stringw(L"+"), btn_pos,
|
||||
video::SColor(255, 255, 255, 255));
|
||||
font->setScale(1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -230,7 +230,10 @@ void RaceGUIOverworld::renderPlayerView(const Camera *camera, float dt)
|
||||
|
||||
if(!World::getWorld()->isRacePhase()) return;
|
||||
|
||||
drawPowerupIcons (kart, viewport, scaling);
|
||||
if (m_multitouch_gui == NULL)
|
||||
{
|
||||
drawPowerupIcons(kart, viewport, scaling);
|
||||
}
|
||||
} // renderPlayerView
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user