diff options
| author | Stephen Enders <84310577289916ceefd4132143fb36b63a5f0c71> | 2022-06-24 21:35:03 -0400 | 
|---|---|---|
| committer | Steph Enders <smenders@gmail.com> | 2022-06-24 17:37:11 -0400 | 
| commit | de7cc1f12273ae80f4d972b0dbfc48066f851684 (patch) | |
| tree | 5007501ef4a00828b2febe4d48656da6eaace228 /src/resources/windows/WindowsResources.cpp | |
| parent | ab37629c6e4798654fca1d533a611da7986b5053 (diff) | |
Fix compilation for Windows
I left a few changes undone in the Windows API.
This should be cross platform now
Diffstat (limited to 'src/resources/windows/WindowsResources.cpp')
| -rw-r--r-- | src/resources/windows/WindowsResources.cpp | 52 | 
1 files changed, 28 insertions, 24 deletions
diff --git a/src/resources/windows/WindowsResources.cpp b/src/resources/windows/WindowsResources.cpp index cfe264f..4ef0e2e 100644 --- a/src/resources/windows/WindowsResources.cpp +++ b/src/resources/windows/WindowsResources.cpp @@ -23,32 +23,36 @@  //    distribution.  //  //======================================================================== -#include "../Resources.h" +#include "WindowsResources.h"  #include <libloaderapi.h>  #define MAX_BUF_SIZE 1024 -class WindowsResources : public Resources { +std::filesystem::path exeDir; +std::filesystem::path workingDir; -protected: -  std::filesystem::path exeDir; -  std::filesystem::path workingDir; +std::vector<std::filesystem::path> WindowsResources::levelSearchDirs() { +  return {workingDir / "maps", exeDir / "maps"}; +} +std::vector<std::filesystem::path> WindowsResources::defaultsSearchDirs() { +  return {workingDir / "dnglib", exeDir / "dnglib"}; +} +std::vector<std::filesystem::path> WindowsResources::fontSearchDirs() { +  return {workingDir / "res", exeDir / "res"}; +} +WindowsResources::WindowsResources() : Resources() { +  this->workingDir = std::filesystem::current_path(); +  this->font = std::make_shared<std::filesystem::path>(workingDir / "res" / +                                                           DEFAULT_FONT); -  std::vector<std::filesystem::path> levelSearchDirs() override { -    return {workingDir / "maps", exeDir / "maps"}; -  } -  std::vector<std::filesystem::path> defaultsSearchDirs() override { -    return {workingDir / "dnglib", exeDir / "dnglib"}; -  } -  std::vector<std::filesystem::path> fontSearchDirs() override { -    return {workingDir / "res", exeDir / "res"}; -  } +  char exe_dir_str[255]; +  GetModuleFileNameA(nullptr, exe_dir_str, 255); +  this->exeDir = std::filesystem::path{exe_dir_str}.remove_filename(); +} -public: -  const char *convert_to_str(std::filesystem::path &path) override { -    std::setlocale(LC_ALL, "en_US.utf8"); // TODO more support? -    const wchar_t *wstr = path.c_str(); -    size_t len = std::wcslen(wstr) + 1; // gotta get that \0 -    char *ret = static_cast<char *>(malloc(sizeof(char) * len)); // buffered -    std::wcstombs(ret, path.c_str(), len); -    return ret; -  } -};
\ No newline at end of file +const char *WindowsResources::convert_to_str(std::filesystem::path &path) { +  std::setlocale(LC_ALL, "en_US.utf8"); // TODO more support? +  const wchar_t *wstr = path.c_str(); +  size_t len = std::wcslen(wstr) + 1; // gotta get that \0 +  char *ret = static_cast<char *>(malloc(sizeof(char) * len)); // buffered +  std::wcstombs(ret, path.c_str(), len); +  return ret; +}  |