|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
25 static const std::string README_FILENAME =
"README.md";
26 static const std::string CHANGELOG_FILENAME =
"changelog.txt";
27 static const std::string KNOWN_BUGS_FILENAME =
"known-bugs.txt";
28 static const std::string LICENSE_FILENAME =
"COPYING.md";
30 static const std::string WEBSITE_LINK =
"https://www.openttd.org/";
31 static const std::string WIKI_LINK =
"https://wiki.openttd.org/";
32 static const std::string BUGTRACKER_LINK =
"https://bugs.openttd.org/";
33 static const std::string COMMUNITY_LINK =
"https://community.openttd.org/";
51 auto file_path = FioGetDirectory(sp,
BASE_DIR) + filename.data();
62 this->ConstructWindow();
78 void SetStringParameters(
WidgetID widget)
const override
87 if (this->filename == CHANGELOG_FILENAME) {
104 for (
size_t line_index = 0; line_index < this->
lines.size(); ++line_index) {
105 const Line &line = this->
lines[line_index];
106 if (line.
text.find(
"---", 0) != 0)
continue;
109 this->
lines.resize(line_index - 2);
114 this->
lines[line_index - 1].colour = TC_GOLD;
115 this->
lines[line_index].colour = TC_GOLD;
116 this->
jumplist.push_back(line_index - 1);
128 this->EnableTextfileButton(README_FILENAME, WID_HW_README);
129 this->EnableTextfileButton(CHANGELOG_FILENAME, WID_HW_CHANGELOG);
130 this->EnableTextfileButton(KNOWN_BUGS_FILENAME, WID_HW_KNOWN_BUGS);
131 this->EnableTextfileButton(LICENSE_FILENAME, WID_HW_LICENSE);
134 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
140 case WID_HW_CHANGELOG:
143 case WID_HW_KNOWN_BUGS:
150 OpenBrowser(WEBSITE_LINK);
153 OpenBrowser(WIKI_LINK);
155 case WID_HW_BUGTRACKER:
156 OpenBrowser(BUGTRACKER_LINK);
158 case WID_HW_COMMUNITY:
159 OpenBrowser(COMMUNITY_LINK);
165 void EnableTextfileButton(std::string_view filename,
WidgetID button_widget)
171 static constexpr
NWidgetPart _nested_helpwin_widgets[] = {
196 static WindowDesc _helpwin_desc(__FILE__, __LINE__,
200 std::begin(_nested_helpwin_widgets), std::end(_nested_helpwin_widgets)
203 void ShowHelpWindow()
205 AllocateWindowDescFront<HelpWindow>(&_helpwin_desc, 0);
static constexpr size_t CHANGELOG_VERSIONS_LIMIT
Only show the first 20 changelog versions in the textfile viewer.
void AfterLoadChangelog()
For changelog files, add a jumplist entry for each version.
Searchpath
Types of searchpaths OpenTTD might use.
static std::optional< std::string > FindGameManualFilePath(std::string_view filename)
Find the path to the game manual file.
@ SP_INSTALLATION_DIR
Search in the installation directory.
Window class displaying the help window.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
High level window description.
@ BASE_DIR
Base directory for all subdirectories.
int32_t WindowNumber
Number to differentiate different windows of the same class.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
virtual void AfterLoadText()
Post-processing after the text is loaded.
@ SP_APPLICATION_BUNDLE_DIR
Search within the application bundle.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
virtual void LoadTextfile(const std::string &textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
Window class displaying the game manual textfile viewer.
@ SP_SHARED_DIR
Search in the shared directory, like 'Shared Files' under Windows.
Coordinates of a point in 2D.
@ SP_WORKING_DIR
Search in the working directory.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
std::vector< size_t > jumplist
Table of contents list, line numbers.
@ SP_BINARY_DIR
Search in the directory where the binary resides.
bool FioCheckFileExists(const std::string &filename, Subdirectory subdir)
Check whether the given file exists.
std::string filepath
Full path to the filename.
@ NO_DIRECTORY
A path without any base directory.
std::vector< Line > lines
#text, split into lines in a table with lines.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
bool trusted
Whether the content is trusted (read: not from content like NewGRFs, etc).
std::vector< Hyperlink > link_anchors
Anchor names of headings that can be linked to.
@ TFT_GAME_MANUAL
Game manual/documentation file.
std::string text
Contents of the line.
Window for displaying a textfile.
Data structure for an opened window.
std::string filename
Filename of the textfile.
@ WDP_CENTER
Center the window.
void AfterLoadText() override
Post-processing after the text is loaded.