summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-11-18 13:05:55 +0000
committerfrosch <frosch@openttd.org>2011-11-18 13:05:55 +0000
commitb725913f3b57110e18114f1f316e810d1d807e35 (patch)
tree9453f7a6328a47c9db0868be95fce48f7750f81d
parentb7b74ed7dc0e70cb2ce6931e71f5311600ec3a50 (diff)
downloadopenttd-b725913f3b57110e18114f1f316e810d1d807e35.tar.xz
(svn r23248) -Codechange: Rename everything related to the NewGRF 'readme' to 'textfile', so it is more generic.
-rw-r--r--src/lang/english.txt2
-rw-r--r--src/newgrf_config.cpp26
-rw-r--r--src/newgrf_config.h2
-rw-r--r--src/newgrf_gui.cpp90
-rw-r--r--src/window_type.h2
5 files changed, 62 insertions, 60 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index acc2ea710..dba859af0 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -2440,7 +2440,7 @@ STR_NEWGRF_PARAMETERS_DEFAULT_NAME :Parameter {NUM}
STR_NEWGRF_PARAMETERS_SETTING :{STRING1}: {ORANGE}{STRING1}
STR_NEWGRF_PARAMETERS_NUM_PARAM :{LTBLUE}Number of parameters: {ORANGE}{NUM}
-# NewGRF readme window
+# NewGRF textfile window
STR_NEWGRF_README_CAPTION :{WHITE}NewGRF readme of {RAW_STRING}
# NewGRF inspect window
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index 93190cbc9..026b62ff3 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -833,25 +833,27 @@ bool GRFConfig::IsOpenTTDBaseGRF() const
}
/**
- * Search the readme.txt file next to this NewGRF.
- * @return The filename for the readme, \c NULL otherwise.
+ * Search a textfile file next to this NewGRF.
+ * @return The filename for the textfile, \c NULL otherwise.
*/
-const char *GRFConfig::GetReadme() const
+const char *GRFConfig::GetTextfile() const
{
+ static const char prefix[] = "readme";
+
if (this->filename == NULL) return NULL;
- static char readme_path[MAX_PATH];
- strecpy(readme_path, this->filename, lastof(readme_path));
+ static char file_path[MAX_PATH];
+ strecpy(file_path, this->filename, lastof(file_path));
- char *slash = strrchr(readme_path, PATHSEPCHAR);
+ char *slash = strrchr(file_path, PATHSEPCHAR);
if (slash == NULL) return NULL;
- seprintf(slash + 1, lastof(readme_path), "readme_%s.txt", GetCurrentLanguageIsoCode());
- if (FioCheckFileExists(readme_path, NEWGRF_DIR)) return readme_path;
+ seprintf(slash + 1, lastof(file_path), "%s_%s.txt", prefix, GetCurrentLanguageIsoCode());
+ if (FioCheckFileExists(file_path, NEWGRF_DIR)) return file_path;
- seprintf(slash + 1, lastof(readme_path), "readme_%.2s.txt", GetCurrentLanguageIsoCode());
- if (FioCheckFileExists(readme_path, NEWGRF_DIR)) return readme_path;
+ seprintf(slash + 1, lastof(file_path), "%s_%.2s.txt", prefix, GetCurrentLanguageIsoCode());
+ if (FioCheckFileExists(file_path, NEWGRF_DIR)) return file_path;
- strecpy(slash + 1, "readme.txt", lastof(readme_path));
- return FioCheckFileExists(readme_path, NEWGRF_DIR) ? readme_path : NULL;
+ seprintf(slash + 1, lastof(file_path), "%s.txt", prefix);
+ return FioCheckFileExists(file_path, NEWGRF_DIR) ? file_path : NULL;
}
diff --git a/src/newgrf_config.h b/src/newgrf_config.h
index d54051e9e..7576c9682 100644
--- a/src/newgrf_config.h
+++ b/src/newgrf_config.h
@@ -175,7 +175,7 @@ struct GRFConfig : ZeroedMemoryAllocator {
bool IsOpenTTDBaseGRF() const;
- const char *GetReadme() const;
+ const char *GetTextfile() const;
const char *GetName() const;
const char *GetDescription() const;
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index b00b70540..6f5f8988e 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -464,38 +464,38 @@ void OpenGRFParameterWindow(GRFConfig *c)
new NewGRFParametersWindow(&_newgrf_parameters_desc, c);
}
-/** Widgets of the #NewGRFReadmeWindow. */
-enum ShowNewGRFReadmeWidgets {
- GRW_WIDGET_CAPTION, ///< The caption of the window.
- GRW_WIDGET_BACKGROUND, ///< Panel to draw the readme on.
- GRW_WIDGET_VSCROLLBAR, ///< Vertical scrollbar to scroll through the readme up-and-down.
- GRW_WIDGET_HSCROLLBAR, ///< Horizontal scrollbar to scroll through the readme left-to-right.
+/** Widgets of the #NewGRFTextfileWindow. */
+enum ShowNewGRFTextfileWidgets {
+ GTW_WIDGET_CAPTION, ///< The caption of the window.
+ GTW_WIDGET_BACKGROUND, ///< Panel to draw the textfile on.
+ GTW_WIDGET_VSCROLLBAR, ///< Vertical scrollbar to scroll through the textfile up-and-down.
+ GTW_WIDGET_HSCROLLBAR, ///< Horizontal scrollbar to scroll through the textfile left-to-right.
};
-/** Window for displaying the readme of a NewGRF. */
-struct NewGRFReadmeWindow : public Window {
- const GRFConfig *grf_config; ///< View the readme of this GRFConfig.
+/** Window for displaying the textfile of a NewGRF. */
+struct NewGRFTextfileWindow : public Window {
+ const GRFConfig *grf_config; ///< View the textfile of this GRFConfig.
int line_height; ///< Height of a line in the display widget.
Scrollbar *vscroll; ///< Vertical scrollbar.
Scrollbar *hscroll; ///< Horizontal scrollbar.
- char *text; ///< Lines of text from the NewGRF's readme.
+ char *text; ///< Lines of text from the NewGRF's textfile.
SmallVector<const char *, 64> lines; ///< #text, split into lines in a table with lines.
- uint max_length; ///< The longest line in the readme (in pixels).
+ uint max_length; ///< The longest line in the textfile (in pixels).
- static const int TOP_SPACING = WD_FRAMETEXT_TOP; ///< Additional spacing at the top of the #GRW_WIDGET_BACKGROUND widget.
- static const int BOTTOM_SPACING = WD_FRAMETEXT_BOTTOM; ///< Additional spacing at the bottom of the #GRW_WIDGET_BACKGROUND widget.
+ static const int TOP_SPACING = WD_FRAMETEXT_TOP; ///< Additional spacing at the top of the #GTW_WIDGET_BACKGROUND widget.
+ static const int BOTTOM_SPACING = WD_FRAMETEXT_BOTTOM; ///< Additional spacing at the bottom of the #GTW_WIDGET_BACKGROUND widget.
- NewGRFReadmeWindow(const WindowDesc *desc, const GRFConfig *c) : Window(), grf_config(c)
+ NewGRFTextfileWindow(const WindowDesc *desc, const GRFConfig *c) : Window(), grf_config(c)
{
this->CreateNestedTree(desc);
- this->vscroll = this->GetScrollbar(GRW_WIDGET_VSCROLLBAR);
- this->hscroll = this->GetScrollbar(GRW_WIDGET_HSCROLLBAR);
+ this->vscroll = this->GetScrollbar(GTW_WIDGET_VSCROLLBAR);
+ this->hscroll = this->GetScrollbar(GTW_WIDGET_HSCROLLBAR);
this->FinishInitNested(desc);
- this->LoadReadme();
+ this->LoadTextfile();
}
- ~NewGRFReadmeWindow()
+ ~NewGRFTextfileWindow()
{
free(this->text);
}
@@ -503,7 +503,7 @@ struct NewGRFReadmeWindow : public Window {
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{
switch (widget) {
- case GRW_WIDGET_BACKGROUND:
+ case GTW_WIDGET_BACKGROUND:
this->line_height = FONT_HEIGHT_NORMAL + 2;
resize->height = this->line_height;
@@ -515,12 +515,12 @@ struct NewGRFReadmeWindow : public Window {
virtual void SetStringParameters(int widget) const
{
- if (widget == GRW_WIDGET_CAPTION) SetDParamStr(0, this->grf_config->GetName());
+ if (widget == GTW_WIDGET_CAPTION) SetDParamStr(0, this->grf_config->GetName());
}
virtual void DrawWidget(const Rect &r, int widget) const
{
- if (widget != GRW_WIDGET_BACKGROUND) return;
+ if (widget != GTW_WIDGET_BACKGROUND) return;
DrawPixelInfo new_dpi;
if (!FillDrawPixelInfo(&new_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) return;
@@ -540,26 +540,26 @@ struct NewGRFReadmeWindow : public Window {
virtual void OnResize()
{
- this->vscroll->SetCapacityFromWidget(this, GRW_WIDGET_BACKGROUND, this->line_height);
- this->hscroll->SetCapacityFromWidget(this, GRW_WIDGET_BACKGROUND);
+ this->vscroll->SetCapacityFromWidget(this, GTW_WIDGET_BACKGROUND, this->line_height);
+ this->hscroll->SetCapacityFromWidget(this, GTW_WIDGET_BACKGROUND);
}
private:
/**
- * Load the NewGRF's readme text from file, and setup #lines, #max_length, and both scrollbars.
+ * Load the NewGRF's textfile text from file, and setup #lines, #max_length, and both scrollbars.
*/
- void LoadReadme()
+ void LoadTextfile()
{
this->lines.Clear();
- /* Does GRF have readme? */
- const char *readme = this->grf_config->GetReadme();
- if (readme == NULL) return;
+ /* Does GRF have a file of the demanded type? */
+ const char *textfile = this->grf_config->GetTextfile();
+ if (textfile == NULL) return;
/* Get text from file */
size_t filesize;
- FILE *handle = FioFOpenFile(readme, "rb", NEWGRF_DIR, &filesize);
+ FILE *handle = FioFOpenFile(textfile, "rb", NEWGRF_DIR, &filesize);
if (handle == NULL) return;
this->text = ReallocT(this->text, filesize + 1);
@@ -602,36 +602,36 @@ private:
}
};
-static const NWidgetPart _nested_newgrf_readme_widgets[] = {
+static const NWidgetPart _nested_newgrf_textfile_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_MAUVE),
- NWidget(WWT_CAPTION, COLOUR_MAUVE, GRW_WIDGET_CAPTION), SetDataTip(STR_NEWGRF_README_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
+ NWidget(WWT_CAPTION, COLOUR_MAUVE, GTW_WIDGET_CAPTION), SetDataTip(STR_NEWGRF_README_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
EndContainer(),
NWidget(NWID_HORIZONTAL),
- NWidget(WWT_PANEL, COLOUR_MAUVE, GRW_WIDGET_BACKGROUND), SetMinimalSize(200, 125), SetResize(1, 12), SetScrollbar(GRW_WIDGET_VSCROLLBAR),
+ NWidget(WWT_PANEL, COLOUR_MAUVE, GTW_WIDGET_BACKGROUND), SetMinimalSize(200, 125), SetResize(1, 12), SetScrollbar(GTW_WIDGET_VSCROLLBAR),
EndContainer(),
NWidget(NWID_VERTICAL),
- NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, GRW_WIDGET_VSCROLLBAR),
+ NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, GTW_WIDGET_VSCROLLBAR),
EndContainer(),
EndContainer(),
NWidget(NWID_HORIZONTAL),
- NWidget(NWID_HSCROLLBAR, COLOUR_MAUVE, GRW_WIDGET_HSCROLLBAR),
+ NWidget(NWID_HSCROLLBAR, COLOUR_MAUVE, GTW_WIDGET_HSCROLLBAR),
NWidget(WWT_RESIZEBOX, COLOUR_MAUVE),
EndContainer(),
};
-/** Window definition for the grf readme window */
-static const WindowDesc _newgrf_readme_desc(
+/** Window definition for the grf textfile window */
+static const WindowDesc _newgrf_textfile_desc(
WDP_CENTER, 630, 460,
- WC_NEWGRF_README, WC_NONE,
+ WC_NEWGRF_TEXTFILE, WC_NONE,
WDF_UNCLICK_BUTTONS,
- _nested_newgrf_readme_widgets, lengthof(_nested_newgrf_readme_widgets)
+ _nested_newgrf_textfile_widgets, lengthof(_nested_newgrf_textfile_widgets)
);
-void ShowNewGRFReadmeWindow(const GRFConfig *c)
+void ShowNewGRFTextfileWindow(const GRFConfig *c)
{
- DeleteWindowByClass(WC_NEWGRF_README);
- new NewGRFReadmeWindow(&_newgrf_readme_desc, c);
+ DeleteWindowByClass(WC_NEWGRF_TEXTFILE);
+ new NewGRFTextfileWindow(&_newgrf_textfile_desc, c);
}
static GRFPresetList _grf_preset_list;
@@ -750,7 +750,7 @@ struct NewGRFWindow : public QueryStringBaseWindow, NewGRFScanCallback {
~NewGRFWindow()
{
DeleteWindowByClass(WC_GRF_PARAMETERS);
- DeleteWindowByClass(WC_NEWGRF_README);
+ DeleteWindowByClass(WC_NEWGRF_TEXTFILE);
if (this->editable && !this->execute) {
CopyGRFConfigList(this->orig_list, this->actives, true);
@@ -1127,7 +1127,7 @@ struct NewGRFWindow : public QueryStringBaseWindow, NewGRFScanCallback {
case SNGRFS_NEWGRF_README: // View GRF readme
if (this->active_sel == NULL && this->avail_sel == NULL) break;
- ShowNewGRFReadmeWindow(this->active_sel != NULL ? this->active_sel : this->avail_sel);
+ ShowNewGRFTextfileWindow(this->active_sel != NULL ? this->active_sel : this->avail_sel);
break;
case SNGRFS_SET_PARAMETERS: { // Edit parameters
@@ -1183,7 +1183,7 @@ struct NewGRFWindow : public QueryStringBaseWindow, NewGRFScanCallback {
this->avail_pos = -1;
this->avails.ForceRebuild();
this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window
- this->DeleteChildWindows(WC_NEWGRF_README); // Remove the view readme window
+ this->DeleteChildWindows(WC_NEWGRF_TEXTFILE); // Remove the view textfile window
}
virtual void OnDropdownSelect(int widget, int index)
@@ -1290,7 +1290,7 @@ struct NewGRFWindow : public QueryStringBaseWindow, NewGRFScanCallback {
);
const GRFConfig *c = (this->avail_sel == NULL) ? this->active_sel : this->avail_sel;
- this->SetWidgetDisabledState(SNGRFS_NEWGRF_README, c == NULL || c->GetReadme() == NULL);
+ this->SetWidgetDisabledState(SNGRFS_NEWGRF_README, c == NULL || c->GetTextfile() == NULL);
this->SetWidgetDisabledState(SNGRFS_SET_PARAMETERS, !this->show_params || disable_all || this->active_sel->num_valid_params == 0);
this->SetWidgetDisabledState(SNGRFS_TOGGLE_PALETTE, disable_all);
diff --git a/src/window_type.h b/src/window_type.h
index b003cfea8..e6e1da192 100644
--- a/src/window_type.h
+++ b/src/window_type.h
@@ -112,7 +112,7 @@ enum WindowClass {
WC_INDUSTRY_CARGOES,
WC_GRF_PARAMETERS,
WC_BUILD_OBJECT,
- WC_NEWGRF_README,
+ WC_NEWGRF_TEXTFILE,
WC_INVALID = 0xFFFF
};