Use new badging facility to show the green check on selected karts, simplifying code and fixing bugs
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4313 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
aa7bd6a591
commit
a5278e6257
@ -1101,7 +1101,7 @@ void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, co
|
||||
{
|
||||
drawSpinnerChild(rect, widget, pressed, focused);
|
||||
}
|
||||
else if (type == WTYPE_ICON_BUTTON)
|
||||
else if (type == WTYPE_ICON_BUTTON || type == WTYPE_MODEL_VIEW)
|
||||
{
|
||||
drawIconButton(rect, widget, pressed, focused);
|
||||
}
|
||||
@ -1121,6 +1121,7 @@ void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, co
|
||||
{
|
||||
drawCheckBox(rect, widget, focused);
|
||||
}
|
||||
|
||||
|
||||
if (ID_DEBUG && id != -1)
|
||||
{
|
||||
@ -1132,29 +1133,45 @@ void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, co
|
||||
|
||||
if (widget->m_lock_badge || widget->m_okay_badge)
|
||||
{
|
||||
// TODO
|
||||
video::ITexture* texture = NULL;
|
||||
|
||||
if (widget->m_lock_badge) texture = irr_driver->getTexture(file_manager->getTextureFile("gui_lock.png"));
|
||||
else if (widget->m_okay_badge) texture = irr_driver->getTexture(file_manager->getTextureFile("green_check.png"));
|
||||
else { assert(false); return; }
|
||||
const core::dimension2d<u32>& texture_size = texture->getSize();
|
||||
const float aspectRatio = (float)texture_size.Width / (float)texture_size.Height;
|
||||
const int h = std::min( rect.getHeight()/2 , (int)(texture_size.Height) );
|
||||
int w = (int)(aspectRatio*h);
|
||||
|
||||
const core::rect<s32> source_area = core::rect<s32>(0, 0, texture_size.Width, texture_size.Height);
|
||||
|
||||
const core::rect< s32 > rect2 = core::rect< s32 >(rect.UpperLeftCorner.X,
|
||||
rect.LowerRightCorner.Y - h,
|
||||
rect.UpperLeftCorner.X + w,
|
||||
rect.LowerRightCorner.Y);
|
||||
|
||||
GUIEngine::getDriver()->draw2DImage(texture, rect2, source_area,
|
||||
0 /* no clipping */, 0, true /* alpha */);
|
||||
drawBadgeOn(widget, rect);
|
||||
}
|
||||
}
|
||||
|
||||
void Skin::drawBadgeOn(const Widget* widget, const core::rect<s32>& rect)
|
||||
{
|
||||
video::ITexture* texture = NULL;
|
||||
float max_icon_size = 0.35f;
|
||||
|
||||
if (widget->m_lock_badge)
|
||||
{
|
||||
texture = irr_driver->getTexture(file_manager->getTextureFile("gui_lock.png"));
|
||||
max_icon_size = 0.5f; // Lock badge can be quite big
|
||||
}
|
||||
else if (widget->m_okay_badge)
|
||||
{
|
||||
texture = irr_driver->getTexture(file_manager->getTextureFile("green_check.png"));
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
const core::dimension2d<u32>& texture_size = texture->getSize();
|
||||
const float aspectRatio = (float)texture_size.Width / (float)texture_size.Height;
|
||||
const int h = std::min( (int)(rect.getHeight()*max_icon_size), (int)(texture_size.Height) );
|
||||
int w = (int)(aspectRatio*h);
|
||||
|
||||
const core::rect<s32> source_area = core::rect<s32>(0, 0, texture_size.Width, texture_size.Height);
|
||||
|
||||
const core::rect< s32 > rect2 = core::rect< s32 >(rect.UpperLeftCorner.X,
|
||||
rect.LowerRightCorner.Y - h,
|
||||
rect.UpperLeftCorner.X + w,
|
||||
rect.LowerRightCorner.Y);
|
||||
|
||||
GUIEngine::getDriver()->draw2DImage(texture, rect2, source_area,
|
||||
0 /* no clipping */, 0, true /* alpha */);
|
||||
}
|
||||
|
||||
void Skin::draw3DButtonPanePressed (IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip)
|
||||
{
|
||||
process3DPane(element, rect, true /* pressed */ );
|
||||
|
@ -243,7 +243,8 @@ namespace GUIEngine
|
||||
void renderSections(ptr_vector<Widget>* within_vector=NULL);
|
||||
void drawBgImage();
|
||||
void drawBGFadeColor();
|
||||
|
||||
void drawBadgeOn(const Widget* widget, const irr::core::rect<irr::s32>& rect);
|
||||
|
||||
// irrlicht's callbacks
|
||||
virtual void draw2DRectangle (irr::gui::IGUIElement *element, const irr::video::SColor &color, const irr::core::rect< irr::s32 > &pos, const irr::core::rect< irr::s32 > *clip);
|
||||
virtual void draw3DButtonPanePressed (irr::gui::IGUIElement *element, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip);
|
||||
|
@ -584,7 +584,7 @@ void DynamicRibbonWidget::updateItemDisplay()
|
||||
icon->m_text = m_items[icon_id].m_user_name;
|
||||
icon->m_lock_badge = m_items[icon_id].m_locked;
|
||||
|
||||
std::wcout << L"Setting widget text '" << icon->m_text.c_str() << L"'\n";
|
||||
//std::wcout << L"Setting widget text '" << icon->m_text.c_str() << L"'\n";
|
||||
|
||||
// if the ribbon has no "ribbon-wide" label, call will do nothing
|
||||
row.setLabel(i, m_items[icon_id].m_user_name);
|
||||
|
@ -22,11 +22,14 @@ using namespace GUIEngine;
|
||||
using namespace irr::core;
|
||||
using namespace irr::gui;
|
||||
|
||||
ModelViewWidget::ModelViewWidget()
|
||||
ModelViewWidget::ModelViewWidget() : IconButtonWidget(false, false)
|
||||
{
|
||||
m_type = WTYPE_MODEL_VIEW;
|
||||
m_rtt_provider = NULL;
|
||||
m_rotation_mode = ROTATE_OFF;
|
||||
|
||||
// so that the base class doesn't complain there is no icon defined
|
||||
m_properties[PROP_ICON]="gui/main_help.png";
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
ModelViewWidget::~ModelViewWidget()
|
||||
@ -39,17 +42,11 @@ ModelViewWidget::~ModelViewWidget()
|
||||
// -----------------------------------------------------------------------------
|
||||
void ModelViewWidget::add()
|
||||
{
|
||||
rect<s32> widget_size = rect<s32>(x, y, x + w, y + h);
|
||||
//stringw& message = m_text;
|
||||
|
||||
IGUIImage* btn = GUIEngine::getGUIEnv()->addImage(widget_size, m_parent, getNewNoFocusID());
|
||||
m_element = btn;
|
||||
btn->setUseAlphaChannel(true);
|
||||
btn->setTabStop(false);
|
||||
btn->setScaleImage(true);
|
||||
|
||||
//m_element = GUIEngine::getGUIEnv()->addMeshViewer(widget_size, NULL, ++id_counter_2);
|
||||
// so that the base class doesn't complain there is no icon defined
|
||||
m_properties[PROP_ICON]="gui/main_help.png";
|
||||
|
||||
IconButtonWidget::add();
|
||||
|
||||
/*
|
||||
TODO: remove this unclean thing, I think irrlicht provides this feature:
|
||||
virtual void IGUIElement::OnPostRender (u32 timeMs)
|
||||
@ -59,10 +56,6 @@ void ModelViewWidget::add()
|
||||
|
||||
angle = 0;
|
||||
|
||||
id = m_element->getID();
|
||||
//m_element->setTabOrder(id);
|
||||
m_element->setTabGroup(false);
|
||||
m_element->setTabStop(false);
|
||||
} // add
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -149,7 +142,9 @@ void ModelViewWidget::update(float delta)
|
||||
}
|
||||
|
||||
m_texture = m_rtt_provider->renderToTexture(angle);
|
||||
((IGUIImage*)m_element)->setImage(m_texture);
|
||||
setImage(m_texture);
|
||||
//getIrrlichtElement<IGUIButton>()->setImage(m_texture);
|
||||
//getIrrlichtElement<IGUIButton>()->setPressedImage(m_texture);
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,13 +23,13 @@
|
||||
#include <irrlicht.h>
|
||||
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "guiengine/widget.hpp"
|
||||
#include "guiengine/widgets/icon_button_widget.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
/** A model view widget. See guiengine/engine.hpp for a detailed overview */
|
||||
class ModelViewWidget : public Widget
|
||||
class ModelViewWidget : public IconButtonWidget
|
||||
{
|
||||
enum RotationMode
|
||||
{
|
||||
|
@ -426,6 +426,8 @@ FocusDispatcher* g_dispatcher = NULL;
|
||||
player_id_w *= 2;
|
||||
player_name_w = 0;
|
||||
|
||||
modelView->m_okay_badge = true;
|
||||
/*
|
||||
irr::video::ITexture* texture = irr_driver->getTexture( file_manager->getTextureFile("green_check.png").c_str() ) ;
|
||||
const int check_size = 128; // TODO: reduce size on smaller resolutions?
|
||||
const int check_x = model_x + model_w - check_size;
|
||||
@ -436,6 +438,7 @@ FocusDispatcher* g_dispatcher = NULL;
|
||||
greenCheckWidget->setScaleImage(true);
|
||||
greenCheckWidget->setTabStop(false);
|
||||
greenCheckWidget->setUseAlphaChannel(true);
|
||||
*/
|
||||
}
|
||||
|
||||
/** \return Whether this player confirmed his kart and indent selection */
|
||||
|
Loading…
x
Reference in New Issue
Block a user