diff options
author | Aki <please@ignore.pl> | 2024-03-09 23:02:17 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2024-03-09 23:02:17 +0100 |
commit | e1606f9bbc45e7ba57c461dc1ca4d4a86c5d76dd (patch) | |
tree | d13c968b28d8f9a076b7fed0d6f098fc448ce87c /InfoEx/src | |
parent | eced12a69603e23d6869f92a2d5302f4605354ba (diff) | |
download | starshatter-e1606f9bbc45e7ba57c461dc1ca4d4a86c5d76dd.zip starshatter-e1606f9bbc45e7ba57c461dc1ca4d4a86c5d76dd.tar.gz starshatter-e1606f9bbc45e7ba57c461dc1ca4d4a86c5d76dd.tar.bz2 |
Replaced MachineInfo with stripped cross-platform solution
It could easily handle more, but is there really need for it? Having
some information about the machine in logs is nice, but with the
current state of affairs most of errors are coming from bad pointer
uses than anything else...
InfoEx is STATIC, because it seems FoundationEx can cause multiple
definitions in scenarios like this.
Diffstat (limited to 'InfoEx/src')
-rw-r--r-- | InfoEx/src/description.cpp | 53 | ||||
-rw-r--r-- | InfoEx/src/directx_other.cpp | 22 | ||||
-rw-r--r-- | InfoEx/src/directx_win32.cpp | 28 |
3 files changed, 103 insertions, 0 deletions
diff --git a/InfoEx/src/description.cpp b/InfoEx/src/description.cpp new file mode 100644 index 0000000..5635de5 --- /dev/null +++ b/InfoEx/src/description.cpp @@ -0,0 +1,53 @@ +#include <InfoEx.h> + +#include <infoware/infoware.hpp> + +#include <Text.h> + + +namespace +{ + + +static constexpr const char* prefixes[] {"", "k", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q"}; + + +Text +HumanReadable(long double value, const char* unit) +{ + int magnitude = 0; + while (value > 1000) { + value /= 1000; + magnitude++; + } + return Text::format("%.2Lf %s%s", value, prefixes[magnitude], unit); +} + + +} // namespace + + +namespace InfoEx +{ + + +Text +ShortDescription() +{ + return iware::system::OS_info().full_name.data(); +} + + +Text +LongDescription() +{ + return Text::format( + "OS: %s\nPhysical memory: %s\nCPU: %s\nCPU frequency: %s", + iware::system::OS_info().full_name.data(), + HumanReadable(iware::system::memory().physical_total, "B").data(), + iware::cpu::model_name().data(), + HumanReadable(iware::cpu::frequency(), "Hz").data()); +} + + +} // namespace InfoEx diff --git a/InfoEx/src/directx_other.cpp b/InfoEx/src/directx_other.cpp new file mode 100644 index 0000000..75d1d39 --- /dev/null +++ b/InfoEx/src/directx_other.cpp @@ -0,0 +1,22 @@ +#ifndef _WIN32 + +#include <InfoEx.h> + +#include <Text.h> + + +namespace InfoEx +{ + + +DXVersion +DirectX() +{ + return DXVersion::None; +} + + +} // namespace InfoEx + + +#endif // _WIN32 diff --git a/InfoEx/src/directx_win32.cpp b/InfoEx/src/directx_win32.cpp new file mode 100644 index 0000000..4ade30b --- /dev/null +++ b/InfoEx/src/directx_win32.cpp @@ -0,0 +1,28 @@ +#ifdef _WIN32 + +#include <InfoEx.h> + +#include <windows.h> + +#include <Text.h> + + +namespace InfoEx +{ + + +DXVersion +DirectX() +{ + auto lib = LoadLibrary("D3D9.DLL"); + if (lib == nullptr) + return DXVersion::None; + FreeLibrary(lib); + return DXVersion::Dx9; +} + + +} // namespace InfoEx + + +#endif // _WIN32 |