intro_gui.c
changeset 1794 24b4239f2090
parent 1728 ea7210a31593
child 1796 614d996f6be7
equal deleted inserted replaced
1793:b9a37c98b468 1794:24b4239f2090
    43 };
    43 };
    44 
    44 
    45 extern void HandleOnEditText(WindowEvent *e);
    45 extern void HandleOnEditText(WindowEvent *e);
    46 extern void HandleOnEditTextCancel(void);
    46 extern void HandleOnEditTextCancel(void);
    47 
    47 
       
    48 static inline void CreateScenario(void) {_switch_mode = SM_EDITOR;}
       
    49 
       
    50 static inline void SetNewLandscapeType(byte landscape)
       
    51 {
       
    52 	_opt_newgame.landscape = landscape;
       
    53 	InvalidateWindowClasses(WC_SELECT_GAME);
       
    54 }
       
    55 
    48 static void SelectGameWndProc(Window *w, WindowEvent *e)
    56 static void SelectGameWndProc(Window *w, WindowEvent *e)
    49 {
    57 {
    50 	/* We do +/- 6 for the map_xy because 64 is 2^6, but it is the lowest available element */
    58 	/* We do +/- 6 for the map_xy because 64 is 2^6, but it is the lowest available element */
    51 	static const StringID mapsizes[] = {STR_64, STR_128, STR_256, STR_512, STR_1024, STR_2048, INVALID_STRING_ID};
    59 	static const StringID mapsizes[] = {STR_64, STR_128, STR_256, STR_512, STR_1024, STR_2048, INVALID_STRING_ID};
    52 
    60 
    62 		DrawString(283, 121, mapsizes[_patches.map_y - 6], 0x10);
    70 		DrawString(283, 121, mapsizes[_patches.map_y - 6], 0x10);
    63 		break;
    71 		break;
    64 
    72 
    65 	case WE_CLICK:
    73 	case WE_CLICK:
    66 		switch (e->click.widget) {
    74 		switch (e->click.widget) {
    67 		case 2: DoCommandP(0, 0, 0, NULL, CMD_START_NEW_GAME); break;
    75 		case 2: AskForNewGameToStart(); break;
    68 		case 3: ShowSaveLoadDialog(SLD_LOAD_GAME); break;
    76 		case 3: ShowSaveLoadDialog(SLD_LOAD_GAME); break;
    69 		case 4: DoCommandP(0, InteractiveRandom(), 0, NULL, CMD_CREATE_SCENARIO); break;
    77 		case 4: CreateScenario(); break;
    70 		case 5: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break;
    78 		case 5: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break;
    71 		case 6: case 7: case 8: case 9:
    79 		case 6: case 7: case 8: case 9:
    72 			// XXX: Useless usage of the CMD infrastructure?
    80 			SetNewLandscapeType(e->click.widget - 6);
    73 			DoCommandP(0, e->click.widget - 6, 0, NULL, CMD_SET_NEW_LANDSCAPE_TYPE);
       
    74 			break;
    81 			break;
    75 		case 10: case 11: /* Mapsize X */
    82 		case 10: case 11: /* Mapsize X */
    76 			ShowDropDownMenu(w, mapsizes, _patches.map_x - 6, 11, 0, 0);
    83 			ShowDropDownMenu(w, mapsizes, _patches.map_x - 6, 11, 0, 0);
    77 			break;
    84 			break;
    78 		case 12: case 13: /* Mapsize Y */
    85 		case 12: case 13: /* Mapsize Y */
   120 void ShowSelectGameWindow(void)
   127 void ShowSelectGameWindow(void)
   121 {
   128 {
   122 	AllocateWindowDesc(&_select_game_desc);
   129 	AllocateWindowDesc(&_select_game_desc);
   123 }
   130 }
   124 
   131 
   125 
   132 void GenRandomNewGame(uint32 rnd1, uint32 rnd2)
   126 // p1 = mode
   133 {
   127 //    0 - start new game
   134 	_random_seeds[0][0] = rnd1;
   128 //    1 - close new game dialog
   135 	_random_seeds[0][1] = rnd2;
   129 
       
   130 int32 CmdStartNewGame(int x, int y, uint32 flags, uint32 p1, uint32 p2)
       
   131 {
       
   132 	if (!(flags & DC_EXEC))
       
   133 		return 0;
       
   134 
       
   135 	switch(p1) {
       
   136 	case 0: // show select game window
       
   137 		AskForNewGameToStart();
       
   138 		break;
       
   139 	case 1: // close select game window
       
   140 		DeleteWindowById(WC_SAVELOAD, 0);
       
   141 		break;
       
   142 	}
       
   143 
       
   144 	return 0;
       
   145 }
       
   146 
       
   147 int32 CmdGenRandomNewGame(int x, int y, uint32 flags, uint32 p1, uint32 p2)
       
   148 {
       
   149 	if (!(flags & DC_EXEC))
       
   150 		return 0;
       
   151 
       
   152 	// this forces stuff into test mode.
       
   153 	_docommand_recursive = 0;
       
   154 
       
   155 	_random_seeds[0][0] = p1;
       
   156 	_random_seeds[0][1] = p2;
       
   157 
   136 
   158 	SwitchMode(SM_NEWGAME);
   137 	SwitchMode(SM_NEWGAME);
   159 	return 0;
       
   160 }
       
   161 
       
   162 int32 CmdCreateScenario(int x, int y, uint32 flags, uint32 p1, uint32 p2)
       
   163 {
       
   164 	if (!(flags & DC_EXEC))
       
   165 		return 0;
       
   166 
       
   167 	_switch_mode = SM_EDITOR;
       
   168 	return 0;
       
   169 }
   138 }
   170 
   139 
   171 int32 CmdStartScenario(int x, int y, uint32 flags, uint32 p1, uint32 p2)
   140 int32 CmdStartScenario(int x, int y, uint32 flags, uint32 p1, uint32 p2)
   172 {
   141 {
   173 	if (!(flags & DC_EXEC))
   142 	if (!(flags & DC_EXEC))
   295 
   264 
   296 void AskExitToGameMenu(void)
   265 void AskExitToGameMenu(void)
   297 {
   266 {
   298 	AllocateWindowDescFront(&_ask_quit_game_desc, 0);
   267 	AllocateWindowDescFront(&_ask_quit_game_desc, 0);
   299 }
   268 }
   300 
       
   301 int32 CmdSetNewLandscapeType(int x, int y, uint32 flags, uint32 p1, uint32 p2)
       
   302 {
       
   303 	if (flags & DC_EXEC) {
       
   304 		_opt_newgame.landscape = p1;
       
   305 		InvalidateWindowClasses(WC_SELECT_GAME);
       
   306 	}
       
   307 	return 0;
       
   308 }