mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 20:58:07 +03:00
ui: move select level dialog to libtrx
This commit is contained in:
parent
7f574c9448
commit
f23a777f64
12 changed files with 59 additions and 33 deletions
|
@ -625,6 +625,8 @@
|
||||||
"PASSPORT_EXIT_DEMO": "Exit Demo",
|
"PASSPORT_EXIT_DEMO": "Exit Demo",
|
||||||
"PASSPORT_EXIT_GAME": "Exit Game",
|
"PASSPORT_EXIT_GAME": "Exit Game",
|
||||||
"PASSPORT_EXIT_TO_TITLE": "Exit to Title",
|
"PASSPORT_EXIT_TO_TITLE": "Exit to Title",
|
||||||
|
"PASSPORT_LEGACY_SELECT_LEVEL_1": "Legacy saves do not",
|
||||||
|
"PASSPORT_LEGACY_SELECT_LEVEL_2": "support this feature.",
|
||||||
"PASSPORT_LOAD_GAME": "Load Game",
|
"PASSPORT_LOAD_GAME": "Load Game",
|
||||||
"PASSPORT_MODE_NEW_GAME": "New Game",
|
"PASSPORT_MODE_NEW_GAME": "New Game",
|
||||||
"PASSPORT_MODE_NEW_GAME_JP": "Japanese NG",
|
"PASSPORT_MODE_NEW_GAME_JP": "Japanese NG",
|
||||||
|
@ -634,6 +636,7 @@
|
||||||
"PASSPORT_SAVE_GAME": "Save Game",
|
"PASSPORT_SAVE_GAME": "Save Game",
|
||||||
"PASSPORT_SELECT_LEVEL": "Select Level",
|
"PASSPORT_SELECT_LEVEL": "Select Level",
|
||||||
"PASSPORT_SELECT_MODE": "Select Mode",
|
"PASSPORT_SELECT_MODE": "Select Mode",
|
||||||
|
"PASSPORT_STORY_SO_FAR": "Story so far...",
|
||||||
"PAUSE_ARE_YOU_SURE": "Are you sure?",
|
"PAUSE_ARE_YOU_SURE": "Are you sure?",
|
||||||
"PAUSE_CONTINUE": "Continue",
|
"PAUSE_CONTINUE": "Continue",
|
||||||
"PAUSE_EXIT_TO_TITLE": "Exit to title?",
|
"PAUSE_EXIT_TO_TITLE": "Exit to title?",
|
||||||
|
|
|
@ -1,24 +1,30 @@
|
||||||
#include "game/ui/dialogs/select_level.h"
|
#include "game/ui/dialogs/select_level.h"
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
#include "game/game_flow.h"
|
#include "game/game_flow.h"
|
||||||
#include "game/game_string.h"
|
#include "game/game_string.h"
|
||||||
#include "game/savegame.h"
|
#include "game/savegame.h"
|
||||||
#include "game/screen.h"
|
#include "game/scaler.h"
|
||||||
#include "global/vars.h"
|
#include "game/ui/common.h"
|
||||||
|
#include "game/ui/elements/anchor.h"
|
||||||
|
#include "game/ui/elements/hide.h"
|
||||||
|
#include "game/ui/elements/label.h"
|
||||||
|
#include "game/ui/elements/modal.h"
|
||||||
|
#include "game/ui/elements/offset.h"
|
||||||
|
#include "game/ui/elements/requester.h"
|
||||||
|
#include "game/ui/elements/resize.h"
|
||||||
|
#include "game/ui/elements/spacer.h"
|
||||||
|
#include "game/ui/elements/stack.h"
|
||||||
|
#include "game/viewport.h"
|
||||||
|
#include "memory.h"
|
||||||
|
#include "vector.h"
|
||||||
|
|
||||||
#include <libtrx/debug.h>
|
// TODO: consolidate this variable
|
||||||
#include <libtrx/game/ui/common.h>
|
#if TR_VERSION == 1
|
||||||
#include <libtrx/game/ui/elements/anchor.h>
|
extern int32_t g_InvMode;
|
||||||
#include <libtrx/game/ui/elements/hide.h>
|
#else
|
||||||
#include <libtrx/game/ui/elements/label.h>
|
extern int32_t g_Inv_Mode;
|
||||||
#include <libtrx/game/ui/elements/modal.h>
|
#endif
|
||||||
#include <libtrx/game/ui/elements/offset.h>
|
|
||||||
#include <libtrx/game/ui/elements/requester.h>
|
|
||||||
#include <libtrx/game/ui/elements/resize.h>
|
|
||||||
#include <libtrx/game/ui/elements/spacer.h>
|
|
||||||
#include <libtrx/game/ui/elements/stack.h>
|
|
||||||
#include <libtrx/memory.h>
|
|
||||||
#include <libtrx/vector.h>
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
M_ROW_ROLE_PLAY_LEVEL,
|
M_ROW_ROLE_PLAY_LEVEL,
|
||||||
|
@ -41,15 +47,20 @@ static int32_t M_GetVisibleRows(void);
|
||||||
|
|
||||||
static int32_t M_GetVisibleRows(void)
|
static int32_t M_GetVisibleRows(void)
|
||||||
{
|
{
|
||||||
const int32_t res_h = Screen_GetResHeightDownscaled(RSR_TEXT);
|
if (TR_VERSION == 2) {
|
||||||
if (res_h <= 240) {
|
|
||||||
return 5;
|
|
||||||
} else if (res_h <= 384) {
|
|
||||||
return 7;
|
|
||||||
} else if (res_h <= 480) {
|
|
||||||
return 10;
|
return 10;
|
||||||
} else {
|
} else {
|
||||||
return 12;
|
const int32_t res_h =
|
||||||
|
Scaler_CalcInverse(Viewport_GetHeight(), SCALER_TARGET_TEXT);
|
||||||
|
if (res_h <= 240) {
|
||||||
|
return 5;
|
||||||
|
} else if (res_h <= 384) {
|
||||||
|
return 7;
|
||||||
|
} else if (res_h <= 480) {
|
||||||
|
return 10;
|
||||||
|
} else {
|
||||||
|
return 12;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +91,12 @@ UI_SELECT_LEVEL_DIALOG_STATE *UI_SelectLevelDialog_Init(const int32_t save_slot)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_InvMode == INV_TITLE_MODE && GF_HasAvailableStory(save_slot)) {
|
#if TR_VERSION == 1
|
||||||
|
const INVENTORY_MODE inv_mode = g_InvMode;
|
||||||
|
#else
|
||||||
|
const INVENTORY_MODE inv_mode = g_Inv_Mode;
|
||||||
|
#endif
|
||||||
|
if (inv_mode == INV_TITLE_MODE && GF_HasAvailableStory(save_slot)) {
|
||||||
Vector_Add(
|
Vector_Add(
|
||||||
s->rows,
|
s->rows,
|
||||||
&(M_ROW) {
|
&(M_ROW) {
|
||||||
|
@ -120,7 +136,12 @@ int32_t UI_SelectLevelDialog_Control(UI_SELECT_LEVEL_DIALOG_STATE *const s)
|
||||||
|
|
||||||
void UI_SelectLevelDialog(UI_SELECT_LEVEL_DIALOG_STATE *const s)
|
void UI_SelectLevelDialog(UI_SELECT_LEVEL_DIALOG_STATE *const s)
|
||||||
{
|
{
|
||||||
UI_BeginModal(0.5f, g_InvMode == INV_TITLE_MODE ? 0.72f : 0.55f);
|
#if TR_VERSION == 1
|
||||||
|
const float modal_y = g_InvMode == INV_TITLE_MODE ? 0.72f : 0.55f;
|
||||||
|
#else
|
||||||
|
const float modal_y = g_Inv_Mode == INV_TITLE_MODE ? 0.8f : 0.65f;
|
||||||
|
#endif
|
||||||
|
UI_BeginModal(0.5f, modal_y);
|
||||||
UI_BeginResize(300.0f, -1.0f);
|
UI_BeginResize(300.0f, -1.0f);
|
||||||
UI_BeginRequester(&s->req, GS(PASSPORT_SELECT_LEVEL));
|
UI_BeginRequester(&s->req, GS(PASSPORT_SELECT_LEVEL));
|
||||||
|
|
|
@ -129,6 +129,9 @@ GS_DEFINE(PASSPORT_MODE_NEW_GAME, "New Game")
|
||||||
GS_DEFINE(PASSPORT_MODE_NEW_GAME_PLUS, "New Game+")
|
GS_DEFINE(PASSPORT_MODE_NEW_GAME_PLUS, "New Game+")
|
||||||
GS_DEFINE(PASSPORT_MODE_NEW_GAME_JP, "Japanese NG")
|
GS_DEFINE(PASSPORT_MODE_NEW_GAME_JP, "Japanese NG")
|
||||||
GS_DEFINE(PASSPORT_MODE_NEW_GAME_JP_PLUS, "Japanese NG+")
|
GS_DEFINE(PASSPORT_MODE_NEW_GAME_JP_PLUS, "Japanese NG+")
|
||||||
|
GS_DEFINE(PASSPORT_STORY_SO_FAR, "Story so far...")
|
||||||
|
GS_DEFINE(PASSPORT_LEGACY_SELECT_LEVEL_1, "Legacy saves do not")
|
||||||
|
GS_DEFINE(PASSPORT_LEGACY_SELECT_LEVEL_2, "support this feature.")
|
||||||
GS_DEFINE(SOUND_SET_VOLUMES, "Set Volumes")
|
GS_DEFINE(SOUND_SET_VOLUMES, "Set Volumes")
|
||||||
GS_DEFINE(OSD_TRAPEZOID_FILTER_ON, "Trapezoid filter enabled")
|
GS_DEFINE(OSD_TRAPEZOID_FILTER_ON, "Trapezoid filter enabled")
|
||||||
GS_DEFINE(OSD_TRAPEZOID_FILTER_OFF, "Trapezoid filter disabled")
|
GS_DEFINE(OSD_TRAPEZOID_FILTER_OFF, "Trapezoid filter disabled")
|
||||||
|
|
|
@ -54,12 +54,10 @@ typedef struct {
|
||||||
int32_t level_num;
|
int32_t level_num;
|
||||||
char *level_title;
|
char *level_title;
|
||||||
int16_t initial_version;
|
int16_t initial_version;
|
||||||
#if TR_VERSION == 1
|
|
||||||
struct {
|
struct {
|
||||||
bool restart;
|
bool restart;
|
||||||
bool select_level;
|
bool select_level;
|
||||||
} features;
|
} features;
|
||||||
#endif
|
|
||||||
} SAVEGAME_INFO;
|
} SAVEGAME_INFO;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "./ui/dialogs/pause.h"
|
#include "./ui/dialogs/pause.h"
|
||||||
#include "./ui/dialogs/photo_mode.h"
|
#include "./ui/dialogs/photo_mode.h"
|
||||||
#include "./ui/dialogs/save_slot.h"
|
#include "./ui/dialogs/save_slot.h"
|
||||||
|
#include "./ui/dialogs/select_level.h"
|
||||||
#include "./ui/dialogs/stats.h"
|
#include "./ui/dialogs/stats.h"
|
||||||
#include "./ui/elements/anchor.h"
|
#include "./ui/elements/anchor.h"
|
||||||
#include "./ui/elements/fade.h"
|
#include "./ui/elements/fade.h"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <libtrx/game/ui/common.h>
|
#include "../common.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
|
@ -211,6 +211,7 @@ sources = [
|
||||||
'game/ui/dialogs/pause.c',
|
'game/ui/dialogs/pause.c',
|
||||||
'game/ui/dialogs/photo_mode.c',
|
'game/ui/dialogs/photo_mode.c',
|
||||||
'game/ui/dialogs/save_slot.c',
|
'game/ui/dialogs/save_slot.c',
|
||||||
|
'game/ui/dialogs/select_level.c',
|
||||||
'game/ui/dialogs/stats.c',
|
'game/ui/dialogs/stats.c',
|
||||||
'game/ui/elements/anchor.c',
|
'game/ui/elements/anchor.c',
|
||||||
'game/ui/elements/fade.c',
|
'game/ui/elements/fade.c',
|
||||||
|
@ -241,8 +242,8 @@ sources = [
|
||||||
'gfx/gl/buffer.c',
|
'gfx/gl/buffer.c',
|
||||||
'gfx/gl/program.c',
|
'gfx/gl/program.c',
|
||||||
'gfx/gl/sampler.c',
|
'gfx/gl/sampler.c',
|
||||||
'gfx/gl/track.c',
|
|
||||||
'gfx/gl/texture.c',
|
'gfx/gl/texture.c',
|
||||||
|
'gfx/gl/track.c',
|
||||||
'gfx/gl/utils.c',
|
'gfx/gl/utils.c',
|
||||||
'gfx/gl/vertex_array.c',
|
'gfx/gl/vertex_array.c',
|
||||||
'gfx/renderers/fbo_renderer.c',
|
'gfx/renderers/fbo_renderer.c',
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
GS_DEFINE(PASSPORT_RESTART_LEVEL, "Restart Level")
|
GS_DEFINE(PASSPORT_RESTART_LEVEL, "Restart Level")
|
||||||
GS_DEFINE(PASSPORT_STORY_SO_FAR, "Story so far...")
|
|
||||||
GS_DEFINE(PASSPORT_LEGACY_SELECT_LEVEL_1, "Legacy saves do not")
|
|
||||||
GS_DEFINE(PASSPORT_LEGACY_SELECT_LEVEL_2, "support this feature.")
|
|
||||||
GS_DEFINE(DETAIL_REFLECTIONS, "Reflections")
|
GS_DEFINE(DETAIL_REFLECTIONS, "Reflections")
|
||||||
GS_DEFINE(DETAIL_FBO_FILTER, "FBO filter")
|
GS_DEFINE(DETAIL_FBO_FILTER, "FBO filter")
|
||||||
GS_DEFINE(DETAIL_VSYNC, "VSync")
|
GS_DEFINE(DETAIL_VSYNC, "VSync")
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include "game/screen.h"
|
#include "game/screen.h"
|
||||||
#include "game/sound.h"
|
#include "game/sound.h"
|
||||||
#include "game/text.h"
|
#include "game/text.h"
|
||||||
#include "game/ui/dialogs/select_level.h"
|
|
||||||
#include "global/const.h"
|
#include "global/const.h"
|
||||||
#include "global/vars.h"
|
#include "global/vars.h"
|
||||||
|
|
||||||
|
|
|
@ -262,7 +262,6 @@ sources = [
|
||||||
'game/stats/common.c',
|
'game/stats/common.c',
|
||||||
'game/text.c',
|
'game/text.c',
|
||||||
'game/ui/common.c',
|
'game/ui/common.c',
|
||||||
'game/ui/dialogs/select_level.c',
|
|
||||||
'game/ui/dialogs/stats.c',
|
'game/ui/dialogs/stats.c',
|
||||||
'game/viewport.c',
|
'game/viewport.c',
|
||||||
'global/enum_map.c',
|
'global/enum_map.c',
|
||||||
|
|
|
@ -102,6 +102,8 @@ static bool M_FillInfo(MYFILE *const fp, SAVEGAME_INFO *const info)
|
||||||
File_Seek(fp, 0, FILE_SEEK_SET);
|
File_Seek(fp, 0, FILE_SEEK_SET);
|
||||||
File_ReadData(fp, &header, sizeof(SAVEGAME_BSON_HEADER));
|
File_ReadData(fp, &header, sizeof(SAVEGAME_BSON_HEADER));
|
||||||
info->initial_version = header.initial_version;
|
info->initial_version = header.initial_version;
|
||||||
|
info->features.restart = false;
|
||||||
|
info->features.select_level = false;
|
||||||
|
|
||||||
File_Skip(fp, header.compressed_size);
|
File_Skip(fp, header.compressed_size);
|
||||||
SAVEGAME_BSON_EXTENDED_HEADER extra_header;
|
SAVEGAME_BSON_EXTENDED_HEADER extra_header;
|
||||||
|
|
|
@ -717,6 +717,8 @@ static bool M_FillInfo(MYFILE *const fp, SAVEGAME_INFO *const savegame_info)
|
||||||
|
|
||||||
savegame_info->level_num = File_ReadS16(fp);
|
savegame_info->level_num = File_ReadS16(fp);
|
||||||
savegame_info->initial_version = VERSION_LEGACY;
|
savegame_info->initial_version = VERSION_LEGACY;
|
||||||
|
savegame_info->features.restart = false;
|
||||||
|
savegame_info->features.select_level = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue