mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Merge "new version" window back to changelog
This commit is contained in:
committed by
Aaron van Geffen
parent
ddee3c0e46
commit
6dd67296a4
@@ -44,7 +44,7 @@ public:
|
||||
case WC_BOTTOM_TOOLBAR:
|
||||
return window_game_bottom_toolbar_open();
|
||||
case WC_CHANGELOG:
|
||||
return window_changelog_open();
|
||||
return OpenView(WV_CHANGELOG);
|
||||
case WC_CHEATS:
|
||||
return window_cheats_open();
|
||||
case WC_CLEAR_SCENERY:
|
||||
@@ -135,8 +135,6 @@ public:
|
||||
return window_water_open();
|
||||
case WC_NETWORK:
|
||||
return window_network_open();
|
||||
case WC_NEW_VERSION:
|
||||
return window_new_version_open();
|
||||
default:
|
||||
Console::Error::WriteLine("Unhandled window class (%d)", wc);
|
||||
return nullptr;
|
||||
@@ -174,6 +172,10 @@ public:
|
||||
return window_editor_bottom_toolbar_open();
|
||||
case WV_EDITOR_MAIN:
|
||||
return window_editor_main_open();
|
||||
case WV_CHANGELOG:
|
||||
return window_changelog_open(WV_CHANGELOG);
|
||||
case WV_NEW_VERSION_INFO:
|
||||
return window_changelog_open(WV_NEW_VERSION_INFO);
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ static void window_about_openrct2_mouseup(rct_window* w, rct_widgetindex widgetI
|
||||
context_open_window(WC_CHANGELOG);
|
||||
break;
|
||||
case WIDX_NEW_VERSION:
|
||||
context_open_window(WC_NEW_VERSION);
|
||||
context_open_window_view(WV_NEW_VERSION_INFO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,12 @@
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/OpenRCT2.h>
|
||||
#include <openrct2/PlatformEnvironment.h>
|
||||
#include <openrct2/Version.h>
|
||||
#include <openrct2/core/String.hpp>
|
||||
#include <openrct2/drawing/Drawing.h>
|
||||
#include <openrct2/localisation/Localisation.h>
|
||||
#include <openrct2/platform/platform.h>
|
||||
#include <openrct2/ui/UiContext.h>
|
||||
#include <openrct2/util/Util.h>
|
||||
#include <vector>
|
||||
|
||||
@@ -29,19 +31,21 @@ enum {
|
||||
WIDX_TITLE,
|
||||
WIDX_CLOSE,
|
||||
WIDX_CONTENT_PANEL,
|
||||
WIDX_SCROLL
|
||||
WIDX_SCROLL,
|
||||
WIDX_OPEN_URL,
|
||||
};
|
||||
|
||||
static constexpr const int32_t WW = 500;
|
||||
static constexpr const int32_t WH = 400;
|
||||
static constexpr const rct_string_id WINDOW_TITLE = STR_CHANGELOG_TITLE;
|
||||
constexpr int32_t MIN_WW = 300;
|
||||
constexpr int32_t MIN_WH = 200;
|
||||
constexpr int32_t MIN_WH = 250;
|
||||
|
||||
static rct_widget window_changelog_widgets[] = {
|
||||
WINDOW_SHIM(WINDOW_TITLE, WW, WH),
|
||||
MakeWidget({0, 14}, {500, 386}, WWT_RESIZE, 1 ), // content panel
|
||||
MakeWidget({3, 16}, {495, 370}, WWT_SCROLL, 1, SCROLL_BOTH), // scroll area
|
||||
MakeWidget({0, 14}, {500, 382}, WWT_RESIZE, 1 ), // content panel
|
||||
MakeWidget({3, 16}, {495, 366}, WWT_SCROLL, 1, SCROLL_BOTH), // scroll area
|
||||
MakeWidget({3, 473}, {300, 14}, WWT_PLACEHOLDER, 1, STR_NEW_RELEASE_DOWNLOAD_PAGE), // changelog button
|
||||
{ WIDGETS_END },
|
||||
};
|
||||
|
||||
@@ -85,23 +89,56 @@ static rct_window_event_list window_changelog_events = {
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
static void window_new_version_process_info();
|
||||
static void window_changelog_dispose_data();
|
||||
static bool window_changelog_read_file();
|
||||
static void window_changelog_dispose_file();
|
||||
|
||||
static std::string _changelogText;
|
||||
static std::vector<const char*> _changelogLines;
|
||||
static const NewVersionInfo* _newVersionInfo;
|
||||
static std::vector<std::string> _changelogLines;
|
||||
static int32_t _changelogLongestLineWidth = 0;
|
||||
static int _persnality = 0;
|
||||
|
||||
rct_window* window_changelog_open()
|
||||
rct_window* window_changelog_open(int personality)
|
||||
{
|
||||
rct_window* window;
|
||||
|
||||
window = window_bring_to_front_by_class(WC_CHANGELOG);
|
||||
if (window != nullptr)
|
||||
{
|
||||
return window;
|
||||
}
|
||||
|
||||
if (!window_changelog_read_file())
|
||||
return nullptr;
|
||||
uint64_t enabled_widgets{};
|
||||
|
||||
window_changelog_widgets[WIDX_OPEN_URL].type = WWT_PLACEHOLDER;
|
||||
switch (personality)
|
||||
{
|
||||
case WV_NEW_VERSION_INFO:
|
||||
if (!GetContext()->HasNewVersionInfo())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
_persnality = WV_NEW_VERSION_INFO;
|
||||
window_new_version_process_info();
|
||||
enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_OPEN_URL);
|
||||
window_changelog_widgets[WIDX_OPEN_URL].type = WWT_BUTTON;
|
||||
break;
|
||||
|
||||
case WV_CHANGELOG:
|
||||
if (!window_changelog_read_file())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
_persnality = WV_CHANGELOG;
|
||||
enabled_widgets = (1 << WIDX_CLOSE);
|
||||
break;
|
||||
|
||||
default:
|
||||
log_error("Invalid personality for changelog window: %d", personality);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32_t screenWidth = context_get_width();
|
||||
int32_t screenHeight = context_get_height();
|
||||
@@ -109,19 +146,20 @@ rct_window* window_changelog_open()
|
||||
window = window_create_centred(
|
||||
screenWidth * 4 / 5, screenHeight * 4 / 5, &window_changelog_events, WC_CHANGELOG, WF_RESIZABLE);
|
||||
window->widgets = window_changelog_widgets;
|
||||
window->enabled_widgets = (1 << WIDX_CLOSE);
|
||||
window->enabled_widgets = enabled_widgets;
|
||||
|
||||
window_init_scroll_widgets(window);
|
||||
window->min_width = MIN_WW;
|
||||
window->min_height = MIN_WH;
|
||||
window->max_width = MIN_WW;
|
||||
window->max_height = MIN_WH;
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
static void window_changelog_close([[maybe_unused]] rct_window* w)
|
||||
{
|
||||
window_changelog_dispose_file();
|
||||
window_changelog_dispose_data();
|
||||
}
|
||||
|
||||
static void window_changelog_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
||||
@@ -131,6 +169,9 @@ static void window_changelog_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
||||
case WIDX_CLOSE:
|
||||
window_close(w);
|
||||
break;
|
||||
case WIDX_OPEN_URL:
|
||||
GetContext()->GetUiContext()->OpenURL(_newVersionInfo->url);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,6 +185,11 @@ static void window_changelog_resize(rct_window* w)
|
||||
|
||||
w->min_width = MIN_WW;
|
||||
w->min_height = MIN_WH;
|
||||
|
||||
auto download_button_width = window_changelog_widgets[WIDX_OPEN_URL].width();
|
||||
window_changelog_widgets[WIDX_OPEN_URL].left = (w->width - download_button_width) / 2;
|
||||
window_changelog_widgets[WIDX_OPEN_URL].right = window_changelog_widgets[WIDX_OPEN_URL].left + download_button_width;
|
||||
|
||||
if (w->width < w->min_width)
|
||||
{
|
||||
w->Invalidate();
|
||||
@@ -175,7 +221,9 @@ static void window_changelog_invalidate(rct_window* w)
|
||||
window_changelog_widgets[WIDX_CONTENT_PANEL].right = w->width - 1;
|
||||
window_changelog_widgets[WIDX_CONTENT_PANEL].bottom = w->height - 1;
|
||||
window_changelog_widgets[WIDX_SCROLL].right = w->width - 3;
|
||||
window_changelog_widgets[WIDX_SCROLL].bottom = w->height - 15;
|
||||
window_changelog_widgets[WIDX_SCROLL].bottom = w->height - 22;
|
||||
window_changelog_widgets[WIDX_OPEN_URL].bottom = w->height - 5;
|
||||
window_changelog_widgets[WIDX_OPEN_URL].top = w->height - 19;
|
||||
}
|
||||
|
||||
static void window_changelog_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
@@ -197,10 +245,61 @@ static void window_changelog_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
|
||||
if (screenCoords.y + lineHeight < dpi->y || screenCoords.y >= dpi->y + dpi->height)
|
||||
continue;
|
||||
|
||||
gfx_draw_string(dpi, static_cast<const char*>(line), w->colours[0], screenCoords);
|
||||
gfx_draw_string(dpi, line.c_str(), w->colours[0], screenCoords);
|
||||
}
|
||||
}
|
||||
|
||||
static void window_changelog_process_changelog_text(const std::string& text)
|
||||
{
|
||||
std::string::size_type pos = 0;
|
||||
std::string::size_type prev = 0;
|
||||
while ((pos = text.find("\n", prev)) != std::string::npos)
|
||||
{
|
||||
std::string line = text.substr(prev, pos - prev);
|
||||
for (char* ch = line.data(); *ch != '\0'; ch++)
|
||||
{
|
||||
if (utf8_is_format_code(*ch))
|
||||
{
|
||||
*ch = FORMAT_OUTLINE_OFF;
|
||||
}
|
||||
}
|
||||
_changelogLines.push_back(line);
|
||||
prev = pos + 1;
|
||||
}
|
||||
|
||||
// To get the last substring (or only, if delimiter is not found)
|
||||
_changelogLines.push_back(text.substr(prev));
|
||||
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
||||
_changelogLongestLineWidth = 0;
|
||||
for (auto line : _changelogLines)
|
||||
{
|
||||
auto width = gfx_get_string_width(line.c_str());
|
||||
_changelogLongestLineWidth = std::max(width, _changelogLongestLineWidth);
|
||||
}
|
||||
}
|
||||
|
||||
static void window_new_version_process_info()
|
||||
{
|
||||
_newVersionInfo = GetContext()->GetNewVersionInfo();
|
||||
|
||||
char version_info[256];
|
||||
|
||||
const char* version_info_ptr = _newVersionInfo->name.c_str();
|
||||
format_string(version_info, 256, STR_NEW_RELEASE_VERSION_INFO, &version_info_ptr);
|
||||
|
||||
_changelogLines.push_back(version_info);
|
||||
_changelogLines.push_back("");
|
||||
|
||||
window_changelog_process_changelog_text(_newVersionInfo->changelog);
|
||||
}
|
||||
|
||||
static void window_changelog_dispose_data()
|
||||
{
|
||||
_changelogLines.clear();
|
||||
_changelogLines.shrink_to_fit();
|
||||
}
|
||||
|
||||
static std::string GetChangelogPath()
|
||||
{
|
||||
auto env = GetContext()->GetPlatformEnvironment();
|
||||
@@ -225,6 +324,7 @@ static std::string GetChangelogText()
|
||||
|
||||
static bool window_changelog_read_file()
|
||||
{
|
||||
std::string _changelogText;
|
||||
try
|
||||
{
|
||||
_changelogText = GetChangelogText();
|
||||
@@ -240,47 +340,6 @@ static bool window_changelog_read_file()
|
||||
return false;
|
||||
}
|
||||
|
||||
// Non-const cast required until C++17 is enabled
|
||||
auto* start = static_cast<char*>(_changelogText.data());
|
||||
if (_changelogText.size() >= 3 && utf8_is_bom(start))
|
||||
{
|
||||
start += 3;
|
||||
}
|
||||
|
||||
_changelogLines.clear();
|
||||
_changelogLines.push_back(start);
|
||||
auto ch = start;
|
||||
while (*ch != '\0')
|
||||
{
|
||||
uint8_t c = *ch;
|
||||
if (c == '\n')
|
||||
{
|
||||
*ch++ = 0;
|
||||
_changelogLines.push_back(ch);
|
||||
}
|
||||
else if (utf8_is_format_code(c))
|
||||
{
|
||||
*ch++ = FORMAT_OUTLINE_OFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
ch++;
|
||||
}
|
||||
}
|
||||
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
||||
_changelogLongestLineWidth = 0;
|
||||
for (auto line : _changelogLines)
|
||||
{
|
||||
auto width = gfx_get_string_width(line);
|
||||
_changelogLongestLineWidth = std::max(width, _changelogLongestLineWidth);
|
||||
}
|
||||
window_changelog_process_changelog_text(_changelogText);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void window_changelog_dispose_file()
|
||||
{
|
||||
_changelogText = std::string();
|
||||
_changelogLines.clear();
|
||||
_changelogLines.shrink_to_fit();
|
||||
}
|
||||
|
||||
@@ -1,273 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2020 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <openrct2-ui/interface/Widget.h>
|
||||
#include <openrct2-ui/windows/Window.h>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/OpenRCT2.h>
|
||||
#include <openrct2/PlatformEnvironment.h>
|
||||
#include <openrct2/Version.h>
|
||||
#include <openrct2/core/String.hpp>
|
||||
#include <openrct2/drawing/Drawing.h>
|
||||
#include <openrct2/localisation/Localisation.h>
|
||||
#include <openrct2/platform/platform.h>
|
||||
#include <openrct2/ui/UiContext.h>
|
||||
#include <openrct2/util/Util.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
// clang-format off
|
||||
enum {
|
||||
WIDX_BACKGROUND,
|
||||
WIDX_TITLE,
|
||||
WIDX_CLOSE,
|
||||
WIDX_CONTENT_PANEL,
|
||||
WIDX_SCROLL,
|
||||
WIDX_OPEN_URL,
|
||||
};
|
||||
|
||||
static constexpr const int32_t WW = 500;
|
||||
static constexpr const int32_t WH = 400;
|
||||
static constexpr const rct_string_id WINDOW_TITLE = STR_CHANGELOG_TITLE;
|
||||
constexpr int32_t MIN_WW = 300;
|
||||
constexpr int32_t MIN_WH = 250;
|
||||
|
||||
static rct_widget window_new_version_widgets[] = {
|
||||
WINDOW_SHIM(WINDOW_TITLE, WW, WH),
|
||||
MakeWidget({0, 14}, {500, 382}, WWT_RESIZE, 1 ), // content panel
|
||||
MakeWidget({3, 16}, {495, 366}, WWT_SCROLL, 1, SCROLL_BOTH), // scroll area
|
||||
MakeWidget({3, 473}, {300, 14}, WWT_BUTTON, 1, STR_NEW_RELEASE_DOWNLOAD_PAGE), // changelog button
|
||||
{ WIDGETS_END },
|
||||
};
|
||||
|
||||
static void window_new_version_close(rct_window *w);
|
||||
static void window_new_version_mouseup(rct_window *w, rct_widgetindex widgetIndex);
|
||||
static void window_new_version_resize(rct_window *w);
|
||||
static void window_new_version_scrollgetsize(rct_window *w, int32_t scrollIndex, int32_t *width, int32_t *height);
|
||||
static void window_new_version_invalidate(rct_window *w);
|
||||
static void window_new_version_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
||||
static void window_new_version_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int32_t scrollIndex);
|
||||
|
||||
static rct_window_event_list window_new_version_events = {
|
||||
window_new_version_close,
|
||||
window_new_version_mouseup,
|
||||
window_new_version_resize,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
window_new_version_scrollgetsize,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
window_new_version_invalidate,
|
||||
window_new_version_paint,
|
||||
window_new_version_scrollpaint
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
static void window_new_version_process_info();
|
||||
static void window_new_version_dispose_data();
|
||||
|
||||
static const NewVersionInfo* _newVersionInfo;
|
||||
static std::vector<std::string> _changelogLines;
|
||||
static int32_t _changelogLongestLineWidth = 0;
|
||||
|
||||
rct_window* window_new_version_open()
|
||||
{
|
||||
rct_window* window;
|
||||
|
||||
window = window_bring_to_front_by_class(WC_NEW_VERSION);
|
||||
if (window != nullptr)
|
||||
{
|
||||
return window;
|
||||
}
|
||||
|
||||
if (!GetContext()->HasNewVersionInfo())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
window_new_version_process_info();
|
||||
|
||||
int32_t screenWidth = context_get_width();
|
||||
int32_t screenHeight = context_get_height();
|
||||
|
||||
window = window_create_centred(
|
||||
screenWidth * 4 / 5, screenHeight * 4 / 5, &window_new_version_events, WC_NEW_VERSION, WF_RESIZABLE);
|
||||
window->widgets = window_new_version_widgets;
|
||||
window->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_OPEN_URL);
|
||||
|
||||
window_init_scroll_widgets(window);
|
||||
window->min_width = MIN_WW;
|
||||
window->min_height = MIN_WH;
|
||||
window->max_width = MIN_WW;
|
||||
window->max_height = MIN_WH;
|
||||
|
||||
window->colours[0] = COLOUR_GREY;
|
||||
window->colours[1] = COLOUR_DARK_GREEN;
|
||||
window->colours[2] = COLOUR_DARK_GREEN;
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
static void window_new_version_close([[maybe_unused]] rct_window* w)
|
||||
{
|
||||
window_new_version_dispose_data();
|
||||
}
|
||||
|
||||
static void window_new_version_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
||||
{
|
||||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_CLOSE:
|
||||
window_close(w);
|
||||
break;
|
||||
case WIDX_OPEN_URL:
|
||||
GetContext()->GetUiContext()->OpenURL(_newVersionInfo->url);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void window_new_version_resize(rct_window* w)
|
||||
{
|
||||
int32_t screenWidth = context_get_width();
|
||||
int32_t screenHeight = context_get_height();
|
||||
|
||||
w->max_width = (screenWidth * 4) / 5;
|
||||
w->max_height = (screenHeight * 4) / 5;
|
||||
|
||||
w->min_width = MIN_WW;
|
||||
w->min_height = MIN_WH;
|
||||
|
||||
auto download_button_width = window_new_version_widgets[WIDX_OPEN_URL].width();
|
||||
window_new_version_widgets[WIDX_OPEN_URL].left = (w->width - download_button_width) / 2;
|
||||
window_new_version_widgets[WIDX_OPEN_URL].right = window_new_version_widgets[WIDX_OPEN_URL].left + download_button_width;
|
||||
|
||||
if (w->width < w->min_width)
|
||||
{
|
||||
w->Invalidate();
|
||||
w->width = w->min_width;
|
||||
}
|
||||
if (w->height < w->min_height)
|
||||
{
|
||||
w->Invalidate();
|
||||
w->height = w->min_height;
|
||||
}
|
||||
}
|
||||
|
||||
static void window_new_version_scrollgetsize(
|
||||
[[maybe_unused]] rct_window* w, [[maybe_unused]] int32_t scrollIndex, int32_t* width, int32_t* height)
|
||||
{
|
||||
*width = _changelogLongestLineWidth + 4;
|
||||
|
||||
const int32_t lineHeight = font_get_line_height(gCurrentFontSpriteBase);
|
||||
*height = static_cast<int32_t>(_changelogLines.size() * lineHeight);
|
||||
}
|
||||
|
||||
static void window_new_version_invalidate(rct_window* w)
|
||||
{
|
||||
window_new_version_widgets[WIDX_BACKGROUND].right = w->width - 1;
|
||||
window_new_version_widgets[WIDX_BACKGROUND].bottom = w->height - 1;
|
||||
window_new_version_widgets[WIDX_TITLE].right = w->width - 2;
|
||||
window_new_version_widgets[WIDX_CLOSE].left = w->width - 13;
|
||||
window_new_version_widgets[WIDX_CLOSE].right = w->width - 3;
|
||||
window_new_version_widgets[WIDX_CONTENT_PANEL].right = w->width - 1;
|
||||
window_new_version_widgets[WIDX_CONTENT_PANEL].bottom = w->height - 1;
|
||||
window_new_version_widgets[WIDX_SCROLL].right = w->width - 3;
|
||||
window_new_version_widgets[WIDX_SCROLL].bottom = w->height - 22;
|
||||
window_new_version_widgets[WIDX_OPEN_URL].bottom = w->height - 5;
|
||||
window_new_version_widgets[WIDX_OPEN_URL].top = w->height - 19;
|
||||
}
|
||||
|
||||
static void window_new_version_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
{
|
||||
window_draw_widgets(w, dpi);
|
||||
}
|
||||
|
||||
static void window_new_version_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, [[maybe_unused]] int32_t scrollIndex)
|
||||
{
|
||||
gCurrentFontFlags = 0;
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
||||
|
||||
const int32_t lineHeight = font_get_line_height(gCurrentFontSpriteBase);
|
||||
|
||||
ScreenCoordsXY screenCoords(3, 3 - lineHeight);
|
||||
for (auto line : _changelogLines)
|
||||
{
|
||||
screenCoords.y += lineHeight;
|
||||
if (screenCoords.y + lineHeight < dpi->y || screenCoords.y >= dpi->y + dpi->height)
|
||||
continue;
|
||||
|
||||
gfx_draw_string(dpi, line.c_str(), w->colours[0], screenCoords);
|
||||
}
|
||||
}
|
||||
|
||||
static void window_new_version_process_info()
|
||||
{
|
||||
_newVersionInfo = GetContext()->GetNewVersionInfo();
|
||||
|
||||
std::string::size_type pos = 0;
|
||||
std::string::size_type prev = 0;
|
||||
char version_info[256];
|
||||
|
||||
const char* version_info_ptr = _newVersionInfo->name.c_str();
|
||||
format_string(version_info, 256, STR_NEW_RELEASE_VERSION_INFO, &version_info_ptr);
|
||||
|
||||
_changelogLines.push_back(version_info);
|
||||
_changelogLines.push_back("");
|
||||
|
||||
while ((pos = _newVersionInfo->changelog.find("\n", prev)) != std::string::npos)
|
||||
{
|
||||
std::string line = _newVersionInfo->changelog.substr(prev, pos - prev);
|
||||
for (char* ch = line.data(); *ch != '\0'; ch++)
|
||||
{
|
||||
if (utf8_is_format_code(*ch))
|
||||
{
|
||||
*ch = FORMAT_OUTLINE_OFF;
|
||||
}
|
||||
}
|
||||
_changelogLines.push_back(line);
|
||||
prev = pos + 1;
|
||||
}
|
||||
|
||||
// To get the last substring (or only, if delimiter is not found)
|
||||
_changelogLines.push_back(_newVersionInfo->changelog.substr(prev));
|
||||
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
||||
_changelogLongestLineWidth = 0;
|
||||
for (auto line : _changelogLines)
|
||||
{
|
||||
auto width = gfx_get_string_width(line.c_str());
|
||||
_changelogLongestLineWidth = std::max(width, _changelogLongestLineWidth);
|
||||
}
|
||||
}
|
||||
|
||||
static void window_new_version_dispose_data()
|
||||
{
|
||||
_changelogLines.clear();
|
||||
_changelogLines.shrink_to_fit();
|
||||
}
|
||||
@@ -180,7 +180,7 @@ static void window_title_menu_mouseup(rct_window* w, rct_widgetindex widgetIndex
|
||||
}
|
||||
break;
|
||||
case WIDX_NEW_VERSION:
|
||||
context_open_window(WC_NEW_VERSION);
|
||||
context_open_window_view(WV_NEW_VERSION_INFO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -612,7 +612,7 @@ static void window_top_toolbar_dropdown(rct_window* w, rct_widgetindex widgetInd
|
||||
context_quit();
|
||||
break;
|
||||
case DDIDX_UPDATE_AVAILABLE:
|
||||
context_open_window(WC_NEW_VERSION);
|
||||
context_open_window_view(WV_NEW_VERSION_INFO);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -36,8 +36,7 @@ extern bool gWindowSceneryEyedropperEnabled;
|
||||
|
||||
rct_window* window_about_open();
|
||||
void WindowCampaignRefreshRides();
|
||||
rct_window* window_changelog_open();
|
||||
rct_window* window_new_version_open();
|
||||
rct_window* window_changelog_open(int personality);
|
||||
rct_window* window_cheats_open();
|
||||
rct_window* window_clear_scenery_open();
|
||||
rct_window* custom_currency_window_open();
|
||||
|
||||
@@ -482,7 +482,6 @@ enum
|
||||
WC_VIEW_CLIPPING = 131,
|
||||
WC_OBJECT_LOAD_ERROR = 132,
|
||||
WC_NETWORK = 133,
|
||||
WC_NEW_VERSION = 134,
|
||||
|
||||
// Only used for colour schemes
|
||||
WC_STAFF = 220,
|
||||
@@ -507,6 +506,8 @@ enum
|
||||
WV_NETWORK_PASSWORD,
|
||||
WV_EDITOR_BOTTOM_TOOLBAR,
|
||||
WV_EDITOR_MAIN,
|
||||
WV_CHANGELOG,
|
||||
WV_NEW_VERSION_INFO,
|
||||
};
|
||||
|
||||
enum
|
||||
|
||||
Reference in New Issue
Block a user