Changeset - r9093:19c5268b9f72
[Not reviewed]
master
0 1 0
peter1138 - 16 years ago 2008-05-05 11:24:58
peter1138@openttd.org
(svn r12952) -Cleanup: Indenting and codestyle
1 file changed with 45 insertions and 36 deletions:
0 comments (0 inline, 0 general)
src/news_gui.cpp
Show inline comments
 
@@ -128,13 +128,14 @@ void DrawNewsBorder(const Window *w)
 
static void NewsWindowProc(Window *w, WindowEvent *e)
 
{
 
	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;
 
		} break;
 
			break;
 
		}
 

	
 
		case WE_PAINT: {
 
			const NewsItem *ni = WP(w, news_d).ni;
 

	
 
			switch (ni->display_mode) {
 
				case NM_NORMAL:
 
@@ -183,34 +184,39 @@ static void NewsWindowProc(Window *w, Wi
 
						DrawWindowViewport(w);
 
						CopyInDParam(0, ni->params, lengthof(ni->params));
 
						DrawStringMultiCenter(w->width / 2, w->height - 16, ni->string_id, w->width - 4);
 
					}
 
					break;
 
			}
 
		} break;
 
			break;
 
		}
 

	
 
		case WE_CLICK: {
 
		case WE_CLICK:
 
			switch (e->we.click.widget) {
 
			case 1: {
 
				NewsItem *ni = WP(w, news_d).ni;
 
				DeleteWindow(w);
 
				ni->duration = 0;
 
				_forced_news = INVALID_NEWS;
 
			} break;
 
			case 0: {
 
				NewsItem *ni = WP(w, news_d).ni;
 
				if (ni->flags & NF_VEHICLE) {
 
					Vehicle *v = GetVehicle(ni->data_a);
 
					ScrollMainWindowTo(v->x_pos, v->y_pos);
 
				} else if (ni->flags & NF_TILE) {
 
					if (!ScrollMainWindowToTile(ni->data_a) && ni->data_b != 0)
 
						ScrollMainWindowToTile(ni->data_b);
 
				case 1: {
 
					NewsItem *ni = WP(w, news_d).ni;
 
					DeleteWindow(w);
 
					ni->duration = 0;
 
					_forced_news = INVALID_NEWS;
 
					break;
 
				}
 
			} break;
 

	
 
				case 0: {
 
					NewsItem *ni = WP(w, news_d).ni;
 
					if (ni->flags & NF_VEHICLE) {
 
						Vehicle *v = GetVehicle(ni->data_a);
 
						ScrollMainWindowTo(v->x_pos, v->y_pos);
 
					} else if (ni->flags & NF_TILE) {
 
						if (!ScrollMainWindowToTile(ni->data_a) && ni->data_b != 0) {
 
							ScrollMainWindowToTile(ni->data_b);
 
						}
 
					}
 
					break;
 
				}
 
			}
 
		} break;
 
			break;
 

	
 
		case WE_KEYPRESS:
 
			if (e->we.keypress.keycode == WKC_SPACE) {
 
				/* Don't continue. */
 
				e->we.keypress.cont = false;
 
				DeleteWindow(w);
 
@@ -222,24 +228,25 @@ static void NewsWindowProc(Window *w, Wi
 
				case WE_CREATE: w->message.msg = e->we.message.wparam; break;
 
				case WE_DESTROY: w->message.msg = 0; break;
 
			}
 
			break;
 

	
 
		case WE_TICK: { // Scroll up newsmessages from the bottom in steps of 4 pixels
 
			int diff;
 
			int y = max(w->top - 4, _screen.height - w->height - 12 - w->message.msg);
 
			if (y == w->top) return;
 

	
 
			if (w->viewport != NULL)
 
			if (w->viewport != NULL) {
 
				w->viewport->top += y - w->top;
 
			}
 

	
 
			diff = Delta(w->top, y);
 
			int diff = Delta(w->top, y);
 
			w->top = y;
 

	
 
			SetDirtyBlocks(w->left, w->top - diff, w->left + w->width, w->top + w->height);
 
		} break;
 
			break;
 
		}
 
	}
 
}
 

	
 
/**
 
 * Return the correct index in the pseudo-fifo
 
 * queue and deals with overflows when increasing the index
 
@@ -695,21 +702,21 @@ static const WindowDesc _message_history
 
/** Display window with news messages history */
 
void ShowMessageHistory()
 
{
 
	DeleteWindowById(WC_MESSAGE_HISTORY, 0);
 
	Window *w = AllocateWindowDesc(&_message_history_desc);
 

	
 
	if (w != NULL) {
 
		w->vscroll.cap = 10;
 
		w->vscroll.count = _total_news;
 
		w->resize.step_height = 12;
 
		w->resize.height = w->height - 12 * 6; // minimum of 4 items in the list, each item 12 high
 
		w->resize.step_width = 1;
 
		w->resize.width = 200; // can't make window any smaller than 200 pixel
 
		SetWindowDirty(w);
 
	}
 
	if (w == NULL) return;
 

	
 
	w->vscroll.cap = 10;
 
	w->vscroll.count = _total_news;
 
	w->resize.step_height = 12;
 
	w->resize.height = w->height - 12 * 6; // minimum of 4 items in the list, each item 12 high
 
	w->resize.step_width = 1;
 
	w->resize.width = 200; // can't make window any smaller than 200 pixel
 
	SetWindowDirty(w);
 
}
 

	
 

	
 
/** News settings window widget offset constants */
 
enum {
 
	WIDGET_NEWSOPT_DROP_SUMMARY = 4,  ///< Dropdown that adjusts at once the level for all settings
 
@@ -754,27 +761,28 @@ static void MessageOptionsWndProc(Window
 
				SetMessageButtonStates(w, _news_type_data[i].display, i);
 
				/* If the value doesn't match the ALL-button value, set the ALL-button value to 'off' */
 
				if (_news_type_data[i].display != all_val) all_val = ND_OFF;
 
			}
 
			/* If all values are the same value, the ALL-button will take over this value */
 
			WP(w, def_d).data_1 = all_val;
 
		} break;
 
			break;
 
		}
 

	
 
		case WE_PAINT: {
 
		case WE_PAINT:
 
			if (_news_ticker_sound) w->LowerWidget(WIDGET_NEWSOPT_SOUNDTICKER);
 

	
 
			w->widget[WIDGET_NEWSOPT_DROP_SUMMARY].data = message_opt[WP(w, def_d).data_1];
 
			DrawWindowWidgets(w);
 

	
 
			/* Draw the string of each setting on each button. */
 
			for (int i = 0, y = 26; i < NT_END; i++, y += 12) {
 
				/* 51 comes from 13 + 89 (left and right of the button)+1, shiefted by one as to get division,
 
				 * which will give centered position */
 
				DrawStringCentered(51, y + 1, message_opt[_news_type_data[i].display], TC_BLACK);
 
			}
 
		} break;
 
			break;
 

	
 
		case WE_CLICK:
 
			switch (e->we.click.widget) {
 
				case WIDGET_NEWSOPT_DROP_SUMMARY: // Dropdown menu for all settings
 
					ShowDropDownMenu(w, message_opt, WP(w, def_d).data_1, WIDGET_NEWSOPT_DROP_SUMMARY, 0, 0);
 
					break;
 
@@ -792,13 +800,14 @@ static void MessageOptionsWndProc(Window
 
						byte val = (_news_type_data[element].display + ((wid % NB_WIDG_PER_SETTING) ? 1 : -1)) % 3;
 

	
 
						SetMessageButtonStates(w, val, element);
 
						_news_type_data[element].display = (NewsDisplay)val;
 
						SetWindowDirty(w);
 
					}
 
				} break;
 
					break;
 
				}
 
			}
 
			break;
 

	
 
		case WE_DROPDOWN_SELECT: // Select all settings for newsmessages
 
			WP(w, def_d).data_1 = e->we.dropdown.index;
 

	
0 comments (0 inline, 0 general)