Skip to content

Commit 8b16a93

Browse files
committed
Add system info
1 parent d37970d commit 8b16a93

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
"clock.hpp": "c",
7878
"stringextensions.hpp": "c",
7979
"reent.h": "c",
80-
"mutex.hpp": "c"
80+
"mutex.hpp": "c",
81+
"iomanip": "cpp"
8182
}
8283
}

Library/Sources/CTRPluginFrameworkImpl/Menu/PluginMenuTools.cpp

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#include <iomanip>
2+
#include <sstream>
3+
#include <time.h>
14
#include <Headers.hpp>
25

36
namespace CTRPluginFramework {
@@ -594,6 +597,45 @@ namespace CTRPluginFramework {
594597
_menu.Draw();
595598
}
596599

600+
string SystemModel() {
601+
u8 model = 0;
602+
std::stringstream models;
603+
604+
vector<string> Model = {
605+
"Old 3DS",
606+
"Old 3DS XL",
607+
"New 3DS",
608+
"Old 2DS",
609+
"New 3DS XL",
610+
"New 2DS XL"
611+
};
612+
613+
CFGU_GetSystemModel(&model);
614+
models << Model[model];
615+
return models.str();
616+
}
617+
618+
string InternetAccess() {
619+
std::stringstream netStatus;
620+
netStatus << "Wi-Fi: " << (System::IsConnectedToInternet() ? "On" : "Off");
621+
return netStatus.str();
622+
}
623+
624+
string CurrentTime() {
625+
std::ostringstream currentTime;
626+
627+
time_t unixTime = time(NULL);
628+
struct tm* timeStruct = gmtime((const time_t*)&unixTime);
629+
630+
int hours = timeStruct->tm_hour;
631+
int minutes = timeStruct->tm_min;
632+
int seconds = timeStruct->tm_sec;
633+
634+
currentTime << "Time: " << std::setw(2) << std::setfill('0') << hours << ":" << std::setw(2) << minutes << ":" << std::setw(2) << seconds;
635+
636+
return currentTime.str();
637+
}
638+
597639
static const char text1[] = "Brought to you";
598640
static const char nextText[] = "by semaj14";
599641

@@ -607,10 +649,13 @@ namespace CTRPluginFramework {
607649

608650
static const char version[] = "Version: 1.0.0";
609651
static const char compiled[] = "Compiled: December 12, 2022";
652+
const char *info[3] = {SystemModel().c_str(), InternetAccess().c_str(), CurrentTime().c_str()};
610653

611654
{
612655
int bottom = 205;
613-
int posY = 30;
656+
int posY1 = 30;
657+
int posY2 = 60;
658+
int posY3 = 80;
614659

615660
if (timesup)
616661
Renderer::DrawString(text1, (320 - Renderer::LinuxFontSize(text1)) / 2, bottom, blank);
@@ -622,8 +667,11 @@ namespace CTRPluginFramework {
622667
timesup = !timesup;
623668
}
624669

625-
Renderer::DrawString(version, (320 - Renderer::LinuxFontSize(version)) / 2, posY, Color::Gray);
626-
Renderer::DrawString(compiled, (320 - Renderer::LinuxFontSize(compiled)) / 2, posY, Color::Gray);
670+
Renderer::DrawString(version, (320 - Renderer::LinuxFontSize(version)) / 2, posY1, Color::Gray);
671+
Renderer::DrawString(compiled, (320 - Renderer::LinuxFontSize(compiled)) / 2, posY1, Color::Gray);
672+
673+
for (unsigned int i = 0; i < sizeof(info) / sizeof(info[0]); i ++)
674+
Renderer::DrawString(info[i], (320 - Renderer::LinuxFontSize(info[i])) / 2, (i == 0 ? posY2 : posY3), (i == 0 ? Color::Gainsboro : Color::Gray));
627675
}
628676

629677
Renderer::SetTarget(TOP);

Library/lib/libctrpf.a

4.72 KB
Binary file not shown.

0 commit comments

Comments
 (0)