Skip to content

Commit

Permalink
✨ Added login and user profile UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Zentro committed Sep 3, 2024
1 parent 012c38a commit 29c3720
Show file tree
Hide file tree
Showing 14 changed files with 623 additions and 1 deletion.
Binary file added resources/icons/blank.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions source/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ CVar* mp_cyclethru_net_actors;

// New remote API
CVar* remote_query_url;
CVar* remote_login_token;

// Diagnostic
CVar* diag_auto_spawner_report;
Expand Down
6 changes: 6 additions & 0 deletions source/main/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ enum MsgType
MSG_NET_DISCONNECT_REQUESTED,
MSG_NET_USER_DISCONNECT,
MSG_NET_RECV_ERROR,
MSG_NET_USERAUTH_SUCCESS,
MSG_NET_USERAUTH_FAILURE,
MSG_NET_USERAUTH_TFA_REQUESTED,
MSG_NET_USERAUTH_TFA_FAILURE,
MSG_NET_USERAUTH_TFA_TRIGGERED,
MSG_NET_REFRESH_SERVERLIST_SUCCESS, //!< Payload = GUI::MpServerInfoVec* (owner)
MSG_NET_REFRESH_SERVERLIST_FAILURE, //!< Payload = RoR::CurlFailInfo* (owner)
MSG_NET_REFRESH_REPOLIST_SUCCESS, //!< Payload = GUI::ResourcesCollection* (owner)
Expand Down Expand Up @@ -364,6 +369,7 @@ extern CVar* mp_cyclethru_net_actors; //!< Include remote actors when cycling th

// New remote API
extern CVar* remote_query_url;
extern CVar* remote_login_token;

// Diagnostic
extern CVar* diag_auto_spawner_report;
Expand Down
1 change: 1 addition & 0 deletions source/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ set(SOURCE_FILES
gui/panels/GUI_ConsoleWindow.{h,cpp}
gui/panels/GUI_DirectionArrow.{h,cpp}
gui/panels/GUI_LoadingWindow.{h,cpp}
gui/panels/GUI_LoginBox.{h,cpp}
gui/panels/GUI_FlexbodyDebug.{h,cpp}
gui/panels/GUI_FrictionSettings.{h,cpp}
gui/panels/GUI_TopMenubar.{h,cpp}
Expand Down
3 changes: 2 additions & 1 deletion source/main/ForwardDeclarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This source file is part of Rigs of Rods
Copyright 2005-2012 Pierre-Michel Ricordel
Copyright 2007-2012 Thomas Fischer
Copyright 2013-2020 Petr Ohlidal
Copyright 2013-2024 Petr Ohlidal
For more information, see http://www.rigsofrods.org/
Expand Down Expand Up @@ -227,6 +227,7 @@ namespace RoR
class SurveyMap;
class TopMenubar;
class VehicleButtons;
class LoginBox;
}
} // namespace RoR

Expand Down
4 changes: 4 additions & 0 deletions source/main/GameContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,10 @@ void GameContext::UpdateGlobalInputEvents()
{
App::GetGuiManager()->RepositorySelector.SetVisible(false);
}
else if (App::GetGuiManager()->LoginBox.IsVisible())
{
App::GetGuiManager()->LoginBox.SetVisible(false);
}
else
{
this->PushMessage(Message(MSG_APP_SHUTDOWN_REQUESTED));
Expand Down
5 changes: 5 additions & 0 deletions source/main/gui/GUIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,11 @@ void GUIManager::DrawMainMenuGui()
{
this->RepositorySelector.Draw();
}

if (this->LoginBox.IsVisible())
{
this->LoginBox.Draw();
}
}

void GUIManager::ShowMessageBox(const char* title, const char* text, bool allow_close, const char* btn1_text, const char* btn2_text)
Expand Down
2 changes: 2 additions & 0 deletions source/main/gui/GUIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "GUI_TopMenubar.h"
#include "GUI_VehicleDescription.h"
#include "GUI_VehicleButtons.h"
#include "GUI_LoginBox.h"

// Deps
#include <Bites/OgreWindowEventUtilities.h>
Expand Down Expand Up @@ -126,6 +127,7 @@ class GUIManager
GUI::DirectionArrow DirectionArrow;
GUI::VehicleButtons VehicleButtons;
GUI::FlexbodyDebug FlexbodyDebug;
GUI::LoginBox LoginBox;
Ogre::Overlay* MenuWallpaper = nullptr;

// GUI manipulation
Expand Down
37 changes: 37 additions & 0 deletions source/main/gui/panels/GUI_GameMainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ using namespace GUI;
void GameMainMenu::Draw()
{
this->DrawMenuPanel();
this->DrawProfileBox();
if (App::app_state->getEnum<AppState>() == AppState::MAIN_MENU)
{
this->DrawVersionBox();
Expand Down Expand Up @@ -224,6 +225,42 @@ void GameMainMenu::DrawMenuPanel()
m_kb_enter_index = -1;
}

void GameMainMenu::DrawProfileBox()
{
ImVec2 image_size = ImVec2(50, 50);
ImVec2 button_size = ImVec2(60, 30);
ImVec2 display_size = ImGui::GetIO().DisplaySize;

const float window_height = 15.0f;
const float margin = display_size.y / 15.0f;

ImGui::SetNextWindowPos(ImVec2(margin, margin));
ImGui::PushStyleColor(ImGuiCol_WindowBg, WINDOW_BG_COLOR);
ImGuiWindowFlags flags =
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize |
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar;
if (ImGui::Begin(_LC("MainMenu", "Profile box"), nullptr, flags))
{
ImGui::Image(
reinterpret_cast<ImTextureID>(FetchIcon("blank.png")->getHandle()),
image_size);

ImGui::SameLine();
if (ImGui::Button("Log in", button_size)) {
App::GetGuiManager()->LoginBox.SetVisible(true);
this->SetVisible(false);
}

ImGui::SameLine();
if (ImGui::Button("Regster", button_size)) {
// TODO open as a link
}

ImGui::End();
}
ImGui::PopStyleColor(1);
}

void GameMainMenu::DrawVersionBox()
{
const float margin = ImGui::GetIO().DisplaySize.y / 30.f;
Expand Down
1 change: 1 addition & 0 deletions source/main/gui/panels/GUI_GameMainMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class GameMainMenu
void DrawMenuPanel();
void DrawVersionBox();
void DrawNoticeBox();
void DrawProfileBox();
bool HighlightButton(const std::string &text, ImVec2 btn_size, int index) const;
void HandleInputEvents();
bool m_is_visible = false;
Expand Down
Loading

0 comments on commit 29c3720

Please sign in to comment.