openttd updated to 1.5.0-beta2

--HG--
branch : openttd
This commit is contained in:
Pavel Stupnikov
2015-03-01 00:30:53 +03:00
parent 0abb47ce90
commit d201932121
682 changed files with 26103 additions and 16553 deletions

View File

@@ -1,4 +1,4 @@
/* $Id: window.cpp 26392 2014-03-05 21:21:55Z alberth $ */
/* $Id: window.cpp 27147 2015-02-13 21:25:48Z frosch $ */
/*
* This file is part of OpenTTD.
@@ -37,6 +37,8 @@
#include "game/game.hpp"
#include "video/video_driver.hpp"
#include "safeguards.h"
/** Values for _settings_client.gui.auto_scrolling */
enum ViewportAutoscrolling {
VA_DISABLED, //!< Do not autoscroll when mouse is at edge of viewport.
@@ -85,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),
@@ -100,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;
@@ -111,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.
*/
@@ -446,7 +468,7 @@ bool EditBoxInGlobalFocus()
void Window::UnfocusFocusedWidget()
{
if (this->nested_focus != NULL) {
if (this->nested_focus->type == WWT_EDITBOX) _video_driver->EditBoxLostFocus();
if (this->nested_focus->type == WWT_EDITBOX) VideoDriver::GetInstance()->EditBoxLostFocus();
/* Repaint the widget that lost focus. A focused edit box may else leave the caret on the screen. */
this->nested_focus->SetDirty(this);
@@ -470,7 +492,7 @@ bool Window::SetFocusedWidget(int widget_index)
/* Repaint the widget that lost focus. A focused edit box may else leave the caret on the screen. */
this->nested_focus->SetDirty(this);
if (this->nested_focus->type == WWT_EDITBOX) _video_driver->EditBoxLostFocus();
if (this->nested_focus->type == WWT_EDITBOX) VideoDriver::GetInstance()->EditBoxLostFocus();
}
this->nested_focus = this->GetWidget<NWidgetCore>(widget_index);
return true;
@@ -481,7 +503,7 @@ bool Window::SetFocusedWidget(int widget_index)
*/
void Window::OnFocusLost()
{
if (this->nested_focus != NULL && this->nested_focus->type == WWT_EDITBOX) _video_driver->EditBoxLostFocus();
if (this->nested_focus != NULL && this->nested_focus->type == WWT_EDITBOX) VideoDriver::GetInstance()->EditBoxLostFocus();
}
/**
@@ -750,7 +772,7 @@ static void DispatchRightClickEvent(Window *w, int x, int y)
if (w->OnRightClick(pt, wid->index)) return;
}
if (_settings_client.gui.hover_delay == 0 && wid->tool_tip != 0) GuiShowTooltips(w, wid->tool_tip, 0, NULL, TCC_RIGHT_CLICK);
if (_settings_client.gui.hover_delay_ms == 0 && wid->tool_tip != 0) GuiShowTooltips(w, wid->tool_tip, 0, NULL, TCC_RIGHT_CLICK);
}
/**
@@ -1265,6 +1287,7 @@ static uint GetWindowZPriority(const Window *w)
case WC_CONFIRM_POPUP_QUERY:
case WC_MODAL_PROGRESS:
case WC_NETWORK_STATUS_WINDOW:
case WC_SAVE_PRESET:
++z_priority;
case WC_GENERATE_LANDSCAPE:
@@ -2876,7 +2899,7 @@ void HandleMouseEvents()
static uint32 hover_time = 0;
static Point hover_pos = {0, 0};
if (_settings_client.gui.hover_delay > 0) {
if (_settings_client.gui.hover_delay_ms > 0) {
if (!_cursor.in_window || click != MC_NONE || mousewheel != 0 || _left_button_down || _right_button_down ||
hover_pos.x == 0 || abs(_cursor.pos.x - hover_pos.x) >= MAX_OFFSET_HOVER ||
hover_pos.y == 0 || abs(_cursor.pos.y - hover_pos.y) >= MAX_OFFSET_HOVER) {
@@ -2884,7 +2907,7 @@ void HandleMouseEvents()
hover_time = _realtime_tick;
_mouse_hovering = false;
} else {
if (hover_time != 0 && _realtime_tick > hover_time + _settings_client.gui.hover_delay * 1000) {
if (hover_time != 0 && _realtime_tick > hover_time + _settings_client.gui.hover_delay_ms) {
click = MC_HOVER;
_input_events_this_tick++;
_mouse_hovering = true;
@@ -3261,6 +3284,9 @@ void ReInitAllWindows()
NWidgetLeaf::InvalidateDimensionCache(); // Reset cached sizes of several widgets.
NWidgetScrollbar::InvalidateDimensionCache();
extern void InitDepotWindowBlockSizes();
InitDepotWindowBlockSizes();
Window *w;
FOR_ALL_WINDOWS_FROM_BACK(w) {
w->ReInit();
@@ -3382,7 +3408,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
@@ -3394,14 +3420,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;