From 1ec49d3557562bfb9eff2fc3517a390e293864b9 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 3 Jun 2025 19:54:02 -0500 Subject: [PATCH] Windows 2000 support, part 1 --- CMakeLists.txt | 2 +- scripts/release-winxp.sh | 2 +- src/engine/winStuff.cpp | 2 +- src/fileutils.cpp | 2 +- src/gui/fileDialog.cpp | 21 ++++++++++++++++----- src/gui/fileDialog.h | 10 ++++++++-- src/main.cpp | 2 ++ 7 files changed, 30 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e845bd992..8257e7186 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -188,7 +188,7 @@ list(APPEND DEPENDENCIES_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) if (WIN32) # support Windows XP if (SUPPORT_XP) - list(APPEND DEPENDENCIES_DEFINES "_WIN32_WINNT=0x0501") + list(APPEND DEPENDENCIES_DEFINES "_WIN32_WINNT=0x0500") list(APPEND DEPENDENCIES_DEFINES "SUPPORT_XP") else() # support Windows Vista diff --git a/scripts/release-winxp.sh b/scripts/release-winxp.sh index 953d2d802..423a32974 100755 --- a/scripts/release-winxp.sh +++ b/scripts/release-winxp.sh @@ -16,7 +16,7 @@ fi cd xpbuild # TODO: potential Arch-ism? -i686-w64-mingw32-cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_FLAGS="-O2" -DCMAKE_CXX_FLAGS="-O2 -Wall -Wextra -Wno-unused-parameter -Wno-cast-function-type" -DBUILD_SHARED_LIBS=OFF -DSUPPORT_XP=ON -DWITH_RENDER_DX11=OFF -DSDL_SSE=OFF -DSDL_SSE2=OFF -DSDL_SSE3=OFF -DENABLE_SSE=OFF -DENABLE_SSE2=OFF -DENABLE_AVX=OFF -DENABLE_AVX2=OFF -DUSE_BACKWARD=ON -DCONSOLE_SUBSYSTEM=OFF -DWITH_LOCALE=ON -DUSE_MOMO=ON -DFORCE_CODEVIEW=ON .. || exit 1 +i686-w64-mingw32-cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_FLAGS="-O2" -DCMAKE_CXX_FLAGS="-O2 -Wall -Wextra -Wno-unused-parameter -Wno-cast-function-type" -DBUILD_SHARED_LIBS=OFF -DSUPPORT_XP=ON -DWITH_RENDER_DX11=OFF -DSDL_SSE=OFF -DSDL_SSE2=OFF -DSDL_SSE3=OFF -DENABLE_SSE=OFF -DENABLE_SSE2=OFF -DENABLE_AVX=OFF -DENABLE_AVX2=OFF -DUSE_BACKWARD=OFF -DCONSOLE_SUBSYSTEM=OFF -DWITH_LOCALE=ON -DUSE_MOMO=ON -DFORCE_CODEVIEW=OFF .. || exit 1 make -j8 || exit 1 cd .. diff --git a/src/engine/winStuff.cpp b/src/engine/winStuff.cpp index fccfae277..c4ddf39f3 100644 --- a/src/engine/winStuff.cpp +++ b/src/engine/winStuff.cpp @@ -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"."; } diff --git a/src/fileutils.cpp b/src/fileutils.cpp index c62313fd6..975eaad31 100644 --- a/src/fileutils.cpp +++ b/src/fileutils.cpp @@ -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 diff --git a/src/gui/fileDialog.cpp b/src/gui/fileDialog.cpp index a2634c8bb..b78191f50 100644 --- a/src/gui/fileDialog.cpp +++ b/src/gui/fileDialog.cpp @@ -7,7 +7,7 @@ #include #elif defined(ANDROID) #include -#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 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 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); diff --git a/src/gui/fileDialog.h b/src/gui/fileDialog.h index 78d04fc26..a4dba005e 100644 --- a/src/gui/fileDialog.h +++ b/src/gui/fileDialog.h @@ -19,12 +19,14 @@ #elif defined(ANDROID) #include -#else +#elif (!defined(SUPPORT_XP) || !defined(_WIN32)) namespace pfd { class open_file; class save_file; class select_folder; } +#else +// nothing #endif typedef std::function 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& filter); diff --git a/src/main.cpp b/src/main.cpp index b6e8a3035..6151846bc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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));