Changeset - r9165:ce5457160835
[Not reviewed]
master
0 10 0
rubidium - 16 years ago 2008-05-10 12:30:27
rubidium@openttd.org
(svn r13028) -Codechange: WE_MESSAGE and WE_INVALIDATE_DATA were doing the same thing.
10 files changed with 41 insertions and 102 deletions:
0 comments (0 inline, 0 general)
src/main_gui.cpp
Show inline comments
 
@@ -190,7 +190,7 @@ bool DoZoomInOutWindow(int how, Window *
 
	}
 
	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,
 
			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;
 
	}
 
}
src/network/network_gui.cpp
Show inline comments
 
@@ -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(Win
 
			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(Wi
 
			}
 
			break;
 

	
 
		case WE_MESSAGE:
 
		case WE_INVALIDATE_DATA:
 
			SetWindowDirty(w);
 
			break;
 
	}
 
@@ -1860,7 +1860,7 @@ static void ChatWindowWndProc(Window *w,
 
{
 
	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,
 
			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;
 
	}
src/news_gui.cpp
Show inline comments
 
@@ -62,6 +62,7 @@ static NewsID _latest_news = INVALID_NEW
 

	
 
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, Wi
 
	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, Wi
 
			}
 
			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) {
src/saveload.cpp
Show inline comments
 
@@ -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;
 
}
 

	
src/smallmap_gui.cpp
Show inline comments
 
@@ -1182,10 +1182,8 @@ static void ExtraViewPortWndProc(Window 
 
			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;
 
	}
src/statusbar_gui.cpp
Show inline comments
 
@@ -86,7 +86,7 @@ static void StatusBarWndProc(Window *w, 
 
			}
 

	
 
			/* 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, 
 
			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:
src/toolbar_gui.cpp
Show inline comments
 
@@ -796,7 +796,7 @@ static void MainToolbarWndProc(Window *w
 
			}
 
			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(Windo
 
			}
 
			break;
 

	
 
		case WE_MESSAGE:
 
		case WE_INVALIDATE_DATA:
 
			HandleZoomMessage(w, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, 9, 10);
 
			break;
 
	}
src/window.cpp
Show inline comments
 
@@ -1591,53 +1591,6 @@ static bool MaybeBringWindowToFront(cons
 
	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
 
 * 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 cl
 
 * 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);
 
	}
 
}
 

	
src/window_func.h
Show inline comments
 
@@ -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 InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_index);
 
void InvalidateWindow(WindowClass cls, WindowNumber number);
 
void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_index);
 
void InvalidateWindowClasses(WindowClass cls);
 
void InvalidateWindowClassesData(WindowClass cls);
 

	
 
void DeleteWindowById(WindowClass cls, WindowNumber number);
 
void DeleteWindowByClass(WindowClass cls);
 

	
src/window_gui.h
Show inline comments
 
@@ -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
 
@@ -274,16 +271,6 @@ struct ResizeInfo {
 
};
 

	
 
/**
 
 * Message data structure for messages sent between winodows
 
 * @see SendWindowMessageW()
 
 */
 
struct WindowMessage {
 
	int msg;
 
	int wparam;
 
	int lparam;
 
};
 

	
 
/**
 
 * Data structure for an opened window
 
 */
 
struct Window : ZeroedMemoryAllocator {
 
@@ -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
 

	
0 comments (0 inline, 0 general)