|
@@ -91,24 +91,28 @@ static void ShowNewGRFInfo(const GRFConf
|
|
|
/* Show GRF parameter list */
|
|
|
if (show_params) {
|
|
|
if (c->num_params > 0) {
|
|
|
GRFBuildParamList(buff, c, lastof(buff));
|
|
|
SetDParam(0, STR_JUST_RAW_STRING);
|
|
|
SetDParamStr(1, buff);
|
|
|
} else {
|
|
|
SetDParam(0, STR_01A9_NONE);
|
|
|
}
|
|
|
y += DrawStringMultiLine(x, y, STR_NEWGRF_PARAMETER, w, bottom - y);
|
|
|
}
|
|
|
|
|
|
/* Draw the palette of the NewGRF */
|
|
|
SetDParamStr(0, c->windows_paletted ? "Windows" : "DOS");
|
|
|
y += DrawStringMultiLine(x, y, STR_NEWGRF_PALETTE, w, bottom - y);
|
|
|
|
|
|
/* Show flags */
|
|
|
if (c->status == GCS_NOT_FOUND) y += DrawStringMultiLine(x, y, STR_NEWGRF_NOT_FOUND, w, bottom - y);
|
|
|
if (c->status == GCS_DISABLED) y += DrawStringMultiLine(x, y, STR_NEWGRF_DISABLED, w, bottom - y);
|
|
|
if (HasBit(c->flags, GCF_COMPATIBLE)) y += DrawStringMultiLine(x, y, STR_NEWGRF_COMPATIBLE_LOADED, w, bottom - y);
|
|
|
|
|
|
/* Draw GRF info if it exists */
|
|
|
if (c->info != NULL && !StrEmpty(c->info)) {
|
|
|
SetDParam(0, STR_JUST_RAW_STRING);
|
|
|
SetDParamStr(1, c->info);
|
|
|
y += DrawStringMultiLine(x, y, STR_02BD, w, bottom - y);
|
|
|
} else {
|
|
|
y += DrawStringMultiLine(x, y, STR_NEWGRF_NO_INFO, w, bottom - y);
|
|
@@ -292,24 +296,25 @@ struct NewGRFWindow : public Window {
|
|
|
SNGRFS_PRESET_LIST,
|
|
|
SNGRFS_PRESET_SAVE,
|
|
|
SNGRFS_PRESET_DELETE,
|
|
|
SNGRFS_BACKGROUND2,
|
|
|
SNGRFS_ADD,
|
|
|
SNGRFS_REMOVE,
|
|
|
SNGRFS_MOVE_UP,
|
|
|
SNGRFS_MOVE_DOWN,
|
|
|
SNGRFS_FILE_LIST,
|
|
|
SNGRFS_SCROLLBAR,
|
|
|
SNGRFS_NEWGRF_INFO,
|
|
|
SNGRFS_SET_PARAMETERS,
|
|
|
SNGRFS_TOGGLE_PALETTE,
|
|
|
SNGRFS_APPLY_CHANGES,
|
|
|
SNGRFS_RESIZE,
|
|
|
};
|
|
|
|
|
|
GRFConfig **orig_list; ///< grf list the window is shown with
|
|
|
GRFConfig *list; ///< temporary grf list to which changes are made
|
|
|
GRFConfig *sel; ///< selected grf item
|
|
|
bool editable; ///< is the window editable
|
|
|
bool show_params; ///< are the grf-parameters shown in the info-panel
|
|
|
bool execute; ///< on pressing 'apply changes' are grf changes applied immediately, or only list is updated
|
|
|
int query_widget; ///< widget that opened a query
|
|
|
int preset; ///< selected preset
|
|
@@ -350,24 +355,25 @@ struct NewGRFWindow : public Window {
|
|
|
const GRFConfig *c;
|
|
|
int i;
|
|
|
|
|
|
for (c = this->list, i = 0; c != NULL; c = c->next, i++) {}
|
|
|
|
|
|
this->vscroll.cap = (this->widget[SNGRFS_FILE_LIST].bottom - this->widget[SNGRFS_FILE_LIST].top) / 14 + 1;
|
|
|
SetVScrollCount(this, i);
|
|
|
|
|
|
this->SetWidgetsDisabledState(!this->editable,
|
|
|
SNGRFS_PRESET_LIST,
|
|
|
SNGRFS_ADD,
|
|
|
SNGRFS_APPLY_CHANGES,
|
|
|
SNGRFS_TOGGLE_PALETTE,
|
|
|
WIDGET_LIST_END
|
|
|
);
|
|
|
}
|
|
|
|
|
|
virtual void OnPaint()
|
|
|
{
|
|
|
bool disable_all = this->sel == NULL || !this->editable;
|
|
|
|
|
|
this->SetWidgetsDisabledState(disable_all,
|
|
|
SNGRFS_REMOVE,
|
|
|
SNGRFS_MOVE_UP,
|
|
|
SNGRFS_MOVE_DOWN,
|
|
@@ -562,24 +568,32 @@ struct NewGRFWindow : public Window {
|
|
|
break;
|
|
|
|
|
|
case SNGRFS_SET_PARAMETERS: { // Edit parameters
|
|
|
if (this->sel == NULL) break;
|
|
|
|
|
|
this->query_widget = widget;
|
|
|
static char buff[512];
|
|
|
GRFBuildParamList(buff, this->sel, lastof(buff));
|
|
|
SetDParamStr(0, buff);
|
|
|
ShowQueryString(STR_JUST_RAW_STRING, STR_NEWGRF_PARAMETER_QUERY, 63, 250, this, CS_ALPHANUMERAL);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
case SNGRFS_TOGGLE_PALETTE: {
|
|
|
if (this->sel != NULL) {
|
|
|
this->sel->windows_paletted ^= true;
|
|
|
this->SetDirty();
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnDropdownSelect(int widget, int index)
|
|
|
{
|
|
|
if (index == -1) {
|
|
|
ClearGRFConfigList(&this->list);
|
|
|
this->preset = -1;
|
|
|
} else {
|
|
|
GRFConfig *c = LoadGRFPresetFromConfig(_grf_preset_list[index]);
|
|
|
|
|
|
if (c != NULL) {
|
|
@@ -656,34 +670,35 @@ static const Widget _newgrf_widgets[] =
|
|
|
{ WWT_CAPTION, RESIZE_RIGHT, COLOUR_MAUVE, 11, 299, 0, 13, STR_NEWGRF_SETTINGS_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS }, // SNGRFS_CAPTION
|
|
|
{ WWT_PANEL, RESIZE_RIGHT, COLOUR_MAUVE, 0, 299, 14, 41, STR_NULL, STR_NULL }, // SNGRFS_BACKGROUND1
|
|
|
{ WWT_DROPDOWN, RESIZE_RIGHT, COLOUR_YELLOW, 10, 103, 16, 27, STR_EMPTY, STR_NEWGRF_PRESET_LIST_TIP }, // SNGRFS_PRESET_LIST
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_LR, COLOUR_YELLOW, 104, 196, 16, 27, STR_NEWGRF_PRESET_SAVE, STR_NEWGRF_PRESET_SAVE_TIP }, // SNGRFS_PRESET_SAVE
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_LR, COLOUR_YELLOW, 197, 289, 16, 27, STR_NEWGRF_PRESET_DELETE, STR_NEWGRF_PRESET_DELETE_TIP }, // SNGRFS_PRESET_DELETE
|
|
|
{ WWT_PANEL, RESIZE_RIGHT, COLOUR_MAUVE, 0, 299, 30, 45, STR_NULL, STR_NULL }, // SNGRFS_BACKGROUND
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_YELLOW, 10, 79, 32, 43, STR_NEWGRF_ADD, STR_NEWGRF_ADD_TIP }, // SNGRFS_ADD
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_YELLOW, 80, 149, 32, 43, STR_NEWGRF_REMOVE, STR_NEWGRF_REMOVE_TIP }, // SNGRFS_REMOVE
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_YELLOW, 150, 219, 32, 43, STR_NEWGRF_MOVEUP, STR_NEWGRF_MOVEUP_TIP }, // SNGRFS_MOVE_UP
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_RIGHT, COLOUR_YELLOW, 220, 289, 32, 43, STR_NEWGRF_MOVEDOWN, STR_NEWGRF_MOVEDOWN_TIP }, // SNGRFS_MOVE_DOWN
|
|
|
{ WWT_MATRIX, RESIZE_RB, COLOUR_MAUVE, 0, 287, 46, 115, 0x501, STR_NEWGRF_FILE_TIP }, // SNGRFS_FILE_LIST
|
|
|
{ WWT_SCROLLBAR, RESIZE_LRB, COLOUR_MAUVE, 288, 299, 46, 115, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST }, // SNGRFS_SCROLLBAR
|
|
|
{ WWT_PANEL, RESIZE_RTB, COLOUR_MAUVE, 0, 299, 116, 228, STR_NULL, STR_NULL }, // SNGRFS_NEWGRF_INFO
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_MAUVE, 0, 143, 229, 240, STR_NEWGRF_SET_PARAMETERS, STR_NULL }, // SNGRFS_SET_PARAMETERS
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_RTB, COLOUR_MAUVE, 144, 287, 229, 240, STR_NEWGRF_APPLY_CHANGES, STR_NULL }, // SNGRFS_APPLY_CHANGES
|
|
|
{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_MAUVE, 288, 299, 229, 240, 0x0, STR_RESIZE_BUTTON }, // SNGRFS_RESIZE
|
|
|
{ WWT_PANEL, RESIZE_RTB, COLOUR_MAUVE, 0, 299, 116, 238, STR_NULL, STR_NULL }, // SNGRFS_NEWGRF_INFO
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_MAUVE, 0, 95, 239, 250, STR_NEWGRF_SET_PARAMETERS, STR_NULL }, // SNGRFS_SET_PARAMETERS
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_RTB, COLOUR_MAUVE, 96, 191, 239, 250, STR_NEWGRF_TOGGLE_PALETTE, STR_NEWGRF_TOGGLE_PALETTE_TIP }, // SNGRFS_TOGGLE_PALETTE
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_RTB, COLOUR_MAUVE, 192, 287, 239, 250, STR_NEWGRF_APPLY_CHANGES, STR_NULL }, // SNGRFS_APPLY_CHANGES
|
|
|
{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_MAUVE, 288, 299, 239, 250, 0x0, STR_RESIZE_BUTTON }, // SNGRFS_RESIZE
|
|
|
{ WIDGETS_END },
|
|
|
};
|
|
|
|
|
|
/* Window definition of the manage newgrfs window */
|
|
|
static const WindowDesc _newgrf_desc = {
|
|
|
WDP_CENTER, WDP_CENTER, 300, 241, 300, 241,
|
|
|
WDP_CENTER, WDP_CENTER, 300, 251, 300, 251,
|
|
|
WC_GAME_OPTIONS, WC_NONE,
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
|
|
|
_newgrf_widgets,
|
|
|
};
|
|
|
|
|
|
/** Callback function for the newgrf 'apply changes' confirmation window
|
|
|
* @param w Window which is calling this callback
|
|
|
* @param confirmed boolean value, true when yes was clicked, false otherwise
|
|
|
*/
|
|
|
static void NewGRFConfirmationCallback(Window *w, bool confirmed)
|
|
|
{
|
|
|
if (confirmed) {
|