Allow Lua to get any vanilla texture

This commit is contained in:
MysterD 2022-05-07 03:05:25 -07:00
parent 52c863fb36
commit cdcbdabb37
4 changed files with 1316 additions and 1270 deletions

View File

@ -137,3 +137,25 @@ end
function network_send_to(toLocalIndex, reliable, dataTable)
-- ...
end
--- @param textureName string
--- @return TextureInfo
function get_texture_info(textureName)
-- ...
end
--- @param textureName string
--- @return TextureInfo
function get_texture_info(textureName)
-- ...
end
--- @param texInfo TextureInfo
--- @param x number
--- @param y number
--- @param scaleW number
--- @param scaleH number
--- @return nil
function djui_hud_render_texture(texInfo, x, y, scaleW, scaleH)
-- ...
end

View File

@ -512,6 +512,16 @@ struct DynosOption : NoCopy {
};
typedef bool (*DynosLoopFunc)(DynosOption *, void *);
struct BuiltinTexInfo {
const char* identifier;
const void* pointer;
const char* path;
s32 width;
s32 height;
s32 bitSize;
};
//
// Utils
//
@ -722,6 +732,7 @@ const char* DynOS_Builtin_LvlCol_GetFromData(const Collision* aData);
const Texture* DynOS_Builtin_Tex_GetFromName(const char* aDataName);
const char* DynOS_Builtin_Tex_GetFromData(const Texture* aData);
const char* DynOS_Builtin_Tex_GetNameFromFileName(const char* aDataName);
const struct BuiltinTexInfo* DynOS_Builtin_Tex_GetInfoFromName(const char* aDataName);
const void* DynOS_Builtin_Func_GetFromName(const char* aDataName);
const void* DynOS_Builtin_Func_GetFromIndex(s32 aIndex);
s32 DynOS_Builtin_Func_GetIndexFromData(const void* aData);

File diff suppressed because it is too large Load Diff

View File

@ -452,7 +452,6 @@ bool DynOS_Tex_Get(const char* aTexName, struct TextureInfo* aOutTexInfo) {
default: return false;
}
//aOutTexInfo->format = _Data->mRawFormat;
aOutTexInfo->width = _Data->mRawWidth;
aOutTexInfo->height = _Data->mRawHeight;
aOutTexInfo->texture = _Data->mRawData.begin();
@ -461,6 +460,11 @@ bool DynOS_Tex_Get(const char* aTexName, struct TextureInfo* aOutTexInfo) {
}
// check builtin textures
//return DynOS_Builtin_Tex_GetFromName(aTexName);
return false;
const struct BuiltinTexInfo* info = DynOS_Builtin_Tex_GetInfoFromName(aTexName);
if (!info) { return false; }
aOutTexInfo->bitSize = info->bitSize;
aOutTexInfo->width = info->width;
aOutTexInfo->height = info->height;
aOutTexInfo->texture = (u8*)info->pointer;
return true;
}