Skip to content

Commit

Permalink
Make config option apply to all scenarios
Browse files Browse the repository at this point in the history
This will allow players to disable the skybox in custom levels.
  • Loading branch information
lahm86 committed Jul 19, 2024
1 parent cd2bd6d commit d4fd163
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/game/level.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "game/level.h"

#include "config.h"
#include "game/camera.h"
#include "game/carrier.h"
#include "game/effects.h"
Expand Down Expand Up @@ -1007,6 +1008,9 @@ bool Level_Load(int level_num)
: g_GameFlow.draw_distance_max)
* WALL_L);

Output_SetSkyboxEnabled(
g_Config.enable_skybox && g_Objects[O_SKYBOX].loaded);

return ret;
}

Expand Down
13 changes: 12 additions & 1 deletion src/game/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef struct {
} edges[2];
} LIGHTNING;

static bool m_IsSkyboxEnabled = false;
static bool m_IsWibbleEffect = false;
static bool m_IsWaterEffect = false;
static bool m_IsShadeEffect = false;
Expand Down Expand Up @@ -346,7 +347,7 @@ static const int16_t *Output_CalcRoomVertices(const int16_t *obj_ptr)
int32_t depth = zv_int >> W2V_SHIFT;
if (depth > Output_GetDrawDistMax()) {
m_VBuf[i].g = 0x1FFF;
if (!g_Objects[O_SKYBOX].loaded) {
if (!m_IsSkyboxEnabled) {
clip_flags |= 16;
}
} else if (depth) {
Expand Down Expand Up @@ -622,6 +623,16 @@ void Output_DrawPolygons_I(const int16_t *obj_ptr, int32_t clip)
Matrix_Pop();
}

void Output_SetSkyboxEnabled(const bool enabled)
{
m_IsSkyboxEnabled = enabled;
}

bool Output_IsSkyboxEnabled(void)
{
return m_IsSkyboxEnabled;
}

void Output_DrawSkybox(const int16_t *obj_ptr)
{
g_PhdLeft = Viewport_GetMinX();
Expand Down
3 changes: 3 additions & 0 deletions src/game/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ void Output_CalculateObjectLighting(
void Output_DrawPolygons(const int16_t *obj_ptr, int clip);
void Output_DrawPolygons_I(const int16_t *obj_ptr, int32_t clip);

void Output_SetSkyboxEnabled(bool enabled);
bool Output_IsSkyboxEnabled(void);
void Output_DrawSkybox(const int16_t *obj_ptr);

void Output_DrawRoom(const int16_t *obj_ptr);
void Output_DrawShadow(
int16_t size, const BOUNDS_16 *bounds, const ITEM_INFO *item);
Expand Down
4 changes: 2 additions & 2 deletions src/game/room_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ static void Room_PrepareToDraw(int16_t room_num)

static void Room_DrawSkybox(void)
{
const OBJECT_INFO skybox = g_Objects[O_SKYBOX];
if (!skybox.loaded) {
if (!Output_IsSkyboxEnabled()) {
return;
}

Expand All @@ -263,6 +262,7 @@ static void Room_DrawSkybox(void)
g_MatrixPtr->_13 = 0;
g_MatrixPtr->_23 = 0;

const OBJECT_INFO skybox = g_Objects[O_SKYBOX];
const FRAME_INFO *const frame = g_Anims[skybox.anim_index].frame_ptr;
Matrix_RotYXZpack(frame->mesh_rots[0]);
Output_DrawSkybox(g_Meshes[skybox.mesh_index]);
Expand Down
2 changes: 1 addition & 1 deletion tools/config/TR1X_ConfigTool/Resources/Lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
},
"enable_skybox": {
"Title": "Skybox",
"Description": "Enables a default skybox in Lost Valley and Colosseum."
"Description": "Enables the skybox in supported levels."
},
"enable_braid": {
"Title": "Braid",
Expand Down
2 changes: 1 addition & 1 deletion tools/config/TR1X_ConfigTool/Resources/Lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
},
"enable_skybox": {
"Title": "Cielo",
"Description": "Habilita un cielo predeterminado en Valle perdido y El Coliseo."
"Description": "Habilita el cielo en niveles soportados."
},
"enable_braid": {
"Title": "Trenza",
Expand Down
2 changes: 1 addition & 1 deletion tools/config/TR1X_ConfigTool/Resources/Lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
},
"enable_skybox": {
"Title": "Ciel",
"Description": "Active un ciel par défaut dans la Vallée perdue et le Colisée."
"Description": "Active le ciel dans les niveaux pris en charge."
},
"enable_braid": {
"Title": "Tresse de Lara",
Expand Down
2 changes: 1 addition & 1 deletion tools/config/TR1X_ConfigTool/Resources/Lang/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
},
"enable_skybox": {
"Title": "Cielo",
"Description": "Abilita un cielo predefinito nella Valle Perduta e nel Colosseo."
"Description": "Abilita il cielo nei livelli supportati."
},
"enable_braid": {
"Title": "Treccia",
Expand Down

0 comments on commit d4fd163

Please sign in to comment.