From 751dfe61c7277b23ae7c68ade90d0122888de77e Mon Sep 17 00:00:00 2001
From: Agent X <44549182+Agent-11@users.noreply.github.com>
Date: Mon, 20 Mar 2023 22:36:25 -0400
Subject: [PATCH] Move everything over (#280)
---
autogen/convert_constants.py | 2 +
autogen/lua_definitions/constants.lua | 33 ++++++++
autogen/lua_definitions/functions.lua | 35 +++++++++
docs/lua/constants.md | 18 +++++
docs/lua/functions-3.md | 38 +++++++++
docs/lua/functions-4.md | 79 +++++++++++++++++++
docs/lua/functions.md | 6 ++
src/game/area.c | 4 +
src/game/game_init.c | 6 +-
src/game/ingame_menu.c | 93 +++++++++++-----------
src/game/rendering_graph_node.c | 2 +
src/game/skybox.c | 6 ++
src/game/skybox.h | 3 +
src/pc/djui/djui.c | 4 +
src/pc/djui/djui.h | 1 +
src/pc/djui/djui_hud_utils.c | 10 ++-
src/pc/djui/djui_hud_utils.h | 4 +
src/pc/djui/djui_panel_pause.c | 2 +-
src/pc/gfx/gfx_pc.c | 7 ++
src/pc/gfx/gfx_pc.h | 4 +
src/pc/lua/smlua_constants_autogen.c | 11 +++
src/pc/lua/smlua_functions_autogen.c | 106 ++++++++++++++++++++++++++
src/pc/lua/utils/smlua_misc_utils.c | 25 ++++++
src/pc/lua/utils/smlua_misc_utils.h | 6 ++
src/pc/network/network.c | 7 ++
25 files changed, 465 insertions(+), 47 deletions(-)
diff --git a/autogen/convert_constants.py b/autogen/convert_constants.py
index b4e6e542..c0189ec8 100644
--- a/autogen/convert_constants.py
+++ b/autogen/convert_constants.py
@@ -39,6 +39,7 @@ in_files = [
"include/surface_terrains.h",
"src/game/level_update.h",
"src/pc/network/version.h",
+ "include/geo_commands.h",
"include/level_commands.h",
"src/audio/external.h"
]
@@ -49,6 +50,7 @@ exclude_constants = {
}
include_constants = {
+ 'include/geo_commands.h': ['BACKGROUND'],
'include/level_commands.h': [ "WARP_CHECKPOINT", "WARP_NO_CHECKPOINT" ],
'src/audio/external.h': [ "SEQ_PLAYER" ]
}
diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua
index 890c4608..cfb9b076 100644
--- a/autogen/lua_definitions/constants.lua
+++ b/autogen/lua_definitions/constants.lua
@@ -3272,6 +3272,39 @@ SEQ_PLAYER_LEVEL = 0
--- @type integer
SEQ_PLAYER_SFX = 2
+--- @type integer
+BACKGROUND_ABOVE_CLOUDS = 8
+
+--- @type integer
+BACKGROUND_BELOW_CLOUDS = 3
+
+--- @type integer
+BACKGROUND_CUSTOM = 10
+
+--- @type integer
+BACKGROUND_DESERT = 5
+
+--- @type integer
+BACKGROUND_FLAMING_SKY = 1
+
+--- @type integer
+BACKGROUND_GREEN_SKY = 7
+
+--- @type integer
+BACKGROUND_HAUNTED = 6
+
+--- @type integer
+BACKGROUND_OCEAN_SKY = 0
+
+--- @type integer
+BACKGROUND_PURPLE_SKY = 9
+
+--- @type integer
+BACKGROUND_SNOW_MOUNTAINS = 4
+
+--- @type integer
+BACKGROUND_UNDERWATER_CITY = 2
+
--- @type integer
GEO_CONTEXT_AREA_INIT = 4
diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua
index c0f86634..fd1bfb0e 100644
--- a/autogen/lua_definitions/functions.lua
+++ b/autogen/lua_definitions/functions.lua
@@ -3643,6 +3643,11 @@ function djui_hud_get_screen_width()
-- ...
end
+--- @return boolean
+function djui_hud_is_pause_menu_created()
+ -- ...
+end
+
--- @param message string
--- @return number
function djui_hud_measure_text(message)
@@ -3701,6 +3706,12 @@ function djui_hud_set_mouse_locked(locked)
-- ...
end
+--- @param enable boolean
+--- @return nil
+function djui_hud_set_render_behind_hud(enable)
+ -- ...
+end
+
--- @param resolutionType HudUtilsResolution
--- @return nil
function djui_hud_set_resolution(resolutionType)
@@ -8317,11 +8328,22 @@ function get_last_star_or_key()
-- ...
end
+--- @param index integer
+--- @return number
+function get_lighting_dir(index)
+ -- ...
+end
+
--- @return integer
function get_network_area_timer()
-- ...
end
+--- @return integer
+function get_skybox()
+ -- ...
+end
+
--- @param initialValue integer
--- @return Pointer_integer
function get_temp_s32_pointer(initialValue)
@@ -8424,6 +8446,13 @@ function set_last_star_or_key(value)
-- ...
end
+--- @param index integer
+--- @param value number
+--- @return nil
+function set_lighting_dir(index, value)
+ -- ...
+end
+
--- @param far number
--- @return nil
function set_override_far(far)
@@ -8442,6 +8471,12 @@ function set_override_near(near)
-- ...
end
+--- @param background integer
+--- @return nil
+function set_override_skybox(background)
+ -- ...
+end
+
--- @param speed integer
--- @return nil
function set_ttc_speed_setting(speed)
diff --git a/docs/lua/constants.md b/docs/lua/constants.md
index f7d068b1..2f23c003 100644
--- a/docs/lua/constants.md
+++ b/docs/lua/constants.md
@@ -15,6 +15,7 @@
- [enum DjuiFontType](#enum-DjuiFontType)
- [enum HudUtilsResolution](#enum-HudUtilsResolution)
- [external.h](#externalh)
+- [geo_commands.h](#geo_commandsh)
- [graph_node.h](#graph_nodeh)
- [interaction.c](#interactionc)
- [enum InteractionFlag](#enum-InteractionFlag)
@@ -1109,6 +1110,23 @@
+## [geo_commands.h](#geo_commands.h)
+- BACKGROUND_ABOVE_CLOUDS
+- BACKGROUND_BELOW_CLOUDS
+- BACKGROUND_CUSTOM
+- BACKGROUND_DESERT
+- BACKGROUND_FLAMING_SKY
+- BACKGROUND_GREEN_SKY
+- BACKGROUND_HAUNTED
+- BACKGROUND_OCEAN_SKY
+- BACKGROUND_PURPLE_SKY
+- BACKGROUND_SNOW_MOUNTAINS
+- BACKGROUND_UNDERWATER_CITY
+
+[:arrow_up_small:](#)
+
+
+
## [graph_node.h](#graph_node.h)
- GEO_CONTEXT_AREA_INIT
- GEO_CONTEXT_AREA_LOAD
diff --git a/docs/lua/functions-3.md b/docs/lua/functions-3.md
index 2a8ef038..7b86c458 100644
--- a/docs/lua/functions-3.md
+++ b/docs/lua/functions-3.md
@@ -2143,6 +2143,24 @@
+## [djui_hud_is_pause_menu_created](#djui_hud_is_pause_menu_created)
+
+### Lua Example
+`local booleanValue = djui_hud_is_pause_menu_created()`
+
+### Parameters
+- None
+
+### Returns
+- `boolean`
+
+### C Prototype
+`bool djui_hud_is_pause_menu_created(void);`
+
+[:arrow_up_small:](#)
+
+
+
## [djui_hud_measure_text](#djui_hud_measure_text)
### Lua Example
@@ -2299,6 +2317,26 @@
+## [djui_hud_set_render_behind_hud](#djui_hud_set_render_behind_hud)
+
+### Lua Example
+`djui_hud_set_render_behind_hud(enable)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| enable | `boolean` |
+
+### Returns
+- None
+
+### C Prototype
+`void djui_hud_set_render_behind_hud(bool enable);`
+
+[:arrow_up_small:](#)
+
+
+
## [djui_hud_set_resolution](#djui_hud_set_resolution)
### Lua Example
diff --git a/docs/lua/functions-4.md b/docs/lua/functions-4.md
index 30cb2603..544b597b 100644
--- a/docs/lua/functions-4.md
+++ b/docs/lua/functions-4.md
@@ -8297,6 +8297,26 @@
+## [get_lighting_dir](#get_lighting_dir)
+
+### Lua Example
+`local numberValue = get_lighting_dir(index)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| index | `integer` |
+
+### Returns
+- `number`
+
+### C Prototype
+`f32 get_lighting_dir(u8 index);`
+
+[:arrow_up_small:](#)
+
+
+
## [get_network_area_timer](#get_network_area_timer)
### Lua Example
@@ -8315,6 +8335,24 @@
+## [get_skybox](#get_skybox)
+
+### Lua Example
+`local integerValue = get_skybox()`
+
+### Parameters
+- None
+
+### Returns
+- `integer`
+
+### C Prototype
+`s8 get_skybox();`
+
+[:arrow_up_small:](#)
+
+
+
## [get_temp_s32_pointer](#get_temp_s32_pointer)
### Lua Example
@@ -8634,6 +8672,27 @@
+## [set_lighting_dir](#set_lighting_dir)
+
+### Lua Example
+`set_lighting_dir(index, value)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| index | `integer` |
+| value | `number` |
+
+### Returns
+- None
+
+### C Prototype
+`void set_lighting_dir(u8 index, f32 value);`
+
+[:arrow_up_small:](#)
+
+
+
## [set_override_far](#set_override_far)
### Lua Example
@@ -8694,6 +8753,26 @@
+## [set_override_skybox](#set_override_skybox)
+
+### Lua Example
+`set_override_skybox(background)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| background | `integer` |
+
+### Returns
+- None
+
+### C Prototype
+`void set_override_skybox(s8 background);`
+
+[:arrow_up_small:](#)
+
+
+
## [set_ttc_speed_setting](#set_ttc_speed_setting)
### Lua Example
diff --git a/docs/lua/functions.md b/docs/lua/functions.md
index a77a11eb..d1d7d0e4 100644
--- a/docs/lua/functions.md
+++ b/docs/lua/functions.md
@@ -721,6 +721,7 @@
- [djui_hud_get_raw_mouse_y](functions-3.md#djui_hud_get_raw_mouse_y)
- [djui_hud_get_screen_height](functions-3.md#djui_hud_get_screen_height)
- [djui_hud_get_screen_width](functions-3.md#djui_hud_get_screen_width)
+ - [djui_hud_is_pause_menu_created](functions-3.md#djui_hud_is_pause_menu_created)
- [djui_hud_measure_text](functions-3.md#djui_hud_measure_text)
- [djui_hud_print_text](functions-3.md#djui_hud_print_text)
- [djui_hud_render_rect](functions-3.md#djui_hud_render_rect)
@@ -728,6 +729,7 @@
- [djui_hud_set_color](functions-3.md#djui_hud_set_color)
- [djui_hud_set_font](functions-3.md#djui_hud_set_font)
- [djui_hud_set_mouse_locked](functions-3.md#djui_hud_set_mouse_locked)
+ - [djui_hud_set_render_behind_hud](functions-3.md#djui_hud_set_render_behind_hud)
- [djui_hud_set_resolution](functions-3.md#djui_hud_set_resolution)
- [djui_hud_world_pos_to_screen_pos](functions-3.md#djui_hud_world_pos_to_screen_pos)
@@ -1544,7 +1546,9 @@
- [get_hand_foot_pos_y](functions-4.md#get_hand_foot_pos_y)
- [get_hand_foot_pos_z](functions-4.md#get_hand_foot_pos_z)
- [get_last_star_or_key](functions-4.md#get_last_star_or_key)
+ - [get_lighting_dir](functions-4.md#get_lighting_dir)
- [get_network_area_timer](functions-4.md#get_network_area_timer)
+ - [get_skybox](functions-4.md#get_skybox)
- [get_temp_s32_pointer](functions-4.md#get_temp_s32_pointer)
- [get_time](functions-4.md#get_time)
- [get_ttc_speed_setting](functions-4.md#get_ttc_speed_setting)
@@ -1561,9 +1565,11 @@
- [save_file_set_using_backup_slot](functions-4.md#save_file_set_using_backup_slot)
- [set_environment_region](functions-4.md#set_environment_region)
- [set_last_star_or_key](functions-4.md#set_last_star_or_key)
+ - [set_lighting_dir](functions-4.md#set_lighting_dir)
- [set_override_far](functions-4.md#set_override_far)
- [set_override_fov](functions-4.md#set_override_fov)
- [set_override_near](functions-4.md#set_override_near)
+ - [set_override_skybox](functions-4.md#set_override_skybox)
- [set_ttc_speed_setting](functions-4.md#set_ttc_speed_setting)
diff --git a/src/game/area.c b/src/game/area.c
index cff1a61a..d9f81443 100644
--- a/src/game/area.c
+++ b/src/game/area.c
@@ -25,6 +25,7 @@
#include "game/ingame_menu.h"
#include "pc/network/network.h"
#include "pc/lua/smlua_hooks.h"
+#include "pc/djui/djui.h"
struct SpawnInfo gPlayerSpawnInfos[MAX_PLAYERS];
struct GraphNode *D_8033A160[MAX_LOADED_GRAPH_NODES];
@@ -419,6 +420,9 @@ void render_game(void) {
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH,
SCREEN_HEIGHT - BORDER_HEIGHT);
+ if (gDjuiRenderBehindHud && !gDjuiPanelPauseCreated) {
+ djui_render();
+ }
render_hud();
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
diff --git a/src/game/game_init.c b/src/game/game_init.c
index 868e48e3..b229496d 100644
--- a/src/game/game_init.c
+++ b/src/game/game_init.c
@@ -256,8 +256,10 @@ void end_master_display_list(void) {
draw_profiler();
}
- extern void djui_render(void);
- djui_render();
+ if (!gDjuiRenderBehindHud || gDjuiPanelPauseCreated) {
+ extern void djui_render(void);
+ djui_render();
+ }
gDPFullSync(gDisplayListHead++);
gSPEndDisplayList(gDisplayListHead++);
diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c
index fd10efa1..3d6c769c 100644
--- a/src/game/ingame_menu.c
+++ b/src/game/ingame_menu.c
@@ -3063,62 +3063,69 @@ s16 render_pause_courses_and_castle(void) {
}
break;
case DIALOG_STATE_VERTICAL:
- shade_screen();
- render_pause_my_score_coins();
- render_pause_red_coins();
+ if (!gDjuiPanelPauseCreated) {
+ shade_screen();
+ render_pause_my_score_coins();
+ render_pause_red_coins();
- /* Always allow exiting from course */
- if (gLevelValues.pauseExitAnywhere || (gMarioStates[0].action & ACT_FLAG_PAUSE_EXIT)) {
- render_pause_course_options(99, 93, &gDialogLineNum, 15);
- }
-
-#ifdef VERSION_EU
- if (gPlayer1Controller->buttonPressed & (A_BUTTON | Z_TRIG | START_BUTTON))
-#else
- if (gPlayer1Controller->buttonPressed & A_BUTTON
- || gPlayer1Controller->buttonPressed & START_BUTTON)
-#endif
- {
- level_set_transition(0, NULL);
- play_sound(SOUND_MENU_PAUSE_2, gGlobalSoundSource);
- gDialogBoxState = DIALOG_STATE_OPENING;
- gMenuMode = -1;
-
- if (gDialogLineNum == 2 || gDialogLineNum == 3) {
- num = gDialogLineNum;
- } else {
- num = 1;
+ /* Always allow exiting from course */
+ if (gLevelValues.pauseExitAnywhere || (gMarioStates[0].action & ACT_FLAG_PAUSE_EXIT)) {
+ render_pause_course_options(99, 93, &gDialogLineNum, 15);
}
- return num;
+#ifdef VERSION_EU
+ if (gPlayer1Controller->buttonPressed & (A_BUTTON | Z_TRIG | START_BUTTON))
+#else
+ if (gPlayer1Controller->buttonPressed & A_BUTTON
+ || gPlayer1Controller->buttonPressed & START_BUTTON)
+#endif
+ {
+ level_set_transition(0, NULL);
+ play_sound(SOUND_MENU_PAUSE_2, gGlobalSoundSource);
+ gDialogBoxState = DIALOG_STATE_OPENING;
+ gMenuMode = -1;
+
+ if (gDialogLineNum == 2 || gDialogLineNum == 3) {
+ num = gDialogLineNum;
+ } else {
+ num = 1;
+ }
+
+ return num;
+ }
}
break;
case DIALOG_STATE_HORIZONTAL:
- shade_screen();
- print_hud_pause_colorful_str();
- if (gLevelValues.extendedPauseDisplay) {
- render_pause_castle_menu_box_extended(160, 143);
- render_pause_castle_main_strings_extended(84, 60);
- } else {
+ if (!gDjuiPanelPauseCreated) {
+ shade_screen();
+ print_hud_pause_colorful_str();
render_pause_castle_menu_box(160, 143);
render_pause_castle_main_strings(104, 60);
- }
+
+ if (gLevelValues.extendedPauseDisplay) {
+ render_pause_castle_menu_box_extended(160, 143);
+ render_pause_castle_main_strings_extended(84, 60);
+ } else {
+ render_pause_castle_menu_box(160, 143);
+ render_pause_castle_main_strings(104, 60);
+ }
#ifdef VERSION_EU
- if (gPlayer1Controller->buttonPressed & (A_BUTTON | Z_TRIG | START_BUTTON))
+ if (gPlayer1Controller->buttonPressed & (A_BUTTON | Z_TRIG | START_BUTTON))
#else
- if (gPlayer1Controller->buttonPressed & A_BUTTON
- || gPlayer1Controller->buttonPressed & START_BUTTON)
+ if (gPlayer1Controller->buttonPressed & A_BUTTON
+ || gPlayer1Controller->buttonPressed & START_BUTTON)
#endif
- {
- level_set_transition(0, NULL);
- play_sound(SOUND_MENU_PAUSE_2, gGlobalSoundSource);
- gMenuMode = -1;
- gDialogBoxState = DIALOG_STATE_OPENING;
+ {
+ level_set_transition(0, NULL);
+ play_sound(SOUND_MENU_PAUSE_2, gGlobalSoundSource);
+ gMenuMode = -1;
+ gDialogBoxState = DIALOG_STATE_OPENING;
- return 1;
- }
- break;
+ return 1;
+ }
+ }
+ break;
}
if (gDialogTextAlpha < 250) {
diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c
index e17a0e04..be9289dd 100644
--- a/src/game/rendering_graph_node.c
+++ b/src/game/rendering_graph_node.c
@@ -14,6 +14,7 @@
#include "pc/lua/smlua_hooks.h"
#include "pc/utils/misc.h"
#include "pc/debuglog.h"
+#include "game/skybox.h"
#include "include/course_table.h"
/**
@@ -825,6 +826,7 @@ static void geo_process_background(struct GraphNodeBackground *node) {
gDPPipeSync(gfx++);
gDPSetCycleType(gfx++, G_CYC_1CYCLE);
gSPEndDisplayList(gfx++);
+ gReadOnlyBackground = -1;
geo_append_display_list((void *) VIRTUAL_TO_PHYSICAL(gfxStart), 0);
}
diff --git a/src/game/skybox.c b/src/game/skybox.c
index 1318f858..a0f6a285 100644
--- a/src/game/skybox.c
+++ b/src/game/skybox.c
@@ -64,6 +64,9 @@ typedef const Texture *const SkyboxTexture[80];
extern u8 gRenderingInterpolated;
+s8 gReadOnlyBackground;
+s8 gOverrideBackground = -1;
+
extern SkyboxTexture bbh_skybox_ptrlist;
extern SkyboxTexture bidw_skybox_ptrlist;
extern SkyboxTexture bitfs_skybox_ptrlist;
@@ -330,6 +333,9 @@ Gfx *init_skybox_display_list(s8 player, s8 background, s8 colorIndex) {
Gfx *create_skybox_facing_camera(s8 player, s8 background, f32 fov,
f32 posX, f32 posY, f32 posZ,
f32 focX, f32 focY, f32 focZ) {
+ gReadOnlyBackground = background;
+ background = gOverrideBackground == -1 ? background : gOverrideBackground;
+
f32 cameraFaceX = focX - posX;
f32 cameraFaceY = focY - posY;
f32 cameraFaceZ = focZ - posZ;
diff --git a/src/game/skybox.h b/src/game/skybox.h
index e70b8d96..11dfff8b 100644
--- a/src/game/skybox.h
+++ b/src/game/skybox.h
@@ -4,6 +4,9 @@
#include
#include
+extern s8 gReadOnlyBackground;
+extern s8 gOverrideBackground;
+
extern Texture* gCustomSkyboxPtrList[];
Gfx *create_skybox_facing_camera(s8 player, s8 background, f32 fov,
diff --git a/src/pc/djui/djui.c b/src/pc/djui/djui.c
index 6a66a7c7..c522f022 100644
--- a/src/pc/djui/djui.c
+++ b/src/pc/djui/djui.c
@@ -16,6 +16,7 @@ static struct DjuiText* sDjuiLuaError = NULL;
static u32 sDjuiLuaErrorTimeout = 0;
bool gDjuiInMainMenu = true;
bool gDjuiDisabled = false;
+bool gDjuiRenderBehindHud = false;
bool sDjuiRendered60fps = false;
@@ -24,6 +25,8 @@ void patch_djui_before(void) {
}
void patch_djui_interpolated(UNUSED f32 delta) {
+ if (gDjuiRenderBehindHud && !gDjuiPanelPauseCreated) { return; }
+
// reset the head and re-render DJUI
if (delta >= 0.5f && !sDjuiRendered60fps && (gDjuiInMainMenu || gDjuiPanelPauseCreated)) {
sDjuiRendered60fps = true;
@@ -92,6 +95,7 @@ void djui_render(void) {
djui_popup_update();
djui_base_set_visible(&sDjuiPauseOptions->base, (sCurrPlayMode == PLAY_MODE_PAUSED));
+ djui_base_set_visible(&sDjuiPauseOptions->base, (sCurrPlayMode == PLAY_MODE_PAUSED) && !gDjuiPanelPauseCreated);
if (gDjuiRoot != NULL) {
djui_base_render(&gDjuiRoot->base);
}
diff --git a/src/pc/djui/djui.h b/src/pc/djui/djui.h
index c168f28e..54cfa88e 100644
--- a/src/pc/djui/djui.h
+++ b/src/pc/djui/djui.h
@@ -64,6 +64,7 @@
extern struct DjuiRoot* gDjuiRoot;
extern bool gDjuiInMainMenu;
extern bool gDjuiDisabled;
+extern bool gDjuiRenderBehindHud;
void djui_init(void);
void djui_connect_menu_open(void);
diff --git a/src/pc/djui/djui_hud_utils.c b/src/pc/djui/djui_hud_utils.c
index 8ae75ff3..13dd019f 100644
--- a/src/pc/djui/djui_hud_utils.c
+++ b/src/pc/djui/djui_hud_utils.c
@@ -415,4 +415,12 @@ void djui_hud_world_pos_to_screen_pos(Vec3f pos, Vec3f out) {
out[0] += djui_hud_get_screen_width() / 2.0f;
out[1] += djui_hud_get_screen_height() / 2.0f;
-}
\ No newline at end of file
+}
+
+void djui_hud_set_render_behind_hud(bool enable) {
+ gDjuiRenderBehindHud = enable;
+}
+
+bool djui_hud_is_pause_menu_created(void) {
+ return gDjuiPanelPauseCreated;
+}
diff --git a/src/pc/djui/djui_hud_utils.h b/src/pc/djui/djui_hud_utils.h
index f0990dc8..a82cbec9 100644
--- a/src/pc/djui/djui_hud_utils.h
+++ b/src/pc/djui/djui_hud_utils.h
@@ -61,4 +61,8 @@ void djui_hud_render_rect_interpolated(f32 prevX, f32 prevY, f32 prevWidth, f32
void djui_hud_world_pos_to_screen_pos(Vec3f pos, Vec3f out);
+void djui_hud_set_render_behind_hud(bool enable);
+
+bool djui_hud_is_pause_menu_created(void);
+
#endif
\ No newline at end of file
diff --git a/src/pc/djui/djui_panel_pause.c b/src/pc/djui/djui_panel_pause.c
index 8ae54680..cfa7a9b6 100644
--- a/src/pc/djui/djui_panel_pause.c
+++ b/src/pc/djui/djui_panel_pause.c
@@ -48,7 +48,7 @@ void djui_panel_pause_create(struct DjuiBase* caller) {
djui_base_set_size(&rect1->base, 1.0f, 64);
djui_base_set_color(&rect1->base, 0, 0, 0, 0);
{
- struct DjuiButton* button4 = djui_button_create(&rect1->base, "Dynos Packs");
+ struct DjuiButton* button4 = djui_button_create(&rect1->base, "DynOS Packs");
djui_base_set_size_type(&button4->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button4->base, 0.5f, 64);
djui_base_set_alignment(&button4->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP);
diff --git a/src/pc/gfx/gfx_pc.c b/src/pc/gfx/gfx_pc.c
index 60a6d1a0..f249077a 100644
--- a/src/pc/gfx/gfx_pc.c
+++ b/src/pc/gfx/gfx_pc.c
@@ -177,6 +177,8 @@ static f32 sDepthZAdd = 0;
static f32 sDepthZMult = 1;
static f32 sDepthZSub = 0;
+Vec3f gLightingDir;
+
// 4x4 pink-black checkerboard texture to indicate missing textures
#define MISSING_W 4
#define MISSING_H 4
@@ -709,6 +711,11 @@ static void calculate_normal_dir(const Light_t *light, float coeffs[3]) {
light->dir[1] / 127.0f,
light->dir[2] / 127.0f
};
+
+ light_dir[0] += gLightingDir[0];
+ light_dir[1] += gLightingDir[1];
+ light_dir[2] += gLightingDir[2];
+
gfx_transposed_matrix_mul(coeffs, light_dir, rsp.modelview_matrix_stack[rsp.modelview_matrix_stack_size - 1]);
gfx_normalize_vector(coeffs);
}
diff --git a/src/pc/gfx/gfx_pc.h b/src/pc/gfx/gfx_pc.h
index 716221a4..76b066d1 100644
--- a/src/pc/gfx/gfx_pc.h
+++ b/src/pc/gfx/gfx_pc.h
@@ -1,6 +1,8 @@
#ifndef GFX_PC_H
#define GFX_PC_H
+#include "types.h"
+
struct GfxRenderingAPI;
struct GfxWindowManagerAPI;
@@ -11,6 +13,8 @@ struct GfxDimensions {
extern struct GfxDimensions gfx_current_dimensions;
+extern Vec3f gLightingDir;
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c
index 214c917f..60bcfc43 100644
--- a/src/pc/lua/smlua_constants_autogen.c
+++ b/src/pc/lua/smlua_constants_autogen.c
@@ -1308,6 +1308,17 @@ char gSmluaConstants[] = ""
"SEQ_PLAYER_LEVEL = 0\n"
"SEQ_PLAYER_ENV = 1\n"
"SEQ_PLAYER_SFX = 2\n"
+"BACKGROUND_OCEAN_SKY = 0\n"
+"BACKGROUND_FLAMING_SKY = 1\n"
+"BACKGROUND_UNDERWATER_CITY = 2\n"
+"BACKGROUND_BELOW_CLOUDS = 3\n"
+"BACKGROUND_SNOW_MOUNTAINS = 4\n"
+"BACKGROUND_DESERT = 5\n"
+"BACKGROUND_HAUNTED = 6\n"
+"BACKGROUND_GREEN_SKY = 7\n"
+"BACKGROUND_ABOVE_CLOUDS = 8\n"
+"BACKGROUND_PURPLE_SKY = 9\n"
+"BACKGROUND_CUSTOM = 10\n"
"GRAPH_RENDER_ACTIVE = (1 << 0)\n"
"GRAPH_RENDER_CHILDREN_FIRST = (1 << 1)\n"
"GRAPH_RENDER_BILLBOARD = (1 << 2)\n"
diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c
index a2219ff4..9b3ab55e 100644
--- a/src/pc/lua/smlua_functions_autogen.c
+++ b/src/pc/lua/smlua_functions_autogen.c
@@ -11569,6 +11569,21 @@ int smlua_func_djui_hud_get_screen_width(UNUSED lua_State* L) {
return 1;
}
+int smlua_func_djui_hud_is_pause_menu_created(UNUSED lua_State* L) {
+ if (L == NULL) { return 0; }
+
+ int top = lua_gettop(L);
+ if (top != 0) {
+ LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "djui_hud_is_pause_menu_created", 0, top);
+ return 0;
+ }
+
+
+ lua_pushboolean(L, djui_hud_is_pause_menu_created());
+
+ return 1;
+}
+
int smlua_func_djui_hud_measure_text(lua_State* L) {
if (L == NULL) { return 0; }
@@ -11720,6 +11735,23 @@ int smlua_func_djui_hud_set_mouse_locked(lua_State* L) {
return 1;
}
+int smlua_func_djui_hud_set_render_behind_hud(lua_State* L) {
+ if (L == NULL) { return 0; }
+
+ int top = lua_gettop(L);
+ if (top != 1) {
+ LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "djui_hud_set_render_behind_hud", 1, top);
+ return 0;
+ }
+
+ bool enable = smlua_to_boolean(L, 1);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "djui_hud_set_render_behind_hud"); return 0; }
+
+ djui_hud_set_render_behind_hud(enable);
+
+ return 1;
+}
+
int smlua_func_djui_hud_set_resolution(lua_State* L) {
if (L == NULL) { return 0; }
@@ -27129,6 +27161,23 @@ int smlua_func_get_last_star_or_key(UNUSED lua_State* L) {
return 1;
}
+int smlua_func_get_lighting_dir(lua_State* L) {
+ if (L == NULL) { return 0; }
+
+ int top = lua_gettop(L);
+ if (top != 1) {
+ LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_lighting_dir", 1, top);
+ return 0;
+ }
+
+ u8 index = smlua_to_integer(L, 1);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_lighting_dir"); return 0; }
+
+ lua_pushnumber(L, get_lighting_dir(index));
+
+ return 1;
+}
+
int smlua_func_get_network_area_timer(UNUSED lua_State* L) {
if (L == NULL) { return 0; }
@@ -27144,6 +27193,21 @@ int smlua_func_get_network_area_timer(UNUSED lua_State* L) {
return 1;
}
+int smlua_func_get_skybox(UNUSED lua_State* L) {
+ if (L == NULL) { return 0; }
+
+ int top = lua_gettop(L);
+ if (top != 0) {
+ LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_skybox", 0, top);
+ return 0;
+ }
+
+
+ lua_pushinteger(L, get_skybox());
+
+ return 1;
+}
+
int smlua_func_get_temp_s32_pointer(lua_State* L) {
if (L == NULL) { return 0; }
@@ -27428,6 +27492,25 @@ int smlua_func_set_last_star_or_key(lua_State* L) {
return 1;
}
+int smlua_func_set_lighting_dir(lua_State* L) {
+ if (L == NULL) { return 0; }
+
+ int top = lua_gettop(L);
+ if (top != 2) {
+ LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_lighting_dir", 2, top);
+ return 0;
+ }
+
+ u8 index = smlua_to_integer(L, 1);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_lighting_dir"); return 0; }
+ f32 value = smlua_to_number(L, 2);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_lighting_dir"); return 0; }
+
+ set_lighting_dir(index, value);
+
+ return 1;
+}
+
int smlua_func_set_override_far(lua_State* L) {
if (L == NULL) { return 0; }
@@ -27479,6 +27562,23 @@ int smlua_func_set_override_near(lua_State* L) {
return 1;
}
+int smlua_func_set_override_skybox(lua_State* L) {
+ if (L == NULL) { return 0; }
+
+ int top = lua_gettop(L);
+ if (top != 1) {
+ LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_override_skybox", 1, top);
+ return 0;
+ }
+
+ s8 background = smlua_to_integer(L, 1);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_override_skybox"); return 0; }
+
+ set_override_skybox(background);
+
+ return 1;
+}
+
int smlua_func_set_ttc_speed_setting(lua_State* L) {
if (L == NULL) { return 0; }
@@ -29668,6 +29768,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "djui_hud_get_raw_mouse_y", smlua_func_djui_hud_get_raw_mouse_y);
smlua_bind_function(L, "djui_hud_get_screen_height", smlua_func_djui_hud_get_screen_height);
smlua_bind_function(L, "djui_hud_get_screen_width", smlua_func_djui_hud_get_screen_width);
+ smlua_bind_function(L, "djui_hud_is_pause_menu_created", smlua_func_djui_hud_is_pause_menu_created);
smlua_bind_function(L, "djui_hud_measure_text", smlua_func_djui_hud_measure_text);
smlua_bind_function(L, "djui_hud_print_text", smlua_func_djui_hud_print_text);
smlua_bind_function(L, "djui_hud_render_rect", smlua_func_djui_hud_render_rect);
@@ -29675,6 +29776,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "djui_hud_set_color", smlua_func_djui_hud_set_color);
smlua_bind_function(L, "djui_hud_set_font", smlua_func_djui_hud_set_font);
smlua_bind_function(L, "djui_hud_set_mouse_locked", smlua_func_djui_hud_set_mouse_locked);
+ smlua_bind_function(L, "djui_hud_set_render_behind_hud", smlua_func_djui_hud_set_render_behind_hud);
smlua_bind_function(L, "djui_hud_set_resolution", smlua_func_djui_hud_set_resolution);
smlua_bind_function(L, "djui_hud_world_pos_to_screen_pos", smlua_func_djui_hud_world_pos_to_screen_pos);
@@ -30439,7 +30541,9 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "get_hand_foot_pos_y", smlua_func_get_hand_foot_pos_y);
smlua_bind_function(L, "get_hand_foot_pos_z", smlua_func_get_hand_foot_pos_z);
smlua_bind_function(L, "get_last_star_or_key", smlua_func_get_last_star_or_key);
+ smlua_bind_function(L, "get_lighting_dir", smlua_func_get_lighting_dir);
smlua_bind_function(L, "get_network_area_timer", smlua_func_get_network_area_timer);
+ smlua_bind_function(L, "get_skybox", smlua_func_get_skybox);
smlua_bind_function(L, "get_temp_s32_pointer", smlua_func_get_temp_s32_pointer);
smlua_bind_function(L, "get_time", smlua_func_get_time);
smlua_bind_function(L, "get_ttc_speed_setting", smlua_func_get_ttc_speed_setting);
@@ -30456,9 +30560,11 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "save_file_set_using_backup_slot", smlua_func_save_file_set_using_backup_slot);
smlua_bind_function(L, "set_environment_region", smlua_func_set_environment_region);
smlua_bind_function(L, "set_last_star_or_key", smlua_func_set_last_star_or_key);
+ smlua_bind_function(L, "set_lighting_dir", smlua_func_set_lighting_dir);
smlua_bind_function(L, "set_override_far", smlua_func_set_override_far);
smlua_bind_function(L, "set_override_fov", smlua_func_set_override_fov);
smlua_bind_function(L, "set_override_near", smlua_func_set_override_near);
+ smlua_bind_function(L, "set_override_skybox", smlua_func_set_override_skybox);
smlua_bind_function(L, "set_ttc_speed_setting", smlua_func_set_ttc_speed_setting);
// smlua_model_utils.h
diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c
index fdab7020..2956eae1 100644
--- a/src/pc/lua/utils/smlua_misc_utils.c
+++ b/src/pc/lua/utils/smlua_misc_utils.c
@@ -17,6 +17,8 @@
#include "game/rendering_graph_node.h"
#include "game/level_update.h"
#include "pc/djui/djui_hud_utils.h"
+#include "game/skybox.h"
+#include "pc/gfx/gfx_pc.h"
#include "include/course_table.h"
u32 get_network_area_timer(void) {
@@ -383,6 +385,29 @@ void add_scroll_target(u32 index, const char* name, u32 offset, u32 size) {
///
+f32 get_lighting_dir(u8 index) {
+ if (index > 2) { return 0; }
+ return gLightingDir[index];
+}
+
+void set_lighting_dir(u8 index, f32 value) {
+ if (index > 2) { return; }
+
+ gLightingDir[index] = value;
+}
+
+///
+
+s8 get_skybox() {
+ return gReadOnlyBackground;
+}
+
+void set_override_skybox(s8 background) {
+ gOverrideBackground = background;
+}
+
+///
+
bool course_is_main_course(u16 levelNum) {
return COURSE_IS_MAIN_COURSE(levelNum);
}
diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h
index 0d5a5c16..5394e3ae 100644
--- a/src/pc/lua/utils/smlua_misc_utils.h
+++ b/src/pc/lua/utils/smlua_misc_utils.h
@@ -92,6 +92,12 @@ void set_override_far(f32 far);
void add_scroll_target(u32 index, const char* name, u32 offset, u32 size);
+f32 get_lighting_dir(u8 index);
+void set_lighting_dir(u8 index, f32 value);
+
+s8 get_skybox();
+void set_override_skybox(s8 background);
+
void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue);
bool course_is_main_course(u16 levelNum);
diff --git a/src/pc/network/network.c b/src/pc/network/network.c
index 45bb0408..32b16627 100644
--- a/src/pc/network/network.c
+++ b/src/pc/network/network.c
@@ -20,6 +20,8 @@
#include "pc/crash_handler.h"
#include "pc/debuglog.h"
#include "game/camera.h"
+#include "pc/gfx/gfx_pc.h"
+#include "game/skybox.h"
#include "game/object_list_processor.h"
#include "game/object_helpers.h"
#include "menu/intro_geo.h"
@@ -509,6 +511,11 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup) {
gOverrideNear = 0;
gOverrideFar = 0;
gOverrideFOV = 0;
+ gLightingDir[0] = 0;
+ gLightingDir[1] = 0;
+ gLightingDir[2] = 0;
+ gOverrideBackground = -1;
+ gDjuiRenderBehindHud = false;
dynos_mod_shutdown();
mods_clear(&gActiveMods);
mods_clear(&gRemoteMods);