main_gui.c
changeset 4536 f13408cba18f
parent 4512 7151d4ee3a0f
child 4548 23b56455df33
equal deleted inserted replaced
4535:17934c877430 4536:f13408cba18f
  1022 
  1022 
  1023 	assert(w != 0);
  1023 	assert(w != 0);
  1024 
  1024 
  1025 	vp = w->viewport;
  1025 	vp = w->viewport;
  1026 
  1026 
  1027 	if (_game_mode != GM_MENU && !IsGeneratingWorld()) {
  1027 	if (_game_mode != GM_MENU) {
  1028 		if ((in && vp->zoom == 0) || (!in && vp->zoom == 2))
  1028 		if ((in && vp->zoom == 0) || (!in && vp->zoom == 2))
  1029 			return;
  1029 			return;
  1030 
  1030 
  1031 		pt = GetTileZoomCenterWindow(in,w);
  1031 		pt = GetTileZoomCenterWindow(in,w);
  1032 		if (pt.x != -1) {
  1032 		if (pt.x != -1) {
  1774 			_toolbar_button_procs[e->click.widget](w);
  1774 			_toolbar_button_procs[e->click.widget](w);
  1775 	} break;
  1775 	} break;
  1776 
  1776 
  1777 	case WE_KEYPRESS: {
  1777 	case WE_KEYPRESS: {
  1778 		PlayerID local = (_local_player != OWNER_SPECTATOR) ? _local_player : 0;
  1778 		PlayerID local = (_local_player != OWNER_SPECTATOR) ? _local_player : 0;
  1779 
       
  1780 		if (IsGeneratingWorld()) break;
       
  1781 
  1779 
  1782 		switch (e->keypress.keycode) {
  1780 		switch (e->keypress.keycode) {
  1783 		case WKC_F1: case WKC_PAUSE:
  1781 		case WKC_F1: case WKC_PAUSE:
  1784 			ToolbarPauseClick(w);
  1782 			ToolbarPauseClick(w);
  1785 			break;
  1783 			break;
  2104 		SetDParam(0, _date);
  2102 		SetDParam(0, _date);
  2105 		DrawStringCentered(
  2103 		DrawStringCentered(
  2106 			70, 1, (_pause || _patches.status_long_date) ? STR_00AF : STR_00AE, 0
  2104 			70, 1, (_pause || _patches.status_long_date) ? STR_00AF : STR_00AE, 0
  2107 		);
  2105 		);
  2108 
  2106 
  2109 		if (p != NULL && !IsGeneratingWorld()) {
  2107 		if (p != NULL) {
  2110 			// Draw player money
  2108 			// Draw player money
  2111 			SetDParam64(0, p->money64);
  2109 			SetDParam64(0, p->money64);
  2112 			DrawStringCentered(570, 1, p->player_money >= 0 ? STR_0004 : STR_0005, 0);
  2110 			DrawStringCentered(570, 1, p->player_money >= 0 ? STR_0004 : STR_0005, 0);
  2113 		}
  2111 		}
  2114 
  2112 
  2122 		} else if (WP(w,def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) {
  2120 		} else if (WP(w,def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) {
  2123 			// Draw the scrolling news text
  2121 			// Draw the scrolling news text
  2124 			if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w,def_d).data_1))
  2122 			if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w,def_d).data_1))
  2125 				WP(w,def_d).data_1 = -1280;
  2123 				WP(w,def_d).data_1 = -1280;
  2126 		} else {
  2124 		} else {
  2127 			if (p != NULL && !IsGeneratingWorld()) {
  2125 			if (p != NULL) {
  2128 				// This is the default text
  2126 				// This is the default text
  2129 				SetDParam(0, p->name_1);
  2127 				SetDParam(0, p->name_1);
  2130 				SetDParam(1, p->name_2);
  2128 				SetDParam(1, p->name_2);
  2131 				DrawStringCentered(320, 1, STR_02BA, 0);
  2129 				DrawStringCentered(320, 1, STR_02BA, 0);
  2132 			}
  2130 			}
  2223 			*/
  2221 			*/
  2224 		}
  2222 		}
  2225 		break;
  2223 		break;
  2226 
  2224 
  2227 	case WE_KEYPRESS:
  2225 	case WE_KEYPRESS:
  2228 		if (e->keypress.keycode == WKC_BACKQUOTE) {
       
  2229 			if (!IsGeneratingWorld()) IConsoleSwitch();
       
  2230 			e->keypress.cont = false;
       
  2231 			break;
       
  2232 		}
       
  2233 
       
  2234 		switch (e->keypress.keycode) {
  2226 		switch (e->keypress.keycode) {
  2235 			case 'Q' | WKC_CTRL:
  2227 			case 'Q' | WKC_CTRL:
  2236 			case 'Q' | WKC_META:
  2228 			case 'Q' | WKC_META:
  2237 				AskExitGame();
  2229 				AskExitGame();
  2238 				break;
  2230 				break;
  2239 		}
  2231 		}
  2240 
  2232 
  2241 		if (_game_mode == GM_MENU || IsGeneratingWorld()) break;
  2233 		/* Disable all key shortcuts, except quit shortcuts when
       
  2234 		 * generating the world, otherwise they create threading
       
  2235 		 * problem during the generating, resulting in random
       
  2236 		 * assertions that are hard to trigger and debug */
       
  2237 		if (IsGeneratingWorld()) break;
       
  2238 
       
  2239 		if (e->keypress.keycode == WKC_BACKQUOTE) {
       
  2240 			IConsoleSwitch();
       
  2241 			e->keypress.cont = false;
       
  2242 			break;
       
  2243 		}
       
  2244 
       
  2245 		if (_game_mode == GM_MENU) break;
  2242 
  2246 
  2243 		switch (e->keypress.keycode) {
  2247 		switch (e->keypress.keycode) {
  2244 			case 'C':
  2248 			case 'C':
  2245 			case 'Z': {
  2249 			case 'Z': {
  2246 				Point pt = GetTileBelowCursor();
  2250 				Point pt = GetTileBelowCursor();
  2361 {
  2365 {
  2362 	Window *w;
  2366 	Window *w;
  2363 
  2367 
  2364 	if (_game_mode != GM_EDITOR) {
  2368 	if (_game_mode != GM_EDITOR) {
  2365 		w = AllocateWindowDesc(&_toolb_normal_desc);
  2369 		w = AllocateWindowDesc(&_toolb_normal_desc);
  2366 		/* Disable zoom-in for normal things, and zoom-out if we come
  2370 		w->disabled_state = 1 << 18;
  2367 		 *  from world-generating. */
       
  2368 		w->disabled_state = IsGeneratingWorld() ? (1 << 18) : (1 << 17);
       
  2369 	} else {
  2371 	} else {
  2370 		w = AllocateWindowDesc(&_toolb_scen_desc);
  2372 		w = AllocateWindowDesc(&_toolb_scen_desc);
  2371 		/* Disable zoom-in for normal things, and zoom-out if we come
  2373 		w->disabled_state = 1 << 10;
  2372 		 *  from world-generating. */
       
  2373 		w->disabled_state = IsGeneratingWorld() ? (1 << 10) : (1 << 9);
       
  2374 	}
  2374 	}
  2375 	CLRBITS(w->flags4, WF_WHITE_BORDER_MASK);
  2375 	CLRBITS(w->flags4, WF_WHITE_BORDER_MASK);
  2376 
  2376 
  2377 	if (_networking) {
  2377 	if (_networking) {
  2378 		/* If networking, disable fast-forward button */
  2378 		/* If networking, disable fast-forward button */