mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
(svn r13028) -Codechange: WE_MESSAGE and WE_INVALIDATE_DATA were doing the same thing.
This commit is contained in:
parent
f23026cce8
commit
935434333b
@ -190,7 +190,7 @@ bool DoZoomInOutWindow(int how, Window *w)
|
||||
}
|
||||
w->SetDirty();
|
||||
/* Update the windows that have zoom-buttons to perhaps disable their buttons */
|
||||
SendWindowMessageClass(w->window_class, how, w->window_number, 0);
|
||||
InvalidateThisWindowData(w);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -390,9 +390,9 @@ static void MainWindowWndProc(Window *w, WindowEvent *e)
|
||||
ZoomInOrOutToCursorWindow(e->we.wheel.wheel < 0, w);
|
||||
break;
|
||||
|
||||
case WE_MESSAGE:
|
||||
case WE_INVALIDATE_DATA:
|
||||
/* Forward the message to the appropiate toolbar (ingame or scenario editor) */
|
||||
SendWindowMessage(WC_MAIN_TOOLBAR, 0, e->we.message.msg, e->we.message.wparam, e->we.message.lparam);
|
||||
InvalidateWindowData(WC_MAIN_TOOLBAR, 0, e->we.invalidate.data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ enum {
|
||||
* @param unselect unselect the currently selected item */
|
||||
void UpdateNetworkGameWindow(bool unselect)
|
||||
{
|
||||
SendWindowMessage(WC_NETWORK_WINDOW, 0, unselect, 0, 0);
|
||||
InvalidateWindowData(WC_NETWORK_WINDOW, 0, unselect);
|
||||
}
|
||||
|
||||
static bool _internal_sort_order; // Used for Qsort order-flipping
|
||||
@ -549,8 +549,8 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
|
||||
if (nd->field == NGWW_PLAYER) HandleEditBox(w, &WP(w, network_ql_d).q, NGWW_PLAYER);
|
||||
break;
|
||||
|
||||
case WE_MESSAGE:
|
||||
if (e->we.message.msg != 0) nd->server = NULL;
|
||||
case WE_INVALIDATE_DATA:
|
||||
if (e->we.invalidate.data != 0) nd->server = NULL;
|
||||
ld->flags |= VL_REBUILD;
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
@ -1183,7 +1183,7 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_MESSAGE:
|
||||
case WE_INVALIDATE_DATA:
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
}
|
||||
@ -1860,7 +1860,7 @@ static void ChatWindowWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
switch (e->event) {
|
||||
case WE_CREATE:
|
||||
SendWindowMessage(WC_NEWS_WINDOW, 0, WE_CREATE, w->height, 0);
|
||||
InvalidateWindowData(WC_NEWS_WINDOW, 0, w->height);
|
||||
SetBit(_no_scroll, SCROLL_CHAT); // do not scroll the game with the arrow-keys
|
||||
break;
|
||||
|
||||
@ -1910,7 +1910,7 @@ static void ChatWindowWndProc(Window *w, WindowEvent *e)
|
||||
break;
|
||||
|
||||
case WE_DESTROY:
|
||||
SendWindowMessage(WC_NEWS_WINDOW, 0, WE_DESTROY, 0, 0);
|
||||
InvalidateWindowData(WC_NEWS_WINDOW, 0, 0);
|
||||
ClrBit(_no_scroll, SCROLL_CHAT);
|
||||
break;
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ static NewsID _latest_news = INVALID_NEWS; ///< points to last item in fifo que
|
||||
|
||||
struct news_d : vp_d {
|
||||
uint16 follow_vehicle;
|
||||
uint16 chat_height;
|
||||
int32 scrollpos_x;
|
||||
int32 scrollpos_y;
|
||||
int32 dest_scrollpos_x;
|
||||
@ -131,7 +132,7 @@ static void NewsWindowProc(Window *w, WindowEvent *e)
|
||||
switch (e->event) {
|
||||
case WE_CREATE: { // If chatbar is open at creation time, we need to go above it
|
||||
const Window *w1 = FindWindowById(WC_SEND_NETWORK_MSG, 0);
|
||||
w->message.msg = (w1 != NULL) ? w1->height : 0;
|
||||
WP(w, news_d).chat_height = (w1 != NULL) ? w1->height : 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -231,15 +232,12 @@ static void NewsWindowProc(Window *w, WindowEvent *e)
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_MESSAGE: // The chatbar has notified us that is was either created or closed
|
||||
switch (e->we.message.msg) {
|
||||
case WE_CREATE: w->message.msg = e->we.message.wparam; break;
|
||||
case WE_DESTROY: w->message.msg = 0; break;
|
||||
}
|
||||
case WE_INVALIDATE_DATA: // The chatbar has notified us that is was either created or closed
|
||||
WP(w, news_d).chat_height = e->we.invalidate.data;
|
||||
break;
|
||||
|
||||
case WE_TICK: { // Scroll up newsmessages from the bottom in steps of 4 pixels
|
||||
int y = max(w->top - 4, _screen.height - w->height - 12 - w->message.msg);
|
||||
int y = max(w->top - 4, _screen.height - w->height - 12 - WP(w, news_d).chat_height);
|
||||
if (y == w->top) return;
|
||||
|
||||
if (w->viewport != NULL) {
|
||||
|
@ -1493,7 +1493,7 @@ static void SaveFileStart()
|
||||
_fast_forward = 0;
|
||||
if (_cursor.sprite == SPR_CURSOR_MOUSE) SetMouseCursor(SPR_CURSOR_ZZZ, PAL_NONE);
|
||||
|
||||
SendWindowMessage(WC_STATUS_BAR, 0, true, 0, 0);
|
||||
InvalidateWindowData(WC_STATUS_BAR, 0, true);
|
||||
_ts.saveinprogress = true;
|
||||
}
|
||||
|
||||
@ -1504,7 +1504,7 @@ static void SaveFileDone()
|
||||
_fast_forward = _ts.ff_state;
|
||||
if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE);
|
||||
|
||||
SendWindowMessage(WC_STATUS_BAR, 0, false, 0, 0);
|
||||
InvalidateWindowData(WC_STATUS_BAR, 0, false);
|
||||
_ts.saveinprogress = false;
|
||||
}
|
||||
|
||||
|
@ -1182,10 +1182,8 @@ static void ExtraViewPortWndProc(Window *w, WindowEvent *e)
|
||||
ZoomInOrOutToCursorWindow(e->we.wheel.wheel < 0, w);
|
||||
break;
|
||||
|
||||
|
||||
case WE_MESSAGE:
|
||||
case WE_INVALIDATE_DATA:
|
||||
/* Only handle zoom message if intended for us (msg ZOOM_IN/ZOOM_OUT) */
|
||||
if (e->we.message.wparam != w->window_number) break;
|
||||
HandleZoomMessage(w, w->viewport, 5, 6);
|
||||
break;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ static void StatusBarWndProc(Window *w, WindowEvent *e)
|
||||
}
|
||||
|
||||
/* Draw status bar */
|
||||
if (w->message.msg) { // true when saving is active
|
||||
if (WP(w, def_d).data_3) { // true when saving is active
|
||||
DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_SAVING_GAME, TC_FROMSTRING);
|
||||
} else if (_do_autosave) {
|
||||
DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_032F_AUTOSAVE, TC_FROMSTRING);
|
||||
@ -113,9 +113,8 @@ static void StatusBarWndProc(Window *w, WindowEvent *e)
|
||||
if (WP(w, def_d).data_2 > 0) DrawSprite(SPR_BLOT, PALETTE_TO_RED, w->widget[1].right - 11, 2);
|
||||
} break;
|
||||
|
||||
case WE_MESSAGE:
|
||||
w->message.msg = e->we.message.msg;
|
||||
w->SetDirty();
|
||||
case WE_INVALIDATE_DATA:
|
||||
WP(w, def_d).data_3 = e->we.invalidate.data;
|
||||
break;
|
||||
|
||||
case WE_CLICK:
|
||||
|
@ -796,7 +796,7 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e)
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_MESSAGE:
|
||||
case WE_INVALIDATE_DATA:
|
||||
if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(w, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, 17, 18);
|
||||
break;
|
||||
}
|
||||
@ -1032,7 +1032,7 @@ static void ScenEditToolbarWndProc(Window *w, WindowEvent *e)
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_MESSAGE:
|
||||
case WE_INVALIDATE_DATA:
|
||||
HandleZoomMessage(w, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, 9, 10);
|
||||
break;
|
||||
}
|
||||
|
@ -1591,53 +1591,6 @@ static bool MaybeBringWindowToFront(const Window *w)
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Send a message from one window to another. The receiving window is found by
|
||||
* @param w Window pointer pointing to the other window
|
||||
* @param msg Specifies the message to be sent
|
||||
* @param wparam Specifies additional message-specific information
|
||||
* @param lparam Specifies additional message-specific information
|
||||
*/
|
||||
static void SendWindowMessageW(Window *w, uint msg, uint wparam, uint lparam)
|
||||
{
|
||||
WindowEvent e;
|
||||
|
||||
e.event = WE_MESSAGE;
|
||||
e.we.message.msg = msg;
|
||||
e.we.message.wparam = wparam;
|
||||
e.we.message.lparam = lparam;
|
||||
|
||||
w->HandleWindowEvent(&e);
|
||||
}
|
||||
|
||||
/** Send a message from one window to another. The receiving window is found by
|
||||
* @param wnd_class see WindowClass class AND
|
||||
* @param wnd_num see WindowNumber number, mostly 0
|
||||
* @param msg Specifies the message to be sent
|
||||
* @param wparam Specifies additional message-specific information
|
||||
* @param lparam Specifies additional message-specific information
|
||||
*/
|
||||
void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam)
|
||||
{
|
||||
Window *w = FindWindowById(wnd_class, wnd_num);
|
||||
if (w != NULL) SendWindowMessageW(w, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
/** Send a message from one window to another. The message will be sent
|
||||
* to ALL windows of the windowclass specified in the first parameter
|
||||
* @param wnd_class see WindowClass class
|
||||
* @param msg Specifies the message to be sent
|
||||
* @param wparam Specifies additional message-specific information
|
||||
* @param lparam Specifies additional message-specific information
|
||||
*/
|
||||
void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam)
|
||||
{
|
||||
Window* const *wz;
|
||||
|
||||
FOR_ALL_WINDOWS(wz) {
|
||||
if ((*wz)->window_class == wnd_class) SendWindowMessageW(*wz, msg, wparam, lparam);
|
||||
}
|
||||
}
|
||||
|
||||
/** Handle keyboard input.
|
||||
* @param key Lower 8 bits contain the ASCII character, the higher 16 bits the keycode
|
||||
*/
|
||||
@ -2032,9 +1985,14 @@ void InvalidateWindowClasses(WindowClass cls)
|
||||
* Mark window data as invalid (in need of re-computing)
|
||||
* @param w Window with invalid data
|
||||
*/
|
||||
void InvalidateThisWindowData(Window *w)
|
||||
void InvalidateThisWindowData(Window *w, int data)
|
||||
{
|
||||
CallWindowEventNP(w, WE_INVALIDATE_DATA);
|
||||
WindowEvent e;
|
||||
|
||||
e.event = WE_INVALIDATE_DATA;
|
||||
e.we.invalidate.data = data;
|
||||
|
||||
w->HandleWindowEvent(&e);
|
||||
w->SetDirty();
|
||||
}
|
||||
|
||||
@ -2043,13 +2001,13 @@ void InvalidateThisWindowData(Window *w)
|
||||
* @param cls Window class
|
||||
* @param number Window number within the class
|
||||
*/
|
||||
void InvalidateWindowData(WindowClass cls, WindowNumber number)
|
||||
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data)
|
||||
{
|
||||
Window* const *wz;
|
||||
|
||||
FOR_ALL_WINDOWS(wz) {
|
||||
Window *w = *wz;
|
||||
if (w->window_class == cls && w->window_number == number) InvalidateThisWindowData(w);
|
||||
if (w->window_class == cls && w->window_number == number) InvalidateThisWindowData(w, data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2057,12 +2015,12 @@ void InvalidateWindowData(WindowClass cls, WindowNumber number)
|
||||
* Mark window data of all windows of a given class as invalid (in need of re-computing)
|
||||
* @param cls Window class
|
||||
*/
|
||||
void InvalidateWindowClassesData(WindowClass cls)
|
||||
void InvalidateWindowClassesData(WindowClass cls, int data)
|
||||
{
|
||||
Window* const *wz;
|
||||
|
||||
FOR_ALL_WINDOWS(wz) {
|
||||
if ((*wz)->window_class == cls) InvalidateThisWindowData(*wz);
|
||||
if ((*wz)->window_class == cls) InvalidateThisWindowData(*wz, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,6 @@
|
||||
#include "player_type.h"
|
||||
|
||||
void SetWindowDirty(const Window *w);
|
||||
void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam);
|
||||
void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam);
|
||||
|
||||
Window *FindWindowById(WindowClass cls, WindowNumber number);
|
||||
void ChangeWindowOwner(PlayerID old_player, PlayerID new_player);
|
||||
@ -23,18 +21,20 @@ void UnInitWindowSystem();
|
||||
void ResetWindowSystem();
|
||||
void SetupColorsAndInitialWindow();
|
||||
void InputLoop();
|
||||
void InvalidateThisWindowData(Window *w);
|
||||
void InvalidateWindowData(WindowClass cls, WindowNumber number);
|
||||
|
||||
void InvalidateThisWindowData(Window *w, int data = 0);
|
||||
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data = 0);
|
||||
void InvalidateWindowClassesData(WindowClass cls, int data = 0);
|
||||
|
||||
void DeleteNonVitalWindows();
|
||||
void DeleteAllNonVitalWindows();
|
||||
void HideVitalWindows();
|
||||
void ShowVitalWindows();
|
||||
|
||||
void InvalidateWindow(WindowClass cls, WindowNumber number);
|
||||
void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_index);
|
||||
void InvalidateWindow(WindowClass cls, WindowNumber number);
|
||||
void InvalidateWindowClasses(WindowClass cls);
|
||||
void InvalidateWindowClassesData(WindowClass cls);
|
||||
|
||||
void DeleteWindowById(WindowClass cls, WindowNumber number);
|
||||
void DeleteWindowByClass(WindowClass cls);
|
||||
|
||||
|
@ -131,7 +131,6 @@ enum WindowEventCodes {
|
||||
WE_PLACE_PRESIZE,
|
||||
WE_DROPDOWN_SELECT,
|
||||
WE_RESIZE, ///< Request to resize the window, @see WindowEvent.we.resize
|
||||
WE_MESSAGE, ///< Receipt of a message from another window. @see WindowEvent.we.message, SendWindowMessage(), SendWindowMessageClass()
|
||||
WE_SCROLL,
|
||||
WE_INVALIDATE_DATA, ///< Notification that data displayed by the window is obsolete
|
||||
WE_CTRL_CHANGED, ///< CTRL key has changed state
|
||||
@ -192,10 +191,8 @@ struct WindowEvent {
|
||||
} keypress;
|
||||
|
||||
struct {
|
||||
int msg; ///< message to be sent
|
||||
int wparam; ///< additional message-specific information
|
||||
int lparam; ///< additional message-specific information
|
||||
} message;
|
||||
int data;
|
||||
} invalidate;
|
||||
|
||||
struct {
|
||||
Point delta; ///< delta position against position of last call
|
||||
@ -273,16 +270,6 @@ struct ResizeInfo {
|
||||
uint step_height; ///< Step-size of height resize changes
|
||||
};
|
||||
|
||||
/**
|
||||
* Message data structure for messages sent between winodows
|
||||
* @see SendWindowMessageW()
|
||||
*/
|
||||
struct WindowMessage {
|
||||
int msg;
|
||||
int wparam;
|
||||
int lparam;
|
||||
};
|
||||
|
||||
/**
|
||||
* Data structure for an opened window
|
||||
*/
|
||||
@ -322,7 +309,6 @@ public:
|
||||
uint widget_count; ///< Number of widgets of the window
|
||||
uint32 desc_flags; ///< Window/widgets default flags setting, @see WindowDefaultFlag
|
||||
|
||||
WindowMessage message; ///< Buffer for storing received messages (for communication between different window events)
|
||||
Window *parent; ///< Parent window
|
||||
byte custom[WINDOW_CUSTOM_SIZE]; ///< Additional data depending on window type
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user