File diff r23123:aa31147b532e → r23124:8fa6d269005b
src/news_gui.cpp
Show inline comments
 
@@ -257,17 +257,19 @@ NewsDisplay NewsTypeData::GetDisplay() c
 

	
 
/** 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
 
	const 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).
 
	static int duration;  ///< Remaining time for showing the current news message (may only be access while a news item is displayed).
 

	
 
	uint timer;
 

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

	
 
		this->flags |= WF_DISABLE_VP_SCROLL;
 

	
 
@@ -482,17 +484,24 @@ struct NewsWindow : Window {
 
		/* The chatbar has notified us that is was either created or closed */
 
		int newtop = this->top + this->chat_height - data;
 
		this->chat_height = data;
 
		this->SetWindowTop(newtop);
 
	}
 

	
 
	virtual void OnTick()
 
	virtual void OnRealtimeTick(uint delta_ms)
 
	{
 
		/* Scroll up newsmessages from the bottom in steps of 4 pixels */
 
		int newtop = max(this->top - 4, _screen.height - this->height - this->status_height - this->chat_height);
 
		this->SetWindowTop(newtop);
 
		int count = CountIntervalElapsed(this->timer, delta_ms, 15);
 
		if (count > 0) {
 
			/* Scroll up newsmessages from the bottom */
 
			int newtop = max(this->top - 2 * count, _screen.height - this->height - this->status_height - this->chat_height);
 
			this->SetWindowTop(newtop);
 
		}
 

	
 
		/* Decrement the news timer. We don't need to action an elapsed event here,
 
		 * so no need to use TimerElapsed(). */
 
		if (NewsWindow::duration > 0) NewsWindow::duration -= delta_ms;
 
	}
 

	
 
private:
 
	/**
 
	 * Moves the window to a new #top coordinate. Makes screen dirty where needed.
 
	 * @param newtop new top coordinate
 
@@ -533,13 +542,13 @@ private:
 
			default:
 
				NOT_REACHED();
 
		}
 
	}
 
};
 

	
 
/* static */ uint NewsWindow::duration = 0; // Instance creation.
 
/* static */ int NewsWindow::duration = 0; // Instance creation.
 

	
 

	
 
/** Open up an own newspaper window for the news item */
 
static void ShowNewspaper(const NewsItem *ni)
 
{
 
	SoundFx sound = _news_type_data[ni->type].sound;
 
@@ -585,17 +594,14 @@ static bool ReadyForNextItem()
 
	if (ni == NULL) return true;
 

	
 
	/* Ticker message
 
	 * Check if the status bar message is still being displayed? */
 
	if (IsNewsTickerShown()) return false;
 

	
 
	/* Newspaper message, decrement duration counter */
 
	if (NewsWindow::duration != 0) NewsWindow::duration--;
 

	
 
	/* neither newsticker nor newspaper are running */
 
	return (NewsWindow::duration == 0 || FindWindowById(WC_NEWS_WINDOW, 0) == NULL);
 
	return (NewsWindow::duration <= 0 || FindWindowById(WC_NEWS_WINDOW, 0) == NULL);
 
}
 

	
 
/** Move to the next news item */
 
static void MoveToNextItem()
 
{
 
	InvalidateWindowData(WC_STATUS_BAR, 0, SBI_NEWS_DELETED); // invalidate the statusbar