Windows 2000 support, part 1

This commit is contained in:
tildearrow 2025-06-03 19:54:02 -05:00
parent f5a6a9ed6c
commit 1ec49d3557
7 changed files with 30 additions and 11 deletions

View file

@ -35,7 +35,7 @@ String getWinConfigPath() {
if (!PathIsDirectoryW(configPath.c_str())) {
logI("creating config dir...");
int mkdirRet;
if ((mkdirRet=SHCreateDirectory(NULL,configPath.c_str()))!=ERROR_SUCCESS) {
if ((mkdirRet=SHCreateDirectoryExW(NULL,configPath.c_str(),NULL))!=ERROR_SUCCESS) {
logW("could not make config dir! (%.8x)",mkdirRet);
configPath=L".";
}

View file

@ -96,7 +96,7 @@ bool dirExists(const char* what) {
bool makeDir(const char* path) {
#ifdef _WIN32
return (SHCreateDirectory(NULL,utf8To16(path).c_str())==ERROR_SUCCESS);
return (SHCreateDirectoryExW(NULL,utf8To16(path).c_str(),NULL)==ERROR_SUCCESS);
#else
return (mkdir(path,0755)==0);
#endif

View file

@ -7,7 +7,7 @@
#include <nfd.h>
#elif defined(ANDROID)
#include <SDL.h>
#else
#elif (!defined(SUPPORT_XP) || !defined(_WIN32))
#include "../../extern/pfd-fixed/portable-file-dialogs.h"
#endif
@ -176,9 +176,12 @@ bool FurnaceGUIFileDialog::openLoad(String header, std::vector<String> filter, S
jniEnv->DeleteLocalRef(class_);
jniEnv->DeleteLocalRef(activity);
return true;
#else
#elif (!defined(SUPPORT_XP) || !defined(_WIN32))
dialogO=new pfd::open_file(header,path,filter,allowMultiple?(pfd::opt::multiselect):(pfd::opt::none));
hasError=!pfd::settings::available();
#else
hasError=true;
return false;
#endif
} else {
hasError=false;
@ -268,9 +271,12 @@ bool FurnaceGUIFileDialog::openSave(String header, std::vector<String> filter, S
jniEnv->DeleteLocalRef(class_);
jniEnv->DeleteLocalRef(activity);
return true;
#else
#elif (!defined(SUPPORT_XP) || !defined(_WIN32))
dialogS=new pfd::save_file(header,path,filter);
hasError=!pfd::settings::available();
#else
hasError=true;
return false;
#endif
} else {
hasError=false;
@ -312,9 +318,12 @@ bool FurnaceGUIFileDialog::openSelectDir(String header, String path, double dpiS
#elif defined(ANDROID)
hasError=true;
return false;
#else
#elif (!defined(SUPPORT_XP) || !defined(_WIN32))
dialogF=new pfd::select_folder(header,path);
hasError=!pfd::settings::available();
#else
hasError=true;
return false;
#endif
} else {
hasError=false;
@ -407,7 +416,7 @@ bool FurnaceGUIFileDialog::render(const ImVec2& min, const ImVec2& max) {
#elif defined(ANDROID)
// TODO: detect when file picker is closed
return false;
#else
#elif (!defined(SUPPORT_XP) || !defined(_WIN32))
if (dialogType==2) {
if (dialogF!=NULL) {
if (dialogF->ready(0)) {
@ -455,6 +464,8 @@ bool FurnaceGUIFileDialog::render(const ImVec2& min, const ImVec2& max) {
logE("what!");
}
return false;
#else
return false;
#endif
} else {
return ImGuiFileDialog::Instance()->Display("FileDialog",ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollWithMouse,min,max);

View file

@ -19,12 +19,14 @@
#elif defined(ANDROID)
#include <jni.h>
#else
#elif (!defined(SUPPORT_XP) || !defined(_WIN32))
namespace pfd {
class open_file;
class save_file;
class select_folder;
}
#else
// nothing
#endif
typedef std::function<void(const char*)> FileDialogSelectCallback;
@ -48,10 +50,14 @@ class FurnaceGUIFileDialog {
void* dialogO;
void* dialogS;
void* dialogF;
#else
#elif (!defined(SUPPORT_XP) || !defined(_WIN32))
pfd::open_file* dialogO;
pfd::save_file* dialogS;
pfd::select_folder* dialogF;
#else
unsigned char* dialogO;
unsigned char* dialogS;
unsigned char* dialogF;
#endif
void convertFilterList(std::vector<String>& filter);

View file

@ -545,12 +545,14 @@ int main(int argc, char** argv) {
// Windows console thing - thanks dj.tuBIG/MaliceX
#ifdef _WIN32
#ifndef TA_SUBSYSTEM_CONSOLE
#ifndef SUPPORT_XP
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
freopen("CONIN$", "r", stdin);
}
#endif
#endif
#endif
srand(time(NULL));