Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/states_screens/race_gui_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ void RaceGUIBase::renderPlayerView(const Camera *camera, float dt)

if (m_multitouch_gui != NULL && !GUIEngine::ModalDialog::isADialogActive())
{
m_multitouch_gui->draw(kart, viewport, scaling);
m_multitouch_gui->draw(kart, viewport, scaling, dt);
}
} // renderPlayerView

Expand Down
9 changes: 6 additions & 3 deletions src/states_screens/race_gui_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,12 @@ class RaceGUIBase
void drawPlayerIcon(AbstractKart *kart, int x, int y, int w,
bool is_local);

virtual void drawEnergyMeter(int x, int y, const AbstractKart *kart,
const core::recti &viewport,
const core::vector2df &scaling) {};
virtual void drawEnergyMeter (int x, int y, const AbstractKart *kart,
const core::recti &viewport,
const core::vector2df &scaling) {};
virtual void drawSpeedEnergyRank(const AbstractKart* kart,
const core::recti &viewport,
const core::vector2df &scaling, float dt) {};

void cleanupMessages(const float dt);
void removeReferee();
Expand Down
43 changes: 41 additions & 2 deletions src/states_screens/race_gui_multitouch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ using namespace irr;
#include "karts/abstract_kart.hpp"
#include "karts/controller/kart_control.hpp"
#include "network/protocols/client_lobby.hpp"
#include "race/race_manager.hpp"
#include "states_screens/race_gui_base.hpp"

#include <IrrlichtDevice.h>
Expand All @@ -46,6 +47,7 @@ RaceGUIMultitouch::RaceGUIMultitouch(RaceGUIBase* race_gui)
m_race_gui = race_gui;
m_gui_action = false;
m_is_spectator_mode = false;
m_is_watching_replay = false;
m_height = 0;
m_steering_wheel_tex = NULL;
m_steering_wheel_tex_mask_up = NULL;
Expand Down Expand Up @@ -164,12 +166,18 @@ void RaceGUIMultitouch::init()
"android/steering_wheel_mask_down.png");

auto cl = LobbyProtocol::get<ClientLobby>();

auto rm = RaceManager::get()->isWatchingReplay();

if (cl && cl->isSpectator())
{
createSpectatorGUI();
m_is_spectator_mode = true;
}
else if (rm)
Comment thread
GustaLOLE marked this conversation as resolved.
{
createWatchingGUI();
m_is_watching_replay = true;
}
else
{
createRaceGUI();
Expand Down Expand Up @@ -271,6 +279,32 @@ void RaceGUIMultitouch::createRaceGUI()
int(btn_size), int(btn_size));
} // createRaceGUI

//-----------------------------------------------------------------------------
/** Determines the look of multitouch watching GUI interface (for replay watching)
*/
void RaceGUIMultitouch::createWatchingGUI()
{
if (m_device == NULL)
return;

const float scale = UserConfigParams::m_multitouch_scale;

const int h = irr_driver->getActualScreenSize().Height;
const float btn_size = 0.125f * h * scale;
const float margin = 0.075f * h * scale;
const float margin_top = 0.3f * h;

const float small_ratio = 0.75f;
const float btn_small_size = small_ratio * btn_size;
const float margin_small = small_ratio * margin;

m_height = (unsigned int)(btn_size + 2 * margin);

m_device->addButton(BUTTON_ESCAPE,
int(margin_top), int(margin_small),
int(btn_small_size), int(btn_small_size));
} // createWatchingGUI

//-----------------------------------------------------------------------------
/** Determines the look of spectator GUI interface
*/
Expand Down Expand Up @@ -356,7 +390,8 @@ void RaceGUIMultitouch::onCustomButtonPress(unsigned int button_id,
*/
void RaceGUIMultitouch::draw(const AbstractKart* kart,
const core::recti &viewport,
const core::vector2df &scaling)
const core::vector2df &scaling,
float dt)
{
#ifndef SERVER_ONLY
if (m_device == NULL)
Expand Down Expand Up @@ -550,6 +585,10 @@ void RaceGUIMultitouch::draw(const AbstractKart* kart,
font->setScale(1.0f);
font->setBlackBorder(false);
}
if (m_is_watching_replay)
{
m_race_gui->drawSpeedEnergyRank(kart, viewport, scaling, dt);
}
}
}
#endif
Expand Down
5 changes: 4 additions & 1 deletion src/states_screens/race_gui_multitouch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ using namespace irr;

class AbstractKart;
class MultitouchDevice;
class RaceManager;
class RaceGUIBase;

class RaceGUIMultitouch
Expand All @@ -43,6 +44,7 @@ class RaceGUIMultitouch

bool m_gui_action;
bool m_is_spectator_mode;
bool m_is_watching_replay;
unsigned int m_height;

video::ITexture* m_steering_wheel_tex;
Expand All @@ -65,6 +67,7 @@ class RaceGUIMultitouch

void init();
void createRaceGUI();
void createWatchingGUI();
void createSpectatorGUI();
void close();
static void onCustomButtonPress(unsigned int button_id, bool pressed);
Expand All @@ -74,7 +77,7 @@ class RaceGUIMultitouch
~RaceGUIMultitouch();

void draw(const AbstractKart* kart, const core::recti &viewport,
const core::vector2df &scaling);
const core::vector2df &scaling, float dt);

unsigned int getHeight() {return m_height;}
bool isSpectatorMode() {return m_is_spectator_mode;}
Expand Down