GuiGetFont fix.

This commit is contained in:
jussi
2024-02-22 01:10:22 +02:00
parent 178196b0ff
commit 04d2a7df47
8 changed files with 19 additions and 11 deletions

2
API.md
View File

@@ -8805,7 +8805,7 @@ Set gui custom font (global state)
> font = RL.GuiGetFont() > font = RL.GuiGetFont()
Get gui custom font (global state) Get gui custom font (global state). Return as lightuserdata
- Success return Font - Success return Font

View File

@@ -5924,7 +5924,7 @@ function RL.GuiGetState() end
---@return any RL.GuiSetFont ---@return any RL.GuiSetFont
function RL.GuiSetFont( font ) end function RL.GuiSetFont( font ) end
---Get gui custom font (global state) ---Get gui custom font (global state). Return as lightuserdata
---- Success return Font ---- Success return Font
---@return any font ---@return any font
function RL.GuiGetFont() end function RL.GuiGetFont() end

View File

@@ -10,6 +10,8 @@ KEY CHANGES:
DETAILED CHANGES: DETAILED CHANGES:
- ADDED: GetBufferElementSize and GetBufferLength. - ADDED: GetBufferElementSize and GetBufferLength.
- FIXED: Compress_data example. - FIXED: Compress_data example.
- FIXED: GuiGetFont return lightuserdata.
- FIXED: GuiSetStyle, GuiLoadStyle and GuiLoadStyleDefault sets state->guiDefaultFont to GuiGetFont.
------------------------------------------------------------------------ ------------------------------------------------------------------------
Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0 Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0

View File

@@ -248,10 +248,10 @@ function RL.init()
RL.SetWindowSize( winSize ) RL.SetWindowSize( winSize )
RL.SetWindowPosition( { mPos.x + mSize.x / 2 - winSize.x / 2, mPos.y + mSize.y / 2 - winSize.y / 2 } ) RL.SetWindowPosition( { mPos.x + mSize.x / 2 - winSize.x / 2, mPos.y + mSize.y / 2 - winSize.y / 2 } )
RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SIZE, 20 ) -- RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SIZE, 20 )
RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SPACING, 4 ) -- RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SPACING, 4 )
RL.GuiSetStyle( RL.SPINNER, RL.TEXT_ALIGNMENT, RL.TEXT_ALIGN_RIGHT ) -- RL.GuiSetStyle( RL.SPINNER, RL.TEXT_ALIGNMENT, RL.TEXT_ALIGN_RIGHT )
RL.GuiSetStyle( RL.SPINNER, RL.TEXT_PADDING, 2 ) -- RL.GuiSetStyle( RL.SPINNER, RL.TEXT_PADDING, 2 )
cat.texture = RL.LoadTexture( RL.GetBasePath().."../resources/images/cat.png" ) cat.texture = RL.LoadTexture( RL.GetBasePath().."../resources/images/cat.png" )
local texSize = Vec2:new( RL.GetTextureSize( cat.texture ) ) local texSize = Vec2:new( RL.GetTextureSize( cat.texture ) )

View File

@@ -1733,7 +1733,7 @@ function Raygui:new()
object.textEdit = false object.textEdit = false
object.defaultTexture = RL.GetTextureDefault() object.defaultTexture = RL.GetTextureDefault()
object.defaultRect = Rect:new( 0, 0, 1, 1 ) -- For texture. object.defaultRect = Rect:new( 0, 0, 1, 1 ) -- For texture.
object.defaultFont = RL.GetFontDefault() object.defaultFont = RL.GuiGetFont()
object.mouseOffset = Vec2:new() object.mouseOffset = Vec2:new()
object.view = Rect:new() -- Active if larger than 0. Then only controls in view will be updated and drawn. object.view = Rect:new() -- Active if larger than 0. Then only controls in view will be updated and drawn.
object.tooltip = { object.tooltip = {

View File

@@ -13,6 +13,7 @@ typedef struct {
Vector2 resolution; Vector2 resolution;
int logLevelInvalid; int logLevelInvalid;
Font defaultFont; Font defaultFont;
Font guiDefaultFont;
Material defaultMaterial; Material defaultMaterial;
Texture defaultTexture; Texture defaultTexture;
int* RLGLcurrentShaderLocs; int* RLGLcurrentShaderLocs;

View File

@@ -119,6 +119,7 @@ int lguiGuiSetFont( lua_State* L ) {
Font* font = uluaGetFont( L, 1 ); Font* font = uluaGetFont( L, 1 );
GuiSetFont( *font ); GuiSetFont( *font );
state->guiDefaultFont = GuiGetFont();
return 0; return 0;
} }
@@ -126,12 +127,12 @@ int lguiGuiSetFont( lua_State* L ) {
/* /*
> font = RL.GuiGetFont() > font = RL.GuiGetFont()
Get gui custom font (global state) Get gui custom font (global state). Return as lightuserdata
- Success return Font - Success return Font
*/ */
int lguiGuiGetFont( lua_State* L ) { int lguiGuiGetFont( lua_State* L ) {
uluaPushFont( L, GuiGetFont() ); lua_pushlightuserdata( L, &state->guiDefaultFont );
return 1; return 1;
} }
@@ -151,6 +152,7 @@ int lguiGuiSetStyle( lua_State* L ) {
int value = luaL_checkinteger( L, 3 ); int value = luaL_checkinteger( L, 3 );
GuiSetStyle( control, property, value ); GuiSetStyle( control, property, value );
state->guiDefaultFont = GuiGetFont();
return 0; return 0;
} }
@@ -190,6 +192,7 @@ int lguiGuiLoadStyle( lua_State* L ) {
return 1; return 1;
} }
state->guiDefaultFont = GuiGetFont();
TraceLog( state->logLevelInvalid, "Invalid file '%s'", lua_tostring( L, 1 ) ); TraceLog( state->logLevelInvalid, "Invalid file '%s'", lua_tostring( L, 1 ) );
lua_pushnil( L ); lua_pushnil( L );
@@ -203,6 +206,7 @@ Load style default over global style
*/ */
int lguiGuiLoadStyleDefault( lua_State* L ) { int lguiGuiLoadStyleDefault( lua_State* L ) {
GuiLoadStyleDefault(); GuiLoadStyleDefault();
state->guiDefaultFont = GuiGetFont();
return 0; return 0;
} }

View File

@@ -29,6 +29,7 @@ bool stateInit( int argn, const char** argc, const char* exePath ) {
state->run = luaInit( argn, argc ); state->run = luaInit( argn, argc );
} }
state->defaultFont = GetFontDefault(); state->defaultFont = GetFontDefault();
state->guiDefaultFont = GuiGetFont();
state->defaultMaterial = LoadMaterialDefault(); state->defaultMaterial = LoadMaterialDefault();
state->defaultTexture = (Texture){ 1, 1, 1, 1, 7 }; state->defaultTexture = (Texture){ 1, 1, 1, 1, 7 };
state->RLGLcurrentShaderLocs = malloc( RL_MAX_SHADER_LOCATIONS * sizeof( int ) ); state->RLGLcurrentShaderLocs = malloc( RL_MAX_SHADER_LOCATIONS * sizeof( int ) );