skate3recomp-multiplayer/src/skate3_native_ghost_dialog.h
MiTHRAL 4ec504ac6c ghost: fix auto-assigned room code flickering + copy button
When the relay auto-assigns a room, the code lives in the connection state
while the skate3_ghost_room cvar stays empty. The network loop was
overwriting the active room with the empty cvar every 25 ms, making the code
flicker in and out of the menu, and the Copy button copied the empty cvar.

- Loop: only sync the cvar into the active room when it is non-empty;
  preserve the server-assigned code otherwise.
- Menu: Copy grabs the ACTIVE room from GetStatus() (works for auto-assigned
  rooms, with a brief 'copied' hint); the room field now surfaces the
  auto-assigned code instead of staying blank.
2026-08-27 12:56:22 -04:00

49 lines
No EOL
1.3 KiB
C++

#pragma once
// Ghost multiplayer UI: the multiplayer menu (GhostDialog, bound to M) and
// the always-present nameplate overlay (GhostNameplateOverlay) that labels
// each remote ghost with its owner's display name.
#include <rex/ui/imgui_dialog.h>
#include "native/skate3_native_ghost_proto.h"
namespace skate3 {
class GhostDialog final : public rex::ui::ImGuiDialog {
public:
explicit GhostDialog(rex::ui::ImGuiDrawer* drawer) : ImGuiDialog(drawer) {}
void Show();
void Hide();
void Toggle();
bool visible() const { return visible_; }
protected:
void OnDraw(ImGuiIO& io) override;
private:
void SyncBuffersFromCvars();
bool visible_ = false;
bool synced_ = false;
bool copy_feedback_ = false;
char room_input_[16] = {};
char server_input_[128] = {};
char name_input_[skate3::native_ghost::kGhostMaxNameLen + 1] = {};
int rate_int_ = 20;
};
// Draws a small colored nameplate above every remote ghost whenever ghost
// multiplayer is enabled. Registers like the render-mode indicator (always
// present, draws only while active).
class GhostNameplateOverlay final : public rex::ui::ImGuiDialog {
public:
explicit GhostNameplateOverlay(rex::ui::ImGuiDrawer* drawer)
: ImGuiDialog(drawer) {}
protected:
void OnDraw(ImGuiIO& io) override;
};
} // namespace skate3