Files
@ r15299:e6783715e418
Branch filter:
Location: cpp/openttd-patchpack/source/src/fios_gui.cpp - annotation
r15299:e6783715e418
17.2 KiB
text/x-c
(svn r19950) -Update from WebTranslator v3.0:
french - 35 changes by ElNounch
indonesian - 28 changes by prof
irish - 58 changes by tem
french - 35 changes by ElNounch
indonesian - 28 changes by prof
irish - 58 changes by tem
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 | r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15288:c9665f6c8c50 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 r15272:17705bac0153 | /* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file fios_gui.cpp GUIs for loading/saving games, scenarios, heightmaps, ... */
#include "stdafx.h"
#include "openttd.h"
#include "saveload/saveload.h"
#include "gui.h"
#include "gfx_func.h"
#include "command_func.h"
#include "network/network.h"
#include "network/network_content.h"
#include "strings_func.h"
#include "fileio_func.h"
#include "fios.h"
#include "window_func.h"
#include "tilehighlight_func.h"
#include "querystring_gui.h"
#include "engine_func.h"
#include "table/sprites.h"
#include "table/strings.h"
SaveLoadDialogMode _saveload_mode;
static bool _fios_path_changed;
static bool _savegame_sort_dirty;
enum SaveLoadWindowWidgets {
SLWW_WINDOWTITLE,
SLWW_SORT_BYNAME,
SLWW_SORT_BYDATE,
SLWW_BACKGROUND,
SLWW_FILE_BACKGROUND,
SLWW_HOME_BUTTON,
SLWW_DRIVES_DIRECTORIES_LIST,
SLWW_SCROLLBAR,
SLWW_CONTENT_DOWNLOAD, ///< only available for play scenario/heightmap (content download)
SLWW_SAVE_OSK_TITLE, ///< only available for save operations
SLWW_DELETE_SELECTION, ///< same in here
SLWW_SAVE_GAME, ///< not to mention in here too
SLWW_CONTENT_DOWNLOAD_SEL, ///< Selection 'stack' to 'hide' the content download
};
static const NWidgetPart _nested_load_dialog_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY, SLWW_WINDOWTITLE),
EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_SORT_BYNAME), SetDataTip(STR_SORT_BY_CAPTION_NAME, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_SORT_BYDATE), SetDataTip(STR_SORT_BY_CAPTION_DATE, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, SLWW_BACKGROUND), SetFill(1, 0), SetResize(1, 0), EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, SLWW_FILE_BACKGROUND),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_VERTICAL),
NWidget(WWT_INSET, COLOUR_GREY, SLWW_DRIVES_DIRECTORIES_LIST), SetFill(1, 1), SetPadding(2, 1, 2, 2),
SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), EndContainer(),
NWidget(NWID_SELECTION, INVALID_COLOUR, SLWW_CONTENT_DOWNLOAD_SEL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_CONTENT_DOWNLOAD), SetResize(1, 0),
SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
EndContainer(),
EndContainer(),
NWidget(NWID_VERTICAL),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, SLWW_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON),
NWidget(WWT_SCROLLBAR, COLOUR_GREY, SLWW_SCROLLBAR),
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
EndContainer(),
EndContainer(),
EndContainer(),
};
static const NWidgetPart _nested_save_dialog_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY, SLWW_WINDOWTITLE),
EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_SORT_BYNAME), SetDataTip(STR_SORT_BY_CAPTION_NAME, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_SORT_BYDATE), SetDataTip(STR_SORT_BY_CAPTION_DATE, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, SLWW_BACKGROUND), SetFill(1, 0), SetResize(1, 0), EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, SLWW_FILE_BACKGROUND),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_INSET, COLOUR_GREY, SLWW_DRIVES_DIRECTORIES_LIST), SetPadding(2, 1, 0, 2),
SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), EndContainer(),
NWidget(NWID_VERTICAL),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, SLWW_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON),
NWidget(WWT_SCROLLBAR, COLOUR_GREY, SLWW_SCROLLBAR),
EndContainer(),
EndContainer(),
NWidget(WWT_EDITBOX, COLOUR_GREY, SLWW_SAVE_OSK_TITLE), SetPadding(3, 2, 2, 2), SetFill(1, 0), SetResize(1, 0),
SetDataTip(STR_SAVELOAD_OSKTITLE, STR_SAVELOAD_EDITBOX_TOOLTIP),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_DELETE_SELECTION), SetDataTip(STR_SAVELOAD_DELETE_BUTTON, STR_SAVELOAD_DELETE_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_SAVE_GAME), SetDataTip(STR_SAVELOAD_SAVE_BUTTON, STR_SAVELOAD_SAVE_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
EndContainer(),
};
/* Colours for fios types */
const TextColour _fios_colours[] = {
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
};
void BuildFileList()
{
_fios_path_changed = true;
FiosFreeSavegameList();
switch (_saveload_mode) {
case SLD_NEW_GAME:
case SLD_LOAD_SCENARIO:
case SLD_SAVE_SCENARIO:
FiosGetScenarioList(_saveload_mode); break;
case SLD_LOAD_HEIGHTMAP:
FiosGetHeightmapList(_saveload_mode); break;
default: FiosGetSavegameList(_saveload_mode); break;
}
}
static void MakeSortedSaveGameList()
{
uint sort_start = 0;
uint sort_end = 0;
/* 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
*/
for (const FiosItem *item = _fios_items.Begin(); item != _fios_items.End(); item++) {
switch (item->type) {
case FIOS_TYPE_DIR: sort_start++; break;
case FIOS_TYPE_PARENT: sort_start++; break;
case FIOS_TYPE_DRIVE: sort_end++; break;
default: break;
}
}
uint s_amount = _fios_items.Length() - sort_start - sort_end;
QSortT(_fios_items.Get(sort_start), s_amount, CompareFiosItems);
}
struct SaveLoadWindow : public QueryStringBaseWindow {
private:
FiosItem o_dir;
public:
void GenerateFileName()
{
GenerateDefaultSaveName(this->edit_str_buf, &this->edit_str_buf[this->edit_str_size - 1]);
}
SaveLoadWindow(const WindowDesc *desc, SaveLoadDialogMode mode) : QueryStringBaseWindow(64)
{
static const StringID saveload_captions[] = {
STR_SAVELOAD_LOAD_CAPTION,
STR_SAVELOAD_LOAD_SCENARIO,
STR_SAVELOAD_SAVE_CAPTION,
STR_SAVELOAD_SAVE_SCENARIO,
STR_SAVELOAD_LOAD_HEIGHTMAP,
};
assert((uint)mode < lengthof(saveload_captions));
/* Use an array to define what will be the current file type being handled
* by current file mode */
switch (mode) {
case SLD_SAVE_GAME: this->GenerateFileName(); break;
case SLD_SAVE_SCENARIO: strecpy(this->edit_str_buf, "UNNAMED", &this->edit_str_buf[edit_str_size - 1]); break;
default: break;
}
this->afilter = CS_ALPHANUMERAL;
InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, 240);
this->CreateNestedTree(desc);
if (mode == SLD_LOAD_GAME) this->GetWidget<NWidgetStacked>(SLWW_CONTENT_DOWNLOAD_SEL)->SetDisplayedPlane(SZSP_HORIZONTAL);
this->GetWidget<NWidgetCore>(SLWW_WINDOWTITLE)->widget_data = saveload_captions[mode];
this->FinishInitNested(desc, 0);
this->LowerWidget(SLWW_DRIVES_DIRECTORIES_LIST);
/* pause is only used in single-player, non-editor mode, non-menu mode. It
* will be unpaused in the WE_DESTROY event handler. */
if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) {
DoCommandP(0, PM_PAUSED_SAVELOAD, 1, CMD_PAUSE);
}
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0);
BuildFileList();
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:
strecpy(o_dir.name, _personal_dir, lastof(o_dir.name));
}
/* 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);
}
}
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) {
DoCommandP(0, PM_PAUSED_SAVELOAD, 0, CMD_PAUSE);
}
FiosFreeSavegameList();
}
virtual void DrawWidget(const Rect &r, int widget) const
{
switch (widget) {
case SLWW_SORT_BYNAME:
case SLWW_SORT_BYDATE:
if (((_savegame_sort_order & SORT_BY_NAME) != 0) == (widget == SLWW_SORT_BYNAME)) {
this->DrawSortButtonState(widget, _savegame_sort_order & SORT_DESCENDING ? SBS_DOWN : SBS_UP);
}
break;
case SLWW_BACKGROUND: {
static const char *path = NULL;
static StringID str = STR_ERROR_UNABLE_TO_READ_DRIVE;
static uint64 tot = 0;
if (_fios_path_changed) {
str = FiosGetDescText(&path, &tot);
_fios_path_changed = false;
}
if (str != STR_ERROR_UNABLE_TO_READ_DRIVE) SetDParam(0, tot);
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP, str);
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, path, TC_BLACK);
} break;
case SLWW_DRIVES_DIRECTORIES_LIST: {
GfxFillRect(r.left + 1, r.top + 1, r.right, r.bottom, 0xD7);
uint y = r.top + WD_FRAMERECT_TOP;
for (uint pos = this->vscroll.GetPosition(); pos < _fios_items.Length(); pos++) {
const FiosItem *item = _fios_items.Get(pos);
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, item->title, _fios_colours[item->type]);
y += this->resize.step_height;
if (y >= this->vscroll.GetCapacity() * this->resize.step_height + r.top + WD_FRAMERECT_TOP) break;
}
} break;
}
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{
switch (widget) {
case SLWW_BACKGROUND:
size->height = 2 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
break;
case SLWW_DRIVES_DIRECTORIES_LIST:
resize->height = FONT_HEIGHT_NORMAL;
size->height = resize->height * 10 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
break;
}
}
virtual void OnPaint()
{
if (_savegame_sort_dirty) {
_savegame_sort_dirty = false;
MakeSortedSaveGameList();
}
this->vscroll.SetCount(_fios_items.Length());
this->DrawWidgets();
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
this->DrawEditBox(SLWW_SAVE_OSK_TITLE);
}
}
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case SLWW_SORT_BYNAME: // Sort save names by name
_savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ?
SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME;
_savegame_sort_dirty = true;
this->SetDirty();
break;
case SLWW_SORT_BYDATE: // Sort save names by date
_savegame_sort_order = (_savegame_sort_order == SORT_BY_DATE) ?
SORT_BY_DATE | SORT_DESCENDING : SORT_BY_DATE;
_savegame_sort_dirty = true;
this->SetDirty();
break;
case SLWW_HOME_BUTTON: // OpenTTD 'button', jumps to OpenTTD directory
FiosBrowseTo(&o_dir);
this->SetDirty();
BuildFileList();
break;
case SLWW_DRIVES_DIRECTORIES_LIST: { // Click the listbox
int y = (pt.y - this->GetWidget<NWidgetBase>(SLWW_DRIVES_DIRECTORIES_LIST)->pos_y - WD_FRAMERECT_TOP) / this->resize.step_height;
if (y < 0 || (y += this->vscroll.GetPosition()) >= this->vscroll.GetCount()) return;
const FiosItem *file = _fios_items.Get(y);
const char *name = FiosBrowseTo(file);
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);
strecpy(_file_to_saveload.name, name, lastof(_file_to_saveload.name));
strecpy(_file_to_saveload.title, file->title, lastof(_file_to_saveload.title));
delete this;
} else if (_saveload_mode == SLD_LOAD_HEIGHTMAP) {
SetFiosType(file->type);
strecpy(_file_to_saveload.name, name, lastof(_file_to_saveload.name));
strecpy(_file_to_saveload.title, file->title, lastof(_file_to_saveload.title));
delete this;
ShowHeightmapLoad();
} else {
/* SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox */
ttd_strlcpy(this->text.buf, file->title, this->text.maxsize);
UpdateTextBufferSize(&this->text);
this->SetWidgetDirty(SLWW_SAVE_OSK_TITLE);
}
} else {
/* Changed directory, need repaint. */
this->SetDirty();
BuildFileList();
}
break;
}
case SLWW_CONTENT_DOWNLOAD:
if (!_network_available) {
ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
} 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;
case SLWW_DELETE_SELECTION: case SLWW_SAVE_GAME: // Delete, Save game
break;
}
}
virtual void OnMouseLoop()
{
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
this->HandleEditBox(SLWW_SAVE_OSK_TITLE);
}
}
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
{
if (keycode == WKC_ESC) {
delete this;
return ES_HANDLED;
}
EventState state = ES_NOT_HANDLED;
if ((_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) &&
this->HandleEditBoxKey(SLWW_SAVE_OSK_TITLE, key, keycode, state) == HEBR_CONFIRM) {
this->HandleButtonClick(SLWW_SAVE_GAME);
}
return state;
}
virtual void OnTimeout()
{
/* This test protects against using widgets 11 and 12 which are only available
* in those two saveload mode */
if (!(_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO)) return;
if (this->IsWidgetLowered(SLWW_DELETE_SELECTION)) { // Delete button clicked
if (!FiosDelete(this->text.buf)) {
ShowErrorMessage(STR_ERROR_UNABLE_TO_DELETE_FILE, INVALID_STRING_ID, WL_ERROR);
} else {
BuildFileList();
/* Reset file name to current date on successful delete */
if (_saveload_mode == SLD_SAVE_GAME) GenerateFileName();
}
UpdateTextBufferSize(&this->text);
this->SetDirty();
} else if (this->IsWidgetLowered(SLWW_SAVE_GAME)) { // Save button clicked
_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();
}
}
virtual void OnResize()
{
this->vscroll.SetCapacityFromWidget(this, SLWW_DRIVES_DIRECTORIES_LIST);
}
virtual void OnInvalidateData(int data)
{
BuildFileList();
}
};
static const WindowDesc _load_dialog_desc(
WDP_CENTER, 257, 294,
WC_SAVELOAD, WC_NONE,
WDF_UNCLICK_BUTTONS,
_nested_load_dialog_widgets, lengthof(_nested_load_dialog_widgets)
);
static const WindowDesc _save_dialog_desc(
WDP_CENTER, 257, 320,
WC_SAVELOAD, WC_NONE,
WDF_UNCLICK_BUTTONS,
_nested_save_dialog_widgets, lengthof(_nested_save_dialog_widgets)
);
/** 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
};
void ShowSaveLoadDialog(SaveLoadDialogMode mode)
{
DeleteWindowById(WC_SAVELOAD, 0);
const WindowDesc *sld;
switch (mode) {
case SLD_SAVE_GAME:
case SLD_SAVE_SCENARIO:
sld = &_save_dialog_desc; break;
default:
sld = &_load_dialog_desc; break;
}
_saveload_mode = mode;
_file_to_saveload.filetype = _file_modetotype[mode];
new SaveLoadWindow(sld, mode);
}
void SetFiosType(const byte fiostype)
{
switch (fiostype) {
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;
#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;
default:
_file_to_saveload.mode = SL_INVALID;
break;
}
}
|