# HG changeset patch
# Parent 15bf2566720d735e3cdbd0ab20a0eabb1b4fc197
diff --git a/projects/openttd_vs100.vcxproj b/projects/openttd_vs100.vcxproj
--- a/projects/openttd_vs100.vcxproj
+++ b/projects/openttd_vs100.vcxproj
@@ -363,6 +363,7 @@
+
diff --git a/projects/openttd_vs100.vcxproj.filters b/projects/openttd_vs100.vcxproj.filters
--- a/projects/openttd_vs100.vcxproj.filters
+++ b/projects/openttd_vs100.vcxproj.filters
@@ -318,6 +318,9 @@
Source Files
+
+ Source Files
+
Source Files
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -723,6 +723,10 @@
>
+
+
diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj
--- a/projects/openttd_vs90.vcproj
+++ b/projects/openttd_vs90.vcproj
@@ -720,6 +720,10 @@
>
+
+
diff --git a/source.list b/source.list
--- a/source.list
+++ b/source.list
@@ -73,6 +73,7 @@
strings.cpp
subsidy.cpp
texteff.cpp
+textfile_gui.cpp
tgp.cpp
tile_map.cpp
tilearea.cpp
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -19,7 +19,7 @@
#include "window_func.h"
#include "progress.h"
#include "video/video_driver.hpp"
-#include "strings_func.h"
+#include "textfile_gui.h"
#include "fileio_func.h"
#include "fios.h"
@@ -876,31 +876,9 @@
* @param type The type of the textfile to search for.
* @return The filename for the textfile, \c NULL otherwise.
*/
-const char *GRFConfig::GetTextfile(TextfileType type) const
+const char *GRFConfig::GetGRFTextfile(TextfileType type) const
{
- static const char * const prefixes[] = {
- "readme",
- "changelog",
- "license",
- };
- assert_compile(lengthof(prefixes) == TFT_END);
-
- const char *prefix = prefixes[type];
-
if (this->filename == NULL) return NULL;
- static char file_path[MAX_PATH];
- strecpy(file_path, this->filename, lastof(file_path));
-
- char *slash = strrchr(file_path, PATHSEPCHAR);
- if (slash == NULL) return NULL;
-
- seprintf(slash + 1, lastof(file_path), "%s_%s.txt", prefix, GetCurrentLanguageIsoCode());
- if (FioCheckFileExists(file_path, NEWGRF_DIR)) return file_path;
-
- seprintf(slash + 1, lastof(file_path), "%s_%.2s.txt", prefix, GetCurrentLanguageIsoCode());
- if (FioCheckFileExists(file_path, NEWGRF_DIR)) return file_path;
-
- seprintf(slash + 1, lastof(file_path), "%s.txt", prefix);
- return FioCheckFileExists(file_path, NEWGRF_DIR) ? file_path : NULL;
+ return GetTextfile(type, NEWGRF_DIR, this->filename);
}
diff --git a/src/newgrf_config.h b/src/newgrf_config.h
--- a/src/newgrf_config.h
+++ b/src/newgrf_config.h
@@ -176,7 +176,7 @@
bool IsOpenTTDBaseGRF() const;
- const char *GetTextfile(TextfileType type) const;
+ const char *GetGRFTextfile(TextfileType type) const;
const char *GetName() const;
const char *GetDescription() const;
const char *GetURL() const;
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -471,7 +471,7 @@
{
this->GetWidget(WID_TF_CAPTION)->SetDataTip(STR_TEXTFILE_README_CAPTION + file_type, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS);
- const char *textfile = this->grf_config->GetTextfile(file_type);
+ const char *textfile = this->grf_config->GetGRFTextfile(file_type);
this->LoadTextfile(textfile, NEWGRF_DIR);
}
@@ -1116,7 +1116,7 @@
const GRFConfig *c = (this->avail_sel == NULL) ? this->active_sel : this->avail_sel;
for (TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
- this->SetWidgetDisabledState(WID_NS_NEWGRF_TEXTFILE + tft, c == NULL || c->GetTextfile(tft) == NULL);
+ this->SetWidgetDisabledState(WID_NS_NEWGRF_TEXTFILE + tft, c == NULL || c->GetGRFTextfile(tft) == NULL);
}
this->SetWidgetDisabledState(WID_NS_OPEN_URL, c == NULL || StrEmpty(c->GetURL()));
diff --git a/src/textfile_gui.h b/src/textfile_gui.h
--- a/src/textfile_gui.h
+++ b/src/textfile_gui.h
@@ -25,6 +25,15 @@
#include "table/strings.h"
+/**
+ * Search a textfile file next to this NewGRF.
+ * @param type The type of the textfile to search for.
+ * @param dir The subdirectory to search in.
+ * @param filename The filename to look for.
+ * @return The path to the textfile, \c NULL otherwise.
+ */
+const char *GetTextfile(TextfileType type, Subdirectory dir, const char *filename);
+
/** Window for displaying a textfile */
struct TextfileWindow : public Window, MissingGlyphSearcher {
TextfileType file_type; ///< Type of textfile to view.