changeset 17319:a047622378d3 draft

(svn r22059) -Fix (r21179): Make the send chat message window follow the position of the status bar.
author terkhen <terkhen@openttd.org>
date Fri, 11 Feb 2011 18:24:12 +0000
parents a63c526add01
children 6268642d587f
files src/network/network_chat_gui.cpp src/settings.cpp src/window.cpp src/window_func.h
diffstat 4 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -303,6 +303,8 @@
 		this->SetFocusedWidget(NWCW_TEXTBOX);
 		InvalidateWindowData(WC_NEWS_WINDOW, 0, this->height);
 		_chat_tab_completion_active = false;
+
+		PositionNetworkChatWindow(this);
 	}
 
 	~NetworkChatWindow()
@@ -457,7 +459,7 @@
 
 	virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number)
 	{
-		Point pt = { (_screen.width - max(sm_width, desc->default_width)) / 2, _screen.height - sm_height - FindWindowById(WC_STATUS_BAR, 0)->height };
+		Point pt = { 0, _screen.height - sm_height - FindWindowById(WC_STATUS_BAR, 0)->height };
 		return pt;
 	}
 
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -693,6 +693,7 @@
 	if (_game_mode != GM_MENU) {
 		PositionStatusbar(NULL);
 		PositionNewsMessage(NULL);
+		PositionNetworkChatWindow(NULL);
 	}
 	return true;
 }
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -2675,6 +2675,17 @@
 	return PositionWindow(w, WC_NEWS_WINDOW, _settings_client.gui.statusbar_pos);
 }
 
+/**
+ * (Re)position network chat window at the screen.
+ * @param w Window structure of the network chat window, may also be \c NULL.
+ * @return X coordinate of left edge of the repositioned network chat winodw.
+ */
+int PositionNetworkChatWindow(Window *w)
+{
+	DEBUG(misc, 5, "Repositioning network chat window...");
+	return PositionWindow(w, WC_SEND_NETWORK_MSG, _settings_client.gui.statusbar_pos);
+}
+
 
 /**
  * Switches viewports following vehicles, which get autoreplaced
@@ -2739,7 +2750,7 @@
 			case WC_SEND_NETWORK_MSG:
 				ResizeWindow(w, Clamp(neww, 320, 640) - w->width, 0);
 				top = newh - w->height - FindWindowById(WC_STATUS_BAR, 0)->height;
-				left = (neww - w->width) >> 1;
+				left = PositionNetworkChatWindow(w);
 				break;
 
 			case WC_CONSOLE:
--- a/src/window_func.h
+++ b/src/window_func.h
@@ -23,6 +23,7 @@
 int PositionMainToolbar(Window *w);
 int PositionStatusbar(Window *w);
 int PositionNewsMessage(Window *w);
+int PositionNetworkChatWindow(Window *w);
 
 int GetMainViewTop();
 int GetMainViewBottom();