Files
re3/src/extras/weaponwheel.cpp
T
2026-12-02 16:18:56 +00:00

1242 lines
41 KiB
C++

/*
* GTA V-style weapon and radio wheels (issue #31).
*
* This file is custom UI, not reversed code: it only exists when
* IMPROVED_WEAPON_WHEEL is defined (src/core/config.h) and it lives in the
* sanctioned src/extras/ layer. Guard-off builds do not compile it.
*
* Interaction (both wheels share one state machine and one radial primitive):
* weapon wheel keyboard+mouse: hold Tab, point with the mouse
* gamepad: hold R2, point with the right stick
* The player keeps walking (WASD/arrows) while the wheel is
* held; the wheel consumes the mouse delta so the camera and
* the player's facing do not turn. This matches GTA V.
* radio wheel keyboard+mouse: hold R while in a radio-equipped vehicle,
* cycle with left/right arrows or the mouse wheel
* gamepad: hold R3, cycle with D-pad left/right or the
* mouse wheel
* The radio wheel does not use the right stick, so throttle,
* brake, steering (left stick), handbrake and drive-by aiming
* keep working while the car is being driven.
* Releasing applies the highlighted entry. Mouse wheel or D-pad left/right
* cycles the entry inside one segment (only the grenade/detonator segment has
* more than one entry).
*
* An optional light 0.35x time-slow is available behind
* IMPROVED_WEAPON_WHEEL_SLOWMO but is off by default.
*
* Optional art: `weapon_wheel/wwN.png` and `weapon_wheel/iconN.png` next to the
* executable. They are third-party assets and are never shipped with the
* repository. Anything missing or unreadable falls back to the procedural
* wheel, so the feature needs no data files at all.
*/
#include "common.h"
#ifdef IMPROVED_WEAPON_WHEEL
#include "weaponwheel.h"
#include "Camera.h"
#include "CutsceneMgr.h"
#include "Darkel.h"
#include "DMAudio.h"
#include "Font.h"
#include "Frontend.h"
#include "Game.h"
#include "Hud.h"
#include "Lists.h"
#include "MusicManager.h"
#include "Pad.h"
#include "PlayerInfo.h"
#include "PlayerPed.h"
#include "Replay.h"
#ifdef GTA_SCENE_EDIT
#include "SceneEdit.h"
#endif
#include "Sprite2d.h"
#include "Text.h"
#include "Timer.h"
#include "Vehicle.h"
#include "audio_enums.h"
#include "crossplatform.h"
#include "rtpng.h"
extern wchar WideErrorString[];
enum
{
// One segment per eWeaponType 0..11; detonator (12) shares segment 11.
// See src/weapons/WeaponType.h for the eWeaponType ordering.
WHEEL_SEGMENTS = 12,
WHEEL_ARC_STEPS = 8, // quads per segment; smoother arcs, only for the procedural ring
WHEEL_FEATHER_STEPS = 4, // flat alpha steps for the radial feather
WHEEL_RING_ANGULAR_STEPS = 4, // flat colour steps across one spoke gap
WHEEL_MAX_RADIO = 12
};
// Radii as a fraction of screen height, measured from the supplied 1080p art
// (mean alpha-bbox radius of icon0..icon11 = 277.82px; ww0..ww11 inner/outer
// extents = 208.17/340.83px) so procedural fallbacks and the art coincide.
#define WHEEL_OUTER_RADIUS 0.3156f // 340.83 / 1080
#define WHEEL_INNER_RADIUS 0.1928f // 208.17 / 1080
#define WHEEL_ICON_RADIUS 0.2572f // 277.82 / 1080
#define WHEEL_ICON_SIZE 0.100f
#define WHEEL_RADIO_TEXT_R 0.2450f
#define WHEEL_WEAPON_LABEL_R 0.355f
// The supplied art's wheel is not exactly at the 1920x1080 frame centre: the
// mean of the 12 icon alpha-bbox centres is (945.75, 570.67), i.e. this offset
// from (960, 540) in units of art height. Subtracted when placing crops so the
// art wheel centre lands on the screen centre used by the procedural ring.
#define WHEEL_ART_CENTRE_X (-14.25f / 1080.0f)
#define WHEEL_ART_CENTRE_Y ( 30.67f / 1080.0f)
#define WHEEL_STICK_DEADZONE 0.35f
// Weapon wheel: absolute virtual cursor, 1:1 with the raw mouse delta. The
// engine disables the OS cursor during gameplay (GLFW_CURSOR_DISABLED), so there
// is no usable absolute window position; the cursor starts at screen centre and
// every mouse pixel moves it one screen pixel. The pointer must leave this
// radius (a few % of screen height) before it selects a segment.
#define WHEEL_CURSOR_DEADZONE 0.06f
#define WHEEL_CURSOR_ARM 0.012f // marker arm length, fraction of screen height
#define WHEEL_CURSOR_THICK 0.0018f // marker thickness, fraction of screen height
#define WHEEL_RING_FEATHER 0.006f // stepped alpha-feather band on the ring edges
#define WHEEL_RING_ANGULAR_FEATHER 0.10f // angular edge fade, fraction of one sector's angle
#define WHEEL_ART_WW_PATH "weapon_wheel/ww%d.png"
#define WHEEL_ART_ICON_PATH "weapon_wheel/icon%d.png"
static const char *ms_aWeaponShort[WHEEL_SEGMENTS] = {
"FIST", "BAT", "PISTOL", "UZI", "SHOTGUN", "AK47",
"M16", "SNIPER", "ROCKET", "FLAME", "MOLOTOV", "GRENADE"
};
static const char *ms_aWeaponLong[] = {
"UNARMED", "BASEBALL BAT", "COLT .45", "UZI", "SHOTGUN", "AK47",
"M16", "SNIPER RIFLE", "ROCKET LAUNCHER", "FLAMETHROWER", "MOLOTOV",
"GRENADE", "DETONATOR"
};
// Radio stations that fit on the wheel, in segment order. USERTRACK and
// RADIO_OFF are appended while opening, depending on availability.
static const uint8 ms_aRadioBase[] = {
HEAD_RADIO, DOUBLE_CLEF, JAH_RADIO, RISE_FM, LIPS_106,
GAME_FM, MSX_FM, FLASHBACK, CHATTERBOX
};
static const char *ms_aRadioShort[] = {
"HEAD", "DOUBLE CLEF", "K-JAH", "RISE", "LIPS", "GAME FM",
"MSX", "FLASHBACK", "CHATTERBOX", "MP3", "RADIO OFF"
};
static bool ms_bOpen;
static bool ms_bRadio;
static int32 ms_nSegments;
static int32 ms_nHovered; // -1 means "nothing pointed at"
static int32 ms_nCurrentSegment; // segment of the currently equipped entry
static bool ms_bSelectionMoved; // radio wheel: player actually cycled
static float ms_fCursorX, ms_fCursorY; // absolute virtual mouse cursor (screen px)
#ifdef IMPROVED_WEAPON_WHEEL_SLOWMO
static float ms_fSavedTimeScale;
#endif
// Remember the last weapon chosen per segment (GTA V remembers per category).
static int8 ms_aLastWeapon[WHEEL_SEGMENTS];
// Radio wheel contents, rebuilt on open.
static uint8 ms_aRadioStation[WHEEL_MAX_RADIO];
static const char *ms_aRadioLabel[WHEEL_MAX_RADIO]; // ASCII fallback
static wchar *ms_apRadioName[WHEEL_MAX_RADIO]; // resolved GXT name or nil
static int32 ms_nRadioCount;
// Optional art, loaded lazily and never freed (process lifetime, like other
// static UI state; avoids static-destructor ordering issues with RenderWare).
static bool ms_bArtTried;
static CSprite2d *ms_apWwArt[WHEEL_SEGMENTS];
static float ms_aWwOffX[WHEEL_SEGMENTS], ms_aWwOffY[WHEEL_SEGMENTS];
static float ms_aWwW[WHEEL_SEGMENTS], ms_aWwH[WHEEL_SEGMENTS];
static CSprite2d *ms_apIconArt[WHEEL_SEGMENTS];
static float ms_aIconOffX[WHEEL_SEGMENTS], ms_aIconOffY[WHEEL_SEGMENTS];
static float ms_aIconW[WHEEL_SEGMENTS], ms_aIconH[WHEEL_SEGMENTS];
// ---------------------------------------------------------------------------
// Art loading
// ---------------------------------------------------------------------------
// Read a PNG through the tree's case-resolving PNG path (RtPNGImageRead ->
// casepath on POSIX), crop it to the non-transparent bounding box so we don't
// keep twelve 1920x1080 textures in memory, and remember where the crop sat
// relative to the art's centre in units of the art height.
static CSprite2d *
Wheel_LoadArt(const char *path, float *pOffX, float *pOffY, float *pW, float *pH)
{
// RtPNGImageRead asserts on a missing file in debug builds, so probe first.
// This is also the case-insensitive probe on POSIX (fcaseopen -> casepath).
FILE *file = fcaseopen(path, "rb");
if (file == nil)
return nil;
uint8 magic[8];
size_t got = fread(magic, 1, sizeof(magic), file);
fclose(file);
if (got != sizeof(magic)
|| magic[0] != 0x89 || magic[1] != 'P' || magic[2] != 'N' || magic[3] != 'G')
return nil;
RwImage *img = RtPNGImageRead(path);
if (img == nil)
return nil;
int32 iw = RwImageGetWidth(img);
int32 ih = RwImageGetHeight(img);
uint8 *pixels = RwImageGetPixels(img);
int32 stride = RwImageGetStride(img);
// The wheel art is RGBA32; anything else is rejected and falls back.
if (pixels == nil || iw <= 0 || ih <= 0 || RwImageGetDepth(img) != 32
|| stride < iw * 4) {
RwImageDestroy(img);
return nil;
}
int32 minX = iw, minY = ih, maxX = -1, maxY = -1;
for (int32 y = 0; y < ih; y++) {
uint8 *row = pixels + y * stride;
for (int32 x = 0; x < iw; x++) {
if (row[x * 4 + 3] > 0) {
if (x < minX) minX = x;
if (x > maxX) maxX = x;
if (y < minY) minY = y;
if (y > maxY) maxY = y;
}
}
}
if (maxX < minX || maxY < minY) {
RwImageDestroy(img);
return nil;
}
int32 cw = maxX - minX + 1;
int32 ch = maxY - minY + 1;
RwImage *crop = RwImageCreate(cw, ch, 32);
if (crop == nil) {
RwImageDestroy(img);
return nil;
}
RwImageAllocatePixels(crop);
uint8 *dst = RwImageGetPixels(crop);
int32 dstStride = RwImageGetStride(crop);
if (dst == nil) {
RwImageDestroy(crop);
RwImageDestroy(img);
return nil;
}
for (int32 y = 0; y < ch; y++)
memcpy(dst + y * dstStride, pixels + (minY + y) * stride + minX * 4, cw * 4);
// Premultiply alpha. The art is straight-alpha RGBA; filtering it as such
// darkens anti-aliased edges (black fringe/jaggies). With premultiplied
// data Wheel_DrawArt blends with ONE/INVSRCALPHA, which is the correct
// filter result for soft edges.
for (int32 y = 0; y < ch; y++) {
uint8 *row = dst + y * dstStride;
for (int32 x = 0; x < cw; x++) {
uint8 *p = row + x * 4;
uint32 a = p[3];
if (a == 255)
continue;
p[0] = (uint8)((p[0] * a + 127) / 255);
p[1] = (uint8)((p[1] * a + 127) / 255);
p[2] = (uint8)((p[2] * a + 127) / 255);
}
}
// Normalised placement, relative to the art frame's centre.
*pOffX = ((minX + cw * 0.5f) - iw * 0.5f) / (float)ih;
*pOffY = ((minY + ch * 0.5f) - ih * 0.5f) / (float)ih;
*pW = cw / (float)ih;
*pH = ch / (float)ih;
RwInt32 w, h, d, flags;
RwImageFindRasterFormat(crop, rwRASTERTYPETEXTURE, &w, &h, &d, &flags);
RwRaster *raster = RwRasterCreate(w, h, d, flags);
if (raster != nil)
RwRasterSetFromImage(raster, crop);
RwImageDestroy(crop);
RwImageDestroy(img);
if (raster == nil)
return nil;
RwTexture *texture = RwTextureCreate(raster);
if (texture == nil) {
RwRasterDestroy(raster);
return nil;
}
RwTextureSetFilterMode(texture, rwFILTERLINEAR);
RwTextureSetAddressing(texture, rwTEXTUREADDRESSCLAMP);
CSprite2d *sprite = new CSprite2d;
sprite->m_pTexture = texture;
return sprite;
}
static void
Wheel_LoadArtOnce(void)
{
if (ms_bArtTried)
return;
ms_bArtTried = true;
char path[64];
for (int32 i = 0; i < WHEEL_SEGMENTS; i++) {
sprintf(path, WHEEL_ART_WW_PATH, i);
ms_apWwArt[i] = Wheel_LoadArt(path, &ms_aWwOffX[i], &ms_aWwOffY[i], &ms_aWwW[i], &ms_aWwH[i]);
sprintf(path, WHEEL_ART_ICON_PATH, i);
ms_apIconArt[i] = Wheel_LoadArt(path, &ms_aIconOffX[i], &ms_aIconOffY[i], &ms_aIconW[i], &ms_aIconH[i]);
}
}
// The art was authored for 1920x1080, so positions scale with screen height and
// are centred on the screen; the wheel therefore stays circular at any aspect.
// The measured wheel-centre offset is subtracted so hand-placed art lands on the
// procedural ring's centre. The textures are alpha-premultiplied by Wheel_LoadArt,
// so draw them with ONE/INVSRCALPHA (correct filtering for soft edges) and put
// the ordinary straight-alpha HUD state back afterwards.
static void
Wheel_DrawArt(CSprite2d *sprite, float offX, float offY, float w, float h, const CRGBA &color)
{
if (sprite == nil)
return;
float scale = SCREEN_HEIGHT;
float x = SCREEN_WIDTH * 0.5f + (offX - WHEEL_ART_CENTRE_X) * scale;
float y = SCREEN_HEIGHT * 0.5f + (offY - WHEEL_ART_CENTRE_Y) * scale;
float dw = w * scale;
float dh = h * scale;
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP);
sprite->Draw(CRect(x - dw * 0.5f, y - dh * 0.5f, x + dw * 0.5f, y + dh * 0.5f), color);
// Back to the straight-alpha state the rest of the 2D pass expects.
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSWRAP);
}
// ---------------------------------------------------------------------------
// Weapon helpers
// ---------------------------------------------------------------------------
static int32
Wheel_SegmentForWeapon(int32 weapon)
{
// The detonator has no art frame and shares the grenade segment.
if (weapon == WEAPONTYPE_DETONATOR)
return WEAPONTYPE_GRENADE;
return weapon;
}
static bool
Wheel_WeaponUsable(CPlayerPed *player, int32 weapon)
{
if (player == nil || !player->HasWeapon(weapon))
return false;
if (weapon == WEAPONTYPE_UNARMED || weapon == WEAPONTYPE_BASEBALLBAT || weapon == WEAPONTYPE_DETONATOR)
return true;
return player->GetWeapon(weapon).m_nAmmoTotal > 0;
}
// First usable weapon in a segment, or -1. Only the grenade segment can hold
// more than one inventory type.
static int32
Wheel_FirstWeaponInSegment(CPlayerPed *player, int32 segment)
{
if (segment < 0 || segment >= WHEEL_SEGMENTS)
return -1;
if (segment == WEAPONTYPE_GRENADE) {
if (Wheel_WeaponUsable(player, WEAPONTYPE_GRENADE))
return WEAPONTYPE_GRENADE;
if (Wheel_WeaponUsable(player, WEAPONTYPE_DETONATOR))
return WEAPONTYPE_DETONATOR;
return -1;
}
if (segment < WEAPONTYPE_LAST_WEAPONTYPE && Wheel_WeaponUsable(player, segment))
return segment;
return -1;
}
static int32
Wheel_SelectedWeapon(CPlayerPed *player, int32 segment)
{
int32 last = ms_aLastWeapon[segment];
if (last >= 0 && Wheel_SegmentForWeapon(last) == segment && Wheel_WeaponUsable(player, last))
return last;
return Wheel_FirstWeaponInSegment(player, segment);
}
// Segment 11 is the only one whose art frame (grenade) is not the only
// inventory type it can select: the detonator shares it. Using the grenade
// glyph and the full-white wwN wedge for a detonator would show a weapon the
// player does not have over a bright background, so those use the game's
// detonator sprite and the procedural gold sector instead.
static bool
Wheel_SegmentArtMatches(CPlayerPed *player, int32 segment)
{
int32 weapon = Wheel_SelectedWeapon(player, segment);
if (weapon < 0)
return false;
if (segment == WEAPONTYPE_GRENADE)
return weapon == WEAPONTYPE_GRENADE;
return true;
}
static void
Wheel_CycleSegment(CPlayerPed *player)
{
if (ms_nHovered != WEAPONTYPE_GRENADE)
return;
int32 grenade = Wheel_WeaponUsable(player, WEAPONTYPE_GRENADE) ? WEAPONTYPE_GRENADE : -1;
int32 detonator = Wheel_WeaponUsable(player, WEAPONTYPE_DETONATOR) ? WEAPONTYPE_DETONATOR : -1;
if (grenade < 0 || detonator < 0)
return; // nothing to cycle between
ms_aLastWeapon[ms_nHovered] = (int8)(ms_aLastWeapon[ms_nHovered] == detonator ? grenade : detonator);
}
static void
Wheel_ApplyWeapon(void)
{
CPlayerPed *player = FindPlayerPed();
if (player == nil || ms_nHovered < 0)
return;
int32 weapon = Wheel_SelectedWeapon(player, ms_nHovered);
if (weapon < 0)
return;
ms_aLastWeapon[ms_nHovered] = (int8)weapon;
player->m_nSelectedWepSlot = (int8)weapon;
// Mirror ProcessWeaponSwitch's m_nSelectedWepSlot != m_currentWeapon check
// (PlayerPed.cpp:667): re-picking the equipped weapon must not call
// MakeChangesForNewWeapon, which would refill the clip for free.
if (player->m_nSelectedWepSlot == player->m_currentWeapon)
return;
// Same rule as the reversed ProcessWeaponSwitch: don't yank the weapon out
// mid-attack/aim; the regular switch logic applies it when the state allows.
if (player->m_nPedState != PED_ATTACK && player->m_nPedState != PED_AIM_GUN && player->m_nPedState != PED_FIGHT)
player->MakeChangesForNewWeapon((int8)weapon);
}
// ---------------------------------------------------------------------------
// Radio helpers
// ---------------------------------------------------------------------------
static wchar *
Wheel_RadioFullName(uint8 station)
{
wchar *s = nil;
switch (station) {
case HEAD_RADIO: s = TheText.Get("FEA_FM0"); break;
case DOUBLE_CLEF: s = TheText.Get("FEA_FM1"); break;
case JAH_RADIO: s = TheText.Get("FEA_FM2"); break;
case RISE_FM: s = TheText.Get("FEA_FM3"); break;
case LIPS_106: s = TheText.Get("FEA_FM4"); break;
case GAME_FM: s = TheText.Get("FEA_FM5"); break;
case MSX_FM: s = TheText.Get("FEA_FM6"); break;
case FLASHBACK: s = TheText.Get("FEA_FM7"); break;
case CHATTERBOX: s = TheText.Get("FEA_FM8"); break;
case USERTRACK: s = TheText.Get("FEA_FM9"); break;
case RADIO_OFF: s = TheText.Get("FEA_FMN"); break;
default: return nil;
}
if (s == nil || s == WideErrorString)
return nil;
return s;
}
static void
Wheel_BuildRadioList(void)
{
ms_nRadioCount = 0;
for (int32 i = 0; i < (int32)ARRAY_SIZE(ms_aRadioBase) && ms_nRadioCount < WHEEL_MAX_RADIO; i++) {
ms_aRadioStation[ms_nRadioCount] = ms_aRadioBase[i];
ms_aRadioLabel[ms_nRadioCount] = ms_aRadioShort[i];
ms_apRadioName[ms_nRadioCount] = Wheel_RadioFullName(ms_aRadioBase[i]);
ms_nRadioCount++;
}
if (DMAudio.IsMP3RadioChannelAvailable() && ms_nRadioCount < WHEEL_MAX_RADIO) {
ms_aRadioStation[ms_nRadioCount] = USERTRACK;
ms_aRadioLabel[ms_nRadioCount] = ms_aRadioShort[9];
ms_apRadioName[ms_nRadioCount] = Wheel_RadioFullName(USERTRACK);
ms_nRadioCount++;
}
#ifdef RADIO_OFF_TEXT
// Same guard the vanilla radio-name HUD uses; without the GXT entry the
// wheel simply has no "off" slot and picking a station turns the radio on.
if (ms_nRadioCount < WHEEL_MAX_RADIO) {
ms_aRadioStation[ms_nRadioCount] = RADIO_OFF;
ms_aRadioLabel[ms_nRadioCount] = ms_aRadioShort[10];
ms_apRadioName[ms_nRadioCount] = Wheel_RadioFullName(RADIO_OFF);
ms_nRadioCount++;
}
#endif
}
static int32
Wheel_RadioSegmentForStation(uint8 station)
{
for (int32 i = 0; i < ms_nRadioCount; i++)
if (ms_aRadioStation[i] == station)
return i;
return -1;
}
static void
Wheel_ApplyRadio(void)
{
if (ms_nHovered < 0 || ms_nHovered >= ms_nRadioCount)
return;
// Seeded hovered entry: releasing without cycling is a no-op.
if (!ms_bSelectionMoved)
return;
if (ms_aRadioStation[ms_nHovered] == MusicManager.GetRadioInCar())
return;
MusicManager.SetRadioInCar(ms_aRadioStation[ms_nHovered]);
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_RADIO_CHANGE, 100);
}
// ---------------------------------------------------------------------------
// Open / close
// ---------------------------------------------------------------------------
static bool
Wheel_PlayerInRadioVehicle(void)
{
CVehicle *veh = FindPlayerVehicle();
if (FindPlayerPed() == nil || veh == nil)
return false;
// Police vehicles have a fixed police radio, not a tunable station.
if (MusicManager.UsesPoliceRadio(veh))
return false;
return MusicManager.PlayerInCar();
}
static bool
Wheel_AllowedToOpen(void)
{
CPlayerPed *player = FindPlayerPed();
if (player == nil || player->DyingOrDead() || player->EnteringCar())
return false;
if (FrontEndMenuManager.m_bMenuActive || CTimer::GetIsPaused())
return false;
if (CReplay::IsPlayingBack() || TheCamera.m_WideScreenOn || CGame::playingIntro)
return false;
// A GTA III rampage locks the player's weapon, so the wheel must not open
// and must not apply a switch while one runs. The weapon wheel only opens
// on foot (Wheel_WeaponTriggerHeld is false in a vehicle), so require that
// here too; this leaves the in-car radio wheel unaffected.
if (FindPlayerVehicle() == nil && CDarkel::FrenzyOnGoing())
return false;
// Rendering (and therefore CHud::Draw) is skipped during the fully faded
// state and during scene edit; close the wheel rather than leaving it open
// while it cannot be seen.
if (TheCamera.GetScreenFadeStatus() == FADE_2)
return false;
#ifdef GTA_SCENE_EDIT
if (CSceneEdit::m_bEditOn)
return false;
#endif
return true;
}
static bool
Wheel_WeaponTriggerHeld(void)
{
CPad *pad = CPad::GetPad(0);
if (FindPlayerVehicle() != nil)
return false;
// Keyboard uses the remappable WEAPON_WHEEL action; R2 stays a fixed
// gamepad fallback (it is not part of the configurable button set).
return pad->GetWeaponWheel() || pad->NewState.RightShoulder2 != 0;
}
static bool
Wheel_RadioTriggerHeld(void)
{
CPad *pad = CPad::GetPad(0);
#ifdef IMPROVED_RADIO_WHEEL
if (!Wheel_PlayerInRadioVehicle())
return false;
// R3 (RightShock) is only PED_LOOKBEHIND on foot; it has no in-car
// binding, unlike L2/R2 (drive-by look), L3 (horn) and R1 (handbrake).
return pad->NewState.RightShock != 0 || !!pad->GetChar('R');
#else
return false;
#endif
}
static void
Wheel_Open(bool radio)
{
CPlayerPed *player = FindPlayerPed();
ms_bOpen = true;
ms_bRadio = radio;
ms_bSelectionMoved = false;
// Absolute virtual cursor starts at the centre; the seeded segment stays
// selected until the pointer leaves the deadzone.
ms_fCursorX = SCREEN_WIDTH * 0.5f;
ms_fCursorY = SCREEN_HEIGHT * 0.5f;
if (radio) {
Wheel_BuildRadioList();
ms_nSegments = ms_nRadioCount;
ms_nCurrentSegment = Wheel_RadioSegmentForStation(MusicManager.GetRadioInCar());
} else {
Wheel_LoadArtOnce();
ms_nSegments = WHEEL_SEGMENTS;
ms_nCurrentSegment = player != nil ? Wheel_SegmentForWeapon(player->m_currentWeapon) : -1;
}
// Seed the selection so mouse wheel / D-pad cycling works immediately and
// releasing without moving does not lose the current entry.
if (ms_nCurrentSegment >= 0)
ms_nHovered = ms_nCurrentSegment;
else
ms_nHovered = ms_nSegments > 0 ? 0 : -1;
// Remember the equipped weapon for its own segment so a seeded, untouched
// weapon wheel (including grenade vs detonator) is a true no-op on release.
if (!radio && player != nil && ms_nCurrentSegment >= 0)
ms_aLastWeapon[ms_nCurrentSegment] = (int8)player->m_currentWeapon;
#ifdef IMPROVED_WEAPON_WHEEL_SLOWMO
if (!radio) {
ms_fSavedTimeScale = CTimer::GetTimeScale();
CTimer::SetTimeScale(0.35f);
}
#endif
}
static void
Wheel_Close(bool apply)
{
if (apply) {
if (ms_bRadio)
Wheel_ApplyRadio();
else
Wheel_ApplyWeapon();
}
#ifdef IMPROVED_WEAPON_WHEEL_SLOWMO
if (!ms_bRadio)
CTimer::SetTimeScale(ms_fSavedTimeScale);
#endif
ms_bOpen = false;
ms_bRadio = false;
ms_nHovered = -1;
}
// ---------------------------------------------------------------------------
// Input
// ---------------------------------------------------------------------------
static int32
Wheel_SegmentFromVector(float x, float y)
{
if (ms_nSegments <= 0)
return -1;
// Screen y points down; maths angles point up, so flip y.
float angle = Atan2(-y, x);
float step = TWOPI / ms_nSegments;
float rel = HALFPI - angle;
while (rel < 0.0f)
rel += TWOPI;
while (rel >= TWOPI)
rel -= TWOPI;
int32 segment = (int32)(rel / step + 0.5f);
if (segment >= ms_nSegments)
segment -= ms_nSegments;
return segment;
}
// Radio wheel: discrete cycling only. No right stick (it drives drive-by look
// in a car) and no mouse-delta integration. Arrow keys are mapped to DPadLeft/
// Right by ControllerConfig, so this covers pad D-pad and keyboard arrows.
static void
Wheel_UpdateRadioInput(void)
{
CPad *pad = CPad::GetPad(0);
bool next = pad->GetMouseWheelDownJustDown()
|| (pad->NewState.DPadRight && !pad->OldState.DPadRight);
bool prev = pad->GetMouseWheelUpJustDown()
|| (pad->NewState.DPadLeft && !pad->OldState.DPadLeft);
if (ms_nRadioCount <= 0 || ms_nHovered < 0)
return;
if (next)
ms_nHovered = (ms_nHovered + 1) % ms_nRadioCount;
else if (prev)
ms_nHovered = (ms_nHovered + ms_nRadioCount - 1) % ms_nRadioCount;
else
return;
ms_bSelectionMoved = true;
}
static void
Wheel_UpdateInput(void)
{
if (ms_bRadio) {
Wheel_UpdateRadioInput();
return;
}
CPad *pad = CPad::GetPad(0);
float bestX = 0.0f, bestY = 0.0f, bestMag = 0.0f;
// Right stick. Both backends produce NewState stick axes in roughly
// -128..127 (see CapturePad/AffectFromXinput), negative Y is up.
float stickX = pad->NewState.RightStickX / 128.0f;
float stickY = pad->NewState.RightStickY / 128.0f;
float mag = Sqrt(stickX * stickX + stickY * stickY);
if (mag > bestMag && mag >= WHEEL_STICK_DEADZONE) {
bestX = stickX;
bestY = stickY;
bestMag = mag;
}
// Mouse: absolute virtual cursor, 1:1 with the raw pad delta. The engine
// keeps the OS cursor disabled during gameplay (GLFW_CURSOR_DISABLED), so
// there is no usable absolute window position: m_nMouseTempPosX/Y is only
// updated while the menu is active. Starting at screen centre and moving
// one screen pixel per mouse pixel gives precise, repeatable pointing with
// no gain, smoothing or dead-band lag. The selection deadzone is
// WHEEL_CURSOR_DEADZONE of screen height, measured from the centre.
// NewMouseControllerState.x/y is the raw OS delta, but UpdateMouse has
// already applied the player's look-inversion flags. A pointing UI must
// follow the physical mouse, so undo that inversion here (the ini on the
// test machine has InvertMouseVertically=1).
float mouseDX = pad->NewMouseControllerState.x;
float mouseDY = pad->NewMouseControllerState.y;
if (MousePointerStateHelper.bInvertHorizontally)
mouseDX = -mouseDX;
if (MousePointerStateHelper.bInvertVertically)
mouseDY = -mouseDY;
ms_fCursorX += mouseDX;
ms_fCursorY += mouseDY;
if (ms_fCursorX < 0.0f) ms_fCursorX = 0.0f;
if (ms_fCursorX > SCREEN_WIDTH) ms_fCursorX = SCREEN_WIDTH;
if (ms_fCursorY < 0.0f) ms_fCursorY = 0.0f;
if (ms_fCursorY > SCREEN_HEIGHT) ms_fCursorY = SCREEN_HEIGHT;
float cursorDX = ms_fCursorX - SCREEN_WIDTH * 0.5f;
float cursorDY = ms_fCursorY - SCREEN_HEIGHT * 0.5f; // screen y is down; helper flips it
float cursorDist = Sqrt(cursorDX * cursorDX + cursorDY * cursorDY);
// The mouse is authoritative once the crosshair leaves the deadzone: the
// maintainer's round-3 report was exactly "crosshair moves but selection
// never changes", caused by updating the cursor without ever assigning
// ms_nHovered from it. The stick still drives selection while the
// crosshair is parked at the centre.
if (cursorDist > WHEEL_CURSOR_DEADZONE * SCREEN_HEIGHT)
ms_nHovered = Wheel_SegmentFromVector(cursorDX, cursorDY);
else if (bestMag > 0.0f)
ms_nHovered = Wheel_SegmentFromVector(bestX, bestY);
if (ms_nHovered >= 0) {
bool next = pad->GetMouseWheelDownJustDown()
|| (pad->NewState.DPadRight && !pad->OldState.DPadRight);
bool prev = pad->GetMouseWheelUpJustDown()
|| (pad->NewState.DPadLeft && !pad->OldState.DPadLeft);
CPlayerPed *player = FindPlayerPed();
if (player != nil && (next || prev))
Wheel_CycleSegment(player);
}
}
// ---------------------------------------------------------------------------
// Process / draw
// ---------------------------------------------------------------------------
// The look/freecam code reads CPad::NewMouseControllerState.x/y directly, so
// the weapon wheel must consume the delta after using it. Wheel_Process runs
// from CGame::Process before CWorld::Process and TheCamera.Process, and after
// CPad::UpdatePads committed the delta; the debug menu uses the same zeroing
// trick. Buttons are untouched, so movement keys keep working.
static void
Wheel_ConsumeMouse(void)
{
CPad *pad = CPad::GetPad(0);
pad->NewMouseControllerState.x = 0.0f;
pad->NewMouseControllerState.y = 0.0f;
}
void
Wheel_Process(void)
{
CPad *pad = CPad::GetPad(0);
if (!ms_bOpen) {
// Only gate opening: while open the wheel deliberately leaves the
// player in control, so the controls-disabled flag is checked here.
if (pad->ArePlayerControlsDisabled() || CCutsceneMgr::IsRunning())
return;
if (!Wheel_AllowedToOpen())
return;
if (Wheel_WeaponTriggerHeld()) {
Wheel_Open(false);
// The opening frame's delta must not turn the camera/player too.
Wheel_ConsumeMouse();
} else if (Wheel_RadioTriggerHeld()) {
Wheel_Open(true);
}
return;
}
if (!Wheel_AllowedToOpen()) {
bool consumeMouse = !ms_bRadio;
Wheel_Close(false);
if (consumeMouse)
Wheel_ConsumeMouse();
return;
}
bool stillWanted = ms_bRadio ? Wheel_RadioTriggerHeld() : Wheel_WeaponTriggerHeld();
if (!stillWanted) {
// Consume on the closing frame too, so the delta that was read while
// the wheel was up does not produce a one-frame camera jump on release.
bool consumeMouse = !ms_bRadio;
Wheel_Close(true);
if (consumeMouse)
Wheel_ConsumeMouse();
return;
}
Wheel_UpdateInput();
// The radio wheel does not own the mouse; only the on-foot weapon wheel
// consumes the delta.
if (!ms_bRadio)
Wheel_ConsumeMouse();
}
// Draw2DPolygon forwards to SetVertices, which fills the vertex buffer in the
// fan order (x3, x4, x2, x1). It therefore expects the four points in Z-order:
// (x1,x2) is one edge, (x3,x4) the opposite edge in the same direction.
// Passing them in angular order instead makes the fan cover only ~80% of the
// quad, leaving notches along every arc step - the source of the ragged ring.
static void
Wheel_DrawRingQuad(float a0, float a1, float r0, float r1, const CRGBA &color)
{
float cx = SCREEN_WIDTH * 0.5f;
float cy = SCREEN_HEIGHT * 0.5f;
CSprite2d::Draw2DPolygon(
cx + r0 * Cos(a0), cy - r0 * Sin(a0), // x1: inner, a0
cx + r1 * Cos(a0), cy - r1 * Sin(a0), // x2: outer, a0
cx + r0 * Cos(a1), cy - r0 * Sin(a1), // x3: inner, a1
cx + r1 * Cos(a1), cy - r1 * Sin(a1), // x4: outer, a1
color);
}
// Alpha for one step of a stepped flat-alpha feather. step 0 is fully
// transparent, step (steps-1) is the full colour.
static uint8
Wheel_StepAlpha(uint8 alpha, int32 step, int32 steps)
{
if (steps <= 1)
return step > 0 ? alpha : 0;
return (uint8)((int32)alpha * step / (steps - 1));
}
// A flat sector band: solid core plus a stepped radial feather. Every strip
// uses the same plain CSprite2d::Draw2DPolygon as the solid sectors, so the
// fade does not depend on the GOURAUD path at all. Three visible strips step
// the alpha down to zero, which is wide enough to soften the edge.
static void
Wheel_DrawSectorBand(float a0, float a1, int32 arcSteps, const CRGBA &color)
{
float inner = SCREEN_HEIGHT * WHEEL_INNER_RADIUS;
float outer = SCREEN_HEIGHT * WHEEL_OUTER_RADIUS;
float feather = SCREEN_HEIGHT * WHEEL_RING_FEATHER;
int32 steps = WHEEL_FEATHER_STEPS;
// Subdivide the arc so the circumference stays a smooth polygon; the tiny
// angular gap strips pass arcSteps=1 (their chord is well under a pixel).
for (int32 k = 0; k < arcSteps; k++) {
float aa = a0 + (a1 - a0) * (k / (float)arcSteps);
float ab = a0 + (a1 - a0) * ((k + 1) / (float)arcSteps);
Wheel_DrawRingQuad(aa, ab, inner + feather, outer - feather, color);
for (int32 j = 0; j < steps; j++) {
float t0 = (float)j / steps;
float t1 = (float)(j + 1) / steps;
// Inner circumference: transparent at "inner", full at the core.
uint8 aIn = Wheel_StepAlpha(color.a, j, steps);
if (aIn != 0)
Wheel_DrawRingQuad(aa, ab, inner + feather * t0, inner + feather * t1,
CRGBA(color.r, color.g, color.b, aIn));
// Outer circumference: full at the core, transparent at "outer".
uint8 aOut = Wheel_StepAlpha(color.a, steps - 1 - j, steps);
if (aOut != 0)
Wheel_DrawRingQuad(aa, ab, outer - feather + feather * t0,
outer - feather + feather * t1,
CRGBA(color.r, color.g, color.b, aOut));
}
}
}
static void
Wheel_DrawRing(void)
{
if (ms_nSegments <= 0 || ms_nSegments > WHEEL_MAX_RADIO)
return;
float step = TWOPI / ms_nSegments;
float aFeather = step * WHEEL_RING_ANGULAR_FEATHER;
CPlayerPed *player = FindPlayerPed();
int32 highlight = ms_nHovered >= 0 ? ms_nHovered : ms_nCurrentSegment;
bool draw[WHEEL_MAX_RADIO];
CRGBA color[WHEEL_MAX_RADIO];
// Pass 1: decide which sectors are drawn and their colour.
for (int32 i = 0; i < ms_nSegments; i++) {
bool available = true;
if (!ms_bRadio)
available = player != nil && Wheel_SelectedWeapon(player, i) >= 0;
// In art mode the selected sector is filled by the smooth wwN overlay.
// Drawing the hard-edged procedural sector underneath it leaves a
// jagged rim peeking past the texture's anti-aliased edge, so skip it.
draw[i] = !(!ms_bRadio && i == highlight && available && ms_apWwArt[i] != nil
&& Wheel_SegmentArtMatches(player, i));
if (!draw[i])
continue;
if (!available)
color[i] = CRGBA(10, 10, 10, 70);
else if (i == highlight)
color[i] = CRGBA(235, 200, 120, 225);
else
color[i] = CRGBA(18, 18, 18, 128);
}
// Pass 2: solid sectors with their stepped radial feather. Sides with a
// drawn neighbour are narrowed by the angular feather; sides next to the
// art-covered sector stay full so the wwN edge has solid ground underneath.
for (int32 i = 0; i < ms_nSegments; i++) {
if (!draw[i])
continue;
int32 prev = (i + ms_nSegments - 1) % ms_nSegments;
int32 next = (i + 1) % ms_nSegments;
float cwInset = draw[next] ? aFeather : 0.0f;
float ccwInset = draw[prev] ? aFeather : 0.0f;
float center = HALFPI - i * step;
float s0 = center - step * 0.5f + cwInset;
float s1 = center + step * 0.5f - ccwInset;
if (s1 <= s0)
continue;
Wheel_DrawSectorBand(s0, s1, WHEEL_ARC_STEPS, color[i]);
}
// Pass 3: angular (spoke) feather. The gap left by the Pass 2 insets is
// filled by a few flat colour strips stepping from one sector colour to
// the next; each strip also gets the stepped radial feather. No per-vertex
// alpha is involved.
for (int32 i = 0; i < ms_nSegments; i++) {
int32 next = (i + 1) % ms_nSegments;
if (!draw[i] || !draw[next])
continue;
float b = HALFPI - (i + 0.5f) * step; // clockwise edge of sector i
float aL = b + aFeather;
float aR = b - aFeather;
const CRGBA &cL = color[i];
const CRGBA &cR = color[next];
for (int32 k = 0; k < WHEEL_RING_ANGULAR_STEPS; k++) {
float t0 = (float)k / WHEEL_RING_ANGULAR_STEPS;
float t1 = (float)(k + 1) / WHEEL_RING_ANGULAR_STEPS;
// First and last strip match the neighbouring sectors exactly.
float t = (float)k / (WHEEL_RING_ANGULAR_STEPS - 1);
float aa = aL + (aR - aL) * t0;
float ab = aL + (aR - aL) * t1;
CRGBA c((uint8)(cL.r + (cR.r - cL.r) * t),
(uint8)(cL.g + (cR.g - cL.g) * t),
(uint8)(cL.b + (cR.b - cL.b) * t),
(uint8)(cL.a + (cR.a - cL.a) * t));
Wheel_DrawSectorBand(aa, ab, 1, c);
}
}
}
static void
Wheel_DrawCentredText(float x, float y, wchar *text, float scaleX, float scaleY, const CRGBA &color)
{
CFont::SetBackgroundOff();
CFont::SetJustifyOff();
CFont::SetRightJustifyOff();
CFont::SetCentreOn();
CFont::SetCentreSize(SCREEN_WIDTH);
CFont::SetPropOn();
CFont::SetFontStyle(FONT_HEADING);
CFont::SetScale(SCREEN_SCALE_X(scaleX), SCREEN_SCALE_Y(scaleY));
CFont::SetColor(color);
CFont::PrintString(x, y, text);
}
static void
Wheel_DrawSegmentText(int32 segment, wchar *text, float radiusFactor, const CRGBA &color)
{
if (ms_nSegments <= 0)
return;
float cx = SCREEN_WIDTH * 0.5f;
float cy = SCREEN_HEIGHT * 0.5f;
float radius = SCREEN_HEIGHT * radiusFactor;
float angle = HALFPI - segment * (TWOPI / ms_nSegments);
Wheel_DrawCentredText(cx + radius * Cos(angle), cy - radius * Sin(angle),
text, 0.30f, 0.50f, color);
}
static void
Wheel_DrawSegmentLabel(int32 segment, const char *ascii, float radiusFactor, const CRGBA &color)
{
wchar text[32];
AsciiToUnicode(ascii, text);
Wheel_DrawSegmentText(segment, text, radiusFactor, color);
}
static void
Wheel_DrawWeaponIcons(void)
{
if (ms_nSegments <= 0)
return;
CPlayerPed *player = FindPlayerPed();
float cx = SCREEN_WIDTH * 0.5f;
float cy = SCREEN_HEIGHT * 0.5f;
float radius = SCREEN_HEIGHT * WHEEL_ICON_RADIUS;
float size = SCREEN_HEIGHT * WHEEL_ICON_SIZE;
float step = TWOPI / ms_nSegments;
for (int32 i = 0; i < ms_nSegments; i++) {
int32 weapon = player != nil ? Wheel_SelectedWeapon(player, i) : -1;
bool available = weapon >= 0;
bool selected = (i == ms_nHovered);
float iconScale = selected ? 1.18f : 1.0f;
uint8 alpha = available ? (selected ? 255 : 150) : 40;
// Prefer the art glyph; the detonator has no art frame (it shares the
// grenade segment), so it uses the game's detonator sprite. Fall back
// to the HUD sprite when the art file is missing.
bool useArt = ms_apIconArt[i] != nil && weapon != WEAPONTYPE_DETONATOR;
if (useArt) {
Wheel_DrawArt(ms_apIconArt[i], ms_aIconOffX[i], ms_aIconOffY[i],
ms_aIconW[i] * iconScale, ms_aIconH[i] * iconScale,
CRGBA(255, 255, 255, alpha));
} else {
int32 sprite = i;
if (weapon == WEAPONTYPE_DETONATOR)
sprite = HUD_DETONATOR;
else if (weapon >= 0)
sprite = weapon;
float angle = HALFPI - i * step;
float x = cx + radius * Cos(angle);
float y = cy - radius * Sin(angle);
float s = size * iconScale;
CHud::Sprites[sprite].Draw(
CRect(x - s * 0.5f, y - s * 0.5f, x + s * 0.5f, y + s * 0.5f),
CRGBA(255, 255, 255, alpha));
// In procedural mode the sprite alone is not always legible, so
// label each segment. Art mode carries readable glyphs already.
Wheel_DrawSegmentLabel(i, weapon >= 0 ? ms_aWeaponLong[weapon] : ms_aWeaponShort[i],
WHEEL_WEAPON_LABEL_R, CRGBA(200, 200, 200, selected ? 255 : 170));
}
}
}
static void
Wheel_DrawRadio(void)
{
if (ms_nSegments <= 0)
return;
for (int32 i = 0; i < ms_nRadioCount; i++) {
CRGBA color = i == ms_nHovered ? CRGBA(255, 240, 180, 255) : CRGBA(210, 210, 210, 220);
if (ms_apRadioName[i] != nil)
Wheel_DrawSegmentText(i, ms_apRadioName[i], WHEEL_RADIO_TEXT_R, color);
else
Wheel_DrawSegmentLabel(i, ms_aRadioLabel[i], WHEEL_RADIO_TEXT_R, color);
}
}
static void
Wheel_DrawMouseCursor(void)
{
if (ms_bRadio)
return;
float arm = SCREEN_HEIGHT * WHEEL_CURSOR_ARM;
float thick = Max(1.0f, SCREEN_HEIGHT * WHEEL_CURSOR_THICK);
CRGBA shadow(0, 0, 0, 200);
CRGBA white(255, 255, 255, 235);
// Dark outline first, then the white cross, so it reads on the dimmed
// background and over the art.
CSprite2d::DrawRect(CRect(ms_fCursorX - arm - 1.0f, ms_fCursorY - thick - 1.0f,
ms_fCursorX + arm + 1.0f, ms_fCursorY + thick + 1.0f), shadow);
CSprite2d::DrawRect(CRect(ms_fCursorX - thick - 1.0f, ms_fCursorY - arm - 1.0f,
ms_fCursorX + thick + 1.0f, ms_fCursorY + arm + 1.0f), shadow);
CSprite2d::DrawRect(CRect(ms_fCursorX - arm, ms_fCursorY - thick,
ms_fCursorX + arm, ms_fCursorY + thick), white);
CSprite2d::DrawRect(CRect(ms_fCursorX - thick, ms_fCursorY - arm,
ms_fCursorX + thick, ms_fCursorY + arm), white);
}
void
Wheel_Draw(void)
{
if (!ms_bOpen)
return;
float cx = SCREEN_WIDTH * 0.5f;
float cy = SCREEN_HEIGHT * 0.5f;
CPlayerPed *player = FindPlayerPed();
int32 highlight = ms_nHovered >= 0 ? ms_nHovered : ms_nCurrentSegment;
// The HUD's text is batched into CFont's sprite banks and is normally
// flushed after CHud::Draw. Flush it now so the dim overlay really sits on
// top of the HUD instead of under the queued text.
CFont::DrawFonts();
// Dim the game/HUD underneath, then the shared translucent ring.
CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(0, 0, 0, 140));
Wheel_DrawRing();
// Draw2DPolygon restores depth states to ON; the 2D pass wants them off.
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
if (ms_bRadio) {
Wheel_DrawRadio();
} else {
// Art highlight for the pointed-at (or currently equipped) segment.
// An unavailable segment must not draw the bright wwN wedge at all:
// the wedge is full-white and would make the greyed-out entry look
// selected/white. The dim procedural sector is enough feedback.
bool highlightAvailable = highlight >= 0 && highlight < WHEEL_SEGMENTS
&& player != nil && Wheel_SelectedWeapon(player, highlight) >= 0
&& Wheel_SegmentArtMatches(player, highlight);
if (highlightAvailable && ms_apWwArt[highlight] != nil) {
// The wwN art is ~95% opaque white. Tint it warm gold; the texture
// is premultiplied and Wheel_DrawArt uses ONE/INVSRCALPHA, so the
// vertex colour multiplies the premultiplied texels and keeps the
// gradient while turning the block into a highlight.
Wheel_DrawArt(ms_apWwArt[highlight], ms_aWwOffX[highlight], ms_aWwOffY[highlight],
ms_aWwW[highlight], ms_aWwH[highlight], CRGBA(255, 205, 110, 255));
}
Wheel_DrawWeaponIcons();
}
// Centre readout.
wchar text[64];
if (ms_bRadio) {
int32 shown = ms_nHovered >= 0 ? ms_nHovered : ms_nCurrentSegment;
if (shown >= 0 && shown < ms_nRadioCount) {
if (ms_apRadioName[shown] != nil)
Wheel_DrawCentredText(cx, cy - SCREEN_SCALE_Y(4.0f), ms_apRadioName[shown], 0.62f, 1.05f, CRGBA(255, 240, 180, 255));
else {
AsciiToUnicode(ms_aRadioLabel[shown], text);
Wheel_DrawCentredText(cx, cy - SCREEN_SCALE_Y(4.0f), text, 0.62f, 1.05f, CRGBA(255, 240, 180, 255));
}
} else {
AsciiToUnicode("RADIO", text);
Wheel_DrawCentredText(cx, cy - SCREEN_SCALE_Y(4.0f), text, 0.62f, 1.05f, CRGBA(200, 200, 200, 220));
}
} else {
int32 shown = ms_nHovered >= 0 ? ms_nHovered : ms_nCurrentSegment;
int32 weapon = -1;
if (shown >= 0 && player != nil)
weapon = Wheel_SelectedWeapon(player, shown);
if (weapon >= 0) {
AsciiToUnicode(ms_aWeaponLong[weapon], text);
Wheel_DrawCentredText(cx, cy - SCREEN_SCALE_Y(4.0f), text, 0.62f, 1.05f, CRGBA(255, 240, 180, 255));
if (weapon != WEAPONTYPE_UNARMED && weapon != WEAPONTYPE_BASEBALLBAT) {
char number[16];
wchar ammo[64];
sprintf(number, "%d", player->GetWeapon(weapon).m_nAmmoTotal);
AsciiToUnicode(number, ammo);
Wheel_DrawCentredText(cx, cy + SCREEN_SCALE_Y(14.0f), ammo, 0.42f, 0.70f, CRGBA(210, 210, 210, 230));
}
} else {
AsciiToUnicode(ms_nHovered >= 0 ? "EMPTY" : "WEAPONS", text);
Wheel_DrawCentredText(cx, cy - SCREEN_SCALE_Y(4.0f), text, 0.62f, 1.05f, CRGBA(200, 200, 200, 220));
}
}
Wheel_DrawMouseCursor();
}
bool
Wheel_IsWeaponWheelOpen(void)
{
return ms_bOpen && !ms_bRadio;
}
bool
Wheel_IsRadioWheelOpen(void)
{
return ms_bOpen && ms_bRadio;
}
#endif // IMPROVED_WEAPON_WHEEL