Merge branch 'master' into enhanced_viewport_overlay

Notes on conflict resolution:
* MarkTileDirtyByTile gained an extra param on both sides of the merge
  Move bridge level offset to be after zoom level param, as it's used less.
* Add zoom level params to MarkBridgeDirty functions
* Fix undefined behaviour in colour_index cycling in ViewportMapDraw

Conflicts:
	src/clear_cmd.cpp
	src/pbs.cpp
	src/rail_cmd.cpp
	src/toolbar_gui.cpp
	src/train_cmd.cpp
	src/vehicle.cpp
	src/viewport.cpp
	src/viewport_func.h
This commit is contained in:
Jonathan G Rennison
2015-08-05 21:25:13 +01:00
220 changed files with 5428 additions and 4324 deletions

View File

@@ -87,12 +87,10 @@ static SmallVector<WindowDesc*, 16> *_window_descs = NULL;
char *_windows_file;
/** Window description constructor. */
WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16 def_width, int16 def_height,
WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16 def_width_trad, int16 def_height_trad,
WindowClass window_class, WindowClass parent_class, uint32 flags,
const NWidgetPart *nwid_parts, int16 nwid_length, HotkeyList *hotkeys) :
default_pos(def_pos),
default_width(def_width),
default_height(def_height),
cls(window_class),
parent_cls(parent_class),
ini_key(ini_key),
@@ -102,7 +100,9 @@ WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16 def_wi
hotkeys(hotkeys),
pref_sticky(false),
pref_width(0),
pref_height(0)
pref_height(0),
default_width_trad(def_width_trad),
default_height_trad(def_height_trad)
{
if (_window_descs == NULL) _window_descs = new SmallVector<WindowDesc*, 16>();
*_window_descs->Append() = this;
@@ -113,6 +113,26 @@ WindowDesc::~WindowDesc()
_window_descs->Erase(_window_descs->Find(this));
}
/**
* Determine default width of window.
* This is either a stored user preferred size, or the build-in default.
* @return Width in pixels.
*/
int16 WindowDesc::GetDefaultWidth() const
{
return this->pref_width != 0 ? this->pref_width : ScaleGUITrad(this->default_width_trad);
}
/**
* Determine default height of window.
* This is either a stored user preferred size, or the build-in default.
* @return Height in pixels.
*/
int16 WindowDesc::GetDefaultHeight() const
{
return this->pref_height != 0 ? this->pref_height : ScaleGUITrad(this->default_height_trad);
}
/**
* Load all WindowDesc settings from _windows_file.
*/
@@ -1059,7 +1079,16 @@ Window::~Window()
free(this->nested_array); // Contents is released through deletion of #nested_root.
delete this->nested_root;
this->window_class = WC_INVALID;
/*
* Make fairly sure that this is written, and not "optimized" away.
* The delete operator is overwritten to not delete it; the deletion
* happens at a later moment in time after the window has been
* removed from the list of windows to prevent issues with items
* being removed during the iteration as not one but more windows
* may be removed by a single call to ~Window by means of the
* DeleteChildWindows function.
*/
const_cast<volatile WindowClass &>(this->window_class) = WC_INVALID;
}
/**
@@ -3408,7 +3437,7 @@ void RelocateAllWindows(int neww, int newh)
continue;
case WC_MAIN_TOOLBAR:
ResizeWindow(w, min(neww, w->window_desc->default_width) - w->width, 0, false);
ResizeWindow(w, min(neww, _toolbar_width) - w->width, 0, false);
top = w->top;
left = PositionMainToolbar(w); // changes toolbar orientation
@@ -3420,14 +3449,15 @@ void RelocateAllWindows(int neww, int newh)
break;
case WC_STATUS_BAR:
ResizeWindow(w, min(neww, w->window_desc->default_width) - w->width, 0, false);
ResizeWindow(w, min(neww, _toolbar_width) - w->width, 0, false);
top = newh - w->height;
left = PositionStatusbar(w);
break;
case WC_SEND_NETWORK_MSG:
ResizeWindow(w, Clamp(neww, 320, 640) - w->width, 0, false);
ResizeWindow(w, min(neww, _toolbar_width) - w->width, 0, false);
top = newh - w->height - FindWindowById(WC_STATUS_BAR, 0)->height;
left = PositionNetworkChatWindow(w);
break;