mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 03:55:11 +00:00
Created TextureInfo struct
This commit is contained in:
parent
ded74e7fb5
commit
29599a82ec
13 changed files with 133 additions and 96 deletions
|
@ -18,6 +18,9 @@ def translate_type_to_lvt(ptype):
|
|||
if ptype == 'char':
|
||||
ptype = 'u8'
|
||||
|
||||
if 'const ' in ptype:
|
||||
ptype = ptype.replace('const ', '').strip()
|
||||
|
||||
if ('char' in ptype and '[' in ptype):
|
||||
return 'LVT_STRING'
|
||||
|
||||
|
@ -57,15 +60,18 @@ def translate_type_to_lvt(ptype):
|
|||
return 'LVT_???'
|
||||
|
||||
def translate_type_to_lot(ptype):
|
||||
if ptype == 'char':
|
||||
ptype = 'u8'
|
||||
|
||||
if ptype == 'const char*':
|
||||
return 'LOT_NONE'
|
||||
|
||||
if ptype == 'char*' or ('char' in ptype and '[' in ptype):
|
||||
return 'LOT_NONE'
|
||||
|
||||
if 'const ' in ptype:
|
||||
ptype = ptype.replace('const ', '')
|
||||
|
||||
if ptype == 'char':
|
||||
ptype = 'u8'
|
||||
|
||||
if '[' in ptype or '{' in ptype:
|
||||
return 'LOT_???'
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ override_field_immutable = {
|
|||
"MarioState": [ "playerIndex" ],
|
||||
"Character": [ "*" ],
|
||||
"NetworkPlayer": [ "*" ],
|
||||
"TextureInfo": [ "*" ],
|
||||
}
|
||||
|
||||
sLuaManuallyDefinedStructs = [
|
||||
|
@ -188,7 +189,7 @@ def get_struct_field_info(struct, field):
|
|||
|
||||
lvt = translate_type_to_lvt(ftype)
|
||||
lot = translate_type_to_lot(ftype)
|
||||
fimmutable = str(lvt == 'LVT_COBJECT' or lvt.endswith('_P')).lower()
|
||||
fimmutable = str(lvt == 'LVT_COBJECT' or lvt.endswith('_P') or 'const ' in ftype).lower()
|
||||
|
||||
if sid in override_field_immutable:
|
||||
if fid in override_field_immutable[sid] or '*' in override_field_immutable[sid]:
|
||||
|
|
|
@ -711,17 +711,14 @@
|
|||
## [djui_hud_render_texture](#djui_hud_render_texture)
|
||||
|
||||
### Lua Example
|
||||
`djui_hud_render_texture(texture, bitSize, x, y, width, height, scaleW, scaleH)`
|
||||
`djui_hud_render_texture(texInfo, x, y, scaleW, scaleH)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| texture | Pointer <integer> |
|
||||
| bitSize | integer |
|
||||
| texInfo | [TextureInfo](structs.md#TextureInfo) |
|
||||
| x | number |
|
||||
| y | number |
|
||||
| width | integer |
|
||||
| height | integer |
|
||||
| scaleW | number |
|
||||
| scaleH | number |
|
||||
|
||||
|
@ -729,7 +726,7 @@
|
|||
- None
|
||||
|
||||
### C Prototype
|
||||
`void djui_hud_render_texture(const u8* texture, u32 bitSize, f32 x, f32 y, u32 width, u32 height, f32 scaleW, f32 scaleH);`
|
||||
`void djui_hud_render_texture(struct TextureInfo* texInfo, f32 x, f32 y, f32 scaleW, f32 scaleH);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
- [SPTask](#SPTask)
|
||||
- [SpawnInfo](#SpawnInfo)
|
||||
- [Surface](#Surface)
|
||||
- [TextureInfo](#TextureInfo)
|
||||
- [TransitionInfo](#TransitionInfo)
|
||||
- [UnusedArea28](#UnusedArea28)
|
||||
- [VblankHandler](#VblankHandler)
|
||||
|
@ -174,7 +175,7 @@
|
|||
| capModelId | integer | read-only |
|
||||
| capWingModelId | integer | read-only |
|
||||
| hudHead | char | read-only |
|
||||
| hudHeadTexture | Pointer <integer> | read-only |
|
||||
| hudHeadTexture | [TextureInfo](#TextureInfo) | read-only |
|
||||
| modelId | integer | read-only |
|
||||
| name | string | read-only |
|
||||
| soundAttacked | integer | read-only |
|
||||
|
@ -771,6 +772,19 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [TextureInfo](#TextureInfo)
|
||||
|
||||
| Field | Type | Access |
|
||||
| ----- | ---- | ------ |
|
||||
| bitSize | const u8 | read-only |
|
||||
| height | const u32 | read-only |
|
||||
| texture | Pointer <integer> | read-only |
|
||||
| width | const u32 | read-only |
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [TransitionInfo](#TransitionInfo)
|
||||
|
||||
| Field | Type | Access |
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include <ultra64.h>
|
||||
#include "macros.h"
|
||||
#include "src/game/characters.h"
|
||||
#include "pc/network/version.h"
|
||||
|
||||
// Certain functions are marked as having return values, but do not
|
||||
|
@ -396,6 +395,14 @@ struct MarioState
|
|||
/*????*/ f32 curAnimOffset;
|
||||
};
|
||||
|
||||
struct TextureInfo
|
||||
{
|
||||
const u8* texture;
|
||||
const u8 bitSize;
|
||||
const u32 width;
|
||||
const u32 height;
|
||||
};
|
||||
|
||||
#define PLAY_MODE_NORMAL 0
|
||||
#define PLAY_MODE_PAUSED 2
|
||||
#define PLAY_MODE_CHANGE_AREA 3
|
||||
|
@ -404,4 +411,6 @@ struct MarioState
|
|||
|
||||
#define MAX_PLAYERS 16
|
||||
|
||||
#include "src/game/characters.h"
|
||||
|
||||
#endif // _SM64_TYPES_H_
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "pc/configfile.h"
|
||||
#include "audio/external.h"
|
||||
#include "engine/graph_node.h"
|
||||
#include "types.h"
|
||||
|
||||
extern Gfx mario_cap_seg3_dl_03022F48[];
|
||||
extern Gfx luigi_cap_seg3_dl_03022F48[];
|
||||
|
@ -29,7 +30,7 @@ struct Character gCharacters[CT_MAX] = {
|
|||
.type = CT_MARIO,
|
||||
.name = "Mario",
|
||||
.hudHead = ',',
|
||||
.hudHeadTexture = texture_hud_char_mario_head,
|
||||
.hudHeadTexture = { .texture = texture_hud_char_mario_head, .bitSize = 8, .width = 16, .height = 16 },
|
||||
.cameraHudHead = GLYPH_CAM_MARIO_HEAD,
|
||||
.modelId = MODEL_MARIO,
|
||||
.capModelId = MODEL_MARIOS_CAP,
|
||||
|
@ -92,7 +93,7 @@ struct Character gCharacters[CT_MAX] = {
|
|||
.type = CT_LUIGI,
|
||||
.name = "Luigi",
|
||||
.hudHead = '.',
|
||||
.hudHeadTexture = texture_hud_char_luigi_head,
|
||||
.hudHeadTexture = { .texture = texture_hud_char_luigi_head, .bitSize = 8, .width = 16, .height = 16 },
|
||||
.cameraHudHead = GLYPH_CAM_LUIGI_HEAD,
|
||||
.modelId = MODEL_LUIGI,
|
||||
.capModelId = MODEL_LUIGIS_CAP,
|
||||
|
@ -155,7 +156,7 @@ struct Character gCharacters[CT_MAX] = {
|
|||
.type = CT_TOAD,
|
||||
.name = "Toad",
|
||||
.hudHead = '/',
|
||||
.hudHeadTexture = texture_hud_char_toad_head,
|
||||
.hudHeadTexture = { .texture = texture_hud_char_toad_head, .bitSize = 8, .width = 16, .height = 16 },
|
||||
.cameraHudHead = GLYPH_CAM_TOAD_HEAD,
|
||||
.modelId = MODEL_TOAD_PLAYER,
|
||||
.capModelId = MODEL_TOADS_CAP,
|
||||
|
@ -218,7 +219,7 @@ struct Character gCharacters[CT_MAX] = {
|
|||
.type = CT_WALUIGI,
|
||||
.name = "Waluigi",
|
||||
.hudHead = 'z',
|
||||
.hudHeadTexture = texture_hud_char_waluigi_head,
|
||||
.hudHeadTexture = { .texture = texture_hud_char_waluigi_head, .bitSize = 8, .width = 16, .height = 16 },
|
||||
.cameraHudHead = GLYPH_CAM_WALUIGI_HEAD,
|
||||
.modelId = MODEL_WALUIGI,
|
||||
.capModelId = MODEL_WALUIGIS_CAP,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef CHARACTERS_H
|
||||
#define CHARACTERS_H
|
||||
#include "PR/ultratypes.h"
|
||||
#include "types.h"
|
||||
// NOTE: do not include any additional headers
|
||||
|
||||
enum CharacterType {
|
||||
|
@ -18,7 +19,7 @@ struct Character {
|
|||
enum CharacterType type;
|
||||
char* name;
|
||||
char hudHead;
|
||||
const u8* hudHeadTexture;
|
||||
struct TextureInfo hudHeadTexture;
|
||||
u32 cameraHudHead;
|
||||
u32 modelId;
|
||||
u32 capModelId;
|
||||
|
|
|
@ -117,7 +117,7 @@ void djui_hud_print_text(const char* message, float x, float y, float scale) {
|
|||
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
|
||||
}
|
||||
|
||||
void djui_hud_render_texture(const u8* texture, u32 bitSize, f32 x, f32 y, u32 width, u32 height, f32 scaleW, f32 scaleH) {
|
||||
static void djui_hud_render_texture_raw(const u8* texture, u32 bitSize, u32 width, u32 height, f32 x, f32 y, f32 scaleW, f32 scaleH) {
|
||||
// translate position
|
||||
f32 translatedX = x;
|
||||
f32 translatedY = y;
|
||||
|
@ -137,3 +137,7 @@ void djui_hud_render_texture(const u8* texture, u32 bitSize, f32 x, f32 y, u32 w
|
|||
// pop
|
||||
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
|
||||
}
|
||||
|
||||
void djui_hud_render_texture(struct TextureInfo* texInfo, f32 x, f32 y, f32 scaleW, f32 scaleH) {
|
||||
djui_hud_render_texture_raw(texInfo->texture, texInfo->bitSize, texInfo->width, texInfo->width, x, y, scaleW, scaleH);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,6 @@ u32 djui_hud_get_screen_height(void);
|
|||
|
||||
f32 djui_hud_measure_text(const char* message);
|
||||
void djui_hud_print_text(const char* message, float x, float y, float scale);
|
||||
void djui_hud_render_texture(const u8* texture, u32 bitSize, f32 x, f32 y, u32 width, u32 height, f32 scaleW, f32 scaleH);
|
||||
void djui_hud_render_texture(struct TextureInfo* texInfo, f32 x, f32 y, f32 scaleW, f32 scaleH);
|
||||
|
||||
#endif
|
|
@ -18,7 +18,7 @@ static struct DjuiText* djuiTextLocations[MAX_PLAYERS] = { 0 };
|
|||
static void playerlist_update_row(u8 i, struct NetworkPlayer* np) {
|
||||
u8 charIndex = np->modelIndex;
|
||||
if (charIndex >= CT_MAX) { charIndex = 0; }
|
||||
djuiImages[i]->texture = gCharacters[charIndex].hudHeadTexture;
|
||||
djuiImages[i]->texture = gCharacters[charIndex].hudHeadTexture.texture;
|
||||
|
||||
u8 visible = np->connected;
|
||||
if (np == gNetworkPlayerServer && gServerSettings.headlessServer) {
|
||||
|
|
|
@ -110,7 +110,7 @@ static struct LuaObjectField sCharacterFields[LUA_CHARACTER_FIELD_COUNT] = {
|
|||
{ "capModelId", LVT_U32, offsetof(struct Character, capModelId), true, LOT_NONE },
|
||||
{ "capWingModelId", LVT_U32, offsetof(struct Character, capWingModelId), true, LOT_NONE },
|
||||
{ "hudHead", LVT_U8, offsetof(struct Character, hudHead), true, LOT_NONE },
|
||||
{ "hudHeadTexture", LVT_U8_P, offsetof(struct Character, hudHeadTexture), true, LOT_POINTER },
|
||||
{ "hudHeadTexture", LVT_COBJECT, offsetof(struct Character, hudHeadTexture), true, LOT_TEXTUREINFO },
|
||||
{ "modelId", LVT_U32, offsetof(struct Character, modelId), true, LOT_NONE },
|
||||
{ "name", LVT_STRING_P, offsetof(struct Character, name), true, LOT_NONE },
|
||||
{ "soundAttacked", LVT_S32, offsetof(struct Character, soundAttacked), true, LOT_NONE },
|
||||
|
@ -466,7 +466,7 @@ static struct LuaObjectField sObjectFields[LUA_OBJECT_FIELD_COUNT] = {
|
|||
{ "areaTimerDuration", LVT_U32, offsetof(struct Object, areaTimerDuration), false, LOT_NONE },
|
||||
// { "areaTimerRunOnceCallback)(void)", LVT_???, offsetof(struct Object, areaTimerRunOnceCallback)(void)), false, LOT_??? }, <--- UNIMPLEMENTED
|
||||
{ "areaTimerType", LVT_S32, offsetof(struct Object, areaTimerType), false, LOT_NONE },
|
||||
// { "behavior", LVT_???, offsetof(struct Object, behavior), false, LOT_??? }, <--- UNIMPLEMENTED
|
||||
// { "behavior", LVT_???, offsetof(struct Object, behavior), true, LOT_??? }, <--- UNIMPLEMENTED
|
||||
{ "bhvDelayTimer", LVT_S16, offsetof(struct Object, bhvDelayTimer), false, LOT_NONE },
|
||||
// { "bhvStack", LOT_???, offsetof(struct Object, bhvStack), false, LOT_??? }, <--- UNIMPLEMENTED
|
||||
{ "bhvStackIndex", LVT_U32, offsetof(struct Object, bhvStackIndex), false, LOT_NONE },
|
||||
|
@ -474,7 +474,7 @@ static struct LuaObjectField sObjectFields[LUA_OBJECT_FIELD_COUNT] = {
|
|||
// { "collidedObjs", LOT_???, offsetof(struct Object, collidedObjs), false, LOT_??? }, <--- UNIMPLEMENTED
|
||||
// { "collisionData", LVT_???, offsetof(struct Object, collisionData), false, LOT_??? }, <--- UNIMPLEMENTED
|
||||
{ "createdThroughNetwork", LVT_U8, offsetof(struct Object, createdThroughNetwork), false, LOT_NONE },
|
||||
// { "curBhvCommand", LVT_???, offsetof(struct Object, curBhvCommand), false, LOT_??? }, <--- UNIMPLEMENTED
|
||||
// { "curBhvCommand", LVT_???, offsetof(struct Object, curBhvCommand), true, LOT_??? }, <--- UNIMPLEMENTED
|
||||
{ "globalPlayerIndex", LVT_U8, offsetof(struct Object, globalPlayerIndex), false, LOT_NONE },
|
||||
{ "header", LVT_COBJECT, offsetof(struct Object, header), true, LOT_OBJECTNODE },
|
||||
{ "heldByPlayerIndex", LVT_U32, offsetof(struct Object, heldByPlayerIndex), false, LOT_NONE },
|
||||
|
@ -596,6 +596,14 @@ static struct LuaObjectField sSurfaceFields[LUA_SURFACE_FIELD_COUNT] = {
|
|||
{ "vertex3", LVT_COBJECT, offsetof(struct Surface, vertex3), true, LOT_VEC3S },
|
||||
};
|
||||
|
||||
#define LUA_TEXTURE_INFO_FIELD_COUNT 4
|
||||
static struct LuaObjectField sTextureInfoFields[LUA_TEXTURE_INFO_FIELD_COUNT] = {
|
||||
{ "bitSize", LVT_U8, offsetof(struct TextureInfo, bitSize), true, LOT_NONE },
|
||||
{ "height", LVT_U32, offsetof(struct TextureInfo, height), true, LOT_NONE },
|
||||
{ "texture", LVT_U8_P, offsetof(struct TextureInfo, texture), true, LOT_POINTER },
|
||||
{ "width", LVT_U32, offsetof(struct TextureInfo, width), true, LOT_NONE },
|
||||
};
|
||||
|
||||
#define LUA_TRANSITION_INFO_FIELD_COUNT 9
|
||||
static struct LuaObjectField sTransitionInfoFields[LUA_TRANSITION_INFO_FIELD_COUNT] = {
|
||||
{ "focDist", LVT_F32, offsetof(struct TransitionInfo, focDist), false, LOT_NONE },
|
||||
|
@ -697,6 +705,7 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN]
|
|||
{ LOT_PLAYERGEOMETRY, sPlayerGeometryFields, LUA_PLAYER_GEOMETRY_FIELD_COUNT },
|
||||
{ LOT_SPAWNINFO, sSpawnInfoFields, LUA_SPAWN_INFO_FIELD_COUNT },
|
||||
{ LOT_SURFACE, sSurfaceFields, LUA_SURFACE_FIELD_COUNT },
|
||||
{ LOT_TEXTUREINFO, sTextureInfoFields, LUA_TEXTURE_INFO_FIELD_COUNT },
|
||||
{ LOT_TRANSITIONINFO, sTransitionInfoFields, LUA_TRANSITION_INFO_FIELD_COUNT },
|
||||
{ LOT_WALLCOLLISIONDATA, sWallCollisionDataFields, LUA_WALL_COLLISION_DATA_FIELD_COUNT },
|
||||
{ LOT_WARPNODE, sWarpNodeFields, LUA_WARP_NODE_FIELD_COUNT },
|
||||
|
|
|
@ -39,6 +39,7 @@ enum LuaObjectAutogenType {
|
|||
LOT_PLAYERGEOMETRY,
|
||||
LOT_SPAWNINFO,
|
||||
LOT_SURFACE,
|
||||
LOT_TEXTUREINFO,
|
||||
LOT_TRANSITIONINFO,
|
||||
LOT_WALLCOLLISIONDATA,
|
||||
LOT_WARPNODE,
|
||||
|
|
|
@ -253,26 +253,20 @@ int smlua_func_djui_hud_print_text(lua_State* L) {
|
|||
}
|
||||
|
||||
int smlua_func_djui_hud_render_texture(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 8)) { return 0; }
|
||||
if(!smlua_functions_valid_param_count(L, 5)) { return 0; }
|
||||
|
||||
const u8* texture = (const u8*)smlua_to_cpointer(L, 1, LVT_U8_P);
|
||||
struct TextureInfo* texInfo = (struct TextureInfo*)smlua_to_cobject(L, 1, LOT_TEXTUREINFO);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
u32 bitSize = smlua_to_integer(L, 2);
|
||||
f32 x = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
f32 x = smlua_to_number(L, 3);
|
||||
f32 y = smlua_to_number(L, 3);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
f32 y = smlua_to_number(L, 4);
|
||||
f32 scaleW = smlua_to_number(L, 4);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
u32 width = smlua_to_integer(L, 5);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
u32 height = smlua_to_integer(L, 6);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
f32 scaleW = smlua_to_number(L, 7);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
f32 scaleH = smlua_to_number(L, 8);
|
||||
f32 scaleH = smlua_to_number(L, 5);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
djui_hud_render_texture(texture, bitSize, x, y, width, height, scaleW, scaleH);
|
||||
djui_hud_render_texture(texInfo, x, y, scaleW, scaleH);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue