(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
prefix with GRF.
This commit is contained in:
		@@ -6,6 +6,7 @@
 | 
				
			|||||||
#include "macros.h"
 | 
					#include "macros.h"
 | 
				
			||||||
#include "debug.h"
 | 
					#include "debug.h"
 | 
				
			||||||
#include "variables.h"
 | 
					#include "variables.h"
 | 
				
			||||||
 | 
					#include "string.h"
 | 
				
			||||||
#include "saveload.h"
 | 
					#include "saveload.h"
 | 
				
			||||||
#include "md5.h"
 | 
					#include "md5.h"
 | 
				
			||||||
#include "newgrf.h"
 | 
					#include "newgrf.h"
 | 
				
			||||||
@@ -261,6 +262,22 @@ const GRFConfig *GetGRFConfig(uint32 grfid)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Build a space separated list of parameters, and terminate */
 | 
				
			||||||
 | 
					char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						uint i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* Return an empty string if there are no parameters */
 | 
				
			||||||
 | 
						if (c->num_params == 0) return strecpy(dst, "", last);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (i = 0; i < c->num_params; i++) {
 | 
				
			||||||
 | 
							if (i > 0) dst = strecpy(dst, " ", last);
 | 
				
			||||||
 | 
							dst += snprintf(dst, last - dst, "%d", c->param[i]);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return dst;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const SaveLoad _grfconfig_desc[] = {
 | 
					static const SaveLoad _grfconfig_desc[] = {
 | 
				
			||||||
	SLE_STR(GRFConfig, filename,   SLE_STR, 0x40),
 | 
						SLE_STR(GRFConfig, filename,   SLE_STR, 0x40),
 | 
				
			||||||
	SLE_VAR(GRFConfig, grfid,      SLE_UINT32),
 | 
						SLE_VAR(GRFConfig, grfid,      SLE_UINT32),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,6 +40,7 @@ void ClearGRFConfigList(GRFConfig *config);
 | 
				
			|||||||
void ResetGRFConfig(bool defaults);
 | 
					void ResetGRFConfig(bool defaults);
 | 
				
			||||||
bool IsGoodGRFConfigList(void);
 | 
					bool IsGoodGRFConfigList(void);
 | 
				
			||||||
bool FillGRFDetails(GRFConfig *config);
 | 
					bool FillGRFDetails(GRFConfig *config);
 | 
				
			||||||
 | 
					char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* In newgrf_gui.c */
 | 
					/* In newgrf_gui.c */
 | 
				
			||||||
void ShowNewGRFSettings(bool editable, bool show_params, GRFConfig **config);
 | 
					void ShowNewGRFSettings(bool editable, bool show_params, GRFConfig **config);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										21
									
								
								newgrf_gui.c
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								newgrf_gui.c
									
									
									
									
									
								
							@@ -7,28 +7,11 @@
 | 
				
			|||||||
#include "gfx.h"
 | 
					#include "gfx.h"
 | 
				
			||||||
#include "gui.h"
 | 
					#include "gui.h"
 | 
				
			||||||
#include "window.h"
 | 
					#include "window.h"
 | 
				
			||||||
#include "strings.h"
 | 
					 | 
				
			||||||
#include "table/strings.h"
 | 
					#include "table/strings.h"
 | 
				
			||||||
#include "table/sprites.h"
 | 
					#include "table/sprites.h"
 | 
				
			||||||
#include "newgrf_config.h"
 | 
					#include "newgrf_config.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Build a space separated list of parameters, and terminate */
 | 
					 | 
				
			||||||
static char *BuildParamList(char *dst, const GRFConfig *c, const char *last)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	uint i;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* Return an empty string if there are no parameters */
 | 
					 | 
				
			||||||
	if (c->num_params == 0) return strecpy(dst, "", last);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for (i = 0; i < c->num_params; i++) {
 | 
					 | 
				
			||||||
		if (i > 0) dst = strecpy(dst, " ", last);
 | 
					 | 
				
			||||||
		dst += snprintf(dst, last - dst, "%d", c->param[i]);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return dst;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** Parse an integerlist string and set each found value
 | 
					/** Parse an integerlist string and set each found value
 | 
				
			||||||
 * @param p the string to be parsed. Each element in the list is seperated by a
 | 
					 * @param p the string to be parsed. Each element in the list is seperated by a
 | 
				
			||||||
 * comma or a space character
 | 
					 * comma or a space character
 | 
				
			||||||
@@ -80,7 +63,7 @@ static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint w, bool show
 | 
				
			|||||||
	/* Show GRF parameter list */
 | 
						/* Show GRF parameter list */
 | 
				
			||||||
	if (show_params) {
 | 
						if (show_params) {
 | 
				
			||||||
		if (c->num_params > 0) {
 | 
							if (c->num_params > 0) {
 | 
				
			||||||
			BuildParamList(buff, c, lastof(buff));
 | 
								GRFBuildParamList(buff, c, lastof(buff));
 | 
				
			||||||
			SetDParamStr(0, buff);
 | 
								SetDParamStr(0, buff);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			SetDParam(0, STR_01A9_NONE);
 | 
								SetDParam(0, STR_01A9_NONE);
 | 
				
			||||||
@@ -401,7 +384,7 @@ static void NewGRFWndProc(Window *w, WindowEvent *e)
 | 
				
			|||||||
					char buff[512];
 | 
										char buff[512];
 | 
				
			||||||
					if (WP(w, newgrf_d).sel == NULL) break;
 | 
										if (WP(w, newgrf_d).sel == NULL) break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					BuildParamList(buff, WP(w, newgrf_d).sel, lastof(buff));
 | 
										GRFBuildParamList(buff, WP(w, newgrf_d).sel, lastof(buff));
 | 
				
			||||||
					ShowQueryString(BindCString(buff), STR_NEWGRF_PARAMETER_QUERY, 63, 250, w->window_class, w->window_number, CS_ALPHANUMERAL);
 | 
										ShowQueryString(BindCString(buff), STR_NEWGRF_PARAMETER_QUERY, 63, 250, w->window_class, w->window_number, CS_ALPHANUMERAL);
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user