mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 20:58:07 +03:00
tr2: move scaler to libtrx
This commit is contained in:
parent
f04a18f208
commit
db94669ae4
12 changed files with 31 additions and 19 deletions
|
@ -1,20 +1,21 @@
|
|||
#include "game/scaler.h"
|
||||
|
||||
#include "global/vars.h"
|
||||
|
||||
#include <libtrx/config.h>
|
||||
#include <libtrx/log.h>
|
||||
#include <libtrx/utils.h>
|
||||
#include "config.h"
|
||||
#include "game/viewport.h"
|
||||
#include "log.h"
|
||||
#include "utils.h"
|
||||
|
||||
static int32_t M_DoCalc(
|
||||
int32_t unit, int32_t base_width, int32_t base_height, double factor)
|
||||
{
|
||||
const int32_t win_width = Viewport_GetWidth();
|
||||
const int32_t win_height = Viewport_GetHeight();
|
||||
const int32_t sign = unit < 0 ? -1 : 1;
|
||||
const int32_t scale_x = g_PhdWinWidth > base_width
|
||||
? ((double)g_PhdWinWidth * ABS(unit) * factor) / MAX(1, base_width)
|
||||
const int32_t scale_x = win_width > base_width
|
||||
? ((double)win_width * ABS(unit) * factor) / MAX(1, base_width)
|
||||
: ABS(unit) * factor;
|
||||
const int32_t scale_y = g_PhdWinHeight > base_height
|
||||
? ((double)g_PhdWinHeight * ABS(unit) * factor) / MAX(1, base_height)
|
||||
const int32_t scale_y = win_height > base_height
|
||||
? ((double)win_height * ABS(unit) * factor) / MAX(1, base_height)
|
||||
: ABS(unit) * factor;
|
||||
return MIN(scale_x, scale_y) * sign;
|
||||
}
|
|
@ -11,5 +11,7 @@ extern int16_t Viewport_GetFOV(bool resolve_user_fov);
|
|||
extern void Viewport_AlterFOV(int16_t view_angle);
|
||||
#endif
|
||||
|
||||
extern int32_t Viewport_GetWidth(void);
|
||||
extern int32_t Viewport_GetHeight(void);
|
||||
extern int32_t Viewport_GetMaxX(void);
|
||||
extern int32_t Viewport_GetMaxY(void);
|
||||
|
|
|
@ -169,6 +169,8 @@ sources = [
|
|||
'game/matrix.c',
|
||||
'game/music.c',
|
||||
'game/objects/common.c',
|
||||
'game/objects/creatures/bear.c',
|
||||
'game/objects/creatures/wolf.c',
|
||||
'game/objects/general/bridge_common.c',
|
||||
'game/objects/general/bridge_flat.c',
|
||||
'game/objects/general/bridge_tilt1.c',
|
||||
|
@ -176,8 +178,6 @@ sources = [
|
|||
'game/objects/general/drawbridge.c',
|
||||
'game/objects/general/trapdoor.c',
|
||||
'game/objects/names.c',
|
||||
'game/objects/creatures/bear.c',
|
||||
'game/objects/creatures/wolf.c',
|
||||
'game/objects/traps/movable_block.c',
|
||||
'game/objects/vars.c',
|
||||
'game/output/common.c',
|
||||
|
@ -197,6 +197,7 @@ sources = [
|
|||
'game/rooms/common.c',
|
||||
'game/rooms/draw.c',
|
||||
'game/savegame/common.c',
|
||||
'game/scaler.c',
|
||||
'game/shell/common.c',
|
||||
'game/shell/main.c',
|
||||
'game/sound.c',
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#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"
|
||||
|
@ -16,6 +15,7 @@
|
|||
#include <libtrx/debug.h>
|
||||
#include <libtrx/game/math.h>
|
||||
#include <libtrx/game/matrix.h>
|
||||
#include <libtrx/game/scaler.h>
|
||||
#include <libtrx/log.h>
|
||||
#include <libtrx/memory.h>
|
||||
#include <libtrx/utils.h>
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
#include "game/objects/vars.h"
|
||||
#include "game/output.h"
|
||||
#include "game/savegame.h"
|
||||
#include "game/scaler.h"
|
||||
#include "game/text.h"
|
||||
#include "game/viewport.h"
|
||||
#include "global/vars.h"
|
||||
|
||||
#include <libtrx/config.h>
|
||||
#include <libtrx/game/matrix.h>
|
||||
#include <libtrx/game/scaler.h>
|
||||
#include <libtrx/utils.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
#include "decomp/decomp.h"
|
||||
#include "game/clock.h"
|
||||
#include "game/output.h"
|
||||
#include "game/scaler.h"
|
||||
#include "global/vars.h"
|
||||
|
||||
#include <libtrx/game/scaler.h>
|
||||
#include <libtrx/utils.h>
|
||||
|
||||
static int32_t M_Scale(const int32_t value);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "game/scaler.h"
|
||||
#include "global/vars.h"
|
||||
|
||||
#include <libtrx/config.h>
|
||||
#include <libtrx/game/scaler.h>
|
||||
#include <libtrx/game/ui/common.h>
|
||||
|
||||
int32_t UI_GetCanvasWidth(void)
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
#include "game/ui/dialogs/graphic_settings.h"
|
||||
|
||||
#include "game/scaler.h"
|
||||
|
||||
#include <libtrx/config.h>
|
||||
#include <libtrx/debug.h>
|
||||
#include <libtrx/game/game_string.h>
|
||||
#include <libtrx/game/input.h>
|
||||
#include <libtrx/game/scaler.h>
|
||||
#include <libtrx/game/ui/elements/anchor.h>
|
||||
#include <libtrx/game/ui/elements/hide.h>
|
||||
#include <libtrx/game/ui/elements/label.h>
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include "game/ui/dialogs/save_slot.h"
|
||||
|
||||
#include "game/inventory_ring/vars.h"
|
||||
#include "game/scaler.h"
|
||||
#include "global/vars.h"
|
||||
|
||||
#include <libtrx/game/game_string.h>
|
||||
#include <libtrx/game/input.h>
|
||||
#include <libtrx/game/savegame.h>
|
||||
#include <libtrx/game/scaler.h>
|
||||
#include <libtrx/game/ui/common.h>
|
||||
#include <libtrx/game/ui/elements/anchor.h>
|
||||
#include <libtrx/game/ui/elements/hide.h>
|
||||
|
|
|
@ -203,6 +203,16 @@ void Viewport_AlterFOV(const int16_t view_angle)
|
|||
M_ApplyGameVars(&m_Viewport);
|
||||
}
|
||||
|
||||
int32_t Viewport_GetWidth(void)
|
||||
{
|
||||
return g_PhdWinWidth;
|
||||
}
|
||||
|
||||
int32_t Viewport_GetHeight(void)
|
||||
{
|
||||
return g_PhdWinHeight;
|
||||
}
|
||||
|
||||
int32_t Viewport_GetMaxX(void)
|
||||
{
|
||||
return g_PhdWinMaxX;
|
||||
|
|
|
@ -262,7 +262,6 @@ sources = [
|
|||
'game/savegame/common.c',
|
||||
'game/savegame/savegame_bson.c',
|
||||
'game/savegame/savegame_legacy.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