src/news_gui.cpp
branchnoai
changeset 9723 eee46cb39750
parent 9722 ebf0ece7d8f6
child 9724 b39bc69bb2f2
equal deleted inserted replaced
9722:ebf0ece7d8f6 9723:eee46cb39750
     1 /* $Id$ */
     1 /* $Id$ */
     2 
     2 
     3 
     3 
     4 #include "stdafx.h"
     4 #include "stdafx.h"
     5 #include "openttd.h"
     5 #include "openttd.h"
     6 #include "functions.h"
       
     7 #include "strings.h"
       
     8 #include "table/sprites.h"
     6 #include "table/sprites.h"
     9 #include "table/strings.h"
     7 #include "table/strings.h"
    10 #include "window.h"
       
    11 #include "gui.h"
     8 #include "gui.h"
    12 #include "viewport.h"
     9 #include "window_gui.h"
    13 #include "gfx.h"
    10 #include "viewport_func.h"
    14 #include "news.h"
    11 #include "news.h"
    15 #include "vehicle.h"
       
    16 #include "sound.h"
       
    17 #include "variables.h"
    12 #include "variables.h"
    18 #include "date.h"
       
    19 #include "string.h"
       
    20 #include "transparency.h"
    13 #include "transparency.h"
       
    14 #include "strings_func.h"
       
    15 #include "window_func.h"
       
    16 #include "date_func.h"
       
    17 #include "vehicle_base.h"
       
    18 #include "sound_func.h"
       
    19 #include "string_func.h"
    21 
    20 
    22 /** @file news_gui.cpp
    21 /** @file news_gui.cpp
    23  *
    22  *
    24  * News system is realized as a FIFO queue (in an array)
    23  * News system is realized as a FIFO queue (in an array)
    25  * The positions in the queue can't be rearranged, we only access
    24  * The positions in the queue can't be rearranged, we only access
   218 		if (y == w->top) return;
   217 		if (y == w->top) return;
   219 
   218 
   220 		if (w->viewport != NULL)
   219 		if (w->viewport != NULL)
   221 			w->viewport->top += y - w->top;
   220 			w->viewport->top += y - w->top;
   222 
   221 
   223 		diff = delta(w->top, y);
   222 		diff = Delta(w->top, y);
   224 		w->top = y;
   223 		w->top = y;
   225 
   224 
   226 		SetDirtyBlocks(w->left, w->top - diff, w->left + w->width, w->top + w->height);
   225 		SetDirtyBlocks(w->left, w->top - diff, w->left + w->width, w->top + w->height);
   227 	} break;
   226 	} break;
   228 	}
   227 	}
   799  */
   798  */
   800 static void SetMessageButtonStates(Window *w, byte value, int element)
   799 static void SetMessageButtonStates(Window *w, byte value, int element)
   801 {
   800 {
   802 	element *= NB_WIDG_PER_SETTING;
   801 	element *= NB_WIDG_PER_SETTING;
   803 
   802 
   804 	SetWindowWidgetDisabledState(w, element + WIDGET_NEWSOPT_START_OPTION, value == 0);
   803 	w->SetWidgetDisabledState(element + WIDGET_NEWSOPT_START_OPTION, value == 0);
   805 	SetWindowWidgetDisabledState(w, element + WIDGET_NEWSOPT_START_OPTION + 2, value == 2);
   804 	w->SetWidgetDisabledState(element + WIDGET_NEWSOPT_START_OPTION + 2, value == 2);
   806 }
   805 }
   807 
   806 
   808 /**
   807 /**
   809  * Event handler of the Message Options window
   808  * Event handler of the Message Options window
   810  * @param w window pointer
   809  * @param w window pointer
   834 
   833 
   835 		case WE_PAINT: {
   834 		case WE_PAINT: {
   836 			uint32 val = _news_display_opt;
   835 			uint32 val = _news_display_opt;
   837 			int i, y;
   836 			int i, y;
   838 
   837 
   839 			if (_news_ticker_sound) LowerWindowWidget(w, WIDGET_NEWSOPT_SOUNDTICKER);
   838 			if (_news_ticker_sound) w->LowerWidget(WIDGET_NEWSOPT_SOUNDTICKER);
   840 			DrawWindowWidgets(w);
   839 			DrawWindowWidgets(w);
   841 
   840 
   842 			/* Draw the string of each setting on each button. */
   841 			/* Draw the string of each setting on each button. */
   843 			for (i = 0, y = 26; i < NT_END; i++, y += 12, val >>= 2) {
   842 			for (i = 0, y = 26; i < NT_END; i++, y += 12, val >>= 2) {
   844 				/* 51 comes from 13 + 89 (left and right of the button)+1, shiefted by one as to get division,
   843 				/* 51 comes from 13 + 89 (left and right of the button)+1, shiefted by one as to get division,
   857 					ShowDropDownMenu(w, message_opt, WP(w, def_d).data_1, WIDGET_NEWSOPT_DROP_SUMMARY, 0, 0);
   856 					ShowDropDownMenu(w, message_opt, WP(w, def_d).data_1, WIDGET_NEWSOPT_DROP_SUMMARY, 0, 0);
   858 					break;
   857 					break;
   859 
   858 
   860 				case WIDGET_NEWSOPT_SOUNDTICKER: // Change ticker sound on/off
   859 				case WIDGET_NEWSOPT_SOUNDTICKER: // Change ticker sound on/off
   861 					_news_ticker_sound ^= 1;
   860 					_news_ticker_sound ^= 1;
   862 					ToggleWidgetLoweredState(w, e->we.click.widget);
   861 					w->ToggleWidgetLoweredState(e->we.click.widget);
   863 					InvalidateWidget(w, e->we.click.widget);
   862 					w->InvalidateWidget(e->we.click.widget);
   864 					break;
   863 					break;
   865 
   864 
   866 				default: { // Clicked on the [<] .. [>] widgets
   865 				default: { // Clicked on the [<] .. [>] widgets
   867 					int wid = e->we.click.widget - WIDGET_NEWSOPT_START_OPTION;
   866 					int wid = e->we.click.widget - WIDGET_NEWSOPT_START_OPTION;
   868 					if (wid >= 0 && wid < (NB_WIDG_PER_SETTING * NT_END)) {
   867 					if (wid >= 0 && wid < (NB_WIDG_PER_SETTING * NT_END)) {