Forbid changing resolution in-game
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5443 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -480,6 +480,8 @@ EventPropagation EventHandler::onGUIEvent(const SEvent& event)
|
||||
Widget* w = GUIEngine::getWidget(id);
|
||||
if (w == NULL) break;
|
||||
|
||||
if (w->m_deactivated) return EVENT_BLOCK;
|
||||
|
||||
// These events are only triggered by keyboard/mouse (or so I hope...)
|
||||
const int playerID = input_manager->getPlayerKeyboardID();
|
||||
if (input_manager->masterPlayerOnly() && playerID != PLAYER_ID_GAME_MASTER) break;
|
||||
|
||||
@@ -657,7 +657,7 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, Widget* widget, const
|
||||
{
|
||||
// for now, when this kind of widget is disabled, just hide it. we can change that behaviour if
|
||||
// we ever need to...
|
||||
if (widget->m_deactivated) return;
|
||||
//if (widget->m_deactivated) return;
|
||||
|
||||
bool mark_selected = widget->isSelected(PLAYER_ID_GAME_MASTER);
|
||||
bool always_show_selection = false;
|
||||
@@ -676,6 +676,9 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, Widget* widget, const
|
||||
/* tab-bar ribbons */
|
||||
if (type == RIBBON_TABS)
|
||||
{
|
||||
// for now jsut don't draw it, change that if ever needed
|
||||
if (widget->m_deactivated) return;
|
||||
|
||||
BoxRenderParams* params;
|
||||
|
||||
if (mark_selected && (focused || parent_focused))
|
||||
@@ -726,8 +729,6 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, Widget* widget, const
|
||||
/* draw "selection bubble" if relevant */
|
||||
if (always_show_selection && mark_selected)
|
||||
{
|
||||
//GUIEngine::getDriver()->draw2DRectangle( SColor(255, 255,0,0), rect );
|
||||
|
||||
ITexture* tex_bubble = SkinConfig::m_render_params["selectionHalo::neutral"].getImage();
|
||||
|
||||
const int texture_w = tex_bubble->getSize().Width;
|
||||
@@ -746,10 +747,20 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, Widget* widget, const
|
||||
rect.UpperLeftCorner.Y - y_shift_up),
|
||||
dimension2d< s32 >(rectWidth, rectHeight) );
|
||||
|
||||
//GUIEngine::getDriver()->draw2DRectangleOutline( rect2, SColor(255, 0,255,0) );
|
||||
|
||||
GUIEngine::getDriver()->draw2DImage(tex_bubble, rect2, source_area,
|
||||
0 /* no clipping */, 0, true /* alpha */);
|
||||
if (widget->m_deactivated)
|
||||
{
|
||||
SColor colors[] = { SColor(100,255,255,255),
|
||||
SColor(100,255,255,255),
|
||||
SColor(100,255,255,255),
|
||||
SColor(100,255,255,255) };
|
||||
GUIEngine::getDriver()->draw2DImage(tex_bubble, rect2, source_area,
|
||||
0 /* no clipping */, colors, true /* alpha */);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUIEngine::getDriver()->draw2DImage(tex_bubble, rect2, source_area,
|
||||
0 /* no clipping */, 0, true /* alpha */);
|
||||
}
|
||||
}
|
||||
|
||||
// if multiple player selected the same ribbon item, we need to know to make it visible
|
||||
@@ -987,11 +998,6 @@ void Skin::drawSpinnerChild(const core::rect< s32 > &rect, Widget* widget, const
|
||||
*/
|
||||
void Skin::drawIconButton(const core::rect< s32 > &rect, Widget* widget, const bool pressed, bool focused)
|
||||
{
|
||||
// for now, when this kind of widget is disabled, just hide it. we can change that behaviour if
|
||||
// we ever need to...
|
||||
if (widget->m_deactivated) return;
|
||||
|
||||
|
||||
if (focused)
|
||||
{
|
||||
int grow = 45;
|
||||
@@ -1046,9 +1052,23 @@ void Skin::drawIconButton(const core::rect< s32 > &rect, Widget* widget, const b
|
||||
}
|
||||
|
||||
IconButtonWidget* icon_widget = (IconButtonWidget*) widget;
|
||||
GUIEngine::getDriver()->draw2DImage(icon_widget->m_texture, sized_rect,
|
||||
core::rect<s32>(0,0,icon_widget->m_texture_w, icon_widget->m_texture_h),
|
||||
0 /* no clipping */, 0, true /* alpha */);
|
||||
|
||||
if (widget->m_deactivated)
|
||||
{
|
||||
SColor colors[] = { SColor(100,255,255,255),
|
||||
SColor(100,255,255,255),
|
||||
SColor(100,255,255,255),
|
||||
SColor(100,255,255,255) };
|
||||
GUIEngine::getDriver()->draw2DImage(icon_widget->m_texture, sized_rect,
|
||||
core::rect<s32>(0,0,icon_widget->m_texture_w, icon_widget->m_texture_h),
|
||||
0 /* no clipping */, colors, true /* alpha */);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUIEngine::getDriver()->draw2DImage(icon_widget->m_texture, sized_rect,
|
||||
core::rect<s32>(0,0,icon_widget->m_texture_w, icon_widget->m_texture_h),
|
||||
0 /* no clipping */, 0, true /* alpha */);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1058,10 +1078,6 @@ void Skin::drawIconButton(const core::rect< s32 > &rect, Widget* widget, const b
|
||||
*/
|
||||
void Skin::drawCheckBox(const core::rect< s32 > &rect, Widget* widget, bool focused)
|
||||
{
|
||||
// for now, when this kind of widget is disabled, just hide it. we can change that behaviour if
|
||||
// we ever need to...
|
||||
if (widget->m_deactivated) return;
|
||||
|
||||
CheckBoxWidget* w = dynamic_cast<CheckBoxWidget*>(widget);
|
||||
|
||||
ITexture* texture;
|
||||
@@ -1082,8 +1098,20 @@ void Skin::drawCheckBox(const core::rect< s32 > &rect, Widget* widget, bool focu
|
||||
|
||||
const core::rect< s32 > source_area = core::rect< s32 >(0, 0, texture_w, texture_h);
|
||||
|
||||
GUIEngine::getDriver()->draw2DImage( texture, rect, source_area,
|
||||
0 /* no clipping */, 0, true /* alpha */);
|
||||
if (widget->m_deactivated)
|
||||
{
|
||||
SColor colors[] = { SColor(100,255,255,255),
|
||||
SColor(100,255,255,255),
|
||||
SColor(100,255,255,255),
|
||||
SColor(100,255,255,255) };
|
||||
GUIEngine::getDriver()->draw2DImage( texture, rect, source_area,
|
||||
0 /* no clipping */, colors, true /* alpha */);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUIEngine::getDriver()->draw2DImage( texture, rect, source_area,
|
||||
0 /* no clipping */, 0, true /* alpha */);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -131,6 +131,34 @@ void Widget::elementRemoved()
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void Widget::setActivated()
|
||||
{
|
||||
if (!m_deactivated) return; // already active, nothing to do
|
||||
|
||||
m_deactivated = false;
|
||||
const int count = m_children.size();
|
||||
for (int n=0; n<count; n++)
|
||||
{
|
||||
m_children[n].setActivated();
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void Widget::setDeactivated()
|
||||
{
|
||||
if (m_deactivated) return; // already deactivated, nothing to do
|
||||
|
||||
m_deactivated = true;
|
||||
const int count = m_children.size();
|
||||
for (int n=0; n<count; n++)
|
||||
{
|
||||
m_children[n].setDeactivated();
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
namespace GUIEngine
|
||||
{
|
||||
|
||||
@@ -230,6 +230,9 @@ namespace GUIEngine
|
||||
/** A bitmask of which badges to show, if any; choices are *_BADGE, defined above */
|
||||
int m_badges;
|
||||
|
||||
/** A simple flag that can be raised to hide this widget */
|
||||
bool m_deactivated;
|
||||
|
||||
public:
|
||||
/**
|
||||
* This is set to NULL by default; set to something else in a widget to mean
|
||||
@@ -296,6 +299,12 @@ namespace GUIEngine
|
||||
/** Set to false if widget is something that should not receieve focus */
|
||||
bool m_focusable;
|
||||
|
||||
/** \brief undos setDeactivated() */
|
||||
void setActivated();
|
||||
|
||||
/** \brief greys out the widget, making it not clickable for the user */
|
||||
void setDeactivated();
|
||||
|
||||
/** Used in two cases :
|
||||
1) For 'placeholder' divisions; at the time the layout is created, there is nothing to
|
||||
place there yet, but we know there eventually will. So in this case pass 'true' to the
|
||||
@@ -304,9 +313,6 @@ namespace GUIEngine
|
||||
it instead of creating a new ID if it is. In practice, it's not widely implemented (FIXME) */
|
||||
int m_reserved_id;
|
||||
|
||||
/** A simple flag that can be raised to hide this widget */
|
||||
bool m_deactivated;
|
||||
|
||||
Widget(WidgetType type, bool reserve_id = false);
|
||||
virtual ~Widget();
|
||||
|
||||
|
||||
@@ -601,6 +601,8 @@ void DynamicRibbonWidget::onRibbonWidgetFocus(RibbonWidget* emitter, const int p
|
||||
|
||||
void DynamicRibbonWidget::scroll(const int x_delta)
|
||||
{
|
||||
if (m_deactivated) return;
|
||||
|
||||
// Refuse to scroll when everything is visible
|
||||
if ((int)m_items.size() <= m_row_amount*m_col_amount) return;
|
||||
|
||||
@@ -874,6 +876,8 @@ void DynamicRibbonWidget::update(float dt)
|
||||
// -----------------------------------------------------------------------------
|
||||
bool DynamicRibbonWidget::setSelection(int item_id, const int playerID, const bool focusIt)
|
||||
{
|
||||
if (m_deactivated) return false;
|
||||
|
||||
//printf("****DynamicRibbonWidget::setSelection()****\n");
|
||||
|
||||
m_selected_item[playerID] = item_id;
|
||||
@@ -911,6 +915,8 @@ bool DynamicRibbonWidget::setSelection(int item_id, const int playerID, const bo
|
||||
// -----------------------------------------------------------------------------
|
||||
bool DynamicRibbonWidget::setSelection(const std::string item_codename, const int playerID, const bool focusIt)
|
||||
{
|
||||
if (m_deactivated) return false;
|
||||
|
||||
const int item_count = m_items.size();
|
||||
for (int n=0; n<item_count; n++)
|
||||
{
|
||||
|
||||
@@ -762,7 +762,7 @@ void KartSelectionScreen::init()
|
||||
|
||||
RibbonWidget* tabs = this->getWidget<RibbonWidget>("kartgroups");
|
||||
assert( tabs != NULL );
|
||||
tabs->m_deactivated = false;
|
||||
tabs->setActivated();
|
||||
|
||||
// FIXME: Reload previous kart selection screen state
|
||||
m_kart_widgets.clearAndDeleteAll();
|
||||
@@ -1122,7 +1122,7 @@ void KartSelectionScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
|
||||
RibbonWidget* tabs = this->getWidget<RibbonWidget>("kartgroups");
|
||||
assert( tabs != NULL );
|
||||
tabs->m_deactivated = true;
|
||||
tabs->setDeactivated();
|
||||
|
||||
// validate choices to notify player of duplicates
|
||||
const bool names_ok = validateIdentChoices();
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "guiengine/widgets/button_widget.hpp"
|
||||
#include "guiengine/widgets/check_box_widget.hpp"
|
||||
#include "guiengine/widgets/dynamic_ribbon_widget.hpp"
|
||||
#include "guiengine/widgets/spinner_widget.hpp"
|
||||
@@ -77,7 +78,7 @@ void OptionsScreenVideo::loadedFromFile()
|
||||
{
|
||||
std::cerr << "WARNING: could not find a single skin, make sure that "
|
||||
"the data files are correctly installed\n";
|
||||
skinSelector->m_deactivated = true;
|
||||
skinSelector->setDeactivated();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -103,6 +104,9 @@ void OptionsScreenVideo::init()
|
||||
GUIEngine::SpinnerWidget* skinSelector = this->getWidget<GUIEngine::SpinnerWidget>("skinchoice");
|
||||
assert( skinSelector != NULL );
|
||||
|
||||
GUIEngine::ButtonWidget* applyBtn = this->getWidget<GUIEngine::ButtonWidget>("apply_resolution");
|
||||
assert( applyBtn != NULL );
|
||||
|
||||
// ---- video modes
|
||||
DynamicRibbonWidget* res = this->getWidget<DynamicRibbonWidget>("resolutions");
|
||||
assert( res != NULL );
|
||||
@@ -147,6 +151,20 @@ void OptionsScreenVideo::init()
|
||||
|
||||
res->updateItemDisplay();
|
||||
|
||||
// forbid changing resolution from in-game
|
||||
if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU)
|
||||
{
|
||||
res->setDeactivated();
|
||||
full->setDeactivated();
|
||||
applyBtn->setDeactivated();
|
||||
}
|
||||
else
|
||||
{
|
||||
res->setActivated();
|
||||
full->setActivated();
|
||||
applyBtn->setActivated();
|
||||
}
|
||||
|
||||
// ---- select current resolution every time
|
||||
const std::vector<VideoMode>& modes = irr_driver->getVideoModes();
|
||||
const int amount = modes.size();
|
||||
|
||||
@@ -142,16 +142,18 @@ void RaceSetupScreen::onGameModeChanged()
|
||||
// deactivate the AI karts count widget for modes for which we have no AI
|
||||
//FIXME? Don't hardcode here which modes have an AI and which don't
|
||||
SpinnerWidget* kartamount = getWidget<SpinnerWidget>("aikartamount");
|
||||
kartamount->m_deactivated = (gamemode == "3strikes");
|
||||
|
||||
// use this dirty trick to hide the number inside the spinner (FIXME)
|
||||
if (kartamount->m_deactivated)
|
||||
if (gamemode == "3strikes")
|
||||
{
|
||||
kartamount->setDeactivated();
|
||||
|
||||
// dirty trick to hide the number inside the spinner (FIXME)
|
||||
kartamount->m_text = L"-";
|
||||
kartamount->setValue( kartamount->getValue() );
|
||||
}
|
||||
else if (kartamount->m_text.size() > 0)
|
||||
else
|
||||
{
|
||||
kartamount->setActivated();
|
||||
|
||||
kartamount->m_text = L"";
|
||||
kartamount->setValue( kartamount->getValue() );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user