Mouse lock & freeze cam fixes and warp constants (#103)

This commit is contained in:
Agent X 2022-05-19 20:06:51 -04:00 committed by GitHub
parent 0c7ada8d2b
commit 68d46cdefe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 90 additions and 9 deletions

View File

@ -12,6 +12,7 @@ in_files = [
"include/types.h",
"include/sm64.h",
"src/pc/lua/smlua_hooks.h",
"src/game/area.h",
"src/game/camera.h",
"include/mario_animation_ids.h",
"include/sounds.h",

View File

@ -336,6 +336,45 @@ COURSE_COUNT = 25
--- @type integer
COURSE_MIN = 1
--- @type integer
INSTANT_WARP_INDEX_START = 0x00
--- @type integer
INSTANT_WARP_INDEX_STOP = 0x04
--- @type integer
MAX_LOADED_GRAPH_NODES = 0x100
--- @type integer
WARP_TRANSITION_FADE_FROM_BOWSER = 0x12
--- @type integer
WARP_TRANSITION_FADE_FROM_CIRCLE = 0x0A
--- @type integer
WARP_TRANSITION_FADE_FROM_COLOR = 0x00
--- @type integer
WARP_TRANSITION_FADE_FROM_MARIO = 0x10
--- @type integer
WARP_TRANSITION_FADE_FROM_STAR = 0x08
--- @type integer
WARP_TRANSITION_FADE_INTO_BOWSER = 0x13
--- @type integer
WARP_TRANSITION_FADE_INTO_CIRCLE = 0x0B
--- @type integer
WARP_TRANSITION_FADE_INTO_COLOR = 0x01
--- @type integer
WARP_TRANSITION_FADE_INTO_MARIO = 0x11
--- @type integer
WARP_TRANSITION_FADE_INTO_STAR = 0x09
--- @class BehaviorId
--- @type BehaviorId

View File

@ -1,6 +1,7 @@
## [:rewind: Lua Reference](lua.md)
# Supported Constants
- [area.h](#areah)
- [behavior_table.h](#behavior_tableh)
- [enum BehaviorId](#enum-BehaviorId)
- [camera.h](#camerah)
@ -57,6 +58,25 @@
<br />
## [area.h](#area.h)
- INSTANT_WARP_INDEX_START
- INSTANT_WARP_INDEX_STOP
- MAX_LOADED_GRAPH_NODES
- WARP_TRANSITION_FADE_FROM_BOWSER
- WARP_TRANSITION_FADE_FROM_CIRCLE
- WARP_TRANSITION_FADE_FROM_COLOR
- WARP_TRANSITION_FADE_FROM_MARIO
- WARP_TRANSITION_FADE_FROM_STAR
- WARP_TRANSITION_FADE_INTO_BOWSER
- WARP_TRANSITION_FADE_INTO_CIRCLE
- WARP_TRANSITION_FADE_INTO_COLOR
- WARP_TRANSITION_FADE_INTO_MARIO
- WARP_TRANSITION_FADE_INTO_STAR
[:arrow_up_small:](#)
<br />
## [behavior_table.h](#behavior_table.h)
### [enum BehaviorId](#BehaviorId)

View File

@ -32,6 +32,7 @@
#include "pc/configfile.h"
#include "pc/network/network.h"
#include "pc/lua/smlua_hooks.h"
#include "pc/djui/djui.h"
#define CBUTTON_MASK (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS)
@ -3050,7 +3051,7 @@ void update_lakitu(struct Camera *c) {
* Gets controller input, checks for cutscenes, handles mode changes, and moves the camera
*/
void update_camera(struct Camera *c) {
if (gOverrideFreezeCamera) {
if (gOverrideFreezeCamera && !gDjuiInMainMenu) {
return;
}
UNUSED u8 unused[24];

View File

@ -24,6 +24,7 @@
#include "../fs/fs.h"
#include "game/level_update.h"
#include "pc/lua/utils/smlua_misc_utils.h"
#include "pc/djui/djui.h"
#include "pc/djui/djui_hud_utils.h"
@ -168,12 +169,14 @@ static void controller_sdl_read(OSContPad *pad) {
}
#ifdef BETTERCAMERA
if (newcam_mouse == 1 && sCurrPlayMode != 2) {
SDL_SetRelativeMouseMode(SDL_TRUE);
ignore_lock = TRUE;
} else {
SDL_SetRelativeMouseMode(SDL_FALSE);
ignore_lock = FALSE;
if (!gDjuiHudLockMouse) {
if (newcam_mouse == 1 && (!is_game_paused() || sCurrPlayMode != 2) && !gDjuiInMainMenu) {
SDL_SetRelativeMouseMode(SDL_TRUE);
ignore_lock = true;
} else {
SDL_SetRelativeMouseMode(SDL_FALSE);
ignore_lock = false;
}
}
u32 mouse = SDL_GetRelativeMouseState(&mouse_x, &mouse_y);
@ -187,7 +190,7 @@ static void controller_sdl_read(OSContPad *pad) {
last_mouse = (mouse_buttons ^ mouse) & mouse;
mouse_buttons = mouse;
#endif
if (!ignore_lock && sCurrPlayMode != 2) {
if (!ignore_lock && (!is_game_paused() || sCurrPlayMode != 2) && !gDjuiInMainMenu) {
SDL_SetRelativeMouseMode(gDjuiHudLockMouse ? SDL_TRUE : SDL_FALSE);
#ifndef BETTERCAMERA

View File

@ -22,7 +22,7 @@ static enum HudUtilsResolution sResolution = RESOLUTION_DJUI;
static enum DjuiFontType sFont = FONT_NORMAL;
f32 gDjuiHudUtilsZ = 0;
u8 gDjuiHudLockMouse = FALSE;
u8 gDjuiHudLockMouse = false;
extern ALIGNED8 const u8 texture_hud_char_camera[];
extern ALIGNED8 const u8 texture_hud_char_lakitu[];

View File

@ -307,6 +307,19 @@ char gSmluaConstants[] = ""
"COURSE_COUNT = 25\n"
"--- @type integer\n"
"COURSE_MIN = 1\n"
"MAX_LOADED_GRAPH_NODES = 0x100\n"
"INSTANT_WARP_INDEX_START = 0x00\n"
"INSTANT_WARP_INDEX_STOP = 0x04\n"
"WARP_TRANSITION_FADE_FROM_COLOR = 0x00\n"
"WARP_TRANSITION_FADE_INTO_COLOR = 0x01\n"
"WARP_TRANSITION_FADE_FROM_STAR = 0x08\n"
"WARP_TRANSITION_FADE_INTO_STAR = 0x09\n"
"WARP_TRANSITION_FADE_FROM_CIRCLE = 0x0A\n"
"WARP_TRANSITION_FADE_INTO_CIRCLE = 0x0B\n"
"WARP_TRANSITION_FADE_FROM_MARIO = 0x10\n"
"WARP_TRANSITION_FADE_INTO_MARIO = 0x11\n"
"WARP_TRANSITION_FADE_FROM_BOWSER = 0x12\n"
"WARP_TRANSITION_FADE_INTO_BOWSER = 0x13\n"
"id_bhv1Up = 0\n"
"id_bhv1upJumpOnApproach = 1\n"
"id_bhv1upRunningAway = 2\n"

View File

@ -11,11 +11,13 @@
#include "pc/configfile.h"
#include "pc/cheats.h"
#include "pc/djui/djui.h"
#include "pc/djui/djui_hud_utils.h"
#include "pc/utils/misc.h"
#include "pc/lua/smlua.h"
#include "pc/mods/mods.h"
#include "pc/crash_handler.h"
#include "pc/debuglog.h"
#include "game/camera.h"
// Mario 64 specific externs
extern s16 sCurrPlayMode;
@ -460,6 +462,8 @@ void network_shutdown(bool sendLeaving, bool exiting) {
// reset other stuff
extern u8* gOverrideEeprom;
gOverrideEeprom = NULL;
gOverrideFreezeCamera = false;
gDjuiHudLockMouse = false;
dynos_mod_shutdown();
mods_clear(&gActiveMods);
mods_clear(&gRemoteMods);