Codechange: replace C-style strings with C++-style strings in textfile (#10772)
This commit is contained in:
@@ -19,25 +19,14 @@ std::optional<std::string> GetTextfile(TextfileType type, Subdirectory dir, cons
|
||||
|
||||
/** Window for displaying a textfile */
|
||||
struct TextfileWindow : public Window, MissingGlyphSearcher {
|
||||
struct Line {
|
||||
int top; ///< Top scroll position.
|
||||
int bottom; ///< Bottom scroll position.
|
||||
const char *text; ///< Pointer to text buffer.
|
||||
|
||||
Line(int top, const char *text) : top(top), bottom(top + 1), text(text) {}
|
||||
};
|
||||
|
||||
TextfileType file_type; ///< Type of textfile to view.
|
||||
Scrollbar *vscroll; ///< Vertical scrollbar.
|
||||
Scrollbar *hscroll; ///< Horizontal scrollbar.
|
||||
char *text; ///< Lines of text from the NewGRF's textfile.
|
||||
std::vector<Line> lines; ///< #text, split into lines in a table with lines.
|
||||
uint search_iterator; ///< Iterator for the font check search.
|
||||
|
||||
uint max_length; ///< Maximum length of unwrapped text line.
|
||||
|
||||
TextfileWindow(TextfileType file_type);
|
||||
~TextfileWindow();
|
||||
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override;
|
||||
void OnClick(Point pt, int widget, int click_count) override;
|
||||
@@ -47,13 +36,24 @@ struct TextfileWindow : public Window, MissingGlyphSearcher {
|
||||
|
||||
void Reset() override;
|
||||
FontSize DefaultSize() override;
|
||||
const char *NextString() override;
|
||||
std::optional<std::string_view> NextString() override;
|
||||
bool Monospace() override;
|
||||
void SetFontNames(FontCacheSettings *settings, const char *font_name, const void *os_data) override;
|
||||
|
||||
virtual void LoadTextfile(const std::string &textfile, Subdirectory dir);
|
||||
|
||||
private:
|
||||
struct Line {
|
||||
int top; ///< Top scroll position.
|
||||
int bottom; ///< Bottom scroll position.
|
||||
std::string_view text; ///< Pointer to text buffer.
|
||||
|
||||
Line(int top, std::string_view text) : top(top), bottom(top + 1), text(text) {}
|
||||
};
|
||||
|
||||
std::string text; ///< Lines of text from the NewGRF's textfile.
|
||||
std::vector<Line> lines; ///< #text, split into lines in a table with lines.
|
||||
|
||||
uint ReflowContent();
|
||||
uint GetContentHeight();
|
||||
void SetupScrollbars(bool force_reflow);
|
||||
|
Reference in New Issue
Block a user