2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file misc_gui.cpp GUIs for a number of misc windows. */
|
2007-03-03 04:04:22 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
2005-06-02 19:30:21 +00:00
|
|
|
#include "openttd.h"
|
2005-02-05 15:58:59 +00:00
|
|
|
#include "debug.h"
|
2007-04-12 13:07:15 +00:00
|
|
|
#include "landscape.h"
|
2007-10-17 20:09:16 +00:00
|
|
|
#include "newgrf_text.h"
|
2009-01-04 15:32:25 +00:00
|
|
|
#include "saveload/saveload.h"
|
2007-12-19 23:26:02 +00:00
|
|
|
#include "tile_map.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "gui.h"
|
2007-12-19 20:45:46 +00:00
|
|
|
#include "station_gui.h"
|
2008-01-09 09:45:45 +00:00
|
|
|
#include "viewport_func.h"
|
|
|
|
#include "gfx_func.h"
|
2008-03-31 00:06:17 +00:00
|
|
|
#include "station_func.h"
|
2007-12-21 21:50:46 +00:00
|
|
|
#include "command_func.h"
|
2008-09-30 20:51:04 +00:00
|
|
|
#include "company_func.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "town.h"
|
2007-01-02 17:34:03 +00:00
|
|
|
#include "network/network.h"
|
2009-03-13 21:32:38 +00:00
|
|
|
#include "network/network_content.h"
|
2005-07-21 22:15:02 +00:00
|
|
|
#include "variables.h"
|
2009-01-31 20:16:06 +00:00
|
|
|
#include "company_base.h"
|
|
|
|
#include "texteff.hpp"
|
2007-02-20 22:09:21 +00:00
|
|
|
#include "cargotype.h"
|
2008-09-30 20:51:04 +00:00
|
|
|
#include "company_manager_face.h"
|
2007-12-21 19:49:27 +00:00
|
|
|
#include "strings_func.h"
|
2008-08-31 10:50:05 +00:00
|
|
|
#include "fileio_func.h"
|
2006-08-05 00:59:45 +00:00
|
|
|
#include "fios.h"
|
2007-12-23 10:56:02 +00:00
|
|
|
#include "zoom_func.h"
|
2007-12-25 11:26:07 +00:00
|
|
|
#include "window_func.h"
|
2008-01-07 14:23:25 +00:00
|
|
|
#include "string_func.h"
|
2008-03-31 06:42:26 +00:00
|
|
|
#include "newgrf_cargo.h"
|
2008-05-07 13:10:15 +00:00
|
|
|
#include "tilehighlight_func.h"
|
2008-05-11 12:26:20 +00:00
|
|
|
#include "querystring_gui.h"
|
2007-12-21 22:50:51 +00:00
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/strings.h"
|
|
|
|
|
2006-08-05 00:59:45 +00:00
|
|
|
/* Variables to display file lists */
|
2007-12-27 17:29:27 +00:00
|
|
|
SaveLoadDialogMode _saveload_mode;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
|
2005-03-28 13:30:51 +00:00
|
|
|
static bool _fios_path_changed;
|
2005-03-28 08:48:41 +00:00
|
|
|
static bool _savegame_sort_dirty;
|
2009-02-25 21:45:14 +00:00
|
|
|
int _caret_timer;
|
2005-03-28 08:48:41 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
static const Widget _land_info_widgets[] = {
|
2008-07-31 02:59:21 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
2008-08-02 22:48:43 +00:00
|
|
|
{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 299, 0, 13, STR_01A3_LAND_AREA_INFORMATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
|
{ WWT_PANEL, RESIZE_BOTTOM, COLOUR_GREY, 0, 299, 14, 99, 0x0, STR_NULL},
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _land_info_desc = {
|
2008-08-02 22:48:43 +00:00
|
|
|
WDP_AUTO, WDP_AUTO, 300, 100, 300, 100,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_LAND_INFO, WC_NONE,
|
2004-08-09 17:04:08 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
|
|
|
_land_info_widgets,
|
|
|
|
};
|
|
|
|
|
2008-05-08 19:26:55 +00:00
|
|
|
class LandInfoWindow : public Window {
|
|
|
|
enum {
|
2008-07-25 22:37:34 +00:00
|
|
|
LAND_INFO_CENTERED_LINES = 12, ///< Up to 12 centered lines
|
2008-05-21 22:15:39 +00:00
|
|
|
LAND_INFO_MULTICENTER_LINE = LAND_INFO_CENTERED_LINES, ///< One multicenter line
|
|
|
|
LAND_INFO_LINE_END,
|
|
|
|
|
2008-05-08 19:26:55 +00:00
|
|
|
LAND_INFO_LINE_BUFF_SIZE = 512,
|
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-08 19:26:55 +00:00
|
|
|
public:
|
2008-05-21 22:15:39 +00:00
|
|
|
char landinfo_data[LAND_INFO_LINE_END][LAND_INFO_LINE_BUFF_SIZE];
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-10 19:59:41 +00:00
|
|
|
virtual void OnPaint()
|
2008-05-08 19:26:55 +00:00
|
|
|
{
|
2008-05-17 12:48:06 +00:00
|
|
|
this->DrawWidgets();
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2008-06-21 18:59:15 +00:00
|
|
|
uint y = 21;
|
2008-05-21 22:15:39 +00:00
|
|
|
for (uint i = 0; i < LAND_INFO_CENTERED_LINES; i++) {
|
2008-06-21 18:59:15 +00:00
|
|
|
if (StrEmpty(this->landinfo_data[i])) break;
|
2008-05-21 22:15:39 +00:00
|
|
|
|
2008-08-02 22:48:43 +00:00
|
|
|
DoDrawStringCentered(150, y, this->landinfo_data[i], i == 0 ? TC_LIGHT_BLUE : TC_FROMSTRING);
|
2008-06-21 18:59:15 +00:00
|
|
|
y += i == 0 ? 16 : 12;
|
2008-05-21 22:15:39 +00:00
|
|
|
}
|
|
|
|
|
2008-06-21 18:59:15 +00:00
|
|
|
y += 6;
|
2008-05-21 22:15:39 +00:00
|
|
|
|
2008-07-17 13:47:04 +00:00
|
|
|
if (!StrEmpty(this->landinfo_data[LAND_INFO_MULTICENTER_LINE])) {
|
|
|
|
SetDParamStr(0, this->landinfo_data[LAND_INFO_MULTICENTER_LINE]);
|
2008-08-02 22:48:43 +00:00
|
|
|
DrawStringMultiCenter(150, y, STR_JUST_RAW_STRING, this->width - 4);
|
2008-07-17 13:47:04 +00:00
|
|
|
}
|
2008-05-08 19:26:55 +00:00
|
|
|
}
|
2008-04-04 17:27:38 +00:00
|
|
|
|
2008-05-08 19:26:55 +00:00
|
|
|
LandInfoWindow(TileIndex tile) : Window(&_land_info_desc) {
|
2008-09-30 20:39:50 +00:00
|
|
|
Company *c = GetCompany(IsValidCompanyID(_local_company) ? _local_company : COMPANY_FIRST);
|
2008-05-29 15:13:28 +00:00
|
|
|
Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
|
2007-01-10 16:31:40 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
Money old_money = c->money;
|
|
|
|
c->money = INT64_MAX;
|
2009-02-09 21:20:05 +00:00
|
|
|
CommandCost costclear = DoCommand(tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR);
|
2008-09-30 20:39:50 +00:00
|
|
|
c->money = old_money;
|
2007-01-10 16:31:40 +00:00
|
|
|
|
2008-05-08 19:26:55 +00:00
|
|
|
/* Because build_date is not set yet in every TileDesc, we make sure it is empty */
|
|
|
|
TileDesc td;
|
|
|
|
AcceptedCargo ac;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2008-07-25 19:50:40 +00:00
|
|
|
td.build_date = INVALID_DATE;
|
2008-05-21 22:15:39 +00:00
|
|
|
|
|
|
|
/* Most tiles have only one owner, but
|
|
|
|
* - drivethrough roadstops can be build on town owned roads (up to 2 owners) and
|
|
|
|
* - roads can have up to four owners (railroad, road, tram, 3rd-roadtype "highway").
|
|
|
|
*/
|
|
|
|
td.owner_type[0] = STR_01A7_OWNER; // At least one owner is displayed, though it might be "N/A".
|
|
|
|
td.owner_type[1] = STR_NULL; // STR_NULL results in skipping the owner
|
|
|
|
td.owner_type[2] = STR_NULL;
|
|
|
|
td.owner_type[3] = STR_NULL;
|
|
|
|
td.owner[0] = OWNER_NONE;
|
|
|
|
td.owner[1] = OWNER_NONE;
|
|
|
|
td.owner[2] = OWNER_NONE;
|
|
|
|
td.owner[3] = OWNER_NONE;
|
|
|
|
|
2008-07-25 22:37:34 +00:00
|
|
|
td.station_class = STR_NULL;
|
|
|
|
td.station_name = STR_NULL;
|
|
|
|
|
|
|
|
td.grf = NULL;
|
|
|
|
|
2008-05-08 19:26:55 +00:00
|
|
|
GetAcceptedCargo(tile, ac);
|
|
|
|
GetTileDesc(tile, &td);
|
2007-01-10 16:31:40 +00:00
|
|
|
|
2008-05-21 22:15:39 +00:00
|
|
|
uint line_nr = 0;
|
|
|
|
|
|
|
|
/* Tiletype */
|
2008-05-08 19:26:55 +00:00
|
|
|
SetDParam(0, td.dparam[0]);
|
2008-05-21 22:15:39 +00:00
|
|
|
GetString(this->landinfo_data[line_nr], td.str, lastof(this->landinfo_data[line_nr]));
|
|
|
|
line_nr++;
|
2007-01-10 16:31:40 +00:00
|
|
|
|
2008-05-21 22:15:39 +00:00
|
|
|
/* Up to four owners */
|
|
|
|
for (uint i = 0; i < 4; i++) {
|
|
|
|
if (td.owner_type[i] == STR_NULL) continue;
|
|
|
|
|
|
|
|
SetDParam(0, STR_01A6_N_A);
|
|
|
|
if (td.owner[i] != OWNER_NONE && td.owner[i] != OWNER_WATER) GetNameOfOwner(td.owner[i], tile);
|
|
|
|
GetString(this->landinfo_data[line_nr], td.owner_type[i], lastof(this->landinfo_data[line_nr]));
|
|
|
|
line_nr++;
|
|
|
|
}
|
2008-05-08 19:26:55 +00:00
|
|
|
|
2008-12-26 23:37:53 +00:00
|
|
|
/* Cost to clear/revenue when cleared */
|
2008-05-08 19:26:55 +00:00
|
|
|
StringID str = STR_01A4_COST_TO_CLEAR_N_A;
|
|
|
|
if (CmdSucceeded(costclear)) {
|
2008-12-26 23:37:53 +00:00
|
|
|
Money cost = costclear.GetCost();
|
|
|
|
if (cost < 0) {
|
|
|
|
cost = -cost; // Negate negative cost to a positive revenue
|
|
|
|
str = STR_REVENUE_WHEN_CLEARED;
|
|
|
|
} else {
|
|
|
|
str = STR_01A5_COST_TO_CLEAR;
|
|
|
|
}
|
|
|
|
SetDParam(0, cost);
|
2008-05-08 19:26:55 +00:00
|
|
|
}
|
2008-05-21 22:15:39 +00:00
|
|
|
GetString(this->landinfo_data[line_nr], str, lastof(this->landinfo_data[line_nr]));
|
|
|
|
line_nr++;
|
2008-05-08 19:26:55 +00:00
|
|
|
|
2008-05-21 22:15:39 +00:00
|
|
|
/* Location */
|
2008-07-17 13:47:04 +00:00
|
|
|
char tmp[16];
|
|
|
|
snprintf(tmp, lengthof(tmp), "0x%.4X", tile);
|
2008-05-08 19:26:55 +00:00
|
|
|
SetDParam(0, TileX(tile));
|
|
|
|
SetDParam(1, TileY(tile));
|
|
|
|
SetDParam(2, TileHeight(tile));
|
2008-07-17 13:47:04 +00:00
|
|
|
SetDParamStr(3, tmp);
|
2008-05-21 22:15:39 +00:00
|
|
|
GetString(this->landinfo_data[line_nr], STR_LANDINFO_COORDS, lastof(this->landinfo_data[line_nr]));
|
|
|
|
line_nr++;
|
2008-05-08 19:26:55 +00:00
|
|
|
|
2008-05-21 22:15:39 +00:00
|
|
|
/* Local authority */
|
2008-05-08 19:26:55 +00:00
|
|
|
SetDParam(0, STR_01A9_NONE);
|
|
|
|
if (t != NULL && t->IsValid()) {
|
|
|
|
SetDParam(0, STR_TOWN);
|
|
|
|
SetDParam(1, t->index);
|
|
|
|
}
|
2008-05-21 22:15:39 +00:00
|
|
|
GetString(this->landinfo_data[line_nr], STR_01A8_LOCAL_AUTHORITY, lastof(this->landinfo_data[line_nr]));
|
|
|
|
line_nr++;
|
2008-05-08 19:26:55 +00:00
|
|
|
|
2008-05-21 22:15:39 +00:00
|
|
|
/* Build date */
|
2008-07-25 19:50:40 +00:00
|
|
|
if (td.build_date != INVALID_DATE) {
|
2008-05-21 22:15:39 +00:00
|
|
|
SetDParam(0, td.build_date);
|
|
|
|
GetString(this->landinfo_data[line_nr], STR_BUILD_DATE, lastof(this->landinfo_data[line_nr]));
|
|
|
|
line_nr++;
|
|
|
|
}
|
|
|
|
|
2008-07-25 22:37:34 +00:00
|
|
|
/* Station class */
|
|
|
|
if (td.station_class != STR_NULL) {
|
|
|
|
SetDParam(0, td.station_class);
|
|
|
|
GetString(this->landinfo_data[line_nr], STR_TILEDESC_STATION_CLASS, lastof(this->landinfo_data[line_nr]));
|
|
|
|
line_nr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Station type name */
|
|
|
|
if (td.station_name != STR_NULL) {
|
|
|
|
SetDParam(0, td.station_name);
|
|
|
|
GetString(this->landinfo_data[line_nr], STR_TILEDESC_STATION_TYPE, lastof(this->landinfo_data[line_nr]));
|
|
|
|
line_nr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NewGRF name */
|
|
|
|
if (td.grf != NULL) {
|
|
|
|
SetDParamStr(0, td.grf);
|
|
|
|
GetString(this->landinfo_data[line_nr], STR_TILEDESC_NEWGRF_NAME, lastof(this->landinfo_data[line_nr]));
|
|
|
|
line_nr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(line_nr < LAND_INFO_CENTERED_LINES);
|
|
|
|
|
2008-06-21 18:59:15 +00:00
|
|
|
/* Mark last line empty */
|
|
|
|
this->landinfo_data[line_nr][0] = '\0';
|
2008-05-21 22:15:39 +00:00
|
|
|
|
|
|
|
/* Cargo acceptance is displayed in a extra multiline */
|
|
|
|
char *strp = GetString(this->landinfo_data[LAND_INFO_MULTICENTER_LINE], STR_01CE_CARGO_ACCEPTED, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
|
2008-05-08 19:26:55 +00:00
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
for (CargoID i = 0; i < NUM_CARGO; ++i) {
|
|
|
|
if (ac[i] > 0) {
|
|
|
|
/* Add a comma between each item. */
|
|
|
|
if (found) {
|
|
|
|
*strp++ = ',';
|
|
|
|
*strp++ = ' ';
|
|
|
|
}
|
|
|
|
found = true;
|
|
|
|
|
|
|
|
/* If the accepted value is less than 8, show it in 1/8:ths */
|
|
|
|
if (ac[i] < 8) {
|
|
|
|
SetDParam(0, ac[i]);
|
|
|
|
SetDParam(1, GetCargo(i)->name);
|
2008-05-21 22:15:39 +00:00
|
|
|
strp = GetString(strp, STR_01D1_8, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
|
2008-05-08 19:26:55 +00:00
|
|
|
} else {
|
2008-05-21 22:15:39 +00:00
|
|
|
strp = GetString(strp, GetCargo(i)->name, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
|
2008-05-08 19:26:55 +00:00
|
|
|
}
|
2007-01-10 16:31:40 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-21 22:15:39 +00:00
|
|
|
if (!found) this->landinfo_data[LAND_INFO_MULTICENTER_LINE][0] = '\0';
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2008-06-21 18:59:15 +00:00
|
|
|
if (found) line_nr += 2;
|
|
|
|
|
|
|
|
if (line_nr > 6) ResizeWindow(this, 0, 12 * (line_nr - 6));
|
|
|
|
|
|
|
|
this->FindWindowPlacementAndResize(&_land_info_desc);
|
|
|
|
|
2006-06-10 08:37:41 +00:00
|
|
|
#if defined(_DEBUG)
|
|
|
|
# define LANDINFOD_LEVEL 0
|
|
|
|
#else
|
|
|
|
# define LANDINFOD_LEVEL 1
|
|
|
|
#endif
|
2008-05-08 19:26:55 +00:00
|
|
|
DEBUG(misc, LANDINFOD_LEVEL, "TILE: %#x (%i,%i)", tile, TileX(tile), TileY(tile));
|
|
|
|
DEBUG(misc, LANDINFOD_LEVEL, "type_height = %#x", _m[tile].type_height);
|
|
|
|
DEBUG(misc, LANDINFOD_LEVEL, "m1 = %#x", _m[tile].m1);
|
|
|
|
DEBUG(misc, LANDINFOD_LEVEL, "m2 = %#x", _m[tile].m2);
|
|
|
|
DEBUG(misc, LANDINFOD_LEVEL, "m3 = %#x", _m[tile].m3);
|
|
|
|
DEBUG(misc, LANDINFOD_LEVEL, "m4 = %#x", _m[tile].m4);
|
|
|
|
DEBUG(misc, LANDINFOD_LEVEL, "m5 = %#x", _m[tile].m5);
|
|
|
|
DEBUG(misc, LANDINFOD_LEVEL, "m6 = %#x", _m[tile].m6);
|
|
|
|
DEBUG(misc, LANDINFOD_LEVEL, "m7 = %#x", _me[tile].m7);
|
2006-06-10 08:37:41 +00:00
|
|
|
#undef LANDINFOD_LEVEL
|
2008-05-08 19:26:55 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void Place_LandInfo(TileIndex tile)
|
|
|
|
{
|
|
|
|
DeleteWindowById(WC_LAND_INFO, 0);
|
|
|
|
new LandInfoWindow(tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void PlaceLandBlockInfo()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-06-06 13:47:06 +00:00
|
|
|
if (_cursor.sprite == SPR_CURSOR_QUERY) {
|
2004-08-09 17:04:08 +00:00
|
|
|
ResetObjectToPlace();
|
|
|
|
} else {
|
|
|
|
_place_proc = Place_LandInfo;
|
2007-11-15 18:28:00 +00:00
|
|
|
SetObjectToPlace(SPR_CURSOR_QUERY, PAL_NONE, VHM_RECT, WC_MAIN_TOOLBAR, 0);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const Widget _about_widgets[] = {
|
2008-07-31 02:59:21 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 419, 0, 13, STR_015B_OPENTTD, STR_NULL},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 419, 14, 271, 0x0, STR_NULL},
|
|
|
|
{ WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 5, 414, 40, 245, STR_NULL, STR_NULL},
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _about_desc = {
|
2007-07-27 12:49:04 +00:00
|
|
|
WDP_CENTER, WDP_CENTER, 420, 272, 420, 272,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_GAME_OPTIONS, WC_NONE,
|
2004-08-09 17:04:08 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
|
|
|
_about_widgets,
|
|
|
|
};
|
|
|
|
|
2008-05-14 20:01:06 +00:00
|
|
|
struct AboutWindow : public Window {
|
|
|
|
int scroll_height;
|
|
|
|
uint16 counter;
|
|
|
|
|
|
|
|
AboutWindow() : Window(&_about_desc)
|
|
|
|
{
|
|
|
|
this->counter = 5;
|
|
|
|
this->scroll_height = this->height - 40;
|
|
|
|
this->FindWindowPlacementAndResize(&_about_desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
|
|
|
static const char *credits[] = {
|
|
|
|
/*************************************************************************
|
|
|
|
* maximum length of string which fits in window -^*/
|
|
|
|
"Original design by Chris Sawyer",
|
|
|
|
"Original graphics by Simon Foster",
|
|
|
|
"",
|
|
|
|
"The OpenTTD team (in alphabetical order):",
|
|
|
|
" Jean-Francois Claeys (Belugas) - GUI, newindustries and more",
|
|
|
|
" Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles",
|
|
|
|
" Matthijs Kooijman (blathijs) - Pathfinder-guru, pool rework",
|
2008-08-18 17:07:27 +00:00
|
|
|
" Victor Fischer (Celestar) - Programming everywhere you need him to",
|
2008-05-14 20:01:06 +00:00
|
|
|
" Christoph Elsenhans (frosch) - General coding",
|
2009-03-15 00:32:36 +00:00
|
|
|
" Loïc Guilloux (glx) - Windows Expert",
|
|
|
|
" Michael Lutz (michi_cc) - Path based signals",
|
2008-05-14 20:01:06 +00:00
|
|
|
" Owen Rudge (orudge) - Forum host, OS/2 port",
|
|
|
|
" Peter Nelson (peter1138) - Spiritual descendant from newGRF gods",
|
|
|
|
" Remko Bijker (Rubidium) - Lead coder and way more",
|
|
|
|
" Zdenek Sojka (SmatZ) - Bug finder and fixer",
|
2009-03-15 00:32:36 +00:00
|
|
|
" Thijs Marinussen (Yexo) - AI Framework",
|
2008-05-14 20:01:06 +00:00
|
|
|
"",
|
|
|
|
"Inactive Developers:",
|
|
|
|
" Tamás Faragó (Darkvater) - Ex-Lead coder",
|
2009-03-15 00:32:36 +00:00
|
|
|
" Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)",
|
|
|
|
" Jonathan Coome (Maedhros) - High priest of the NewGRF Temple",
|
|
|
|
" Attila Bán (MiHaMiX) - WebTranslator, Nightlies, Wiki and bugtracker host",
|
2008-05-14 20:01:06 +00:00
|
|
|
" Christoph Mallon (Tron) - Programmer, code correctness police",
|
|
|
|
"",
|
|
|
|
"Retired Developers:",
|
|
|
|
" Ludvig Strigeus (ludde) - OpenTTD author, main coder (0.1 - 0.3.3)",
|
|
|
|
" Serge Paquet (vurlix) - Assistant project manager, coder (0.1 - 0.3.3)",
|
|
|
|
" Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3.0 - 0.3.6)",
|
2009-03-15 00:32:36 +00:00
|
|
|
" Benedikt Brüggemeier (skidd13) - Bug fixer and code reworker",
|
|
|
|
" Patric Stout (TrueLight) - Programmer, webhoster (0.3 - pre0.7)",
|
2008-05-14 20:01:06 +00:00
|
|
|
"",
|
|
|
|
"Special thanks go out to:",
|
|
|
|
" Josef Drexler - For his great work on TTDPatch",
|
|
|
|
" Marcin Grzegorczyk - For his documentation of TTD internals",
|
|
|
|
" Petr Baudis (pasky) - Many patches, newGRF support",
|
|
|
|
" Stefan Meißner (sign_de) - For his work on the console",
|
|
|
|
" Simon Sasburg (HackyKid) - Many bugfixes he has blessed us with",
|
|
|
|
" Cian Duffy (MYOB) - BeOS port / manual writing",
|
|
|
|
" Christian Rosentreter (tokai) - MorphOS / AmigaOS port",
|
|
|
|
" Richard Kempton (richK) - additional airports, initial TGP implementation",
|
|
|
|
"",
|
2009-02-25 01:21:50 +00:00
|
|
|
" Alberto Demichelis - Squirrel scripting language © 2003-2008",
|
2008-05-14 20:01:06 +00:00
|
|
|
" Michael Blunck - Pre-Signals and Semaphores © 2003",
|
|
|
|
" George - Canal/Lock graphics © 2003-2004",
|
|
|
|
" David Dallaston - Tram tracks",
|
|
|
|
" Marcin Grzegorczyk - Foundations for Tracks on Slopes",
|
|
|
|
" All Translators - Who made OpenTTD a truly international game",
|
|
|
|
" Bug Reporters - Without whom OpenTTD would still be full of bugs!",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"And last but not least:",
|
|
|
|
" Chris Sawyer - For an amazing game!"
|
|
|
|
};
|
|
|
|
|
2008-05-17 12:48:06 +00:00
|
|
|
this->DrawWidgets();
|
2008-05-14 20:01:06 +00:00
|
|
|
|
|
|
|
/* Show original copyright and revision version */
|
|
|
|
DrawStringCentered(210, 17, STR_00B6_ORIGINAL_COPYRIGHT, TC_FROMSTRING);
|
|
|
|
DrawStringCentered(210, 17 + 10, STR_00B7_VERSION, TC_FROMSTRING);
|
|
|
|
|
|
|
|
int y = this->scroll_height;
|
|
|
|
|
|
|
|
/* Show all scrolling credits */
|
|
|
|
for (uint i = 0; i < lengthof(credits); i++) {
|
|
|
|
if (y >= 50 && y < (this->height - 40)) {
|
|
|
|
DoDrawString(credits[i], 10, y, TC_BLACK);
|
|
|
|
}
|
|
|
|
y += 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the last text has scrolled start a new from the start */
|
|
|
|
if (y < 50) this->scroll_height = this->height - 40;
|
|
|
|
|
|
|
|
DoDrawStringCentered(210, this->height - 25, "Website: http://www.openttd.org", TC_BLACK);
|
|
|
|
DrawStringCentered(210, this->height - 15, STR_00BA_COPYRIGHT_OPENTTD, TC_FROMSTRING);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnTick()
|
|
|
|
{
|
|
|
|
if (--this->counter == 0) {
|
|
|
|
this->counter = 5;
|
|
|
|
this->scroll_height--;
|
|
|
|
this->SetDirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void ShowAboutWindow()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
DeleteWindowById(WC_GAME_OPTIONS, 0);
|
2008-05-14 20:01:06 +00:00
|
|
|
new AboutWindow();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const Widget _errmsg_widgets[] = {
|
2008-07-31 02:59:21 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_RED, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, COLOUR_RED, 11, 239, 0, 13, STR_00B2_MESSAGE, STR_NULL},
|
|
|
|
{ WWT_PANEL, RESIZE_BOTTOM, COLOUR_RED, 0, 239, 14, 45, 0x0, STR_NULL},
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const Widget _errmsg_face_widgets[] = {
|
2008-07-31 02:59:21 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_RED, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, COLOUR_RED, 11, 333, 0, 13, STR_00B3_MESSAGE_FROM, STR_NULL},
|
|
|
|
{ WWT_PANEL, RESIZE_BOTTOM, COLOUR_RED, 0, 333, 14, 136, 0x0, STR_NULL},
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2008-05-17 02:54:04 +00:00
|
|
|
struct ErrmsgWindow : public Window {
|
|
|
|
private:
|
|
|
|
uint duration;
|
|
|
|
uint64 decode_params[20];
|
|
|
|
StringID message_1;
|
|
|
|
StringID message_2;
|
2008-09-30 20:39:50 +00:00
|
|
|
bool show_company_manager_face;
|
2007-10-17 20:09:16 +00:00
|
|
|
|
2008-07-22 19:25:47 +00:00
|
|
|
int y[2];
|
|
|
|
|
2008-05-17 02:54:04 +00:00
|
|
|
public:
|
2008-09-30 20:39:50 +00:00
|
|
|
ErrmsgWindow(Point pt, int width, int height, StringID msg1, StringID msg2, const Widget *widget, bool show_company_manager_face) :
|
2008-05-18 20:40:30 +00:00
|
|
|
Window(pt.x, pt.y, width, height, WC_ERRMSG, widget),
|
2008-09-30 20:39:50 +00:00
|
|
|
show_company_manager_face(show_company_manager_face)
|
2008-05-17 02:54:04 +00:00
|
|
|
{
|
2008-05-29 15:13:28 +00:00
|
|
|
this->duration = _settings_client.gui.errmsg_duration;
|
2008-05-17 02:54:04 +00:00
|
|
|
CopyOutDParam(this->decode_params, 0, lengthof(this->decode_params));
|
|
|
|
this->message_1 = msg1;
|
|
|
|
this->message_2 = msg2;
|
|
|
|
this->desc_flags = WDF_STD_BTN | WDF_DEF_WIDGET;
|
2008-07-22 19:25:47 +00:00
|
|
|
|
|
|
|
SwitchToErrorRefStack();
|
|
|
|
RewindTextRefStack();
|
|
|
|
|
|
|
|
assert(msg2 != INVALID_STRING_ID);
|
|
|
|
|
|
|
|
int h2 = 3 + GetStringHeight(msg2, width - 2); // msg2 is printed first
|
|
|
|
int h1 = (msg1 == INVALID_STRING_ID) ? 0 : 3 + GetStringHeight(msg1, width - 2);
|
|
|
|
|
|
|
|
SwitchToNormalRefStack();
|
|
|
|
|
|
|
|
int h = 15 + h1 + h2;
|
|
|
|
height = max<int>(height, h);
|
|
|
|
|
|
|
|
if (msg1 == INVALID_STRING_ID) {
|
2008-07-23 15:01:50 +00:00
|
|
|
/* only 1 line will be printed */
|
2008-07-22 19:25:47 +00:00
|
|
|
y[1] = (height - 15) / 2 + 15 - 5;
|
|
|
|
} else {
|
|
|
|
int over = (height - h) / 4;
|
|
|
|
|
|
|
|
y[1] = 15 + h2 / 2 + 1 - 5 + over;
|
|
|
|
y[0] = height - 3 - h1 / 2 - 5 - over;
|
|
|
|
}
|
|
|
|
|
2008-05-17 02:54:04 +00:00
|
|
|
this->FindWindowPlacementAndResize(width, height);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-05-17 02:54:04 +00:00
|
|
|
|
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
|
|
|
CopyInDParam(0, this->decode_params, lengthof(this->decode_params));
|
2008-05-17 12:48:06 +00:00
|
|
|
this->DrawWidgets();
|
2008-05-17 02:54:04 +00:00
|
|
|
CopyInDParam(0, this->decode_params, lengthof(this->decode_params));
|
|
|
|
|
|
|
|
/* If the error message comes from a NewGRF, we must use the text ref. stack reserved for error messages.
|
2008-05-17 12:26:00 +00:00
|
|
|
* If the message doesn't come from a NewGRF, it won't use the TTDP-style text ref. stack, so we won't hurt anything
|
|
|
|
*/
|
2008-05-17 02:54:04 +00:00
|
|
|
SwitchToErrorRefStack();
|
|
|
|
RewindTextRefStack();
|
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
if (this->show_company_manager_face) {
|
|
|
|
const Company *c = GetCompany((CompanyID)GetDParamX(this->decode_params, 2));
|
|
|
|
DrawCompanyManagerFace(c->face, c->colour, 2, 16);
|
2008-05-17 02:54:04 +00:00
|
|
|
}
|
|
|
|
|
2008-07-22 19:25:47 +00:00
|
|
|
DrawStringMultiCenter(this->width - 120, y[1], this->message_2, this->width - 2);
|
|
|
|
if (this->message_1 != INVALID_STRING_ID) DrawStringMultiCenter(this->width - 120, y[0], this->message_1, this->width - 2);
|
2008-05-17 02:54:04 +00:00
|
|
|
|
|
|
|
/* Switch back to the normal text ref. stack for NewGRF texts */
|
|
|
|
SwitchToNormalRefStack();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnMouseLoop()
|
|
|
|
{
|
|
|
|
if (_right_button_down) delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnHundredthTick()
|
|
|
|
{
|
|
|
|
if (--this->duration == 0) delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
~ErrmsgWindow()
|
|
|
|
{
|
2009-01-19 15:06:11 +00:00
|
|
|
SetRedErrorSquare(INVALID_TILE);
|
2008-05-17 02:54:04 +00:00
|
|
|
extern StringID _switch_mode_errorstr;
|
|
|
|
_switch_mode_errorstr = INVALID_STRING_ID;
|
|
|
|
}
|
|
|
|
|
2008-05-17 23:11:06 +00:00
|
|
|
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
2008-05-17 02:54:04 +00:00
|
|
|
{
|
2008-05-17 23:11:06 +00:00
|
|
|
if (keycode != WKC_SPACE) return ES_NOT_HANDLED;
|
2008-05-17 02:54:04 +00:00
|
|
|
delete this;
|
2008-05-17 23:11:06 +00:00
|
|
|
return ES_HANDLED;
|
2008-05-17 02:54:04 +00:00
|
|
|
}
|
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y)
|
|
|
|
{
|
|
|
|
DeleteWindowById(WC_ERRMSG, 0);
|
|
|
|
|
2008-05-29 15:13:28 +00:00
|
|
|
if (!_settings_client.gui.errmsg_duration) return;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-17 02:54:04 +00:00
|
|
|
if (msg_2 == STR_NULL) msg_2 = STR_EMPTY;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2008-04-04 17:27:38 +00:00
|
|
|
Point pt;
|
|
|
|
const ViewPort *vp;
|
|
|
|
|
2008-05-17 02:54:04 +00:00
|
|
|
if (msg_1 != STR_013B_OWNED_BY || GetDParam(2) >= 8) {
|
2008-03-26 10:38:31 +00:00
|
|
|
if ((x | y) != 0) {
|
2004-08-09 17:04:08 +00:00
|
|
|
pt = RemapCoords2(x, y);
|
2006-11-18 00:14:43 +00:00
|
|
|
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-03 04:04:22 +00:00
|
|
|
/* move x pos to opposite corner */
|
2007-05-15 16:08:46 +00:00
|
|
|
pt.x = UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left;
|
2004-08-09 17:04:08 +00:00
|
|
|
pt.x = (pt.x < (_screen.width >> 1)) ? _screen.width - 260 : 20;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2007-03-03 04:04:22 +00:00
|
|
|
/* move y pos to opposite corner */
|
2007-05-15 16:08:46 +00:00
|
|
|
pt.y = UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top;
|
2004-08-09 17:04:08 +00:00
|
|
|
pt.y = (pt.y < (_screen.height >> 1)) ? _screen.height - 80 : 100;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
} else {
|
|
|
|
pt.x = (_screen.width - 240) >> 1;
|
|
|
|
pt.y = (_screen.height - 46) >> 1;
|
|
|
|
}
|
2008-05-17 12:26:00 +00:00
|
|
|
new ErrmsgWindow(pt, 240, 46, msg_1, msg_2, _errmsg_widgets, false);
|
2004-08-09 17:04:08 +00:00
|
|
|
} else {
|
2008-03-26 10:38:31 +00:00
|
|
|
if ((x | y) != 0) {
|
2004-08-09 17:04:08 +00:00
|
|
|
pt = RemapCoords2(x, y);
|
2006-11-18 00:14:43 +00:00
|
|
|
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
|
2008-07-23 15:01:50 +00:00
|
|
|
pt.x = Clamp(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (334 / 2), 0, _screen.width - 334);
|
|
|
|
pt.y = Clamp(UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top - (137 / 2), 22, _screen.height - 137);
|
2004-08-09 17:04:08 +00:00
|
|
|
} else {
|
2008-07-23 15:01:50 +00:00
|
|
|
pt.x = (_screen.width - 334) >> 1;
|
2004-08-09 17:04:08 +00:00
|
|
|
pt.y = (_screen.height - 137) >> 1;
|
|
|
|
}
|
2008-05-17 12:26:00 +00:00
|
|
|
new ErrmsgWindow(pt, 334, 137, msg_1, msg_2, _errmsg_face_widgets, true);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-21 14:32:27 +00:00
|
|
|
void ShowEstimatedCostOrIncome(Money cost, int x, int y)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-10-07 07:35:15 +00:00
|
|
|
StringID msg = STR_0805_ESTIMATED_COST;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
if (cost < 0) {
|
|
|
|
cost = -cost;
|
|
|
|
msg = STR_0807_ESTIMATED_INCOME;
|
|
|
|
}
|
2007-06-21 17:25:17 +00:00
|
|
|
SetDParam(0, cost);
|
2005-10-07 07:35:15 +00:00
|
|
|
ShowErrorMessage(INVALID_STRING_ID, msg, x, y);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-06-21 14:32:27 +00:00
|
|
|
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2009-01-09 22:56:28 +00:00
|
|
|
Point pt = RemapCoords(x, y, z);
|
2008-04-04 17:27:38 +00:00
|
|
|
StringID msg = STR_0801_COST;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
if (cost < 0) {
|
|
|
|
cost = -cost;
|
|
|
|
msg = STR_0803_INCOME;
|
|
|
|
}
|
2007-06-21 17:25:17 +00:00
|
|
|
SetDParam(0, cost);
|
2007-06-21 16:17:47 +00:00
|
|
|
AddTextEffect(msg, pt.x, pt.y, 0x250, TE_RISING);
|
2005-06-15 16:58:15 +00:00
|
|
|
}
|
|
|
|
|
2007-06-21 14:32:27 +00:00
|
|
|
void ShowFeederIncomeAnimation(int x, int y, int z, Money cost)
|
2005-06-15 16:58:15 +00:00
|
|
|
{
|
2009-01-09 22:56:28 +00:00
|
|
|
Point pt = RemapCoords(x, y, z);
|
2005-06-15 16:58:15 +00:00
|
|
|
|
2007-06-21 17:25:17 +00:00
|
|
|
SetDParam(0, cost);
|
2007-06-21 16:17:47 +00:00
|
|
|
AddTextEffect(STR_FEEDER, pt.x, pt.y, 0x250, TE_RISING);
|
|
|
|
}
|
|
|
|
|
2007-06-22 18:28:44 +00:00
|
|
|
TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent, StringID string)
|
2007-06-21 16:17:47 +00:00
|
|
|
{
|
|
|
|
Point pt = RemapCoords(x, y, z);
|
|
|
|
|
2007-06-22 18:28:44 +00:00
|
|
|
assert(string != STR_NULL);
|
|
|
|
|
2007-06-21 16:17:47 +00:00
|
|
|
SetDParam(0, percent);
|
2007-06-22 18:28:44 +00:00
|
|
|
return AddTextEffect(string, pt.x, pt.y, 0xFFFF, TE_STATIC);
|
2007-06-21 16:17:47 +00:00
|
|
|
}
|
|
|
|
|
2007-06-22 18:28:44 +00:00
|
|
|
void UpdateFillingPercent(TextEffectID te_id, uint8 percent, StringID string)
|
2007-06-21 16:17:47 +00:00
|
|
|
{
|
2007-06-22 18:28:44 +00:00
|
|
|
assert(string != STR_NULL);
|
|
|
|
|
2007-06-21 16:17:47 +00:00
|
|
|
SetDParam(0, percent);
|
2007-06-22 18:28:44 +00:00
|
|
|
UpdateTextEffect(te_id, string);
|
2007-06-21 16:17:47 +00:00
|
|
|
}
|
|
|
|
|
2008-09-21 18:28:35 +00:00
|
|
|
void HideFillingPercent(TextEffectID *te_id)
|
2007-06-21 16:17:47 +00:00
|
|
|
{
|
2008-09-21 18:28:35 +00:00
|
|
|
if (*te_id == INVALID_TE_ID) return;
|
|
|
|
|
|
|
|
RemoveTextEffect(*te_id);
|
|
|
|
*te_id = INVALID_TE_ID;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-08-03 13:07:29 +00:00
|
|
|
static const Widget _tooltips_widgets[] = {
|
2008-07-31 02:59:21 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 199, 0, 31, 0x0, STR_NULL},
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2008-05-11 17:44:38 +00:00
|
|
|
struct TooltipsWindow : public Window
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2008-05-11 17:44:38 +00:00
|
|
|
StringID string_id;
|
|
|
|
byte paramcount;
|
|
|
|
uint64 params[5];
|
2008-08-02 11:26:25 +00:00
|
|
|
bool use_left_mouse_button;
|
2006-10-12 15:13:40 +00:00
|
|
|
|
2008-05-11 17:44:38 +00:00
|
|
|
TooltipsWindow(int x, int y, int width, int height, const Widget *widget,
|
2008-08-02 11:26:25 +00:00
|
|
|
StringID str, uint paramcount, const uint64 params[], bool use_left_mouse_button) :
|
2008-05-18 20:40:30 +00:00
|
|
|
Window(x, y, width, height, WC_TOOLTIPS, widget)
|
2008-05-11 17:44:38 +00:00
|
|
|
{
|
|
|
|
this->string_id = str;
|
|
|
|
assert(sizeof(this->params[0]) == sizeof(params[0]));
|
2008-09-29 16:27:02 +00:00
|
|
|
assert(paramcount <= lengthof(this->params));
|
2008-05-11 17:44:38 +00:00
|
|
|
memcpy(this->params, params, sizeof(this->params[0]) * paramcount);
|
|
|
|
this->paramcount = paramcount;
|
2008-08-02 11:26:25 +00:00
|
|
|
this->use_left_mouse_button = use_left_mouse_button;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-11 17:44:38 +00:00
|
|
|
this->flags4 &= ~WF_WHITE_BORDER_MASK; // remove white-border from tooltip
|
|
|
|
this->widget[0].right = width;
|
|
|
|
this->widget[0].bottom = height;
|
2006-10-12 15:13:40 +00:00
|
|
|
|
2008-05-11 17:44:38 +00:00
|
|
|
FindWindowPlacementAndResize(width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
|
|
|
GfxFillRect(0, 0, this->width - 1, this->height - 1, 0);
|
|
|
|
GfxFillRect(1, 1, this->width - 2, this->height - 2, 0x44);
|
|
|
|
|
|
|
|
for (uint arg = 0; arg < this->paramcount; arg++) {
|
|
|
|
SetDParam(arg, this->params[arg]);
|
|
|
|
}
|
|
|
|
DrawStringMultiCenter((this->width >> 1), (this->height >> 1) - 5, this->string_id, this->width - 2);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-05-11 17:44:38 +00:00
|
|
|
|
|
|
|
virtual void OnMouseLoop()
|
|
|
|
{
|
|
|
|
/* We can show tooltips while dragging tools. These are shown as long as
|
|
|
|
* we are dragging the tool. Normal tooltips work with rmb */
|
2008-08-02 11:26:25 +00:00
|
|
|
if (this->use_left_mouse_button ? !_left_button_down : !_right_button_down) delete this;
|
2008-05-11 17:44:38 +00:00
|
|
|
}
|
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-10-12 15:13:40 +00:00
|
|
|
/** Shows a tooltip
|
2007-04-17 20:23:13 +00:00
|
|
|
* @param str String to be displayed
|
|
|
|
* @param paramcount number of params to deal with
|
2008-08-02 11:26:25 +00:00
|
|
|
* @param params (optional) up to 5 pieces of additional information that may be added to a tooltip
|
|
|
|
* @param use_left_mouse_button close the tooltip when the left (true) or right (false) mousebutton is released
|
|
|
|
*/
|
|
|
|
void GuiShowTooltips(StringID str, uint paramcount, const uint64 params[], bool use_left_mouse_button)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-10-18 14:20:10 +00:00
|
|
|
DeleteWindowById(WC_TOOLTIPS, 0);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-08-02 11:26:25 +00:00
|
|
|
if (str == STR_NULL) return;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-03-26 10:38:31 +00:00
|
|
|
for (uint i = 0; i != paramcount; i++) SetDParam(i, params[i]);
|
|
|
|
char buffer[512];
|
2006-10-21 23:31:34 +00:00
|
|
|
GetString(buffer, str, lastof(buffer));
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-03-26 10:38:31 +00:00
|
|
|
Dimension br = GetStringBoundingBox(buffer);
|
2006-10-12 15:13:40 +00:00
|
|
|
br.width += 6; br.height += 4; // increase slightly to have some space around the box
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-09-05 23:11:41 +00:00
|
|
|
/* Cut tooltip length to 200 pixels max, wrap to new line if longer */
|
2006-10-12 15:13:40 +00:00
|
|
|
if (br.width > 200) {
|
|
|
|
br.height += ((br.width - 4) / 176) * 10;
|
|
|
|
br.width = 200;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-09-05 23:11:41 +00:00
|
|
|
/* Correctly position the tooltip position, watch out for window and cursor size
|
|
|
|
* Clamp value to below main toolbar and above statusbar. If tooltip would
|
|
|
|
* go below window, flip it so it is shown above the cursor */
|
2008-03-26 10:38:31 +00:00
|
|
|
int y = Clamp(_cursor.pos.y + _cursor.size.y + _cursor.offs.y + 5, 22, _screen.height - 12);
|
2006-10-12 15:13:40 +00:00
|
|
|
if (y + br.height > _screen.height - 12) y = _cursor.pos.y + _cursor.offs.y - br.height - 5;
|
2008-03-26 10:38:31 +00:00
|
|
|
int x = Clamp(_cursor.pos.x - (br.width >> 1), 0, _screen.width - br.width);
|
2006-10-12 15:13:40 +00:00
|
|
|
|
2008-08-02 11:26:25 +00:00
|
|
|
new TooltipsWindow(x, y, br.width, br.height, _tooltips_widgets, str, paramcount, params, use_left_mouse_button);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-06 22:32:20 +00:00
|
|
|
static int DrawStationCoverageText(const AcceptedCargo cargo,
|
|
|
|
int str_x, int str_y, StationCoverageType sct, bool supplies)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-11-06 15:25:02 +00:00
|
|
|
bool first = true;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2008-07-17 13:47:04 +00:00
|
|
|
char string[512];
|
|
|
|
char *b = InlineString(string, supplies ? STR_SUPPLIES : STR_000D_ACCEPTS);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-07-12 13:40:24 +00:00
|
|
|
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
2008-07-17 13:47:04 +00:00
|
|
|
if (b >= lastof(string) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode()
|
2007-07-12 13:40:24 +00:00
|
|
|
switch (sct) {
|
|
|
|
case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break;
|
|
|
|
case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break;
|
|
|
|
case SCT_ALL: break;
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
2008-04-13 15:07:36 +00:00
|
|
|
if (cargo[i] >= (supplies ? 1U : 8U)) {
|
2006-11-06 15:25:02 +00:00
|
|
|
if (first) {
|
|
|
|
first = false;
|
|
|
|
} else {
|
|
|
|
/* Add a comma if this is not the first item */
|
|
|
|
*b++ = ',';
|
|
|
|
*b++ = ' ';
|
|
|
|
}
|
2007-02-20 22:09:21 +00:00
|
|
|
b = InlineString(b, GetCargo(i)->name);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-06 15:25:02 +00:00
|
|
|
/* If first is still true then no cargo is accepted */
|
|
|
|
if (first) b = InlineString(b, STR_00D0_NOTHING);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-11-06 15:25:02 +00:00
|
|
|
*b = '\0';
|
2007-12-08 18:50:39 +00:00
|
|
|
|
|
|
|
/* Make sure we detect any buffer overflow */
|
2008-07-17 13:47:04 +00:00
|
|
|
assert(b < endof(string));
|
2007-12-08 18:50:39 +00:00
|
|
|
|
2008-07-17 13:47:04 +00:00
|
|
|
SetDParamStr(0, string);
|
|
|
|
return DrawStringMultiLine(str_x, str_y, STR_JUST_RAW_STRING, 144);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-04-06 22:32:20 +00:00
|
|
|
/**
|
|
|
|
* Calculates and draws the accepted or supplied cargo around the selected tile(s)
|
|
|
|
* @param sx x position where the string is to be drawn
|
|
|
|
* @param sy y position where the string is to be drawn
|
|
|
|
* @param sct which type of cargo is to be displayed (passengers/non-passengers)
|
|
|
|
* @param rad radius around selected tile(s) to be searched
|
|
|
|
* @param supplies if supplied cargos should be drawn, else accepted cargos
|
|
|
|
* @return Returns the y value below the string that was drawn
|
|
|
|
*/
|
|
|
|
int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad, bool supplies)
|
2007-07-25 00:16:30 +00:00
|
|
|
{
|
2006-01-23 19:12:35 +00:00
|
|
|
TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y);
|
2008-04-06 22:32:20 +00:00
|
|
|
AcceptedCargo cargo;
|
2006-01-23 19:12:35 +00:00
|
|
|
if (tile < MapSize()) {
|
2008-04-06 22:32:20 +00:00
|
|
|
if (supplies) {
|
|
|
|
GetProductionAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad);
|
|
|
|
} else {
|
|
|
|
GetAcceptanceAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad);
|
|
|
|
}
|
|
|
|
return sy + DrawStationCoverageText(cargo, sx, sy, sct, supplies);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-01-27 11:01:10 +00:00
|
|
|
|
|
|
|
return sy;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-07-26 03:33:12 +00:00
|
|
|
void CheckRedrawStationCoverage(const Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-10-23 13:04:44 +00:00
|
|
|
if (_thd.dirty & 1) {
|
|
|
|
_thd.dirty &= ~1;
|
2004-08-09 17:04:08 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-16 22:05:33 +00:00
|
|
|
/* Delete a character at the caret position in a text buf.
|
|
|
|
* If backspace is set, delete the character before the caret,
|
|
|
|
* else delete the character after it. */
|
|
|
|
static void DelChar(Textbuf *tb, bool backspace)
|
2005-01-06 15:54:09 +00:00
|
|
|
{
|
2006-11-16 22:05:33 +00:00
|
|
|
WChar c;
|
2007-03-05 00:34:48 +00:00
|
|
|
char *s = tb->buf + tb->caretpos;
|
2006-11-16 22:05:33 +00:00
|
|
|
|
2007-03-05 00:34:48 +00:00
|
|
|
if (backspace) s = Utf8PrevChar(s);
|
2006-11-16 22:05:33 +00:00
|
|
|
|
2008-05-27 21:41:00 +00:00
|
|
|
uint16 len = (uint16)Utf8Decode(&c, s);
|
2008-03-26 10:38:31 +00:00
|
|
|
uint width = GetCharacterWidth(FS_NORMAL, c);
|
2006-11-16 22:05:33 +00:00
|
|
|
|
|
|
|
tb->width -= width;
|
2007-03-05 00:34:48 +00:00
|
|
|
if (backspace) {
|
|
|
|
tb->caretpos -= len;
|
|
|
|
tb->caretxoffs -= width;
|
|
|
|
}
|
2006-11-16 22:05:33 +00:00
|
|
|
|
|
|
|
/* Move the remaining characters over the marker */
|
2008-10-22 19:12:10 +00:00
|
|
|
memmove(s, s + len, tb->size - (s - tb->buf) - len);
|
|
|
|
tb->size -= len;
|
2005-01-06 15:54:09 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 18:59:54 +00:00
|
|
|
/**
|
|
|
|
* Delete a character from a textbuffer, either with 'Delete' or 'Backspace'
|
|
|
|
* The character is delete from the position the caret is at
|
2007-04-17 20:23:13 +00:00
|
|
|
* @param tb Textbuf type to be changed
|
|
|
|
* @param delmode Type of deletion, either WKC_BACKSPACE or WKC_DELETE
|
2007-07-30 13:36:09 +00:00
|
|
|
* @return Return true on successful change of Textbuf, or false otherwise
|
2005-02-21 18:59:54 +00:00
|
|
|
*/
|
|
|
|
bool DeleteTextBufferChar(Textbuf *tb, int delmode)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-02-21 18:59:54 +00:00
|
|
|
if (delmode == WKC_BACKSPACE && tb->caretpos != 0) {
|
2006-11-16 22:05:33 +00:00
|
|
|
DelChar(tb, true);
|
2005-02-21 18:59:54 +00:00
|
|
|
return true;
|
2008-10-22 19:12:10 +00:00
|
|
|
} else if (delmode == WKC_DELETE && tb->caretpos < tb->size - 1) {
|
2006-11-16 22:05:33 +00:00
|
|
|
DelChar(tb, false);
|
2005-02-21 18:59:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-02-21 18:59:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-05-30 16:03:21 +00:00
|
|
|
/**
|
|
|
|
* Delete every character in the textbuffer
|
2007-04-17 20:23:13 +00:00
|
|
|
* @param tb Textbuf buffer to be emptied
|
2005-05-30 16:03:21 +00:00
|
|
|
*/
|
|
|
|
void DeleteTextBufferAll(Textbuf *tb)
|
|
|
|
{
|
2008-10-22 19:12:10 +00:00
|
|
|
memset(tb->buf, 0, tb->maxsize);
|
|
|
|
tb->size = 1;
|
|
|
|
tb->width = tb->caretpos = tb->caretxoffs = 0;
|
2005-05-30 16:03:21 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 18:59:54 +00:00
|
|
|
/**
|
2006-04-06 19:16:39 +00:00
|
|
|
* Insert a character to a textbuffer. If maxwidth of the Textbuf is zero,
|
|
|
|
* we don't care about the visual-length but only about the physical
|
2006-04-06 19:11:41 +00:00
|
|
|
* length of the string
|
2007-04-17 20:23:13 +00:00
|
|
|
* @param tb Textbuf type to be changed
|
2005-02-21 18:59:54 +00:00
|
|
|
* @param key Character to be inserted
|
2007-07-30 13:36:09 +00:00
|
|
|
* @return Return true on successful change of Textbuf, or false otherwise
|
2005-02-21 18:59:54 +00:00
|
|
|
*/
|
2006-11-16 22:05:33 +00:00
|
|
|
bool InsertTextBufferChar(Textbuf *tb, WChar key)
|
2005-02-21 18:59:54 +00:00
|
|
|
{
|
2006-05-09 13:23:04 +00:00
|
|
|
const byte charwidth = GetCharacterWidth(FS_NORMAL, key);
|
2008-05-27 21:41:00 +00:00
|
|
|
uint16 len = (uint16)Utf8CharLen(key);
|
2008-10-22 19:12:10 +00:00
|
|
|
if (tb->size + len <= tb->maxsize && (tb->maxwidth == 0 || tb->width + charwidth <= tb->maxwidth)) {
|
|
|
|
memmove(tb->buf + tb->caretpos + len, tb->buf + tb->caretpos, tb->size - tb->caretpos);
|
2006-11-16 22:05:33 +00:00
|
|
|
Utf8Encode(tb->buf + tb->caretpos, key);
|
2008-10-22 19:12:10 +00:00
|
|
|
tb->size += len;
|
|
|
|
tb->width += charwidth;
|
2006-11-16 22:05:33 +00:00
|
|
|
|
|
|
|
tb->caretpos += len;
|
2005-02-21 18:59:54 +00:00
|
|
|
tb->caretxoffs += charwidth;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2005-01-06 15:54:09 +00:00
|
|
|
|
2005-02-21 18:59:54 +00:00
|
|
|
/**
|
|
|
|
* Handle text navigation with arrow keys left/right.
|
|
|
|
* This defines where the caret will blink and the next characer interaction will occur
|
2007-04-17 20:23:13 +00:00
|
|
|
* @param tb Textbuf type where navigation occurs
|
|
|
|
* @param navmode Direction in which navigation occurs WKC_LEFT, WKC_RIGHT, WKC_END, WKC_HOME
|
2007-07-30 13:36:09 +00:00
|
|
|
* @return Return true on successful change of Textbuf, or false otherwise
|
2005-02-21 18:59:54 +00:00
|
|
|
*/
|
|
|
|
bool MoveTextBufferPos(Textbuf *tb, int navmode)
|
|
|
|
{
|
|
|
|
switch (navmode) {
|
2008-03-26 10:38:31 +00:00
|
|
|
case WKC_LEFT:
|
|
|
|
if (tb->caretpos != 0) {
|
|
|
|
WChar c;
|
|
|
|
const char *s = Utf8PrevChar(tb->buf + tb->caretpos);
|
|
|
|
Utf8Decode(&c, s);
|
|
|
|
tb->caretpos = s - tb->buf; // -= (tb->buf + tb->caretpos - s)
|
|
|
|
tb->caretxoffs -= GetCharacterWidth(FS_NORMAL, c);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2006-11-16 22:05:33 +00:00
|
|
|
|
2008-03-26 10:38:31 +00:00
|
|
|
case WKC_RIGHT:
|
2008-10-22 19:12:10 +00:00
|
|
|
if (tb->caretpos < tb->size - 1) {
|
2008-03-26 10:38:31 +00:00
|
|
|
WChar c;
|
2006-11-16 22:05:33 +00:00
|
|
|
|
2008-05-27 21:41:00 +00:00
|
|
|
tb->caretpos += (uint16)Utf8Decode(&c, tb->buf + tb->caretpos);
|
2008-03-26 10:38:31 +00:00
|
|
|
tb->caretxoffs += GetCharacterWidth(FS_NORMAL, c);
|
2006-11-16 22:05:33 +00:00
|
|
|
|
2008-03-26 10:38:31 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WKC_HOME:
|
|
|
|
tb->caretpos = 0;
|
|
|
|
tb->caretxoffs = 0;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case WKC_END:
|
2008-10-22 19:12:10 +00:00
|
|
|
tb->caretpos = tb->size - 1;
|
2008-03-26 10:38:31 +00:00
|
|
|
tb->caretxoffs = tb->width;
|
2005-02-21 18:59:54 +00:00
|
|
|
return true;
|
2008-04-04 17:27:38 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2005-02-21 18:59:54 +00:00
|
|
|
}
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2005-02-21 18:59:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-10-24 22:57:44 +00:00
|
|
|
/**
|
|
|
|
* Initialize the textbuffer by supplying it the buffer to write into
|
|
|
|
* and the maximum length of this buffer
|
2007-04-17 20:23:13 +00:00
|
|
|
* @param tb Textbuf type which is getting initialized
|
2006-10-24 22:57:44 +00:00
|
|
|
* @param buf the buffer that will be holding the data for input
|
2008-10-22 19:12:10 +00:00
|
|
|
* @param maxsize maximum size in bytes, including terminating '\0'
|
2006-10-24 22:57:44 +00:00
|
|
|
* @param maxwidth maximum length in pixels of this buffer. If reached, buffer
|
2008-10-22 19:12:10 +00:00
|
|
|
* cannot grow, even if maxsize would allow because there is space. Width
|
|
|
|
* of zero '0' means the buffer is only restricted by maxsize */
|
|
|
|
void InitializeTextBuffer(Textbuf *tb, char *buf, uint16 maxsize, uint16 maxwidth)
|
2006-10-24 22:57:44 +00:00
|
|
|
{
|
2008-10-22 19:12:10 +00:00
|
|
|
assert(maxsize != 0);
|
|
|
|
|
|
|
|
tb->buf = buf;
|
|
|
|
tb->maxsize = maxsize;
|
|
|
|
tb->maxwidth = maxwidth;
|
|
|
|
tb->caret = true;
|
2006-10-24 22:57:44 +00:00
|
|
|
UpdateTextBufferSize(tb);
|
|
|
|
}
|
|
|
|
|
2005-02-21 18:59:54 +00:00
|
|
|
/**
|
2007-04-17 20:23:13 +00:00
|
|
|
* Update Textbuf type with its actual physical character and screenlength
|
2005-02-21 18:59:54 +00:00
|
|
|
* Get the count of characters in the string as well as the width in pixels.
|
|
|
|
* Useful when copying in a larger amount of text at once
|
2007-04-17 20:23:13 +00:00
|
|
|
* @param tb Textbuf type which length is calculated
|
2005-02-21 18:59:54 +00:00
|
|
|
*/
|
|
|
|
void UpdateTextBufferSize(Textbuf *tb)
|
|
|
|
{
|
2006-11-16 22:05:33 +00:00
|
|
|
const char *buf = tb->buf;
|
2005-11-13 13:43:55 +00:00
|
|
|
|
2005-02-21 18:59:54 +00:00
|
|
|
tb->width = 0;
|
2008-10-22 19:12:10 +00:00
|
|
|
tb->size = 1; // terminating zero
|
2005-02-21 18:59:54 +00:00
|
|
|
|
2008-10-22 19:12:10 +00:00
|
|
|
WChar c;
|
|
|
|
while ((c = Utf8Consume(&buf)) != '\0') {
|
2006-11-16 22:05:33 +00:00
|
|
|
tb->width += GetCharacterWidth(FS_NORMAL, c);
|
2008-10-22 19:12:10 +00:00
|
|
|
tb->size += Utf8CharLen(c);
|
2005-02-21 18:59:54 +00:00
|
|
|
}
|
|
|
|
|
2008-10-22 19:12:10 +00:00
|
|
|
assert(tb->size <= tb->maxsize);
|
|
|
|
|
|
|
|
tb->caretpos = tb->size - 1;
|
2005-02-21 18:59:54 +00:00
|
|
|
tb->caretxoffs = tb->width;
|
|
|
|
}
|
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
bool HandleCaret(Textbuf *tb)
|
2005-02-21 18:59:54 +00:00
|
|
|
{
|
2008-05-11 12:26:20 +00:00
|
|
|
/* caret changed? */
|
|
|
|
bool b = !!(_caret_timer & 0x20);
|
2005-02-21 18:59:54 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
if (b != tb->caret) {
|
|
|
|
tb->caret = b;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-02-09 01:22:29 +00:00
|
|
|
bool QueryString::HasEditBoxFocus(const Window *w, int wid) const
|
|
|
|
{
|
|
|
|
return ((w->window_class == WC_OSK &&
|
|
|
|
_focused_window == w->parent &&
|
|
|
|
w->parent->focused_widget &&
|
|
|
|
w->parent->focused_widget->type == WWT_EDITBOX) ||
|
|
|
|
w->IsWidgetGloballyFocused(wid));
|
|
|
|
}
|
|
|
|
|
2008-10-25 19:59:11 +00:00
|
|
|
HandleEditBoxResult QueryString::HandleEditBoxKey(Window *w, int wid, uint16 key, uint16 keycode, Window::EventState &state)
|
2008-05-11 12:26:20 +00:00
|
|
|
{
|
2009-02-09 01:22:29 +00:00
|
|
|
if (!QueryString::HasEditBoxFocus(w, wid)) return HEBR_NOT_FOCUSED;
|
|
|
|
|
2008-05-17 23:11:06 +00:00
|
|
|
state = Window::ES_HANDLED;
|
2008-05-11 12:26:20 +00:00
|
|
|
|
|
|
|
switch (keycode) {
|
2008-10-25 19:59:11 +00:00
|
|
|
case WKC_ESC: return HEBR_CANCEL;
|
2008-03-26 10:38:31 +00:00
|
|
|
|
2008-10-25 19:59:11 +00:00
|
|
|
case WKC_RETURN: case WKC_NUM_ENTER: return HEBR_CONFIRM;
|
2008-03-26 10:38:31 +00:00
|
|
|
|
|
|
|
case (WKC_CTRL | 'V'):
|
2008-05-11 12:26:20 +00:00
|
|
|
if (InsertTextBufferClipboard(&this->text)) w->InvalidateWidget(wid);
|
2008-03-26 10:38:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case (WKC_CTRL | 'U'):
|
2008-05-11 12:26:20 +00:00
|
|
|
DeleteTextBufferAll(&this->text);
|
2007-12-07 18:05:49 +00:00
|
|
|
w->InvalidateWidget(wid);
|
2008-03-26 10:38:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WKC_BACKSPACE: case WKC_DELETE:
|
2008-05-11 12:26:20 +00:00
|
|
|
if (DeleteTextBufferChar(&this->text, keycode)) w->InvalidateWidget(wid);
|
2008-03-26 10:38:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
|
2008-05-11 12:26:20 +00:00
|
|
|
if (MoveTextBufferPos(&this->text, keycode)) w->InvalidateWidget(wid);
|
2008-03-26 10:38:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-05-11 12:26:20 +00:00
|
|
|
if (IsValidChar(key, this->afilter)) {
|
|
|
|
if (InsertTextBufferChar(&this->text, key)) w->InvalidateWidget(wid);
|
2009-03-11 09:21:11 +00:00
|
|
|
} else {
|
|
|
|
state = Window::ES_NOT_HANDLED;
|
2006-11-16 22:05:33 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-10-25 19:59:11 +00:00
|
|
|
return HEBR_EDITING;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
void QueryString::HandleEditBox(Window *w, int wid)
|
2005-02-21 18:59:54 +00:00
|
|
|
{
|
2009-02-09 01:22:29 +00:00
|
|
|
if (HasEditBoxFocus(w, wid) && HandleCaret(&this->text)) {
|
2009-01-25 22:16:08 +00:00
|
|
|
w->InvalidateWidget(wid);
|
|
|
|
/* When we're not the OSK, notify 'our' OSK to redraw the widget,
|
|
|
|
* so the caret changes appropriately. */
|
|
|
|
if (w->window_class != WC_OSK) {
|
|
|
|
Window *w_osk = FindWindowById(WC_OSK, 0);
|
|
|
|
if (w_osk != NULL && w_osk->parent == w) w_osk->OnInvalidateData();
|
|
|
|
}
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
void QueryString::DrawEditBox(Window *w, int wid)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-10-27 10:12:57 +00:00
|
|
|
const Widget *wi = &w->widget[wid];
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-03-26 10:08:17 +00:00
|
|
|
assert((wi->type & WWT_MASK) == WWT_EDITBOX);
|
|
|
|
|
2007-01-13 15:00:40 +00:00
|
|
|
GfxFillRect(wi->left + 1, wi->top + 1, wi->right - 1, wi->bottom - 1, 215);
|
|
|
|
|
2008-04-04 17:27:38 +00:00
|
|
|
DrawPixelInfo dpi;
|
|
|
|
int delta;
|
|
|
|
|
2006-10-27 10:12:57 +00:00
|
|
|
/* Limit the drawing of the string inside the widget boundaries */
|
|
|
|
if (!FillDrawPixelInfo(&dpi,
|
2008-03-26 10:38:31 +00:00
|
|
|
wi->left + 4,
|
|
|
|
wi->top + 1,
|
|
|
|
wi->right - wi->left - 4,
|
|
|
|
wi->bottom - wi->top - 1)) {
|
|
|
|
return;
|
|
|
|
}
|
2006-10-27 10:12:57 +00:00
|
|
|
|
2008-04-04 17:27:38 +00:00
|
|
|
DrawPixelInfo *old_dpi = _cur_dpi;
|
2006-10-27 10:12:57 +00:00
|
|
|
_cur_dpi = &dpi;
|
|
|
|
|
|
|
|
/* We will take the current widget length as maximum width, with a small
|
|
|
|
* space reserved at the end for the caret to show */
|
2008-05-11 12:26:20 +00:00
|
|
|
const Textbuf *tb = &this->text;
|
2008-04-04 17:27:38 +00:00
|
|
|
|
2006-10-27 10:12:57 +00:00
|
|
|
delta = (wi->right - wi->left) - tb->width - 10;
|
|
|
|
if (delta > 0) delta = 0;
|
|
|
|
|
|
|
|
if (tb->caretxoffs + delta < 0) delta = -tb->caretxoffs;
|
|
|
|
|
2007-11-04 00:08:57 +00:00
|
|
|
DoDrawString(tb->buf, delta, 0, TC_YELLOW);
|
2009-02-09 01:22:29 +00:00
|
|
|
if (HasEditBoxFocus(w, wid) && tb->caret) DoDrawString("_", tb->caretxoffs + delta, 0, TC_WHITE);
|
2006-10-27 10:12:57 +00:00
|
|
|
|
|
|
|
_cur_dpi = old_dpi;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2009-01-03 23:40:29 +00:00
|
|
|
HandleEditBoxResult QueryStringBaseWindow::HandleEditBoxKey(int wid, uint16 key, uint16 keycode, EventState &state)
|
2008-05-11 12:26:20 +00:00
|
|
|
{
|
2008-05-17 23:11:06 +00:00
|
|
|
return this->QueryString::HandleEditBoxKey(this, wid, key, keycode, state);
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QueryStringBaseWindow::HandleEditBox(int wid)
|
|
|
|
{
|
|
|
|
this->QueryString::HandleEditBox(this, wid);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QueryStringBaseWindow::DrawEditBox(int wid)
|
|
|
|
{
|
|
|
|
this->QueryString::DrawEditBox(this, wid);
|
|
|
|
}
|
|
|
|
|
2009-01-03 13:59:05 +00:00
|
|
|
void QueryStringBaseWindow::OnOpenOSKWindow(int wid)
|
|
|
|
{
|
|
|
|
ShowOnScreenKeyboard(this, wid, 0, 0);
|
|
|
|
}
|
|
|
|
|
2006-12-30 01:17:53 +00:00
|
|
|
enum QueryStringWidgets {
|
|
|
|
QUERY_STR_WIDGET_TEXT = 3,
|
2008-09-15 19:02:50 +00:00
|
|
|
QUERY_STR_WIDGET_DEFAULT,
|
2006-12-30 01:17:53 +00:00
|
|
|
QUERY_STR_WIDGET_CANCEL,
|
|
|
|
QUERY_STR_WIDGET_OK
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
struct QueryStringWindow : public QueryStringBaseWindow
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2008-08-13 14:52:54 +00:00
|
|
|
QueryStringWindow(uint16 size, const WindowDesc *desc, Window *parent) : QueryStringBaseWindow(size, desc)
|
2008-05-11 12:26:20 +00:00
|
|
|
{
|
2008-05-14 19:08:09 +00:00
|
|
|
this->parent = parent;
|
2009-02-09 01:22:29 +00:00
|
|
|
this->SetFocusedWidget(QUERY_STR_WIDGET_TEXT);
|
2005-05-17 23:25:18 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
this->FindWindowPlacementAndResize(desc);
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
|
|
|
SetDParam(0, this->caption);
|
2008-05-17 12:48:06 +00:00
|
|
|
this->DrawWidgets();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
this->DrawEditBox(QUERY_STR_WIDGET_TEXT);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnOk()
|
|
|
|
{
|
|
|
|
if (this->orig == NULL || strcmp(this->text.buf, this->orig) != 0) {
|
|
|
|
/* If the parent is NULL, the editbox is handled by general function
|
2008-07-23 15:01:50 +00:00
|
|
|
* HandleOnEditText */
|
2008-05-11 12:26:20 +00:00
|
|
|
if (this->parent != NULL) {
|
|
|
|
this->parent->OnQueryTextFinished(this->text.buf);
|
|
|
|
} else {
|
|
|
|
HandleOnEditText(this->text.buf);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-05-14 20:28:11 +00:00
|
|
|
this->handled = true;
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
|
{
|
|
|
|
switch (widget) {
|
2008-09-15 19:02:50 +00:00
|
|
|
case QUERY_STR_WIDGET_DEFAULT:
|
|
|
|
this->text.buf[0] = '\0';
|
|
|
|
/* Fallthrough */
|
2008-05-11 12:26:20 +00:00
|
|
|
case QUERY_STR_WIDGET_OK:
|
|
|
|
this->OnOk();
|
|
|
|
/* Fallthrough */
|
|
|
|
case QUERY_STR_WIDGET_CANCEL:
|
|
|
|
delete this;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
virtual void OnMouseLoop()
|
|
|
|
{
|
|
|
|
this->HandleEditBox(QUERY_STR_WIDGET_TEXT);
|
2008-05-10 13:46:36 +00:00
|
|
|
}
|
2008-05-11 12:26:20 +00:00
|
|
|
|
2008-05-17 23:11:06 +00:00
|
|
|
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
2008-05-11 12:26:20 +00:00
|
|
|
{
|
2009-03-11 09:21:11 +00:00
|
|
|
EventState state = ES_NOT_HANDLED;
|
2008-05-17 23:11:06 +00:00
|
|
|
switch (this->HandleEditBoxKey(QUERY_STR_WIDGET_TEXT, key, keycode, state)) {
|
2008-05-28 15:28:27 +00:00
|
|
|
default: NOT_REACHED();
|
2008-10-25 19:59:11 +00:00
|
|
|
case HEBR_EDITING: {
|
2008-05-28 15:28:27 +00:00
|
|
|
Window *osk = FindWindowById(WC_OSK, 0);
|
|
|
|
if (osk != NULL && osk->parent == this) osk->OnInvalidateData();
|
|
|
|
} break;
|
2008-10-25 19:59:11 +00:00
|
|
|
case HEBR_CONFIRM: this->OnOk();
|
2008-05-11 12:26:20 +00:00
|
|
|
/* FALL THROUGH */
|
2008-10-25 19:59:11 +00:00
|
|
|
case HEBR_CANCEL: delete this; break; // close window, abandon changes
|
2009-02-09 01:22:29 +00:00
|
|
|
case HEBR_NOT_FOCUSED: break;
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
2008-05-17 23:11:06 +00:00
|
|
|
return state;
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
|
|
|
|
2009-01-03 13:59:05 +00:00
|
|
|
virtual void OnOpenOSKWindow(int wid)
|
|
|
|
{
|
|
|
|
ShowOnScreenKeyboard(this, wid, QUERY_STR_WIDGET_CANCEL, QUERY_STR_WIDGET_OK);
|
|
|
|
}
|
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
~QueryStringWindow()
|
|
|
|
{
|
|
|
|
if (!this->handled && this->parent != NULL) {
|
2008-05-27 23:40:36 +00:00
|
|
|
Window *parent = this->parent;
|
|
|
|
this->parent = NULL; // so parent doesn't try to delete us again
|
|
|
|
parent->OnQueryTextFinished(NULL);
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
static const Widget _query_string_widgets[] = {
|
2008-07-31 02:59:21 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 259, 0, 13, STR_012D, STR_NULL},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 259, 14, 29, 0x0, STR_NULL},
|
2008-09-15 19:02:50 +00:00
|
|
|
{ WWT_EDITBOX, RESIZE_NONE, COLOUR_GREY, 2, 257, 16, 27, 0x0, STR_NULL}, // QUERY_STR_WIDGET_TEXT
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 86, 30, 41, STR_DEFAULT, STR_NULL}, // QUERY_STR_WIDGET_DEFAULT
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 87, 172, 30, 41, STR_012E_CANCEL, STR_NULL}, // QUERY_STR_WIDGET_CANCEL
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 173, 259, 30, 41, STR_012F_OK, STR_NULL}, // QUERY_STR_WIDGET_OK
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _query_string_desc = {
|
2007-07-27 12:49:04 +00:00
|
|
|
190, 219, 260, 42, 260, 42,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_QUERY_STRING, WC_NONE,
|
2007-12-06 15:58:39 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
2004-08-09 17:04:08 +00:00
|
|
|
_query_string_widgets,
|
|
|
|
};
|
|
|
|
|
2006-12-30 01:17:53 +00:00
|
|
|
/** Show a query popup window with a textbox in it.
|
|
|
|
* @param str StringID for the text shown in the textbox
|
|
|
|
* @param caption StringID of text shown in caption of querywindow
|
2008-10-22 19:12:10 +00:00
|
|
|
* @param maxsize maximum size in bytes (including terminating '\0')
|
2006-12-30 01:17:53 +00:00
|
|
|
* @param maxwidth maximum width in pixels allowed
|
|
|
|
* @param parent pointer to a Window that will handle the events (ok/cancel) of this
|
2008-05-19 09:24:03 +00:00
|
|
|
* window. If NULL, results are handled by global function HandleOnEditText
|
2008-09-15 16:29:40 +00:00
|
|
|
* @param afilter filters out unwanted character input
|
|
|
|
* @param flags various flags, @see QueryStringFlags
|
|
|
|
*/
|
2008-10-22 19:12:10 +00:00
|
|
|
void ShowQueryString(StringID str, StringID caption, uint maxsize, uint maxwidth, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
DeleteWindowById(WC_QUERY_STRING, 0);
|
|
|
|
|
2008-10-22 19:12:10 +00:00
|
|
|
QueryStringWindow *w = new QueryStringWindow(maxsize, &_query_string_desc, parent);
|
2008-05-11 12:26:20 +00:00
|
|
|
|
2008-10-22 19:12:10 +00:00
|
|
|
GetString(w->edit_str_buf, str, &w->edit_str_buf[maxsize - 1]);
|
|
|
|
w->edit_str_buf[maxsize - 1] = '\0';
|
2005-02-19 14:40:32 +00:00
|
|
|
|
2008-09-15 16:29:40 +00:00
|
|
|
if ((flags & QSF_ACCEPT_UNCHANGED) == 0) w->orig = strdup(w->edit_str_buf);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-09-15 19:02:50 +00:00
|
|
|
if ((flags & QSF_ENABLE_DEFAULT) == 0) {
|
|
|
|
/* without the "Default" button, make "Cancel" and "OK" buttons wider */
|
|
|
|
w->SetWidgetHiddenState(QUERY_STR_WIDGET_DEFAULT, true);
|
|
|
|
w->widget[QUERY_STR_WIDGET_CANCEL].left = 0;
|
|
|
|
w->widget[QUERY_STR_WIDGET_CANCEL].right = w->width / 2 - 1;
|
|
|
|
w->widget[QUERY_STR_WIDGET_OK].left = w->width / 2;
|
|
|
|
w->widget[QUERY_STR_WIDGET_OK].right = w->width - 1;
|
|
|
|
}
|
|
|
|
|
2007-12-02 14:29:48 +00:00
|
|
|
w->LowerWidget(QUERY_STR_WIDGET_TEXT);
|
2008-05-11 12:26:20 +00:00
|
|
|
w->caption = caption;
|
|
|
|
w->afilter = afilter;
|
2008-10-22 19:12:10 +00:00
|
|
|
InitializeTextBuffer(&w->text, w->edit_str_buf, maxsize, maxwidth);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-12-29 17:54:47 +00:00
|
|
|
|
|
|
|
enum QueryWidgets {
|
|
|
|
QUERY_WIDGET_CAPTION = 1,
|
|
|
|
QUERY_WIDGET_NO = 3,
|
|
|
|
QUERY_WIDGET_YES
|
|
|
|
};
|
|
|
|
|
2008-05-11 06:59:51 +00:00
|
|
|
/**
|
|
|
|
* Window used for asking the user a YES/NO question.
|
|
|
|
*/
|
|
|
|
struct QueryWindow : public Window {
|
2008-05-19 19:17:56 +00:00
|
|
|
QueryCallbackProc *proc; ///< callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' clicked, false otherwise
|
|
|
|
uint64 params[10]; ///< local copy of _decode_parameters
|
|
|
|
StringID message; ///< message shown for query window
|
2006-12-29 17:54:47 +00:00
|
|
|
|
2008-05-19 19:17:56 +00:00
|
|
|
QueryWindow(const WindowDesc *desc, StringID caption, StringID message, Window *parent, QueryCallbackProc *callback) : Window(desc)
|
2008-05-11 06:59:51 +00:00
|
|
|
{
|
|
|
|
if (parent == NULL) parent = FindWindowById(WC_MAIN_WINDOW, 0);
|
|
|
|
this->parent = parent;
|
|
|
|
this->left = parent->left + (parent->width / 2) - (this->width / 2);
|
|
|
|
this->top = parent->top + (parent->height / 2) - (this->height / 2);
|
|
|
|
|
|
|
|
/* Create a backup of the variadic arguments to strings because it will be
|
2008-07-23 15:01:50 +00:00
|
|
|
* overridden pretty often. We will copy these back for drawing */
|
2008-05-11 06:59:51 +00:00
|
|
|
CopyOutDParam(this->params, 0, lengthof(this->params));
|
|
|
|
this->widget[QUERY_WIDGET_CAPTION].data = caption;
|
|
|
|
this->message = message;
|
|
|
|
this->proc = callback;
|
2008-05-11 11:41:18 +00:00
|
|
|
|
|
|
|
this->FindWindowPlacementAndResize(desc);
|
2008-05-11 06:59:51 +00:00
|
|
|
}
|
2006-12-29 17:54:47 +00:00
|
|
|
|
2008-05-11 06:59:51 +00:00
|
|
|
~QueryWindow()
|
|
|
|
{
|
|
|
|
if (this->proc != NULL) this->proc(this->parent, false);
|
|
|
|
}
|
2006-12-29 17:54:47 +00:00
|
|
|
|
2008-05-11 06:59:51 +00:00
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
|
|
|
CopyInDParam(0, this->params, lengthof(this->params));
|
2008-05-17 12:48:06 +00:00
|
|
|
this->DrawWidgets();
|
2008-05-11 06:59:51 +00:00
|
|
|
CopyInDParam(0, this->params, lengthof(this->params));
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
|
2008-05-11 06:59:51 +00:00
|
|
|
DrawStringMultiCenter(this->width / 2, (this->height / 2) - 10, this->message, this->width - 2);
|
|
|
|
}
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
|
2008-05-11 06:59:51 +00:00
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
|
{
|
|
|
|
switch (widget) {
|
2008-05-19 19:17:56 +00:00
|
|
|
case QUERY_WIDGET_YES: {
|
|
|
|
/* in the Generate New World window, clicking 'Yes' causes
|
|
|
|
* DeleteNonVitalWindows() to be called - we shouldn't be in a window then */
|
|
|
|
QueryCallbackProc *proc = this->proc;
|
|
|
|
Window *parent = this->parent;
|
2008-05-28 06:30:55 +00:00
|
|
|
/* Prevent the destructor calling the callback function */
|
|
|
|
this->proc = NULL;
|
2008-05-19 19:17:56 +00:00
|
|
|
delete this;
|
|
|
|
if (proc != NULL) {
|
|
|
|
proc(parent, true);
|
|
|
|
proc = NULL;
|
2006-12-29 17:54:47 +00:00
|
|
|
}
|
2008-05-19 19:17:56 +00:00
|
|
|
} break;
|
2008-05-11 06:59:51 +00:00
|
|
|
case QUERY_WIDGET_NO:
|
|
|
|
delete this;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
|
2008-05-17 23:11:06 +00:00
|
|
|
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
2008-05-11 06:59:51 +00:00
|
|
|
{
|
|
|
|
/* ESC closes the window, Enter confirms the action */
|
|
|
|
switch (keycode) {
|
|
|
|
case WKC_RETURN:
|
|
|
|
case WKC_NUM_ENTER:
|
|
|
|
if (this->proc != NULL) {
|
|
|
|
this->proc(this->parent, true);
|
|
|
|
this->proc = NULL;
|
|
|
|
}
|
|
|
|
/* Fallthrough */
|
|
|
|
case WKC_ESC:
|
|
|
|
delete this;
|
2008-05-17 23:11:06 +00:00
|
|
|
return ES_HANDLED;
|
2008-05-11 06:59:51 +00:00
|
|
|
}
|
2008-05-17 23:11:06 +00:00
|
|
|
return ES_NOT_HANDLED;
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
}
|
2008-05-11 06:59:51 +00:00
|
|
|
};
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
|
2006-12-29 17:54:47 +00:00
|
|
|
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
static const Widget _query_widgets[] = {
|
2008-07-31 02:59:21 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_RED, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, COLOUR_RED, 11, 209, 0, 13, STR_NULL, STR_NULL},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, COLOUR_RED, 0, 209, 14, 81, 0x0, /*OVERRIDE*/STR_NULL},
|
|
|
|
{WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_YELLOW, 20, 90, 62, 73, STR_00C9_NO, STR_NULL},
|
|
|
|
{WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_YELLOW, 120, 190, 62, 73, STR_00C8_YES, STR_NULL},
|
2006-12-29 17:54:47 +00:00
|
|
|
{ WIDGETS_END },
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _query_desc = {
|
2007-07-27 12:49:04 +00:00
|
|
|
WDP_CENTER, WDP_CENTER, 210, 82, 210, 82,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_CONFIRM_POPUP_QUERY, WC_NONE,
|
2006-12-29 17:54:47 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_DEF_WIDGET | WDF_MODAL,
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
_query_widgets,
|
|
|
|
};
|
|
|
|
|
2006-12-29 17:54:47 +00:00
|
|
|
/** Show a modal confirmation window with standard 'yes' and 'no' buttons
|
|
|
|
* The window is aligned to the centre of its parent.
|
|
|
|
* NOTE: You cannot use BindCString as parameter for this window!
|
|
|
|
* @param caption string shown as window caption
|
|
|
|
* @param message string that will be shown for the window
|
|
|
|
* @param parent pointer to parent window, if this pointer is NULL the parent becomes
|
|
|
|
* the main window WC_MAIN_WINDOW
|
2008-07-23 15:01:50 +00:00
|
|
|
* @param callback callback function pointer to set in the window descriptor
|
|
|
|
*/
|
2008-05-19 19:17:56 +00:00
|
|
|
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
{
|
2008-05-11 06:59:51 +00:00
|
|
|
new QueryWindow(&_query_desc, caption, message, parent, callback);
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-14 00:27:28 +00:00
|
|
|
static const Widget _load_dialog_widgets[] = {
|
2009-03-13 21:32:38 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 256, 0, 13, STR_NULL, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 127, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 128, 256, 14, 25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP},
|
|
|
|
{ WWT_PANEL, RESIZE_RIGHT, COLOUR_GREY, 0, 256, 26, 47, 0x0, STR_NULL},
|
|
|
|
{ WWT_PANEL, RESIZE_RB, COLOUR_GREY, 0, 256, 48, 153, 0x0, STR_NULL},
|
|
|
|
{ WWT_PUSHIMGBTN, RESIZE_LR, COLOUR_GREY, 245, 256, 48, 59, SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON},
|
|
|
|
{ WWT_INSET, RESIZE_RB, COLOUR_GREY, 2, 243, 50, 139, 0x0, STR_400A_LIST_OF_DRIVES_DIRECTORIES},
|
|
|
|
{ WWT_SCROLLBAR, RESIZE_LRB, COLOUR_GREY, 245, 256, 60, 141, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_RTB, COLOUR_GREY, 0, 243, 142, 153, STR_CONTENT_INTRO_BUTTON, STR_CONTENT_INTRO_BUTTON_TIP},
|
|
|
|
{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_GREY, 245, 256, 142, 153, 0x0, STR_RESIZE_BUTTON},
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
{ WIDGETS_END},
|
|
|
|
};
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
static const Widget _save_dialog_widgets[] = {
|
2008-07-31 02:59:21 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 256, 0, 13, STR_NULL, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 127, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 128, 256, 14, 25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP},
|
|
|
|
{ WWT_PANEL, RESIZE_RIGHT, COLOUR_GREY, 0, 256, 26, 47, 0x0, STR_NULL},
|
|
|
|
{ WWT_PANEL, RESIZE_RB, COLOUR_GREY, 0, 256, 48, 151, 0x0, STR_NULL},
|
|
|
|
{ WWT_PUSHIMGBTN, RESIZE_LR, COLOUR_GREY, 245, 256, 48, 59, SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON},
|
|
|
|
{ WWT_INSET, RESIZE_RB, COLOUR_GREY, 2, 243, 50, 150, 0x0, STR_400A_LIST_OF_DRIVES_DIRECTORIES},
|
|
|
|
{ WWT_SCROLLBAR, RESIZE_LRB, COLOUR_GREY, 245, 256, 60, 151, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
|
|
|
{ WWT_PANEL, RESIZE_RTB, COLOUR_GREY, 0, 256, 152, 167, 0x0, STR_NULL},
|
|
|
|
{ WWT_EDITBOX, RESIZE_RTB, COLOUR_GREY, 2, 254, 154, 165, STR_SAVE_OSKTITLE, STR_400B_CURRENTLY_SELECTED_NAME},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 0, 127, 168, 179, STR_4003_DELETE, STR_400C_DELETE_THE_CURRENTLY_SELECTED},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 128, 244, 168, 179, STR_4002_SAVE, STR_400D_SAVE_THE_CURRENT_GAME_USING},
|
|
|
|
{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_GREY, 245, 256, 168, 179, 0x0, STR_RESIZE_BUTTON},
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2009-02-09 02:57:15 +00:00
|
|
|
/* Colours for fios types */
|
|
|
|
const TextColour _fios_colours[] = {
|
2007-11-04 00:08:57 +00:00
|
|
|
TC_LIGHT_BLUE, TC_DARK_GREEN, TC_DARK_GREEN, TC_ORANGE, TC_LIGHT_BROWN,
|
|
|
|
TC_ORANGE, TC_LIGHT_BROWN, TC_ORANGE, TC_ORANGE, TC_YELLOW
|
|
|
|
};
|
2005-08-01 16:31:19 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void BuildFileList()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-03-28 13:30:51 +00:00
|
|
|
_fios_path_changed = true;
|
2004-08-09 17:04:08 +00:00
|
|
|
FiosFreeSavegameList();
|
2006-08-05 00:59:45 +00:00
|
|
|
|
2005-10-23 13:04:44 +00:00
|
|
|
switch (_saveload_mode) {
|
|
|
|
case SLD_NEW_GAME:
|
|
|
|
case SLD_LOAD_SCENARIO:
|
|
|
|
case SLD_SAVE_SCENARIO:
|
2008-06-02 14:19:27 +00:00
|
|
|
FiosGetScenarioList(_saveload_mode); break;
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
case SLD_LOAD_HEIGHTMAP:
|
2008-06-02 14:19:27 +00:00
|
|
|
FiosGetHeightmapList(_saveload_mode); break;
|
2005-10-23 13:04:44 +00:00
|
|
|
|
2008-06-02 14:19:27 +00:00
|
|
|
default: FiosGetSavegameList(_saveload_mode); break;
|
2005-10-23 13:04:44 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-07-17 16:01:26 +00:00
|
|
|
static void DrawFiosTexts(uint maxw)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-03-28 13:30:51 +00:00
|
|
|
static const char *path = NULL;
|
|
|
|
static StringID str = STR_4006_UNABLE_TO_READ_DRIVE;
|
2009-01-16 12:59:47 +00:00
|
|
|
static uint64 tot = 0;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-03-28 13:30:51 +00:00
|
|
|
if (_fios_path_changed) {
|
|
|
|
str = FiosGetDescText(&path, &tot);
|
|
|
|
_fios_path_changed = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (str != STR_4006_UNABLE_TO_READ_DRIVE) SetDParam(0, tot);
|
2007-11-04 00:08:57 +00:00
|
|
|
DrawString(2, 37, str, TC_FROMSTRING);
|
|
|
|
DoDrawStringTruncated(path, 2, 27, TC_BLACK, maxw);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
static void MakeSortedSaveGameList()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-11-13 14:54:09 +00:00
|
|
|
uint sort_start = 0;
|
|
|
|
uint sort_end = 0;
|
|
|
|
|
2006-07-26 03:33:12 +00:00
|
|
|
/* Directories are always above the files (FIOS_TYPE_DIR)
|
|
|
|
* Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE)
|
|
|
|
* Only sort savegames/scenarios, not directories
|
2004-08-09 17:04:08 +00:00
|
|
|
*/
|
2008-06-02 14:19:27 +00:00
|
|
|
for (const FiosItem *item = _fios_items.Begin(); item != _fios_items.End(); item++) {
|
|
|
|
switch (item->type) {
|
2005-11-13 14:54:09 +00:00
|
|
|
case FIOS_TYPE_DIR: sort_start++; break;
|
|
|
|
case FIOS_TYPE_PARENT: sort_start++; break;
|
|
|
|
case FIOS_TYPE_DRIVE: sort_end++; break;
|
2008-04-23 12:03:47 +00:00
|
|
|
default: break;
|
2005-11-13 14:54:09 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-06-02 14:19:27 +00:00
|
|
|
uint s_amount = _fios_items.Length() - sort_start - sort_end;
|
2008-04-04 17:27:38 +00:00
|
|
|
if (s_amount > 0) {
|
2008-06-02 14:19:27 +00:00
|
|
|
qsort(_fios_items.Get(sort_start), s_amount, sizeof(FiosItem), compare_FiosItems);
|
2008-04-04 17:27:38 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
extern void StartupEngines();
|
2005-01-23 23:59:49 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
struct SaveLoadWindow : public QueryStringBaseWindow {
|
2009-01-27 03:50:36 +00:00
|
|
|
private:
|
|
|
|
enum SaveLoadWindowWidgets {
|
|
|
|
SLWW_CLOSE = 0,
|
|
|
|
SLWW_WINDOWTITLE,
|
|
|
|
SLWW_SORT_BYNAME,
|
|
|
|
SLWW_SORT_BYDATE,
|
|
|
|
SLWW_HOME_BUTTON = 6,
|
|
|
|
SLWW_DRIVES_DIRECTORIES_LIST,
|
2009-03-13 21:32:38 +00:00
|
|
|
SLWW_CONTENT_DOWNLOAD = 9, ///< only available for play scenario/heightmap (content download)
|
|
|
|
SLWW_SAVE_OSK_TITLE, ///< only available for save operations
|
2009-01-27 03:50:36 +00:00
|
|
|
SLWW_DELETE_SELECTION, ///< same in here
|
|
|
|
SLWW_SAVE_GAME, ///< not to mention in here too
|
|
|
|
};
|
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
FiosItem o_dir;
|
2009-01-27 03:50:36 +00:00
|
|
|
public:
|
2005-10-28 00:09:59 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
void GenerateFileName()
|
|
|
|
{
|
2009-01-02 22:49:43 +00:00
|
|
|
GenerateDefaultSaveName(this->edit_str_buf, &this->edit_str_buf[this->edit_str_size - 1]);
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-08-11 22:08:56 +00:00
|
|
|
SaveLoadWindow(const WindowDesc *desc, SaveLoadDialogMode mode) : QueryStringBaseWindow(64, desc)
|
2008-05-11 12:26:20 +00:00
|
|
|
{
|
|
|
|
static const StringID saveload_captions[] = {
|
|
|
|
STR_4001_LOAD_GAME,
|
|
|
|
STR_0298_LOAD_SCENARIO,
|
|
|
|
STR_4000_SAVE_GAME,
|
|
|
|
STR_0299_SAVE_SCENARIO,
|
|
|
|
STR_LOAD_HEIGHTMAP,
|
|
|
|
};
|
|
|
|
|
2009-03-13 21:32:38 +00:00
|
|
|
this->vscroll.cap = 10;
|
|
|
|
this->resize.step_width = 2;
|
|
|
|
this->resize.step_height = 10;
|
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
|
|
|
|
|
|
|
|
/* Use an array to define what will be the current file type being handled
|
|
|
|
* by current file mode */
|
|
|
|
switch (mode) {
|
2009-03-13 21:32:38 +00:00
|
|
|
case SLD_LOAD_GAME:
|
|
|
|
this->HideWidget(SLWW_CONTENT_DOWNLOAD);
|
|
|
|
this->widget[SLWW_DRIVES_DIRECTORIES_LIST].bottom += this->widget[SLWW_CONTENT_DOWNLOAD].bottom - this->widget[SLWW_CONTENT_DOWNLOAD].top;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SLD_LOAD_SCENARIO:
|
|
|
|
case SLD_LOAD_HEIGHTMAP:
|
|
|
|
this->vscroll.cap--;
|
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
case SLD_SAVE_GAME: this->GenerateFileName(); break;
|
|
|
|
case SLD_SAVE_SCENARIO: strcpy(this->edit_str_buf, "UNNAMED"); break;
|
|
|
|
default: break;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
assert((uint)mode < lengthof(saveload_captions));
|
2006-06-10 08:37:41 +00:00
|
|
|
|
2009-01-27 03:50:36 +00:00
|
|
|
this->widget[SLWW_WINDOWTITLE].data = saveload_captions[mode];
|
|
|
|
this->LowerWidget(SLWW_DRIVES_DIRECTORIES_LIST);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
this->afilter = CS_ALPHANUMERAL;
|
2008-08-11 22:08:56 +00:00
|
|
|
InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, 240);
|
2006-06-10 08:37:41 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
/* pause is only used in single-player, non-editor mode, non-menu mode. It
|
2008-07-23 15:01:50 +00:00
|
|
|
* will be unpaused in the WE_DESTROY event handler. */
|
2008-05-11 12:26:20 +00:00
|
|
|
if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) {
|
2008-12-28 14:37:19 +00:00
|
|
|
if (_pause_game >= 0) DoCommandP(0, 1, 0, CMD_PAUSE);
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
BuildFileList();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
ResetObjectToPlace();
|
|
|
|
|
|
|
|
o_dir.type = FIOS_TYPE_DIRECT;
|
|
|
|
switch (_saveload_mode) {
|
|
|
|
case SLD_SAVE_GAME:
|
|
|
|
case SLD_LOAD_GAME:
|
|
|
|
FioGetDirectory(o_dir.name, lengthof(o_dir.name), SAVE_DIR);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SLD_SAVE_SCENARIO:
|
|
|
|
case SLD_LOAD_SCENARIO:
|
|
|
|
FioGetDirectory(o_dir.name, lengthof(o_dir.name), SCENARIO_DIR);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SLD_LOAD_HEIGHTMAP:
|
|
|
|
FioGetDirectory(o_dir.name, lengthof(o_dir.name), HEIGHTMAP_DIR);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-11-02 11:20:15 +00:00
|
|
|
strecpy(o_dir.name, _personal_dir, lastof(o_dir.name));
|
2008-03-26 10:38:31 +00:00
|
|
|
}
|
|
|
|
|
2009-02-09 01:22:29 +00:00
|
|
|
/* Focus the edit box by default in the save windows */
|
|
|
|
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
|
|
|
|
this->SetFocusedWidget(SLWW_SAVE_OSK_TITLE);
|
|
|
|
}
|
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
this->FindWindowPlacementAndResize(desc);
|
|
|
|
}
|
2008-03-26 10:38:31 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
virtual ~SaveLoadWindow()
|
|
|
|
{
|
|
|
|
/* pause is only used in single-player, non-editor mode, non menu mode */
|
|
|
|
if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) {
|
2008-12-28 14:37:19 +00:00
|
|
|
if (_pause_game >= 0) DoCommandP(0, 0, 0, CMD_PAUSE);
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
|
|
|
FiosFreeSavegameList();
|
|
|
|
}
|
2005-10-28 00:09:59 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
|
|
|
int y;
|
2008-03-26 10:08:17 +00:00
|
|
|
|
2008-06-02 14:19:27 +00:00
|
|
|
SetVScrollCount(this, _fios_items.Length());
|
2008-05-17 12:48:06 +00:00
|
|
|
this->DrawWidgets();
|
2008-05-11 12:26:20 +00:00
|
|
|
DrawFiosTexts(this->width);
|
2008-03-26 10:38:31 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
if (_savegame_sort_dirty) {
|
|
|
|
_savegame_sort_dirty = false;
|
|
|
|
MakeSortedSaveGameList();
|
|
|
|
}
|
|
|
|
|
2009-01-27 03:50:36 +00:00
|
|
|
const Widget *widg = &this->widget[SLWW_DRIVES_DIRECTORIES_LIST];
|
|
|
|
GfxFillRect(widg->left + 1, widg->top + 1, widg->right, widg->bottom, 0xD7);
|
|
|
|
this->DrawSortButtonState(_savegame_sort_order & SORT_BY_NAME ? SLWW_SORT_BYNAME : SLWW_SORT_BYDATE, _savegame_sort_order & SORT_DESCENDING ? SBS_DOWN : SBS_UP);
|
2008-05-11 12:26:20 +00:00
|
|
|
|
2009-01-27 03:50:36 +00:00
|
|
|
y = widg->top + 1;
|
2008-06-02 14:19:27 +00:00
|
|
|
for (uint pos = this->vscroll.pos; pos < _fios_items.Length(); pos++) {
|
|
|
|
const FiosItem *item = _fios_items.Get(pos);
|
2008-05-11 12:26:20 +00:00
|
|
|
|
2009-02-09 02:57:15 +00:00
|
|
|
DoDrawStringTruncated(item->title, 4, y, _fios_colours[item->type], this->width - 18);
|
2008-05-11 12:26:20 +00:00
|
|
|
y += 10;
|
2009-01-27 03:50:36 +00:00
|
|
|
if (y >= this->vscroll.cap * 10 + widg->top + 1) break;
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
|
2009-01-27 03:50:36 +00:00
|
|
|
this->DrawEditBox(SLWW_SAVE_OSK_TITLE);
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
|
{
|
|
|
|
switch (widget) {
|
2009-01-27 03:50:36 +00:00
|
|
|
case SLWW_SORT_BYNAME: // Sort save names by name
|
2008-05-11 12:26:20 +00:00
|
|
|
_savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ?
|
|
|
|
SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME;
|
|
|
|
_savegame_sort_dirty = true;
|
|
|
|
this->SetDirty();
|
|
|
|
break;
|
|
|
|
|
2009-01-27 03:50:36 +00:00
|
|
|
case SLWW_SORT_BYDATE: // Sort save names by date
|
2008-05-11 12:26:20 +00:00
|
|
|
_savegame_sort_order = (_savegame_sort_order == SORT_BY_DATE) ?
|
|
|
|
SORT_BY_DATE | SORT_DESCENDING : SORT_BY_DATE;
|
|
|
|
_savegame_sort_dirty = true;
|
|
|
|
this->SetDirty();
|
|
|
|
break;
|
|
|
|
|
2009-01-27 03:50:36 +00:00
|
|
|
case SLWW_HOME_BUTTON: // OpenTTD 'button', jumps to OpenTTD directory
|
2008-05-11 12:26:20 +00:00
|
|
|
FiosBrowseTo(&o_dir);
|
|
|
|
this->SetDirty();
|
|
|
|
BuildFileList();
|
|
|
|
break;
|
2005-07-22 09:16:34 +00:00
|
|
|
|
2009-01-27 03:50:36 +00:00
|
|
|
case SLWW_DRIVES_DIRECTORIES_LIST: { // Click the listbox
|
2008-05-11 12:26:20 +00:00
|
|
|
int y = (pt.y - this->widget[widget].top - 1) / 10;
|
2008-03-26 10:38:31 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
if (y < 0 || (y += this->vscroll.pos) >= this->vscroll.count) return;
|
|
|
|
|
2008-06-02 14:19:27 +00:00
|
|
|
const FiosItem *file = _fios_items.Get(y);
|
2008-05-11 12:26:20 +00:00
|
|
|
|
2009-03-04 00:13:52 +00:00
|
|
|
const char *name = FiosBrowseTo(file);
|
2008-05-11 12:26:20 +00:00
|
|
|
if (name != NULL) {
|
|
|
|
if (_saveload_mode == SLD_LOAD_GAME || _saveload_mode == SLD_LOAD_SCENARIO) {
|
|
|
|
_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD;
|
|
|
|
|
|
|
|
SetFiosType(file->type);
|
2008-11-02 11:20:15 +00:00
|
|
|
strecpy(_file_to_saveload.name, name, lastof(_file_to_saveload.name));
|
|
|
|
strecpy(_file_to_saveload.title, file->title, lastof(_file_to_saveload.title));
|
2008-05-11 12:26:20 +00:00
|
|
|
|
|
|
|
delete this;
|
|
|
|
} else if (_saveload_mode == SLD_LOAD_HEIGHTMAP) {
|
|
|
|
SetFiosType(file->type);
|
2008-11-02 11:20:15 +00:00
|
|
|
strecpy(_file_to_saveload.name, name, lastof(_file_to_saveload.name));
|
|
|
|
strecpy(_file_to_saveload.title, file->title, lastof(_file_to_saveload.title));
|
2008-05-11 12:26:20 +00:00
|
|
|
|
|
|
|
delete this;
|
|
|
|
ShowHeightmapLoad();
|
|
|
|
} else {
|
|
|
|
/* SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox */
|
2008-10-22 19:12:10 +00:00
|
|
|
ttd_strlcpy(this->text.buf, file->title, this->text.maxsize);
|
2008-05-11 12:26:20 +00:00
|
|
|
UpdateTextBufferSize(&this->text);
|
2009-01-27 03:50:36 +00:00
|
|
|
this->InvalidateWidget(SLWW_SAVE_OSK_TITLE);
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
2008-03-26 10:38:31 +00:00
|
|
|
} else {
|
2008-05-11 12:26:20 +00:00
|
|
|
/* Changed directory, need repaint. */
|
|
|
|
this->SetDirty();
|
2008-03-26 10:38:31 +00:00
|
|
|
BuildFileList();
|
|
|
|
}
|
2008-05-11 12:26:20 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-03-26 10:38:31 +00:00
|
|
|
|
2009-03-13 21:32:38 +00:00
|
|
|
case SLWW_CONTENT_DOWNLOAD:
|
|
|
|
if (!_network_available) {
|
|
|
|
ShowErrorMessage(INVALID_STRING_ID, STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
|
|
|
|
} else {
|
|
|
|
#if defined(ENABLE_NETWORK)
|
|
|
|
switch (_saveload_mode) {
|
|
|
|
default: NOT_REACHED();
|
|
|
|
case SLD_LOAD_SCENARIO: ShowNetworkContentListWindow(NULL, CONTENT_TYPE_SCENARIO); break;
|
|
|
|
case SLD_LOAD_HEIGHTMAP: ShowNetworkContentListWindow(NULL, CONTENT_TYPE_HEIGHTMAP); break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-01-27 03:50:36 +00:00
|
|
|
case SLWW_DELETE_SELECTION: case SLWW_SAVE_GAME: // Delete, Save game
|
2008-05-11 12:26:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-03-21 22:09:19 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
virtual void OnMouseLoop()
|
|
|
|
{
|
|
|
|
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
|
2009-01-27 03:50:36 +00:00
|
|
|
this->HandleEditBox(SLWW_SAVE_OSK_TITLE);
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-17 23:11:06 +00:00
|
|
|
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
2008-05-11 12:26:20 +00:00
|
|
|
{
|
|
|
|
if (keycode == WKC_ESC) {
|
|
|
|
delete this;
|
2008-05-17 23:11:06 +00:00
|
|
|
return ES_HANDLED;
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
|
|
|
|
2008-05-17 23:11:06 +00:00
|
|
|
EventState state = ES_NOT_HANDLED;
|
2008-05-11 12:26:20 +00:00
|
|
|
if ((_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) &&
|
2009-01-27 03:50:36 +00:00
|
|
|
this->HandleEditBoxKey(SLWW_SAVE_OSK_TITLE, key, keycode, state) == HEBR_CONFIRM) {
|
|
|
|
this->HandleButtonClick(SLWW_SAVE_GAME);
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
|
|
|
|
2008-05-17 23:11:06 +00:00
|
|
|
return state;
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnTimeout()
|
|
|
|
{
|
|
|
|
/* This test protects against using widgets 11 and 12 which are only available
|
2008-07-23 15:01:50 +00:00
|
|
|
* in those two saveload mode */
|
2008-05-11 12:26:20 +00:00
|
|
|
if (!(_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO)) return;
|
2005-01-23 23:59:49 +00:00
|
|
|
|
2009-01-27 03:50:36 +00:00
|
|
|
if (this->IsWidgetLowered(SLWW_DELETE_SELECTION)) { // Delete button clicked
|
2008-05-11 12:26:20 +00:00
|
|
|
if (!FiosDelete(this->text.buf)) {
|
|
|
|
ShowErrorMessage(INVALID_STRING_ID, STR_4008_UNABLE_TO_DELETE_FILE, 0, 0);
|
|
|
|
} else {
|
|
|
|
BuildFileList();
|
|
|
|
/* Reset file name to current date on successful delete */
|
|
|
|
if (_saveload_mode == SLD_SAVE_GAME) GenerateFileName();
|
2008-03-26 10:38:31 +00:00
|
|
|
}
|
2005-01-03 19:45:18 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
UpdateTextBufferSize(&this->text);
|
|
|
|
this->SetDirty();
|
2009-01-27 03:50:36 +00:00
|
|
|
} else if (this->IsWidgetLowered(SLWW_SAVE_GAME)) { // Save button clicked
|
2008-05-11 12:26:20 +00:00
|
|
|
_switch_mode = SM_SAVE;
|
|
|
|
FiosMakeSavegameName(_file_to_saveload.name, this->text.buf, sizeof(_file_to_saveload.name));
|
|
|
|
|
|
|
|
/* In the editor set up the vehicle engines correctly (date might have changed) */
|
|
|
|
if (_game_mode == GM_EDITOR) StartupEngines();
|
|
|
|
}
|
2004-09-10 19:02:27 +00:00
|
|
|
}
|
2008-05-11 12:26:20 +00:00
|
|
|
|
|
|
|
virtual void OnResize(Point new_size, Point delta)
|
|
|
|
{
|
|
|
|
/* Widget 2 and 3 have to go with halve speed, make it so obiwan */
|
|
|
|
uint diff = delta.x / 2;
|
2009-01-27 03:50:36 +00:00
|
|
|
this->widget[SLWW_SORT_BYNAME].right += diff;
|
|
|
|
this->widget[SLWW_SORT_BYDATE].left += diff;
|
|
|
|
this->widget[SLWW_SORT_BYDATE].right += delta.x;
|
2008-05-11 12:26:20 +00:00
|
|
|
|
|
|
|
/* Same for widget 11 and 12 in save-dialog */
|
|
|
|
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
|
2009-01-27 03:50:36 +00:00
|
|
|
this->widget[SLWW_DELETE_SELECTION].right += diff;
|
|
|
|
this->widget[SLWW_SAVE_GAME].left += diff;
|
|
|
|
this->widget[SLWW_SAVE_GAME].right += delta.x;
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this->vscroll.cap += delta.y / 10;
|
|
|
|
}
|
2009-03-13 21:32:38 +00:00
|
|
|
|
|
|
|
virtual void OnInvalidateData(int data)
|
|
|
|
{
|
|
|
|
BuildFileList();
|
|
|
|
}
|
2008-05-11 12:26:20 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
static const WindowDesc _load_dialog_desc = {
|
2007-07-27 22:11:22 +00:00
|
|
|
WDP_CENTER, WDP_CENTER, 257, 154, 257, 294,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_SAVELOAD, WC_NONE,
|
2007-12-06 15:58:39 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
|
2006-11-14 00:27:28 +00:00
|
|
|
_load_dialog_widgets,
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _save_dialog_desc = {
|
2007-07-27 22:11:22 +00:00
|
|
|
WDP_CENTER, WDP_CENTER, 257, 180, 257, 320,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_SAVELOAD, WC_NONE,
|
2007-12-06 15:58:39 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
|
2004-08-09 17:04:08 +00:00
|
|
|
_save_dialog_widgets,
|
|
|
|
};
|
|
|
|
|
2007-12-28 04:20:56 +00:00
|
|
|
/** These values are used to convert the file/operations mode into a corresponding file type.
|
|
|
|
* So each entry, as expressed by the related comment, is based on the enum */
|
|
|
|
static const FileType _file_modetotype[] = {
|
|
|
|
FT_SAVEGAME, ///< used for SLD_LOAD_GAME
|
|
|
|
FT_SCENARIO, ///< used for SLD_LOAD_SCENARIO
|
|
|
|
FT_SAVEGAME, ///< used for SLD_SAVE_GAME
|
|
|
|
FT_SCENARIO, ///< used for SLD_SAVE_SCENARIO
|
|
|
|
FT_HEIGHTMAP, ///< used for SLD_LOAD_HEIGHTMAP
|
|
|
|
FT_SAVEGAME, ///< SLD_NEW_GAME
|
|
|
|
};
|
|
|
|
|
2007-12-27 17:29:27 +00:00
|
|
|
void ShowSaveLoadDialog(SaveLoadDialogMode mode)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
DeleteWindowById(WC_SAVELOAD, 0);
|
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
const WindowDesc *sld;
|
2005-02-22 14:52:20 +00:00
|
|
|
switch (mode) {
|
2008-05-11 12:26:20 +00:00
|
|
|
case SLD_SAVE_GAME:
|
|
|
|
case SLD_SAVE_SCENARIO:
|
|
|
|
sld = &_save_dialog_desc; break;
|
|
|
|
default:
|
|
|
|
sld = &_load_dialog_desc; break;
|
2005-11-14 19:48:04 +00:00
|
|
|
}
|
2004-09-17 17:53:34 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
_saveload_mode = mode;
|
|
|
|
_file_to_saveload.filetype = _file_modetotype[mode];
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
new SaveLoadWindow(sld, mode);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void RedrawAutosave()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0));
|
|
|
|
}
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
void SetFiosType(const byte fiostype)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
switch (fiostype) {
|
2005-10-23 13:04:44 +00:00
|
|
|
case FIOS_TYPE_FILE:
|
|
|
|
case FIOS_TYPE_SCENARIO:
|
|
|
|
_file_to_saveload.mode = SL_LOAD;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FIOS_TYPE_OLDFILE:
|
|
|
|
case FIOS_TYPE_OLD_SCENARIO:
|
|
|
|
_file_to_saveload.mode = SL_OLD_LOAD;
|
|
|
|
break;
|
|
|
|
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
#ifdef WITH_PNG
|
|
|
|
case FIOS_TYPE_PNG:
|
|
|
|
_file_to_saveload.mode = SL_PNG;
|
|
|
|
break;
|
|
|
|
#endif /* WITH_PNG */
|
|
|
|
|
|
|
|
case FIOS_TYPE_BMP:
|
|
|
|
_file_to_saveload.mode = SL_BMP;
|
|
|
|
break;
|
|
|
|
|
2005-10-23 13:04:44 +00:00
|
|
|
default:
|
|
|
|
_file_to_saveload.mode = SL_INVALID;
|
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|