Fixed potentially dangerous name clash between Widget members and SkinWidgetContainer members + added the proper m_ prefix as per our style guidelines along the way

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5625 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-07-04 19:25:20 +00:00
parent d68e299da0
commit a77405d53a
27 changed files with 503 additions and 485 deletions

View File

@ -155,7 +155,7 @@ void Screen::calculateLayout(ptr_vector<Widget>& widgets, Widget* parent)
break;
}
const int w = parent->w, h = parent->h;
const int w = parent->m_w, h = parent->m_h;
// find space left after placing all absolutely-sized widgets in a row
// (the space left will be divided between remaining widgets later)
@ -172,11 +172,12 @@ void Screen::calculateLayout(ptr_vector<Widget>& widgets, Widget* parent)
}
// absolutely-sized widgets
left_space -= (horizontal ? widgets[n].w : widgets[n].h);
left_space -= (horizontal ? widgets[n].m_w : widgets[n].m_h);
} // next widget
// ---- lay widgets in row
int x = parent->x, y = parent->y;
int x = parent->m_x;
int y = parent->m_y;
for (int n=0; n<widgets_amount; n++)
{
std::string prop = widgets[n].m_properties[ PROP_PROPORTION ];
@ -192,61 +193,59 @@ void Screen::calculateLayout(ptr_vector<Widget>& widgets, Widget* parent)
if (horizontal)
{
widgets[n].x = x;
widgets[n].m_x = x;
std::string align = widgets[n].m_properties[ PROP_ALIGN ];
if (align.size() < 1)
{
if (widgets[n].m_properties[ PROP_Y ].size() > 0)
widgets[n].y = atoi(widgets[n].m_properties[ PROP_Y ].c_str());
widgets[n].m_y = atoi(widgets[n].m_properties[ PROP_Y ].c_str());
else
widgets[n].y = y;
widgets[n].m_y = y;
}
else if (align == "top") widgets[n].y = y;
else if (align == "center") widgets[n].y = y + h/2 - widgets[n].h/2;
else if (align == "bottom") widgets[n].y = y + h - widgets[n].h;
else if (align == "top") widgets[n].m_y = y;
else if (align == "center") widgets[n].m_y = y + h/2 - widgets[n].m_h/2;
else if (align == "bottom") widgets[n].m_y = y + h - widgets[n].m_h;
else std::cerr << "/!\\ Warning /!\\ : alignment '" << align.c_str()
<< "' is unknown (widget '" << widgets[n].m_properties[PROP_ID].c_str()
<< "', in a horiozntal-row layout)\n";
widgets[n].w = (int)(left_space*fraction);
widgets[n].m_w = (int)(left_space*fraction);
if (widgets[n].m_properties[PROP_MAX_WIDTH].size() > 0)
{
const int max_width = atoi( widgets[n].m_properties[PROP_MAX_WIDTH].c_str() );
if (widgets[n].w > max_width) widgets[n].w = max_width;
if (widgets[n].m_w > max_width) widgets[n].m_w = max_width;
}
x += widgets[n].w;
x += widgets[n].m_w;
}
else
{
widgets[n].h = (int)(left_space*fraction);
widgets[n].m_h = (int)(left_space*fraction);
if (widgets[n].m_properties[PROP_MAX_HEIGHT].size() > 0)
{
const int max_height = atoi( widgets[n].m_properties[PROP_MAX_HEIGHT].c_str() );
if(widgets[n].h > max_height) widgets[n].h = max_height;
if (widgets[n].m_h > max_height) widgets[n].m_h = max_height;
}
std::string align = widgets[n].m_properties[ PROP_ALIGN ];
if (align.size() < 1)
{
if (widgets[n].m_properties[ PROP_X ].size() > 0)
widgets[n].x = atoi(widgets[n].m_properties[ PROP_X ].c_str());
widgets[n].m_x = atoi(widgets[n].m_properties[ PROP_X ].c_str());
else
widgets[n].x = x;
widgets[n].m_x = x;
}
else if (align == "left") widgets[n].x = x;
else if (align == "center") widgets[n].x = x + w/2 - widgets[n].w/2;
else if (align == "right") widgets[n].x = x + w - widgets[n].w;
else if (align == "left") widgets[n].m_x = x;
else if (align == "center") widgets[n].m_x = x + w/2 - widgets[n].m_w/2;
else if (align == "right") widgets[n].m_x = x + w - widgets[n].m_w;
else std::cerr << "/!\\ Warning /!\\ : alignment '" << align.c_str()
<< "' is unknown (widget '" << widgets[n].m_properties[PROP_ID].c_str()
<< "', in a vertical-row layout)\n";
widgets[n].y = y;
widgets[n].m_y = y;
y += widgets[n].h;
y += widgets[n].m_h;
}
}
else
@ -255,23 +254,23 @@ void Screen::calculateLayout(ptr_vector<Widget>& widgets, Widget* parent)
if (horizontal)
{
widgets[n].x = x;
widgets[n].m_x = x;
std::string align = widgets[n].m_properties[ PROP_ALIGN ];
if (align.size() < 1)
{
if (widgets[n].m_properties[ PROP_Y ].size() > 0)
widgets[n].y = atoi(widgets[n].m_properties[ PROP_Y ].c_str());
widgets[n].m_y = atoi(widgets[n].m_properties[ PROP_Y ].c_str());
else
widgets[n].y = y;
widgets[n].m_y = y;
}
else if (align == "top") widgets[n].y = y;
else if (align == "center") widgets[n].y = y + h/2 - widgets[n].h/2;
else if (align == "bottom") widgets[n].y = y + h - widgets[n].h;
else if (align == "top") widgets[n].m_y = y;
else if (align == "center") widgets[n].m_y = y + h/2 - widgets[n].m_h/2;
else if (align == "bottom") widgets[n].m_y = y + h - widgets[n].m_h;
else std::cerr << "/!\\ Warning /!\\ : alignment '" << align.c_str() << "' is unknown in widget " << widgets[n].m_properties[PROP_ID].c_str() << std::endl;
x += widgets[n].w;
x += widgets[n].m_w;
}
else
{
@ -282,17 +281,17 @@ void Screen::calculateLayout(ptr_vector<Widget>& widgets, Widget* parent)
if (align.size() < 1)
{
if (widgets[n].m_properties[ PROP_X ].size() > 0)
widgets[n].x = atoi(widgets[n].m_properties[ PROP_X ].c_str());
widgets[n].m_x = atoi(widgets[n].m_properties[ PROP_X ].c_str());
else
widgets[n].x = x;
widgets[n].m_x = x;
}
else if (align == "left") widgets[n].x = x;
else if (align == "center") widgets[n].x = x + w/2 - widgets[n].w/2;
else if (align == "right") widgets[n].x = x + w - widgets[n].w;
else if (align == "left") widgets[n].m_x = x;
else if (align == "center") widgets[n].m_x = x + w/2 - widgets[n].m_w/2;
else if (align == "right") widgets[n].m_x = x + w - widgets[n].m_w;
else std::cerr << "/!\\ Warning /!\\ : alignment '" << align.c_str() << "' is unknown in widget " << widgets[n].m_properties[PROP_ID].c_str() << std::endl;
widgets[n].y = y;
widgets[n].m_y = y;
y += widgets[n].h;
y += widgets[n].m_h;
}
} // end if property or absolute size
@ -346,12 +345,19 @@ void Screen::addWidgetsRecursively(ptr_vector<Widget>& widgets, Widget* parent)
}
else
{
// warn if widget has no dimensions (except for ribbons and icons, where it is normal since it adjusts to its contents)
if((widgets[n].w < 1 || widgets[n].h < 1) && widgets[n].m_type != WTYPE_RIBBON && widgets[n].m_type != WTYPE_ICON_BUTTON)
// warn if widget has no dimensions (except for ribbons and icons, where it is normal since it
// adjusts to its contents)
if ((widgets[n].m_w < 1 || widgets[n].m_h < 1) &&
widgets[n].m_type != WTYPE_RIBBON &&
widgets[n].m_type != WTYPE_ICON_BUTTON)
{
std::cerr << "/!\\ Warning /!\\ : widget " << widgets[n].m_properties[PROP_ID].c_str() << " has no dimensions" << std::endl;
}
if(widgets[n].x == -1 || widgets[n].y == -1)
if (widgets[n].m_x == -1 || widgets[n].m_y == -1)
{
std::cerr << "/!\\ Warning /!\\ : widget " << widgets[n].m_properties[PROP_ID].c_str() << " has no position" << std::endl;
}
widgets[n].add();
}

View File

@ -336,15 +336,15 @@ void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, const core::rec
const core::rect<s32>* clipRect)
{
// check if widget moved. if so, recalculate coords
if (w->x != dest.UpperLeftCorner.X || w->y != dest.UpperLeftCorner.Y ||
w->w != dest.getWidth() || w->h != dest.getHeight())
if (w->m_skin_x != dest.UpperLeftCorner.X || w->m_skin_y != dest.UpperLeftCorner.Y ||
w->m_skin_w != dest.getWidth() || w->m_skin_h != dest.getHeight())
{
w->dest_areas_inited = false;
w->dest_areas_yflip_inited = false;
w->x = dest.UpperLeftCorner.X;
w->y = dest.UpperLeftCorner.Y;
w->w = dest.getWidth();
w->h = dest.getHeight();
w->m_skin_dest_areas_inited = false;
w->m_skin_dest_areas_yflip_inited = false;
w->m_skin_x = dest.UpperLeftCorner.X;
w->m_skin_y = dest.UpperLeftCorner.Y;
w->m_skin_w = dest.getWidth();
w->m_skin_h = dest.getHeight();
//std::cout << "widget moved, calculating again\n";
}
@ -377,23 +377,23 @@ void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, const core::rec
+----l--------------------m----n
*/
if (!w->dest_areas_inited)
if (!w->m_skin_dest_areas_inited)
{
w->dest_x = dest.UpperLeftCorner.X;
w->dest_y = dest.UpperLeftCorner.Y;
w->dest_x2 = dest.LowerRightCorner.X;
w->dest_y2 = dest.LowerRightCorner.Y;
w->m_skin_dest_x = dest.UpperLeftCorner.X;
w->m_skin_dest_y = dest.UpperLeftCorner.Y;
w->m_skin_dest_x2 = dest.LowerRightCorner.X;
w->m_skin_dest_y2 = dest.LowerRightCorner.Y;
//const float xscale = (float)(dest_x2-dest_x)/texture_w;
const float yscale = (float)(w->dest_y2 - w->dest_y)/texture_h;
const float yscale = (float)(w->m_skin_dest_y2 - w->m_skin_dest_y)/texture_h;
int dest_left_border, dest_right_border;
// scale and keep aspect ratio
if(preserve_h_aspect_ratios)
if (preserve_h_aspect_ratios)
{
dest_left_border = (int)(left_border * (w->dest_y2 - w->dest_y) / texture_h );
dest_right_border = (int)(right_border * (w->dest_y2 - w->dest_y) / texture_h);
dest_left_border = (int)(left_border * (w->m_skin_dest_y2 - w->m_skin_dest_y) / texture_h );
dest_right_border = (int)(right_border * (w->m_skin_dest_y2 - w->m_skin_dest_y) / texture_h);
}
else
{
@ -407,17 +407,17 @@ void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, const core::rec
const float hborder_in_portion = 1 - hborder_out_portion;
const float vborder_in_portion = 1 - vborder_out_portion;
const int ax = (int)(w->dest_x - dest_left_border*hborder_out_portion);
const int ay = (int)(w->dest_y - dest_top_border*vborder_out_portion);
const int ax = (int)(w->m_skin_dest_x - dest_left_border * hborder_out_portion);
const int ay = (int)(w->m_skin_dest_y - dest_top_border * vborder_out_portion);
const int bx = (int)(w->dest_x + dest_left_border*hborder_in_portion);
const int bx = (int)(w->m_skin_dest_x + dest_left_border*hborder_in_portion);
const int by = ay;
const int cx = (int)(w->dest_x2 - dest_right_border*hborder_in_portion);
const int cx = (int)(w->m_skin_dest_x2 - dest_right_border*hborder_in_portion);
const int cy = ay;
const int dx = ax;
const int dy = (int)(w->dest_y + dest_top_border*vborder_in_portion);
const int dy = (int)(w->m_skin_dest_y + dest_top_border*vborder_in_portion);
const int ex = bx;
const int ey = dy;
@ -425,11 +425,11 @@ void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, const core::rec
const int fx = cx;
const int fy = dy;
const int gx = (int)(w->dest_x2 + dest_right_border*hborder_out_portion);
const int gx = (int)(w->m_skin_dest_x2 + dest_right_border*hborder_out_portion);
const int gy = dy;
const int hx = ax;
const int hy = (int)(w->dest_y2 - dest_bottom_border*vborder_in_portion);
const int hy = (int)(w->m_skin_dest_y2 - dest_bottom_border*vborder_in_portion);
const int ix = bx;
const int iy = hy;
@ -441,7 +441,7 @@ void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, const core::rec
const int ky = hy;
const int lx = bx;
const int ly = (int)(w->dest_y2 + dest_bottom_border*vborder_out_portion);
const int ly = (int)(w->m_skin_dest_y2 + dest_bottom_border*vborder_out_portion);
const int mx = cx;
const int my = ly;
@ -449,47 +449,47 @@ void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, const core::rec
const int nx = gx;
const int ny = ly;
w->dest_area_left = core::rect<s32>(dx, dy, ix, iy);
w->dest_area_center = core::rect<s32>(ex, ey, jx, jy);
w->dest_area_right = core::rect<s32>(fx, fy, kx, ky);
w->m_skin_dest_area_left = core::rect<s32>(dx, dy, ix, iy);
w->m_skin_dest_area_center = core::rect<s32>(ex, ey, jx, jy);
w->m_skin_dest_area_right = core::rect<s32>(fx, fy, kx, ky);
w->dest_area_top = core::rect<s32>(bx, by, fx, fy);
w->dest_area_bottom = core::rect<s32>(ix, iy, mx, my);
w->m_skin_dest_area_top = core::rect<s32>(bx, by, fx, fy);
w->m_skin_dest_area_bottom = core::rect<s32>(ix, iy, mx, my);
w->dest_area_top_left = core::rect<s32>(ax, ay, ex, ey);
w->dest_area_top_right = core::rect<s32>(cx, cy, gx, gy);
w->dest_area_bottom_left = core::rect<s32>(hx, hy, lx, ly);
w->dest_area_bottom_right = core::rect<s32>(jx, jy, nx, ny);
w->m_skin_dest_area_top_left = core::rect<s32>(ax, ay, ex, ey);
w->m_skin_dest_area_top_right = core::rect<s32>(cx, cy, gx, gy);
w->m_skin_dest_area_bottom_left = core::rect<s32>(hx, hy, lx, ly);
w->m_skin_dest_area_bottom_right = core::rect<s32>(jx, jy, nx, ny);
w->dest_areas_inited = true;
w->m_skin_dest_areas_inited = true;
}
if (vertical_flip)
{
if (!w->dest_areas_yflip_inited)
if (!w->m_skin_dest_areas_yflip_inited)
{
#define FLIP_Y( X ) { const int y1 = X.UpperLeftCorner.Y - w->dest_y; \
const int y2 = X.LowerRightCorner.Y - w->dest_y; \
#define FLIP_Y( X ) { const int y1 = X.UpperLeftCorner.Y - w->m_skin_dest_y; \
const int y2 = X.LowerRightCorner.Y - w->m_skin_dest_y; \
X##_yflip = X; \
X##_yflip.UpperLeftCorner.Y = w->dest_y + (w->dest_y2 - w->dest_y) - y2;\
X##_yflip.LowerRightCorner.Y = w->dest_y + (w->dest_y2 - w->dest_y) - y1;}
X##_yflip.UpperLeftCorner.Y = w->m_skin_dest_y + (w->m_skin_dest_y2 - w->m_skin_dest_y) - y2;\
X##_yflip.LowerRightCorner.Y = w->m_skin_dest_y + (w->m_skin_dest_y2 - w->m_skin_dest_y) - y1;}
FLIP_Y(w->dest_area_left)
FLIP_Y(w->dest_area_center)
FLIP_Y(w->dest_area_right)
FLIP_Y(w->m_skin_dest_area_left)
FLIP_Y(w->m_skin_dest_area_center)
FLIP_Y(w->m_skin_dest_area_right)
FLIP_Y(w->dest_area_top)
FLIP_Y(w->dest_area_bottom)
FLIP_Y(w->m_skin_dest_area_top)
FLIP_Y(w->m_skin_dest_area_bottom)
FLIP_Y(w->dest_area_top_left)
FLIP_Y(w->dest_area_top_right)
FLIP_Y(w->dest_area_bottom_left)
FLIP_Y(w->dest_area_bottom_right)
FLIP_Y(w->m_skin_dest_area_top_left)
FLIP_Y(w->m_skin_dest_area_top_right)
FLIP_Y(w->m_skin_dest_area_bottom_left)
FLIP_Y(w->m_skin_dest_area_bottom_right)
#undef FLIP_Y
}
w->dest_areas_yflip_inited = true;
w->m_skin_dest_areas_yflip_inited = true;
params.calculateYFlipIfNeeded();
}
@ -507,7 +507,7 @@ X##_yflip.LowerRightCorner.Y = w->dest_y + (w->dest_y2 - w->dest_y) - y1;}
core::rect<s32>& GET_AREA(source_area_bottom_right);
#undef GET_AREA
#define GET_AREA( X ) X = (vertical_flip ? w->X##_yflip : w->X)
#define GET_AREA( X ) X = (vertical_flip ? w->m_skin_##X##_yflip : w->m_skin_##X)
core::rect<s32>& GET_AREA(dest_area_left);
core::rect<s32>& GET_AREA(dest_area_center);
core::rect<s32>& GET_AREA(dest_area_right);
@ -524,9 +524,9 @@ X##_yflip.LowerRightCorner.Y = w->dest_y + (w->dest_y2 - w->dest_y) - y1;}
SColor* colorptr = NULL;
// create a color object
if ( (w->r != -1 && w->g != -1 && w->b != -1) || ID_DEBUG || deactivated)
if ( (w->m_skin_r != -1 && w->m_skin_g != -1 && w->m_skin_b != -1) || ID_DEBUG || deactivated)
{
SColor thecolor(255, w->r, w->g, w->b);
SColor thecolor(255, w->m_skin_r, w->m_skin_g, w->m_skin_b);
colorptr = new SColor[4]();
colorptr[0] = thecolor;
colorptr[1] = thecolor;
@ -912,9 +912,9 @@ void Skin::drawSpinnerBody(const core::rect< s32 > &rect, Widget* widget, const
}
if (focused_widget != NULL && widget->m_children.size()>2)
{
if (widget->m_children[0].id == focused_widget->getID() ||
widget->m_children[1].id == focused_widget->getID() ||
widget->m_children[2].id == focused_widget->getID())
if (widget->m_children[0].getID() == focused_widget->getID() ||
widget->m_children[1].getID() == focused_widget->getID() ||
widget->m_children[2].getID() == focused_widget->getID())
{
focused = true;
}
@ -975,14 +975,14 @@ void Skin::drawSpinnerBody(const core::rect< s32 > &rect, Widget* widget, const
const SpinnerWidget* w = dynamic_cast<const SpinnerWidget*>(widget);
if (w->isGauge() && !w->m_deactivated)
{
const int handle_size = (int)( widget->h*params.left_border/(float)params.getImage()->getSize().Height );
const int handle_size = (int)( widget->m_h*params.left_border/(float)params.getImage()->getSize().Height );
const float value = (float)(w->getValue() - w->getMin()) / (w->getMax() - w->getMin());
const core::rect< s32 > dest_area = core::rect< s32 >(widget->x + handle_size,
widget->y,
widget->x + handle_size + (int)((widget->w - 2*handle_size)*value),
widget->y + widget->h);
const core::rect< s32 > dest_area = core::rect< s32 >(widget->m_x + handle_size,
widget->m_y,
widget->m_x + handle_size + (int)((widget->m_w - 2*handle_size)*value),
widget->m_y + widget->m_h);
const ITexture* texture = SkinConfig::m_render_params["gaugefill::neutral"].getImage();
const int texture_w = texture->getSize().Width;
@ -1014,9 +1014,10 @@ void Skin::drawSpinnerChild(const core::rect< s32 > &rect, Widget* widget, const
else if (widget->m_properties[PROP_ID] == "right") areas = BoxRenderParams::RIGHT;
else return;
core::rect< s32 > rect2 = core::rect< s32 >( spinner->x, spinner->y,
spinner->x + spinner->w,
spinner->y + spinner->h );
core::rect< s32 > rect2 = core::rect< s32 >( spinner->m_x,
spinner->m_y,
spinner->m_x + spinner->m_w,
spinner->m_y + spinner->m_h );
BoxRenderParams& params = SkinConfig::m_render_params["spinner::down"];
params.areas = areas;
@ -1194,7 +1195,10 @@ void Skin::renderSections(ptr_vector<Widget>* within_vector)
{
if(widget.m_show_bounding_box)
{
core::rect< s32 > rect = core::rect<s32>( widget.x, widget.y, widget.x + widget.w, widget.y + widget.h );
core::rect< s32 > rect = core::rect<s32>(widget.m_x,
widget.m_y,
widget.m_x + widget.m_w,
widget.m_y + widget.m_h );
drawBoxFromStretchableTexture(&widget, rect, SkinConfig::m_render_params["section::neutral"]);
}
else

View File

@ -119,52 +119,52 @@ namespace GUIEngine
class SkinWidgetContainer
{
public:
int x, y, w, h;
int m_skin_x, m_skin_y, m_skin_w, m_skin_h;
bool dest_areas_inited;
bool dest_areas_yflip_inited;
int dest_x, dest_y, dest_x2, dest_y2;
bool m_skin_dest_areas_inited;
bool m_skin_dest_areas_yflip_inited;
int m_skin_dest_x, m_skin_dest_y, m_skin_dest_x2, m_skin_dest_y2;
// see comments in Skin::drawBoxFromStretchableTexture for explaination of
// what these are
irr::core::rect<irr::s32> dest_area_left;
irr::core::rect<irr::s32> dest_area_center;
irr::core::rect<irr::s32> dest_area_right;
irr::core::rect<irr::s32> m_skin_dest_area_left;
irr::core::rect<irr::s32> m_skin_dest_area_center;
irr::core::rect<irr::s32> m_skin_dest_area_right;
irr::core::rect<irr::s32> dest_area_top;
irr::core::rect<irr::s32> dest_area_bottom;
irr::core::rect<irr::s32> m_skin_dest_area_top;
irr::core::rect<irr::s32> m_skin_dest_area_bottom;
irr::core::rect<irr::s32> dest_area_top_left;
irr::core::rect<irr::s32> dest_area_top_right;
irr::core::rect<irr::s32> dest_area_bottom_left;
irr::core::rect<irr::s32> dest_area_bottom_right;
irr::core::rect<irr::s32> m_skin_dest_area_top_left;
irr::core::rect<irr::s32> m_skin_dest_area_top_right;
irr::core::rect<irr::s32> m_skin_dest_area_bottom_left;
irr::core::rect<irr::s32> m_skin_dest_area_bottom_right;
// y flip
irr::core::rect<irr::s32> dest_area_left_yflip;
irr::core::rect<irr::s32> dest_area_center_yflip;
irr::core::rect<irr::s32> dest_area_right_yflip;
irr::core::rect<irr::s32> m_skin_dest_area_left_yflip;
irr::core::rect<irr::s32> m_skin_dest_area_center_yflip;
irr::core::rect<irr::s32> m_skin_dest_area_right_yflip;
irr::core::rect<irr::s32> dest_area_top_yflip;
irr::core::rect<irr::s32> dest_area_bottom_yflip;
irr::core::rect<irr::s32> m_skin_dest_area_top_yflip;
irr::core::rect<irr::s32> m_skin_dest_area_bottom_yflip;
irr::core::rect<irr::s32> dest_area_top_left_yflip;
irr::core::rect<irr::s32> dest_area_top_right_yflip;
irr::core::rect<irr::s32> dest_area_bottom_left_yflip;
irr::core::rect<irr::s32> dest_area_bottom_right_yflip;
irr::core::rect<irr::s32> m_skin_dest_area_top_left_yflip;
irr::core::rect<irr::s32> m_skin_dest_area_top_right_yflip;
irr::core::rect<irr::s32> m_skin_dest_area_bottom_left_yflip;
irr::core::rect<irr::s32> m_skin_dest_area_bottom_right_yflip;
short r, g, b;
short m_skin_r, m_skin_g, m_skin_b;
SkinWidgetContainer()
{
dest_areas_inited = false;
dest_areas_yflip_inited = false;
x = -1;
y = -1;
w = -1;
h = -1;
r = -1;
g = -1;
b = -1;
m_skin_dest_areas_inited = false;
m_skin_dest_areas_yflip_inited = false;
m_skin_x = -1;
m_skin_y = -1;
m_skin_w = -1;
m_skin_h = -1;
m_skin_r = -1;
m_skin_g = -1;
m_skin_b = -1;
} // SkinWidgetContainer
}; // class SkinWidgetContainer

View File

@ -61,11 +61,11 @@ Widget::Widget(WidgetType type, bool reserve_id)
{
m_magic_number = 0xCAFEC001;
x = -1;
y = -1;
w = -1;
h = -1;
id = -1;
m_x = -1;
m_y = -1;
m_w = -1;
m_h = -1;
m_id = -1;
m_element = NULL;
m_title_font = false;
m_type = type;
@ -293,10 +293,10 @@ void Widget::move(const int x, const int y, const int w, const int h)
{
assert(m_magic_number == 0xCAFEC001);
this->x = x;
this->y = y;
this->w = w;
this->h = h;
m_x = x;
m_y = y;
m_w = w;
m_h = h;
m_element->setRelativePosition( core::rect < s32 > (x, y, x+w, y+h) );
}
@ -329,10 +329,10 @@ void Widget::readCoords(Widget* parent)
}
else
{
parent_w = parent->w;
parent_h = parent->h;
parent_x = parent->x;
parent_y = parent->y;
parent_w = parent->m_w;
parent_h = parent->m_h;
parent_x = parent->m_x;
parent_y = parent->m_y;
}
// ---- try converting to number
@ -341,9 +341,9 @@ void Widget::readCoords(Widget* parent)
int abs_x = -1, percent_x = -1;
if(convertToCoord(x, &abs_x, &percent_x ))
{
if(abs_x > -1) this->x = parent_x + abs_x;
else if(abs_x < -1) this->x = parent_x + (parent_w + abs_x);
else if(percent_x > -1) this->x = parent_x + parent_w*percent_x/100;
if (abs_x > -1) m_x = parent_x + abs_x;
else if (abs_x < -1) m_x = parent_x + (parent_w + abs_x);
else if (percent_x > -1) m_x = parent_x + parent_w*percent_x/100;
}
}
@ -352,9 +352,9 @@ void Widget::readCoords(Widget* parent)
int abs_y = -1, percent_y = -1;
if(convertToCoord(y, &abs_y, &percent_y ))
{
if(abs_y > -1) this->y = parent_y + abs_y;
else if(abs_y < -1) this->y = parent_y + (parent_h + abs_y);
else if(percent_y > -1) this->y = parent_y + parent_h*percent_y/100;
if (abs_y > -1) m_y = parent_y + abs_y;
else if (abs_y < -1) m_y = parent_y + (parent_h + abs_y);
else if (percent_y > -1) m_y = parent_y + parent_h*percent_y/100;
}
}
@ -391,54 +391,54 @@ void Widget::readCoords(Widget* parent)
int abs_w = -1, percent_w = -1;
if(convertToCoord(width, &abs_w, &percent_w ))
{
if(abs_w > -1) this->w = abs_w;
else if(percent_w > -1) this->w = (int)round(parent_w*percent_w/100.0);
if (abs_w > -1) m_w = abs_w;
else if (percent_w > -1) m_w = (int)round(parent_w*percent_w/100.0);
}
else if(texture_w > -1) this->w = texture_w;
else if(label_w > -1) this->w = label_w;
else if(texture_w > -1) m_w = texture_w;
else if(label_w > -1) m_w = label_w;
}
// height
{
int abs_h = -1, percent_h = -1;
if(convertToCoord(height, &abs_h, &percent_h ))
if (convertToCoord(height, &abs_h, &percent_h ))
{
if(abs_h > -1) this->h = abs_h;
else if(percent_h > -1) this->h = parent_h*percent_h/100;
if (abs_h > -1) m_h = abs_h;
else if (percent_h > -1) m_h = parent_h*percent_h/100;
}
else if(texture_h > -1 && label_h > -1) this->h = texture_h + label_h; // label + icon
else if(texture_h > -1) this->h = texture_h;
else if(label_h > -1) this->h = label_h;
else if (texture_h > -1 && label_h > -1) m_h = texture_h + label_h; // label + icon
else if (texture_h > -1) m_h = texture_h;
else if (label_h > -1) m_h = label_h;
}
// ---- can't make widget bigger than parent
if(this->h > (int)parent_h)
if (m_h > (int)parent_h)
{
float ratio = (float)parent_h/this->h;
float ratio = (float)parent_h / m_h;
this->w = (int)(this->w*ratio);
this->h = (int)(this->h*ratio);
m_w = (int)(m_w*ratio);
m_h = (int)(m_h*ratio);
}
if(this->w > (int)parent_w)
if (m_w > (int)parent_w)
{
// scale down while keeping aspect ratio (don't do this for text widgets though...)
float ratio = (float)parent_w/this->w;
float ratio = (float)parent_w/m_w;
this->w = (int)(this->w*ratio);
if (m_type != WTYPE_LABEL) this->h = (int)(this->h*ratio);
m_w = (int)(m_w*ratio);
if (m_type != WTYPE_LABEL) m_h = (int)(m_h*ratio);
}
// ------ check for given max size
if(m_properties[PROP_MAX_WIDTH].size() > 0)
if (m_properties[PROP_MAX_WIDTH].size() > 0)
{
const int max_width = atoi( this->m_properties[PROP_MAX_WIDTH].c_str() );
if(this->w > max_width) this->w = max_width;
const int max_width = atoi( m_properties[PROP_MAX_WIDTH].c_str() );
if (m_w > max_width) m_w = max_width;
}
if(m_properties[PROP_MAX_HEIGHT].size() > 0)
if (m_properties[PROP_MAX_HEIGHT].size() > 0)
{
const int max_height = atoi( this->m_properties[PROP_MAX_HEIGHT].c_str() );
if(this->h > max_height) this->h = max_height;
const int max_height = atoi( m_properties[PROP_MAX_HEIGHT].c_str() );
if (m_h > max_height) m_h = max_height;
}
}

View File

@ -193,18 +193,17 @@ namespace GUIEngine
irr::gui::IGUIElement* m_element;
// FIXME... i forgot the m_ everywhere ... XD
/** numerical ID used by irrLicht to identify this widget
* (not the same as the string identificator specified in the XML file)
*/
int id;
int m_id;
/** Usually, only one widget at a time can be focused. There is however a special case where all
players can move through the screen. This variable will then be used as a bitmask to contain
which players beyong player 1 have this widget focused. */
bool m_player_focus[MAX_PLAYER_COUNT];
/** Whether to reserve an ID in 'm_reserved_id' when widget is added */
bool m_reserve_id;
/** When inferring widget size from its label length, this method will be called to
@ -260,7 +259,7 @@ namespace GUIEngine
/** Coordinates of the widget once added (the difference between those x/h and PROP_WIDTH/PROP_HEIGHT is
that the props are read in raw form from the XML file; PROP_WIDTH can then be e.g. "10%" and w,
once the widget is added, will be e.g. 80.) */
int x, y, w, h;
int m_x, m_y, m_w, m_h;
/** Whether to show a bounding box around this widget (used for sections) */
bool m_show_bounding_box;
@ -411,6 +410,8 @@ namespace GUIEngine
*/
virtual void elementRemoved();
int getID() const { return m_id; }
bool searchInsideMe() const { return m_check_inside_me; }
};

View File

@ -30,12 +30,12 @@ ButtonWidget::ButtonWidget() : Widget(WTYPE_BUTTON)
void ButtonWidget::add()
{
rect<s32> widget_size = rect<s32>(x, y, x + w, y + h);
rect<s32> widget_size = rect<s32>(m_x, m_y, m_x + m_w, m_y + m_h);
stringw& message = m_text;
m_element = GUIEngine::getGUIEnv()->addButton(widget_size, m_parent, getNewID(), message.c_str(), L"");
id = m_element->getID();
m_element->setTabOrder(id);
m_id = m_element->getID();
m_element->setTabOrder(m_id);
m_element->setTabGroup(false);
}

View File

@ -32,13 +32,13 @@ CheckBoxWidget::CheckBoxWidget() : Widget(WTYPE_CHECKBOX)
void CheckBoxWidget::add()
{
rect<s32> widget_size = rect<s32>(x, y, x + w, y + h);
rect<s32> widget_size = rect<s32>(m_x, m_y, m_x + m_w, m_y + m_h);
//stringw& message = m_text;
//m_element = GUIEngine::getGUIEnv()->addCheckBox(true /* checked */, widget_size, NULL, ++id_counter, message.c_str());
m_element = GUIEngine::getGUIEnv()->addButton(widget_size, m_parent, getNewID(), L"");
id = m_element->getID();
m_element->setTabOrder(id);
m_id = m_element->getID();
m_element->setTabOrder(m_id);
m_element->setTabGroup(false);
}
// -----------------------------------------------------------------------------

View File

@ -87,7 +87,10 @@ void DynamicRibbonWidget::add()
if (m_has_label)
{
// leave room for many lines, just in case (FIXME: remove this hack)
rect<s32> label_size = rect<s32>(x, y + h - m_label_height, x+w, y+h+m_label_height*5);
rect<s32> label_size = rect<s32>(m_x,
m_y + m_h - m_label_height,
m_x + m_w,
m_y + m_h + m_label_height*5);
m_label = GUIEngine::getGUIEnv()->addStaticText(L" ", label_size, false, true /* word wrap */, NULL, -1);
m_label->setTextAlignment( EGUIA_CENTER, EGUIA_UPPERLEFT );
m_label->setWordWrap(true);
@ -104,14 +107,14 @@ void DynamicRibbonWidget::add()
m_left_widget = new Widget(WTYPE_NONE);
m_right_widget = new Widget(WTYPE_NONE);
const int average_y = y + (h-m_label_height)/2;
const int average_y = m_y + (m_h - m_label_height)/2;
m_arrows_w = 30;
const int button_h = 50;
// right arrow
rect<s32> right_arrow_location = rect<s32>(x + w - m_arrows_w,
rect<s32> right_arrow_location = rect<s32>(m_x + m_w - m_arrows_w,
average_y - button_h/2,
x + w,
m_x + m_w,
average_y + button_h/2);
stringw rmessage = ">>";
IGUIButton* right_arrow = GUIEngine::getGUIEnv()->addButton(right_arrow_location, NULL, getNewNoFocusID(), rmessage.c_str(), L"");
@ -120,13 +123,13 @@ void DynamicRibbonWidget::add()
m_right_widget->m_event_handler = this;
m_right_widget->m_focusable = false;
m_right_widget->m_properties[PROP_ID] = "right";
m_right_widget->id = right_arrow->getID();
m_right_widget->m_id = right_arrow->getID();
m_children.push_back( m_right_widget );
// left arrow
rect<s32> left_arrow_location = rect<s32>(x,
rect<s32> left_arrow_location = rect<s32>(m_x,
average_y - button_h/2,
x + m_arrows_w,
m_x + m_arrows_w,
average_y + button_h/2);
stringw lmessage = "<<";
IGUIButton* left_arrow = GUIEngine::getGUIEnv()->addButton(left_arrow_location, NULL, getNewNoFocusID(), lmessage.c_str(), L"");
@ -135,7 +138,7 @@ void DynamicRibbonWidget::add()
m_left_widget->m_event_handler = this;
m_left_widget->m_focusable = false;
m_left_widget->m_properties[PROP_ID] = "left";
m_left_widget->id = left_arrow->getID();
m_left_widget->m_id = left_arrow->getID();
m_children.push_back( m_left_widget );
// ---- Determine number of rows and columns
@ -152,7 +155,7 @@ void DynamicRibbonWidget::add()
}
// determine row amount
m_row_amount = (int)round((h-m_label_height) / (float)m_child_height);
m_row_amount = (int)round((m_h - m_label_height) / (float)m_child_height);
if (m_properties[PROP_MAX_ROWS].size() > 0)
{
@ -198,9 +201,9 @@ void DynamicRibbonWidget::buildInternalStructure()
m_rows.clearWithoutDeleting(); // rows already deleted above, don't double-delete
// ---- determine column amount
const float row_height = (float)(h - m_label_height)/(float)m_row_amount;
const float row_height = (float)(m_h - m_label_height)/(float)m_row_amount;
float ratio_zoom = (float)row_height / (float)(m_child_height - m_label_height);
m_col_amount = (int)round( w / ( m_child_width*ratio_zoom ) );
m_col_amount = (int)round( m_w / ( m_child_width*ratio_zoom ) );
// ajust column amount to not add more item slots than we actually need
@ -242,10 +245,10 @@ void DynamicRibbonWidget::buildInternalStructure()
ribbon->setListener(this);
ribbon->m_reserved_id = m_ids[n];
ribbon->x = x + m_arrows_w;
ribbon->y = y + (int)(n*row_height);
ribbon->w = w - m_arrows_w*2;
ribbon->h = (int)(row_height);
ribbon->m_x = m_x + m_arrows_w;
ribbon->m_y = m_y + (int)(n*row_height);
ribbon->m_w = m_w - m_arrows_w*2;
ribbon->m_h = (int)(row_height);
ribbon->m_type = WTYPE_RIBBON;
std::stringstream name;
@ -264,8 +267,8 @@ void DynamicRibbonWidget::buildInternalStructure()
// set size to get proper ratio (as most textures are saved scaled down to 256x256)
icon->m_properties[PROP_WIDTH] = m_properties[PROP_CHILD_WIDTH];
icon->m_properties[PROP_HEIGHT] = m_properties[PROP_CHILD_HEIGHT];
icon->w = atoi(icon->m_properties[PROP_WIDTH].c_str());
icon->h = atoi(icon->m_properties[PROP_HEIGHT].c_str());
icon->m_w = atoi(icon->m_properties[PROP_WIDTH].c_str());
icon->m_h = atoi(icon->m_properties[PROP_HEIGHT].c_str());
// If we want each icon to have its own label, we must make it non-empty, otherwise
// it will assume there is no label and none will be created (FIXME: that's ugly)

View File

@ -76,17 +76,17 @@ void IconButtonWidget::add()
useAspectRatio = m_custom_aspect_ratio;
}
int suggested_h = h;
int suggested_w = (int)((useAspectRatio < 0 ? w : useAspectRatio*suggested_h));
int suggested_h = m_h;
int suggested_w = (int)((useAspectRatio < 0 ? m_w : useAspectRatio * suggested_h));
if (suggested_w > w)
if (suggested_w > m_w)
{
const float needed_scale_factor = (float)w / (float)suggested_w;
const float needed_scale_factor = (float)m_w / (float)suggested_w;
suggested_w = (int)(suggested_w*needed_scale_factor);
suggested_h = (int)(suggested_h*needed_scale_factor);
}
const int x_from = x + (w - suggested_w)/2; // center horizontally
const int y_from = y + (h - suggested_h)/2; // center vertically
const int x_from = m_x + (m_w - suggested_w)/2; // center horizontally
const int y_from = m_y + (m_h - suggested_h)/2; // center vertically
rect<s32> widget_size = rect<s32>(x_from,
y_from,
@ -99,7 +99,7 @@ void IconButtonWidget::add()
btn->setTabStop(m_tab_stop);
m_element = btn;
id = m_element->getID();
m_id = m_element->getID();
// ---- label if any
stringw& message = m_text;
@ -108,7 +108,10 @@ void IconButtonWidget::add()
//std::cout << "Adding label of icon widget, m_properties[PROP_EXTEND_LABEL] = " << m_properties[PROP_EXTEND_LABEL] << std::endl;
const int label_extra_size = ( m_properties[PROP_EXTEND_LABEL].size() == 0 ?
0 : atoi(m_properties[PROP_EXTEND_LABEL].c_str()) );
widget_size = rect<s32>(x - label_extra_size/2, y + h, x + w + label_extra_size/2, y + h*2);
widget_size = rect<s32>(m_x - label_extra_size/2,
m_y + m_h,
m_x + m_w + label_extra_size/2,
m_y + m_h*2);
m_label = GUIEngine::getGUIEnv()->addStaticText(message.c_str(), widget_size, false, true /* word wrap */, m_parent);
m_label->setTextAlignment(EGUIA_CENTER, EGUIA_UPPERLEFT);
@ -116,8 +119,8 @@ void IconButtonWidget::add()
}
// ---- IDs
id = m_element->getID();
if (m_tab_stop) m_element->setTabOrder(id);
m_id = m_element->getID();
if (m_tab_stop) m_element->setTabOrder(m_id);
m_element->setTabGroup(false);
}
// -----------------------------------------------------------------------------

View File

@ -33,7 +33,7 @@ LabelWidget::LabelWidget(bool title) : Widget(WTYPE_LABEL)
void LabelWidget::add()
{
rect<s32> widget_size = rect<s32>(x, y, x + w, y + h);
rect<s32> widget_size = rect<s32>(m_x, m_y, m_x + m_w, m_y + m_h);
const bool word_wrap = m_properties[PROP_WORD_WRAP] == "true";
stringw& message = m_text;
@ -59,7 +59,7 @@ void LabelWidget::add()
//irrwidget->setBackgroundColor( video::SColor(255,255,0,0) );
//irrwidget->setDrawBackground(true);
id = m_element->getID();
m_id = m_element->getID();
//m_element->setTabOrder(id);
m_element->setTabStop(false);
m_element->setTabGroup(false);

View File

@ -71,7 +71,7 @@ void ListWidget::setIcons(STKModifiedSpriteBank* icons)
void ListWidget::add()
{
rect<s32> widget_size = rect<s32>(x, y, x + w, y + h);
rect<s32> widget_size = rect<s32>(m_x, m_y, m_x + m_w, m_y + m_h);
IGUIListBox* list = GUIEngine::getGUIEnv()->addListBox (widget_size, m_parent, getNewID());
list->setAutoScrollEnabled(false);

View File

@ -64,7 +64,7 @@ void RibbonWidget::add()
m_labels.clearWithoutDeleting();
rect<s32> widget_size = rect<s32>(x, y, x + w, y + h);
rect<s32> widget_size = rect<s32>(m_x, m_y, m_x + m_w, m_y + m_h);
int id = (m_reserved_id == -1 ? getNewID() : m_reserved_id);
@ -92,20 +92,20 @@ void RibbonWidget::add()
icon->m_tab_stop = false;
}
total_needed_space += m_children[i].w;
total_needed_space += m_children[i].m_w;
}
int free_h_space = w - total_needed_space;
int free_h_space = m_w - total_needed_space;
//int biggest_y = 0;
const int button_y = 10;
float global_zoom = 1;
const int min_free_space = 50;
global_zoom = (float)w / (float)( w - free_h_space + min_free_space );
free_h_space = (int)(w - total_needed_space*global_zoom);
global_zoom = (float)m_w / (float)( m_w - free_h_space + min_free_space );
free_h_space = (int)(m_w - total_needed_space*global_zoom);
const int one_button_space = (int)round((float)w / (float)subbuttons_amount);
const int one_button_space = (int)round((float)m_w / (float)subbuttons_amount);
// ---- add children
for (int i=0; i<subbuttons_amount; i++)
@ -118,7 +118,7 @@ void RibbonWidget::add()
{
IGUIButton * subbtn = NULL;
rect<s32> subsize = rect<s32>(widget_x - one_button_space/2+2, 0,
widget_x + one_button_space/2-2, h);
widget_x + one_button_space/2-2, m_h);
stringw& message = m_children[i].m_text;
@ -189,7 +189,7 @@ void RibbonWidget::add()
const int needed_space_under_button = has_label ? GUIEngine::getFontHeight()*line_count : 10;
float imageRatio = (float)m_children[i].w/(float)m_children[i].h;
float imageRatio = (float)m_children[i].m_w / (float)m_children[i].m_h;
// calculate the size of the image
video::ITexture* image = irr_driver->getTexture((file_manager->getDataDir() + "/" + m_children[i].m_properties[PROP_ICON]).c_str());
@ -199,40 +199,40 @@ void RibbonWidget::add()
// scale to fit (FIXME: calculate the right value directly...)
float zoom = global_zoom;
if (button_y + image_h*zoom + needed_space_under_button > h)
if (button_y + image_h*zoom + needed_space_under_button > m_h)
{
// scale down
while (button_y + image_h*zoom + needed_space_under_button > h) zoom -= 0.01f;
while (button_y + image_h*zoom + needed_space_under_button > m_h) zoom -= 0.01f;
}
else
{
// scale up
while (button_y + image_h*zoom + needed_space_under_button < h) zoom += 0.01f;
while (button_y + image_h*zoom + needed_space_under_button < m_h) zoom += 0.01f;
}
// ---- add bitmap button part
// backup and restore position in case the same object is added multiple times (FIXME: unclean)
int old_x = m_children[i].x;
int old_y = m_children[i].y;
int old_w = m_children[i].w;
int old_h = m_children[i].h;
int old_x = m_children[i].m_x;
int old_y = m_children[i].m_y;
int old_w = m_children[i].m_w;
int old_h = m_children[i].m_h;
m_children[i].x = widget_x - (int)(image_w*zoom/2.0f);
m_children[i].y = button_y;
m_children[i].w = (int)(image_w*zoom);
m_children[i].h = (int)(image_h*zoom);
m_children[i].m_x = widget_x - (int)(image_w*zoom/2.0f);
m_children[i].m_y = button_y;
m_children[i].m_w = (int)(image_w*zoom);
m_children[i].m_h = (int)(image_h*zoom);
IconButtonWidget* icon = ((IconButtonWidget*)m_children.get(i));
icon->m_properties[PROP_EXTEND_LABEL] = StringUtils::toString(one_button_space - icon->w);
icon->m_properties[PROP_EXTEND_LABEL] = StringUtils::toString(one_button_space - icon->m_w);
m_children.get(i)->m_parent = btn;
m_children.get(i)->add();
// restore backuped size and location (see above for more info)
m_children[i].x = old_x;
m_children[i].y = old_y;
m_children[i].w = old_w;
m_children[i].h = old_h;
m_children[i].m_x = old_x;
m_children[i].m_y = old_y;
m_children[i].m_w = old_w;
m_children[i].m_h = old_h;
// the label itself will be added by the icon widget. since it adds the label outside of the
// widget area it is assigned to, the label will appear in the area we want at the bottom

View File

@ -103,20 +103,20 @@ void SpinnerWidget::add()
widgetID = getNewID();
}
rect<s32> widget_size = rect<s32>(x, y, x + w, y + h);
rect<s32> widget_size = rect<s32>(m_x, m_y, m_x + m_w, m_y + m_h);
IGUIButton * btn = GUIEngine::getGUIEnv()->addButton(widget_size, m_parent, widgetID, L"");
m_element = btn;
m_element->setTabOrder( m_element->getID() );
// left arrow
rect<s32> subsize_left_arrow = rect<s32>(0 ,0, h, h);
rect<s32> subsize_left_arrow = rect<s32>(0 ,0, m_h, m_h);
IGUIButton * left_arrow = GUIEngine::getGUIEnv()->addButton(subsize_left_arrow, btn, getNewNoFocusID(), L" ");
m_children[0].m_element = left_arrow;
left_arrow->setTabStop(false);
m_children[0].m_event_handler = this;
m_children[0].m_properties[PROP_ID] = "left";
m_children[0].id = m_children[0].m_element->getID();
m_children[0].m_id = m_children[0].m_element->getID();
// label
if (m_graphical)
@ -125,12 +125,12 @@ void SpinnerWidget::add()
assert(texture != NULL);
const int texture_width = texture->getSize().Width;
const int free_h_space = w-h*2-texture_width; // to center image
const int free_h_space = m_w - m_h*2 - texture_width; // to center image
rect<s32> subsize_label = rect<s32>(h+free_h_space/2, 0, w-h+free_h_space/2, h);
rect<s32> subsize_label = rect<s32>(m_h + free_h_space/2, 0, m_w - m_h+ free_h_space/2, m_h);
IGUIImage * subbtn = GUIEngine::getGUIEnv()->addImage(subsize_label, btn, getNewNoFocusID());
m_children[1].m_element = subbtn;
m_children[1].id = subbtn->getID();
m_children[1].m_id = subbtn->getID();
m_children[1].m_event_handler = this;
subbtn->setUseAlphaChannel(true);
@ -139,13 +139,13 @@ void SpinnerWidget::add()
}
else
{
rect<s32> subsize_label = rect<s32>(h, 0, w-h, h);
rect<s32> subsize_label = rect<s32>(m_h, 0, m_w - m_h, m_h);
IGUIStaticText* label = GUIEngine::getGUIEnv()->addStaticText(stringw(m_value).c_str(), subsize_label,
false /* border */, true /* word wrap */,
btn, getNewNoFocusID());
m_children[1].m_element = label;
m_children[1].m_event_handler = this;
m_children[1].id = label->getID();
m_children[1].m_id = label->getID();
label->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
label->setTabStop(false);
label->setNotClipped(true);
@ -153,13 +153,13 @@ void SpinnerWidget::add()
// right arrow
rect<s32> subsize_right_arrow = rect<s32>(w-h, 0, w, h);
rect<s32> subsize_right_arrow = rect<s32>(m_w - m_h, 0, m_w, m_h);
IGUIButton * right_arrow = GUIEngine::getGUIEnv()->addButton(subsize_right_arrow, btn, getNewNoFocusID(), L" ");
right_arrow->setTabStop(false);
m_children[2].m_element = right_arrow;
m_children[2].m_event_handler = this;
m_children[2].m_properties[PROP_ID] = "right";
m_children[2].id = m_children[2].m_element->getID();
m_children[2].m_id = m_children[2].m_element->getID();
// refresh display
setValue(m_value);

View File

@ -32,13 +32,13 @@ TextBoxWidget::TextBoxWidget() : Widget(WTYPE_TEXTBOX)
void TextBoxWidget::add()
{
rect<s32> widget_size = rect<s32>(x, y, x + w, y + h);
rect<s32> widget_size = rect<s32>(m_x, m_y, m_x + m_w, m_y + m_h);
stringw& text = m_text;
m_element = GUIEngine::getGUIEnv()->addEditBox(text.c_str(), widget_size,
true /* border */, m_parent, getNewID());
id = m_element->getID();
m_element->setTabOrder(id);
m_id = m_element->getID();
m_element->setTabOrder(m_id);
m_element->setTabGroup(false);
m_element->setTabStop(true);
}

View File

@ -207,7 +207,7 @@ void CreditsScreen::init()
assert(w != NULL);
reset();
setArea(w->x, w->y, w->w, w->h);
setArea(w->m_x, w->m_y, w->m_w, w->m_h);
}
// ---------------------------------------------------------------------------------------------------

View File

@ -60,10 +60,10 @@ AddDeviceDialog::AddDeviceDialog() : ModalDialog(0.7f, 0.7f)
const int textWidth = font->getDimension( widget->m_text.c_str() ).Width + 40;
widget->x = m_area.getWidth()/2 - textWidth/2;
widget->y = y_bottom;
widget->w = textWidth;
widget->h = buttonHeight;
widget->m_x = m_area.getWidth()/2 - textWidth/2;
widget->m_y = y_bottom;
widget->m_w = textWidth;
widget->m_h = buttonHeight;
widget->setParent(m_irrlicht_window);
m_children.push_back(widget);
widget->add();
@ -75,10 +75,10 @@ AddDeviceDialog::AddDeviceDialog() : ModalDialog(0.7f, 0.7f)
const int textWidth = font->getDimension( widget->m_text.c_str() ).Width + 40;
widget->x = m_area.getWidth()/2 - textWidth/2;
widget->y = y_bottom + buttonHeight + 10;
widget->w = textWidth;
widget->h = buttonHeight;
widget->m_x = m_area.getWidth()/2 - textWidth/2;
widget->m_y = y_bottom + buttonHeight + 10;
widget->m_w = textWidth;
widget->m_h = buttonHeight;
widget->setParent(m_irrlicht_window);
m_children.push_back(widget);
widget->add();

View File

@ -52,32 +52,32 @@ AddonsLoading::AddonsLoading(Addons * id, const float w, const float h) :
/* Next and previous button*/
m_next = new IconButtonWidget();
m_next->setImage("gui/next_addons.png");
m_next->x = area_right.UpperLeftCorner.X + 100;
m_next->y = area_right.UpperLeftCorner.Y +20 ;
m_next->w = 75;
m_next->m_x = area_right.UpperLeftCorner.X + 100;
m_next->m_y = area_right.UpperLeftCorner.Y +20 ;
m_next->m_w = 75;
m_next->m_properties[PROP_ID] = "next";
m_next->h = 40;
m_next->m_h = 40;
m_next->setParent(m_irrlicht_window);
m_children.push_back(m_next);
m_next->add();
m_previous = new IconButtonWidget();
m_previous->setImage("gui/back_addons.png");
m_previous->x = area_right.UpperLeftCorner.X + 20;
m_previous->y = area_right.UpperLeftCorner.Y +20 ;
m_previous->w = 75;
m_previous->m_x = area_right.UpperLeftCorner.X + 20;
m_previous->m_y = area_right.UpperLeftCorner.Y +20 ;
m_previous->m_w = 75;
m_previous->m_properties[PROP_ID] = "previous";
m_previous->h = 40;
m_previous->m_h = 40;
m_previous->setParent(m_irrlicht_window);
m_children.push_back(m_previous);
m_previous->add();
name = new LabelWidget();
name->m_text = StringUtils::insertValues(_("Name: %i"), this->addons->GetName().c_str());
name->x = area_left.UpperLeftCorner.X;
name->y = area_left.UpperLeftCorner.Y;
name->w = area_left.getWidth();
name->h = area_left.getHeight()/6;
name->m_x = area_left.UpperLeftCorner.X;
name->m_y = area_left.UpperLeftCorner.Y;
name->m_w = area_left.getWidth();
name->m_h = area_left.getHeight()/6;
name->setParent(m_irrlicht_window);
m_children.push_back(name);
@ -85,20 +85,20 @@ AddonsLoading::AddonsLoading(Addons * id, const float w, const float h) :
description = new LabelWidget();
description->m_properties[PROP_WORD_WRAP] = "true";
description->x = area_left.UpperLeftCorner.X;
description->y = area_left.UpperLeftCorner.Y + area_left.getHeight()/6;
description->w = area_left.getWidth();
description->h = area_left.getHeight()/3;
description->m_x = area_left.UpperLeftCorner.X;
description->m_y = area_left.UpperLeftCorner.Y + area_left.getHeight()/6;
description->m_w = area_left.getWidth();
description->m_h = area_left.getHeight()/3;
description->setParent(m_irrlicht_window);
description->m_text = StringUtils::insertValues(_("Description: %i"), this->addons->GetDescription().c_str());
description->add();
version = new LabelWidget();
version->x = area_left.UpperLeftCorner.X;
version->y = area_left.UpperLeftCorner.Y + area_left.getHeight()/6 + area_left.getHeight()/3;
version->m_x = area_left.UpperLeftCorner.X;
version->m_y = area_left.UpperLeftCorner.Y + area_left.getHeight()/6 + area_left.getHeight()/3;
version->m_text = StringUtils::insertValues(_("Version: %i"), this->addons->GetVersionAsStr().c_str());
version->w = area_left.getWidth();
version->h = area_left.getHeight()/3;
version->m_w = area_left.getWidth();
version->m_h = area_left.getHeight()/3;
version->setParent(m_irrlicht_window);
m_children.push_back(version);
@ -117,10 +117,10 @@ void AddonsLoading::loadInfo()
/*I think we can wait a little to have the icon ?*/
download("icon/" + this->addons->GetIcon(), this->addons->GetName() + ".png");
icon->setImage(std::string(file_manager->getConfigDir() + "/" + this->addons->GetName() + ".png").c_str(), IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
icon->x = area_right.UpperLeftCorner.X;
icon->y = area_right.UpperLeftCorner.Y;
icon->w = m_area.getWidth()/2;
icon->h = m_area.getHeight();
icon->m_x = area_right.UpperLeftCorner.X;
icon->m_y = area_right.UpperLeftCorner.Y;
icon->m_w = m_area.getWidth()/2;
icon->m_h = m_area.getHeight();
icon->setParent(m_irrlicht_window);
m_children.push_back(icon);
icon->add();
@ -137,12 +137,12 @@ void AddonsLoading::loadInfo()
/*m_back_button->setLabel(std::string("Back").c_str());*/
m_back_button->m_text = _("Back");
m_back_button->m_properties[PROP_ID] = "cancel";
m_back_button->x = 20;
m_back_button->y = m_area.getHeight()-45;
m_back_button->m_x = 20;
m_back_button->m_y = m_area.getHeight()-45;
m_back_button->setParent(m_irrlicht_window);
m_children.push_back(m_back_button);
m_back_button->w = 150;
m_back_button->h = 35;
m_back_button->m_w = 150;
m_back_button->m_h = 35;
m_back_button->add();
this->install_button = new ButtonWidget();
@ -152,12 +152,12 @@ void AddonsLoading::loadInfo()
else
this->install_button->m_text = _("Install");
this->install_button->m_properties[PROP_ID] = "install";
this->install_button->x = m_area.getWidth()-170;
this->install_button->y = m_area.getHeight()-45;
this->install_button->m_x = m_area.getWidth()-170;
this->install_button->m_y = m_area.getHeight()-45;
this->install_button->setParent(m_irrlicht_window);
m_children.push_back(this->install_button);
this->install_button->w = 150;
this->install_button->h = 35;
this->install_button->m_w = 150;
this->install_button->m_h = 35;
this->install_button->add();
}

View File

@ -65,10 +65,10 @@ ConfirmResolutionDialog::ConfirmResolutionDialog() : ModalDialog(0.7f, 0.7f)
const int textWidth = font->getDimension( widget->m_text.c_str() ).Width + 40;
widget->x = m_area.getWidth()/2 - textWidth/2;
widget->y = y_bottom;
widget->w = textWidth;
widget->h = buttonHeight;
widget->m_x = m_area.getWidth()/2 - textWidth/2;
widget->m_y = y_bottom;
widget->m_w = textWidth;
widget->m_h = buttonHeight;
widget->setParent(m_irrlicht_window);
m_children.push_back(widget);
widget->add();
@ -81,10 +81,10 @@ ConfirmResolutionDialog::ConfirmResolutionDialog() : ModalDialog(0.7f, 0.7f)
const int textWidth = font->getDimension( widget->m_text.c_str() ).Width + 40;
widget->x = m_area.getWidth()/2 - textWidth/2;
widget->y = y_bottom + buttonHeight + 10;
widget->w = textWidth;
widget->h = buttonHeight;
widget->m_x = m_area.getWidth()/2 - textWidth/2;
widget->m_y = y_bottom + buttonHeight + 10;
widget->m_w = textWidth;
widget->m_h = buttonHeight;
widget->setParent(m_irrlicht_window);
m_children.push_back(widget);
widget->add();

View File

@ -40,10 +40,10 @@ EnterPlayerNameDialog::EnterPlayerNameDialog(const float w, const float h) :
m_label_ctrl->m_text = _("Enter the new player's name");
m_label_ctrl->m_properties[PROP_TEXT_ALIGN] = "center";
m_label_ctrl->x = 0;
m_label_ctrl->y = 0;
m_label_ctrl->w = m_area.getWidth();
m_label_ctrl->h = m_area.getHeight()/3;
m_label_ctrl->m_x = 0;
m_label_ctrl->m_y = 0;
m_label_ctrl->m_w = m_area.getWidth();
m_label_ctrl->m_h = m_area.getHeight()/3;
m_label_ctrl->setParent(m_irrlicht_window);
m_children.push_back(m_label_ctrl);
@ -58,10 +58,10 @@ EnterPlayerNameDialog::EnterPlayerNameDialog(const float w, const float h) :
textCtrl = new TextBoxWidget();
textCtrl->m_text = "";
textCtrl->x = 50;
textCtrl->y = textAreaYFrom - 10;
textCtrl->w = m_area.getWidth()-100;
textCtrl->h = textHeight + 5;
textCtrl->m_x = 50;
textCtrl->m_y = textAreaYFrom - 10;
textCtrl->m_w = m_area.getWidth()-100;
textCtrl->m_h = textHeight + 5;
textCtrl->setParent(m_irrlicht_window);
m_children.push_back(textCtrl);
textCtrl->add();
@ -72,10 +72,10 @@ EnterPlayerNameDialog::EnterPlayerNameDialog(const float w, const float h) :
cancelButton = new ButtonWidget();
cancelButton->m_properties[PROP_ID] = "cancel";
cancelButton->m_text = _("Cancel");
cancelButton->x = 15;
cancelButton->y = m_area.getHeight() - textHeight - 12;
cancelButton->w = m_area.getWidth() - 30;
cancelButton->h = textHeight + 6;
cancelButton->m_x = 15;
cancelButton->m_y = m_area.getHeight() - textHeight - 12;
cancelButton->m_w = m_area.getWidth() - 30;
cancelButton->m_h = textHeight + 6;
cancelButton->setParent(m_irrlicht_window);
m_children.push_back(cancelButton);

View File

@ -98,10 +98,10 @@ GPInfoDialog::GPInfoDialog(const std::string& gpIdent, const float w, const floa
LabelWidget* widget = new LabelWidget();
widget->m_text = lineText;
widget->x = 20;
widget->y = from_y;
widget->w = m_area.getWidth()/2 - 20;
widget->h = height_of_one_line;
widget->m_x = 20;
widget->m_y = from_y;
widget->m_w = m_area.getWidth()/2 - 20;
widget->m_h = height_of_one_line;
widget->setParent(m_irrlicht_window);
m_children.push_back(widget);
@ -120,10 +120,10 @@ GPInfoDialog::GPInfoDialog(const std::string& gpIdent, const float w, const floa
// images are saved squared, but must be stretched to 4:3
m_screenshot_widget->setCustomAspectRatio(4.0f / 3.0f);
m_screenshot_widget->x = m_area.getWidth()/2;
m_screenshot_widget->y = y1;
m_screenshot_widget->w = m_area.getWidth()/2;
m_screenshot_widget->h = y2 - y1 - 10;
m_screenshot_widget->m_x = m_area.getWidth()/2;
m_screenshot_widget->m_y = y1;
m_screenshot_widget->m_w = m_area.getWidth()/2;
m_screenshot_widget->m_h = y2 - y1 - 10;
Track* track = track_manager->getTrack(tracks[0]);
@ -150,10 +150,10 @@ GPInfoDialog::GPInfoDialog(const std::string& gpIdent, const float w, const floa
okBtn->setBadge(BAD_BADGE);
}
okBtn->x = m_area.getWidth()/2 - 200;
okBtn->y = y2;
okBtn->w = 400;
okBtn->h = m_area.getHeight() - y2 - 15;
okBtn->m_x = m_area.getWidth()/2 - 200;
okBtn->m_y = y2;
okBtn->m_w = 400;
okBtn->m_h = m_area.getHeight() - y2 - 15;
okBtn->setParent(m_irrlicht_window);
m_children.push_back(okBtn);
okBtn->add();

View File

@ -55,10 +55,10 @@ void PlayerInfoDialog::showRegularDialog()
textCtrl = new TextBoxWidget();
textCtrl->m_properties[PROP_ID] = "renameplayer";
textCtrl->m_text = m_player->getName();
textCtrl->x = 50;
textCtrl->y = y1 - textHeight/2;
textCtrl->w = m_area.getWidth()-100;
textCtrl->h = textHeight + 5;
textCtrl->m_x = 50;
textCtrl->m_y = y1 - textHeight/2;
textCtrl->m_w = m_area.getWidth()-100;
textCtrl->m_h = textHeight + 5;
textCtrl->setParent(m_irrlicht_window);
m_children.push_back(textCtrl);
textCtrl->add();
@ -73,10 +73,10 @@ void PlayerInfoDialog::showRegularDialog()
const int textWidth = font->getDimension( widget->m_text.c_str() ).Width + 40;
widget->x = m_area.getWidth()/2 - textWidth/2;
widget->y = y2;
widget->w = textWidth;
widget->h = buttonHeight;
widget->m_x = m_area.getWidth()/2 - textWidth/2;
widget->m_y = y2;
widget->m_w = textWidth;
widget->m_h = buttonHeight;
widget->setParent(m_irrlicht_window);
m_children.push_back(widget);
widget->add();
@ -88,10 +88,10 @@ void PlayerInfoDialog::showRegularDialog()
const int textWidth = font->getDimension( widget->m_text.c_str() ).Width + 40;
widget->x = m_area.getWidth()/2 - textWidth/2;
widget->y = y3;
widget->w = textWidth;
widget->h = buttonHeight;
widget->m_x = m_area.getWidth()/2 - textWidth/2;
widget->m_y = y3;
widget->m_w = textWidth;
widget->m_h = buttonHeight;
widget->setParent(m_irrlicht_window);
m_children.push_back(widget);
widget->add();
@ -106,10 +106,10 @@ void PlayerInfoDialog::showRegularDialog()
const int textWidth = font->getDimension( widget->m_text.c_str() ).Width + 40;
widget->x = m_area.getWidth()/2 - textWidth/2;
widget->y = y4;
widget->w = textWidth;
widget->h = buttonHeight;
widget->m_x = m_area.getWidth()/2 - textWidth/2;
widget->m_y = y4;
widget->m_w = textWidth;
widget->m_h = buttonHeight;
widget->setParent(m_irrlicht_window);
m_children.push_back(widget);
widget->add();
@ -152,10 +152,10 @@ void PlayerInfoDialog::showConfirmDialog()
const int textWidth = font->getDimension( widget->m_text.c_str() ).Width + 40;
widget->x = m_area.getWidth()/2 - textWidth/2;
widget->y = m_area.getHeight()/2;
widget->w = textWidth;
widget->h = buttonHeight;
widget->m_x = m_area.getWidth()/2 - textWidth/2;
widget->m_y = m_area.getHeight()/2;
widget->m_w = textWidth;
widget->m_h = buttonHeight;
widget->setParent(m_irrlicht_window);
m_children.push_back(widget);
widget->add();
@ -170,10 +170,10 @@ void PlayerInfoDialog::showConfirmDialog()
const int textWidth = font->getDimension( widget->m_text.c_str() ).Width + 40;
widget->x = m_area.getWidth()/2 - textWidth/2;
widget->y = m_area.getHeight()*3/4;
widget->w = textWidth;
widget->h = buttonHeight;
widget->m_x = m_area.getWidth()/2 - textWidth/2;
widget->m_y = m_area.getHeight()*3/4;
widget->m_w = textWidth;
widget->m_h = buttonHeight;
widget->setParent(m_irrlicht_window);
m_children.push_back(widget);
widget->add();

View File

@ -33,10 +33,10 @@ PressAKeyDialog::PressAKeyDialog(const float w, const float h) :
LabelWidget* widget = new LabelWidget();
widget->m_text = _("Press a key");
widget->m_properties[PROP_TEXT_ALIGN] = "center";
widget->x = 0;
widget->y = 0;
widget->w = m_area.getWidth();
widget->h = m_area.getHeight()/2;
widget->m_x = 0;
widget->m_y = 0;
widget->m_w = m_area.getWidth();
widget->m_h = m_area.getHeight()/2;
widget->setParent(m_irrlicht_window);
m_children.push_back(widget);
@ -49,10 +49,10 @@ PressAKeyDialog::PressAKeyDialog(const float w, const float h) :
ButtonWidget* widget2 = new ButtonWidget();
widget2->m_properties[PROP_ID] = "cancel";
widget2->m_text = _("Press ESC to cancel");
widget2->x = 15;
widget2->y = m_area.getHeight() - textHeight - 12;
widget2->w = m_area.getWidth() - 30;
widget2->h = textHeight + 6;
widget2->m_x = 15;
widget2->m_y = m_area.getHeight() - textHeight - 12;
widget2->m_w = m_area.getWidth() - 30;
widget2->m_h = textHeight + 6;
widget2->setParent(m_irrlicht_window);
m_children.push_back(widget2);

View File

@ -337,20 +337,20 @@ RaceOverDialog::RaceOverDialog(const float percentWidth,
LabelWidget* unlocked_label = new LabelWidget();
unlocked_label->m_properties[PROP_ID] = "label";
unlocked_label->m_properties[PROP_TEXT_ALIGN] = "center";
unlocked_label->x = button_h + 30;
unlocked_label->y = label_y;
unlocked_label->w = m_area.getWidth() - button_h*2 - 60;
unlocked_label->h = button_h;
unlocked_label->m_x = button_h + 30;
unlocked_label->m_y = label_y;
unlocked_label->m_w = m_area.getWidth() - button_h*2 - 60;
unlocked_label->m_h = button_h;
unlocked_label->m_text = _("You unlocked a new feature!");
unlocked_label->setParent(m_irrlicht_window);
m_children.push_back(unlocked_label);
unlocked_label->add();
ButtonWidget* whats_next_btn = new ButtonWidget();
whats_next_btn->x = 15;
whats_next_btn->y = m_area.getHeight() - (button_h + margin_between_buttons);
whats_next_btn->w = m_area.getWidth() - 30;
whats_next_btn->h = button_h;
whats_next_btn->m_x = 15;
whats_next_btn->m_y = m_area.getHeight() - (button_h + margin_between_buttons);
whats_next_btn->m_w = m_area.getWidth() - 30;
whats_next_btn->m_h = button_h;
whats_next_btn->setParent(m_irrlicht_window);
whats_next_btn->m_text = _("See unlocked features");
@ -365,10 +365,10 @@ RaceOverDialog::RaceOverDialog(const float percentWidth,
{
ButtonWidget* new_race_btn = new ButtonWidget();
new_race_btn->m_properties[PROP_ID] = "newracebtn";
new_race_btn->x = 15;
new_race_btn->y = m_area.getHeight() - (button_h + margin_between_buttons)*3;
new_race_btn->w = m_area.getWidth() - 30;
new_race_btn->h = button_h;
new_race_btn->m_x = 15;
new_race_btn->m_y = m_area.getHeight() - (button_h + margin_between_buttons)*3;
new_race_btn->m_w = m_area.getWidth() - 30;
new_race_btn->m_h = button_h;
new_race_btn->m_text = _("Setup New Race");
new_race_btn->setParent(m_irrlicht_window);
m_children.push_back(new_race_btn);
@ -376,20 +376,20 @@ RaceOverDialog::RaceOverDialog(const float percentWidth,
ButtonWidget* race_again_btn = new ButtonWidget();
race_again_btn->m_properties[PROP_ID] = "raceagainbtn";
race_again_btn->x = 15;
race_again_btn->y = m_area.getHeight() - (button_h + margin_between_buttons)*2;
race_again_btn->w = m_area.getWidth() - 30;
race_again_btn->h = button_h;
race_again_btn->m_x = 15;
race_again_btn->m_y = m_area.getHeight() - (button_h + margin_between_buttons)*2;
race_again_btn->m_w = m_area.getWidth() - 30;
race_again_btn->m_h = button_h;
race_again_btn->m_text = _("Race in this track again");
race_again_btn->setParent(m_irrlicht_window);
m_children.push_back(race_again_btn);
race_again_btn->add();
ButtonWidget* whats_next_btn = new ButtonWidget();
whats_next_btn->x = 15;
whats_next_btn->y = m_area.getHeight() - (button_h + margin_between_buttons);
whats_next_btn->w = m_area.getWidth() - 30;
whats_next_btn->h = button_h;
whats_next_btn->m_x = 15;
whats_next_btn->m_y = m_area.getHeight() - (button_h + margin_between_buttons);
whats_next_btn->m_w = m_area.getWidth() - 30;
whats_next_btn->m_h = button_h;
whats_next_btn->setParent(m_irrlicht_window);
whats_next_btn->m_text = _("Back to the main menu");
@ -403,10 +403,10 @@ RaceOverDialog::RaceOverDialog(const float percentWidth,
else if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
{
ButtonWidget* whats_next_btn = new ButtonWidget();
whats_next_btn->x = 15;
whats_next_btn->y = m_area.getHeight() - (button_h + margin_between_buttons)*2;
whats_next_btn->w = m_area.getWidth() - 30;
whats_next_btn->h = button_h;
whats_next_btn->m_x = 15;
whats_next_btn->m_y = m_area.getHeight() - (button_h + margin_between_buttons)*2;
whats_next_btn->m_w = m_area.getWidth() - 30;
whats_next_btn->m_h = button_h;
whats_next_btn->setParent(m_irrlicht_window);
whats_next_btn->m_text = _("Continue Grand Prix");
@ -420,10 +420,10 @@ RaceOverDialog::RaceOverDialog(const float percentWidth,
ButtonWidget* abort_gp = new ButtonWidget();
abort_gp->m_properties[PROP_ID] = "backtomenu";
abort_gp->x = 15;
abort_gp->y = m_area.getHeight() - (button_h + margin_between_buttons);
abort_gp->w = m_area.getWidth() - 30;
abort_gp->h = button_h;
abort_gp->m_x = 15;
abort_gp->m_y = m_area.getHeight() - (button_h + margin_between_buttons);
abort_gp->m_w = m_area.getWidth() - 30;
abort_gp->m_h = button_h;
abort_gp->m_text = _("Abort Grand Prix");
abort_gp->setParent(m_irrlicht_window);
m_children.push_back(abort_gp);

View File

@ -68,10 +68,10 @@ RacePausedDialog::RacePausedDialog(const float percentWidth, const float percent
back_btn->m_properties[PROP_ICON] = "gui/back.png";
//I18N: In the 'paused' screen
back_btn->m_text = _("Back to Race");
back_btn->x = m_area.getWidth() / 2 - icon_size;
back_btn->y = text_height*2;
back_btn->w = icon_size*2; // width larger to leave room for text
back_btn->h = icon_size;
back_btn->m_x = m_area.getWidth() / 2 - icon_size;
back_btn->m_y = text_height*2;
back_btn->m_w = icon_size*2; // width larger to leave room for text
back_btn->m_h = icon_size;
back_btn->setParent(m_irrlicht_window);
m_children.push_back(back_btn);
back_btn->add();
@ -82,10 +82,10 @@ RacePausedDialog::RacePausedDialog(const float percentWidth, const float percent
m_choice_ribbon = new RibbonWidget(RIBBON_TOOLBAR);
m_choice_ribbon->m_properties[PROP_ID] = "choiceribbon";
m_choice_ribbon->x = 0;
m_choice_ribbon->y = text_height*2 + icon_size + 50;
m_choice_ribbon->w = m_area.getWidth();
m_choice_ribbon->h = icon_size + text_height;
m_choice_ribbon->m_x = 0;
m_choice_ribbon->m_y = text_height*2 + icon_size + 50;
m_choice_ribbon->m_w = m_area.getWidth();
m_choice_ribbon->m_h = icon_size + text_height;
m_choice_ribbon->setParent(m_irrlicht_window);
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_SINGLE)

View File

@ -86,10 +86,10 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const irr::core:
screenshotWidget->setCustomAspectRatio(4.0f / 3.0f);
core::rect< s32 > area_right(m_area.getWidth()/2, y1, m_area.getWidth(), y2-10);
screenshotWidget->x = area_right.UpperLeftCorner.X;
screenshotWidget->y = area_right.UpperLeftCorner.Y;
screenshotWidget->w = area_right.getWidth();
screenshotWidget->h = area_right.getHeight();
screenshotWidget->m_x = area_right.UpperLeftCorner.X;
screenshotWidget->m_y = area_right.UpperLeftCorner.Y;
screenshotWidget->m_w = area_right.getWidth();
screenshotWidget->m_h = area_right.getHeight();
// temporary icon, will replace it just after (but it will be shown if the given icon is not found)
screenshotWidget->m_properties[PROP_ICON] = "gui/main_help.png";
@ -109,10 +109,10 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const irr::core:
if (has_laps)
{
m_spinner = new SpinnerWidget();
m_spinner->x = m_area.getWidth()/2 - 200;
m_spinner->y = y2;
m_spinner->w = 400;
m_spinner->h = y3 - y2 - 15;
m_spinner->m_x = m_area.getWidth()/2 - 200;
m_spinner->m_y = y2;
m_spinner->m_w = 400;
m_spinner->m_h = y3 - y2 - 15;
m_spinner->setParent(m_irrlicht_window);
m_spinner->m_properties[PROP_ID] = "lapcountspinner";
@ -137,10 +137,10 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const irr::core:
ButtonWidget* okBtn = new ButtonWidget();
okBtn->m_properties[PROP_ID] = "start";
okBtn->m_text = _("Start Race");
okBtn->x = m_area.getWidth()/2 - 200;
okBtn->y = y3;
okBtn->w = 400;
okBtn->h = m_area.getHeight() - y3 - 15;
okBtn->m_x = m_area.getWidth()/2 - 200;
okBtn->m_y = y3;
okBtn->m_w = 400;
okBtn->m_h = m_area.getHeight() - y3 - 15;
okBtn->setParent(m_irrlicht_window);
m_children.push_back(okBtn);
okBtn->add();

View File

@ -118,10 +118,10 @@ void GrandPrixWin::init()
GUIEngine::LabelWidget* unlocked_label = new GUIEngine::LabelWidget();
unlocked_label->m_properties[GUIEngine::PROP_ID] = "label";
unlocked_label->m_properties[GUIEngine::PROP_TEXT_ALIGN] = "center";
unlocked_label->x = label_x_from;
unlocked_label->y = y_from;
unlocked_label->w = message_width;
unlocked_label->h = label_height;
unlocked_label->m_x = label_x_from;
unlocked_label->m_y = y_from;
unlocked_label->m_w = message_width;
unlocked_label->m_h = label_height;
unlocked_label->m_text = message;
//const irr::video::SColor orange(255, 255, 126, 21);
//unlocked_label->setColor(orange);

View File

@ -70,10 +70,10 @@ public:
m_parent = parent;
m_supports_multiplayer = true;
x = 0;
y = 0;
w = 1;
h = 1;
m_x = 0;
m_y = 0;
m_w = 1;
m_h = 1;
m_reserved_id = Widget::getNewNoFocusID();
}
@ -90,15 +90,15 @@ public:
virtual void add()
{
core::rect<s32> widget_size = core::rect<s32>(x, y, x + w, y + h);
core::rect<s32> widget_size = core::rect<s32>(m_x, m_y, m_x + m_w, m_y + m_h);
//gui::IGUIStaticText* irrwidget = GUIEngine::getGUIEnv()->addStaticText(L" ", widget_size, false, false, NULL, m_reserved_id);
m_element = GUIEngine::getGUIEnv()->addButton(widget_size, NULL, m_reserved_id, L"Dispatcher", L"");
id = m_element->getID();
m_id = m_element->getID();
m_element->setTabStop(true);
m_element->setTabGroup(false);
m_element->setTabOrder(id);
m_element->setTabOrder(m_id);
m_element->setVisible(false);
}
@ -142,8 +142,8 @@ public:
m_incorrect = true;
irr::video::ITexture* texture = irr_driver->getTexture( file_manager->getTextureFile("red_mark.png").c_str() ) ;
const int mark_size = h;
const int mark_x = w - mark_size*2;
const int mark_size = m_h;
const int mark_x = m_w - mark_size*2;
const int mark_y = 0;
core::rect< s32 > red_mark_area(mark_x, mark_y, mark_x + mark_size, mark_y + mark_size);
m_red_mark_widget = GUIEngine::getGUIEnv()->addImage( red_mark_area, /* parent */ m_element );
@ -223,11 +223,11 @@ public:
this->m_playerID = m_playerID;
this->m_properties[PROP_ID] = StringUtils::insertValues("@p%i", m_playerID);
setSize(area->x, area->y, area->w, area->h);
target_x = x;
target_y = y;
target_w = w;
target_h = h;
setSize(area->m_x, area->m_y, area->m_w, area->m_h);
target_x = m_x;
target_y = m_y;
target_w = m_w;
target_h = m_h;
// ---- Player ID label
if (associatedPlayer->getDevice()->getType() == DT_KEYBOARD)
@ -247,20 +247,20 @@ public:
m_player_ID_label->m_properties[PROP_TEXT_ALIGN] = "center";
m_player_ID_label->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_label", m_playerID);
m_player_ID_label->x = player_id_x;
m_player_ID_label->y = player_id_y;
m_player_ID_label->w = player_id_w;
m_player_ID_label->h = player_id_h;
m_player_ID_label->m_x = player_id_x;
m_player_ID_label->m_y = player_id_y;
m_player_ID_label->m_w = player_id_w;
m_player_ID_label->m_h = player_id_h;
//playerID->setParent(this);
m_children.push_back(m_player_ID_label);
// ---- Player identity spinner
m_player_ident_spinner = new PlayerNameSpinner(parent, m_playerID);
m_player_ident_spinner->x = player_name_x;
m_player_ident_spinner->y = player_name_y;
m_player_ident_spinner->w = player_name_w;
m_player_ident_spinner->h = player_name_h;
m_player_ident_spinner->m_x = player_name_x;
m_player_ident_spinner->m_y = player_name_y;
m_player_ident_spinner->m_w = player_name_w;
m_player_ident_spinner->m_h = player_name_h;
//m_player_ident_spinner->m_event_handler = this;
if (irrlichtWidgetID == -1)
@ -283,10 +283,10 @@ public:
// ----- Kart model view
m_model_view = new ModelViewWidget();
m_model_view->x = model_x;
m_model_view->y = model_y;
m_model_view->w = model_w;
m_model_view->h = model_h;
m_model_view->m_x = model_x;
m_model_view->m_y = model_y;
m_model_view->m_w = model_w;
m_model_view->m_h = model_h;
m_model_view->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_model", m_playerID);
//m_model_view->setParent(this);
m_children.push_back(m_model_view);
@ -308,10 +308,10 @@ public:
m_kart_name->m_text = props->getName();
m_kart_name->m_properties[PROP_TEXT_ALIGN] = "center";
m_kart_name->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_kartname", m_playerID);
m_kart_name->x = kart_name_x;
m_kart_name->y = kart_name_y;
m_kart_name->w = kart_name_w;
m_kart_name->h = kart_name_h;
m_kart_name->m_x = kart_name_x;
m_kart_name->m_y = kart_name_y;
m_kart_name->m_w = kart_name_w;
m_kart_name->m_h = kart_name_h;
//m_kart_name->setParent(this);
m_children.push_back(m_kart_name);
}
@ -418,10 +418,10 @@ public:
target_w = w;
target_h = h;
x_speed = abs( this->x - x ) / 300.0f;
y_speed = abs( this->y - y ) / 300.0f;
w_speed = abs( this->w - w ) / 300.0f;
h_speed = abs( this->h - h ) / 300.0f;
x_speed = abs( m_x - x ) / 300.0f;
y_speed = abs( m_y - y ) / 300.0f;
w_speed = abs( m_w - w ) / 300.0f;
h_speed = abs( m_h - h ) / 300.0f;
}
/** Call when player confirmed his identity and kart */
@ -458,58 +458,58 @@ public:
/** Updates the animation (moving/shrinking/etc.) */
void onUpdate(float delta)
{
if (target_x == x && target_y == y && target_w == w && target_h == h) return;
if (target_x == m_x && target_y == m_y && target_w == m_w && target_h == m_h) return;
int move_step = (int)(delta*1000.0f);
// move x towards target
if (x < target_x)
if (m_x < target_x)
{
x += (int)(move_step*x_speed);
if (x > target_x) x = target_x; // don't move to the other side of the target
m_x += (int)(move_step*x_speed);
if (m_x > target_x) m_x = target_x; // don't move to the other side of the target
}
else if (x > target_x)
else if (m_x > target_x)
{
x -= (int)(move_step*x_speed);
if (x < target_x) x = target_x; // don't move to the other side of the target
m_x -= (int)(move_step*x_speed);
if (m_x < target_x) m_x = target_x; // don't move to the other side of the target
}
// move y towards target
if (y < target_y)
if (m_y < target_y)
{
y += (int)(move_step*y_speed);
if (y > target_y) y = target_y; // don't move to the other side of the target
m_y += (int)(move_step*y_speed);
if (m_y > target_y) m_y = target_y; // don't move to the other side of the target
}
else if (y > target_y)
else if (m_y > target_y)
{
y -= (int)(move_step*y_speed);
if (y < target_y) y = target_y; // don't move to the other side of the target
m_y -= (int)(move_step*y_speed);
if (m_y < target_y) m_y = target_y; // don't move to the other side of the target
}
// move w towards target
if (w < target_w)
if (m_w < target_w)
{
w += (int)(move_step*w_speed);
if (w > target_w) w = target_w; // don't move to the other side of the target
m_w += (int)(move_step*w_speed);
if (m_w > target_w) m_w = target_w; // don't move to the other side of the target
}
else if (w > target_w)
else if (m_w > target_w)
{
w -= (int)(move_step*w_speed);
if (w < target_w) w = target_w; // don't move to the other side of the target
m_w -= (int)(move_step*w_speed);
if (m_w < target_w) m_w = target_w; // don't move to the other side of the target
}
// move h towards target
if (h < target_h)
if (m_h < target_h)
{
h += (int)(move_step*h_speed);
if (h > target_h) h = target_h; // don't move to the other side of the target
m_h += (int)(move_step*h_speed);
if (m_h > target_h) m_h = target_h; // don't move to the other side of the target
}
else if (h > target_h)
else if (m_h > target_h)
{
h -= (int)(move_step*h_speed);
if (h < target_h) h = target_h; // don't move to the other side of the target
m_h -= (int)(move_step*h_speed);
if (m_h < target_h) m_h = target_h; // don't move to the other side of the target
}
setSize(x, y, w, h);
setSize(m_x, m_y, m_w, m_h);
m_player_ID_label->move(player_id_x,
player_id_y,
@ -563,10 +563,10 @@ public:
/** Sets the size of the widget as a whole, and placed children widgets inside itself */
void setSize(const int x, const int y, const int w, const int h)
{
this->x = x;
this->y = y;
this->w = w;
this->h = h;
m_x = x;
m_y = y;
m_w = w;
m_h = h;
// -- sizes
player_id_w = w;
@ -892,7 +892,7 @@ bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
// ---- Get available area for karts
// make a copy of the area, ands move it to be outside the screen
Widget kartsArea = *this->getWidget("playerskarts"); // copy
kartsArea.x = irr_driver->getFrameSize().Width; // start at the rightmost of the screen
kartsArea.m_x = irr_driver->getFrameSize().Width; // start at the rightmost of the screen
// ---- Create new active player
PlayerProfile* profileToUse = UserConfigParams::m_all_players.get(0);
@ -924,11 +924,11 @@ bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
// ---- Divide screen space among all karts
const int amount = m_kart_widgets.size();
Widget* fullarea = this->getWidget("playerskarts");
const int splitWidth = fullarea->w / amount;
const int splitWidth = fullarea->m_w / amount;
for (int n=0; n<amount; n++)
{
m_kart_widgets[n].move( fullarea->x + splitWidth*n, fullarea->y, splitWidth, fullarea->h );
m_kart_widgets[n].move( fullarea->m_x + splitWidth*n, fullarea->m_y, splitWidth, fullarea->m_h );
}
@ -1009,7 +1009,8 @@ bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player)
// Tell the removed widget to perform the shrinking animation (which will be updated in onUpdate,
// and will stop when the widget has disappeared)
Widget* fullarea = this->getWidget("playerskarts");
m_removed_widget->move( m_removed_widget->x + m_removed_widget->w/2, fullarea->y + fullarea->h, 0, 0);
m_removed_widget->move(m_removed_widget->m_x + m_removed_widget->m_w/2,
fullarea->m_y + fullarea->m_h, 0, 0);
// update selections
@ -1062,7 +1063,7 @@ void KartSelectionScreen::onUpdate(float delta, irr::video::IVideoDriver*)
{
m_removed_widget->onUpdate(delta);
if (m_removed_widget->w == 0 || m_removed_widget->h == 0)
if (m_removed_widget->m_w == 0 || m_removed_widget->m_h == 0)
{
// destruct when too small (for "disappear" effects)
this->manualRemoveWidget(m_removed_widget);
@ -1430,13 +1431,13 @@ void KartSelectionScreen::renumberKarts()
DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("karts");
assert( w != NULL );
Widget* fullarea = this->getWidget("playerskarts");
const int splitWidth = fullarea->w / m_kart_widgets.size();
const int splitWidth = fullarea->m_w / m_kart_widgets.size();
//printf("Renumbering karts...");
for (int n=0; n < m_kart_widgets.size(); n++)
{
m_kart_widgets[n].setPlayerID(n);
m_kart_widgets[n].move( fullarea->x + splitWidth*n, fullarea->y, splitWidth, fullarea->h );
m_kart_widgets[n].move( fullarea->m_x + splitWidth*n, fullarea->m_y, splitWidth, fullarea->m_h );
}
w->updateItemDisplay();