(svn r1680) Feature: Replace train GUI now remembers the railtype selected in the dropdown menu
This commit is contained in:
		
							
								
								
									
										2
									
								
								misc.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								misc.c
									
									
									
									
									
								
							@@ -194,6 +194,8 @@ void InitializeGame(void)
 | 
				
			|||||||
	for (i = 0; i < lengthof(_autoreplace_array); i++)
 | 
						for (i = 0; i < lengthof(_autoreplace_array); i++)
 | 
				
			||||||
		_autoreplace_array[i] = i;
 | 
							_autoreplace_array[i] = i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_railtype_selected_in_replace_gui = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	AddTypeToEngines(); // make sure all engines have a type
 | 
						AddTypeToEngines(); // make sure all engines have a type
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SetObjectToPlace(1, 0, 0, 0);
 | 
						SetObjectToPlace(1, 0, 0, 0);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -434,6 +434,7 @@ VARDEF byte _vehicle_design_names;
 | 
				
			|||||||
/* Autoreplace vehicle stuff*/
 | 
					/* Autoreplace vehicle stuff*/
 | 
				
			||||||
VARDEF byte _autoreplace_array[256];
 | 
					VARDEF byte _autoreplace_array[256];
 | 
				
			||||||
VARDEF uint16 _player_num_engines[256];
 | 
					VARDEF uint16 _player_num_engines[256];
 | 
				
			||||||
 | 
					VARDEF byte _railtype_selected_in_replace_gui;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Debugging levels */
 | 
					/* Debugging levels */
 | 
				
			||||||
VARDEF int _debug_spritecache_level;
 | 
					VARDEF int _debug_spritecache_level;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -373,7 +373,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	switch (WP(w,replaceveh_d).vehicletype) {
 | 
						switch (WP(w,replaceveh_d).vehicletype) {
 | 
				
			||||||
		case VEH_Train: {
 | 
							case VEH_Train: {
 | 
				
			||||||
			railtype = WP(w,replaceveh_d).railtype;
 | 
								railtype = _railtype_selected_in_replace_gui;
 | 
				
			||||||
			w->widget[13].color = _player_colors[_local_player];	// sets the colour of that art thing
 | 
								w->widget[13].color = _player_colors[_local_player];	// sets the colour of that art thing
 | 
				
			||||||
			w->widget[16].color = _player_colors[_local_player];	// sets the colour of that art thing
 | 
								w->widget[16].color = _player_colors[_local_player];	// sets the colour of that art thing
 | 
				
			||||||
			for (engine_id = 0; engine_id < NUM_TRAIN_ENGINES; engine_id++) {
 | 
								for (engine_id = 0; engine_id < NUM_TRAIN_ENGINES; engine_id++) {
 | 
				
			||||||
@@ -524,7 +524,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	switch (WP(w,replaceveh_d).vehicletype) {
 | 
						switch (WP(w,replaceveh_d).vehicletype) {
 | 
				
			||||||
		case VEH_Train: {
 | 
							case VEH_Train: {
 | 
				
			||||||
			byte railtype = WP(w,replaceveh_d).railtype;
 | 
								byte railtype = _railtype_selected_in_replace_gui;
 | 
				
			||||||
			DrawString(157, 89 + (14 * w->vscroll.cap), _rail_types_list[railtype], 0x10);
 | 
								DrawString(157, 89 + (14 * w->vscroll.cap), _rail_types_list[railtype], 0x10);
 | 
				
			||||||
			/* draw sorting criteria string */
 | 
								/* draw sorting criteria string */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -834,7 +834,7 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
 | 
				
			|||||||
						if ( !(HASBIT(DEREF_ENGINE(NUM_NORMAL_RAIL_ENGINES)->player_avail, _local_player)))
 | 
											if ( !(HASBIT(DEREF_ENGINE(NUM_NORMAL_RAIL_ENGINES)->player_avail, _local_player)))
 | 
				
			||||||
							engine_avail = 6;
 | 
												engine_avail = 6;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					ShowDropDownMenu(w, _rail_types_list, WP(w,replaceveh_d).railtype, 15, engine_avail, 1);
 | 
										ShowDropDownMenu(w, _rail_types_list, _railtype_selected_in_replace_gui, 15, engine_avail, 1);
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				case 4: {
 | 
									case 4: {
 | 
				
			||||||
@@ -867,7 +867,7 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
 | 
				
			|||||||
		} break;
 | 
							} break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		case WE_DROPDOWN_SELECT: { /* we have selected a dropdown item in the list */
 | 
							case WE_DROPDOWN_SELECT: { /* we have selected a dropdown item in the list */
 | 
				
			||||||
			WP(w,replaceveh_d).railtype = e->dropdown.index;
 | 
								_railtype_selected_in_replace_gui = e->dropdown.index;
 | 
				
			||||||
			SetWindowDirty(w);
 | 
								SetWindowDirty(w);
 | 
				
			||||||
		} break;
 | 
							} break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								window.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								window.h
									
									
									
									
									
								
							@@ -323,7 +323,6 @@ typedef struct {
 | 
				
			|||||||
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildtrain_d));
 | 
					assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildtrain_d));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
	byte railtype;
 | 
					 | 
				
			||||||
	byte vehicletype;
 | 
						byte vehicletype;
 | 
				
			||||||
	byte sel_index[2];
 | 
						byte sel_index[2];
 | 
				
			||||||
	int16 sel_engine[2];
 | 
						int16 sel_engine[2];
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user