OpenTTD Source 20241224-master-gf74b0cf984
|
Implementation of MS Windows system calls. More...
#include "../../stdafx.h"
#include "../../debug.h"
#include "../../gfx_func.h"
#include "../../textbuf_gui.h"
#include "../../fileio_func.h"
#include <windows.h>
#include <fcntl.h>
#include <mmsystem.h>
#include <regstr.h>
#include <shlobj.h>
#include <shellapi.h>
#include <winnls.h>
#include "win32.h"
#include "../../fios.h"
#include "../../core/alloc_func.hpp"
#include "../../string_func.h"
#include <sys/stat.h>
#include "../../language.h"
#include "../../thread.h"
#include "../../library_loader.h"
#include "../../safeguards.h"
Go to the source code of this file.
Macros | |
#define | NO_SHOBJIDL_SORTDIRECTION |
#define | SORT_DIGITSASNUMBERS 0x00000008 |
#define | LINGUISTIC_IGNORECASE 0x00000010 |
Functions | |
bool | MyShowCursor (bool show, bool toggle) |
void | ShowOSErrorBox (const char *buf, bool) |
void | OSOpenBrowser (const std::string &url) |
bool | FiosIsRoot (const std::string &file) |
void | FiosGetDrives (FileList &file_list) |
bool | FiosIsHiddenFile (const std::filesystem::path &path) |
std::optional< uint64_t > | FiosGetDiskFreeSpace (const std::string &path) |
void | CreateConsole () |
static std::string | ConvertLfToCrLf (std::string_view msg) |
Replace linefeeds with carriage-return and linefeed. | |
static INT_PTR CALLBACK | HelpDialogFunc (HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam) |
Callback function to handle the window. | |
void | ShowInfoI (const std::string &str) |
char * | getcwd (char *buf, size_t size) |
void | DetermineBasePaths (const char *exe) |
std::optional< std::string > | GetClipboardContents () |
Try to retrieve the current clipboard contents. | |
std::string | FS2OTTD (const std::wstring &name) |
Convert to OpenTTD's encoding from a wide string. | |
std::wstring | OTTD2FS (const std::string &name) |
Convert from OpenTTD's encoding to a wide string. | |
char * | convert_from_fs (const std::wstring_view src, std::span< char > dst_buf) |
Convert to OpenTTD's encoding from that of the environment in UNICODE. | |
wchar_t * | convert_to_fs (const std::string_view src, std::span< wchar_t > dst_buf) |
Convert from OpenTTD's encoding to that of the environment in UNICODE. | |
const char * | GetCurrentLocale (const char *) |
Determine the current user's locale. | |
void | Win32SetCurrentLocaleName (std::string iso_code) |
int | OTTDStringCompare (std::string_view s1, std::string_view s2) |
int | Win32StringContains (const std::string_view str, const std::string_view value, bool case_insensitive) |
Search if a string is contained in another string using the current locale. | |
void | SetCurrentThreadName (const char *) |
Name the thread this function is called on for the debugger. | |
Variables | |
static bool | _has_console |
static bool | _cursor_disable = true |
static bool | _cursor_visible = true |
std::string | _config_file |
Configuration file of OpenTTD. | |
static WCHAR | _cur_iso_locale [16] = L"" |
Implementation of MS Windows system calls.
Definition in file win32.cpp.
char * convert_from_fs | ( | const std::wstring_view | src, |
std::span< char > | dst_buf | ||
) |
Convert to OpenTTD's encoding from that of the environment in UNICODE.
OpenTTD encoding is UTF8, local is wide.
src | wide string that will be converted |
dst_buf | span of valid char buffer that will receive the converted string |
Definition at line 372 of file win32.cpp.
Referenced by HandleIMEComposition(), MusicDriver_DMusic::Start(), and MusicDriver_Win32::Start().
wchar_t * convert_to_fs | ( | const std::string_view | src, |
std::span< wchar_t > | dst_buf | ||
) |
Convert from OpenTTD's encoding to that of the environment in UNICODE.
OpenTTD encoding is UTF8, local is wide.
src | string that will be converted |
dst_buf | span of valid wide-char buffer that will receive the converted string |
Definition at line 389 of file win32.cpp.
Referenced by HFontFromFont(), and LoadWin32Font().
|
static |
std::optional< uint64_t > FiosGetDiskFreeSpace | ( | const std::string & | path | ) |
bool FiosIsHiddenFile | ( | const std::filesystem::path & | path | ) |
std::string FS2OTTD | ( | const std::wstring & | name | ) |
Convert to OpenTTD's encoding from a wide string.
OpenTTD internal encoding is UTF8.
name | valid string that will be converted (local, or wide) |
Definition at line 337 of file win32.cpp.
Referenced by _ValidateSignatureFile(), TarScanner::AddFile(), NetworkError::AsString(), DetermineBasePaths(), FillLanguageList(), FiosGetFileList(), GetClipboardContents(), HandleIMEComposition(), InitializeLanguagePacks(), openttd_main(), ReadLanguagePack(), ReconsiderGameScriptLanguage(), NetworkAddress::Resolve(), ScanPath(), and SurveyConfiguration().
std::optional< std::string > GetClipboardContents | ( | ) |
const char * GetCurrentLocale | ( | const char * | ) |
|
static |
std::wstring OTTD2FS | ( | const std::string & | name | ) |
Convert from OpenTTD's encoding to a wide string.
OpenTTD internal encoding is UTF8.
name | valid string that will be converted (UTF8) |
console_cp | convert to the console encoding instead of the normal system encoding. |
Definition at line 354 of file win32.cpp.
Referenced by _ValidateSignatureFile(), FiosFileScanner::AddFile(), TarScanner::AddFile(), DetermineBasePaths(), FileExists(), FillLanguageList(), FioCreateDirectory(), FioRemove(), FiosGetFileList(), VideoDriver_Win32Base::MakeWindow(), FileHandle::Open(), openttd_main(), IniFile::SaveToDisk(), FileScanner::Scan(), and FileScanner::Scan().
int OTTDStringCompare | ( | std::string_view | s1, |
std::string_view | s2 | ||
) |
void SetCurrentThreadName | ( | const char * | name | ) |
Name the thread this function is called on for the debugger.
name | Name to set for the thread.. |
Definition at line 540 of file win32.cpp.
Referenced by StartNewThread().
int Win32StringContains | ( | const std::string_view | str, |
const std::string_view | value, | ||
bool | case_insensitive | ||
) |
Search if a string is contained in another string using the current locale.
str | String to search in. |
value | String to search for. |
case_insensitive | Search case-insensitive. |
Definition at line 479 of file win32.cpp.
References LibraryLoader::GetFunction().
Referenced by StrNaturalContains(), and StrNaturalContainsIgnoreCase().
|
extern |
Configuration file of OpenTTD.
Definition at line 60 of file settings.cpp.
Referenced by DeleteGRFPresetFromConfig(), GetGRFPresetList(), LoadFromConfig(), LoadGRFPresetFromConfig(), SaveGRFPresetToConfig(), and SaveToConfig().