Merge branch 'master' into 1.5

Conflicts:
	src/ai/ai_gui.cpp
	src/build_vehicle_gui.cpp
	src/cheat_gui.cpp
	src/company_gui.cpp
	src/depot_gui.cpp
	src/dock_gui.cpp
	src/genworld_gui.cpp
	src/misc_gui.cpp
	src/network/network_content_gui.cpp
	src/network/network_gui.cpp
	src/newgrf_gui.cpp
	src/news_gui.cpp
	src/rail_gui.cpp
	src/road_gui.cpp
	src/settings_gui.cpp
	src/settings_gui.h
	src/station_gui.cpp
	src/table/settings.ini
	src/toolbar_gui.cpp
	src/toolbar_gui.h
	src/vehicle_gui.cpp
	src/video/sdl_v.cpp
	src/widget.cpp
	src/widgets/settings_widget.h
This commit is contained in:
pelya
2015-03-29 21:48:14 +03:00
115 changed files with 3996 additions and 1021 deletions

View File

@@ -34,11 +34,15 @@ byte _support8bpp;
CursorVars _cursor;
bool _ctrl_pressed; ///< Is Ctrl pressed?
bool _shift_pressed; ///< Is Shift pressed?
bool _move_pressed;
byte _fast_forward;
bool _left_button_down; ///< Is left mouse button pressed?
bool _left_button_clicked; ///< Is left mouse button clicked?
bool _right_button_down; ///< Is right mouse button pressed?
bool _right_button_clicked; ///< Is right mouse button clicked?
Point _right_button_down_pos; ///< Pos of right mouse button click, for drag and drop
DrawPixelInfo _screen;
bool _screen_disable_anim = false; ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
bool _exit_game;
@@ -1201,6 +1205,8 @@ void ScreenSizeChanged()
/* screen size changed and the old bitmap is invalid now, so we don't want to undraw it */
_cursor.visible = false;
NWidgetScrollbar::ResetAllWidgetMinSizes();
}
void UndrawMouseCursor()
@@ -1218,11 +1224,6 @@ void UndrawMouseCursor()
void DrawMouseCursor()
{
#if defined(WINCE)
/* Don't ever draw the mouse for WinCE, as we work with a stylus */
return;
#endif
/* Don't draw the mouse cursor if the screen is not ready */
if (_screen.dst_ptr == NULL) return;
@@ -1678,3 +1679,104 @@ void SortResolutions(int count)
{
QSortT(_resolutions, count, &compare_res);
}
/**
* Returns the initial value for a margin, after telling where are the left and right margins and where we want to draw/write (begining/end of line)
* @param left is the left margin of the horizontal space we want to draw to
* @param right: right margin
* @param to_end_line: 0 if working at the begining of the line, 1 if working at the end
* @return the margin we asked
*/
int InitTempMargin(int left, int right, bool to_end_line)
{
return to_end_line ^ (_current_text_dir == TD_RTL) ? right :left;
}
/**
* Consumes a space in an horizontal margin
* @param space: amount of space used
* @param here: the margin where to add the space
* @param to_end_line: 0 if working at the begining of the line, 1 if working at the end
*/
void AddSpace(int space, int &here, bool to_end_line)
{
here += to_end_line ^ (_current_text_dir == TD_RTL) ? -space : space;
}
/**
* After drawing something, update a margin
* @param end is where we ended drawing (usually the return value of a DrawString function)
* @param margin is the margin we want to update
* @param to_end_line: 0 if working at the begining of the line, 1 if working at the end
*/
void UpdateMarginEnd(int end, int &margin, bool to_end_line)
{
margin = to_end_line ^ (_current_text_dir == TD_RTL) ? min(end, margin) : max(end, margin);
}
/**
* After drawing something, horizontal margins are updated
* @param end: last position drawn
* @param left is the left margin of the horizontal space drawn
* @param right: right margin
* @param to_end_line: 0 if working at the begining of the line, 1 if working at the end
*/
void UpdateMarginsEnd(int end, int &left, int &right, bool to_end_line)
{
if (to_end_line ^ (_current_text_dir == TD_RTL)) {
right = end;
} else {
left = end;
}
}
/**
* After drawing something of a certain width, update margins
* @param width: used space
* @param initial left margin
* @param initial right margin
* @param to_end_line: 0 if working at the begining of the line, 1 if working at the end
*/
void UpdateMarginsWidth(int width, int &left, int &right, bool to_end_line)
{
if (to_end_line ^ (_current_text_dir == TD_RTL)) {
right -= width;
} else {
left += width;
}
}
/**
* Draws a string in a delimited space; temporal margin gets updated
* @param left is the left margin of the horizontal space we want to draw to
* @param right: right margin of the horizontal space we want to draw to
* @param top: vertical position
* @param margin keeps the most extreme limit used of the line (this should be previously initialized with InitTempLimit)
* @param string to draw
* @param colour for the string
* @param alignment of the string (only left or right alignment)
* @param underline
*/
void DrawString2(int left, int right, int top, int &margin, StringID str, TextColour colour, StringAlignment align, bool underline)
{
int end = DrawString(left, right, top, str, colour, align, underline);
UpdateMarginEnd(end, margin, align == SA_RIGHT);
}
/**
* Draws a sprite in a delimited space; temporal margin gets updated
* @param width of the sprite
* @param left is the left margin of the horizontal space we want to draw to
* @param right: right margin of the horizontal space
* @param top: vertical position
* @param margin keeps the most extreme limit used of the line (this should be previously initialized with InitTempLimit)
* @param sprite
* @param palette
* @param to_end_line: 0 if working at the begining of the line, 1 if working at the end
*/
void DrawSprite2(int width, int left, int right, int top, int &margin, SpriteID img, PaletteID pal, bool to_end_line, SubSprite *sub)
{
DrawSprite(img, pal, to_end_line ^ (_current_text_dir == TD_RTL) ? right - width : left, top, sub);
margin = to_end_line ^ (_current_text_dir == TD_RTL) ? min(right - width, margin): max(margin, left + width);
}