Changeset - r13428:b65c72efe5d8
[Not reviewed]
master
0 4 0
rubidium - 15 years ago 2009-11-02 10:15:48
rubidium@openttd.org
(svn r17947) -Codechange: make the statusbar, chat input and news window know of eachothers size so they don't get overlapped and don't get invisible (bottoms) of windows when a larger font is used
4 files changed with 24 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -115,13 +115,13 @@ void CDECL NetworkAddChatMessage(TextCol
 
void NetworkInitChatMessage()
 
{
 
	MAX_CHAT_MESSAGES   = _settings_client.gui.network_chat_box_height;
 

	
 
	_chatmsg_list       = ReallocT(_chatmsg_list, _settings_client.gui.network_chat_box_height);
 
	_chatmsg_box.x      = 10;
 
	_chatmsg_box.y      = 30;
 
	_chatmsg_box.y      = 3 * FONT_HEIGHT_NORMAL;
 
	_chatmsg_box.width  = _settings_client.gui.network_chat_box_width;
 
	_chatmsg_box.height = _settings_client.gui.network_chat_box_height * (FONT_HEIGHT_NORMAL + NETWORK_CHAT_LINE_SPACING) + 2;
 
	_chatmessage_backup = ReallocT(_chatmessage_backup, _chatmsg_box.width * _chatmsg_box.height * BlitterFactoryBase::GetCurrentBlitter()->GetBytesPerPixel());
 

	
 
	for (uint i = 0; i < MAX_CHAT_MESSAGES; i++) {
 
		_chatmsg_list[i].message[0] = '\0';
 
@@ -446,12 +446,18 @@ struct NetworkChatWindow : public QueryS
 
	virtual void OnPaint()
 
	{
 
		this->DrawWidgets();
 
		this->DrawEditBox(NWCW_TEXTBOX);
 
	}
 

	
 
	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 };
 
		return pt;
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *resize)
 
	{
 
		if (widget != NWCW_DESTINATION) return;
 

	
 
		if (this->dtype == DESTTYPE_CLIENT) {
 
			SetDParamStr(0, NetworkFindClientInfoFromClientID((ClientID)this->dest)->client_name);
 
@@ -534,13 +540,13 @@ static const NWidgetPart _nested_chat_wi
 
			EndContainer(),
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
 
static const WindowDesc _chat_window_desc(
 
	WDP_CENTER, -26, 320, 14, 640, 14, // x, y, width, height
 
	WDP_CENTER, 0, 320, 14, 640, 14, // x, y, width, height
 
	WC_SEND_NETWORK_MSG, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET,
 
	NULL, _nested_chat_window_widgets, lengthof(_nested_chat_window_widgets)
 
);
 

	
 
void ShowNetworkChatQueryWindow(DestType type, int dest)
src/news_gui.cpp
Show inline comments
 
@@ -277,20 +277,22 @@ NewsTypeData _news_type_data[] = {
 

	
 
assert_compile(lengthof(_news_type_data) == NT_END);
 

	
 
/** Window class displaying a news item. */
 
struct NewsWindow : Window {
 
	uint16 chat_height;   ///< Height of the chat window.
 
	uint16 status_height; ///< Height of the status bar window
 
	NewsItem *ni;         ///< News item to display.
 
	static uint duration; ///< Remaining time for showing current news message (may only be accessed while a news item is displayed).
 

	
 
	NewsWindow(const WindowDesc *desc, NewsItem *ni) : Window(), ni(ni)
 
	{
 
		NewsWindow::duration = 555;
 
		const Window *w = FindWindowById(WC_SEND_NETWORK_MSG, 0);
 
		this->chat_height = (w != NULL) ? w->height : 0;
 
		this->status_height = FindWindowById(WC_STATUS_BAR, 0)->height;
 

	
 
		this->flags4 |= WF_DISABLE_VP_SCROLL;
 

	
 
		this->CreateNestedTree(desc);
 
		switch (this->ni->subtype) {
 
			case NS_COMPANY_TROUBLE:
 
@@ -487,13 +489,13 @@ struct NewsWindow : Window {
 
		this->chat_height = data;
 
	}
 

	
 
	virtual void OnTick()
 
	{
 
		/* Scroll up newsmessages from the bottom in steps of 4 pixels */
 
		int y = max(this->top - 4, _screen.height - this->height - 12 - this->chat_height);
 
		int y = max(this->top - 4, _screen.height - this->height - this->status_height - this->chat_height);
 
		if (y == this->top) return;
 

	
 
		if (this->viewport != NULL) this->viewport->top += y - this->top;
 

	
 
		int diff = Delta(this->top, y);
 
		this->top = y;
src/statusbar_gui.cpp
Show inline comments
 
@@ -95,17 +95,28 @@ struct StatusBarWindow : Window {
 
		this->ticker_scroll    =   TICKER_STOP;
 
		this->reminder_timeout = REMINDER_STOP;
 

	
 
		this->InitNested(desc);
 
	}
 

	
 
	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 };
 
		return pt;
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		this->DrawWidgets();
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *resize)
 
	{
 
		size->height = FONT_HEIGHT_NORMAL + padding.height;
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		switch (widget) {
 
			case SBW_LEFT:
 
				/* Draw the date */
 
				SetDParam(0, _date);
 
@@ -199,13 +210,13 @@ static const NWidgetPart _nested_main_st
 
		NWidget(WWT_PANEL, COLOUR_GREY, SBW_LEFT), SetMinimalSize(140, 12), EndContainer(),
 
		NWidget(WWT_PUSHBTN, COLOUR_GREY, SBW_MIDDLE), SetMinimalSize(40, 12), SetDataTip(0x0, STR_STATUSBAR_TOOLTIP_SHOW_LAST_NEWS), SetResize(1, 0),
 
		NWidget(WWT_PUSHBTN, COLOUR_GREY, SBW_RIGHT), SetMinimalSize(140, 12),
 
	EndContainer(),
 
};
 

	
 
static WindowDesc _main_status_desc(
 
static const WindowDesc _main_status_desc(
 
	WDP_CENTER, 0, 320, 12, 640, 12,
 
	WC_STATUS_BAR, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_NO_FOCUS,
 
	NULL, _nested_main_status_widgets, lengthof(_nested_main_status_widgets)
 
);
 

	
 
@@ -217,9 +228,8 @@ bool IsNewsTickerShown()
 
	const StatusBarWindow *w = dynamic_cast<StatusBarWindow*>(FindWindowById(WC_STATUS_BAR, 0));
 
	return w != NULL && w->ticker_scroll < StatusBarWindow::TICKER_STOP;
 
}
 

	
 
void ShowStatusBar()
 
{
 
	_main_status_desc.top = _screen.height - 12;
 
	new StatusBarWindow(&_main_status_desc);
 
}
src/window.cpp
Show inline comments
 
@@ -2717,13 +2717,13 @@ void RelocateAllWindows(int neww, int ne
 
				top = newh - w->height;
 
				left = (neww - w->width) >> 1;
 
				break;
 

	
 
			case WC_SEND_NETWORK_MSG:
 
				ResizeWindow(w, Clamp(neww, 320, 640) - w->width, 0);
 
				top = (newh - 26); // 26 = height of status bar + height of chat bar
 
				top = newh - w->height - FindWindowById(WC_STATUS_BAR, 0)->height;
 
				left = (neww - w->width) >> 1;
 
				break;
 

	
 
			case WC_CONSOLE:
 
				IConsoleResize(w);
 
				continue;
0 comments (0 inline, 0 general)