Camera config values for lua (#116)

* Added camera config getters and setters
This commit is contained in:
PeachyPeach 2022-05-23 03:47:36 +02:00 committed by GitHub
parent a1c73d13ef
commit d1bb79f4a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 903 additions and 0 deletions

View File

@ -7323,6 +7323,116 @@ function allocate_mario_action(actFlags)
-- ...
end
--- @param enable boolean
--- @return nil
function camera_config_enable_analog_cam(enable)
-- ...
end
--- @param enable boolean
--- @return nil
function camera_config_enable_free_cam(enable)
-- ...
end
--- @param enable boolean
--- @return nil
function camera_config_enable_mouse_look(enable)
-- ...
end
--- @return integer
function camera_config_get_aggression()
-- ...
end
--- @return integer
function camera_config_get_deceleration()
-- ...
end
--- @return integer
function camera_config_get_pan_level()
-- ...
end
--- @return integer
function camera_config_get_x_sensitivity()
-- ...
end
--- @return integer
function camera_config_get_y_sensitivity()
-- ...
end
--- @param invert boolean
--- @return nil
function camera_config_invert_x(invert)
-- ...
end
--- @param invert boolean
--- @return nil
function camera_config_invert_y(invert)
-- ...
end
--- @return boolean
function camera_config_is_analog_cam_enabled()
-- ...
end
--- @return boolean
function camera_config_is_free_cam_enabled()
-- ...
end
--- @return boolean
function camera_config_is_mouse_look_enabled()
-- ...
end
--- @return boolean
function camera_config_is_x_inverted()
-- ...
end
--- @return boolean
function camera_config_is_y_inverted()
-- ...
end
--- @param value integer
--- @return nil
function camera_config_set_aggression(value)
-- ...
end
--- @param value integer
--- @return nil
function camera_config_set_deceleration(value)
-- ...
end
--- @param value integer
--- @return nil
function camera_config_set_pan_level(value)
-- ...
end
--- @param value integer
--- @return nil
function camera_config_set_x_sensitivity(value)
-- ...
end
--- @param value integer
--- @return nil
function camera_config_set_y_sensitivity(value)
-- ...
end
--- @return nil
function camera_freeze()
-- ...

View File

@ -5113,6 +5113,386 @@
<br />
## [camera_config_enable_analog_cam](#camera_config_enable_analog_cam)
### Lua Example
`camera_config_enable_analog_cam(enable)`
### Parameters
| Field | Type |
| ----- | ---- |
| enable | `boolean` |
### Returns
- None
### C Prototype
`void camera_config_enable_analog_cam(bool enable);`
[:arrow_up_small:](#)
<br />
## [camera_config_enable_free_cam](#camera_config_enable_free_cam)
### Lua Example
`camera_config_enable_free_cam(enable)`
### Parameters
| Field | Type |
| ----- | ---- |
| enable | `boolean` |
### Returns
- None
### C Prototype
`void camera_config_enable_free_cam(bool enable);`
[:arrow_up_small:](#)
<br />
## [camera_config_enable_mouse_look](#camera_config_enable_mouse_look)
### Lua Example
`camera_config_enable_mouse_look(enable)`
### Parameters
| Field | Type |
| ----- | ---- |
| enable | `boolean` |
### Returns
- None
### C Prototype
`void camera_config_enable_mouse_look(bool enable);`
[:arrow_up_small:](#)
<br />
## [camera_config_get_aggression](#camera_config_get_aggression)
### Lua Example
`local integerValue = camera_config_get_aggression()`
### Parameters
- None
### Returns
- `integer`
### C Prototype
`u32 camera_config_get_aggression(void);`
[:arrow_up_small:](#)
<br />
## [camera_config_get_deceleration](#camera_config_get_deceleration)
### Lua Example
`local integerValue = camera_config_get_deceleration()`
### Parameters
- None
### Returns
- `integer`
### C Prototype
`u32 camera_config_get_deceleration(void);`
[:arrow_up_small:](#)
<br />
## [camera_config_get_pan_level](#camera_config_get_pan_level)
### Lua Example
`local integerValue = camera_config_get_pan_level()`
### Parameters
- None
### Returns
- `integer`
### C Prototype
`u32 camera_config_get_pan_level(void);`
[:arrow_up_small:](#)
<br />
## [camera_config_get_x_sensitivity](#camera_config_get_x_sensitivity)
### Lua Example
`local integerValue = camera_config_get_x_sensitivity()`
### Parameters
- None
### Returns
- `integer`
### C Prototype
`u32 camera_config_get_x_sensitivity(void);`
[:arrow_up_small:](#)
<br />
## [camera_config_get_y_sensitivity](#camera_config_get_y_sensitivity)
### Lua Example
`local integerValue = camera_config_get_y_sensitivity()`
### Parameters
- None
### Returns
- `integer`
### C Prototype
`u32 camera_config_get_y_sensitivity(void);`
[:arrow_up_small:](#)
<br />
## [camera_config_invert_x](#camera_config_invert_x)
### Lua Example
`camera_config_invert_x(invert)`
### Parameters
| Field | Type |
| ----- | ---- |
| invert | `boolean` |
### Returns
- None
### C Prototype
`void camera_config_invert_x(bool invert);`
[:arrow_up_small:](#)
<br />
## [camera_config_invert_y](#camera_config_invert_y)
### Lua Example
`camera_config_invert_y(invert)`
### Parameters
| Field | Type |
| ----- | ---- |
| invert | `boolean` |
### Returns
- None
### C Prototype
`void camera_config_invert_y(bool invert);`
[:arrow_up_small:](#)
<br />
## [camera_config_is_analog_cam_enabled](#camera_config_is_analog_cam_enabled)
### Lua Example
`local booleanValue = camera_config_is_analog_cam_enabled()`
### Parameters
- None
### Returns
- `boolean`
### C Prototype
`bool camera_config_is_analog_cam_enabled(void);`
[:arrow_up_small:](#)
<br />
## [camera_config_is_free_cam_enabled](#camera_config_is_free_cam_enabled)
### Lua Example
`local booleanValue = camera_config_is_free_cam_enabled()`
### Parameters
- None
### Returns
- `boolean`
### C Prototype
`bool camera_config_is_free_cam_enabled(void);`
[:arrow_up_small:](#)
<br />
## [camera_config_is_mouse_look_enabled](#camera_config_is_mouse_look_enabled)
### Lua Example
`local booleanValue = camera_config_is_mouse_look_enabled()`
### Parameters
- None
### Returns
- `boolean`
### C Prototype
`bool camera_config_is_mouse_look_enabled(void);`
[:arrow_up_small:](#)
<br />
## [camera_config_is_x_inverted](#camera_config_is_x_inverted)
### Lua Example
`local booleanValue = camera_config_is_x_inverted()`
### Parameters
- None
### Returns
- `boolean`
### C Prototype
`bool camera_config_is_x_inverted(void);`
[:arrow_up_small:](#)
<br />
## [camera_config_is_y_inverted](#camera_config_is_y_inverted)
### Lua Example
`local booleanValue = camera_config_is_y_inverted()`
### Parameters
- None
### Returns
- `boolean`
### C Prototype
`bool camera_config_is_y_inverted(void);`
[:arrow_up_small:](#)
<br />
## [camera_config_set_aggression](#camera_config_set_aggression)
### Lua Example
`camera_config_set_aggression(value)`
### Parameters
| Field | Type |
| ----- | ---- |
| value | `integer` |
### Returns
- None
### C Prototype
`void camera_config_set_aggression(u32 value);`
[:arrow_up_small:](#)
<br />
## [camera_config_set_deceleration](#camera_config_set_deceleration)
### Lua Example
`camera_config_set_deceleration(value)`
### Parameters
| Field | Type |
| ----- | ---- |
| value | `integer` |
### Returns
- None
### C Prototype
`void camera_config_set_deceleration(u32 value);`
[:arrow_up_small:](#)
<br />
## [camera_config_set_pan_level](#camera_config_set_pan_level)
### Lua Example
`camera_config_set_pan_level(value)`
### Parameters
| Field | Type |
| ----- | ---- |
| value | `integer` |
### Returns
- None
### C Prototype
`void camera_config_set_pan_level(u32 value);`
[:arrow_up_small:](#)
<br />
## [camera_config_set_x_sensitivity](#camera_config_set_x_sensitivity)
### Lua Example
`camera_config_set_x_sensitivity(value)`
### Parameters
| Field | Type |
| ----- | ---- |
| value | `integer` |
### Returns
- None
### C Prototype
`void camera_config_set_x_sensitivity(u32 value);`
[:arrow_up_small:](#)
<br />
## [camera_config_set_y_sensitivity](#camera_config_set_y_sensitivity)
### Lua Example
`camera_config_set_y_sensitivity(value)`
### Parameters
| Field | Type |
| ----- | ---- |
| value | `integer` |
### Returns
- None
### C Prototype
`void camera_config_set_y_sensitivity(u32 value);`
[:arrow_up_small:](#)
<br />
## [camera_freeze](#camera_freeze)
### Lua Example

View File

@ -1368,6 +1368,26 @@
- smlua_misc_utils.h
- [allocate_mario_action](functions-4.md#allocate_mario_action)
- [camera_config_enable_analog_cam](functions-4.md#camera_config_enable_analog_cam)
- [camera_config_enable_free_cam](functions-4.md#camera_config_enable_free_cam)
- [camera_config_enable_mouse_look](functions-4.md#camera_config_enable_mouse_look)
- [camera_config_get_aggression](functions-4.md#camera_config_get_aggression)
- [camera_config_get_deceleration](functions-4.md#camera_config_get_deceleration)
- [camera_config_get_pan_level](functions-4.md#camera_config_get_pan_level)
- [camera_config_get_x_sensitivity](functions-4.md#camera_config_get_x_sensitivity)
- [camera_config_get_y_sensitivity](functions-4.md#camera_config_get_y_sensitivity)
- [camera_config_invert_x](functions-4.md#camera_config_invert_x)
- [camera_config_invert_y](functions-4.md#camera_config_invert_y)
- [camera_config_is_analog_cam_enabled](functions-4.md#camera_config_is_analog_cam_enabled)
- [camera_config_is_free_cam_enabled](functions-4.md#camera_config_is_free_cam_enabled)
- [camera_config_is_mouse_look_enabled](functions-4.md#camera_config_is_mouse_look_enabled)
- [camera_config_is_x_inverted](functions-4.md#camera_config_is_x_inverted)
- [camera_config_is_y_inverted](functions-4.md#camera_config_is_y_inverted)
- [camera_config_set_aggression](functions-4.md#camera_config_set_aggression)
- [camera_config_set_deceleration](functions-4.md#camera_config_set_deceleration)
- [camera_config_set_pan_level](functions-4.md#camera_config_set_pan_level)
- [camera_config_set_x_sensitivity](functions-4.md#camera_config_set_x_sensitivity)
- [camera_config_set_y_sensitivity](functions-4.md#camera_config_set_y_sensitivity)
- [camera_freeze](functions-4.md#camera_freeze)
- [camera_unfreeze](functions-4.md#camera_unfreeze)
- [deref_s32_pointer](functions-4.md#deref_s32_pointer)

View File

@ -15073,6 +15073,206 @@ int smlua_func_allocate_mario_action(lua_State* L) {
return 1;
}
int smlua_func_camera_config_enable_analog_cam(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
bool enable = smlua_to_boolean(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
camera_config_enable_analog_cam(enable);
return 1;
}
int smlua_func_camera_config_enable_free_cam(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
bool enable = smlua_to_boolean(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
camera_config_enable_free_cam(enable);
return 1;
}
int smlua_func_camera_config_enable_mouse_look(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
bool enable = smlua_to_boolean(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
camera_config_enable_mouse_look(enable);
return 1;
}
int smlua_func_camera_config_get_aggression(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
lua_pushinteger(L, camera_config_get_aggression());
return 1;
}
int smlua_func_camera_config_get_deceleration(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
lua_pushinteger(L, camera_config_get_deceleration());
return 1;
}
int smlua_func_camera_config_get_pan_level(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
lua_pushinteger(L, camera_config_get_pan_level());
return 1;
}
int smlua_func_camera_config_get_x_sensitivity(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
lua_pushinteger(L, camera_config_get_x_sensitivity());
return 1;
}
int smlua_func_camera_config_get_y_sensitivity(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
lua_pushinteger(L, camera_config_get_y_sensitivity());
return 1;
}
int smlua_func_camera_config_invert_x(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
bool invert = smlua_to_boolean(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
camera_config_invert_x(invert);
return 1;
}
int smlua_func_camera_config_invert_y(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
bool invert = smlua_to_boolean(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
camera_config_invert_y(invert);
return 1;
}
int smlua_func_camera_config_is_analog_cam_enabled(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
lua_pushboolean(L, camera_config_is_analog_cam_enabled());
return 1;
}
int smlua_func_camera_config_is_free_cam_enabled(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
lua_pushboolean(L, camera_config_is_free_cam_enabled());
return 1;
}
int smlua_func_camera_config_is_mouse_look_enabled(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
lua_pushboolean(L, camera_config_is_mouse_look_enabled());
return 1;
}
int smlua_func_camera_config_is_x_inverted(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
lua_pushboolean(L, camera_config_is_x_inverted());
return 1;
}
int smlua_func_camera_config_is_y_inverted(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
lua_pushboolean(L, camera_config_is_y_inverted());
return 1;
}
int smlua_func_camera_config_set_aggression(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
u32 value = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
camera_config_set_aggression(value);
return 1;
}
int smlua_func_camera_config_set_deceleration(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
u32 value = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
camera_config_set_deceleration(value);
return 1;
}
int smlua_func_camera_config_set_pan_level(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
u32 value = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
camera_config_set_pan_level(value);
return 1;
}
int smlua_func_camera_config_set_x_sensitivity(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
u32 value = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
camera_config_set_x_sensitivity(value);
return 1;
}
int smlua_func_camera_config_set_y_sensitivity(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
u32 value = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
camera_config_set_y_sensitivity(value);
return 1;
}
int smlua_func_camera_freeze(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
@ -17596,6 +17796,26 @@ void smlua_bind_functions_autogen(void) {
// smlua_misc_utils.h
smlua_bind_function(L, "allocate_mario_action", smlua_func_allocate_mario_action);
smlua_bind_function(L, "camera_config_enable_analog_cam", smlua_func_camera_config_enable_analog_cam);
smlua_bind_function(L, "camera_config_enable_free_cam", smlua_func_camera_config_enable_free_cam);
smlua_bind_function(L, "camera_config_enable_mouse_look", smlua_func_camera_config_enable_mouse_look);
smlua_bind_function(L, "camera_config_get_aggression", smlua_func_camera_config_get_aggression);
smlua_bind_function(L, "camera_config_get_deceleration", smlua_func_camera_config_get_deceleration);
smlua_bind_function(L, "camera_config_get_pan_level", smlua_func_camera_config_get_pan_level);
smlua_bind_function(L, "camera_config_get_x_sensitivity", smlua_func_camera_config_get_x_sensitivity);
smlua_bind_function(L, "camera_config_get_y_sensitivity", smlua_func_camera_config_get_y_sensitivity);
smlua_bind_function(L, "camera_config_invert_x", smlua_func_camera_config_invert_x);
smlua_bind_function(L, "camera_config_invert_y", smlua_func_camera_config_invert_y);
smlua_bind_function(L, "camera_config_is_analog_cam_enabled", smlua_func_camera_config_is_analog_cam_enabled);
smlua_bind_function(L, "camera_config_is_free_cam_enabled", smlua_func_camera_config_is_free_cam_enabled);
smlua_bind_function(L, "camera_config_is_mouse_look_enabled", smlua_func_camera_config_is_mouse_look_enabled);
smlua_bind_function(L, "camera_config_is_x_inverted", smlua_func_camera_config_is_x_inverted);
smlua_bind_function(L, "camera_config_is_y_inverted", smlua_func_camera_config_is_y_inverted);
smlua_bind_function(L, "camera_config_set_aggression", smlua_func_camera_config_set_aggression);
smlua_bind_function(L, "camera_config_set_deceleration", smlua_func_camera_config_set_deceleration);
smlua_bind_function(L, "camera_config_set_pan_level", smlua_func_camera_config_set_pan_level);
smlua_bind_function(L, "camera_config_set_x_sensitivity", smlua_func_camera_config_set_x_sensitivity);
smlua_bind_function(L, "camera_config_set_y_sensitivity", smlua_func_camera_config_set_y_sensitivity);
smlua_bind_function(L, "camera_freeze", smlua_func_camera_freeze);
smlua_bind_function(L, "camera_unfreeze", smlua_func_camera_unfreeze);
smlua_bind_function(L, "deref_s32_pointer", smlua_func_deref_s32_pointer);

View File

@ -2,6 +2,7 @@
#include "types.h"
#include "data/dynos.c.h"
#include "game/bettercamera.h"
#include "game/camera.h"
#include "game/hud.h"
#include "pc/lua/smlua.h"
@ -112,6 +113,156 @@ void camera_unfreeze(void) {
gOverrideFreezeCamera = FALSE;
}
bool camera_config_is_free_cam_enabled(void) {
#ifdef BETTERCAMERA
return configEnableCamera;
#else
return false;
#endif
}
bool camera_config_is_analog_cam_enabled(void) {
#ifdef BETTERCAMERA
return configCameraAnalog;
#else
return false;
#endif
}
bool camera_config_is_mouse_look_enabled(void) {
#ifdef BETTERCAMERA
return configCameraMouse;
#else
return false;
#endif
}
bool camera_config_is_x_inverted(void) {
#ifdef BETTERCAMERA
return configCameraInvertX;
#else
return false;
#endif
}
bool camera_config_is_y_inverted(void) {
#ifdef BETTERCAMERA
return configCameraInvertY;
#else
return false;
#endif
}
u32 camera_config_get_x_sensitivity(void) {
#ifdef BETTERCAMERA
return configCameraXSens;
#else
return 0;
#endif
}
u32 camera_config_get_y_sensitivity(void) {
#ifdef BETTERCAMERA
return configCameraYSens;
#else
return 0;
#endif
}
u32 camera_config_get_aggression(void) {
#ifdef BETTERCAMERA
return configCameraAggr;
#else
return 0;
#endif
}
u32 camera_config_get_pan_level(void) {
#ifdef BETTERCAMERA
return configCameraPan;
#else
return 0;
#endif
}
u32 camera_config_get_deceleration(void) {
#ifdef BETTERCAMERA
return configCameraDegrade;
#else
return 0;
#endif
}
void camera_config_enable_free_cam(bool enable) {
#ifdef BETTERCAMERA
configEnableCamera = enable;
newcam_init_settings();
#endif
}
void camera_config_enable_analog_cam(bool enable) {
#ifdef BETTERCAMERA
configCameraAnalog = enable;
newcam_init_settings();
#endif
}
void camera_config_enable_mouse_look(bool enable) {
#ifdef BETTERCAMERA
configCameraMouse = enable;
newcam_init_settings();
#endif
}
void camera_config_invert_x(bool invert) {
#ifdef BETTERCAMERA
configCameraInvertX = invert;
newcam_init_settings();
#endif
}
void camera_config_invert_y(bool invert) {
#ifdef BETTERCAMERA
configCameraInvertY = invert;
newcam_init_settings();
#endif
}
void camera_config_set_x_sensitivity(u32 value) {
#ifdef BETTERCAMERA
configCameraXSens = MIN(MAX(value, 1), 100);
newcam_init_settings();
#endif
}
void camera_config_set_y_sensitivity(u32 value) {
#ifdef BETTERCAMERA
configCameraYSens = MIN(MAX(value, 1), 100);
newcam_init_settings();
#endif
}
void camera_config_set_aggression(u32 value) {
#ifdef BETTERCAMERA
configCameraAggr = MIN(MAX(value, 0), 100);
newcam_init_settings();
#endif
}
void camera_config_set_pan_level(u32 value) {
#ifdef BETTERCAMERA
configCameraPan = MIN(MAX(value, 0), 100);
newcam_init_settings();
#endif
}
void camera_config_set_deceleration(u32 value) {
#ifdef BETTERCAMERA
configCameraDegrade = MIN(MAX(value, 0), 100);
newcam_init_settings();
#endif
}
///
extern s16 gMenuMode;

View File

@ -39,6 +39,28 @@ void hud_render_power_meter(s32 health, f32 x, f32 y, f32 width, f32 height);
void camera_freeze(void);
void camera_unfreeze(void);
bool camera_config_is_free_cam_enabled(void);
bool camera_config_is_analog_cam_enabled(void);
bool camera_config_is_mouse_look_enabled(void);
bool camera_config_is_x_inverted(void);
bool camera_config_is_y_inverted(void);
u32 camera_config_get_x_sensitivity(void);
u32 camera_config_get_y_sensitivity(void);
u32 camera_config_get_aggression(void);
u32 camera_config_get_pan_level(void);
u32 camera_config_get_deceleration(void);
void camera_config_enable_free_cam(bool enable);
void camera_config_enable_analog_cam(bool enable);
void camera_config_enable_mouse_look(bool enable);
void camera_config_invert_x(bool invert);
void camera_config_invert_y(bool invert);
void camera_config_set_x_sensitivity(u32 value);
void camera_config_set_y_sensitivity(u32 value);
void camera_config_set_aggression(u32 value);
void camera_config_set_pan_level(u32 value);
void camera_config_set_deceleration(u32 value);
bool is_game_paused(void);
bool warp_to_level(s32 aLevel, s32 aArea, s32 aAct);