map switch cheats to physical button and show configuration IP address

This commit is contained in:
BernardoGiordano 2019-05-04 12:54:56 +02:00
parent c4303f5b9a
commit 72d23d5bdb
6 changed files with 27 additions and 11 deletions

View file

@ -118,4 +118,11 @@ void StringUtils::trim(std::string &s)
{
ltrim(s);
rtrim(s);
}
char* getConsoleIP(void)
{
struct in_addr in;
in.s_addr = gethostid();
return inet_ntoa(in);
}

View file

@ -36,6 +36,10 @@
#include <string>
#include <string.h>
#include <time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
namespace DateTime
{
@ -56,4 +60,6 @@ namespace StringUtils
void trim(std::string &s);
}
char* getConsoleIP(void);
#endif

@ -1 +1 @@
Subproject commit ce15fe5f1190dbddec29f5ba49aa5c5d94aceb34
Subproject commit 73b19c560e4cacffa0b4f9556a858e6480cc256a

View file

@ -947,7 +947,7 @@ Uint8 FC_LoadFontFromTTF(FC_Font* font, SDL_Renderer* renderer, TTF_Font* ttf, T
// load system symbols
FC_SetLoadingString(font,
"\ue000\ue001\ue002\ue003\ue004\ue005\ue006\ue041\ue045\ue046\ue085\ue086\ue058\ue080\ue071"
"\ue000\ue001\ue002\ue003\ue004\ue005\ue006\ue041\ue045\ue046\ue085\ue086\ue058\ue080\ue071\ue0c5"
// TODO: figure out why it crashes while loading the whole symbols
// "\ue000\ue001\ue002\ue003\ue004\ue005\ue006\ue007\ue008\ue009\ue00a\ue00b\ue00c\ue00d\ue00e\ue00f"

View file

@ -241,7 +241,7 @@ bool Gui::init(void)
backupList = new Scrollable(538, 276, 414, 380, rows);
buttonBackup = new Clickable(956, 276, 220, 80, theme().c2, theme().c6, "Backup \ue004", true);
buttonRestore = new Clickable(956, 360, 220, 80, theme().c2, theme().c6, "Restore \ue005", true);
buttonCheats = new Clickable(956, 444, 220, 80, theme().c2, theme().c6, "Cheats", true);
buttonCheats = new Clickable(956, 444, 220, 80, theme().c2, theme().c6, "Cheats \ue0c5", true);
buttonBackup->canChangeColorWhenSelected(true);
buttonRestore->canChangeColorWhenSelected(true);
buttonCheats->canChangeColorWhenSelected(true);
@ -371,7 +371,13 @@ void Gui::draw(void)
buttonRestore->draw(30, FC_MakeColor(0, 0, 0, 0));
buttonCheats->draw(30, FC_MakeColor(0, 0, 0, 0));
}
SDL_Color lightBlack = FC_MakeColor(theme().c0.r + 20, theme().c0.g + 20, theme().c0.b + 20, 255);
u32 ver_w, ver_h, checkpoint_h, checkpoint_w, inst_w, inst_h;
SDLH_GetTextDimensions(20, ver, &ver_w, &ver_h);
SDLH_GetTextDimensions(26, "checkpoint", &checkpoint_w, &checkpoint_h);
SDLH_GetTextDimensions(24, "\ue046 Instructions", &inst_w, &inst_h);
if (hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_MINUS)
{
SDLH_DrawRect(0, 0, 1280, 720, FC_MakeColor(0, 0, 0, 190));
@ -381,13 +387,10 @@ void Gui::draw(void)
SDLH_DrawText(24, 100, 360, theme().c6, "\ue000 to enter the selected title");
SDLH_DrawText(24, 100, 390, theme().c6, "\ue001 to exit the selected title");
SDLH_DrawText(24, 616, 450, theme().c6, "\ue002 to delete a backup");
SDLH_DrawText(24, 16*6 + checkpoint_w + 8 + ver_w + inst_w, 672 + (40 - checkpoint_h) / 2 + checkpoint_h - inst_h, COLOR_GOLD,
StringUtils::format("Configuration server running on %s:8000", getConsoleIP()).c_str());
}
SDL_Color lightBlack = FC_MakeColor(theme().c0.r + 20, theme().c0.g + 20, theme().c0.b + 20, 255);
u32 ver_w, ver_h, checkpoint_h, checkpoint_w, inst_h;
SDLH_GetTextDimensions(20, ver, &ver_w, &ver_h);
SDLH_GetTextDimensions(26, "checkpoint", &checkpoint_w, &checkpoint_h);
SDLH_GetTextDimensions(24, "\ue046 Instructions", NULL, &inst_h);
SDLH_DrawRect(0, 672, checkpoint_w + ver_w + 2*16 + 8, 40, lightBlack);
SDLH_DrawText(26, 16, 672 + (40 - checkpoint_h) / 2 + 2, theme().c6, "checkpoint");
SDLH_DrawText(20, 16 + checkpoint_w + 8, 672 + (40 - checkpoint_h) / 2 + checkpoint_h - ver_h, theme().c6, ver);
@ -452,7 +455,7 @@ void Gui::updateButtons(void)
static bool shouldCheckCheatManager = true;
if (CheatManager::loaded() && shouldCheckCheatManager)
{
buttonCheats->text("Cheats");
buttonCheats->text("Cheats \ue0c5");
buttonCheats->setColors(theme().c2, theme().c6);
shouldCheckCheatManager = false;
}

View file

@ -258,7 +258,7 @@ int main(int argc, char** argv)
}
}
if (Gui::isCheatReleased() && CheatManager::loaded())
if ((Gui::isCheatReleased() || (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_RSTICK)) && CheatManager::loaded())
{
if (MS::multipleSelectionEnabled())
{