mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-07-09 23:02:11 -04:00
Remove GameInfoWindow, Multiplayer Button, and FPS Slider
This commit is contained in:
@@ -1,87 +0,0 @@
|
||||
#include "GameInfoWindow.h"
|
||||
#include "UIWidgets.h"
|
||||
#include "libultraship/src/Context.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <libultraship/libultraship.h>
|
||||
#include "spdlog/spdlog.h"
|
||||
#include <common_structs.h>
|
||||
#include <defines.h>
|
||||
|
||||
extern "C" {
|
||||
#include "../../../src/main.h"
|
||||
#include "networking/networking.h"
|
||||
}
|
||||
|
||||
namespace GameInfo {
|
||||
GameInfoWindow::~GameInfoWindow() {
|
||||
SPDLOG_TRACE("destruct game info window");
|
||||
}
|
||||
|
||||
void GameInfoWindow::InitElement() {
|
||||
}
|
||||
|
||||
static s32 sReadyUpBool = false;
|
||||
|
||||
void GameInfoWindow::DrawElement() {
|
||||
const float framerate = ImGui::GetIO().Framerate;
|
||||
const float deltatime = ImGui::GetIO().DeltaTime;
|
||||
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0));
|
||||
|
||||
static char username[NETWORK_USERNAME_LENGTH] = "TestUser";
|
||||
|
||||
ImGui::Text("Username:");
|
||||
ImGui::InputText("##edit", username, IM_ARRAYSIZE(username));
|
||||
|
||||
static char address[32] = "127.0.0.1:64010";
|
||||
static char addressCopy[32];
|
||||
strncpy(addressCopy, address, sizeof(addressCopy));
|
||||
addressCopy[sizeof(addressCopy) - 1] = '\0'; // Ensure null termination
|
||||
|
||||
ImGui::Text("Host:");
|
||||
ImGui::InputText("##edit3", addressCopy, IM_ARRAYSIZE(addressCopy));
|
||||
|
||||
if (ImGui::Button("Connect!")) {
|
||||
char* ip = NULL;
|
||||
uint16_t port = 0;
|
||||
|
||||
char* token = strtok(addressCopy, ":");
|
||||
ip = token;
|
||||
|
||||
token = strtok(NULL, ":");
|
||||
if (token != NULL) {
|
||||
port = (uint16_t) atoi(token);
|
||||
}
|
||||
|
||||
gNetwork.enabled = true;
|
||||
ConnectToServer(ip, port, username);
|
||||
}
|
||||
|
||||
char buttonLabel[32];
|
||||
|
||||
if (sReadyUpBool) {
|
||||
strcpy(buttonLabel, "Lets Go!");
|
||||
} else {
|
||||
strcpy(buttonLabel, "Ready Up!");
|
||||
}
|
||||
|
||||
if (ImGui::Button(buttonLabel)) {
|
||||
sReadyUpBool = !sReadyUpBool;
|
||||
networking_ready_up(sReadyUpBool);
|
||||
}
|
||||
|
||||
if (gGamestate == RACING) {
|
||||
|
||||
ImGui::Text("Player %f, %f, %f", gPlayers[0].pos[0], gPlayers[0].pos[1], gPlayers[0].pos[2]);
|
||||
|
||||
for (int i = 0; i < NUM_PLAYERS; i++) {
|
||||
ImGui::Text("Player %d: type: %X, char: %d, rank: %d, hasAuthority: %d", i, gPlayers[i].type,
|
||||
gPlayers[i].characterId, gPlayers[i].currentRank, gPlayers[i].nHasAuthority);
|
||||
}
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
void GameInfoWindow::UpdateElement() {
|
||||
}
|
||||
} // namespace GameInfo
|
||||
@@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <libultraship/libultraship.h>
|
||||
|
||||
namespace GameInfo {
|
||||
class GameInfoWindow : public Ship::GuiWindow {
|
||||
public:
|
||||
using Ship::GuiWindow::GuiWindow;
|
||||
~GameInfoWindow();
|
||||
|
||||
private:
|
||||
void InitElement() override;
|
||||
void DrawElement() override;
|
||||
void UpdateElement() override;
|
||||
};
|
||||
} // namespace GameInfo
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "ImguiUI.h"
|
||||
#include "UIWidgets.h"
|
||||
#include "ResolutionEditor.h"
|
||||
#include "GameInfoWindow.h"
|
||||
#include "MultiplayerWindow.h"
|
||||
#include "FreecamWindow.h"
|
||||
#include "Tools.h"
|
||||
@@ -35,7 +34,6 @@ std::shared_ptr<Ship::GuiWindow> mConsoleWindow;
|
||||
std::shared_ptr<Ship::GuiWindow> mStatsWindow;
|
||||
std::shared_ptr<Ship::GuiWindow> mInputEditorWindow;
|
||||
std::shared_ptr<Ship::GuiWindow> mGfxDebuggerWindow;
|
||||
std::shared_ptr<Ship::GuiWindow> mGameInfoWindow;
|
||||
std::shared_ptr<Ship::GuiWindow> mMultiplayerWindow;
|
||||
std::shared_ptr<Ship::GuiWindow> mToolsWindow;
|
||||
std::shared_ptr<Ship::GuiWindow> mSceneExplorerWindow;
|
||||
@@ -57,11 +55,6 @@ void SetupGuiElements() {
|
||||
SPDLOG_ERROR("Could not find multiplayer window");
|
||||
}
|
||||
|
||||
mGameInfoWindow = gui->GetGuiWindow("GameInfo");
|
||||
if (mGameInfoWindow == nullptr) {
|
||||
SPDLOG_ERROR("Could not find game info window");
|
||||
}
|
||||
|
||||
mStatsWindow = gui->GetGuiWindow("Stats");
|
||||
if (mStatsWindow == nullptr) {
|
||||
SPDLOG_ERROR("Could not find stats window");
|
||||
@@ -99,13 +92,9 @@ void SetupGuiElements() {
|
||||
mContentBrowserWindow =
|
||||
std::make_shared<Editor::ContentBrowserWindow>("gEditorEnabled", "Content Browser");
|
||||
gui->AddGuiWindow(mContentBrowserWindow);
|
||||
|
||||
mGameInfoWindow = std::make_shared<GameInfo::GameInfoWindow>("gGameInfoEnabled", "Game Info");
|
||||
gui->AddGuiWindow(mGameInfoWindow);
|
||||
}
|
||||
|
||||
void Destroy() {
|
||||
mGameInfoWindow = nullptr;
|
||||
mConsoleWindow = nullptr;
|
||||
mStatsWindow = nullptr;
|
||||
mInputEditorWindow = nullptr;
|
||||
|
||||
@@ -152,13 +152,13 @@ void DrawColumn2(WidgetInfo& info) {
|
||||
}
|
||||
|
||||
void RegisterMultiplayerWidgets() {
|
||||
mPortMenu->AddSidebarEntry("Enhancements", "Multiplayer", 2);
|
||||
WidgetPath path = { "Enhancements", "Multiplayer", SECTION_COLUMN_1 };
|
||||
mPortMenu->AddWidget(path, "Multi Custom 1", WIDGET_CUSTOM)
|
||||
.CustomFunction(DrawColumn1);
|
||||
path.column = SECTION_COLUMN_2;
|
||||
mPortMenu->AddWidget(path, "Multi Custom 2", WIDGET_CUSTOM)
|
||||
.CustomFunction(DrawColumn2);
|
||||
// mPortMenu->AddSidebarEntry("Enhancements", "Multiplayer", 2);
|
||||
// WidgetPath path = { "Enhancements", "Multiplayer", SECTION_COLUMN_1 };
|
||||
// mPortMenu->AddWidget(path, "Multi Custom 1", WIDGET_CUSTOM)
|
||||
// .CustomFunction(DrawColumn1);
|
||||
// path.column = SECTION_COLUMN_2;
|
||||
// mPortMenu->AddWidget(path, "Multi Custom 2", WIDGET_CUSTOM)
|
||||
// .CustomFunction(DrawColumn2);
|
||||
}
|
||||
|
||||
static RegisterMenuInitFunc initFunc(RegisterMultiplayerWidgets);
|
||||
|
||||
+15
-23
@@ -240,21 +240,21 @@ void PortMenu::AddSettings() {
|
||||
.DefaultValue(1));
|
||||
#endif
|
||||
|
||||
AddWidget(path, "Current FPS: %d", WIDGET_CVAR_SLIDER_INT)
|
||||
.CVar("gInterpolationFPS")
|
||||
.Callback([](WidgetInfo& info) {
|
||||
int32_t defaultValue = std::static_pointer_cast<IntSliderOptions>(info.options)->defaultValue;
|
||||
if (CVarGetInteger(info.cVar, defaultValue) == defaultValue) {
|
||||
info.name = "Current FPS: Original (%d)";
|
||||
} else {
|
||||
info.name = "Current FPS: %d";
|
||||
}
|
||||
})
|
||||
.PreFunc([](WidgetInfo& info) {
|
||||
if (mPortMenu->disabledMap.at(DISABLE_FOR_MATCH_REFRESH_RATE_ON).active)
|
||||
info.activeDisables.push_back(DISABLE_FOR_MATCH_REFRESH_RATE_ON);
|
||||
})
|
||||
.Options(IntSliderOptions().Tooltip(tooltip).Min(20).Max(maxFps).DefaultValue(20));
|
||||
// AddWidget(path, "Current FPS: %d", WIDGET_CVAR_SLIDER_INT)
|
||||
// .CVar("gInterpolationFPS")
|
||||
// .Callback([](WidgetInfo& info) {
|
||||
// int32_t defaultValue = std::static_pointer_cast<IntSliderOptions>(info.options)->defaultValue;
|
||||
// if (CVarGetInteger(info.cVar, defaultValue) == defaultValue) {
|
||||
// info.name = "Current FPS: Original (%d)";
|
||||
// } else {
|
||||
// info.name = "Current FPS: %d";
|
||||
// }
|
||||
// })
|
||||
// .PreFunc([](WidgetInfo& info) {
|
||||
// if (mPortMenu->disabledMap.at(DISABLE_FOR_MATCH_REFRESH_RATE_ON).active)
|
||||
// info.activeDisables.push_back(DISABLE_FOR_MATCH_REFRESH_RATE_ON);
|
||||
// })
|
||||
// .Options(IntSliderOptions().Tooltip(tooltip).Min(20).Max(maxFps).DefaultValue(20));
|
||||
AddWidget(path, "Match Refresh Rate", WIDGET_BUTTON)
|
||||
.Callback([](WidgetInfo& info) {
|
||||
int hz = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
|
||||
@@ -400,14 +400,6 @@ void PortMenu::AddDevTools() {
|
||||
"Enables the Gfx Debugger window, allowing you to input commands. Type help for some examples"))
|
||||
.WindowName("GfxDebuggerWindow");
|
||||
|
||||
path = { "Developer", "Game Info", SECTION_COLUMN_1 };
|
||||
AddSidebarEntry("Developer", "Game Info", 1);
|
||||
AddWidget(path, "Popout Game Info", WIDGET_WINDOW_BUTTON)
|
||||
.CVar("gGameInfoEnabled")
|
||||
.Options(ButtonOptions().Tooltip(
|
||||
"Shows the game info window, contains player and actor information"))
|
||||
.WindowName("GameInfo");
|
||||
|
||||
path = { "Developer", "Stats", SECTION_COLUMN_1 };
|
||||
AddSidebarEntry("Developer", "Stats", 1);
|
||||
AddWidget(path, "Popout Stats", WIDGET_WINDOW_BUTTON)
|
||||
|
||||
@@ -531,7 +531,7 @@ void UpdateResolutionVars() {
|
||||
bool IsDroppingFrames() {
|
||||
// a rather imprecise way of checking for frame drops.
|
||||
// but it's mostly there to inform the player of large drops.
|
||||
const short targetFPS = CVarGetInteger("gInterpolationFPS", 20);
|
||||
const short targetFPS = CVarGetInteger("gInterpolationFPS", 30);
|
||||
const float threshold = targetFPS / 20.0f + 4.1f;
|
||||
return ImGui::GetIO().Framerate < targetFPS - threshold;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user