mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 12:47:58 +03:00
parent
965cf41225
commit
a3d3a51445
5 changed files with 60 additions and 18 deletions
|
@ -10,6 +10,7 @@
|
|||
- added an option to control how music is played while underwater (#1937)
|
||||
- added an optional demo number argument to the `/demo` command
|
||||
- changed demo to be interrupted only by esc or action keys
|
||||
- fixed health bar and air bar scaling (#2149)
|
||||
- fixed Lara prioritising throwing a spent flare while mid-air, so to avoid missing ledge grabs (#1989)
|
||||
- fixed Lara at times not being able to jump immediately after going from her walking to running animation (#1587)
|
||||
- fixed bubbles spawning from flares if Lara is in shallow water (#1590)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "game/random.h"
|
||||
#include "game/render/common.h"
|
||||
#include "game/render/priv.h"
|
||||
#include "game/scaler.h"
|
||||
#include "game/shell.h"
|
||||
#include "game/viewport.h"
|
||||
#include "global/vars.h"
|
||||
|
@ -48,23 +49,27 @@ static void M_InsertBar(
|
|||
const COLOR_NAME bar_color_highlight)
|
||||
{
|
||||
const int32_t z_offset = 8;
|
||||
Render_InsertFlatRect(
|
||||
l, t, l + w, t + h, g_PhdNearZ + z_offset * 5,
|
||||
g_NamedColors[COLOR_WHITE].palette_index);
|
||||
Render_InsertFlatRect(
|
||||
l + 1, t + 1, l + w, t + h, g_PhdNearZ + z_offset * 4,
|
||||
g_NamedColors[COLOR_GRAY].palette_index);
|
||||
Render_InsertFlatRect(
|
||||
l + 1, t + 1, l + w - 1, t + h - 1, g_PhdNearZ + z_offset * 3,
|
||||
g_NamedColors[COLOR_BLACK].palette_index);
|
||||
|
||||
Render_InsertFlatRect(
|
||||
l + 2, t + 2, l + (w - 2) * percent / 100, t + h - 2,
|
||||
g_PhdNearZ + z_offset * 2, g_NamedColors[bar_color_main].palette_index);
|
||||
Render_InsertFlatRect(
|
||||
l + 2, t + 3, l + (w - 2) * percent / 100, t + 4,
|
||||
g_PhdNearZ + z_offset * 1,
|
||||
g_NamedColors[bar_color_highlight].palette_index);
|
||||
struct {
|
||||
int32_t x1, y1, x2, y2;
|
||||
COLOR_NAME color;
|
||||
} rects[] = {
|
||||
{ l, t, l + w, t + h, COLOR_WHITE },
|
||||
{ l + 1, t + 1, l + w, t + h, COLOR_GRAY },
|
||||
{ l + 1, t + 1, l + w - 1, t + h - 1, COLOR_BLACK },
|
||||
{ l + 2, t + 2, l + (w - 2) * percent / 100, t + h - 2,
|
||||
bar_color_main },
|
||||
{ l + 2, t + 3, l + (w - 2) * percent / 100, t + 4,
|
||||
bar_color_highlight },
|
||||
};
|
||||
|
||||
for (int32_t i = 0; i < 5; i++) {
|
||||
Render_InsertFlatRect(
|
||||
Scaler_Calc(rects[i].x1), Scaler_Calc(rects[i].y1),
|
||||
Scaler_Calc(rects[i].x2), Scaler_Calc(rects[i].y2),
|
||||
g_PhdNearZ + z_offset * (5 - i),
|
||||
g_NamedColors[rects[i].color].palette_index);
|
||||
}
|
||||
}
|
||||
|
||||
static const int16_t *M_CalcRoomVerticesWibble(const int16_t *obj_ptr)
|
||||
|
@ -751,8 +756,8 @@ void Output_DrawHealthBar(const int32_t percent)
|
|||
void Output_DrawAirBar(const int32_t percent)
|
||||
{
|
||||
g_IsShadeEffect = false;
|
||||
M_InsertBar(
|
||||
g_PhdWinWidth - 112, 6, 105, 9, percent, COLOR_BLUE, COLOR_WHITE);
|
||||
const int32_t w = Scaler_CalcInverse(g_PhdWinWidth);
|
||||
M_InsertBar(w - 112, 6, 105, 9, percent, COLOR_BLUE, COLOR_WHITE);
|
||||
}
|
||||
|
||||
int16_t Output_FindColor(
|
||||
|
|
29
src/tr2/game/scaler.c
Normal file
29
src/tr2/game/scaler.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include "game/scaler.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "global/vars.h"
|
||||
|
||||
#include <libtrx/log.h>
|
||||
#include <libtrx/utils.h>
|
||||
|
||||
static int32_t M_DoCalc(
|
||||
int32_t unit, int32_t base_width, int32_t base_height, double factor)
|
||||
{
|
||||
int32_t scale_x = g_PhdWinWidth > base_width
|
||||
? ((double)g_PhdWinWidth * unit * factor) / base_width
|
||||
: unit * factor;
|
||||
int32_t scale_y = g_PhdWinHeight > base_height
|
||||
? ((double)g_PhdWinHeight * unit * factor) / base_height
|
||||
: unit * factor;
|
||||
return MIN(scale_x, scale_y);
|
||||
}
|
||||
|
||||
int32_t Scaler_Calc(const int32_t unit)
|
||||
{
|
||||
return M_DoCalc(unit, 640, 480, 1.0);
|
||||
}
|
||||
|
||||
int32_t Scaler_CalcInverse(const int32_t unit)
|
||||
{
|
||||
return unit * 0x10000 / MAX(1, Scaler_Calc(0x10000));
|
||||
}
|
6
src/tr2/game/scaler.h
Normal file
6
src/tr2/game/scaler.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
int32_t Scaler_Calc(int32_t unit);
|
||||
int32_t Scaler_CalcInverse(int32_t unit);
|
|
@ -266,6 +266,7 @@ sources = [
|
|||
'game/room.c',
|
||||
'game/room_draw.c',
|
||||
'game/savegame/common.c',
|
||||
'game/scaler.c',
|
||||
'game/shell/common.c',
|
||||
'game/shell/input.c',
|
||||
'game/sound.c',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue