2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
2005-06-02 19:30:21 +00:00
|
|
|
#include "openttd.h"
|
2004-11-25 10:47:30 +00:00
|
|
|
#include "table/strings.h"
|
2006-10-24 13:20:54 +00:00
|
|
|
#include "table/sprites.h"
|
2005-07-22 07:02:20 +00:00
|
|
|
#include "functions.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "window.h"
|
|
|
|
#include "gui.h"
|
|
|
|
#include "gfx.h"
|
|
|
|
#include "player.h"
|
2004-12-04 17:54:56 +00:00
|
|
|
#include "network.h"
|
2005-07-21 22:15:02 +00:00
|
|
|
#include "variables.h"
|
2006-05-22 09:59:09 +00:00
|
|
|
#include "settings.h"
|
(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
|
|
|
#include "heightmap.h"
|
|
|
|
#include "genworld.h"
|
2006-10-12 14:59:27 +00:00
|
|
|
#include "network_gui.h"
|
2006-12-04 14:27:54 +00:00
|
|
|
#include "newgrf.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
static const Widget _select_game_widgets[] = {
|
2006-08-22 14:38:37 +00:00
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 13, 0, 335, 0, 13, STR_0307_OPENTTD, STR_NULL},
|
2006-12-04 14:27:54 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 13, 0, 335, 14, 194, 0x0, STR_NULL},
|
2006-08-22 14:38:37 +00:00
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 22, 33, STR_0140_NEW_GAME, STR_02FB_START_A_NEW_GAME},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 22, 33, STR_0141_LOAD_GAME, STR_02FC_LOAD_A_SAVED_GAME},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 40, 51, STR_029A_PLAY_SCENARIO, STR_0303_START_A_NEW_GAME_USING},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 40, 51, STR_PLAY_HEIGHTMAP, STR_PLAY_HEIGHTMAP_HINT},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 58, 69, STR_0220_CREATE_SCENARIO, STR_02FE_CREATE_A_CUSTOMIZED_GAME},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 58, 69, STR_MULTIPLAYER, STR_0300_SELECT_MULTIPLAYER_GAME},
|
|
|
|
|
2006-10-24 14:15:17 +00:00
|
|
|
{ WWT_IMGBTN_2, RESIZE_NONE, 12, 10, 86, 77, 131, SPR_SELECT_TEMPERATE, STR_030E_SELECT_TEMPERATE_LANDSCAPE},
|
|
|
|
{ WWT_IMGBTN_2, RESIZE_NONE, 12, 90, 166, 77, 131, SPR_SELECT_SUB_ARCTIC, STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE},
|
|
|
|
{ WWT_IMGBTN_2, RESIZE_NONE, 12, 170, 246, 77, 131, SPR_SELECT_SUB_TROPICAL, STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE},
|
|
|
|
{ WWT_IMGBTN_2, RESIZE_NONE, 12, 250, 326, 77, 131, SPR_SELECT_TOYLAND, STR_0311_SELECT_TOYLAND_LANDSCAPE},
|
2006-08-22 14:38:37 +00:00
|
|
|
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 139, 150, STR_0148_GAME_OPTIONS, STR_0301_DISPLAY_GAME_OPTIONS},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 139, 150, STR_01FE_DIFFICULTY, STR_0302_DISPLAY_DIFFICULTY_OPTIONS},
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 157, 168, STR_CONFIG_PATCHES, STR_CONFIG_PATCHES_TIP},
|
2006-12-04 14:27:54 +00:00
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 157, 168, STR_NEWGRF_SETTINGS_BUTTON, STR_NULL},
|
|
|
|
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 175, 186, STR_0304_QUIT, STR_0305_QUIT_OPENTTD},
|
2006-10-24 14:15:17 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
extern void HandleOnEditText(WindowEvent *e);
|
|
|
|
|
2005-05-12 00:18:30 +00:00
|
|
|
static inline void SetNewLandscapeType(byte landscape)
|
|
|
|
{
|
|
|
|
_opt_newgame.landscape = landscape;
|
|
|
|
InvalidateWindowClasses(WC_SELECT_GAME);
|
|
|
|
}
|
|
|
|
|
2005-04-20 12:52:02 +00:00
|
|
|
static void SelectGameWndProc(Window *w, WindowEvent *e)
|
|
|
|
{
|
|
|
|
switch (e->event) {
|
2006-10-03 20:16:20 +00:00
|
|
|
case WE_CREATE: LowerWindowWidget(w, _opt_newgame.landscape + 8); break;
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_PAINT:
|
2006-10-04 19:11:43 +00:00
|
|
|
SetWindowWidgetLoweredState(w, 8, _opt_newgame.landscape == LT_NORMAL);
|
|
|
|
SetWindowWidgetLoweredState(w, 9, _opt_newgame.landscape == LT_HILLY);
|
|
|
|
SetWindowWidgetLoweredState(w, 10, _opt_newgame.landscape == LT_DESERT);
|
|
|
|
SetWindowWidgetLoweredState(w, 11, _opt_newgame.landscape == LT_CANDY);
|
2005-03-12 21:21:47 +00:00
|
|
|
SetDParam(0, STR_6801_EASY + _opt_newgame.diff_level);
|
2004-08-09 17:04:08 +00:00
|
|
|
DrawWindowWidgets(w);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_CLICK:
|
2006-09-23 02:39:24 +00:00
|
|
|
switch (e->we.click.widget) {
|
(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 2: ShowGenerateLandscape(); break;
|
2004-08-09 17:04:08 +00:00
|
|
|
case 3: ShowSaveLoadDialog(SLD_LOAD_GAME); 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 4: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break;
|
|
|
|
case 5: ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP); break;
|
|
|
|
case 6: ShowCreateScenario(); break;
|
|
|
|
case 7:
|
2004-08-22 10:23:37 +00:00
|
|
|
if (!_network_available) {
|
2005-12-13 21:21:57 +00:00
|
|
|
ShowErrorMessage(INVALID_STRING_ID, STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
|
2006-06-27 21:25:53 +00:00
|
|
|
} else {
|
2004-09-06 22:46:02 +00:00
|
|
|
ShowNetworkGameWindow();
|
2006-06-27 21:25:53 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
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 8: case 9: case 10: case 11:
|
2006-10-03 20:16:20 +00:00
|
|
|
RaiseWindowWidget(w, _opt_newgame.landscape + 8);
|
2006-09-23 02:39:24 +00:00
|
|
|
SetNewLandscapeType(e->we.click.widget - 8);
|
(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
|
|
|
break;
|
|
|
|
case 12: ShowGameOptions(); break;
|
|
|
|
case 13: ShowGameDifficulty(); break;
|
|
|
|
case 14: ShowPatchesSelection(); break;
|
2006-12-04 14:27:54 +00:00
|
|
|
case 15: ShowNewGRFSettings(true, true, &_grfconfig_newgame); break;
|
|
|
|
case 16: HandleExitGameRequest(); break;
|
2005-04-20 12:52:02 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-08-19 19:45:04 +00:00
|
|
|
|
|
|
|
case WE_ON_EDIT_TEXT: HandleOnEditText(e); break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const WindowDesc _select_game_desc = {
|
2006-12-04 14:27:54 +00:00
|
|
|
WDP_CENTER, WDP_CENTER, 336, 195,
|
2004-08-09 17:04:08 +00:00
|
|
|
WC_SELECT_GAME,0,
|
|
|
|
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
|
|
|
|
_select_game_widgets,
|
|
|
|
SelectGameWndProc
|
|
|
|
};
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
void ShowSelectGameWindow(void)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
AllocateWindowDesc(&_select_game_desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const Widget _ask_abandon_game_widgets[] = {
|
2005-12-07 15:48:52 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
2005-04-02 12:01:25 +00:00
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 4, 11, 179, 0, 13, STR_00C7_QUIT, STR_NULL},
|
2006-10-24 14:15:17 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 4, 0, 179, 14, 91, 0x0, STR_NULL},
|
2005-04-02 12:01:25 +00:00
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 12, 25, 84, 72, 83, STR_00C9_NO, STR_NULL},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 12, 95, 154, 72, 83, STR_00C8_YES, STR_NULL},
|
|
|
|
{ WIDGETS_END },
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2006-07-26 03:33:12 +00:00
|
|
|
static void AskAbandonGameWndProc(Window *w, WindowEvent *e)
|
2005-11-14 19:48:04 +00:00
|
|
|
{
|
|
|
|
switch (e->event) {
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_PAINT:
|
|
|
|
DrawWindowWidgets(w);
|
|
|
|
#if defined(_WIN32)
|
2004-12-02 22:53:07 +00:00
|
|
|
SetDParam(0, STR_0133_WINDOWS);
|
2004-08-09 17:04:08 +00:00
|
|
|
#elif defined(__APPLE__)
|
2004-12-02 22:53:07 +00:00
|
|
|
SetDParam(0, STR_0135_OSX);
|
2004-08-09 17:04:08 +00:00
|
|
|
#elif defined(__BEOS__)
|
2004-12-02 22:53:07 +00:00
|
|
|
SetDParam(0, STR_OSNAME_BEOS);
|
2004-08-09 17:04:08 +00:00
|
|
|
#elif defined(__MORPHOS__)
|
2004-12-02 22:53:07 +00:00
|
|
|
SetDParam(0, STR_OSNAME_MORPHOS);
|
2005-01-03 19:45:18 +00:00
|
|
|
#elif defined(__AMIGA__)
|
2004-12-10 15:12:48 +00:00
|
|
|
SetDParam(0, STR_OSNAME_AMIGAOS);
|
2004-12-27 10:40:04 +00:00
|
|
|
#elif defined(__OS2__)
|
|
|
|
SetDParam(0, STR_OSNAME_OS2);
|
2004-08-09 17:04:08 +00:00
|
|
|
#else
|
2004-12-02 22:53:07 +00:00
|
|
|
SetDParam(0, STR_0134_UNIX);
|
2004-08-09 17:04:08 +00:00
|
|
|
#endif
|
2005-11-14 19:48:04 +00:00
|
|
|
DrawStringMultiCenter(90, 38, STR_00CA_ARE_YOU_SURE_YOU_WANT_TO, 178);
|
2004-08-09 17:04:08 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case WE_CLICK:
|
2006-09-23 02:39:24 +00:00
|
|
|
switch (e->we.click.widget) {
|
2005-11-13 14:54:09 +00:00
|
|
|
case 3: DeleteWindow(w); break;
|
|
|
|
case 4: _exit_game = true; break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
break;
|
2005-11-13 14:54:09 +00:00
|
|
|
|
2004-09-06 16:21:35 +00:00
|
|
|
case WE_KEYPRESS: /* Exit game on pressing 'Enter' */
|
2006-09-23 02:39:24 +00:00
|
|
|
switch (e->we.keypress.keycode) {
|
2005-11-13 14:54:09 +00:00
|
|
|
case WKC_RETURN:
|
|
|
|
case WKC_NUM_ENTER:
|
|
|
|
_exit_game = true;
|
|
|
|
break;
|
|
|
|
}
|
2004-09-10 19:02:27 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const WindowDesc _ask_abandon_game_desc = {
|
|
|
|
WDP_CENTER, WDP_CENTER, 180, 92,
|
|
|
|
WC_ASK_ABANDON_GAME,0,
|
|
|
|
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS,
|
|
|
|
_ask_abandon_game_widgets,
|
|
|
|
AskAbandonGameWndProc
|
|
|
|
};
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
void AskExitGame(void)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
AllocateWindowDescFront(&_ask_abandon_game_desc, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const Widget _ask_quit_game_widgets[] = {
|
2005-12-07 15:48:52 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
2005-04-02 12:01:25 +00:00
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 4, 11, 179, 0, 13, STR_0161_QUIT_GAME, STR_NULL},
|
2006-10-24 14:15:17 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 4, 0, 179, 14, 91, 0x0, STR_NULL},
|
2005-04-02 12:01:25 +00:00
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 12, 25, 84, 72, 83, STR_00C9_NO, STR_NULL},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 12, 95, 154, 72, 83, STR_00C8_YES, STR_NULL},
|
|
|
|
{ WIDGETS_END },
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2006-07-26 03:33:12 +00:00
|
|
|
static void AskQuitGameWndProc(Window *w, WindowEvent *e)
|
2005-11-14 19:48:04 +00:00
|
|
|
{
|
|
|
|
switch (e->event) {
|
|
|
|
case WE_PAINT:
|
|
|
|
DrawWindowWidgets(w);
|
|
|
|
DrawStringMultiCenter(
|
|
|
|
90, 38,
|
|
|
|
_game_mode != GM_EDITOR ?
|
|
|
|
STR_0160_ARE_YOU_SURE_YOU_WANT_TO : STR_029B_ARE_YOU_SURE_YOU_WANT_TO,
|
|
|
|
178
|
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
break;
|
2004-12-15 11:42:05 +00:00
|
|
|
|
2005-11-14 19:48:04 +00:00
|
|
|
case WE_CLICK:
|
2006-09-23 02:39:24 +00:00
|
|
|
switch (e->we.click.widget) {
|
2005-11-14 19:48:04 +00:00
|
|
|
case 3: DeleteWindow(w); break;
|
|
|
|
case 4: _switch_mode = SM_MENU; break;
|
|
|
|
}
|
|
|
|
break;
|
2004-12-15 11:42:05 +00:00
|
|
|
|
2005-11-14 19:48:04 +00:00
|
|
|
case WE_KEYPRESS: /* Return to main menu on pressing 'Enter' */
|
2006-09-23 02:39:24 +00:00
|
|
|
if (e->we.keypress.keycode == WKC_RETURN) _switch_mode = SM_MENU;
|
2005-11-14 19:48:04 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const WindowDesc _ask_quit_game_desc = {
|
|
|
|
WDP_CENTER, WDP_CENTER, 180, 92,
|
|
|
|
WC_QUIT_GAME,0,
|
|
|
|
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS,
|
|
|
|
_ask_quit_game_widgets,
|
|
|
|
AskQuitGameWndProc
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
void AskExitToGameMenu(void)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
AllocateWindowDescFront(&_ask_quit_game_desc, 0);
|
|
|
|
}
|