Merge remote-tracking branch 'origin/dev' into console-rework

This commit is contained in:
EmeraldLockdown 2026-04-03 20:26:43 -05:00
commit 0d3d3a5bd6
50 changed files with 586 additions and 254 deletions

View file

@ -120,6 +120,7 @@ override_disallowed_functions = {
"src/game/mario.h": [ " init_mario" ], "src/game/mario.h": [ " init_mario" ],
"src/pc/djui/djui_console.h": [ " djui_console_create", "djui_console_message_create", "djui_console_message_dequeue" ], "src/pc/djui/djui_console.h": [ " djui_console_create", "djui_console_message_create", "djui_console_message_dequeue" ],
"src/pc/djui/djui_chat_message.h": [ "create_from" ], "src/pc/djui/djui_chat_message.h": [ "create_from" ],
"src/pc/djui/djui_hud_utils.h": [ "djui_hud_clear_interp_data" ],
"src/game/interaction.h": [ "process_interaction", "_handle_" ], "src/game/interaction.h": [ "process_interaction", "_handle_" ],
"src/game/sound_init.h": [ "_loop_", "thread4_", "set_sound_mode" ], "src/game/sound_init.h": [ "_loop_", "thread4_", "set_sound_mode" ],
"src/pc/network/network_utils.h": [ "network_get_player_text_color[^_]" ], "src/pc/network/network_utils.h": [ "network_get_player_text_color[^_]" ],

View file

@ -3843,7 +3843,7 @@ function djui_hud_set_font(fontType)
end end
--- @return DjuiColor --- @return DjuiColor
--- Gets the current DJUI HUD color --- Gets the current DJUI HUD global color
function djui_hud_get_color() function djui_hud_get_color()
-- ... -- ...
end end
@ -3852,16 +3852,36 @@ end
--- @param g integer --- @param g integer
--- @param b integer --- @param b integer
--- @param a integer --- @param a integer
--- Sets the current DJUI HUD color --- Sets the current DJUI HUD global color
function djui_hud_set_color(r, g, b, a) function djui_hud_set_color(r, g, b, a)
-- ... -- ...
end end
--- Resets the current DJUI HUD color --- Resets the current DJUI HUD global color
function djui_hud_reset_color() function djui_hud_reset_color()
-- ... -- ...
end end
--- @return DjuiColor
--- Gets the current DJUI HUD text default color. This color is overridden by color codes
function djui_hud_get_text_color()
-- ...
end
--- @param r integer
--- @param g integer
--- @param b integer
--- @param a integer
--- Sets the current DJUI HUD text default color. This color is overridden by color codes
function djui_hud_set_text_color(r, g, b, a)
-- ...
end
--- Resets the current DJUI HUD text default color. This color is overridden by color codes
function djui_hud_reset_text_color()
-- ...
end
--- @return integer rotation --- @return integer rotation
--- @return number pivotX --- @return number pivotX
--- @return number pivotY --- @return number pivotY
@ -9083,12 +9103,6 @@ function cur_obj_check_anim_frame_in_range(startFrame, rangeLength)
-- ... -- ...
end end
--- @param a0 Pointer_integer
--- @return integer
function cur_obj_check_frame_prior_current_frame(a0)
-- ...
end
--- @param m MarioState --- @param m MarioState
--- @return integer --- @return integer
function mario_is_in_air_action(m) function mario_is_in_air_action(m)

View file

@ -3,7 +3,9 @@
extern "C" { extern "C" {
#include "include/surface_terrains.h" #include "include/surface_terrains.h"
#include "include/level_misc_macros.h" #include "include/level_misc_macros.h"
#include "include/special_presets.h"
#include "include/special_preset_names.h" #include "include/special_preset_names.h"
#include "src/engine/surface_load.h"
} }
// Free data pointers, but keep nodes and tokens intact // Free data pointers, but keep nodes and tokens intact
@ -34,12 +36,32 @@ struct CollisionValidationData {
u32 vtxCount; u32 vtxCount;
u32 triAlloc; u32 triAlloc;
u32 triCount; u32 triCount;
s16 surfaceType;
u32 specialAlloc; u32 specialAlloc;
u32 specialCount; u32 specialCount;
u32 waterBoxAlloc; u32 waterBoxAlloc;
u32 waterBoxCount; u32 waterBoxCount;
}; };
static u8 GetSpecialObjectType(u8 preset) {
for (s32 i = 0; i < ARRAY_COUNT(SpecialObjectPresets); ++i) {
if (SpecialObjectPresets[i].preset_id == preset) {
return SpecialObjectPresets[i].type;
}
}
return SPTYPE_UNKNOWN;
}
static const char *GetCorrectSpecialObjectCommand(u8 presetType) {
switch (presetType) {
case SPTYPE_NO_YROT_OR_PARAMS: return "SPECIAL_OBJECT";
case SPTYPE_YROT_NO_PARAMS: return "SPECIAL_OBJECT_WITH_YAW";
case SPTYPE_PARAMS_AND_YROT: return "SPECIAL_OBJECT_WITH_YAW_AND_PARAM";
case SPTYPE_DEF_PARAM_AND_YROT: return "SPECIAL_OBJECT_WITH_YAW";
default: return "";
}
}
static void ValidateColSectionChange(GfxData* aGfxData, struct CollisionValidationData& aColValData, u8 section) { static void ValidateColSectionChange(GfxData* aGfxData, struct CollisionValidationData& aColValData, u8 section) {
if (aColValData.section == COL_SECTION_END) { if (aColValData.section == COL_SECTION_END) {
PrintDataError("Found new col section after COL_END"); PrintDataError("Found new col section after COL_END");
@ -67,51 +89,70 @@ static void ValidateColInit(GfxData* aGfxData, struct CollisionValidationData& a
ValidateColSectionChange(aGfxData, aColValData, COL_SECTION_VTX); ValidateColSectionChange(aGfxData, aColValData, COL_SECTION_VTX);
} }
static void ValidateColVertexInit(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 arg0) { static void ValidateColVertexInit(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 vertexCount) {
if (strcmp(aColValData.lastSymbol, "COL_INIT") != 0) { if (strcmp(aColValData.lastSymbol, "COL_INIT") != 0) {
PrintDataError("COL_VERTEX_INIT found outside of vertex section"); PrintDataError("COL_VERTEX_INIT found outside of vertex section");
} }
if (arg0 < 0) { if (vertexCount < 0) {
PrintDataError("COL_VERTEX_INIT with a negative count: %d", arg0); PrintDataError("COL_VERTEX_INIT with a negative count: %d", vertexCount);
} }
aColValData.vtxAlloc = arg0; aColValData.vtxAlloc = vertexCount;
aColValData.vtxCount = 0; aColValData.vtxCount = 0;
} }
static void ValidateColVertex(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 arg0, s16 arg1, s16 arg2) { static void ValidateColVertex(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 x, s16 y, s16 z) {
if (aColValData.section != COL_SECTION_VTX) { if (aColValData.section != COL_SECTION_VTX) {
PrintDataError("COL_VERTEX found outside of vertex section"); PrintDataError("COL_VERTEX found outside of vertex section");
} }
aColValData.vtxCount++; aColValData.vtxCount++;
} }
static void ValidateColTriInit(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 arg0, s16 arg1) { static void ValidateColTriInit(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 surfaceType, s16 triangleCount) {
if (arg1 < 0) { if (triangleCount < 0) {
PrintDataError("COL_TRI_INIT with a negative count: %d", arg1); PrintDataError("COL_TRI_INIT with a negative count: %d", triangleCount);
} }
ValidateColSectionChange(aGfxData, aColValData, COL_SECTION_TRI); ValidateColSectionChange(aGfxData, aColValData, COL_SECTION_TRI);
aColValData.triAlloc = arg1; aColValData.triAlloc = triangleCount;
aColValData.triCount = 0; aColValData.triCount = 0;
aColValData.surfaceType = surfaceType;
} }
static void ValidateColTri(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 arg0, s16 arg1, s16 arg2) { static void ValidateColTri(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 vertex0, s16 vertex1, s16 vertex2) {
if (aColValData.section != COL_SECTION_TRI) { if (aColValData.section != COL_SECTION_TRI) {
PrintDataError("COL_TRI found outside of triangle section"); PrintDataError("COL_TRI found outside of triangle section");
} }
if (arg0 < 0 || arg0 > aColValData.vtxCount) { if (surface_has_force(aColValData.surfaceType)) {
PrintDataError("COL_TRI used vertex outside of known range for first param: %d", arg0); PrintDataError("COL_TRI cannot be used by surface types with a force parameter: %d (use COL_TRI_SPECIAL instead)", aColValData.surfaceType);
} }
if (arg1 < 0 || arg1 > aColValData.vtxCount) { if (vertex0 < 0 || vertex0 > aColValData.vtxCount) {
PrintDataError("COL_TRI used vertex outside of known range for second param: %d", arg1); PrintDataError("COL_TRI used vertex outside of known range for first param: %d", vertex0);
} }
if (arg2 < 0 || arg2 > aColValData.vtxCount) { if (vertex1 < 0 || vertex1 > aColValData.vtxCount) {
PrintDataError("COL_TRI used vertex outside of known range for third param: %d", arg2); PrintDataError("COL_TRI used vertex outside of known range for second param: %d", vertex1);
}
if (vertex2 < 0 || vertex2 > aColValData.vtxCount) {
PrintDataError("COL_TRI used vertex outside of known range for third param: %d", vertex2);
} }
aColValData.triCount++; aColValData.triCount++;
} }
static void ValidateColTriSpecial(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 arg0, s16 arg1, s16 arg2, s16 arg3) { static void ValidateColTriSpecial(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 vertex0, s16 vertex1, s16 vertex2, s16 force) {
ValidateColTri(aGfxData, aColValData, arg0, arg1, arg2); if (aColValData.section != COL_SECTION_TRI) {
PrintDataError("COL_TRI_SPECIAL found outside of triangle section");
}
if (!surface_has_force(aColValData.surfaceType)) {
PrintDataError("COL_TRI_SPECIAL cannot be used by surface types with no force parameter: %d (use COL_TRI instead)", aColValData.surfaceType);
}
if (vertex0 < 0 || vertex0 > aColValData.vtxCount) {
PrintDataError("COL_TRI_SPECIAL used vertex outside of known range for first param: %d", vertex0);
}
if (vertex1 < 0 || vertex1 > aColValData.vtxCount) {
PrintDataError("COL_TRI_SPECIAL used vertex outside of known range for second param: %d", vertex1);
}
if (vertex2 < 0 || vertex2 > aColValData.vtxCount) {
PrintDataError("COL_TRI_SPECIAL used vertex outside of known range for third param: %d", vertex2);
}
aColValData.triCount++;
} }
static void ValidateColStop(GfxData* aGfxData, struct CollisionValidationData& aColValData) { static void ValidateColStop(GfxData* aGfxData, struct CollisionValidationData& aColValData) {
@ -122,49 +163,70 @@ static void ValidateColEnd(GfxData* aGfxData, struct CollisionValidationData& aC
ValidateColSectionChange(aGfxData, aColValData, COL_SECTION_END); ValidateColSectionChange(aGfxData, aColValData, COL_SECTION_END);
} }
static void ValidateColSpecialInit(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 arg0) { static void ValidateColSpecialInit(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 specialCount) {
if (arg0 < 0) { if (specialCount < 0) {
PrintDataError("COL_SPECIAL_INIT with a negative count: %d", arg0); PrintDataError("COL_SPECIAL_INIT with a negative count: %d", specialCount);
} }
ValidateColSectionChange(aGfxData, aColValData, COL_SECTION_SPECIAL); ValidateColSectionChange(aGfxData, aColValData, COL_SECTION_SPECIAL);
aColValData.specialAlloc = arg0; aColValData.specialAlloc = specialCount;
aColValData.specialCount = 0; aColValData.specialCount = 0;
} }
static void ValidateColWaterBoxInit(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 arg0) { static void ValidateColWaterBoxInit(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 waterBoxCount) {
if (arg0 < 0) { if (waterBoxCount < 0) {
PrintDataError("COL_WATER_BOX_INIT with a negative count: %d", arg0); PrintDataError("COL_WATER_BOX_INIT with a negative count: %d", waterBoxCount);
} }
ValidateColSectionChange(aGfxData, aColValData, COL_SECTION_WATER_BOX); ValidateColSectionChange(aGfxData, aColValData, COL_SECTION_WATER_BOX);
aColValData.waterBoxAlloc = arg0; aColValData.waterBoxAlloc = waterBoxCount;
aColValData.waterBoxCount = 0; aColValData.waterBoxCount = 0;
} }
static void ValidateColWaterBox(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4, s16 arg5) { static void ValidateColWaterBox(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 id, s16 x1, s16 z1, s16 x2, s16 z2, s16 y) {
if (aColValData.section != COL_SECTION_WATER_BOX) { if (aColValData.section != COL_SECTION_WATER_BOX) {
PrintDataError("COL_WATER_BOX found outside of water box section"); PrintDataError("COL_WATER_BOX found outside of water box section");
} }
aColValData.waterBoxCount++; aColValData.waterBoxCount++;
} }
static void ValidateColSpecialObject(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 arg0, s16 arg1, s16 arg2, s16 arg3) { static void ValidateColSpecialObject(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 preset, s16 posX, s16 posY, s16 posZ) {
if (aColValData.section != COL_SECTION_SPECIAL) { if (aColValData.section != COL_SECTION_SPECIAL) {
PrintDataError("SPECIAL_OBJECT found outside of special section"); PrintDataError("SPECIAL_OBJECT found outside of special section");
} }
aColValData.specialCount++; u8 presetType = GetSpecialObjectType(preset);
} if (presetType == SPTYPE_UNKNOWN) {
PrintDataError("SPECIAL_OBJECT has invalid preset: %d", preset);
static void ValidateColSpecialObjectWithYaw(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4) { }
if (aColValData.section != COL_SECTION_SPECIAL) { if (presetType != SPTYPE_NO_YROT_OR_PARAMS) {
PrintDataError("SPECIAL_OBJECT_WITH_YAW found outside of special section"); PrintDataError("SPECIAL_OBJECT cannot be used with preset: %d (use %s instead)", preset, GetCorrectSpecialObjectCommand(presetType));
} }
aColValData.specialCount++; aColValData.specialCount++;
} }
static void ValidateColSpecialObjectWithYawAndParam(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4, s16 arg5) { static void ValidateColSpecialObjectWithYaw(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 preset, s16 posX, s16 posY, s16 posZ, s16 yaw) {
if (aColValData.section != COL_SECTION_SPECIAL) {
PrintDataError("SPECIAL_OBJECT_WITH_YAW found outside of special section");
}
u8 presetType = GetSpecialObjectType(preset);
if (presetType == SPTYPE_UNKNOWN) {
PrintDataError("SPECIAL_OBJECT_WITH_YAW has invalid preset: %d", preset);
}
if (presetType != SPTYPE_YROT_NO_PARAMS && presetType != SPTYPE_DEF_PARAM_AND_YROT) {
PrintDataError("SPECIAL_OBJECT_WITH_YAW cannot be used with preset: %d (use %s instead)", preset, GetCorrectSpecialObjectCommand(presetType));
}
aColValData.specialCount++;
}
static void ValidateColSpecialObjectWithYawAndParam(GfxData* aGfxData, struct CollisionValidationData& aColValData, s16 preset, s16 posX, s16 posY, s16 posZ, s16 yaw, s16 param) {
if (aColValData.section != COL_SECTION_SPECIAL) { if (aColValData.section != COL_SECTION_SPECIAL) {
PrintDataError("SPECIAL_OBJECT_WITH_YAW_AND_PARAM found outside of special section"); PrintDataError("SPECIAL_OBJECT_WITH_YAW_AND_PARAM found outside of special section");
} }
u8 presetType = GetSpecialObjectType(preset);
if (presetType == SPTYPE_UNKNOWN) {
PrintDataError("SPECIAL_OBJECT_WITH_YAW_AND_PARAM has invalid preset: %d", preset);
}
if (presetType != SPTYPE_PARAMS_AND_YROT) {
PrintDataError("SPECIAL_OBJECT_WITH_YAW_AND_PARAM cannot be used with preset: %d (use %s instead)", preset, GetCorrectSpecialObjectCommand(presetType));
}
aColValData.specialCount++; aColValData.specialCount++;
} }

View file

@ -151,7 +151,7 @@ PackData* DynOS_Pack_Add(const SysPath& aPath) {
const char* displayName = aPath.c_str(); const char* displayName = aPath.c_str();
const char* ctoken = displayName; const char* ctoken = displayName;
while (*ctoken != '\0') { while (*ctoken != '\0') {
if (*ctoken == '/' || *ctoken == '\\') { if (*ctoken == *PATH_SEPARATOR || *ctoken == *PATH_SEPARATOR_ALT) {
if (*(ctoken + 1) != '\0') { if (*(ctoken + 1) != '\0') {
displayName = (ctoken + 1); displayName = (ctoken + 1);
} }

View file

@ -2885,7 +2885,7 @@ Sets the current DJUI HUD font
## [djui_hud_get_color](#djui_hud_get_color) ## [djui_hud_get_color](#djui_hud_get_color)
### Description ### Description
Gets the current DJUI HUD color Gets the current DJUI HUD global color
### Lua Example ### Lua Example
`local djuiColorValue = djui_hud_get_color()` `local djuiColorValue = djui_hud_get_color()`
@ -2906,7 +2906,7 @@ Gets the current DJUI HUD color
## [djui_hud_set_color](#djui_hud_set_color) ## [djui_hud_set_color](#djui_hud_set_color)
### Description ### Description
Sets the current DJUI HUD color Sets the current DJUI HUD global color
### Lua Example ### Lua Example
`djui_hud_set_color(r, g, b, a)` `djui_hud_set_color(r, g, b, a)`
@ -2932,7 +2932,7 @@ Sets the current DJUI HUD color
## [djui_hud_reset_color](#djui_hud_reset_color) ## [djui_hud_reset_color](#djui_hud_reset_color)
### Description ### Description
Resets the current DJUI HUD color Resets the current DJUI HUD global color
### Lua Example ### Lua Example
`djui_hud_reset_color()` `djui_hud_reset_color()`
@ -2950,6 +2950,74 @@ Resets the current DJUI HUD color
<br /> <br />
## [djui_hud_get_text_color](#djui_hud_get_text_color)
### Description
Gets the current DJUI HUD text default color. This color is overridden by color codes
### Lua Example
`local djuiColorValue = djui_hud_get_text_color()`
### Parameters
- None
### Returns
- [DjuiColor](structs.md#DjuiColor)
### C Prototype
`struct DjuiColor* djui_hud_get_text_color(void);`
[:arrow_up_small:](#)
<br />
## [djui_hud_set_text_color](#djui_hud_set_text_color)
### Description
Sets the current DJUI HUD text default color. This color is overridden by color codes
### Lua Example
`djui_hud_set_text_color(r, g, b, a)`
### Parameters
| Field | Type |
| ----- | ---- |
| r | `integer` |
| g | `integer` |
| b | `integer` |
| a | `integer` |
### Returns
- None
### C Prototype
`void djui_hud_set_text_color(u8 r, u8 g, u8 b, u8 a);`
[:arrow_up_small:](#)
<br />
## [djui_hud_reset_text_color](#djui_hud_reset_text_color)
### Description
Resets the current DJUI HUD text default color. This color is overridden by color codes
### Lua Example
`djui_hud_reset_text_color()`
### Parameters
- None
### Returns
- None
### C Prototype
`void djui_hud_reset_text_color(void);`
[:arrow_up_small:](#)
<br />
## [djui_hud_get_rotation](#djui_hud_get_rotation) ## [djui_hud_get_rotation](#djui_hud_get_rotation)
### Description ### Description

View file

@ -1615,26 +1615,6 @@ Multiplies a vector by the transpose of a matrix of the form: `| ? ? ? 0 |` `| ?
<br /> <br />
## [cur_obj_check_frame_prior_current_frame](#cur_obj_check_frame_prior_current_frame)
### Lua Example
`local integerValue = cur_obj_check_frame_prior_current_frame(a0)`
### Parameters
| Field | Type |
| ----- | ---- |
| a0 | `Pointer` <`integer`> |
### Returns
- `integer`
### C Prototype
`s32 cur_obj_check_frame_prior_current_frame(s16 *a0);`
[:arrow_up_small:](#)
<br />
## [mario_is_in_air_action](#mario_is_in_air_action) ## [mario_is_in_air_action](#mario_is_in_air_action)
### Lua Example ### Lua Example

View file

@ -765,6 +765,9 @@
- [djui_hud_get_color](functions-3.md#djui_hud_get_color) - [djui_hud_get_color](functions-3.md#djui_hud_get_color)
- [djui_hud_set_color](functions-3.md#djui_hud_set_color) - [djui_hud_set_color](functions-3.md#djui_hud_set_color)
- [djui_hud_reset_color](functions-3.md#djui_hud_reset_color) - [djui_hud_reset_color](functions-3.md#djui_hud_reset_color)
- [djui_hud_get_text_color](functions-3.md#djui_hud_get_text_color)
- [djui_hud_set_text_color](functions-3.md#djui_hud_set_text_color)
- [djui_hud_reset_text_color](functions-3.md#djui_hud_reset_text_color)
- [djui_hud_get_rotation](functions-3.md#djui_hud_get_rotation) - [djui_hud_get_rotation](functions-3.md#djui_hud_get_rotation)
- [djui_hud_set_rotation](functions-3.md#djui_hud_set_rotation) - [djui_hud_set_rotation](functions-3.md#djui_hud_set_rotation)
- [djui_hud_set_rotation_interpolated](functions-3.md#djui_hud_set_rotation_interpolated) - [djui_hud_set_rotation_interpolated](functions-3.md#djui_hud_set_rotation_interpolated)
@ -1614,7 +1617,6 @@
- [cur_obj_check_if_at_animation_end](functions-6.md#cur_obj_check_if_at_animation_end) - [cur_obj_check_if_at_animation_end](functions-6.md#cur_obj_check_if_at_animation_end)
- [cur_obj_check_anim_frame](functions-6.md#cur_obj_check_anim_frame) - [cur_obj_check_anim_frame](functions-6.md#cur_obj_check_anim_frame)
- [cur_obj_check_anim_frame_in_range](functions-6.md#cur_obj_check_anim_frame_in_range) - [cur_obj_check_anim_frame_in_range](functions-6.md#cur_obj_check_anim_frame_in_range)
- [cur_obj_check_frame_prior_current_frame](functions-6.md#cur_obj_check_frame_prior_current_frame)
- [mario_is_in_air_action](functions-6.md#mario_is_in_air_action) - [mario_is_in_air_action](functions-6.md#mario_is_in_air_action)
- [mario_is_dive_sliding](functions-6.md#mario_is_dive_sliding) - [mario_is_dive_sliding](functions-6.md#mario_is_dive_sliding)
- [cur_obj_set_y_vel_and_animation](functions-6.md#cur_obj_set_y_vel_and_animation) - [cur_obj_set_y_vel_and_animation](functions-6.md#cur_obj_set_y_vel_and_animation)

View file

@ -100,6 +100,7 @@ N64_BINDS = "N64 Ovládání"
EXTRA_BINDS = "Extra Ovládání" EXTRA_BINDS = "Extra Ovládání"
BACKGROUND_GAMEPAD = "Ovladač v pozadí" BACKGROUND_GAMEPAD = "Ovladač v pozadí"
DISABLE_GAMEPADS = "Zakažte gamepady" DISABLE_GAMEPADS = "Zakažte gamepady"
EXTENDED_REPORTS = "Rozšířené zprávy"
GAMEPAD = "Použít ovladač" GAMEPAD = "Použít ovladač"
DEADZONE = "Deadzone" DEADZONE = "Deadzone"
RUMBLE_STRENGTH = "Síla vibrace" RUMBLE_STRENGTH = "Síla vibrace"

View file

@ -100,6 +100,7 @@ N64_BINDS = "N64 Toetsen"
EXTRA_BINDS = "Extra Toetsen" EXTRA_BINDS = "Extra Toetsen"
BACKGROUND_GAMEPAD = "Achtergrond Gamepad" BACKGROUND_GAMEPAD = "Achtergrond Gamepad"
DISABLE_GAMEPADS = "Gamepads uitschakelen" DISABLE_GAMEPADS = "Gamepads uitschakelen"
EXTENDED_REPORTS = "Uitgebreide rapporten"
GAMEPAD = "Gamepad" GAMEPAD = "Gamepad"
DEADZONE = "Doode-zone" DEADZONE = "Doode-zone"
RUMBLE_STRENGTH = "Rommel Kracht" RUMBLE_STRENGTH = "Rommel Kracht"

View file

@ -100,6 +100,7 @@ N64_BINDS = "N64 Binds"
EXTRA_BINDS = "Extra Binds" EXTRA_BINDS = "Extra Binds"
BACKGROUND_GAMEPAD = "Background Gamepad" BACKGROUND_GAMEPAD = "Background Gamepad"
DISABLE_GAMEPADS = "Disable Gamepads" DISABLE_GAMEPADS = "Disable Gamepads"
EXTENDED_REPORTS = "Extended Reports"
GAMEPAD = "Gamepad" GAMEPAD = "Gamepad"
DEADZONE = "Deadzone" DEADZONE = "Deadzone"
RUMBLE_STRENGTH = "Rumble Strength" RUMBLE_STRENGTH = "Rumble Strength"

View file

@ -100,6 +100,7 @@ N64_BINDS = "Touches N64"
EXTRA_BINDS = "Touches Supplémentaires" EXTRA_BINDS = "Touches Supplémentaires"
BACKGROUND_GAMEPAD = "Manette en arrière plan" BACKGROUND_GAMEPAD = "Manette en arrière plan"
DISABLE_GAMEPADS = "Désactiver les manettes de jeu" DISABLE_GAMEPADS = "Désactiver les manettes de jeu"
EXTENDED_REPORTS = "Rapports détaillés"
GAMEPAD = "Manette" GAMEPAD = "Manette"
DEADZONE = "Zone Morte" DEADZONE = "Zone Morte"
RUMBLE_STRENGTH = "Vibrations" RUMBLE_STRENGTH = "Vibrations"

View file

@ -99,6 +99,7 @@ CONTROLS = "STEUERUNG"
N64_BINDS = "N64-Einstellungen" N64_BINDS = "N64-Einstellungen"
EXTRA_BINDS = "Zusätzliche Einstellungen" EXTRA_BINDS = "Zusätzliche Einstellungen"
BACKGROUND_GAMEPAD = "Hintergrund-Gamepad" BACKGROUND_GAMEPAD = "Hintergrund-Gamepad"
EXTENDED_REPORTS = "Erweiterte Berichte"
DISABLE_GAMEPADS = "Gamepads deaktivieren" DISABLE_GAMEPADS = "Gamepads deaktivieren"
GAMEPAD = "Gamepad" GAMEPAD = "Gamepad"
DEADZONE = "Tote Zone" DEADZONE = "Tote Zone"

View file

@ -98,6 +98,7 @@ CONTROLS = "CONTROLLI"
N64_BINDS = "Comandi N64" N64_BINDS = "Comandi N64"
EXTRA_BINDS = "Comandi Extra" EXTRA_BINDS = "Comandi Extra"
BACKGROUND_GAMEPAD = "Attivi in Background" BACKGROUND_GAMEPAD = "Attivi in Background"
EXTENDED_REPORTS = "Rapporti estesi"
DISABLE_GAMEPADS = "Disabilita i Gamepad" DISABLE_GAMEPADS = "Disabilita i Gamepad"
GAMEPAD = "Controller" GAMEPAD = "Controller"
DEADZONE = "Zona Morta" DEADZONE = "Zona Morta"

View file

@ -99,6 +99,7 @@ CONTROLS = "CONTROLS"
N64_BINDS = "ニンテンドウ64のボタン割り当て" N64_BINDS = "ニンテンドウ64のボタン割り当て"
EXTRA_BINDS = "追加のボタン割り当て" EXTRA_BINDS = "追加のボタン割り当て"
BACKGROUND_GAMEPAD = "バックグラウンドでのコントローラー認識" BACKGROUND_GAMEPAD = "バックグラウンドでのコントローラー認識"
EXTENDED_REPORTS = "拡張レポート"
DISABLE_GAMEPADS = "コントローラーを無効化" DISABLE_GAMEPADS = "コントローラーを無効化"
GAMEPAD = "コントローラー" GAMEPAD = "コントローラー"
DEADZONE = "デッドゾーン" DEADZONE = "デッドゾーン"

View file

@ -99,6 +99,7 @@ CONTROLS = "STEROWANIE"
N64_BINDS = "Przypisania N64" N64_BINDS = "Przypisania N64"
EXTRA_BINDS = "Dodatkowe Przypisania" EXTRA_BINDS = "Dodatkowe Przypisania"
BACKGROUND_GAMEPAD = "Gamepad w Tle" BACKGROUND_GAMEPAD = "Gamepad w Tle"
EXTENDED_REPORTS = "Rozszerzone raporty"
DISABLE_GAMEPADS = "Wyłącz Gamepady" DISABLE_GAMEPADS = "Wyłącz Gamepady"
GAMEPAD = "Gamepad" GAMEPAD = "Gamepad"
DEADZONE = "Martwa Strefa" DEADZONE = "Martwa Strefa"

View file

@ -99,6 +99,7 @@ CONTROLS = "CONTROLES"
N64_BINDS = "N64" N64_BINDS = "N64"
EXTRA_BINDS = "Outros" EXTRA_BINDS = "Outros"
BACKGROUND_GAMEPAD = "Controle de fundo" BACKGROUND_GAMEPAD = "Controle de fundo"
EXTENDED_REPORTS = "Relatórios detalhados"
DISABLE_GAMEPADS = "Desativar controles" DISABLE_GAMEPADS = "Desativar controles"
GAMEPAD = "Controle" GAMEPAD = "Controle"
DEADZONE = "Zona morta" DEADZONE = "Zona morta"

View file

@ -98,6 +98,7 @@ CONTROLS = "CONTROLS"
N64_BINDS = "Кнопки N64" N64_BINDS = "Кнопки N64"
EXTRA_BINDS = "Дополнительные кнопки" EXTRA_BINDS = "Дополнительные кнопки"
BACKGROUND_GAMEPAD = "Фоновый ввод" BACKGROUND_GAMEPAD = "Фоновый ввод"
EXTENDED_REPORTS = "Расширенные отчеты"
DISABLE_GAMEPADS = "Отключить геймпады" DISABLE_GAMEPADS = "Отключить геймпады"
GAMEPAD = "Геймпад" GAMEPAD = "Геймпад"
DEADZONE = "Mёртвая зона" DEADZONE = "Mёртвая зона"

View file

@ -100,6 +100,7 @@ N64_BINDS = "Botones de N64"
EXTRA_BINDS = "Botones Adicionales" EXTRA_BINDS = "Botones Adicionales"
BACKGROUND_GAMEPAD = "Mando en segundo plano" BACKGROUND_GAMEPAD = "Mando en segundo plano"
DISABLE_GAMEPADS = "Desactivar mandos" DISABLE_GAMEPADS = "Desactivar mandos"
EXTENDED_REPORTS = "Informes ampliados"
GAMEPAD = "Mando" GAMEPAD = "Mando"
DEADZONE = "Zona muerta" DEADZONE = "Zona muerta"
RUMBLE_STRENGTH = "Intensidad de vibración" RUMBLE_STRENGTH = "Intensidad de vibración"

View file

@ -26,6 +26,7 @@
#include "pc/network/network.h" #include "pc/network/network.h"
#include "pc/lua/smlua_hooks.h" #include "pc/lua/smlua_hooks.h"
#include "pc/djui/djui.h" #include "pc/djui/djui.h"
#include "pc/djui/djui_hud_utils.h"
#include "pc/djui/djui_panel_pause.h" #include "pc/djui/djui_panel_pause.h"
#include "pc/nametags.h" #include "pc/nametags.h"
#include "engine/lighting_engine.h" #include "engine/lighting_engine.h"
@ -254,6 +255,7 @@ void clear_areas(void) {
le_clear(); le_clear();
geo_clear_interp_data(); geo_clear_interp_data();
djui_hud_clear_interp_data();
} }
void clear_area_graph_nodes(void) { void clear_area_graph_nodes(void) {
@ -313,6 +315,7 @@ void unload_area(void) {
le_clear(); le_clear();
geo_clear_interp_data(); geo_clear_interp_data();
djui_hud_clear_interp_data();
} }
void load_mario_area(void) { void load_mario_area(void) {

View file

@ -594,8 +594,6 @@ void thread5_game_loop(UNUSED void *arg) {
play_music(SEQ_PLAYER_SFX, SEQUENCE_ARGS(0, SEQ_SOUND_PLAYER), 0); play_music(SEQ_PLAYER_SFX, SEQUENCE_ARGS(0, SEQ_SOUND_PLAYER), 0);
set_sound_mode(save_file_get_sound_mode()); set_sound_mode(save_file_get_sound_mode());
thread6_rumble_loop(NULL);
gGlobalTimer++; gGlobalTimer++;
} }
@ -609,6 +607,7 @@ void game_loop_one_iteration(void) {
osContStartReadData(&gSIEventMesgQueue); osContStartReadData(&gSIEventMesgQueue);
} }
thread6_rumble_loop(NULL);
audio_game_loop_tick(); audio_game_loop_tick();
config_gfx_pool(); config_gfx_pool();
read_controller_inputs(); read_controller_inputs();

View file

@ -2445,7 +2445,7 @@ void check_death_barrier(struct MarioState *m) {
smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath); smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath);
if (!allowDeath) { return; } if (!allowDeath) { return; }
if (mario_can_bubble(m)) { if ((mario_can_bubble(m) && m->numLives > 0)) {
switch (gCurrCourseNum) { switch (gCurrCourseNum) {
case COURSE_COTMC: // (20) Cavern of the Metal Cap case COURSE_COTMC: // (20) Cavern of the Metal Cap
case COURSE_TOTWC: // (21) Tower of the Wing Cap case COURSE_TOTWC: // (21) Tower of the Wing Cap

View file

@ -43,6 +43,7 @@
#include "pc/configfile.h" #include "pc/configfile.h"
#include "pc/network/network.h" #include "pc/network/network.h"
#include "pc/djui/djui.h" #include "pc/djui/djui.h"
#include "pc/djui/djui_hud_utils.h"
// used for getting gMainMenuSounds // used for getting gMainMenuSounds
#include "pc/djui/djui_panel_menu_options.h" #include "pc/djui/djui_panel_menu_options.h"
#include "pc/lua/smlua_hooks.h" #include "pc/lua/smlua_hooks.h"
@ -878,8 +879,7 @@ void verify_warp(struct MarioState *m, bool killMario) {
return; return;
} }
m->numLives--; if (m->numLives <= 0) {
if (m->numLives < 0) {
sDelayedWarpOp = WARP_OP_GAME_OVER; sDelayedWarpOp = WARP_OP_GAME_OVER;
} else { } else {
sSourceWarpNodeId = WARP_NODE_DEATH; sSourceWarpNodeId = WARP_NODE_DEATH;
@ -934,8 +934,7 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
break; break;
case WARP_OP_DEATH: case WARP_OP_DEATH:
m->numLives--; if (m->numLives <= 0) {
if (m->numLives <= -1) {
sDelayedWarpOp = WARP_OP_GAME_OVER; sDelayedWarpOp = WARP_OP_GAME_OVER;
} }
sDelayedWarpTimer = 48; sDelayedWarpTimer = 48;
@ -1766,6 +1765,7 @@ s32 update_level(void) {
s32 init_level(void) { s32 init_level(void) {
sync_objects_clear(); sync_objects_clear();
geo_clear_interp_data(); geo_clear_interp_data();
djui_hud_clear_interp_data();
reset_dialog_render_state(); reset_dialog_render_state();
s32 val4 = 0; s32 val4 = 0;

View file

@ -447,7 +447,7 @@ void mario_set_bubbled(struct MarioState* m) {
gLocalBubbleCounter = 20; gLocalBubbleCounter = 20;
drop_and_set_mario_action(m, ACT_BUBBLED, 0); drop_and_set_mario_action(m, ACT_BUBBLED, 0);
if (m->numLives > -1) { if (m->numLives > 0) {
m->numLives--; m->numLives--;
} }
m->healCounter = 0; m->healCounter = 0;

View file

@ -1734,7 +1734,7 @@ s32 act_lava_boost(struct MarioState *m) {
return FALSE; return FALSE;
} }
if (mario_can_bubble(m)) { if ((mario_can_bubble(m) && m->numLives > 0)) {
m->health = 0xFF; m->health = 0xFF;
mario_set_bubbled(m); mario_set_bubbled(m);
} else { } else {

View file

@ -849,7 +849,7 @@ s32 common_death_handler(struct MarioState *m, s32 animation, s32 frameToDeathWa
smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath); smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath);
if (!allowDeath) { return animFrame; } if (!allowDeath) { return animFrame; }
if (mario_can_bubble(m)) { if ((mario_can_bubble(m) && m->numLives > 0)) {
mario_set_bubbled(m); mario_set_bubbled(m);
} else { } else {
level_trigger_warp(m, WARP_OP_DEATH); level_trigger_warp(m, WARP_OP_DEATH);
@ -922,8 +922,7 @@ s32 act_quicksand_death(struct MarioState *m) {
bool allowDeath = true; bool allowDeath = true;
smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath); smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath);
if (!allowDeath) { return FALSE; } if (!allowDeath) { return FALSE; }
if ((mario_can_bubble(m) && m->numLives > 0)) {
if (mario_can_bubble(m)) {
mario_set_bubbled(m); mario_set_bubbled(m);
} else { } else {
level_trigger_warp(m, WARP_OP_DEATH); level_trigger_warp(m, WARP_OP_DEATH);
@ -947,7 +946,7 @@ s32 act_eaten_by_bubba(struct MarioState *m) {
smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath); smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath);
if (!allowDeath) { return FALSE; } if (!allowDeath) { return FALSE; }
if (mario_can_bubble(m)) { if ((mario_can_bubble(m) && m->numLives > 0)) {
m->health = 0xFF; m->health = 0xFF;
mario_set_bubbled(m); mario_set_bubbled(m);
} else { } else {
@ -1437,6 +1436,12 @@ s32 act_exit_land_save_dialog(struct MarioState *m) {
return FALSE; return FALSE;
} }
static void lose_life_after_death_exit(struct MarioState *m) {
if (sDelayedWarpArg != WARP_ARG_EXIT_COURSE) {
m->numLives--;
}
}
s32 act_death_exit(struct MarioState *m) { s32 act_death_exit(struct MarioState *m) {
if (!m) { return 0; } if (!m) { return 0; }
if (15 < m->actionTimer++ if (15 < m->actionTimer++
@ -1447,6 +1452,7 @@ s32 act_death_exit(struct MarioState *m) {
play_character_sound(m, CHAR_SOUND_OOOF2); play_character_sound(m, CHAR_SOUND_OOOF2);
#endif #endif
queue_rumble_data_mario(m, 5, 80); queue_rumble_data_mario(m, 5, 80);
lose_life_after_death_exit(m);
// restore 7.75 units of health // restore 7.75 units of health
m->healCounter = 31; m->healCounter = 31;
} }
@ -1463,6 +1469,7 @@ s32 act_unused_death_exit(struct MarioState *m) {
#else #else
play_character_sound(m, CHAR_SOUND_OOOF2); play_character_sound(m, CHAR_SOUND_OOOF2);
#endif #endif
lose_life_after_death_exit(m);
// restore 7.75 units of health // restore 7.75 units of health
m->healCounter = 31; m->healCounter = 31;
} }
@ -1479,6 +1486,7 @@ s32 act_falling_death_exit(struct MarioState *m) {
#else #else
play_character_sound(m, CHAR_SOUND_OOOF2); play_character_sound(m, CHAR_SOUND_OOOF2);
#endif #endif
lose_life_after_death_exit(m);
queue_rumble_data_mario(m, 5, 80); queue_rumble_data_mario(m, 5, 80);
// restore 7.75 units of health // restore 7.75 units of health
m->healCounter = 31; m->healCounter = 31;
@ -1526,6 +1534,7 @@ s32 act_special_death_exit(struct MarioState *m) {
if (launch_mario_until_land(m, ACT_HARD_BACKWARD_GROUND_KB, CHAR_ANIM_BACKWARD_AIR_KB, -24.0f)) { if (launch_mario_until_land(m, ACT_HARD_BACKWARD_GROUND_KB, CHAR_ANIM_BACKWARD_AIR_KB, -24.0f)) {
queue_rumble_data_mario(m, 5, 80); queue_rumble_data_mario(m, 5, 80);
lose_life_after_death_exit(m);
m->healCounter = 31; m->healCounter = 31;
} }
// show Mario // show Mario
@ -1829,7 +1838,7 @@ s32 act_squished(struct MarioState *m) {
smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath); smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath);
if (!allowDeath) { return FALSE; } if (!allowDeath) { return FALSE; }
if (mario_can_bubble(m)) { if ((mario_can_bubble(m) && m->numLives > 0)) {
mario_set_bubbled(m); mario_set_bubbled(m);
} else { } else {
level_trigger_warp(m, WARP_OP_DEATH); level_trigger_warp(m, WARP_OP_DEATH);
@ -1880,7 +1889,7 @@ s32 act_squished(struct MarioState *m) {
smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath); smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath);
if (!allowDeath) { return FALSE; } if (!allowDeath) { return FALSE; }
if (mario_can_bubble(m)) { if ((mario_can_bubble(m) && m->numLives > 0)) {
mario_set_bubbled(m); mario_set_bubbled(m);
} else { } else {
// 0 units of health // 0 units of health

View file

@ -1003,7 +1003,7 @@ static s32 act_drowning(struct MarioState *m) {
smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath); smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath);
if (!allowDeath) { return FALSE; } if (!allowDeath) { return FALSE; }
if (mario_can_bubble(m)) { if ((mario_can_bubble(m) && m->numLives > 0)) {
mario_set_bubbled(m); mario_set_bubbled(m);
} else { } else {
level_trigger_warp(m, WARP_OP_DEATH); level_trigger_warp(m, WARP_OP_DEATH);
@ -1038,7 +1038,7 @@ static s32 act_water_death(struct MarioState *m) {
smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath); smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath);
if (!allowDeath) { return FALSE; } if (!allowDeath) { return FALSE; }
if (mario_can_bubble(m)) { if ((mario_can_bubble(m) && m->numLives > 0)) {
mario_set_bubbled(m); mario_set_bubbled(m);
} else { } else {
level_trigger_warp(m, WARP_OP_DEATH); level_trigger_warp(m, WARP_OP_DEATH);
@ -1164,7 +1164,7 @@ static s32 act_caught_in_whirlpool(struct MarioState *m) {
smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath); smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath);
if (!allowDeath) { reset_rumble_timers(m); return FALSE; } if (!allowDeath) { reset_rumble_timers(m); return FALSE; }
if (mario_can_bubble(m)) { if ((mario_can_bubble(m) && m->numLives > 0)) {
mario_set_bubbled(m); mario_set_bubbled(m);
} else { } else {
level_trigger_warp(m, WARP_OP_DEATH); level_trigger_warp(m, WARP_OP_DEATH);

View file

@ -185,10 +185,42 @@ void growing_pool_free_pool(struct GrowingPool *pool) {
// growing array // // growing array //
/////////////////// ///////////////////
static void growing_array_free_elements(struct GrowingArray *array) {
if (array) {
if (array->buffer) {
for (u32 i = 0; i != array->capacity; ++i) {
if (array->buffer[i]) {
array->free(array->buffer[i]);
}
}
memset(array->buffer, 0, sizeof(void *) * array->capacity);
}
array->count = 0;
}
}
struct GrowingArray *growing_array_init(struct GrowingArray *array, u32 capacity, GrowingArrayAllocFunc alloc, GrowingArrayFreeFunc free) { struct GrowingArray *growing_array_init(struct GrowingArray *array, u32 capacity, GrowingArrayAllocFunc alloc, GrowingArrayFreeFunc free) {
growing_array_free(&array); growing_array_free_elements(array);
array = calloc(1, sizeof(struct GrowingArray));
array->buffer = calloc(capacity, sizeof(void *)); // reuse buffer if array was already allocated
if (array) {
if (!array->buffer || array->capacity != capacity) {
void **buffer = realloc(array->buffer, sizeof(void *) * capacity);
// if realloc fails, destroy the array and create a new one
if (!buffer) {
growing_array_free(&array);
return growing_array_init(NULL, capacity, alloc, free);
}
memset(buffer, 0, sizeof(void *) * capacity);
array->buffer = buffer;
}
} else {
array = malloc(sizeof(struct GrowingArray));
array->buffer = calloc(capacity, sizeof(void *));
}
array->capacity = capacity; array->capacity = capacity;
array->count = 0; array->count = 0;
array->alloc = alloc; array->alloc = alloc;
@ -248,11 +280,7 @@ void growing_array_move(struct GrowingArray *array, u32 from, u32 to, u32 count)
void growing_array_free(struct GrowingArray **array) { void growing_array_free(struct GrowingArray **array) {
if (*array) { if (*array) {
for (u32 i = 0; i != (*array)->capacity; ++i) { growing_array_free_elements(*array);
if ((*array)->buffer[i]) {
(*array)->free((*array)->buffer[i]);
}
}
free((*array)->buffer); free((*array)->buffer);
free(*array); free(*array);
*array = NULL; *array = NULL;

View file

@ -1333,21 +1333,6 @@ s32 cur_obj_check_anim_frame_in_range(s32 startFrame, s32 rangeLength) {
} }
} }
s32 cur_obj_check_frame_prior_current_frame(s16 *a0) {
if (!o) { return 0; }
s16 sp6 = o->header.gfx.animInfo.animFrame;
while (*a0 != -1) {
if (*a0 == sp6) {
return TRUE;
}
a0++;
}
return FALSE;
}
s32 mario_is_in_air_action(struct MarioState* m) { s32 mario_is_in_air_action(struct MarioState* m) {
if (!m) { return 0; } if (!m) { return 0; }
if (m->action & ACT_FLAG_AIR) { if (m->action & ACT_FLAG_AIR) {

View file

@ -158,7 +158,6 @@ s32 cur_obj_check_if_near_animation_end(void);
s32 cur_obj_check_if_at_animation_end(void); s32 cur_obj_check_if_at_animation_end(void);
s32 cur_obj_check_anim_frame(s32 frame); s32 cur_obj_check_anim_frame(s32 frame);
s32 cur_obj_check_anim_frame_in_range(s32 startFrame, s32 rangeLength); s32 cur_obj_check_anim_frame_in_range(s32 startFrame, s32 rangeLength);
s32 cur_obj_check_frame_prior_current_frame(s16 *a0);
s32 mario_is_in_air_action(struct MarioState* m); s32 mario_is_in_air_action(struct MarioState* m);
s32 mario_is_dive_sliding(struct MarioState* m); s32 mario_is_dive_sliding(struct MarioState* m);
void cur_obj_set_y_vel_and_animation(f32 sp18, s32 sp1C); void cur_obj_set_y_vel_and_animation(f32 sp18, s32 sp1C);

View file

@ -25,6 +25,7 @@
#include "engine/math_util.h" #include "engine/math_util.h"
#include "pc/network/network.h" #include "pc/network/network.h"
#include "pc/lua/smlua.h" #include "pc/lua/smlua.h"
#include "pc/djui/djui_hud_utils.h"
/** /**
* Flags controlling what debug info is displayed. * Flags controlling what debug info is displayed.
@ -605,6 +606,7 @@ void clear_objects(void) {
clear_dynamic_surfaces(); clear_dynamic_surfaces();
geo_clear_interp_data(); geo_clear_interp_data();
djui_hud_clear_interp_data();
} }
/** /**

View file

@ -127,6 +127,7 @@ unsigned int configStickDeadzone = 16;
unsigned int configRumbleStrength = 50; unsigned int configRumbleStrength = 50;
unsigned int configGamepadNumber = 0; unsigned int configGamepadNumber = 0;
bool configBackgroundGamepad = true; bool configBackgroundGamepad = true;
bool configExtendedReports = false;
bool configDisableGamepads = false; bool configDisableGamepads = false;
bool configUseStandardKeyBindingsChat = false; bool configUseStandardKeyBindingsChat = false;
bool configSmoothScrolling = false; bool configSmoothScrolling = false;
@ -270,6 +271,7 @@ static const struct ConfigOption options[] = {
{.name = "rumble_strength", .type = CONFIG_TYPE_UINT, .uintValue = &configRumbleStrength}, {.name = "rumble_strength", .type = CONFIG_TYPE_UINT, .uintValue = &configRumbleStrength},
{.name = "gamepad_number", .type = CONFIG_TYPE_UINT, .uintValue = &configGamepadNumber}, {.name = "gamepad_number", .type = CONFIG_TYPE_UINT, .uintValue = &configGamepadNumber},
{.name = "background_gamepad", .type = CONFIG_TYPE_UINT, .boolValue = &configBackgroundGamepad}, {.name = "background_gamepad", .type = CONFIG_TYPE_UINT, .boolValue = &configBackgroundGamepad},
{.name = "extended_reports", .type = CONFIG_TYPE_BOOL, .boolValue = &configExtendedReports},
#ifndef HANDHELD #ifndef HANDHELD
{.name = "disable_gamepads", .type = CONFIG_TYPE_BOOL, .boolValue = &configDisableGamepads}, {.name = "disable_gamepads", .type = CONFIG_TYPE_BOOL, .boolValue = &configDisableGamepads},
#endif #endif

View file

@ -93,6 +93,7 @@ extern unsigned int configStickDeadzone;
extern unsigned int configRumbleStrength; extern unsigned int configRumbleStrength;
extern unsigned int configGamepadNumber; extern unsigned int configGamepadNumber;
extern bool configBackgroundGamepad; extern bool configBackgroundGamepad;
extern bool configExtendedReports;
extern bool configDisableGamepads; extern bool configDisableGamepads;
extern bool configUseStandardKeyBindingsChat; extern bool configUseStandardKeyBindingsChat;
extern bool configSmoothScrolling; extern bool configSmoothScrolling;

View file

@ -40,6 +40,7 @@ static SDL_GameController *sdl_cntrl = NULL;
static SDL_Joystick *sdl_joystick = NULL; static SDL_Joystick *sdl_joystick = NULL;
static SDL_Haptic *sdl_haptic = NULL; static SDL_Haptic *sdl_haptic = NULL;
static bool sExtendedReports = false;
static bool sBackgroundGamepad = false; static bool sBackgroundGamepad = false;
static u32 num_joy_binds = 0; static u32 num_joy_binds = 0;
@ -102,6 +103,13 @@ static void controller_sdl_bind(void) {
} }
static void controller_sdl_init(void) { static void controller_sdl_init(void) {
// Allows extended reports on PS4 and PS5 controllers
if (configExtendedReports) {
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1");
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");
}
sExtendedReports = configExtendedReports;
// Allows game to be controlled by gamepad when not in focus // Allows game to be controlled by gamepad when not in focus
if (configBackgroundGamepad) { if (configBackgroundGamepad) {
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
@ -200,6 +208,13 @@ static void controller_sdl_read(OSContPad *pad) {
// remember buttons that changed from 0 to 1 // remember buttons that changed from 0 to 1
last_mouse = (mouse_prev ^ mouse) & mouse; last_mouse = (mouse_prev ^ mouse) & mouse;
if (configExtendedReports != sExtendedReports) {
sExtendedReports = configExtendedReports;
char* hint = sExtendedReports ? "1" : "0";
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, hint);
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, hint);
}
if (configBackgroundGamepad != sBackgroundGamepad) { if (configBackgroundGamepad != sBackgroundGamepad) {
sBackgroundGamepad = configBackgroundGamepad; sBackgroundGamepad = configBackgroundGamepad;
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, sBackgroundGamepad ? "1" : "0"); SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, sBackgroundGamepad ? "1" : "0");

View file

@ -217,12 +217,12 @@ static void crash_handler_produce_one_frame_callback(void) {
if (font->textBeginDisplayList != NULL) { if (font->textBeginDisplayList != NULL) {
gSPDisplayList(gDisplayListHead++, font->textBeginDisplayList); gSPDisplayList(gDisplayListHead++, font->textBeginDisplayList);
} }
gDPSetPrimColor(gDisplayListHead++, 0, 0, 255, 255, 255, 255);
for (CrashHandlerText* text = sCrashHandlerText; text->s[0] != 0; ++text) { for (CrashHandlerText* text = sCrashHandlerText; text->s[0] != 0; ++text) {
s32 x = GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(text->x * aspectScale); s32 x = GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(text->x * aspectScale);
s32 y = SCREEN_HEIGHT - 8 - text->y * aspectScale; s32 y = SCREEN_HEIGHT - 8 - text->y * aspectScale;
gDPPipeSync(gDisplayListHead++); gDPPipeSync(gDisplayListHead++);
gDPSetEnvColor(gDisplayListHead++, text->r, text->g, text->b, 0xFF);
create_dl_translation_matrix(DJUI_MTX_PUSH, x, y, 0); create_dl_translation_matrix(DJUI_MTX_PUSH, x, y, 0);
// translate scale // translate scale

View file

@ -171,6 +171,7 @@ void djui_reset_hud_params(void) {
djui_hud_set_rotation(0, ROTATION_PIVOT_X_LEFT, ROTATION_PIVOT_Y_TOP); djui_hud_set_rotation(0, ROTATION_PIVOT_X_LEFT, ROTATION_PIVOT_Y_TOP);
djui_hud_set_text_alignment(TEXT_HALIGN_LEFT, TEXT_VALIGN_TOP); djui_hud_set_text_alignment(TEXT_HALIGN_LEFT, TEXT_VALIGN_TOP);
djui_hud_reset_color(); djui_hud_reset_color();
djui_hud_reset_text_color();
djui_hud_set_filter(FILTER_NEAREST); djui_hud_set_filter(FILTER_NEAREST);
djui_hud_reset_viewport(); djui_hud_reset_viewport();
djui_hud_reset_scissor(); djui_hud_reset_scissor();

View file

@ -166,7 +166,8 @@ void djui_gfx_render_texture_tile(const Texture* texture, u32 w, u32 h, u8 fmt,
void djui_gfx_render_texture_font_begin() { void djui_gfx_render_texture_font_begin() {
gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING | G_CULL_BOTH); gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING | G_CULL_BOTH);
gDPSetCombineMode(gDisplayListHead++, G_CC_FADEA, G_CC_FADEA); gDPSetCombineMode(gDisplayListHead++, G_CC_FADEA, G_CC_MODULATERGBA_PRIM2);
gDPSetCycleType(gDisplayListHead++, G_CYC_2CYCLE);
gDPSetRenderMode(gDisplayListHead++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetRenderMode(gDisplayListHead++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
gDPSetTextureFilter(gDisplayListHead++, djui_hud_get_filter() ? G_TF_BILERP : G_TF_POINT); gDPSetTextureFilter(gDisplayListHead++, djui_hud_get_filter() ? G_TF_BILERP : G_TF_POINT);
gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
@ -193,12 +194,14 @@ void djui_gfx_render_texture_font(const Texture* texture, u32 w, u32 h, u8 fmt,
void djui_gfx_render_texture_font_end() { void djui_gfx_render_texture_font_end() {
gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF); gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF);
gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE);
gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE);
gSPSetGeometryMode(gDisplayListHead++, G_LIGHTING | G_CULL_BACK); gSPSetGeometryMode(gDisplayListHead++, G_LIGHTING | G_CULL_BACK);
} }
void djui_gfx_render_texture_tile_font_begin() { void djui_gfx_render_texture_tile_font_begin() {
gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING | G_CULL_BOTH); gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING | G_CULL_BOTH);
gDPSetCombineMode(gDisplayListHead++, G_CC_FADEA, G_CC_FADEA); gDPSetCombineMode(gDisplayListHead++, G_CC_FADEA, G_CC_MODULATERGBA_PRIM2);
gDPSetCycleType(gDisplayListHead++, G_CYC_2CYCLE);
gDPSetRenderMode(gDisplayListHead++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetRenderMode(gDisplayListHead++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
gDPSetTextureFilter(gDisplayListHead++, G_TF_POINT); gDPSetTextureFilter(gDisplayListHead++, G_TF_POINT);
gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
@ -243,6 +246,7 @@ void djui_gfx_render_texture_tile_font(const Texture* texture, u32 w, u32 h, u8
void djui_gfx_render_texture_tile_font_end() { void djui_gfx_render_texture_tile_font_end() {
gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF); gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF);
gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE);
gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE);
gSPSetGeometryMode(gDisplayListHead++, G_LIGHTING | G_CULL_BACK); gSPSetGeometryMode(gDisplayListHead++, G_LIGHTING | G_CULL_BACK);
} }

View file

@ -35,6 +35,7 @@ struct HudUtilsState {
enum HudUtilsFilter filter; enum HudUtilsFilter filter;
enum DjuiFontType font; enum DjuiFontType font;
struct DjuiColor color; struct DjuiColor color;
struct DjuiColor textColor;
struct { struct {
InterpFieldF32 degrees; InterpFieldF32 degrees;
InterpFieldF32 pivotX; InterpFieldF32 pivotX;
@ -51,6 +52,7 @@ static struct HudUtilsState sHudUtilsState = {
.filter = FILTER_NEAREST, .filter = FILTER_NEAREST,
.font = FONT_NORMAL, .font = FONT_NORMAL,
.color = { 255, 255, 255, 255 }, .color = { 255, 255, 255, 255 },
.textColor = { 255, 255, 255, 255 },
.rotation = { .rotation = {
.degrees = INTERP_INIT(0), .degrees = INTERP_INIT(0),
.pivotX = INTERP_INIT(ROTATION_PIVOT_X_LEFT), .pivotX = INTERP_INIT(ROTATION_PIVOT_X_LEFT),
@ -63,6 +65,7 @@ static struct HudUtilsState sHudUtilsState = {
}; };
static struct DjuiColor sRefColor = { 255, 255, 255, 255 }; static struct DjuiColor sRefColor = { 255, 255, 255, 255 };
static struct DjuiColor sRefTextColor = { 255, 255, 255, 255 };
f32 gDjuiHudUtilsZ = 0; f32 gDjuiHudUtilsZ = 0;
bool gDjuiHudLockMouse = false; bool gDjuiHudLockMouse = false;
@ -144,8 +147,6 @@ static void djui_hud_translate_positions(f32 *outX, f32 *outY, f32 *outW, f32 *o
// interp // // interp //
//////////// ////////////
#define MAX_INTERP_HUD 512
enum InterpHudType { enum InterpHudType {
INTERP_HUD_TRANSLATION, INTERP_HUD_TRANSLATION,
INTERP_HUD_ROTATION, INTERP_HUD_ROTATION,
@ -170,9 +171,16 @@ struct InterpHud {
struct GrowingArray *gfx; struct GrowingArray *gfx;
}; };
static struct InterpHud sInterpHuds[MAX_INTERP_HUD] = { 0 }; static struct GrowingArray *sInterpHuds = NULL;
static u16 sInterpHudCount = 0; static u32 sInterpHudCount = 0;
static u8 sColorAltered = FALSE;
static void interp_hud_free(void *ptr) {
struct InterpHud *interp = ptr;
if (interp) {
growing_array_free(&interp->gfx);
free(interp);
}
}
void patch_djui_hud_before(void) { void patch_djui_hud_before(void) {
sInterpHudCount = 0; sInterpHudCount = 0;
@ -183,8 +191,8 @@ void patch_djui_hud(f32 delta) {
Gfx* savedHeadPos = gDisplayListHead; Gfx* savedHeadPos = gDisplayListHead;
struct HudUtilsState savedState = sHudUtilsState; struct HudUtilsState savedState = sHudUtilsState;
for (u16 i = 0; i < sInterpHudCount; i++) { for (u32 i = 0; i < sInterpHudCount; i++) {
struct InterpHud* interp = &sInterpHuds[i]; struct InterpHud *interp = sInterpHuds->buffer[i];
f32 x = delta_interpolate_f32(interp->posX.prev, interp->posX.curr, delta); f32 x = delta_interpolate_f32(interp->posX.prev, interp->posX.curr, delta);
f32 y = delta_interpolate_f32(interp->posY.prev, interp->posY.curr, delta); f32 y = delta_interpolate_f32(interp->posY.prev, interp->posY.curr, delta);
@ -260,22 +268,28 @@ void patch_djui_hud(f32 delta) {
gDjuiHudUtilsZ = savedZ; gDjuiHudUtilsZ = savedZ;
} }
struct InterpHud *djui_hud_create_interp() { static struct InterpHud *djui_hud_create_interp() {
if (sInterpHudCount >= MAX_INTERP_HUD) { return NULL; } struct InterpHud *interp = (
sInterpHudCount < sInterpHuds->count ?
sInterpHuds->buffer[sInterpHudCount] :
growing_array_alloc(sInterpHuds, sizeof(struct InterpHud))
);
struct InterpHud *interp = &sInterpHuds[sInterpHudCount++]; if (interp) {
interp->z = gDjuiHudUtilsZ; interp->z = gDjuiHudUtilsZ;
interp->state = sHudUtilsState; interp->state = sHudUtilsState;
if (!interp->gfx) { if (!interp->gfx) {
interp->gfx = growing_array_init(NULL, 8, malloc, free); interp->gfx = growing_array_init(NULL, 8, malloc, free);
} else { } else {
interp->gfx->count = 0; interp->gfx->count = 0;
}
sInterpHudCount++;
} }
return interp; return interp;
} }
InterpHudGfx *djui_hud_create_interp_gfx(struct InterpHud *interp, enum InterpHudType type) { static InterpHudGfx *djui_hud_create_interp_gfx(struct InterpHud *interp, enum InterpHudType type) {
if (!interp) { return NULL; } if (!interp) { return NULL; }
InterpHudGfx *gfx = growing_array_alloc(interp->gfx, sizeof(InterpHudGfx)); InterpHudGfx *gfx = growing_array_alloc(interp->gfx, sizeof(InterpHudGfx));
@ -284,6 +298,11 @@ InterpHudGfx *djui_hud_create_interp_gfx(struct InterpHud *interp, enum InterpHu
return gfx; return gfx;
} }
void djui_hud_clear_interp_data() {
sInterpHuds = growing_array_init(sInterpHuds, 16, malloc, interp_hud_free);
sInterpHudCount = 0;
}
//////////// ////////////
// others // // others //
//////////// ////////////
@ -328,19 +347,37 @@ void djui_hud_set_color(u8 r, u8 g, u8 b, u8 a) {
sHudUtilsState.color.g = g; sHudUtilsState.color.g = g;
sHudUtilsState.color.b = b; sHudUtilsState.color.b = b;
sHudUtilsState.color.a = a; sHudUtilsState.color.a = a;
sColorAltered = TRUE;
gDPSetEnvColor(gDisplayListHead++, r, g, b, a); gDPSetEnvColor(gDisplayListHead++, r, g, b, a);
} }
void djui_hud_reset_color(void) { void djui_hud_reset_color(void) {
if (sColorAltered) { sHudUtilsState.color.r = 255;
sHudUtilsState.color.r = 255; sHudUtilsState.color.g = 255;
sHudUtilsState.color.g = 255; sHudUtilsState.color.b = 255;
sHudUtilsState.color.b = 255; sHudUtilsState.color.a = 255;
sHudUtilsState.color.a = 255; gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255);
sColorAltered = FALSE; }
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255);
} struct DjuiColor* djui_hud_get_text_color(void) {
sRefTextColor.r = sHudUtilsState.textColor.r;
sRefTextColor.g = sHudUtilsState.textColor.g;
sRefTextColor.b = sHudUtilsState.textColor.b;
sRefTextColor.a = sHudUtilsState.textColor.a;
return &sRefTextColor;
}
void djui_hud_set_text_color(u8 r, u8 g, u8 b, u8 a) {
sHudUtilsState.textColor.r = r;
sHudUtilsState.textColor.g = g;
sHudUtilsState.textColor.b = b;
sHudUtilsState.textColor.a = a;
}
void djui_hud_reset_text_color(void) {
sHudUtilsState.textColor.r = 255;
sHudUtilsState.textColor.g = 255;
sHudUtilsState.textColor.b = 255;
sHudUtilsState.textColor.a = 255;
} }
void djui_hud_get_rotation(RET s16 *rotation, RET f32 *pivotX, RET f32 *pivotY) { void djui_hud_get_rotation(RET s16 *rotation, RET f32 *pivotX, RET f32 *pivotY) {
@ -533,8 +570,6 @@ static void djui_hud_print_text_internal(const char* message, f32 x, f32 y, f32
if (message == NULL) { return; } if (message == NULL) { return; }
gDjuiHudUtilsZ += 0.001f; gDjuiHudUtilsZ += 0.001f;
if (djui_hud_text_font_is_legacy()) { scale *= 0.5f; }
const struct DjuiFont* font = djui_hud_get_text_font(); const struct DjuiFont* font = djui_hud_get_text_font();
f32 fontScale = font->defaultFontScale * scale; f32 fontScale = font->defaultFontScale * scale;
@ -582,13 +617,26 @@ static void djui_hud_print_text_internal(const char* message, f32 x, f32 y, f32
f32 lineWidth = 0; f32 lineWidth = 0;
f32 textHeight = font->lineHeight; f32 textHeight = font->lineHeight;
// apply text color
gDPSetPrimColor(gDisplayListHead++, 0, 0,
sHudUtilsState.textColor.r,
sHudUtilsState.textColor.g,
sHudUtilsState.textColor.b,
sHudUtilsState.textColor.a
);
font->render_begin(); font->render_begin();
while (*c != '\0') { while (*c != '\0') {
// check color code // check color code
struct DjuiColor parsedColor; struct DjuiColor parsedColor;
if (djui_text_parse_color(c, end, false, &sHudUtilsState.color, &c, &parsedColor)) { if (djui_text_parse_color(c, end, false, &sHudUtilsState.textColor, &c, &parsedColor)) {
gDPSetEnvColor(gDisplayListHead++, parsedColor.r, parsedColor.g, parsedColor.b, parsedColor.a); gDPSetPrimColor(gDisplayListHead++, 0, 0,
parsedColor.r,
parsedColor.g,
parsedColor.b,
parsedColor.a
);
continue; continue;
} }
@ -654,13 +702,22 @@ static void djui_hud_print_text_internal(const char* message, f32 x, f32 y, f32
} }
void djui_hud_print_text(const char* message, f32 x, f32 y, f32 scale) { void djui_hud_print_text(const char* message, f32 x, f32 y, f32 scale) {
if (message == NULL) { return; }
if (djui_hud_text_font_is_legacy()) {
scale *= 0.5f;
}
djui_hud_print_text_internal(message, x, y, scale, NULL); djui_hud_print_text_internal(message, x, y, scale, NULL);
} }
void djui_hud_print_text_interpolated(const char* message, f32 prevX, f32 prevY, f32 prevScale, f32 x, f32 y, f32 scale) { void djui_hud_print_text_interpolated(const char* message, f32 prevX, f32 prevY, f32 prevScale, f32 x, f32 y, f32 scale) {
if (message == NULL) { return; } if (message == NULL) { return; }
if (djui_hud_text_font_is_legacy()) { prevScale *= 0.5f; } if (djui_hud_text_font_is_legacy()) {
scale *= 0.5f;
prevScale *= 0.5f;
}
struct InterpHud *interp = djui_hud_create_interp(); struct InterpHud *interp = djui_hud_create_interp();
if (interp) { if (interp) {

View file

@ -62,6 +62,8 @@ extern struct GlobalTextures gGlobalTextures;
extern f32 gDjuiHudUtilsZ; extern f32 gDjuiHudUtilsZ;
extern bool gDjuiHudLockMouse; extern bool gDjuiHudLockMouse;
void djui_hud_clear_interp_data();
/* |description|Gets the current DJUI HUD resolution|descriptionEnd| */ /* |description|Gets the current DJUI HUD resolution|descriptionEnd| */
u8 djui_hud_get_resolution(void); u8 djui_hud_get_resolution(void);
/* |description|Sets the current DJUI HUD resolution|descriptionEnd| */ /* |description|Sets the current DJUI HUD resolution|descriptionEnd| */
@ -74,12 +76,18 @@ void djui_hud_set_filter(enum HudUtilsFilter filterType);
s8 djui_hud_get_font(void); s8 djui_hud_get_font(void);
/* |description|Sets the current DJUI HUD font|descriptionEnd| */ /* |description|Sets the current DJUI HUD font|descriptionEnd| */
void djui_hud_set_font(s8 fontType); void djui_hud_set_font(s8 fontType);
/* |description|Gets the current DJUI HUD color|descriptionEnd| */ /* |description|Gets the current DJUI HUD global color|descriptionEnd| */
struct DjuiColor* djui_hud_get_color(void); struct DjuiColor* djui_hud_get_color(void);
/* |description|Sets the current DJUI HUD color|descriptionEnd| */ /* |description|Sets the current DJUI HUD global color|descriptionEnd| */
void djui_hud_set_color(u8 r, u8 g, u8 b, u8 a); void djui_hud_set_color(u8 r, u8 g, u8 b, u8 a);
/* |description|Resets the current DJUI HUD color|descriptionEnd| */ /* |description|Resets the current DJUI HUD global color|descriptionEnd| */
void djui_hud_reset_color(void); void djui_hud_reset_color(void);
/* |description|Gets the current DJUI HUD text default color. This color is overridden by color codes|descriptionEnd| */
struct DjuiColor* djui_hud_get_text_color(void);
/* |description|Sets the current DJUI HUD text default color. This color is overridden by color codes|descriptionEnd| */
void djui_hud_set_text_color(u8 r, u8 g, u8 b, u8 a);
/* |description|Resets the current DJUI HUD text default color. This color is overridden by color codes|descriptionEnd| */
void djui_hud_reset_text_color(void);
/* |description|Gets the current DJUI HUD rotation|descriptionEnd| */ /* |description|Gets the current DJUI HUD rotation|descriptionEnd| */
void djui_hud_get_rotation(RET s16 *rotation, RET f32 *pivotX, RET f32 *pivotY); void djui_hud_get_rotation(RET s16 *rotation, RET f32 *pivotX, RET f32 *pivotY);
/* |description|Sets the current DJUI HUD rotation|descriptionEnd| */ /* |description|Sets the current DJUI HUD rotation|descriptionEnd| */

View file

@ -577,6 +577,7 @@ static bool djui_inputbox_render(struct DjuiBase* base) {
} }
// set color // set color
gDPSetPrimColor(gDisplayListHead++, 0, 0, 255, 255, 255, 255);
gDPSetEnvColor(gDisplayListHead++, inputbox->textColor.r, inputbox->textColor.g, inputbox->textColor.b, inputbox->textColor.a); gDPSetEnvColor(gDisplayListHead++, inputbox->textColor.r, inputbox->textColor.g, inputbox->textColor.b, inputbox->textColor.a);
// make selection well formed // make selection well formed

View file

@ -43,6 +43,8 @@ void djui_panel_controls_create(struct DjuiBase* caller) {
djui_checkbox_create(body, DLANG(MISC, USE_STANDARD_KEY_BINDINGS_CHAT), &configUseStandardKeyBindingsChat, NULL); djui_checkbox_create(body, DLANG(MISC, USE_STANDARD_KEY_BINDINGS_CHAT), &configUseStandardKeyBindingsChat, NULL);
#ifdef HAVE_SDL2 #ifdef HAVE_SDL2
djui_checkbox_create(body, DLANG(CONTROLS, EXTENDED_REPORTS), &configExtendedReports, NULL);
int numJoys = SDL_NumJoysticks(); int numJoys = SDL_NumJoysticks();
if (numJoys == 0) { numJoys = 1; } if (numJoys == 0) { numJoys = 1; }

View file

@ -387,8 +387,10 @@ static void djui_text_render_line(struct DjuiText* text, char* c1, char* c2, f32
for (char* c = c1; c < c2;) { for (char* c = c1; c < c2;) {
struct DjuiColor parsedColor; struct DjuiColor parsedColor;
if (djui_text_parse_color(c, c2, true, &sDjuiTextDefaultColor, &c, &parsedColor)) { if (djui_text_parse_color(c, c2, true, &sDjuiTextDefaultColor, &c, &parsedColor)) {
gDPSetEnvColor(gDisplayListHead++, parsedColor.r, parsedColor.g, parsedColor.b, parsedColor.a); sDjuiTextCurrentColor.r = parsedColor.r;
sDjuiTextCurrentColor = parsedColor; sDjuiTextCurrentColor.g = parsedColor.g;
sDjuiTextCurrentColor.b = parsedColor.b;
gDPSetEnvColor(gDisplayListHead++, sDjuiTextCurrentColor.r, sDjuiTextCurrentColor.g, sDjuiTextCurrentColor.b, sDjuiTextCurrentColor.a);
continue; continue;
} }
@ -457,6 +459,7 @@ static bool djui_text_render(struct DjuiBase* base) {
create_dl_scale_matrix(DJUI_MTX_NOPUSH, translatedFontSize, translatedFontSize, 1.0f); create_dl_scale_matrix(DJUI_MTX_NOPUSH, translatedFontSize, translatedFontSize, 1.0f);
// set color // set color
gDPSetPrimColor(gDisplayListHead++, 0, 0, 255, 255, 255, 255);
gDPSetEnvColor(gDisplayListHead++, base->color.r, base->color.g, base->color.b, base->color.a); gDPSetEnvColor(gDisplayListHead++, base->color.r, base->color.g, base->color.b, base->color.a);
sDjuiTextCurrentColor = base->color; sDjuiTextCurrentColor = base->color;

View file

@ -359,7 +359,7 @@ void smlua_init(void) {
} }
// skip loading scripts in subdirectories // skip loading scripts in subdirectories
if (strchr(file->relativePath, '/') != NULL || strchr(file->relativePath, '\\') != NULL) { if (strchr(file->relativePath, *PATH_SEPARATOR) != NULL || strchr(file->relativePath, *PATH_SEPARATOR_ALT) != NULL) {
continue; continue;
} }

View file

@ -12345,6 +12345,59 @@ int smlua_func_djui_hud_reset_color(UNUSED lua_State* L) {
return 1; return 1;
} }
int smlua_func_djui_hud_get_text_color(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_get_text_color", 0, top);
return 0;
}
smlua_push_object(L, LOT_DJUICOLOR, djui_hud_get_text_color(), NULL);
return 1;
}
int smlua_func_djui_hud_set_text_color(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 4) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "djui_hud_set_text_color", 4, top);
return 0;
}
u8 r = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "djui_hud_set_text_color"); return 0; }
u8 g = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "djui_hud_set_text_color"); return 0; }
u8 b = smlua_to_integer(L, 3);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "djui_hud_set_text_color"); return 0; }
u8 a = smlua_to_integer(L, 4);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "djui_hud_set_text_color"); return 0; }
djui_hud_set_text_color(r, g, b, a);
return 1;
}
int smlua_func_djui_hud_reset_text_color(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_reset_text_color", 0, top);
return 0;
}
djui_hud_reset_text_color();
return 1;
}
int smlua_func_djui_hud_get_rotation(lua_State* L) { int smlua_func_djui_hud_get_rotation(lua_State* L) {
if (L == NULL) { return 0; } if (L == NULL) { return 0; }
@ -26885,24 +26938,6 @@ int smlua_func_cur_obj_check_anim_frame_in_range(lua_State* L) {
return 1; return 1;
} }
int smlua_func_cur_obj_check_frame_prior_current_frame(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", "cur_obj_check_frame_prior_current_frame", 1, top);
return 0;
}
s16 * a0 = (s16 *)smlua_to_cpointer(L, 1, LVT_S16_P);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "cur_obj_check_frame_prior_current_frame"); return 0; }
extern s32 cur_obj_check_frame_prior_current_frame(s16 *a0);
lua_pushinteger(L, cur_obj_check_frame_prior_current_frame(a0));
return 1;
}
int smlua_func_mario_is_in_air_action(lua_State* L) { int smlua_func_mario_is_in_air_action(lua_State* L) {
if (L == NULL) { return 0; } if (L == NULL) { return 0; }
@ -37524,6 +37559,9 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "djui_hud_get_color", smlua_func_djui_hud_get_color); smlua_bind_function(L, "djui_hud_get_color", smlua_func_djui_hud_get_color);
smlua_bind_function(L, "djui_hud_set_color", smlua_func_djui_hud_set_color); smlua_bind_function(L, "djui_hud_set_color", smlua_func_djui_hud_set_color);
smlua_bind_function(L, "djui_hud_reset_color", smlua_func_djui_hud_reset_color); smlua_bind_function(L, "djui_hud_reset_color", smlua_func_djui_hud_reset_color);
smlua_bind_function(L, "djui_hud_get_text_color", smlua_func_djui_hud_get_text_color);
smlua_bind_function(L, "djui_hud_set_text_color", smlua_func_djui_hud_set_text_color);
smlua_bind_function(L, "djui_hud_reset_text_color", smlua_func_djui_hud_reset_text_color);
smlua_bind_function(L, "djui_hud_get_rotation", smlua_func_djui_hud_get_rotation); smlua_bind_function(L, "djui_hud_get_rotation", smlua_func_djui_hud_get_rotation);
smlua_bind_function(L, "djui_hud_set_rotation", smlua_func_djui_hud_set_rotation); smlua_bind_function(L, "djui_hud_set_rotation", smlua_func_djui_hud_set_rotation);
smlua_bind_function(L, "djui_hud_set_rotation_interpolated", smlua_func_djui_hud_set_rotation_interpolated); smlua_bind_function(L, "djui_hud_set_rotation_interpolated", smlua_func_djui_hud_set_rotation_interpolated);
@ -38307,7 +38345,6 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "cur_obj_check_if_at_animation_end", smlua_func_cur_obj_check_if_at_animation_end); smlua_bind_function(L, "cur_obj_check_if_at_animation_end", smlua_func_cur_obj_check_if_at_animation_end);
smlua_bind_function(L, "cur_obj_check_anim_frame", smlua_func_cur_obj_check_anim_frame); smlua_bind_function(L, "cur_obj_check_anim_frame", smlua_func_cur_obj_check_anim_frame);
smlua_bind_function(L, "cur_obj_check_anim_frame_in_range", smlua_func_cur_obj_check_anim_frame_in_range); smlua_bind_function(L, "cur_obj_check_anim_frame_in_range", smlua_func_cur_obj_check_anim_frame_in_range);
smlua_bind_function(L, "cur_obj_check_frame_prior_current_frame", smlua_func_cur_obj_check_frame_prior_current_frame);
smlua_bind_function(L, "mario_is_in_air_action", smlua_func_mario_is_in_air_action); smlua_bind_function(L, "mario_is_in_air_action", smlua_func_mario_is_in_air_action);
smlua_bind_function(L, "mario_is_dive_sliding", smlua_func_mario_is_dive_sliding); smlua_bind_function(L, "mario_is_dive_sliding", smlua_func_mario_is_dive_sliding);
smlua_bind_function(L, "cur_obj_set_y_vel_and_animation", smlua_func_cur_obj_set_y_vel_and_animation); smlua_bind_function(L, "cur_obj_set_y_vel_and_animation", smlua_func_cur_obj_set_y_vel_and_animation);

View file

@ -121,7 +121,7 @@ static int smlua_custom_require(lua_State* L) {
return 0; return 0;
} }
if (path_ends_with(moduleName, "/") || path_ends_with(moduleName, "\\")) { if (path_ends_with(moduleName, PATH_SEPARATOR) || path_ends_with(moduleName, PATH_SEPARATOR_ALT)) {
LOG_LUA_LINE("cannot require a directory"); LOG_LUA_LINE("cannot require a directory");
return 0; return 0;
} }

View file

@ -849,7 +849,7 @@ void smlua_logline(void) {
if (strlen(src) < SYS_MAX_PATH) { if (strlen(src) < SYS_MAX_PATH) {
int slashCount = 0; int slashCount = 0;
for (const char* p = src + strlen(src); p > src; --p) { for (const char* p = src + strlen(src); p > src; --p) {
if (*p == '/' || *p == '\\') { if (*p == *PATH_SEPARATOR || *p == *PATH_SEPARATOR_ALT) {
if (++slashCount == 2) { if (++slashCount == 2) {
folderStart = p + 1; folderStart = p + 1;
break; break;

View file

@ -622,8 +622,8 @@ LuaTable get_mod_files(struct Mod* mod, OPTIONAL const char* subDirectory) {
normalize_path(normalizedSubDir); normalize_path(normalizedSubDir);
size_t subDirLen = strlen(normalizedSubDir); size_t subDirLen = strlen(normalizedSubDir);
if (subDirLen > 0 && subDirLen + 1 < SYS_MAX_PATH && normalizedSubDir[subDirLen - 1] != '/') { if (subDirLen > 0 && subDirLen + 1 < SYS_MAX_PATH && normalizedSubDir[subDirLen - 1] != *PATH_SEPARATOR) {
strcat(normalizedSubDir, "/"); strcat(normalizedSubDir, PATH_SEPARATOR);
subDirLen = strlen(normalizedSubDir); subDirLen = strlen(normalizedSubDir);
} }

View file

@ -144,7 +144,7 @@ bool mod_file_create_directories(struct Mod* mod, struct ModFile* modFile) {
char* p = path; char* p = path;
u16 index = 0; u16 index = 0;
while (*p != '\0') { while (*p != '\0') {
if (*p == '/' || *p == '\\') { if (*p == *PATH_SEPARATOR || *p == *PATH_SEPARATOR_ALT) {
if (snprintf(tmpPath, index + 1, "%s", path) < 0) { } if (snprintf(tmpPath, index + 1, "%s", path) < 0) { }
if (!fs_sys_dir_exists(tmpPath)) { if (!fs_sys_dir_exists(tmpPath)) {
fs_sys_mkdir(tmpPath); fs_sys_mkdir(tmpPath);
@ -210,11 +210,9 @@ void normalize_path(char* path) {
// replace slashes // replace slashes
char* p = path; char* p = path;
while (*p) { while (*p) {
#if defined(_WIN32) if (*p == *PATH_SEPARATOR_ALT) {
if (*p == '/') { *p = '\\'; } *p = *PATH_SEPARATOR;
#else }
if (*p == '\\') { *p = '/'; }
#endif
p++; p++;
} }
} }
@ -227,7 +225,7 @@ char* path_basename(char* path) {
char* base = path; char* base = path;
while (*path != '\0') { while (*path != '\0') {
if (*(path + 1) != '\0') { if (*(path + 1) != '\0') {
if (*path == '\\' || *path == '/') { if (*path == *PATH_SEPARATOR || *path == *PATH_SEPARATOR_ALT) {
base = path + 1; base = path + 1;
} }
} }
@ -251,7 +249,7 @@ void path_get_folder(char* path, char* outpath) {
int path_depth(const char* path) { int path_depth(const char* path) {
int depth = 0; int depth = 0;
for (; *path; path++) { for (; *path; path++) {
if (*path == '/' || *path == '\\') { if (*path == *PATH_SEPARATOR || *path == *PATH_SEPARATOR_ALT) {
depth++; depth++;
} }
} }
@ -262,7 +260,7 @@ void resolve_relative_path(const char* base, const char* path, char* output) {
char combined[SYS_MAX_PATH] = ""; char combined[SYS_MAX_PATH] = "";
// If path is absolute, copy as is. Otherwise, combine base and relative path // If path is absolute, copy as is. Otherwise, combine base and relative path
if (path[0] == '/' || path[0] == '\\') { if (path[0] == *PATH_SEPARATOR || path[0] == *PATH_SEPARATOR_ALT) {
snprintf(combined, sizeof(combined), "%s", path); snprintf(combined, sizeof(combined), "%s", path);
} else { } else {
snprintf(combined, sizeof(combined), "%s/%s", base, path); snprintf(combined, sizeof(combined), "%s/%s", base, path);
@ -272,7 +270,7 @@ void resolve_relative_path(const char* base, const char* path, char* output) {
int tokenCount = 0; int tokenCount = 0;
// Tokenize path by separators // Tokenize path by separators
char* token = strtok(combined, "/\\"); char* token = strtok(combined, PATH_SEPARATOR PATH_SEPARATOR_ALT);
while (token && tokenCount < 64) { while (token && tokenCount < 64) {
if (strcmp(token, "..") == 0) { if (strcmp(token, "..") == 0) {
// Pop last token to go up a directory // Pop last token to go up a directory
@ -283,7 +281,7 @@ void resolve_relative_path(const char* base, const char* path, char* output) {
tokens[tokenCount++] = token; tokens[tokenCount++] = token;
} }
token = strtok(NULL, "/\\"); token = strtok(NULL, PATH_SEPARATOR PATH_SEPARATOR_ALT);
} }
output[0] = '\0'; output[0] = '\0';
@ -291,7 +289,7 @@ void resolve_relative_path(const char* base, const char* path, char* output) {
// Build output path from tokens // Build output path from tokens
for (int i = 0; i < tokenCount; i++) { for (int i = 0; i < tokenCount; i++) {
if (i > 0) { if (i > 0) {
strncat(output, "/", SYS_MAX_PATH - strlen(output) - 1); strncat(output, PATH_SEPARATOR, SYS_MAX_PATH - strlen(output) - 1);
} }
strncat(output, tokens[i], SYS_MAX_PATH - strlen(output) - 1); strncat(output, tokens[i], SYS_MAX_PATH - strlen(output) - 1);
} }
@ -308,8 +306,8 @@ bool directory_sanity_check(struct dirent* dir, char* dirPath, char* outPath) {
if (!fs_sys_filename_is_portable(dir->d_name)) { return false; } if (!fs_sys_filename_is_portable(dir->d_name)) { return false; }
// skip anything that contains \ or / // skip anything that contains \ or /
if (strchr(dir->d_name, '/') != NULL) { return false; } if (strchr(dir->d_name, *PATH_SEPARATOR) != NULL) { return false; }
if (strchr(dir->d_name, '\\') != NULL) { return false; } if (strchr(dir->d_name, *PATH_SEPARATOR_ALT) != NULL) { return false; }
// skip anything that starts with . // skip anything that starts with .
if (dir->d_name[0] == '.') { return false; } if (dir->d_name[0] == '.') { return false; }

View file

@ -18,34 +18,26 @@ struct StateExtras {
}; };
static struct StateExtras sStateExtras[MAX_PLAYERS]; static struct StateExtras sStateExtras[MAX_PLAYERS];
void name_without_hex(char* input) {
s32 i, j;
bool inSlash = false;
for (i = j = 0; input[i] != '\0'; i++) {
if (input[i] == '\\') {
inSlash = !inSlash;
} else if (!inSlash) {
input[j++] = input[i]; // it just works
}
}
input[j] = '\0';
}
void djui_hud_print_outlined_text_interpolated(const char* text, f32 prevX, f32 prevY, f32 prevScale, f32 x, f32 y, f32 scale, u8 r, u8 g, u8 b, u8 a, f32 outlineDarkness) { void djui_hud_print_outlined_text_interpolated(const char* text, f32 prevX, f32 prevY, f32 prevScale, f32 x, f32 y, f32 scale, u8 r, u8 g, u8 b, u8 a, f32 outlineDarkness) {
f32 offset = 1 * (scale * 2); f32 offset = 1 * (scale * 2);
f32 prevOffset = 1 * (prevScale * 2); f32 prevOffset = 1 * (prevScale * 2);
djui_hud_set_text_color(r, g, b, 255);
// render outline // render outline
djui_hud_set_color(r * outlineDarkness, g * outlineDarkness, b * outlineDarkness, a); djui_hud_set_color(255 * outlineDarkness, 255 * outlineDarkness, 255 * outlineDarkness, a);
djui_hud_print_text_interpolated(text, prevX - prevOffset, prevY, prevScale, x - offset, y, scale); djui_hud_print_text_interpolated(text, prevX - prevOffset, prevY, prevScale, x - offset, y, scale);
djui_hud_print_text_interpolated(text, prevX + prevOffset, prevY, prevScale, x + offset, y, scale); djui_hud_print_text_interpolated(text, prevX + prevOffset, prevY, prevScale, x + offset, y, scale);
djui_hud_print_text_interpolated(text, prevX, prevY - prevOffset, prevScale, x, y - offset, scale); djui_hud_print_text_interpolated(text, prevX, prevY - prevOffset, prevScale, x, y - offset, scale);
djui_hud_print_text_interpolated(text, prevX, prevY + prevOffset, prevScale, x, y + offset, scale); djui_hud_print_text_interpolated(text, prevX, prevY + prevOffset, prevScale, x, y + offset, scale);
// render text // render text
djui_hud_set_color(r, g, b, a); djui_hud_set_color(255, 255, 255, a);
djui_hud_print_text_interpolated(text, prevX, prevY, prevScale, x, y, scale); djui_hud_print_text_interpolated(text, prevX, prevY, prevScale, x, y, scale);
// reset colors
djui_hud_set_color(255, 255, 255, 255); djui_hud_set_color(255, 255, 255, 255);
djui_hud_set_text_color(255, 255, 255, 255);
} }
void nametags_render(void) { void nametags_render(void) {
@ -59,7 +51,21 @@ void nametags_render(void) {
djui_hud_set_resolution(RESOLUTION_N64); djui_hud_set_resolution(RESOLUTION_N64);
djui_hud_set_font(FONT_SPECIAL); djui_hud_set_font(FONT_SPECIAL);
for (u8 i = gNametagsSettings.showSelfTag ? 0 : 1; i < MAX_PLAYERS; i++) { struct NametagInfo {
Vec3f pos;
f32 scale;
char name[MAX_CONFIG_STRING];
};
struct NametagInfo nametags[MAX_PLAYERS] = {0};
s32 sortedNametagIndices[MAX_PLAYERS] = {0};
s32 numNametags = 0;
extern bool gDjuiHudToWorldCalcViewport;
gDjuiHudToWorldCalcViewport = false;
// sort nametags by their distance to the camera
// insertion sort is quick enough for such small array
for (s32 i = gNametagsSettings.showSelfTag ? 0 : 1; i < MAX_PLAYERS; i++) {
struct MarioState* m = &gMarioStates[i]; struct MarioState* m = &gMarioStates[i];
if (!is_player_active(m)) { continue; } if (!is_player_active(m)) { continue; }
struct NetworkPlayer* np = &gNetworkPlayers[i]; struct NetworkPlayer* np = &gNetworkPlayers[i];
@ -84,8 +90,6 @@ void nametags_render(void) {
vec3f_copy(pos, m->marioBodyState->headPos); vec3f_copy(pos, m->marioBodyState->headPos);
pos[1] += 100; pos[1] += 100;
extern bool gDjuiHudToWorldCalcViewport;
gDjuiHudToWorldCalcViewport = false;
if ((i != 0 || (i == 0 && m->action != ACT_FIRST_PERSON)) && if ((i != 0 || (i == 0 && m->action != ACT_FIRST_PERSON)) &&
djui_hud_world_pos_to_screen_pos(pos, out)) { djui_hud_world_pos_to_screen_pos(pos, out)) {
@ -96,61 +100,89 @@ void nametags_render(void) {
snprintf(name, MAX_CONFIG_STRING, "%s", hookedString); snprintf(name, MAX_CONFIG_STRING, "%s", hookedString);
} else { } else {
snprintf(name, MAX_CONFIG_STRING, "%s", np->name); snprintf(name, MAX_CONFIG_STRING, "%s", np->name);
name_without_hex(name);
} }
if (!djui_hud_world_pos_to_screen_pos(pos, out)) { if (!djui_hud_world_pos_to_screen_pos(pos, out)) {
continue; continue;
} }
u8* color = network_get_player_text_color(m->playerIndex);
f32 scale = -300 / out[2] * djui_hud_get_fov_coeff(); f32 scale = -300 / out[2] * djui_hud_get_fov_coeff();
f32 measure = djui_hud_measure_text(name) * scale * 0.5f;
out[1] -= 16 * scale;
u8 alpha = (i == 0 ? 255 : MIN(np->fadeOpacity << 3, 255)) * clamp(FADE_SCALE - scale, 0.f, 1.f); s32 j = 0;
for (; j < numNametags; ++j) {
struct StateExtras* e = &sStateExtras[i]; const struct NametagInfo *nametag = &nametags[sortedNametagIndices[j]];
if (!e->inited) { if (scale < nametag->scale) {
vec3f_copy(e->prevPos, out); memmove(sortedNametagIndices + j + 1, sortedNametagIndices + j, sizeof(s32) * (numNametags - j));
e->prevScale = scale; break;
e->inited = true; }
} }
sortedNametagIndices[j] = i;
// Apply viewport for credits struct NametagInfo *nametag = &nametags[i];
extern Vp *gViewportOverride; vec3f_copy(nametag->pos, out);
extern Vp *gViewportClip; nametag->scale = scale;
extern Vp gViewportFullscreen; memcpy(nametag->name, name, sizeof(name));
Vp *viewport = gViewportOverride == NULL ? gViewportClip : gViewportOverride;
if (viewport) {
make_viewport_clip_rect(viewport);
gSPViewport(gDisplayListHead++, viewport);
}
djui_hud_print_outlined_text_interpolated(name, numNametags++;
e->prevPos[0] - measure, e->prevPos[1], e->prevScale,
out[0] - measure, out[1], scale,
color[0], color[1], color[2], alpha, 0.25);
if (i != 0 && gNametagsSettings.showHealth) {
djui_hud_set_color(255, 255, 255, alpha);
f32 healthScale = 90 * scale;
f32 prevHealthScale = 90 * e->prevScale;
hud_render_power_meter_interpolated(m->health,
e->prevPos[0] - (prevHealthScale * 0.5f), e->prevPos[1] - 72 * scale, prevHealthScale, prevHealthScale,
out[0] - ( healthScale * 0.5f), out[1] - 72 * scale, healthScale, healthScale
);
}
// Reset viewport
if (viewport) {
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - BORDER_HEIGHT);
gSPViewport(gDisplayListHead++, &gViewportFullscreen);
}
vec3f_copy(e->prevPos, out);
e->prevScale = scale;
} }
gDjuiHudToWorldCalcViewport = true; }
gDjuiHudToWorldCalcViewport = true;
// render nametags
for (s32 k = 0; k < numNametags; ++k) {
s32 playerIndex = sortedNametagIndices[k];
struct NametagInfo *nametag = &nametags[playerIndex];
struct MarioState *m = &gMarioStates[playerIndex];
struct NetworkPlayer *np = &gNetworkPlayers[playerIndex];
u8* color = network_get_player_text_color(m->playerIndex);
f32 measure = djui_hud_measure_text(nametag->name) * nametag->scale * 0.5f;
nametag->pos[1] -= 16 * nametag->scale;
u8 alpha = (playerIndex == 0 ? 255 : MIN(np->fadeOpacity << 3, 255)) * clamp(FADE_SCALE - nametag->scale, 0.f, 1.f);
struct StateExtras* e = &sStateExtras[playerIndex];
if (!e->inited) {
vec3f_copy(e->prevPos, nametag->pos);
e->prevScale = nametag->scale;
e->inited = true;
}
// Apply viewport for credits
extern Vp *gViewportOverride;
extern Vp *gViewportClip;
extern Vp gViewportFullscreen;
Vp *viewport = gViewportOverride == NULL ? gViewportClip : gViewportOverride;
if (viewport) {
make_viewport_clip_rect(viewport);
gSPViewport(gDisplayListHead++, viewport);
}
// render name
djui_hud_print_outlined_text_interpolated(nametag->name,
e->prevPos[0] - measure, e->prevPos[1], e->prevScale,
nametag->pos[0] - measure, nametag->pos[1], nametag->scale,
color[0], color[1], color[2], alpha, 0.25);
// render power meter
if (playerIndex != 0 && gNametagsSettings.showHealth) {
djui_hud_set_color(255, 255, 255, alpha);
f32 healthScale = 90 * nametag->scale;
f32 prevHealthScale = 90 * e->prevScale;
hud_render_power_meter_interpolated(m->health,
e->prevPos[0] - (prevHealthScale * 0.5f), e->prevPos[1] - 72 * nametag->scale, prevHealthScale, prevHealthScale,
nametag->pos[0] - ( healthScale * 0.5f), nametag->pos[1] - 72 * nametag->scale, healthScale, healthScale
);
}
// Reset viewport
if (viewport) {
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - BORDER_HEIGHT);
gSPViewport(gDisplayListHead++, &gViewportFullscreen);
}
vec3f_copy(e->prevPos, nametag->pos);
e->prevScale = nametag->scale;
} }
} }

View file

@ -56,8 +56,8 @@ const char *sys_file_extension(const char *fpath) {
} }
const char *sys_file_name(const char *fpath) { const char *sys_file_name(const char *fpath) {
const char *sep1 = strrchr(fpath, '/'); const char *sep1 = strrchr(fpath, *PATH_SEPARATOR);
const char *sep2 = strrchr(fpath, '\\'); const char *sep2 = strrchr(fpath, *PATH_SEPARATOR_ALT);
const char *sep = sep1 > sep2 ? sep1 : sep2; const char *sep = sep1 > sep2 ? sep1 : sep2;
if (!sep) return fpath; if (!sep) return fpath;
return sep + 1; return sep + 1;
@ -325,7 +325,7 @@ const char *sys_user_path(void) {
// strip the trailing separator // strip the trailing separator
const unsigned int len = strlen(path); const unsigned int len = strlen(path);
if (path[len-1] == '/' || path[len-1] == '\\') { path[len-1] = 0; } if (path[len-1] == *PATH_SEPARATOR || path[len-1] == *PATH_SEPARATOR_ALT) { path[len-1] = 0; }
return path; return path;
} }

View file

@ -7,6 +7,14 @@
/* platform-specific functions and whatnot */ /* platform-specific functions and whatnot */
#ifdef _WIN32
#define PATH_SEPARATOR "\\"
#define PATH_SEPARATOR_ALT "/"
#else
#define PATH_SEPARATOR "/"
#define PATH_SEPARATOR_ALT "\\"
#endif
#define SYS_MAX_PATH 4096 #define SYS_MAX_PATH 4096
// crossplatform impls of misc stuff // crossplatform impls of misc stuff