mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 12:47:58 +03:00
ui: improve modal sizing
Some checks are pending
Run code linters / Run code linters (push) Waiting to run
Publish a pre-release / TR1 (Linux) (push) Waiting to run
Publish a pre-release / TR1 (Windows) (push) Waiting to run
Publish a pre-release / TR1 (Mac) (push) Waiting to run
Publish a pre-release / TR2 (Linux) (push) Waiting to run
Publish a pre-release / TR2 (Windows) (push) Waiting to run
Publish a pre-release / TR2 (Mac) (push) Waiting to run
Publish a pre-release / Create a prerelease (push) Blocked by required conditions
Some checks are pending
Run code linters / Run code linters (push) Waiting to run
Publish a pre-release / TR1 (Linux) (push) Waiting to run
Publish a pre-release / TR1 (Windows) (push) Waiting to run
Publish a pre-release / TR1 (Mac) (push) Waiting to run
Publish a pre-release / TR2 (Linux) (push) Waiting to run
Publish a pre-release / TR2 (Windows) (push) Waiting to run
Publish a pre-release / TR2 (Mac) (push) Waiting to run
Publish a pre-release / Create a prerelease (push) Blocked by required conditions
This commit is contained in:
parent
a859d668f9
commit
6d5bdd89a3
8 changed files with 28 additions and 57 deletions
|
@ -4,8 +4,10 @@
|
|||
#include "debug.h"
|
||||
#include "game/console/common.h"
|
||||
#include "game/game_string.h"
|
||||
#include "game/scaler.h"
|
||||
#include "game/ui/elements/anchor.h"
|
||||
#include "game/ui/events.h"
|
||||
#include "game/viewport.h"
|
||||
#include "memory.h"
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
@ -201,3 +203,23 @@ void UI_HandleTextEdit(const char *const text)
|
|||
UI_FireEvent((EVENT) {
|
||||
.name = "text_edit", .sender = nullptr, .data = (void *)text });
|
||||
}
|
||||
|
||||
int32_t UI_GetCanvasWidth(void)
|
||||
{
|
||||
return Scaler_CalcInverse(Viewport_GetWidth(), SCALER_TARGET_GENERIC);
|
||||
}
|
||||
|
||||
int32_t UI_GetCanvasHeight(void)
|
||||
{
|
||||
return Scaler_CalcInverse(Viewport_GetHeight(), SCALER_TARGET_GENERIC);
|
||||
}
|
||||
|
||||
float UI_ScaleX(const float x)
|
||||
{
|
||||
return Scaler_Calc(x, SCALER_TARGET_GENERIC);
|
||||
}
|
||||
|
||||
float UI_ScaleY(const float y)
|
||||
{
|
||||
return Scaler_Calc(y, SCALER_TARGET_GENERIC);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ void UI_PhotoMode(void)
|
|||
char tmp[50];
|
||||
|
||||
UI_BeginModal(0.0f, 0.0f);
|
||||
UI_BeginPad(8.0f, 10.0f);
|
||||
UI_BeginPad(8.0f, 8.0f);
|
||||
UI_BeginFrame(UI_FRAME_DIALOG_BACKGROUND);
|
||||
UI_BeginPad(8.0, 6.0);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ static const UI_WIDGET_OPS m_Ops = {
|
|||
static void M_Measure(UI_NODE *const node)
|
||||
{
|
||||
node->measure_w = UI_GetCanvasWidth();
|
||||
node->measure_h = UI_GetCanvasHeight() - TEXT_HEIGHT_FIXED;
|
||||
node->measure_h = UI_GetCanvasHeight();
|
||||
}
|
||||
|
||||
void UI_BeginModal(const float x, const float y)
|
||||
|
|
|
@ -50,10 +50,10 @@ typedef struct UI_NODE {
|
|||
|
||||
// Dimensions in virtual pixels of the screen area
|
||||
// (640x480 for any 4:3 resolution on 1.00 text scaling)
|
||||
extern int32_t UI_GetCanvasWidth(void);
|
||||
extern int32_t UI_GetCanvasHeight(void);
|
||||
extern float UI_ScaleX(float x);
|
||||
extern float UI_ScaleY(float y);
|
||||
int32_t UI_GetCanvasWidth(void);
|
||||
int32_t UI_GetCanvasHeight(void);
|
||||
float UI_ScaleX(float x);
|
||||
float UI_ScaleY(float y);
|
||||
|
||||
// Public API for scene management
|
||||
void UI_BeginScene(void);
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
#include "game/screen.h"
|
||||
|
||||
#include <libtrx/config.h>
|
||||
#include <libtrx/game/ui/common.h>
|
||||
|
||||
int32_t UI_GetCanvasWidth(void)
|
||||
{
|
||||
return Screen_GetResHeightDownscaled(RSR_GENERIC) * 16 / 9;
|
||||
}
|
||||
|
||||
int32_t UI_GetCanvasHeight(void)
|
||||
{
|
||||
return Screen_GetResHeightDownscaled(RSR_GENERIC);
|
||||
}
|
||||
|
||||
float UI_ScaleX(const float x)
|
||||
{
|
||||
return Screen_GetRenderScale(x * 0x10000, RSR_GENERIC) / (float)0x10000;
|
||||
}
|
||||
|
||||
float UI_ScaleY(const float y)
|
||||
{
|
||||
return Screen_GetRenderScale(y * 0x10000, RSR_GENERIC) / (float)0x10000;
|
||||
}
|
|
@ -260,7 +260,6 @@ sources = [
|
|||
'game/spawn.c',
|
||||
'game/stats/common.c',
|
||||
'game/text.c',
|
||||
'game/ui/common.c',
|
||||
'game/ui/dialogs/stats.c',
|
||||
'game/viewport.c',
|
||||
'global/enum_map.c',
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
#include "global/vars.h"
|
||||
|
||||
#include <libtrx/config.h>
|
||||
#include <libtrx/game/scaler.h>
|
||||
#include <libtrx/game/ui/common.h>
|
||||
|
||||
int32_t UI_GetCanvasWidth(void)
|
||||
{
|
||||
return Scaler_CalcInverse(g_PhdWinWidth, SCALER_TARGET_GENERIC);
|
||||
}
|
||||
|
||||
int32_t UI_GetCanvasHeight(void)
|
||||
{
|
||||
return Scaler_CalcInverse(g_PhdWinHeight, SCALER_TARGET_GENERIC);
|
||||
}
|
||||
|
||||
float UI_ScaleX(const float x)
|
||||
{
|
||||
return Scaler_Calc(x, SCALER_TARGET_GENERIC);
|
||||
}
|
||||
|
||||
float UI_ScaleY(const float y)
|
||||
{
|
||||
return Scaler_Calc(y, SCALER_TARGET_GENERIC);
|
||||
}
|
|
@ -266,7 +266,6 @@ sources = [
|
|||
'game/spawn.c',
|
||||
'game/stats.c',
|
||||
'game/text.c',
|
||||
'game/ui/common.c',
|
||||
'game/ui/dialogs/graphic_settings.c',
|
||||
'game/ui/dialogs/stats.c',
|
||||
'game/viewport.c',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue