Skip to content

Commit

Permalink
🎨 Remade 'T screen' (vehicle info side-panel)
Browse files Browse the repository at this point in the history
How it behaves now:
* if you move the mouse to the left, and `ui_show_vehicle_buttons=true` (default), then the T-pane will show up translucent with the 'Basics' tab open by default but remember which tab you selected.
* if you press T, the T-panel will show opaque and open the 'Stats' tab
* if you press Cltr+T, the T-panel will show opaque and open the 'Commands' tab, showing the `helptex` texture and commands with descriptions and key combos and an unique in-scene highlight system (both the controls UI and the associated command beams on the vehicle are highlighted bright yellow).
* The T-panel (both opaque and translucent) has an extra tab 'Diag' which contains skeletonview toggles.

How it behaved previously:
* if you move the mouse to the left, and `ui_show_vehicle_buttons=true` (default), a "Buttons UI" would appear - `GUI_VehicleButtons` by Tritonas00 - just buttons with tooltips, no text, custom light/command buttons just numbered without descriptions.
* Pressing T would show up stand-alone stats side-panel `GUI_SimActorStats`
* Pressing Ctrl+T would show up standalone window `GUI_VehicleDescription` with description text, authors, and commands with descriptions and key combos.
* Diagnostic views (skeletonview) was controlled from TopMenubar/Tools menu, `GUI_TopMenubar`, taking signifficant amout of vertical space.
  • Loading branch information
ohlidalp committed Jul 17, 2024
1 parent 05f71f5 commit 3da215a
Show file tree
Hide file tree
Showing 17 changed files with 1,424 additions and 1,940 deletions.
4 changes: 1 addition & 3 deletions source/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,10 @@ set(SOURCE_FILES
gui/panels/GUI_MultiplayerSelector.{h,cpp}
gui/panels/GUI_MultiplayerClientList.{h,cpp}
gui/panels/GUI_NodeBeamUtils.{h,cpp}
gui/panels/GUI_SimActorStats.{h,cpp}
gui/panels/GUI_VehicleInfoTPanel.{h,cpp}
gui/panels/GUI_ScriptMonitor.{h,cpp}
gui/panels/GUI_SimPerfStats.{h,cpp}
gui/panels/GUI_SurveyMap.{h,cpp}
gui/panels/GUI_VehicleDescription.{h,cpp}
gui/panels/GUI_VehicleButtons.{h,cpp}
network/CurlHelpers.{h,cpp}
network/DiscordRpc.{h,cpp}
network/Network.{h,cpp}
Expand Down
3 changes: 1 addition & 2 deletions source/main/ForwardDeclarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,9 @@ namespace RoR
class RepositorySelector;
class DirectionArrow;
class SceneMouse;
class SimActorStats;
class SurveyMap;
class TopMenubar;
class VehicleButtons;
class VehicleInfoTPanel;
}
} // namespace RoR

Expand Down
20 changes: 5 additions & 15 deletions source/main/GameContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#include "TuneupFileFormat.h"
#include "Utils.h"
#include "VehicleAI.h"
#include "GUI_VehicleButtons.h"

using namespace RoR;

Expand Down Expand Up @@ -1484,20 +1483,10 @@ void GameContext::UpdateCommonInputEvents(float dt)
App::GetGameContext()->PushMessage(Message(MSG_SIM_MODIFY_ACTOR_REQUESTED, (void*)rq));
}

// all commands
for (int i = 1; i <= MAX_COMMANDS; i++) // BEWARE: commandkeys are indexed 1-MAX_COMMANDS!
// Apply command buttons in T-screen
if (App::GetGuiManager()->VehicleInfoTPanel.GetActiveCommandKey() != COMMANDKEYID_INVALID)
{
int eventID = EV_COMMANDS_01 + (i - 1);

m_player_actor->ar_command_key[i].playerInputValue = RoR::App::GetInputEngine()->getEventValue(eventID);

for (auto id: App::GetGuiManager()->VehicleButtons.GetCommandEventID())
{
if (id == eventID)
{
m_player_actor->ar_command_key[i].playerInputValue = 1.f;
}
}
m_player_actor->ar_command_key[App::GetGuiManager()->VehicleInfoTPanel.GetActiveCommandKey()].playerInputValue = 1.f;
}

if (RoR::App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_TOGGLE_FORWARDCOMMANDS))
Expand Down Expand Up @@ -1878,7 +1867,8 @@ void GameContext::UpdateTruckInputEvents(float dt)
}
else
{
if (App::GetInputEngine()->getEventBoolValue(EV_TRUCK_HORN) || App::GetGuiManager()->VehicleButtons.GetHornButtonState())
if (App::GetInputEngine()->getEventBoolValue(EV_TRUCK_HORN)
|| App::GetGuiManager()->VehicleInfoTPanel.IsHornButtonActive())
{
SOUND_START(m_player_actor, SS_TRIG_HORN);
}
Expand Down
37 changes: 20 additions & 17 deletions source/main/gui/GUIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,9 @@ void GUIManager::DrawSimGuiBuffered(GfxActor* player_gfx_actor)
{
this->DrawCommonGui();

if (player_gfx_actor && this->SimActorStats.IsVisible())
if (player_gfx_actor && !this->SimPerfStats.IsVisible())
{
this->SimActorStats.Draw(player_gfx_actor);
}

if (player_gfx_actor && player_gfx_actor->GetActor()->ar_state == ActorState::LOCAL_SIMULATED &&
!this->SimActorStats.IsVisible() && !this->SimPerfStats.IsVisible() && !this->GameMainMenu.IsVisible())
{
this->VehicleButtons.Draw(player_gfx_actor);
this->VehicleInfoTPanel.Draw(player_gfx_actor);
}

if (!this->ConsoleWindow.IsVisible())
Expand All @@ -192,11 +186,6 @@ void GUIManager::DrawSimGuiBuffered(GfxActor* player_gfx_actor)
this->FrictionSettings.Draw();
}

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

if (this->SimPerfStats.IsVisible())
{
this->SimPerfStats.Draw();
Expand Down Expand Up @@ -489,16 +478,30 @@ void GUIManager::UpdateInputEvents(float dt)
this->ChatBox.SetVisible(!this->ChatBox.IsVisible());
}

// EV_COMMON_TRUCK_INFO - Vehicle status panel
// EV_COMMON_TRUCK_INFO - Vehicle info side-panel (aka The T-Screen)
if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_TRUCK_INFO) && App::GetGameContext()->GetPlayerActor())
{
this->SimActorStats.SetVisible(!this->SimActorStats.IsVisible());
if (this->VehicleInfoTPanel.IsVisible(GUI::VehicleInfoTPanel::TPANELFOCUS_STATS))
{
this->VehicleInfoTPanel.SetVisible(GUI::VehicleInfoTPanel::TPANELMODE_HIDDEN);
}
else
{
this->VehicleInfoTPanel.SetVisible(GUI::VehicleInfoTPanel::TPANELMODE_OPAQUE, GUI::VehicleInfoTPanel::TPANELFOCUS_STATS);
}
}

// EV_COMMON_TRUCK_DESCRIPTION - Vehicle controls and details
// EV_COMMON_TRUCK_DESCRIPTION - The T-screen with commands
if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_TRUCK_DESCRIPTION) && App::GetGameContext()->GetPlayerActor())
{
this->VehicleDescription.SetVisible(!this->VehicleDescription.IsVisible());
if (this->VehicleInfoTPanel.IsVisible(GUI::VehicleInfoTPanel::TPANELFOCUS_COMMANDS))
{
this->VehicleInfoTPanel.SetVisible(GUI::VehicleInfoTPanel::TPANELMODE_HIDDEN);
}
else
{
this->VehicleInfoTPanel.SetVisible(GUI::VehicleInfoTPanel::TPANELMODE_OPAQUE, GUI::VehicleInfoTPanel::TPANELFOCUS_COMMANDS);
}
}

// EV_COMMON_TOGGLE_DASHBOARD
Expand Down
8 changes: 2 additions & 6 deletions source/main/gui/GUIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@
#include "GUI_MainSelector.h"
#include "GUI_NodeBeamUtils.h"
#include "GUI_DirectionArrow.h"
#include "GUI_SimActorStats.h"
#include "GUI_VehicleInfoTPanel.h"
#include "GUI_SimPerfStats.h"
#include "GUI_SurveyMap.h"
#include "GUI_TextureToolWindow.h"
#include "GUI_GameControls.h"
#include "GUI_TopMenubar.h"
#include "GUI_VehicleDescription.h"
#include "GUI_VehicleButtons.h"

// Deps
#include <Bites/OgreWindowEventUtilities.h>
Expand Down Expand Up @@ -106,13 +104,12 @@ class GUIManager
GUI::GameMainMenu GameMainMenu;
GUI::GameAbout GameAbout;
GUI::GameSettings GameSettings;
GUI::SimActorStats SimActorStats;
GUI::VehicleInfoTPanel VehicleInfoTPanel;
GUI::SimPerfStats SimPerfStats;
GUI::MessageBoxDialog MessageBoxDialog;
GUI::MultiplayerSelector MultiplayerSelector;
GUI::MainSelector MainSelector;
GUI::GameChatBox ChatBox;
GUI::VehicleDescription VehicleDescription;
GUI::MpClientList MpClientList;
GUI::FrictionSettings FrictionSettings;
GUI::TextureToolWindow TextureToolWindow;
Expand All @@ -124,7 +121,6 @@ class GUIManager
GUI::ConsoleWindow ConsoleWindow;
GUI::SurveyMap SurveyMap;
GUI::DirectionArrow DirectionArrow;
GUI::VehicleButtons VehicleButtons;
GUI::FlexbodyDebug FlexbodyDebug;
Ogre::Overlay* MenuWallpaper = nullptr;

Expand Down
48 changes: 45 additions & 3 deletions source/main/gui/GUIUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "GUIUtils.h"

#include "Actor.h"
#include "Utils.h"

#include "imgui_internal.h" // ImTextCharFromUtf8
#include <regex>
Expand Down Expand Up @@ -352,7 +353,7 @@ Ogre::TexturePtr RoR::FetchIcon(const char* name)
return Ogre::TexturePtr(); // null
}

ImDrawList* RoR::GetImDummyFullscreenWindow()
ImDrawList* RoR::GetImDummyFullscreenWindow(const std::string& name /* = "RoR_TransparentFullscreenWindow"*/)
{
ImVec2 screen_size = ImGui::GetIO().DisplaySize;

Expand All @@ -362,7 +363,7 @@ ImDrawList* RoR::GetImDummyFullscreenWindow()
ImGui::SetNextWindowPos(ImVec2(0,0));
ImGui::SetNextWindowSize(screen_size);
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0,0,0,0)); // Fully transparent background!
ImGui::Begin("RoR_TransparentFullscreenWindow", NULL, window_flags);
ImGui::Begin(name.c_str(), NULL, window_flags);
ImDrawList* drawlist = ImGui::GetWindowDrawList();
ImGui::End();
ImGui::PopStyleColor(1); // WindowBg
Expand Down Expand Up @@ -411,14 +412,40 @@ void RoR::ImDrawEventHighlighted(events input_event)
{
col = App::GetGuiManager()->GetTheme().highlight_text_color;
}
std::string text = App::GetInputEngine()->getKeyForCommand(input_event);
std::string text = App::GetInputEngine()->getEventCommandTrimmed(input_event);
const ImVec2 PAD = ImVec2(2.f, 0.f);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, PAD);
ImGui::BeginChildFrame(ImGuiID(input_event), ImGui::CalcTextSize(text.c_str()) + PAD*2);
ImGui::TextColored(col, "%s", text.c_str());
ImGui::EndChildFrame();
ImGui::PopStyleVar(); // FramePadding
}

bool RoR::ImDrawEventHighlightedButton(events input_event, bool* btn_hovered /*=nullptr*/, bool* btn_active /*=nullptr*/)
{
ImVec4 col = ImGui::GetStyle().Colors[ImGuiCol_Text];
if (App::GetInputEngine()->getEventValue(input_event))
{
col = App::GetGuiManager()->GetTheme().highlight_text_color;
}
std::string text = App::GetInputEngine()->getEventCommandTrimmed(input_event);
const ImVec2 PAD = ImVec2(2.f, 0.f);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, PAD);
ImGui::PushStyleColor(ImGuiCol_Text, col);
ImGui::PushID(input_event);
const bool retval = ImGui::Button(text.c_str());
if (btn_hovered != nullptr)
{
*btn_hovered = ImGui::IsItemHovered();
}
if (btn_active != nullptr)
{
*btn_active = ImGui::IsItemActive();
}
ImGui::PopID(); // input_event
ImGui::PopStyleColor(); // Text
ImGui::PopStyleVar(); // FramePadding
return retval;
}

void RoR::ImDrawModifierKeyHighlighted(OIS::KeyCode key)
Expand Down Expand Up @@ -480,3 +507,18 @@ bool RoR::ImButtonHoldToConfirm(const std::string& btn_idstr, const bool smallbu

return false;
}

bool RoR::GetScreenPosFromWorldPos(Ogre::Vector3 const& world_pos, ImVec2& out_screen)
{
ImVec2 screen_size = ImGui::GetIO().DisplaySize;
World2ScreenConverter world2screen(
App::GetCameraManager()->GetCamera()->getViewMatrix(true), App::GetCameraManager()->GetCamera()->getProjectionMatrix(), Ogre::Vector2(screen_size.x, screen_size.y));
Ogre::Vector3 pos_xyz = world2screen.Convert(world_pos);
if (pos_xyz.z < 0.f)
{
out_screen.x = pos_xyz.x;
out_screen.y = pos_xyz.y;
return true;
}
return false;
}
5 changes: 4 additions & 1 deletion source/main/gui/GUIUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,17 @@ void DrawGCombo(CVar* cvar, const char* label, const char* values);

Ogre::TexturePtr FetchIcon(const char* name);

ImDrawList* GetImDummyFullscreenWindow();
// Fullscreen drawing helpers
ImDrawList* GetImDummyFullscreenWindow(const std::string& name = "RoR_TransparentFullscreenWindow");
bool GetScreenPosFromWorldPos(Ogre::Vector3 const& world_pos, ImVec2& out_screen);

// Helpers for coposing combobox item strings.
void ImAddItemToComboboxString(std::string& target, std::string const& item);
void ImTerminateComboboxString(std::string& target);

// Input engine helpers
void ImDrawEventHighlighted(events input_event);
bool ImDrawEventHighlightedButton(events input_event, bool* btn_hovered = nullptr, bool* btn_active = nullptr);
void ImDrawModifierKeyHighlighted(OIS::KeyCode key);

// Draws button which must be held for a period to report "clicked" - shows a tooltip with countdown progressbar.
Expand Down
Loading

0 comments on commit 3da215a

Please sign in to comment.