Changeset - r16508:4ece159f9ad1
[Not reviewed]
master
0 4 0
rubidium - 14 years ago 2010-11-18 19:24:40
rubidium@openttd.org
(svn r21244) -Fix [FS#4240] (r21179): the news message always stayed in the middle; let it follow the setting of the statusbar instead
4 files changed with 24 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/news_gui.cpp
Show inline comments
 
@@ -328,6 +328,8 @@ struct NewsWindow : Window {
 
				nvp->disp_flags |= ND_SHADE_DIMMED;
 
			}
 
		}
 

	
 
		PositionNewsMessage(this);
 
	}
 

	
 
	void DrawNewsBorder(const Rect &r) const
 
@@ -342,7 +344,7 @@ struct NewsWindow : Window {
 

	
 
	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 };
 
		Point pt = { 0, _screen.height };
 
		return pt;
 
	}
 

	
src/settings.cpp
Show inline comments
 
@@ -693,7 +693,10 @@ static bool v_PositionMainToolbar(int32 
 
/** Reposition the statusbar as the setting changed. */
 
static bool v_PositionStatusbar(int32 p1)
 
{
 
	if (_game_mode != GM_MENU) PositionStatusbar(NULL);
 
	if (_game_mode != GM_MENU) {
 
		PositionStatusbar(NULL);
 
		PositionNewsMessage(NULL);
 
	}
 
	return true;
 
}
 

	
src/window.cpp
Show inline comments
 
@@ -2654,12 +2654,15 @@ static int PositionWindow(Window *w, Win
 
	if (w == NULL || w->window_class != clss) {
 
		w = FindWindowById(clss, 0);
 
	}
 

	
 
	if (w == NULL) return 0;
 

	
 
	int old_left = w->left;
 
	switch (setting) {
 
		case 1:  w->left = (_screen.width - w->width) / 2; break;
 
		case 2:  w->left = _screen.width - w->width; break;
 
		default: w->left = 0; break;
 
	}
 
	if (w->viewport != NULL) w->viewport->left += w->left - old_left;
 
	SetDirtyBlocks(0, w->top, _screen.width, w->top + w->height); // invalidate the whole row
 
	return w->left;
 
}
 
@@ -2686,6 +2689,17 @@ int PositionStatusbar(Window *w)
 
	return PositionWindow(w, WC_STATUS_BAR, _settings_client.gui.statusbar_pos);
 
}
 

	
 
/**
 
 * (Re)position news message window at the screen.
 
 * @param w Window structure of the news message window, may also be \c NULL.
 
 * @return X coordinate of left edge of the repositioned news message.
 
 */
 
int PositionNewsMessage(Window *w)
 
{
 
	DEBUG(misc, 5, "Repositioning news message...");
 
	return PositionWindow(w, WC_NEWS_WINDOW, _settings_client.gui.statusbar_pos);
 
}
 

	
 

	
 
/**
 
 * Switches viewports following vehicles, which get autoreplaced
 
@@ -2737,7 +2751,7 @@ void RelocateAllWindows(int neww, int ne
 

	
 
			case WC_NEWS_WINDOW:
 
				top = newh - w->height;
 
				left = (neww - w->width) >> 1;
 
				left = PositionNewsMessage(w);
 
				break;
 

	
 
			case WC_STATUS_BAR:
src/window_func.h
Show inline comments
 
@@ -22,6 +22,7 @@ void ChangeWindowOwner(Owner old_owner, 
 
void ResizeWindow(Window *w, int x, int y);
 
int PositionMainToolbar(Window *w);
 
int PositionStatusbar(Window *w);
 
int PositionNewsMessage(Window *w);
 

	
 
int GetMainViewTop();
 
int GetMainViewBottom();
0 comments (0 inline, 0 general)