mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Replace in-map input display with new graphics
This commit is contained in:
parent
b452232974
commit
bc479321d0
4 changed files with 60 additions and 100 deletions
|
|
@ -17,6 +17,7 @@
|
||||||
#include "../g_game.h"
|
#include "../g_game.h"
|
||||||
#include "../i_joy.h"
|
#include "../i_joy.h"
|
||||||
#include "../k_hud.h"
|
#include "../k_hud.h"
|
||||||
|
#include "../k_kart.h"
|
||||||
#include "../v_draw.hpp"
|
#include "../v_draw.hpp"
|
||||||
|
|
||||||
using srb2::Draw;
|
using srb2::Draw;
|
||||||
|
|
@ -58,31 +59,47 @@ const char* dpad_suffix(const Vec2<float>& v)
|
||||||
|
|
||||||
}; // namespace
|
}; // namespace
|
||||||
|
|
||||||
void K_DrawInputDisplay(INT32 x, INT32 y, UINT8 pid)
|
|
||||||
void K_DrawInputDisplay(INT32 x, INT32 y, INT32 flags, char mode, UINT8 pid, boolean local, boolean transparent)
|
void K_DrawInputDisplay(INT32 x, INT32 y, INT32 flags, char mode, UINT8 pid, boolean local, boolean transparent)
|
||||||
{
|
{
|
||||||
const menucmd_t& cmd = menucmd[pid];
|
const ticcmd_t& cmd = players[displayplayers[pid]].cmd;
|
||||||
const std::string prefix = "PR_";
|
const std::string prefix = fmt::format("PR{}", mode);
|
||||||
auto gfx = [&](auto format, auto&&... args) { return prefix + fmt::format(format, args...); };
|
auto gfx = [&](auto format, auto&&... args) { return prefix + fmt::format(format, args...); };
|
||||||
auto but = [&](char key, INT32 gc) { return gfx(G_PlayerInputAnalog(pid, gc, 0) ? "BT{}B" : "BT{}", key); };
|
auto but = [&](char key, INT32 gc, UINT32 bt)
|
||||||
|
{
|
||||||
|
bool press = local ? G_PlayerInputAnalog(pid, gc, 0) : ((cmd.buttons & bt) == bt);
|
||||||
|
return gfx(press ? "BT{}B" : "BT{}", key);
|
||||||
|
};
|
||||||
|
|
||||||
Draw box(x, y);
|
Draw box = Draw(x, y).flags(flags);
|
||||||
|
|
||||||
box.patch(gfx("CONT"));
|
box.flags(transparent ? V_TRANSLUCENT : 0).patch(gfx("CONT"));
|
||||||
|
|
||||||
Vec2<float> dpad = {
|
Vec2<float> dpad = local ?
|
||||||
|
Vec2<float> {
|
||||||
(G_PlayerInputAnalog(pid, gc_right, 0) - G_PlayerInputAnalog(pid, gc_left, 0)) / (float)JOYAXISRANGE,
|
(G_PlayerInputAnalog(pid, gc_right, 0) - G_PlayerInputAnalog(pid, gc_left, 0)) / (float)JOYAXISRANGE,
|
||||||
(G_PlayerInputAnalog(pid, gc_up, 0) - G_PlayerInputAnalog(pid, gc_down, 0)) / (float)JOYAXISRANGE,
|
(G_PlayerInputAnalog(pid, gc_up, 0) - G_PlayerInputAnalog(pid, gc_down, 0)) / (float)JOYAXISRANGE,
|
||||||
|
} :
|
||||||
|
Vec2<float> {
|
||||||
|
-cmd.turning / (float)KART_FULLTURN,
|
||||||
|
(float)cmd.throwdir,
|
||||||
};
|
};
|
||||||
|
|
||||||
box.patch(gfx("PAD{}", dpad_suffix(dpad)));
|
box.patch(gfx("PAD{}", dpad_suffix(dpad)));
|
||||||
box.patch(but('A', gc_a));
|
box.patch(but('A', gc_a, BT_ACCELERATE));
|
||||||
box.patch(but('B', gc_b));
|
box.patch(but('B', gc_b, BT_LOOKBACK));
|
||||||
box.patch(but('C', gc_c));
|
box.patch(but('C', gc_c, BT_SPINDASHMASK));
|
||||||
box.patch(but('X', gc_x));
|
box.patch(but('X', gc_x, BT_BRAKE));
|
||||||
box.patch(but('Y', gc_y));
|
box.patch(but('Y', gc_y, BT_RESPAWN));
|
||||||
box.patch(but('Z', gc_z));
|
box.patch(but('Z', gc_z, BT_VOTE));
|
||||||
box.patch(but('L', gc_l));
|
box.patch(but('L', gc_l, BT_ATTACK));
|
||||||
box.patch(but('R', gc_r));
|
box.patch(but('R', gc_r, BT_DRIFT));
|
||||||
box.patch(but('S', gc_start));
|
box.patch(but('S', gc_start, 0xFFFFFFFF));
|
||||||
|
|
||||||
|
if (mode == '4' || mode == '5') // Saturn 3D
|
||||||
|
{
|
||||||
|
float dist = (mode == '4') ? 3.f : 2.f;
|
||||||
|
|
||||||
|
box.patch(gfx("JOY1"));
|
||||||
|
box.xy(dpad.x * dist, -dpad.y * dist).patch(gfx("JOY2"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@
|
||||||
#include "k_rank.h"
|
#include "k_rank.h"
|
||||||
#include "g_party.h"
|
#include "g_party.h"
|
||||||
#include "k_hitlag.h"
|
#include "k_hitlag.h"
|
||||||
|
#include "g_input.h"
|
||||||
|
|
||||||
//{ Patch Definitions
|
//{ Patch Definitions
|
||||||
static patch_t *kp_nodraw;
|
static patch_t *kp_nodraw;
|
||||||
|
|
@ -5160,85 +5161,27 @@ static void K_drawKartFirstPerson(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// doesn't need to ever support 4p
|
|
||||||
static void K_drawInput(void)
|
static void K_drawInput(void)
|
||||||
{
|
{
|
||||||
static INT32 pn = 0;
|
INT32 def[4][3] = {
|
||||||
INT32 target = 0, splitflags = (V_SNAPTOBOTTOM|V_SNAPTORIGHT);
|
{247, 156, V_SNAPTOBOTTOM | V_SNAPTORIGHT}, // 1p
|
||||||
INT32 x = BASEVIDWIDTH - 32, y = BASEVIDHEIGHT-24, offs, col;
|
{247, 56, V_SNAPTOBOTTOM | V_SNAPTORIGHT}, // 2p
|
||||||
const INT32 accent1 = splitflags | skincolors[stplyr->skincolor].ramp[5];
|
{6, 52, V_SNAPTOBOTTOM | V_SNAPTOLEFT}, // 4p left
|
||||||
const INT32 accent2 = splitflags | skincolors[stplyr->skincolor].ramp[9];
|
{282 - BASEVIDWIDTH/2, 52, V_SNAPTOBOTTOM | V_SNAPTORIGHT}, // 4p right
|
||||||
ticcmd_t *cmd = &stplyr->cmd;
|
};
|
||||||
|
INT32 k = r_splitscreen <= 1 ? r_splitscreen : 2 + (R_GetViewNumber() & 1);
|
||||||
#define BUTTW 8
|
INT32 flags = def[k][2] | V_SPLITSCREEN | V_SLIDEIN;
|
||||||
#define BUTTH 11
|
char mode = ((stplyr->pflags & PF_ANALOGSTICK) ? '4' : '2') + (r_splitscreen > 1);
|
||||||
|
bool local = !demo.playback && P_IsMachineLocalPlayer(stplyr);
|
||||||
#define drawbutt(xoffs, butt, symb)\
|
K_DrawInputDisplay(
|
||||||
if (!stplyr->exiting && (cmd->buttons & butt))\
|
def[k][0],
|
||||||
{\
|
def[k][1],
|
||||||
offs = 2;\
|
flags,
|
||||||
col = accent1;\
|
mode,
|
||||||
}\
|
(local ? G_LocalSplitscreenPartyPosition : G_PartyPosition)(stplyr - players),
|
||||||
else\
|
local,
|
||||||
{\
|
stplyr->speed > 0
|
||||||
offs = 0;\
|
);
|
||||||
col = accent2;\
|
|
||||||
V_DrawFill(x+(xoffs), y+BUTTH, BUTTW-1, 2, splitflags|31);\
|
|
||||||
}\
|
|
||||||
V_DrawFill(x+(xoffs), y+offs, BUTTW-1, BUTTH, col);\
|
|
||||||
V_DrawFixedPatch((x+1+(xoffs))<<FRACBITS, (y+offs+1)<<FRACBITS, FRACUNIT, splitflags, fontv[TINY_FONT].font[symb-HU_FONTSTART], NULL)
|
|
||||||
|
|
||||||
drawbutt(-2*BUTTW, BT_ACCELERATE, 'A');
|
|
||||||
drawbutt( -BUTTW, BT_BRAKE, 'B');
|
|
||||||
drawbutt( 0, BT_DRIFT, 'D');
|
|
||||||
drawbutt( BUTTW, BT_ATTACK, 'I');
|
|
||||||
|
|
||||||
#undef drawbutt
|
|
||||||
|
|
||||||
#undef BUTTW
|
|
||||||
#undef BUTTH
|
|
||||||
|
|
||||||
y -= 1;
|
|
||||||
|
|
||||||
if (stplyr->exiting || !stplyr->steering) // no turn
|
|
||||||
target = 0;
|
|
||||||
else // turning of multiple strengths!
|
|
||||||
{
|
|
||||||
target = ((abs(stplyr->steering) - 1)/125)+1;
|
|
||||||
if (target > 4)
|
|
||||||
target = 4;
|
|
||||||
if (stplyr->steering < 0)
|
|
||||||
target = -target;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pn != target)
|
|
||||||
{
|
|
||||||
if (abs(pn - target) == 1)
|
|
||||||
pn = target;
|
|
||||||
else if (pn < target)
|
|
||||||
pn += 2;
|
|
||||||
else //if (pn > target)
|
|
||||||
pn -= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pn < 0)
|
|
||||||
{
|
|
||||||
splitflags |= V_FLIP; // right turn
|
|
||||||
x--;
|
|
||||||
}
|
|
||||||
|
|
||||||
target = abs(pn);
|
|
||||||
if (target > 4)
|
|
||||||
target = 4;
|
|
||||||
|
|
||||||
if (!stplyr->skincolor)
|
|
||||||
V_DrawFixedPatch(x<<FRACBITS, y<<FRACBITS, FRACUNIT, splitflags, kp_inputwheel[target], NULL);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UINT8 *colormap;
|
|
||||||
colormap = R_GetTranslationColormap(TC_DEFAULT, static_cast<skincolornum_t>(stplyr->skincolor), GTC_CACHE);
|
|
||||||
V_DrawFixedPatch(x<<FRACBITS, y<<FRACBITS, FRACUNIT, splitflags, kp_inputwheel[target], colormap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void K_drawChallengerScreen(void)
|
static void K_drawChallengerScreen(void)
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ void K_DrawKartPositionNumXY(
|
||||||
boolean exit, boolean lastLap, boolean losing
|
boolean exit, boolean lastLap, boolean losing
|
||||||
);
|
);
|
||||||
|
|
||||||
void K_DrawInputDisplay(INT32 x, INT32 y, UINT8 pid);
|
void K_DrawInputDisplay(INT32 x, INT32 y, INT32 flags, char mode, UINT8 pid, boolean local, boolean transparent);
|
||||||
|
|
||||||
extern patch_t *kp_capsuletarget_arrow[2][2];
|
extern patch_t *kp_capsuletarget_arrow[2][2];
|
||||||
extern patch_t *kp_capsuletarget_icon[2];
|
extern patch_t *kp_capsuletarget_icon[2];
|
||||||
|
|
|
||||||
|
|
@ -4850,7 +4850,7 @@ void M_DrawProfileControls(void)
|
||||||
patch_t *hint = W_CachePatchName("MENUHINT", PU_CACHE);
|
patch_t *hint = W_CachePatchName("MENUHINT", PU_CACHE);
|
||||||
INT32 hintofs = 3;
|
INT32 hintofs = 3;
|
||||||
|
|
||||||
K_DrawInputDisplay(BASEVIDWIDTH*2/3 - optionsmenu.contx, BASEVIDHEIGHT/2 - optionsmenu.conty, pid);
|
K_DrawInputDisplay(BASEVIDWIDTH*2/3 - optionsmenu.contx, BASEVIDHEIGHT/2 - optionsmenu.conty, 0, '_', pid, true, false);
|
||||||
|
|
||||||
if (optionsmenu.trycontroller)
|
if (optionsmenu.trycontroller)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue