diff --git a/Siv3D/include/Siv3D/System.hpp b/Siv3D/include/Siv3D/System.hpp index ccc7659c2..6da9e082d 100644 --- a/Siv3D/include/Siv3D/System.hpp +++ b/Siv3D/include/Siv3D/System.hpp @@ -104,6 +104,16 @@ namespace s3d /// @param fileName ファイル名 | File name /// @return テキストエディタの起動に成功した場合 true, それ以外の場合は false | Returns true if the text editor was launched successfully, otherwise false. bool LaunchFileWithTextEditor(FilePathView fileName); + + /// @brief プログラムが Visual Studio で実行されているかを返します。 | Returns whether the program is running in Visual Studio. + /// @return プログラムが Visual Studio で実行されている場合 true, それ以外の場合は false | Returns true if the program is running in Visual Studio, false otherwise + [[nodiscard]] + bool IsRunningInVisualStudio(); + + /// @brief プログラムが Xcode で実行されているかを返します。 | Returns whether the program is running in Xcode. + /// @return プログラムが Xcode で実行されている場合 true, それ以外の場合は false | Returns true if the program is running in Xcode, false otherwise + [[nodiscard]] + bool IsRunningInXcode(); } # if SIV3D_PLATFORM(WEB) diff --git a/Siv3D/src/Siv3D-Platform/Linux/Siv3D/System/SivSystem_Linux.cpp b/Siv3D/src/Siv3D-Platform/Linux/Siv3D/System/SivSystem_Linux.cpp index c57d77de9..1cc2b9f11 100644 --- a/Siv3D/src/Siv3D-Platform/Linux/Siv3D/System/SivSystem_Linux.cpp +++ b/Siv3D/src/Siv3D-Platform/Linux/Siv3D/System/SivSystem_Linux.cpp @@ -231,5 +231,15 @@ namespace s3d return (std::system(command.c_str()) == 0); } + + bool IsRunningInVisualStudio() + { + return false; + } + + bool IsRunningInXcode() + { + return false; + } } } diff --git a/Siv3D/src/Siv3D-Platform/Web/Siv3D/System/SivSystem_Web.cpp b/Siv3D/src/Siv3D-Platform/Web/Siv3D/System/SivSystem_Web.cpp index 0af909d7f..5c68d5741 100644 --- a/Siv3D/src/Siv3D-Platform/Web/Siv3D/System/SivSystem_Web.cpp +++ b/Siv3D/src/Siv3D-Platform/Web/Siv3D/System/SivSystem_Web.cpp @@ -52,6 +52,16 @@ namespace s3d { return false; } + + bool IsRunningInVisualStudio() + { + return false; + } + + bool IsRunningInXcode() + { + return false; + } } namespace Platform::Web::System diff --git a/Siv3D/src/Siv3D-Platform/WindowsDesktop/Siv3D/System/SivSystem_Windows.cpp b/Siv3D/src/Siv3D-Platform/WindowsDesktop/Siv3D/System/SivSystem_Windows.cpp index eb3cb5668..009e1f5c6 100644 --- a/Siv3D/src/Siv3D-Platform/WindowsDesktop/Siv3D/System/SivSystem_Windows.cpp +++ b/Siv3D/src/Siv3D-Platform/WindowsDesktop/Siv3D/System/SivSystem_Windows.cpp @@ -19,6 +19,26 @@ namespace s3d { + namespace + { + [[nodiscard]] + static bool IsRunningInVisualStudio_impl() + { + wchar_t* pValue; + size_t len; + errno_t err = ::_wdupenv_s(&pValue, &len, L"VisualStudioVersion"); + + if (err || (not pValue)) + { + return false; + } + + std::free(pValue); + + return true; + } + } + namespace System { void Sleep(const int32 milliseconds) @@ -177,5 +197,17 @@ namespace s3d return (::ShellExecuteExW(&sei) != 0); } + + bool IsRunningInVisualStudio() + { + static const bool result = IsRunningInVisualStudio_impl(); + + return result; + } + + bool IsRunningInXcode() + { + return false; + } } } diff --git a/Siv3D/src/Siv3D-Platform/macOS/Siv3D/System/SivSystem_macOS.mm b/Siv3D/src/Siv3D-Platform/macOS/Siv3D/System/SivSystem_macOS.mm index f053eee05..6a37d8f58 100644 --- a/Siv3D/src/Siv3D-Platform/macOS/Siv3D/System/SivSystem_macOS.mm +++ b/Siv3D/src/Siv3D-Platform/macOS/Siv3D/System/SivSystem_macOS.mm @@ -47,6 +47,12 @@ static bool MacOS_OpenHTMLInBrowser(const char* _path) } } + + [[nodiscard]] + static bool IsRunningInXcode_impl() + { + return (std::getenv("__XCODE_BUILT_PRODUCTS_DIR_PATHS") != nullptr); + } } namespace System @@ -190,5 +196,17 @@ bool LaunchFileWithTextEditor(const FilePathView fileName) return (std::system(command.c_str()) == 0); } + + bool IsRunningInVisualStudio() + { + return false; + } + + bool IsRunningInXcode() + { + static const bool result = detail::IsRunningInXcode_impl(); + + return result; + } } }