Skip to content

Commit

Permalink
added repository selector panel
Browse files Browse the repository at this point in the history
  • Loading branch information
tritonas00 committed Feb 26, 2022
1 parent ad9fb06 commit 344550d
Show file tree
Hide file tree
Showing 23 changed files with 1,599 additions and 2 deletions.
Binary file added resources/icons/arrow_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icons/arrow_rotate_anticlockwise.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icons/ror.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icons/star.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
4 changes: 4 additions & 0 deletions source/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ CVar* mp_player_name;
CVar* mp_player_token;
CVar* mp_api_url;

// New remote API
CVar* remote_query_url;

// Diagnostic
CVar* diag_auto_spawner_report;
CVar* diag_camera;
Expand Down Expand Up @@ -152,6 +155,7 @@ CVar* sys_process_dir;
CVar* sys_user_dir;
CVar* sys_config_dir;
CVar* sys_cache_dir;
CVar* sys_thumbnails_dir;
CVar* sys_logs_dir;
CVar* sys_resources_dir;
CVar* sys_profiler_dir;
Expand Down
9 changes: 9 additions & 0 deletions source/main/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ enum MsgType
MSG_NET_RECV_ERROR,
MSG_NET_REFRESH_SERVERLIST_SUCCESS, //!< Payload = GUI::MpServerInfoVec* (owner)
MSG_NET_REFRESH_SERVERLIST_FAILURE,
MSG_NET_REFRESH_REPOLIST_SUCCESS, //!< Payload = GUI::ResourcesCollection* (owner)
MSG_NET_OPEN_RESOURCE_SUCCESS, //!< Payload = GUI::ResourcesCollection* (owner)
MSG_NET_REFRESH_REPOLIST_FAILURE,
// Simulation
MSG_SIM_PAUSE_REQUESTED,
MSG_SIM_UNPAUSE_REQUESTED,
Expand All @@ -98,6 +101,8 @@ enum MsgType
MSG_GUI_CLOSE_SELECTOR_REQUESTED,
MSG_GUI_MP_CLIENTS_REFRESH,
MSG_GUI_SHOW_MESSAGE_BOX_REQUESTED, //!< Payload = MessageBoxConfig* (owner)
MSG_GUI_DOWNLOAD_PROGRESS,
MSG_GUI_DOWNLOAD_FINISHED,
// Editing
MSG_EDI_MODIFY_GROUNDMODEL_REQUESTED, //!< Payload = ground_model_t* (weak)
MSG_EDI_ENTER_TERRN_EDITOR_REQUESTED,
Expand Down Expand Up @@ -295,6 +300,9 @@ extern CVar* mp_player_name;
extern CVar* mp_player_token;
extern CVar* mp_api_url;

// New remote API
extern CVar* remote_query_url;

// Diagnostic
extern CVar* diag_auto_spawner_report;
extern CVar* diag_camera;
Expand Down Expand Up @@ -329,6 +337,7 @@ extern CVar* sys_process_dir;
extern CVar* sys_user_dir;
extern CVar* sys_config_dir;
extern CVar* sys_cache_dir;
extern CVar* sys_thumbnails_dir;
extern CVar* sys_logs_dir;
extern CVar* sys_resources_dir;
extern CVar* sys_profiler_dir;
Expand Down
1 change: 1 addition & 0 deletions source/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ set(SOURCE_FILES
gui/panels/GUI_FrictionSettings.{h,cpp}
gui/panels/GUI_TopMenubar.{h,cpp}
gui/panels/GUI_TextureToolWindow.{h,cpp}
gui/panels/GUI_RepositorySelector.{h,cpp}
gui/panels/GUI_GameControls.{h,cpp}
gui/panels/GUI_GameAbout.{h,cpp}
gui/panels/GUI_GameChatBox.{h,cpp}
Expand Down
1 change: 1 addition & 0 deletions source/main/ForwardDeclarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ namespace RoR
class MainSelector;
class MpClientList;
class MultiplayerSelector;
class RepositorySelector;
class DirectionArrow;
class SceneMouse;
class SimActorStats;
Expand Down
4 changes: 4 additions & 0 deletions source/main/GameContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,10 @@ void GameContext::UpdateGlobalInputEvents()
{
App::GetGuiManager()->SetVisible_MultiplayerSelector(false);
}
else if (App::GetGuiManager()->IsVisible_RepositorySelector())
{
App::GetGuiManager()->SetVisible_RepositorySelector(false);
}
else
{
this->PushMessage(Message(MSG_APP_SHUTDOWN_REQUESTED));
Expand Down
10 changes: 10 additions & 0 deletions source/main/gui/GUIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
//Managed GUI panels
#include "GUI_ConsoleWindow.h"
#include "GUI_FrictionSettings.h"
#include "GUI_RepositorySelector.h"
#include "GUI_GameMainMenu.h"
#include "GUI_GameAbout.h"
#include "GUI_GameChatBox.h"
Expand Down Expand Up @@ -88,6 +89,7 @@ struct GuiManagerImpl
GUI::FrictionSettings panel_FrictionSettings;
GUI::TextureToolWindow panel_TextureToolWindow;
GUI::GameControls panel_GameControls;
GUI::RepositorySelector panel_RepositorySelector;
GUI::NodeBeamUtils panel_NodeBeamUtils;
GUI::LoadingWindow panel_LoadingWindow;
GUI::TopMenubar panel_TopMenubar;
Expand All @@ -108,6 +110,7 @@ void GUIManager::SetVisible_VehicleDescription (bool v) { m_impl->panel_Vehicle
void GUIManager::SetVisible_FrictionSettings (bool v) { m_impl->panel_FrictionSettings .SetVisible(v); }
void GUIManager::SetVisible_TextureToolWindow (bool v) { m_impl->panel_TextureToolWindow .SetVisible(v); }
void GUIManager::SetVisible_GameControls (bool v) { m_impl->panel_GameControls .SetVisible(v); }
void GUIManager::SetVisible_RepositorySelector (bool v) { m_impl->panel_RepositorySelector .SetVisible(v); }
void GUIManager::SetVisible_LoadingWindow (bool v) { m_impl->panel_LoadingWindow .SetVisible(v); }
void GUIManager::SetVisible_Console (bool v) { m_impl->panel_ConsoleWindow .SetVisible(v); }
void GUIManager::SetVisible_GameSettings (bool v) { m_impl->panel_GameSettings .SetVisible(v); }
Expand All @@ -132,6 +135,7 @@ bool GUIManager::IsVisible_VehicleDescription () { return m_impl->panel_Vehicl
bool GUIManager::IsVisible_FrictionSettings () { return m_impl->panel_FrictionSettings .IsVisible(); }
bool GUIManager::IsVisible_TextureToolWindow () { return m_impl->panel_TextureToolWindow .IsVisible(); }
bool GUIManager::IsVisible_GameControls () { return m_impl->panel_GameControls .IsVisible(); }
bool GUIManager::IsVisible_RepositorySelector () { return m_impl->panel_RepositorySelector .IsVisible(); }
bool GUIManager::IsVisible_LoadingWindow () { return m_impl->panel_LoadingWindow .IsVisible(); }
bool GUIManager::IsVisible_Console () { return m_impl->panel_ConsoleWindow .IsVisible(); }
bool GUIManager::IsVisible_GameSettings () { return m_impl->panel_GameSettings .IsVisible(); }
Expand All @@ -148,6 +152,7 @@ GUI::GameMainMenu* GUIManager::GetMainMenu() { return &m_impl-
GUI::GameControls* GUIManager::GetControlsWindow() { return &m_impl->panel_GameControls ; }
GUI::LoadingWindow* GUIManager::GetLoadingWindow() { return &m_impl->panel_LoadingWindow ; }
GUI::MultiplayerSelector* GUIManager::GetMpSelector() { return &m_impl->panel_MultiplayerSelector ; }
GUI::RepositorySelector* GUIManager::GetRepoSelector() { return &m_impl->panel_RepositorySelector ; }
GUI::FrictionSettings* GUIManager::GetFrictionSettings() { return &m_impl->panel_FrictionSettings ; }
GUI::TopMenubar* GUIManager::GetTopMenubar() { return &m_impl->panel_TopMenubar ; }
GUI::SurveyMap* GUIManager::GetSurveyMap() { return &m_impl->panel_SurveyMap ; }
Expand Down Expand Up @@ -510,6 +515,11 @@ void GUIManager::DrawMainMenuGui()
{
m_impl->panel_GameAbout.Draw();
}

if (m_impl->panel_RepositorySelector.IsVisible())
{
m_impl->panel_RepositorySelector.Draw();
}
}

void GUIManager::ShowMessageBox(const char* title, const char* text, bool allow_close, const char* btn1_text, const char* btn2_text)
Expand Down
3 changes: 3 additions & 0 deletions source/main/gui/GUIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class GUIManager: public ZeroedMemoryAllocator
void SetVisible_FrictionSettings (bool visible);
void SetVisible_TextureToolWindow (bool visible);
void SetVisible_GameControls (bool visible);
void SetVisible_RepositorySelector (bool visible);
void SetVisible_NodeBeamUtils (bool visible);
void SetVisible_LoadingWindow (bool visible);
void SetVisible_Console (bool visible);
Expand All @@ -101,6 +102,7 @@ class GUIManager: public ZeroedMemoryAllocator
bool IsVisible_FrictionSettings ();
bool IsVisible_TextureToolWindow ();
bool IsVisible_GameControls ();
bool IsVisible_RepositorySelector ();
bool IsVisible_NodeBeamUtils ();
bool IsVisible_LoadingWindow ();
bool IsVisible_Console ();
Expand All @@ -115,6 +117,7 @@ class GUIManager: public ZeroedMemoryAllocator
GUI::GameControls* GetControlsWindow();
GUI::LoadingWindow* GetLoadingWindow();
GUI::MultiplayerSelector* GetMpSelector();
GUI::RepositorySelector* GetRepoSelector();
GUI::FrictionSettings* GetFrictionSettings();
GUI::TopMenubar* GetTopMenubar();
GUI::SurveyMap* GetSurveyMap();
Expand Down
43 changes: 43 additions & 0 deletions source/main/gui/GUIUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,46 @@ ImDrawList* RoR::GetImDummyFullscreenWindow()

return drawlist;
}

// A nice spinner https://github.com/ocornut/imgui/issues/1901#issuecomment-444929973
void RoR::LoadingIndicatorCircle(const char* label, const float indicator_radius, const ImVec4& main_color, const ImVec4& backdrop_color, const int circle_count, const float speed)
{
ImGuiWindow* window = ImGui::GetCurrentWindow();
if (window->SkipItems)
{
return;
}

ImGuiContext& g = *GImGui;
const ImGuiID id = window->GetID(label);

const ImVec2 pos = window->DC.CursorPos;
const float circle_radius = indicator_radius / 10.0f;
const ImRect bb(pos, ImVec2(pos.x + indicator_radius * 2.0f, pos.y + indicator_radius * 2.0f));
ImGui::ItemSize(bb, ImGui::GetStyle().FramePadding.y);
if (!ImGui::ItemAdd(bb, id))
{
return;
}

const float t = g.Time;
const auto degree_offset = 2.0f * IM_PI / circle_count;

for (int i = 0; i < circle_count; ++i)
{
const auto x = indicator_radius * std::sin(degree_offset * i);
const auto y = indicator_radius * std::cos(degree_offset * i);
const auto growth = std::max(0.0f, std::sin(t * speed - i * degree_offset));
ImVec4 color;
color.x = main_color.x * growth + backdrop_color.x * (1.0f - growth);
color.y = main_color.y * growth + backdrop_color.y * (1.0f - growth);
color.z = main_color.z * growth + backdrop_color.z * (1.0f - growth);
color.w = 1.0f;

window->DrawList->AddCircleFilled(ImVec2(pos.x + indicator_radius + x,
pos.y + indicator_radius - y),
circle_radius + growth * circle_radius,
ImGui::GetColorU32(color));

}
}
2 changes: 2 additions & 0 deletions source/main/gui/GUIUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,6 @@ Ogre::TexturePtr FetchIcon(const char* name);

ImDrawList* GetImDummyFullscreenWindow();

void LoadingIndicatorCircle(const char* label, const float indicator_radius, const ImVec4& main_color, const ImVec4& backdrop_color, const int circle_count, const float speed);

} // namespace RoR
8 changes: 7 additions & 1 deletion source/main/gui/panels/GUI_GameMainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void GameMainMenu::DrawMenuPanel()
if (App::app_state->getEnum<AppState>() == AppState::MAIN_MENU)
{
title = "Main menu";
m_num_buttons = 6;
m_num_buttons = 7;
if (FileExists(PathCombine(App::sys_savegames_dir->getStr(), "autosave.sav")))
{
m_num_buttons++;
Expand Down Expand Up @@ -158,6 +158,12 @@ void GameMainMenu::DrawMenuPanel()
this->SetVisible(false);
}

if (HighlightButton(_LC("MainMenu", "Repository"), btn_size, button_index++))
{
App::GetGuiManager()->SetVisible_RepositorySelector(true);
this->SetVisible(false);
}

if (HighlightButton(_LC("MainMenu", "Settings"), btn_size, button_index++))
{
App::GetGuiManager()->SetVisible_GameSettings(true);
Expand Down
Loading

0 comments on commit 344550d

Please # to comment.