mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge branch 'drawOnMinimapInbounds' into 'master'
Fix and refactor drawOnMinimap (resolves #39, #192) Closes #192 and #39 See merge request KartKrew/RingRacers!40
This commit is contained in:
commit
2bc5fcc047
3 changed files with 116 additions and 173 deletions
118
src/k_hud.cpp
118
src/k_hud.cpp
|
|
@ -4234,6 +4234,19 @@ static void K_drawKartProgressionMinimapIcon(UINT32 distancetofinish, INT32 hudx
|
||||||
V_DrawFixedPatch(hudx, hudy, FRACUNIT, flags, icon, colormap);
|
V_DrawFixedPatch(hudx, hudy, FRACUNIT, flags, icon, colormap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
position_t K_GetKartObjectPosToMinimapPos(fixed_t objx, fixed_t objy)
|
||||||
|
{
|
||||||
|
fixed_t amnumxpos, amnumypos;
|
||||||
|
|
||||||
|
amnumxpos = (FixedMul(objx, minimapinfo.zoom) - minimapinfo.offs_x);
|
||||||
|
amnumypos = -(FixedMul(objy, minimapinfo.zoom) - minimapinfo.offs_y);
|
||||||
|
|
||||||
|
if (encoremode)
|
||||||
|
amnumxpos = -amnumxpos;
|
||||||
|
|
||||||
|
return (position_t){amnumxpos, amnumypos};
|
||||||
|
}
|
||||||
|
|
||||||
static void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, patch_t *icon, UINT8 *colormap)
|
static void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, patch_t *icon, UINT8 *colormap)
|
||||||
{
|
{
|
||||||
// amnum xpos & ypos are the icon's speed around the HUD.
|
// amnum xpos & ypos are the icon's speed around the HUD.
|
||||||
|
|
@ -4243,34 +4256,26 @@ static void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32
|
||||||
// am xpos & ypos are the icon's starting position. Withouht
|
// am xpos & ypos are the icon's starting position. Withouht
|
||||||
// it, they wouldn't 'spawn' on the top-right side of the HUD.
|
// it, they wouldn't 'spawn' on the top-right side of the HUD.
|
||||||
|
|
||||||
fixed_t amnumxpos, amnumypos;
|
position_t amnumpos;
|
||||||
INT32 amxpos, amypos;
|
INT32 amxpos, amypos;
|
||||||
|
|
||||||
amnumxpos = (FixedMul(objx, minimapinfo.zoom) - minimapinfo.offs_x);
|
amnumpos = K_GetKartObjectPosToMinimapPos(objx, objy);
|
||||||
amnumypos = -(FixedMul(objy, minimapinfo.zoom) - minimapinfo.offs_y);
|
|
||||||
|
|
||||||
if (encoremode)
|
amxpos = amnumpos.x + ((hudx - (SHORT(icon->width))/2)<<FRACBITS);
|
||||||
amnumxpos = -amnumxpos;
|
amypos = amnumpos.y + ((hudy - (SHORT(icon->height))/2)<<FRACBITS);
|
||||||
|
|
||||||
amxpos = amnumxpos + ((hudx - (SHORT(icon->width))/2)<<FRACBITS);
|
|
||||||
amypos = amnumypos + ((hudy - (SHORT(icon->height))/2)<<FRACBITS);
|
|
||||||
|
|
||||||
V_DrawFixedPatch(amxpos, amypos, FRACUNIT, flags, icon, colormap);
|
V_DrawFixedPatch(amxpos, amypos, FRACUNIT, flags, icon, colormap);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void K_drawKartMinimapDot(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, UINT8 color, UINT8 size)
|
static void K_drawKartMinimapDot(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, UINT8 color, UINT8 size)
|
||||||
{
|
{
|
||||||
fixed_t amnumxpos, amnumypos;
|
position_t amnumpos;
|
||||||
INT32 amxpos, amypos;
|
INT32 amxpos, amypos;
|
||||||
|
|
||||||
amnumxpos = (FixedMul(objx, minimapinfo.zoom) - minimapinfo.offs_x);
|
amnumpos = K_GetKartObjectPosToMinimapPos(objx, objy);
|
||||||
amnumypos = -(FixedMul(objy, minimapinfo.zoom) - minimapinfo.offs_y);
|
|
||||||
|
|
||||||
if (encoremode)
|
amxpos = (amnumpos.x / FRACUNIT);
|
||||||
amnumxpos = -amnumxpos;
|
amypos = (amnumpos.y / FRACUNIT);
|
||||||
|
|
||||||
amxpos = (amnumxpos / FRACUNIT);
|
|
||||||
amypos = (amnumypos / FRACUNIT);
|
|
||||||
|
|
||||||
if (flags & V_NOSCALESTART)
|
if (flags & V_NOSCALESTART)
|
||||||
{
|
{
|
||||||
|
|
@ -4333,6 +4338,50 @@ static void K_drawKartMinimapWaypoint(waypoint_t *wp, UINT8 rank, INT32 hudx, IN
|
||||||
K_drawKartMinimapDot(wp->mobj->x, wp->mobj->y, hudx, hudy, flags | V_NOSCALESTART, pal, size);
|
K_drawKartMinimapDot(wp->mobj->x, wp->mobj->y, hudx, hudy, flags | V_NOSCALESTART, pal, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INT32 K_GetMinimapTransFlags(const boolean usingProgressBar)
|
||||||
|
{
|
||||||
|
INT32 minimaptrans = 4;
|
||||||
|
boolean dofade = (usingProgressBar && r_splitscreen > 0) || (!usingProgressBar && r_splitscreen >= 1);
|
||||||
|
|
||||||
|
if (dofade)
|
||||||
|
{
|
||||||
|
minimaptrans = FixedMul(minimaptrans, (st_translucency * FRACUNIT) / 10);
|
||||||
|
|
||||||
|
// If the minimap is fully transparent, just get your 0 back. Bail out with this.
|
||||||
|
if (!minimaptrans)
|
||||||
|
return minimaptrans;
|
||||||
|
}
|
||||||
|
|
||||||
|
minimaptrans = ((10-minimaptrans)<<V_ALPHASHIFT);
|
||||||
|
|
||||||
|
return minimaptrans;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 K_GetMinimapSplitFlags(const boolean usingProgressBar)
|
||||||
|
{
|
||||||
|
INT32 splitflags = 0;
|
||||||
|
|
||||||
|
if (usingProgressBar)
|
||||||
|
splitflags = (V_SLIDEIN|V_SNAPTOBOTTOM);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (r_splitscreen < 1) // 1P right aligned
|
||||||
|
{
|
||||||
|
splitflags = (V_SLIDEIN|V_SNAPTORIGHT);
|
||||||
|
}
|
||||||
|
else // 2/4P splits
|
||||||
|
{
|
||||||
|
if (r_splitscreen == 1)
|
||||||
|
splitflags = V_SNAPTORIGHT; // 2P right aligned
|
||||||
|
|
||||||
|
// 3P lives in the middle of the bottom right
|
||||||
|
// viewport and shouldn't fade in OR slide
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return splitflags;
|
||||||
|
}
|
||||||
|
|
||||||
#define ICON_DOT_RADIUS (10)
|
#define ICON_DOT_RADIUS (10)
|
||||||
|
|
||||||
static void K_drawKartMinimap(void)
|
static void K_drawKartMinimap(void)
|
||||||
|
|
@ -4342,8 +4391,8 @@ static void K_drawKartMinimap(void)
|
||||||
INT32 i = 0;
|
INT32 i = 0;
|
||||||
INT32 x, y;
|
INT32 x, y;
|
||||||
|
|
||||||
INT32 minimaptrans = 4;
|
INT32 minimaptrans;
|
||||||
INT32 splitflags = 0;
|
INT32 splitflags;
|
||||||
|
|
||||||
UINT8 skin = 0;
|
UINT8 skin = 0;
|
||||||
UINT8 *colormap = NULL;
|
UINT8 *colormap = NULL;
|
||||||
|
|
@ -4356,7 +4405,7 @@ static void K_drawKartMinimap(void)
|
||||||
fixed_t interpx, interpy;
|
fixed_t interpx, interpy;
|
||||||
|
|
||||||
boolean doprogressionbar = false;
|
boolean doprogressionbar = false;
|
||||||
boolean dofade = false, doencore = false;
|
boolean doencore = false;
|
||||||
|
|
||||||
UINT8 minipal;
|
UINT8 minipal;
|
||||||
|
|
||||||
|
|
@ -4378,6 +4427,11 @@ static void K_drawKartMinimap(void)
|
||||||
doprogressionbar = true;
|
doprogressionbar = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
minimaptrans = K_GetMinimapTransFlags(doprogressionbar);
|
||||||
|
if (!minimaptrans) return; // Exit early if it wouldn't draw anyway.
|
||||||
|
|
||||||
|
splitflags = K_GetMinimapSplitFlags(doprogressionbar);
|
||||||
|
|
||||||
if (doprogressionbar == false)
|
if (doprogressionbar == false)
|
||||||
{
|
{
|
||||||
if (minimapinfo.minimap_pic == NULL)
|
if (minimapinfo.minimap_pic == NULL)
|
||||||
|
|
@ -4385,20 +4439,6 @@ static void K_drawKartMinimap(void)
|
||||||
return; // no pic, just get outta here
|
return; // no pic, just get outta here
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (r_splitscreen < 1) // 1P right aligned
|
|
||||||
{
|
|
||||||
splitflags = (V_SLIDEIN|V_SNAPTORIGHT);
|
|
||||||
}
|
|
||||||
else // 2/4P splits
|
|
||||||
{
|
|
||||||
if (r_splitscreen == 1)
|
|
||||||
splitflags = V_SNAPTORIGHT; // 2P right aligned
|
|
||||||
|
|
||||||
dofade = true;
|
|
||||||
}
|
|
||||||
// 3P lives in the middle of the bottom right
|
|
||||||
// viewport and shouldn't fade in OR slide
|
|
||||||
|
|
||||||
x = MINI_X;
|
x = MINI_X;
|
||||||
y = MINI_Y;
|
y = MINI_Y;
|
||||||
|
|
||||||
|
|
@ -4413,27 +4453,15 @@ static void K_drawKartMinimap(void)
|
||||||
if (r_splitscreen > 0)
|
if (r_splitscreen > 0)
|
||||||
{
|
{
|
||||||
y = BASEVIDHEIGHT/2;
|
y = BASEVIDHEIGHT/2;
|
||||||
dofade = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
y = 180;
|
y = 180;
|
||||||
splitflags = (V_SLIDEIN|V_SNAPTOBOTTOM);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
workingPic = kp_wouldyoustillcatchmeifiwereaworm;
|
workingPic = kp_wouldyoustillcatchmeifiwereaworm;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dofade)
|
|
||||||
{
|
|
||||||
minimaptrans = FixedMul(minimaptrans, (st_translucency * FRACUNIT) / 10);
|
|
||||||
|
|
||||||
if (!minimaptrans)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
minimaptrans = ((10-minimaptrans)<<V_ALPHASHIFT);
|
|
||||||
|
|
||||||
// Really looking forward to never writing this loop again
|
// Really looking forward to never writing this loop again
|
||||||
UINT8 bestplayer = MAXPLAYERS;
|
UINT8 bestplayer = MAXPLAYERS;
|
||||||
for (i = 0; i < MAXPLAYERS; i++)
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
|
|
|
||||||
11
src/k_hud.h
11
src/k_hud.h
|
|
@ -25,6 +25,8 @@ extern "C" {
|
||||||
|
|
||||||
#define POS_DELAY_TIME 10
|
#define POS_DELAY_TIME 10
|
||||||
|
|
||||||
|
extern INT32 MINI_X, MINI_Y;
|
||||||
|
|
||||||
struct trackingResult_t
|
struct trackingResult_t
|
||||||
{
|
{
|
||||||
fixed_t x, y;
|
fixed_t x, y;
|
||||||
|
|
@ -34,6 +36,11 @@ struct trackingResult_t
|
||||||
fixed_t fov;
|
fixed_t fov;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct position_t
|
||||||
|
{
|
||||||
|
fixed_t x, y;
|
||||||
|
} position_t;
|
||||||
|
|
||||||
void K_ObjectTracking(trackingResult_t *result, const vector3_t *point, boolean reverse);
|
void K_ObjectTracking(trackingResult_t *result, const vector3_t *point, boolean reverse);
|
||||||
|
|
||||||
tic_t K_TranslateTimer(tic_t drawtime, UINT8 mode, INT32 *return_jitter);
|
tic_t K_TranslateTimer(tic_t drawtime, UINT8 mode, INT32 *return_jitter);
|
||||||
|
|
@ -118,6 +125,10 @@ playertagtype_t;
|
||||||
playertagtype_t K_WhichPlayerTag(player_t *p);
|
playertagtype_t K_WhichPlayerTag(player_t *p);
|
||||||
void K_DrawPlayerTag(fixed_t x, fixed_t y, player_t *p, playertagtype_t type, INT32 flags);
|
void K_DrawPlayerTag(fixed_t x, fixed_t y, player_t *p, playertagtype_t type, INT32 flags);
|
||||||
|
|
||||||
|
INT32 K_GetMinimapTransFlags(const boolean usingProgressBar);
|
||||||
|
INT32 K_GetMinimapSplitFlags(const boolean usingProgressBar);
|
||||||
|
position_t K_GetKartObjectPosToMinimapPos(fixed_t objx, fixed_t objy);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
148
src/lua_hudlib.c
148
src/lua_hudlib.c
|
|
@ -26,6 +26,7 @@
|
||||||
#include "w_wad.h"
|
#include "w_wad.h"
|
||||||
#include "z_zone.h"
|
#include "z_zone.h"
|
||||||
#include "hu_stuff.h"
|
#include "hu_stuff.h"
|
||||||
|
#include "k_hud.h"
|
||||||
|
|
||||||
#include "lua_script.h"
|
#include "lua_script.h"
|
||||||
#include "lua_libs.h"
|
#include "lua_libs.h"
|
||||||
|
|
@ -575,6 +576,7 @@ static int libd_drawStretched(lua_State *L)
|
||||||
|
|
||||||
// KART: draw patch on minimap from x, y coordinates on the map
|
// KART: draw patch on minimap from x, y coordinates on the map
|
||||||
// Sal: Let's please just merge the relevant info into the actual function, and have Lua call that...
|
// Sal: Let's please just merge the relevant info into the actual function, and have Lua call that...
|
||||||
|
// JugadorXEI: hey, sure.
|
||||||
static int libd_drawOnMinimap(lua_State *L)
|
static int libd_drawOnMinimap(lua_State *L)
|
||||||
{
|
{
|
||||||
fixed_t x, y, scale; // coordinates of the object
|
fixed_t x, y, scale; // coordinates of the object
|
||||||
|
|
@ -585,22 +587,12 @@ static int libd_drawOnMinimap(lua_State *L)
|
||||||
|
|
||||||
// variables used to replicate k_kart's mmap drawer:
|
// variables used to replicate k_kart's mmap drawer:
|
||||||
patch_t *AutomapPic;
|
patch_t *AutomapPic;
|
||||||
INT32 mx, my;
|
|
||||||
INT32 splitflags, minimaptrans;
|
|
||||||
|
|
||||||
// base position of the minimap which also takes splits into account:
|
|
||||||
INT32 MM_X, MM_Y;
|
|
||||||
|
|
||||||
// variables used for actually drawing the icon:
|
// variables used for actually drawing the icon:
|
||||||
fixed_t amnumxpos, amnumypos;
|
position_t amnumpos;
|
||||||
INT32 amxpos, amypos;
|
INT32 minimapflags;
|
||||||
|
fixed_t amxpos, amypos;
|
||||||
node_t *bsp = &nodes[numnodes-1];
|
INT32 mm_x, mm_y;
|
||||||
fixed_t maxx, minx, maxy, miny;
|
|
||||||
|
|
||||||
fixed_t mapwidth, mapheight;
|
|
||||||
fixed_t xoffset, yoffset;
|
|
||||||
fixed_t xscale, yscale, zoom;
|
|
||||||
fixed_t patchw, patchh;
|
fixed_t patchw, patchh;
|
||||||
|
|
||||||
HUDONLY // only run this function in hud hooks
|
HUDONLY // only run this function in hud hooks
|
||||||
|
|
@ -612,55 +604,6 @@ static int libd_drawOnMinimap(lua_State *L)
|
||||||
colormap = *((UINT8 **)luaL_checkudata(L, 5, META_COLORMAP));
|
colormap = *((UINT8 **)luaL_checkudata(L, 5, META_COLORMAP));
|
||||||
centered = lua_optboolean(L, 6);
|
centered = lua_optboolean(L, 6);
|
||||||
|
|
||||||
// replicate exactly what source does for its minimap drawer; AKA hardcoded garbo.
|
|
||||||
|
|
||||||
// first, check what position the mmap is supposed to be in (pasted from k_kart.c):
|
|
||||||
MM_X = BASEVIDWIDTH - 50; // 270
|
|
||||||
MM_Y = (BASEVIDHEIGHT/2)-16; // 84
|
|
||||||
if (r_splitscreen)
|
|
||||||
{
|
|
||||||
MM_Y = (BASEVIDHEIGHT/2);
|
|
||||||
if (r_splitscreen > 1) // 3P : bottom right
|
|
||||||
{
|
|
||||||
MM_X = (3*BASEVIDWIDTH/4);
|
|
||||||
MM_Y = (3*BASEVIDHEIGHT/4);
|
|
||||||
|
|
||||||
if (r_splitscreen > 2) // 4P: centered
|
|
||||||
{
|
|
||||||
MM_X = (BASEVIDWIDTH/2);
|
|
||||||
MM_Y = (BASEVIDHEIGHT/2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// splitscreen flags
|
|
||||||
splitflags = (r_splitscreen == 3 ? 0 : V_SNAPTORIGHT); // flags should only be 0 when it's centered (4p split)
|
|
||||||
|
|
||||||
{
|
|
||||||
const tic_t length = TICRATE/2;
|
|
||||||
|
|
||||||
if (!lt_exitticker)
|
|
||||||
return 0;
|
|
||||||
minimaptrans = 4;
|
|
||||||
if (lt_exitticker < length)
|
|
||||||
minimaptrans = (((INT32)lt_exitticker)*minimaptrans)/((INT32)length);
|
|
||||||
if (!minimaptrans)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
minimaptrans = ((10-minimaptrans)<<FF_TRANSSHIFT);
|
|
||||||
splitflags |= minimaptrans;
|
|
||||||
|
|
||||||
if (!(r_splitscreen == 2))
|
|
||||||
{
|
|
||||||
splitflags &= ~minimaptrans;
|
|
||||||
splitflags |= V_HUDTRANSHALF;
|
|
||||||
}
|
|
||||||
|
|
||||||
splitflags &= ~V_HUDTRANSHALF;
|
|
||||||
splitflags |= V_HUDTRANS;
|
|
||||||
|
|
||||||
// Draw the HUD only when playing in a level.
|
// Draw the HUD only when playing in a level.
|
||||||
// hu_stuff needs this, unlike st_stuff.
|
// hu_stuff needs this, unlike st_stuff.
|
||||||
if (gamestate != GS_LEVEL)
|
if (gamestate != GS_LEVEL)
|
||||||
|
|
@ -669,78 +612,39 @@ static int libd_drawOnMinimap(lua_State *L)
|
||||||
if (R_GetViewNumber() != 0)
|
if (R_GetViewNumber() != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
AutomapPic = mapheaderinfo[gamemap-1]->minimapPic;
|
AutomapPic = minimapinfo.minimap_pic;
|
||||||
|
|
||||||
if (!AutomapPic)
|
if (!AutomapPic)
|
||||||
{
|
{
|
||||||
return 0; // no pic, just get outta here
|
return 0; // no pic, just get outta here
|
||||||
}
|
}
|
||||||
|
|
||||||
mx = MM_X - (AutomapPic->width/2);
|
// Handle offsets and stuff.
|
||||||
my = MM_Y - (AutomapPic->height/2);
|
mm_x = MINI_X;
|
||||||
|
mm_y = MINI_Y - SHORT(AutomapPic->topoffset);
|
||||||
|
|
||||||
// let offsets transfer to the heads, too!
|
|
||||||
if (encoremode)
|
if (encoremode)
|
||||||
mx += SHORT(AutomapPic->leftoffset);
|
{
|
||||||
|
mm_x += SHORT(AutomapPic->leftoffset);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
mx -= SHORT(AutomapPic->leftoffset);
|
{
|
||||||
my -= SHORT(AutomapPic->topoffset);
|
mm_x -= SHORT(AutomapPic->leftoffset);
|
||||||
|
}
|
||||||
|
|
||||||
// now that we have replicated this behavior, we can draw an icon from our supplied x, y coordinates by replicating k_kart.c's totally understandable uncommented code!!!
|
// Minimap flags:
|
||||||
|
minimapflags = K_GetMinimapSplitFlags(false)|K_GetMinimapTransFlags(false);
|
||||||
// get map boundaries using nodes
|
|
||||||
maxx = maxy = INT32_MAX;
|
|
||||||
minx = miny = INT32_MIN;
|
|
||||||
minx = bsp->bbox[0][BOXLEFT];
|
|
||||||
maxx = bsp->bbox[0][BOXRIGHT];
|
|
||||||
miny = bsp->bbox[0][BOXBOTTOM];
|
|
||||||
maxy = bsp->bbox[0][BOXTOP];
|
|
||||||
|
|
||||||
if (bsp->bbox[1][BOXLEFT] < minx)
|
|
||||||
minx = bsp->bbox[1][BOXLEFT];
|
|
||||||
if (bsp->bbox[1][BOXRIGHT] > maxx)
|
|
||||||
maxx = bsp->bbox[1][BOXRIGHT];
|
|
||||||
if (bsp->bbox[1][BOXBOTTOM] < miny)
|
|
||||||
miny = bsp->bbox[1][BOXBOTTOM];
|
|
||||||
if (bsp->bbox[1][BOXTOP] > maxy)
|
|
||||||
maxy = bsp->bbox[1][BOXTOP];
|
|
||||||
|
|
||||||
// You might be wondering why these are being bitshift here
|
|
||||||
// it's because mapwidth and height would otherwise overflow for maps larger than half the size possible...
|
|
||||||
// map boundaries and sizes will ALWAYS be whole numbers thankfully
|
|
||||||
// later calculations take into consideration that these are actually not in terms of FRACUNIT though
|
|
||||||
minx >>= FRACBITS;
|
|
||||||
maxx >>= FRACBITS;
|
|
||||||
miny >>= FRACBITS;
|
|
||||||
maxy >>= FRACBITS;
|
|
||||||
|
|
||||||
// these are our final map boundaries:
|
|
||||||
mapwidth = maxx - minx;
|
|
||||||
mapheight = maxy - miny;
|
|
||||||
|
|
||||||
// These should always be small enough to be bitshift back right now
|
|
||||||
xoffset = (minx + mapwidth/2)<<FRACBITS;
|
|
||||||
yoffset = (miny + mapheight/2)<<FRACBITS;
|
|
||||||
|
|
||||||
xscale = FixedDiv(AutomapPic->width, mapwidth);
|
|
||||||
yscale = FixedDiv(AutomapPic->height, mapheight);
|
|
||||||
zoom = FixedMul(min(xscale, yscale), FRACUNIT-FRACUNIT/20);
|
|
||||||
|
|
||||||
amnumxpos = (FixedMul(x, zoom) - FixedMul(xoffset, zoom));
|
|
||||||
amnumypos = -(FixedMul(y, zoom) - FixedMul(yoffset, zoom));
|
|
||||||
|
|
||||||
if (encoremode)
|
|
||||||
amnumxpos = -amnumxpos;
|
|
||||||
|
|
||||||
// scale patch coords
|
// scale patch coords
|
||||||
patchw = patch->width*scale /2;
|
patchw = (SHORT(patch->width) / 2) * scale;
|
||||||
patchh = patch->height*scale /2;
|
patchh = (SHORT(patch->height) / 2) * scale;
|
||||||
|
|
||||||
if (centered)
|
if (centered)
|
||||||
patchw = patchh = 0; // patch is supposedly already centered, don't butt in.
|
patchw = patchh = 0; // patch is supposedly already centered, don't butt in.
|
||||||
|
|
||||||
amxpos = amnumxpos + ((mx + AutomapPic->width/2)<<FRACBITS) - patchw;
|
amnumpos = K_GetKartObjectPosToMinimapPos(x, y);
|
||||||
amypos = amnumypos + ((my + AutomapPic->height/2)<<FRACBITS) - patchh;
|
|
||||||
|
amxpos = amnumpos.x + (mm_x<<FRACBITS) - patchw;
|
||||||
|
amypos = amnumpos.y + (mm_y<<FRACBITS) - patchh;
|
||||||
|
|
||||||
// and NOW we can FINALLY DRAW OUR GOD DAMN PATCH :V
|
// and NOW we can FINALLY DRAW OUR GOD DAMN PATCH :V
|
||||||
lua_getfield(L, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
|
lua_getfield(L, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
|
||||||
|
|
@ -748,9 +652,9 @@ static int libd_drawOnMinimap(lua_State *L)
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
if (LUA_HUD_IsDrawListValid(list))
|
if (LUA_HUD_IsDrawListValid(list))
|
||||||
LUA_HUD_AddDrawScaled(list, amxpos, amypos, scale, patch, splitflags, colormap);
|
LUA_HUD_AddDrawScaled(list, amxpos, amypos, scale, patch, minimapflags, colormap);
|
||||||
else
|
else
|
||||||
V_DrawFixedPatch(amxpos, amypos, scale, splitflags, patch, colormap);
|
V_DrawFixedPatch(amxpos, amypos, scale, minimapflags, patch, colormap);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue