mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-06 06:32:56 +01:00
Fix changelog
This commit is contained in:
@@ -17,15 +17,18 @@
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/OpenRCT2.h>
|
||||
#include <openrct2/core/Math.hpp>
|
||||
#include <openrct2/core/String.hpp>
|
||||
#include <openrct2/localisation/Localisation.h>
|
||||
#include <openrct2/OpenRCT2.h>
|
||||
#include <openrct2/platform/platform.h>
|
||||
#include <openrct2/PlatformEnvironment.h>
|
||||
#include <openrct2/util/Util.h>
|
||||
#include <openrct2-ui/windows/Window.h>
|
||||
#include <openrct2-ui/interface/Widget.h>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
enum {
|
||||
WIDX_BACKGROUND,
|
||||
WIDX_TITLE,
|
||||
@@ -198,17 +201,25 @@ static void window_changelog_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi,
|
||||
}
|
||||
}
|
||||
|
||||
static std::string GetChangelogPath()
|
||||
{
|
||||
auto env = GetContext()->GetPlatformEnvironment();
|
||||
return env->GetFilePath(PATHID::CHANGELOG);
|
||||
}
|
||||
|
||||
static std::string GetChangelogText()
|
||||
{
|
||||
utf8 path[MAX_PATH];
|
||||
platform_get_changelog_path(path, sizeof(path));
|
||||
|
||||
auto path = GetChangelogPath();
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
auto pathW = String::ToUtf16(path);
|
||||
auto fs = std::ifstream(pathW, std::ios::out | std::ios::app);
|
||||
auto fs = std::ifstream(pathW, std::ios::in);
|
||||
#else
|
||||
auto fs = std::ifstream(path, std::ios::out | std::ios::app);
|
||||
auto fs = std::ifstream(path, std::ios::in);
|
||||
#endif
|
||||
if (!fs.is_open())
|
||||
{
|
||||
throw std::runtime_error("Unable to open " + path);
|
||||
}
|
||||
return std::string((std::istreambuf_iterator<char>(fs)), std::istreambuf_iterator<char>());
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +99,8 @@ private:
|
||||
return DIRBASE::RCT1;
|
||||
case PATHID::SCORES_RCT2:
|
||||
return DIRBASE::RCT2;
|
||||
case PATHID::CHANGELOG:
|
||||
return DIRBASE::DOCUMENTATION;
|
||||
case PATHID::NETWORK_GROUPS:
|
||||
case PATHID::NETWORK_SERVERS:
|
||||
case PATHID::NETWORK_USERS:
|
||||
@@ -134,6 +136,7 @@ IPlatformEnvironment * OpenRCT2::CreatePlatformEnvironment()
|
||||
basePaths[(size_t)DIRBASE::USER] = Path::Combine(Platform::GetFolderPath(SPECIAL_FOLDER::USER_DATA), subDirectory);
|
||||
basePaths[(size_t)DIRBASE::CONFIG] = Path::Combine(Platform::GetFolderPath(SPECIAL_FOLDER::USER_CONFIG), subDirectory);
|
||||
basePaths[(size_t)DIRBASE::CACHE] = Path::Combine(Platform::GetFolderPath(SPECIAL_FOLDER::USER_CACHE), subDirectory);
|
||||
basePaths[(size_t)DIRBASE::DOCUMENTATION] = Platform::GetDocsPath();
|
||||
|
||||
// Override paths that have been specified via the command line
|
||||
if (!String::IsNullOrEmpty(gCustomRCT2DataPath))
|
||||
@@ -151,6 +154,11 @@ IPlatformEnvironment * OpenRCT2::CreatePlatformEnvironment()
|
||||
basePaths[(size_t)DIRBASE::CACHE] = gCustomUserDataPath;
|
||||
}
|
||||
|
||||
if (basePaths[(size_t)DIRBASE::DOCUMENTATION].empty())
|
||||
{
|
||||
basePaths[(size_t)DIRBASE::DOCUMENTATION] = basePaths[(size_t)DIRBASE::OPENRCT2];
|
||||
}
|
||||
|
||||
auto env = OpenRCT2::CreatePlatformEnvironment(basePaths);
|
||||
|
||||
// Now load the config so we can get the RCT1 and RCT2 paths
|
||||
@@ -225,5 +233,6 @@ const char * PlatformEnvironment::FileNames[] =
|
||||
"highscores.dat", // SCORES
|
||||
"scores.dat", // SCORES (LEGACY)
|
||||
"Saved Games" PATH_SEPARATOR "scores.dat", // SCORES (RCT2)
|
||||
"changelog.txt" // CHANGELOG
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@@ -31,8 +31,9 @@ namespace OpenRCT2
|
||||
USER, // Base directory for OpenRCT2 user content.
|
||||
CONFIG, // Base directory for OpenRCT2 configuration.
|
||||
CACHE, // Base directory for OpenRCT2 cache files.
|
||||
DOCUMENTATION, // Base directory for OpenRCT2 doc files.
|
||||
};
|
||||
constexpr sint32 DIRBASE_COUNT = 6;
|
||||
constexpr sint32 DIRBASE_COUNT = 7;
|
||||
using DIRBASE_VALUES = std::string[DIRBASE_COUNT];
|
||||
|
||||
enum class DIRID
|
||||
@@ -67,6 +68,7 @@ namespace OpenRCT2
|
||||
SCORES, // Scenario scores (highscores.dat).
|
||||
SCORES_LEGACY, // Scenario scores, legacy (scores.dat).
|
||||
SCORES_RCT2, // Scenario scores, rct2 (\Saved Games\scores.dat).
|
||||
CHANGELOG, // Notable changes to the game between versions, distributed with the game.
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -69,11 +69,6 @@ float platform_get_default_scale() {
|
||||
return displayScale;
|
||||
}
|
||||
|
||||
void platform_get_changelog_path(utf8 *outPath, size_t outSize)
|
||||
{
|
||||
STUB();
|
||||
}
|
||||
|
||||
bool platform_get_steam_path(utf8 * outPath, size_t outSize)
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -108,27 +108,6 @@ void platform_posix_sub_resolve_openrct_data_path(utf8 *out, size_t size) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Default directory fallback is:
|
||||
* - <exePath>/doc
|
||||
* - /usr/share/doc/openrct2
|
||||
*/
|
||||
static void platform_posix_sub_resolve_openrct_doc_path(utf8 *out, size_t size) {
|
||||
static const utf8 *searchLocations[] = {
|
||||
"./doc",
|
||||
"/usr/share/doc/openrct2",
|
||||
};
|
||||
for (auto searchLocation : searchLocations)
|
||||
{
|
||||
log_verbose("Looking for OpenRCT2 doc path at %s", searchLocation);
|
||||
if (platform_directory_exists(searchLocation))
|
||||
{
|
||||
safe_strcpy(out, searchLocation, size);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint16 platform_get_locale_language(){
|
||||
const char *langString = setlocale(LC_MESSAGES, "");
|
||||
if(langString != NULL){
|
||||
@@ -218,12 +197,6 @@ uint8 platform_get_locale_measurement_format(){
|
||||
return MEASUREMENT_FORMAT_METRIC;
|
||||
}
|
||||
|
||||
void platform_get_changelog_path(utf8 *outPath, size_t outSize)
|
||||
{
|
||||
platform_posix_sub_resolve_openrct_doc_path(outPath, outSize);
|
||||
safe_strcat_path(outPath, "changelog.txt", outSize);
|
||||
}
|
||||
|
||||
bool platform_get_steam_path(utf8 * outPath, size_t outSize)
|
||||
{
|
||||
const char * steamRoot = getenv("STEAMROOT");
|
||||
|
||||
@@ -34,6 +34,11 @@ namespace Platform
|
||||
return std::string();
|
||||
}
|
||||
}
|
||||
|
||||
std::string GetDocsPath()
|
||||
{
|
||||
return std::string();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <pwd.h>
|
||||
#include "../core/Path.hpp"
|
||||
#include "platform.h"
|
||||
#include "Platform2.h"
|
||||
|
||||
namespace Platform
|
||||
@@ -44,6 +45,24 @@ namespace Platform
|
||||
return std::string();
|
||||
}
|
||||
}
|
||||
|
||||
std::string GetDocsPath()
|
||||
{
|
||||
static const utf8 * searchLocations[] =
|
||||
{
|
||||
"./doc",
|
||||
"/usr/share/doc/openrct2",
|
||||
};
|
||||
for (auto searchLocation : searchLocations)
|
||||
{
|
||||
log_verbose("Looking for OpenRCT2 doc path at %s", searchLocation);
|
||||
if (platform_directory_exists(searchLocation))
|
||||
{
|
||||
return searchLocation;
|
||||
}
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -147,6 +147,11 @@ namespace Platform
|
||||
return path;
|
||||
}
|
||||
|
||||
std::string GetDocsPath()
|
||||
{
|
||||
return std::string();
|
||||
}
|
||||
|
||||
static SYSTEMTIME TimeToSystemTime(std::time_t timestamp)
|
||||
{
|
||||
LONGLONG ll = Int32x32To64(timestamp, 10000000) + 116444736000000000;
|
||||
|
||||
@@ -39,6 +39,11 @@ namespace Platform
|
||||
return std::string();
|
||||
}
|
||||
}
|
||||
|
||||
std::string GetDocsPath()
|
||||
{
|
||||
return std::string();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace Platform
|
||||
std::string GetEnvironmentVariable(const std::string &name);
|
||||
std::string GetFolderPath(SPECIAL_FOLDER folder);
|
||||
std::string GetInstallPath();
|
||||
std::string GetDocsPath();
|
||||
|
||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__)
|
||||
std::string GetEnvironmentPath(const char * name);
|
||||
|
||||
@@ -244,12 +244,6 @@ void platform_get_openrct_data_path(utf8 *outPath, size_t outSize)
|
||||
safe_strcpy(outPath, _openrctDataDirectoryPath, outSize);
|
||||
}
|
||||
|
||||
void platform_get_changelog_path(utf8 *outPath, size_t outSize)
|
||||
{
|
||||
safe_strcpy(outPath, gExePath, outSize);
|
||||
safe_strcat_path(outPath, "changelog.txt", outSize);
|
||||
}
|
||||
|
||||
bool platform_get_steam_path(utf8 * outPath, size_t outSize)
|
||||
{
|
||||
wchar_t * wSteamPath;
|
||||
|
||||
@@ -127,7 +127,6 @@ uint8 platform_get_locale_measurement_format();
|
||||
uint8 platform_get_locale_temperature_format();
|
||||
uint8 platform_get_locale_date_format();
|
||||
bool platform_process_is_elevated();
|
||||
void platform_get_changelog_path(utf8 *outPath, size_t outSize);
|
||||
bool platform_get_steam_path(utf8 * outPath, size_t outSize);
|
||||
|
||||
#ifndef NO_TTF
|
||||
|
||||
Reference in New Issue
Block a user