Merge branch 'master' into jgrpp

# Conflicts:
#	src/console.cpp
#	src/os/os2/os2.cpp
#	src/os/unix/font_unix.cpp
#	src/strgen/strgen.h
#	src/strgen/strgen_base.cpp
#	src/table/settings/gui_settings.ini
This commit is contained in:
Jonathan G Rennison
2023-09-02 20:46:57 +01:00
24 changed files with 240 additions and 362 deletions

View File

@@ -14,10 +14,13 @@
#include "../../core/format.hpp"
#include <nlohmann/json.hpp>
#include <thread>
#include <windows.h>
#include "../../safeguards.h"
extern std::string SurveyMemoryToText(uint64_t memory);
void SurveyOS(nlohmann::json &json)
{
_OSVERSIONINFOA os;
@@ -31,7 +34,8 @@ void SurveyOS(nlohmann::json &json)
status.dwLength = sizeof(status);
GlobalMemoryStatusEx(&status);
json["memory"] = status.ullTotalPhys;
json["memory"] = SurveyMemoryToText(status.ullTotalPhys);
json["hardware_concurrency"] = std::thread::hardware_concurrency();
}
#endif /* WITH_NLOHMANN_JSON */

View File

@@ -549,26 +549,19 @@ void DetermineBasePaths(const char *exe)
}
bool GetClipboardContents(char *buffer, const char *last)
std::optional<std::string> GetClipboardContents()
{
HGLOBAL cbuf;
const char *ptr;
if (!IsClipboardFormatAvailable(CF_UNICODETEXT)) return std::nullopt;
if (IsClipboardFormatAvailable(CF_UNICODETEXT)) {
OpenClipboard(nullptr);
cbuf = GetClipboardData(CF_UNICODETEXT);
OpenClipboard(nullptr);
HGLOBAL cbuf = GetClipboardData(CF_UNICODETEXT);
ptr = (const char*)GlobalLock(cbuf);
int out_len = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)ptr, -1, buffer, (last - buffer) + 1, nullptr, nullptr);
GlobalUnlock(cbuf);
CloseClipboard();
std::string result = FS2OTTD(static_cast<LPCWSTR>(GlobalLock(cbuf)));
GlobalUnlock(cbuf);
CloseClipboard();
if (out_len == 0) return false;
} else {
return false;
}
return true;
if (result.empty()) return std::nullopt;
return result;
}