23#include "table/strings.h"
27static const std::string README_FILENAME =
"README.md";
28static const std::string CHANGELOG_FILENAME =
"changelog.md";
29static const std::string KNOWN_BUGS_FILENAME =
"known-bugs.md";
30static const std::string LICENSE_FILENAME =
"COPYING.md";
31static const std::string FONTS_FILENAME =
"fonts.md";
33static const std::string WEBSITE_LINK =
"https://www.openttd.org/";
34static const std::string WIKI_LINK =
"https://wiki.openttd.org/";
35static const std::string BUGTRACKER_LINK =
"https://bugs.openttd.org/";
36static const std::string COMMUNITY_LINK =
"https://community.openttd.org/";
55 std::string file_path = FioGetDirectory(sp, subdir);
56 file_path.append(filename);
64struct GameManualTextfileWindow :
public TextfileWindow {
67 this->ConstructWindow();
86 return GetString(stringid, this->filename);
94 if (this->filename == CHANGELOG_FILENAME) {
111 for (
size_t line_index = 0; line_index < this->
lines.size(); ++line_index) {
112 const Line &line = this->
lines[line_index];
113 if (!line.
text.starts_with(
"###"))
continue;
116 this->
lines.resize(line_index - 2);
132 this->EnableTextfileButton(README_FILENAME,
BASE_DIR, WID_HW_README);
133 this->EnableTextfileButton(CHANGELOG_FILENAME,
BASE_DIR, WID_HW_CHANGELOG);
134 this->EnableTextfileButton(KNOWN_BUGS_FILENAME,
BASE_DIR, WID_HW_KNOWN_BUGS);
135 this->EnableTextfileButton(LICENSE_FILENAME,
BASE_DIR, WID_HW_LICENSE);
136 this->EnableTextfileButton(FONTS_FILENAME,
DOCS_DIR, WID_HW_FONTS);
145 case WID_HW_CHANGELOG:
148 case WID_HW_KNOWN_BUGS:
158 OpenBrowser(WEBSITE_LINK);
161 OpenBrowser(WIKI_LINK);
163 case WID_HW_BUGTRACKER:
164 OpenBrowser(BUGTRACKER_LINK);
166 case WID_HW_COMMUNITY:
167 OpenBrowser(COMMUNITY_LINK);
173 void EnableTextfileButton(std::string_view filename,
Subdirectory subdir,
WidgetID button_widget)
179static constexpr std::initializer_list<NWidgetPart> _nested_helpwin_widgets = {
209 _nested_helpwin_widgets
Control codes that are embedded in the translation strings.
bool FioCheckFileExists(std::string_view filename, Subdirectory subdir)
Check whether the given file exists.
Functions for standard in/out file operations.
Searchpath
Types of searchpaths OpenTTD might use.
@ SP_SHARED_DIR
Search in the shared directory, like 'Shared Files' under Windows.
@ SP_INSTALLATION_DIR
Search in the installation directory.
@ SP_BINARY_DIR
Search in the directory where the binary resides.
@ SP_WORKING_DIR
Search in the working directory.
@ SP_APPLICATION_BUNDLE_DIR
Search within the application bundle.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
@ NO_DIRECTORY
A path without any base directory.
@ BASE_DIR
Base directory for all subdirectories.
@ DOCS_DIR
Subdirectory for documentation.
GUI functions that shouldn't be here.
static constexpr size_t CHANGELOG_VERSIONS_LIMIT
Only show the first 20 changelog versions in the textfile viewer.
static std::optional< std::string > FindGameManualFilePath(std::string_view filename, Subdirectory subdir)
Find the path to the game manual file.
GUI to access manuals and related.
#define Point
Macro that prevents name conflicts between included headers.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
Functions related to low-level strings.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Window class displaying the game manual textfile viewer.
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
void AfterLoadChangelog()
For changelog files, truncate the file after CHANGELOG_VERSIONS_LIMIT versions.
void AfterLoadText() override
Post-processing after the text is loaded.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
std::string text
Contents of the line.
bool trusted
Whether the content is trusted (read: not from content like NewGRFs, etc).
std::vector< Line > lines
text, split into lines in a table with lines.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
virtual void AfterLoadText()
Post-processing after the text is loaded.
std::string filepath
Full path to the filename.
std::vector< Hyperlink > link_anchors
Anchor names of headings that can be linked to.
std::string filename
Filename of the textfile.
virtual void LoadTextfile(const std::string &textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
High level window description.
Number to differentiate different windows of the same class.
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
GUI functions related to textfiles.
@ TFT_GAME_MANUAL
Game manual/documentation file.
Functions, definitions and such used only by the GUI.
Twindow * AllocateWindowDescFront(WindowDesc &desc, WindowNumber window_number, Targs... extra_arguments)
Open a new window.
@ WDP_CENTER
Center the window.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.