src/misc_gui.cpp
branchgamebalance
changeset 9895 7bd07f43b0e3
parent 6540 4db000b2cc41
child 9896 2473804114de
equal deleted inserted replaced
9894:70d78ac95d6c 9895:7bd07f43b0e3
   189 	DEBUG(misc, LANDINFOD_LEVEL, "m5           = %#x", _m[tile].m5);
   189 	DEBUG(misc, LANDINFOD_LEVEL, "m5           = %#x", _m[tile].m5);
   190 	DEBUG(misc, LANDINFOD_LEVEL, "m6           = %#x", _m[tile].m6);
   190 	DEBUG(misc, LANDINFOD_LEVEL, "m6           = %#x", _m[tile].m6);
   191 #undef LANDINFOD_LEVEL
   191 #undef LANDINFOD_LEVEL
   192 }
   192 }
   193 
   193 
   194 void PlaceLandBlockInfo(void)
   194 void PlaceLandBlockInfo()
   195 {
   195 {
   196 	if (_cursor.sprite == SPR_CURSOR_QUERY) {
   196 	if (_cursor.sprite == SPR_CURSOR_QUERY) {
   197 		ResetObjectToPlace();
   197 		ResetObjectToPlace();
   198 	} else {
   198 	} else {
   199 		_place_proc = Place_LandInfo;
   199 		_place_proc = Place_LandInfo;
   213 	"  Matthijs Kooijman (blathijs) - Pathfinder-guru",
   213 	"  Matthijs Kooijman (blathijs) - Pathfinder-guru",
   214 	"  Victor Fischer (Celestar) - Programming everywhere you need him to",
   214 	"  Victor Fischer (Celestar) - Programming everywhere you need him to",
   215 	"  Tamás Faragó (Darkvater) - Lead coder",
   215 	"  Tamás Faragó (Darkvater) - Lead coder",
   216 	"  Loïc Guilloux (glx) - In training, not yet specialized",
   216 	"  Loïc Guilloux (glx) - In training, not yet specialized",
   217 	"  Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)",
   217 	"  Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)",
       
   218 	"  Jonathan Coome (Maedhros) - High priest of the newGRF Temple",
   218 	"  Attila Bán (MiHaMiX) - WebTranslator, Nightlies, Wiki and bugtracker host",
   219 	"  Attila Bán (MiHaMiX) - WebTranslator, Nightlies, Wiki and bugtracker host",
   219 	"  Peter Nelson (peter1138) - Spiritual descendant from newgrf gods",
   220 	"  Peter Nelson (peter1138) - Spiritual descendant from newgrf gods",
   220 	"  Remko Bijker (Rubidium) - THE desync hunter",
   221 	"  Remko Bijker (Rubidium) - THE desync hunter",
   221 	"  Christoph Mallon (Tron) - Programmer, code correctness police",
   222 	"  Christoph Mallon (Tron) - Programmer, code correctness police",
   222 	"  Patric Stout (TrueLight) - Coder, network guru, SVN- and website host",
   223 	"  Patric Stout (TrueLight) - Coder, network guru, SVN- and website host",
   302 	_about_widgets,
   303 	_about_widgets,
   303 	AboutWindowProc
   304 	AboutWindowProc
   304 };
   305 };
   305 
   306 
   306 
   307 
   307 void ShowAboutWindow(void)
   308 void ShowAboutWindow()
   308 {
   309 {
   309 	DeleteWindowById(WC_GAME_OPTIONS, 0);
   310 	DeleteWindowById(WC_GAME_OPTIONS, 0);
   310 	AllocateWindowDesc(&_about_desc);
   311 	AllocateWindowDesc(&_about_desc);
   311 }
   312 }
   312 
   313 
   463 	_build_trees_scen_widgets,
   464 	_build_trees_scen_widgets,
   464 	BuildTreesWndProc
   465 	BuildTreesWndProc
   465 };
   466 };
   466 
   467 
   467 
   468 
   468 void ShowBuildTreesToolbar(void)
   469 void ShowBuildTreesToolbar()
   469 {
   470 {
   470 	if (!IsValidPlayer(_current_player)) return;
   471 	if (!IsValidPlayer(_current_player)) return;
   471 	AllocateWindowDescFront(&_build_trees_desc, 0);
   472 	AllocateWindowDescFront(&_build_trees_desc, 0);
   472 }
   473 }
   473 
   474 
   474 void ShowBuildTreesScenToolbar(void)
   475 void ShowBuildTreesScenToolbar()
   475 {
   476 {
   476 	AllocateWindowDescFront(&_build_trees_scen_desc, 0);
   477 	AllocateWindowDescFront(&_build_trees_scen_desc, 0);
   477 }
   478 }
   478 
   479 
   479 static uint32 _errmsg_decode_params[20];
   480 static uint32 _errmsg_decode_params[20];
  1188 	QUERY_WIDGET_NO = 3,
  1189 	QUERY_WIDGET_NO = 3,
  1189 	QUERY_WIDGET_YES
  1190 	QUERY_WIDGET_YES
  1190 };
  1191 };
  1191 
  1192 
  1192 
  1193 
  1193 typedef struct query_d {
  1194 struct query_d {
  1194 	void (*proc)(Window*, bool); ///< callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' clicked, false otherwise
  1195 	void (*proc)(Window*, bool); ///< callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' clicked, false otherwise
  1195 	StringID message;            ///< message shown for query window
  1196 	StringID message;            ///< message shown for query window
  1196 	uint32 params[20];           ///< local copy of _decode_parameters
  1197 	uint32 params[20];           ///< local copy of _decode_parameters
  1197 	bool calledback;             ///< has callback been executed already (internal usage for WE_DESTROY event)
  1198 	bool calledback;             ///< has callback been executed already (internal usage for WE_DESTROY event)
  1198 } query_d;
  1199 };
  1199 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(query_d));
  1200 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(query_d));
  1200 
  1201 
  1201 
  1202 
  1202 static void QueryWndProc(Window *w, WindowEvent *e)
  1203 static void QueryWndProc(Window *w, WindowEvent *e)
  1203 {
  1204 {
  1327 };
  1328 };
  1328 
  1329 
  1329 /* Colors for fios types */
  1330 /* Colors for fios types */
  1330 const byte _fios_colors[] = {13, 9, 9, 6, 5, 6, 5, 6, 6, 8};
  1331 const byte _fios_colors[] = {13, 9, 9, 6, 5, 6, 5, 6, 6, 8};
  1331 
  1332 
  1332 void BuildFileList(void)
  1333 void BuildFileList()
  1333 {
  1334 {
  1334 	_fios_path_changed = true;
  1335 	_fios_path_changed = true;
  1335 	FiosFreeSavegameList();
  1336 	FiosFreeSavegameList();
  1336 
  1337 
  1337 	switch (_saveload_mode) {
  1338 	switch (_saveload_mode) {
  1360 	if (str != STR_4006_UNABLE_TO_READ_DRIVE) SetDParam(0, tot);
  1361 	if (str != STR_4006_UNABLE_TO_READ_DRIVE) SetDParam(0, tot);
  1361 	DrawString(2, 37, str, 0);
  1362 	DrawString(2, 37, str, 0);
  1362 	DoDrawStringTruncated(path, 2, 27, 16, maxw);
  1363 	DoDrawStringTruncated(path, 2, 27, 16, maxw);
  1363 }
  1364 }
  1364 
  1365 
  1365 static void MakeSortedSaveGameList(void)
  1366 static void MakeSortedSaveGameList()
  1366 {
  1367 {
  1367 	uint sort_start = 0;
  1368 	uint sort_start = 0;
  1368 	uint sort_end = 0;
  1369 	uint sort_end = 0;
  1369 	uint s_amount;
  1370 	uint s_amount;
  1370 	int i;
  1371 	int i;
  1384 	s_amount = _fios_num - sort_start - sort_end;
  1385 	s_amount = _fios_num - sort_start - sort_end;
  1385 	if (s_amount > 0)
  1386 	if (s_amount > 0)
  1386 		qsort(_fios_list + sort_start, s_amount, sizeof(FiosItem), compare_FiosItems);
  1387 		qsort(_fios_list + sort_start, s_amount, sizeof(FiosItem), compare_FiosItems);
  1387 }
  1388 }
  1388 
  1389 
  1389 static void GenerateFileName(void)
  1390 static void GenerateFileName()
  1390 {
  1391 {
  1391 	/* Check if we are not a specatator who wants to generate a name..
  1392 	/* Check if we are not a specatator who wants to generate a name..
  1392 	    Let's use the name of player #0 for now. */
  1393 	    Let's use the name of player #0 for now. */
  1393 	const Player *p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST);
  1394 	const Player *p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST);
  1394 
  1395 
  1396 	SetDParam(1, p->name_2);
  1397 	SetDParam(1, p->name_2);
  1397 	SetDParam(2, _date);
  1398 	SetDParam(2, _date);
  1398 	GetString(_edit_str_buf, STR_4004, lastof(_edit_str_buf));
  1399 	GetString(_edit_str_buf, STR_4004, lastof(_edit_str_buf));
  1399 }
  1400 }
  1400 
  1401 
  1401 extern void StartupEngines(void);
  1402 extern void StartupEngines();
  1402 
  1403 
  1403 static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
  1404 static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
  1404 {
  1405 {
  1405 	static FiosItem o_dir;
  1406 	static FiosItem o_dir;
  1406 
  1407 
  1660 	BuildFileList();
  1661 	BuildFileList();
  1661 
  1662 
  1662 	ResetObjectToPlace();
  1663 	ResetObjectToPlace();
  1663 }
  1664 }
  1664 
  1665 
  1665 void RedrawAutosave(void)
  1666 void RedrawAutosave()
  1666 {
  1667 {
  1667 	SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0));
  1668 	SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0));
  1668 }
  1669 }
  1669 
  1670 
  1670 void SetFiosType(const byte fiostype)
  1671 void SetFiosType(const byte fiostype)
  1731 	_opt.landscape = p1;
  1732 	_opt.landscape = p1;
  1732 	ReloadNewGRFData();
  1733 	ReloadNewGRFData();
  1733 	return _opt.landscape;
  1734 	return _opt.landscape;
  1734 }
  1735 }
  1735 
  1736 
  1736 extern void EnginesMonthlyLoop(void);
  1737 extern void EnginesMonthlyLoop();
  1737 
  1738 
  1738 /**
  1739 /**
  1739  * @param p2 1 (increase) or -1 (decrease)
  1740  * @param p2 1 (increase) or -1 (decrease)
  1740  */
  1741  */
  1741 static int32 ClickChangeDateCheat(int32 p1, int32 p2)
  1742 static int32 ClickChangeDateCheat(int32 p1, int32 p2)
  1763 /** Define basic enum properties */
  1764 /** Define basic enum properties */
  1764 template <> struct EnumPropsT<ce_flags_long> : MakeEnumPropsT<ce_flags_long, byte, CE_NONE, CE_END, CE_END> {};
  1765 template <> struct EnumPropsT<ce_flags_long> : MakeEnumPropsT<ce_flags_long, byte, CE_NONE, CE_END, CE_END> {};
  1765 typedef TinyEnumT<ce_flags_long> ce_flags;
  1766 typedef TinyEnumT<ce_flags_long> ce_flags;
  1766 
  1767 
  1767 
  1768 
  1768 typedef struct CheatEntry {
  1769 struct CheatEntry {
  1769 	VarType type;          ///< type of selector
  1770 	VarType type;          ///< type of selector
  1770 	ce_flags flags;        ///< selector flags
  1771 	ce_flags flags;        ///< selector flags
  1771 	StringID str;          ///< string with descriptive text
  1772 	StringID str;          ///< string with descriptive text
  1772 	void *variable;        ///< pointer to the variable
  1773 	void *variable;        ///< pointer to the variable
  1773 	bool *been_used;       ///< has this cheat been used before?
  1774 	bool *been_used;       ///< has this cheat been used before?
  1774 	CheckButtonClick *proc;///< procedure
  1775 	CheckButtonClick *proc;///< procedure
  1775 	int16 min, max;        ///< range for spinbox setting
  1776 	int16 min, max;        ///< range for spinbox setting
  1776 } CheatEntry;
  1777 };
  1777 
  1778 
  1778 static const CheatEntry _cheats_ui[] = {
  1779 static const CheatEntry _cheats_ui[] = {
  1779 	{SLE_BOOL, {CE_CLICK}, STR_CHEAT_MONEY,          &_cheats.money.value,           &_cheats.money.been_used,           &ClickMoneyCheat,         0,  0},
  1780 	{SLE_BOOL, {CE_CLICK}, STR_CHEAT_MONEY,          &_cheats.money.value,           &_cheats.money.been_used,           &ClickMoneyCheat,         0,  0},
  1780 	{SLE_UINT8, {CE_NONE}, STR_CHEAT_CHANGE_PLAYER,  &_local_player,                 &_cheats.switch_player.been_used,   &ClickChangePlayerCheat,  0, 11},
  1781 	{SLE_UINT8, {CE_NONE}, STR_CHEAT_CHANGE_PLAYER,  &_local_player,                 &_cheats.switch_player.been_used,   &ClickChangePlayerCheat,  0, 11},
  1781 	{SLE_BOOL,  {CE_NONE}, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, NULL,                     0,  0},
  1782 	{SLE_BOOL,  {CE_NONE}, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, NULL,                     0,  0},
  1926 	_cheat_widgets,
  1927 	_cheat_widgets,
  1927 	CheatsWndProc
  1928 	CheatsWndProc
  1928 };
  1929 };
  1929 
  1930 
  1930 
  1931 
  1931 void ShowCheatWindow(void)
  1932 void ShowCheatWindow()
  1932 {
  1933 {
  1933 	DeleteWindowById(WC_CHEATS, 0);
  1934 	DeleteWindowById(WC_CHEATS, 0);
  1934 	AllocateWindowDesc(&_cheats_desc);
  1935 	AllocateWindowDesc(&_cheats_desc);
  1935 }
  1936 }