Merge pull request #55 from Istador/ui-improvements

UI improvements
This commit is contained in:
Jack Garrard 2023-08-24 23:11:31 -07:00 committed by GitHub
commit 125e2bdde2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 77 additions and 163 deletions

View file

@ -29,7 +29,6 @@ class StageSceneStateServerConfig : public al::HostStateBase<al::Scene>, public
enum ServerConfigOption {
GAMEMODECONFIG,
GAMEMODESWITCH,
RECONNECT,
SETIP,
SETPORT
};
@ -42,11 +41,9 @@ class StageSceneStateServerConfig : public al::HostStateBase<al::Scene>, public
void exeMainMenu();
void exeOpenKeyboardIP();
void exeOpenKeyboardPort();
void exeRestartServer();
void exeGamemodeConfig();
void exeGamemodeSelect();
void exeSaveData();
void exeConnectError();
void endSubMenu();
@ -63,7 +60,7 @@ class StageSceneStateServerConfig : public al::HostStateBase<al::Scene>, public
SimpleLayoutMenu* mCurrentMenu = nullptr;
CommonVerticalList* mCurrentList = nullptr;
// Root Page, contains buttons for gamemode config, server reconnecting, and server ip address changing
// Root Page, contains buttons for gamemode config, and server ip address changing
SimpleLayoutMenu* mMainOptions = nullptr;
CommonVerticalList *mMainOptionsList = nullptr;
// Sub-Page of Mode config, used to select a gamemode for the client to use
@ -86,9 +83,7 @@ namespace {
NERVE_HEADER(StageSceneStateServerConfig, MainMenu)
NERVE_HEADER(StageSceneStateServerConfig, OpenKeyboardIP)
NERVE_HEADER(StageSceneStateServerConfig, OpenKeyboardPort)
NERVE_HEADER(StageSceneStateServerConfig, RestartServer)
NERVE_HEADER(StageSceneStateServerConfig, GamemodeConfig)
NERVE_HEADER(StageSceneStateServerConfig, GamemodeSelect)
NERVE_HEADER(StageSceneStateServerConfig, SaveData)
NERVE_HEADER(StageSceneStateServerConfig, ConnectError)
}
}

View file

@ -88,7 +88,6 @@ class Client {
bool startThread();
void readFunc();
static void restartConnection();
static bool isSocketActive() { return sInstance ? sInstance->mSocket->isConnected() : false; };
bool isPlayerConnected(int index) { return mPuppetInfoArr[index]->isConnected; }
@ -175,11 +174,8 @@ class Client {
static bool openKeyboardIP();
static bool openKeyboardPort();
static void showConnect();
static void showConnectError(const char16_t* msg);
static void hideConnect();
static void showUIMessage(const char16_t* msg);
static void hideUIMessage();
void resetCollectedShines();
@ -240,9 +236,7 @@ class Client {
bool mIsFirstConnect = true;
// --- Game Layouts ---
al::WindowConfirmWait* mConnectionWait;
al::WindowConfirmWait* mUIMessage;
al::SimpleLayoutAppearWaitEnd *mConnectStatus;
// --- Game Info ---

View file

@ -9,11 +9,13 @@ public:
HideAndSeekConfigMenu();
void initMenu(const al::LayoutInitInfo &initInfo) override;
const sead::WFixedSafeString<0x200> *getStringData() override;
const sead::WFixedSafeString<0x200>* getStringData() override;
bool updateMenu(int selectIndex) override;
const int getMenuSize() override { return mItemCount; }
private:
static constexpr int mItemCount = 2;
};
static constexpr int mItemCount = 1;
sead::SafeArray<sead::WFixedSafeString<0x200>, mItemCount>* gravityOn = nullptr;
sead::SafeArray<sead::WFixedSafeString<0x200>, mItemCount>* gravityOff = nullptr;
};

View file

@ -71,16 +71,14 @@ Client::Client() {
*/
void Client::init(al::LayoutInitInfo const &initInfo, GameDataHolderAccessor holder) {
mConnectionWait = new (mHeap) al::WindowConfirmWait("ServerWaitConnect", "WindowConfirmWait", initInfo);
mConnectStatus = new (mHeap) al::SimpleLayoutAppearWaitEnd("", "SaveMessage", initInfo, 0, false);
mConnectionWait->setTxtMessage(u"Connecting to Server.");
mConnectionWait->setTxtMessageConfirm(u"Failed to Connect!");
al::setPaneString(mConnectStatus, "TxtSave", u"Connecting to Server.", 0);
al::setPaneString(mConnectStatus, "TxtSaveSh", u"Connecting to Server.", 0);
mUIMessage = new (mHeap) al::WindowConfirmWait("ServerWaitConnect", "WindowConfirmWait", initInfo);
mUIMessage->setTxtMessage(u"a");
mUIMessage->setTxtMessageConfirm(u"b");
mHolder = holder;
startThread();
@ -105,44 +103,6 @@ bool Client::startThread() {
}
}
/**
* @brief restarts currently active connection to server
*
*/
void Client::restartConnection() {
if (!sInstance) {
Logger::log("Static Instance is null!\n");
return;
}
sead::ScopedCurrentHeapSetter setter(sInstance->mHeap);
Logger::log("Sending Disconnect.\n");
PlayerDC *playerDC = new PlayerDC();
playerDC->mUserID = sInstance->mUserID;
sInstance->mSocket->queuePacket(playerDC);
if (sInstance->mSocket->closeSocket()) {
Logger::log("Sucessfully Closed Socket.\n");
}
sInstance->mConnectCount = 0;
sInstance->mIsConnectionActive = sInstance->mSocket->init(sInstance->mServerIP.cstr(), sInstance->mServerPort).isSuccess();
if(sInstance->mSocket->getLogState() == SOCKET_LOG_CONNECTED) {
Logger::log("Reconnect Sucessful!\n");
} else {
Logger::log("Reconnect Unsuccessful.\n");
}
}
/**
* @brief starts a connection using client's TCP socket class, pulling up the software keyboard for user inputted IP if save file does not have one saved.
*
@ -293,6 +253,33 @@ bool Client::openKeyboardPort() {
return isFirstConnect;
}
void Client::showUIMessage(const char16_t* msg) {
if (!sInstance) {
return;
}
sInstance->mUIMessage->setTxtMessageConfirm(msg);
al::hidePane(sInstance->mUIMessage, "Page01"); // hide A button prompt
if (!sInstance->mUIMessage->mIsAlive) {
sInstance->mUIMessage->appear();
sInstance->mUIMessage->playLoop();
}
al::startAction(sInstance->mUIMessage, "Confirm", "State");
}
void Client::hideUIMessage() {
if (!sInstance) {
return;
}
sInstance->mUIMessage->tryEnd();
}
/**
* @brief main thread function for read thread, responsible for processing packets from server
*
@ -1393,37 +1380,3 @@ Shine* Client::findStageShine(int shineID) {
}
return nullptr;
}
void Client::showConnectError(const char16_t* msg) {
if (!sInstance)
return;
sInstance->mConnectionWait->setTxtMessageConfirm(msg);
al::hidePane(sInstance->mConnectionWait, "Page01"); // hide A button prompt
if (!sInstance->mConnectionWait->mIsAlive) {
sInstance->mConnectionWait->appear();
sInstance->mConnectionWait->playLoop();
}
al::startAction(sInstance->mConnectionWait, "Confirm", "State");
}
void Client::showConnect() {
if (!sInstance)
return;
sInstance->mConnectionWait->appear();
sInstance->mConnectionWait->playLoop();
}
void Client::hideConnect() {
if (!sInstance)
return;
sInstance->mConnectionWait->tryEnd();
}

View file

@ -5,20 +5,27 @@
#include "server/hns/HideAndSeekMode.hpp"
#include "server/Client.hpp"
HideAndSeekConfigMenu::HideAndSeekConfigMenu() : GameModeConfigMenu() {}
HideAndSeekConfigMenu::HideAndSeekConfigMenu() : GameModeConfigMenu() {
gravityOn = new sead::SafeArray<sead::WFixedSafeString<0x200>, mItemCount>();
gravityOn->mBuffer[0].copy(u"Toggle H&S Gravity (ON)");
gravityOff = new sead::SafeArray<sead::WFixedSafeString<0x200>, mItemCount>();
gravityOff->mBuffer[0].copy(u"Toggle H&S Gravity (OFF)");
}
void HideAndSeekConfigMenu::initMenu(const al::LayoutInitInfo &initInfo) {
}
const sead::WFixedSafeString<0x200> *HideAndSeekConfigMenu::getStringData() {
sead::SafeArray<sead::WFixedSafeString<0x200>, mItemCount>* gamemodeConfigOptions =
new sead::SafeArray<sead::WFixedSafeString<0x200>, mItemCount>();
gamemodeConfigOptions->mBuffer[0].copy(u"Toggle H&S Gravity On");
gamemodeConfigOptions->mBuffer[1].copy(u"Toggle H&S Gravity Off");
return gamemodeConfigOptions->mBuffer;
const sead::WFixedSafeString<0x200>* HideAndSeekConfigMenu::getStringData() {
HideAndSeekInfo *curMode = GameModeManager::instance()->getInfo<HideAndSeekInfo>();
return (
GameModeManager::instance()->isMode(GameMode::HIDEANDSEEK)
&& curMode != nullptr
&& curMode->mIsUseGravity
? gravityOn->mBuffer
: gravityOff->mBuffer
);
}
bool HideAndSeekConfigMenu::updateMenu(int selectIndex) {
@ -35,13 +42,7 @@ bool HideAndSeekConfigMenu::updateMenu(int selectIndex) {
switch (selectIndex) {
case 0: {
if (GameModeManager::instance()->isMode(GameMode::HIDEANDSEEK)) {
curMode->mIsUseGravity = true;
}
return true;
}
case 1: {
if (GameModeManager::instance()->isMode(GameMode::HIDEANDSEEK)) {
curMode->mIsUseGravity = false;
curMode->mIsUseGravity = !curMode->mIsUseGravity;
}
return true;
}
@ -50,4 +51,4 @@ bool HideAndSeekConfigMenu::updateMenu(int selectIndex) {
return false;
}
}
}

View file

@ -41,14 +41,13 @@ StageSceneStateServerConfig::StageSceneStateServerConfig(const char *name, al::S
mMainOptionsList->unkInt1 = 1;
mMainOptionsList->initDataNoResetSelected(5);
mMainOptionsList->initDataNoResetSelected(4);
sead::SafeArray<sead::WFixedSafeString<0x200>, 5>* mainMenuOptions =
new sead::SafeArray<sead::WFixedSafeString<0x200>, 5>();
sead::SafeArray<sead::WFixedSafeString<0x200>, 4>* mainMenuOptions =
new sead::SafeArray<sead::WFixedSafeString<0x200>, 4>();
mainMenuOptions->mBuffer[ServerConfigOption::GAMEMODECONFIG].copy(u"Gamemode Config");
mainMenuOptions->mBuffer[ServerConfigOption::GAMEMODESWITCH].copy(u"Change Gamemode");
mainMenuOptions->mBuffer[ServerConfigOption::RECONNECT].copy(u"Reconnect to Server");
mainMenuOptions->mBuffer[ServerConfigOption::SETIP].copy(u"Change Server IP");
mainMenuOptions->mBuffer[ServerConfigOption::SETPORT].copy(u"Change Server Port");
@ -101,11 +100,6 @@ StageSceneStateServerConfig::StageSceneStateServerConfig(const char *name, al::S
entry.mList = new CommonVerticalList(entry.mLayout, initInfo, true);
al::setPaneString(entry.mLayout, "TxtOption", u"Gamemode Configuration", 0);
entry.mList->initDataNoResetSelected(entry.mMenu->getMenuSize());
entry.mList->addStringData(entry.mMenu->getStringData(), "TxtContent");
}
@ -115,6 +109,15 @@ StageSceneStateServerConfig::StageSceneStateServerConfig(const char *name, al::S
void StageSceneStateServerConfig::init() {
initNerve(&nrvStageSceneStateServerConfigMainMenu, 0);
#ifdef EMU
char ryujinx[0x10] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
nn::account::Uid user;
nn::account::GetLastOpenedUser(&user);
if (memcmp(user.data, ryujinx, 0x10) == 0) {
Client::showUIMessage(u"Error: Ryujinx default profile detected.\nYou have to create a new user profile!");
}
#endif
}
void StageSceneStateServerConfig::appear(void) {
@ -176,10 +179,6 @@ void StageSceneStateServerConfig::exeMainMenu() {
al::setNerve(this, &nrvStageSceneStateServerConfigGamemodeSelect);
break;
}
case ServerConfigOption::RECONNECT: {
al::setNerve(this, &nrvStageSceneStateServerConfigRestartServer);
break;
}
case ServerConfigOption::SETIP: {
al::setNerve(this, &nrvStageSceneStateServerConfigOpenKeyboardIP);
break;
@ -233,32 +232,16 @@ void StageSceneStateServerConfig::exeOpenKeyboardPort() {
}
}
void StageSceneStateServerConfig::exeRestartServer() {
if (al::isFirstStep(this)) {
mCurrentList->deactivate();
Client::showConnect();
Client::restartConnection();
}
if (Client::isSocketActive()) {
Client::hideConnect();
al::startHitReaction(mCurrentMenu, "リセット", 0);
al::setNerve(this, &nrvStageSceneStateServerConfigMainMenu);
} else {
al::setNerve(this, &nrvStageSceneStateServerConfigConnectError);
}
}
void StageSceneStateServerConfig::exeGamemodeConfig() {
if (al::isFirstStep(this)) {
mGamemodeConfigMenu = &mGamemodeConfigMenus[GameModeManager::instance()->getGameMode()];
mGamemodeConfigMenu->mList->initDataNoResetSelected(mGamemodeConfigMenu->mMenu->getMenuSize());
mGamemodeConfigMenu->mList->addStringData(mGamemodeConfigMenu->mMenu->getStringData(), "TxtContent");
mCurrentList = mGamemodeConfigMenu->mList;
mCurrentMenu = mGamemodeConfigMenu->mLayout;
subMenuStart();
}
@ -290,18 +273,6 @@ void StageSceneStateServerConfig::exeGamemodeSelect() {
}
}
void StageSceneStateServerConfig::exeConnectError() {
if (al::isFirstStep(this)) {
Client::showConnectError(u"Failed to Reconnect!");
}
if (al::isGreaterEqualStep(this, 60)) { // close after 1 second
Client::hideConnect();
al::startHitReaction(mCurrentMenu, "リセット", 0);
al::setNerve(this, &nrvStageSceneStateServerConfigMainMenu);
}
}
void StageSceneStateServerConfig::exeSaveData() {
if (al::isFirstStep(this)) {
@ -373,9 +344,7 @@ namespace {
NERVE_IMPL(StageSceneStateServerConfig, MainMenu)
NERVE_IMPL(StageSceneStateServerConfig, OpenKeyboardIP)
NERVE_IMPL(StageSceneStateServerConfig, OpenKeyboardPort)
NERVE_IMPL(StageSceneStateServerConfig, RestartServer)
NERVE_IMPL(StageSceneStateServerConfig, GamemodeConfig)
NERVE_IMPL(StageSceneStateServerConfig, GamemodeSelect)
NERVE_IMPL(StageSceneStateServerConfig, SaveData)
NERVE_IMPL(StageSceneStateServerConfig, ConnectError)
}
}