Raygui wrapper lib.
This commit is contained in:
10
API.md
10
API.md
@@ -5955,13 +5955,21 @@ Get gui state ( global state )
|
|||||||
|
|
||||||
> success = RL.GuiSetFont( Font font )
|
> success = RL.GuiSetFont( Font font )
|
||||||
|
|
||||||
Set gui custom font ( Global state )
|
Set gui custom font ( global state )
|
||||||
|
|
||||||
- Failure return false
|
- Failure return false
|
||||||
- Success return true
|
- Success return true
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
> font = RL.GuiGetFont()
|
||||||
|
|
||||||
|
Get gui custom font ( global state )
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Gui - Style
|
## Gui - Style
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -4759,13 +4759,18 @@ function RL.GuiGetState() end
|
|||||||
|
|
||||||
-- Gui - Font
|
-- Gui - Font
|
||||||
|
|
||||||
---Set gui custom font ( Global state )
|
---Set gui custom font ( global state )
|
||||||
---- Failure return false
|
---- Failure return false
|
||||||
---- Success return true
|
---- Success return true
|
||||||
---@param font any
|
---@param font any
|
||||||
---@return any success
|
---@return any success
|
||||||
function RL.GuiSetFont( font ) end
|
function RL.GuiSetFont( font ) end
|
||||||
|
|
||||||
|
---Get gui custom font ( global state )
|
||||||
|
---- Success return int
|
||||||
|
---@return any font
|
||||||
|
function RL.GuiGetFont() end
|
||||||
|
|
||||||
-- Gui - Style
|
-- Gui - Style
|
||||||
|
|
||||||
---Set one style property
|
---Set one style property
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ Detailed changes:
|
|||||||
- ADDED: GetCamera3DViewMatrix
|
- ADDED: GetCamera3DViewMatrix
|
||||||
- ADDED: GetCamera3DProjectionMatrix
|
- ADDED: GetCamera3DProjectionMatrix
|
||||||
- ADDED: glBlitFramebuffer
|
- ADDED: glBlitFramebuffer
|
||||||
|
- ADDED: GuiGetFont
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
Release: ReiLua version 0.4.0 Using Raylib 4.2
|
Release: ReiLua version 0.4.0 Using Raylib 4.2
|
||||||
|
|||||||
1
devnotes
1
devnotes
@@ -1,5 +1,6 @@
|
|||||||
Current {
|
Current {
|
||||||
* Check new functions from https://github.com/raysan5/raylib/blob/master/CHANGELOG
|
* Check new functions from https://github.com/raysan5/raylib/blob/master/CHANGELOG
|
||||||
|
* Tilemap clib.
|
||||||
}
|
}
|
||||||
|
|
||||||
Backlog {
|
Backlog {
|
||||||
|
|||||||
@@ -33,9 +33,6 @@ function RL.init()
|
|||||||
RL.SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
RL.SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
||||||
end
|
end
|
||||||
|
|
||||||
function RL.process( delta )
|
|
||||||
end
|
|
||||||
|
|
||||||
function RL.draw()
|
function RL.draw()
|
||||||
RL.ClearBackground( { 50, 20, 75 } )
|
RL.ClearBackground( { 50, 20, 75 } )
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,6 @@ package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua"
|
|||||||
Util = require( "utillib" )
|
Util = require( "utillib" )
|
||||||
Vec2 = require( "vector2" )
|
Vec2 = require( "vector2" )
|
||||||
|
|
||||||
-- print( "RL", RL, #RL )
|
|
||||||
|
|
||||||
-- for i, v in pairs( RL ) do
|
|
||||||
-- print( i, v )
|
|
||||||
-- end
|
|
||||||
|
|
||||||
local TILE_SIZE = 16
|
local TILE_SIZE = 16
|
||||||
local PLAYER_MAXSPEED = 1.5
|
local PLAYER_MAXSPEED = 1.5
|
||||||
local PLAYER_ACCELL = 5
|
local PLAYER_ACCELL = 5
|
||||||
|
|||||||
155
examples/raygui_lib/main.lua
Normal file
155
examples/raygui_lib/main.lua
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua"
|
||||||
|
|
||||||
|
Util = require( "utillib" )
|
||||||
|
Rect = require( "rectangle" )
|
||||||
|
Vec2 = require( "vector2" )
|
||||||
|
Color = require( "color" )
|
||||||
|
Raygui = require( "raygui" )
|
||||||
|
|
||||||
|
local raygui = Raygui:new()
|
||||||
|
|
||||||
|
local grid = {}
|
||||||
|
|
||||||
|
function RL.init()
|
||||||
|
local monitor = 0
|
||||||
|
local mPos = RL.GetMonitorPosition( monitor )
|
||||||
|
local mSize = RL.GetMonitorSize( monitor )
|
||||||
|
local winSize = { 1920, 1080 }
|
||||||
|
|
||||||
|
RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE )
|
||||||
|
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
|
||||||
|
RL.SetWindowSize( winSize )
|
||||||
|
RL.SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
||||||
|
|
||||||
|
RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SIZE, 20 )
|
||||||
|
RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SPACING, 4 )
|
||||||
|
RL.GuiSetStyle( RL.SPINNER, RL.TEXT_ALIGNMENT, RL.TEXT_ALIGN_RIGHT )
|
||||||
|
|
||||||
|
local label = raygui:add( raygui.Label:new(
|
||||||
|
Rect:new( 16, 16, 64, 32 ),
|
||||||
|
"Cat"
|
||||||
|
) )
|
||||||
|
local toggleGroup = raygui:add( raygui.ToggleGroup:new(
|
||||||
|
Rect:new( 68, 16, 64, 32 ),
|
||||||
|
"Cat\nDog",
|
||||||
|
0,
|
||||||
|
function( self ) print( self:getItem( self.active ) ) end
|
||||||
|
) )
|
||||||
|
local button = raygui:add( raygui.Button:new(
|
||||||
|
Rect:new( 245, 188, 64, 32 ),
|
||||||
|
"Dog",
|
||||||
|
function() toggleGroup:setText( "Dog;Cat\nEagle" ) end
|
||||||
|
) )
|
||||||
|
local checkbox = raygui:add( raygui.CheckBox:new(
|
||||||
|
Rect:new( 64, 128, 20, 20 ),
|
||||||
|
"Dog",
|
||||||
|
false
|
||||||
|
) )
|
||||||
|
local combobox = raygui:add( raygui.ComboBox:new(
|
||||||
|
Rect:new( 64, 256, 128, 32 ),
|
||||||
|
"Dog\nCow\nDonkey",
|
||||||
|
0
|
||||||
|
) )
|
||||||
|
local dropdownbox = raygui:add( raygui.DropdownBox:new(
|
||||||
|
Rect:new( 256, 128, 128, 32 ),
|
||||||
|
"Dog\nGiraffe\nLion\nHorse",
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
function( self ) print( self:getItem( self.active ) ) end
|
||||||
|
) )
|
||||||
|
local spinner = raygui:add( raygui.Spinner:new(
|
||||||
|
Rect:new( 464, 256, 128, 32 ),
|
||||||
|
"Health",
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
10,
|
||||||
|
false,
|
||||||
|
function( self ) print( "Spinner value changed to "..self.value ) end
|
||||||
|
) )
|
||||||
|
local valuebox = raygui:add( raygui.ValueBox:new(
|
||||||
|
Rect:new( 464, 316, 128, 32 ),
|
||||||
|
"Health",
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
100,
|
||||||
|
false,
|
||||||
|
function( self ) print( "ValueBox value changed to "..self.value ) end
|
||||||
|
) )
|
||||||
|
local textbox = raygui:add( raygui.TextBox:new(
|
||||||
|
Rect:new( 32, 316, 256, 32 ),
|
||||||
|
"Name",
|
||||||
|
32,
|
||||||
|
false,
|
||||||
|
function( self ) print( "Set text "..self.text ) end
|
||||||
|
) )
|
||||||
|
local textboxmulti = raygui:add( raygui.TextBoxMulti:new(
|
||||||
|
Rect:new( 32, 400, 256, 64 ),
|
||||||
|
"Buggy?",
|
||||||
|
32,
|
||||||
|
false,
|
||||||
|
function( self ) print( "Set text "..self.text ) end
|
||||||
|
) )
|
||||||
|
local slider = raygui:add( raygui.Slider:new(
|
||||||
|
Rect:new( 50, 500, 256, 32 ),
|
||||||
|
"min",
|
||||||
|
"max",
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
100,
|
||||||
|
function( self ) print( "Changed value "..self.value ) end
|
||||||
|
) )
|
||||||
|
local sliderbar = raygui:add( raygui.SliderBar:new(
|
||||||
|
Rect:new( 50, 550, 256, 32 ),
|
||||||
|
"min",
|
||||||
|
"max",
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
100,
|
||||||
|
function( self ) print( "Changed value "..self.value ) end
|
||||||
|
) )
|
||||||
|
local progressbar = raygui:add( raygui.ProgressBar:new(
|
||||||
|
Rect:new( 50, 600, 256, 32 ),
|
||||||
|
"min",
|
||||||
|
"max",
|
||||||
|
20,
|
||||||
|
0,
|
||||||
|
100,
|
||||||
|
function( self ) print( "Changed value "..self.value ) end
|
||||||
|
) )
|
||||||
|
local statusbar = raygui:add( raygui.StatusBar:new(
|
||||||
|
Rect:new( 50, 650, 256, 32 ),
|
||||||
|
"StatusBar"
|
||||||
|
) )
|
||||||
|
local dummyrec = raygui:add( raygui.DummyRec:new(
|
||||||
|
Rect:new( 50, 700, 256, 32 ),
|
||||||
|
"DummyRec"
|
||||||
|
) )
|
||||||
|
grid = raygui:add( raygui.Grid:new(
|
||||||
|
Rect:new( 400, 400, 256, 256 ),
|
||||||
|
"Grid",
|
||||||
|
32,
|
||||||
|
2
|
||||||
|
) )
|
||||||
|
end
|
||||||
|
|
||||||
|
function RL.process( delta )
|
||||||
|
raygui:process()
|
||||||
|
end
|
||||||
|
|
||||||
|
function RL.draw()
|
||||||
|
RL.ClearBackground( { 50, 20, 75 } )
|
||||||
|
|
||||||
|
if 0 <= grid.cell.x then
|
||||||
|
RL.DrawRectangleLines(
|
||||||
|
{
|
||||||
|
grid.bounds.x + grid.cell.x * 32,
|
||||||
|
grid.bounds.y + grid.cell.y * 32,
|
||||||
|
32,
|
||||||
|
32
|
||||||
|
},
|
||||||
|
RL.GREEN
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
raygui:draw()
|
||||||
|
end
|
||||||
BIN
examples/resources/clib/rllib.so
Executable file
BIN
examples/resources/clib/rllib.so
Executable file
Binary file not shown.
BIN
examples/resources/clib/sampleclib.so
Executable file
BIN
examples/resources/clib/sampleclib.so
Executable file
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
util = require( "utillib" )
|
Util = require( "utillib" )
|
||||||
Rect = require( "rectangle" )
|
Rect = require( "rectangle" )
|
||||||
Vec2 = require( "vector2" )
|
Vec2 = require( "vector2" )
|
||||||
Color = require( "color" )
|
Color = require( "color" )
|
||||||
@@ -106,11 +106,11 @@ function Gui.delete( cell )
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Gui.set2Top( cell )
|
function Gui.set2Top( cell )
|
||||||
util.tableMove( Gui._cells, Gui.getId( cell ), 1, #Gui._cells )
|
Util.tableMove( Gui._cells, Gui.getId( cell ), 1, #Gui._cells )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Gui.set2Back( cell )
|
function Gui.set2Back( cell )
|
||||||
util.tableMove( Gui._cells, Gui.getId( cell ), 1, 1 )
|
Util.tableMove( Gui._cells, Gui.getId( cell ), 1, 1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Gui.process( mousePosition )
|
function Gui.process( mousePosition )
|
||||||
@@ -187,7 +187,7 @@ function Gui.process( mousePosition )
|
|||||||
|
|
||||||
if 0 < key then
|
if 0 < key then
|
||||||
if key == RL.KEY_BACKSPACE then
|
if key == RL.KEY_BACKSPACE then
|
||||||
Gui._inputItem.text = util.utf8Sub( Gui._inputItem.text, 0, utf8.len( Gui._inputItem.text ) - 1 )
|
Gui._inputItem.text = Util.utf8Sub( Gui._inputItem.text, 0, utf8.len( Gui._inputItem.text ) - 1 )
|
||||||
elseif key == RL.KEY_ENTER or key == RL.KEY_KP_ENTER then
|
elseif key == RL.KEY_ENTER or key == RL.KEY_KP_ENTER then
|
||||||
if Gui._inputItem.allowLineBreak then
|
if Gui._inputItem.allowLineBreak then
|
||||||
Gui._inputItem.text = Gui._inputItem.text.."\n"
|
Gui._inputItem.text = Gui._inputItem.text.."\n"
|
||||||
@@ -615,8 +615,8 @@ function Container:scroll( pos )
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
self._scrollRect.x = util.clamp( pos.x, 0, self._scrollRect.width - self.bounds.width )
|
self._scrollRect.x = Util.clamp( pos.x, 0, self._scrollRect.width - self.bounds.width )
|
||||||
self._scrollRect.y = util.clamp( pos.y, 0, self._scrollRect.height - self.bounds.height )
|
self._scrollRect.y = Util.clamp( pos.y, 0, self._scrollRect.height - self.bounds.height )
|
||||||
|
|
||||||
self:update()
|
self:update()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
Rectangle = {}
|
Rectangle = {}
|
||||||
|
-- Rectangle.TYPE = "Rectangle"
|
||||||
|
|
||||||
Rectangle.meta = {
|
Rectangle.meta = {
|
||||||
__index = Rectangle,
|
__index = Rectangle,
|
||||||
__tostring = function( r )
|
__tostring = function( r )
|
||||||
|
|||||||
@@ -114,6 +114,9 @@ function utillib.split( str, sep )
|
|||||||
for str in string.gmatch( str, "([^"..sep.."]+)" ) do
|
for str in string.gmatch( str, "([^"..sep.."]+)" ) do
|
||||||
table.insert( t, str )
|
table.insert( t, str )
|
||||||
end
|
end
|
||||||
|
-- for s in string.gmatch( str, "([^"..sep.."]+)" ) do
|
||||||
|
-- table.insert( t, s )
|
||||||
|
-- end
|
||||||
|
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2049,7 +2049,8 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
// Delete text
|
// Delete text
|
||||||
if (keyCount > 0)
|
if (keyCount > 0)
|
||||||
{
|
{
|
||||||
if (IsKeyPressed(KEY_BACKSPACE))
|
// if (IsKeyPressed(KEY_BACKSPACE))
|
||||||
|
if ( GetKeyPressed() == KEY_BACKSPACE )
|
||||||
{
|
{
|
||||||
while ((keyCount > 0) && ((text[--keyCount] & 0xc0) == 0x80));
|
while ((keyCount > 0) && ((text[--keyCount] & 0xc0) == 0x80));
|
||||||
text[keyCount] = '\0';
|
text[keyCount] = '\0';
|
||||||
@@ -2343,7 +2344,8 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
// Delete characters
|
// Delete characters
|
||||||
if (textLength > 0)
|
if (textLength > 0)
|
||||||
{
|
{
|
||||||
if (IsKeyPressed(KEY_BACKSPACE))
|
// if (IsKeyPressed(KEY_BACKSPACE))
|
||||||
|
if ( GetKeyPressed() == KEY_BACKSPACE )
|
||||||
{
|
{
|
||||||
if ((unsigned char)text[textLength - 1] < 127)
|
if ((unsigned char)text[textLength - 1] < 127)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ int lguiGuiSetState( lua_State *L );
|
|||||||
int lguiGuiGetState( lua_State *L );
|
int lguiGuiGetState( lua_State *L );
|
||||||
/* Font. */
|
/* Font. */
|
||||||
int lguiGuiSetFont( lua_State *L );
|
int lguiGuiSetFont( lua_State *L );
|
||||||
|
int lguiGuiGetFont( lua_State *L );
|
||||||
/* Style */
|
/* Style */
|
||||||
int lguiGuiSetStyle( lua_State *L );
|
int lguiGuiSetStyle( lua_State *L );
|
||||||
int lguiGuiGetStyle( lua_State *L );
|
int lguiGuiGetStyle( lua_State *L );
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ typedef struct {
|
|||||||
lua_State *luaState;
|
lua_State *luaState;
|
||||||
Vector2 resolution;
|
Vector2 resolution;
|
||||||
int textureSource;
|
int textureSource;
|
||||||
|
size_t guiFont;
|
||||||
/* Resources. */
|
/* Resources. */
|
||||||
/* Images. */
|
/* Images. */
|
||||||
Image **images;
|
Image **images;
|
||||||
|
|||||||
5
src/gl.c
5
src/gl.c
@@ -55,10 +55,11 @@ int lglBlitFramebuffer( lua_State *L ) {
|
|||||||
dstRect.x, dstRect.y, dstRect.width, dstRect.height,
|
dstRect.x, dstRect.y, dstRect.width, dstRect.height,
|
||||||
mask,
|
mask,
|
||||||
filter
|
filter
|
||||||
// GL_COLOR_BUFFER_BIT, // mask
|
|
||||||
// GL_NEAREST // filter
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
glBindFramebuffer( GL_READ_FRAMEBUFFER, 0 );
|
||||||
|
glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 );
|
||||||
|
|
||||||
lua_pushboolean( L, true );
|
lua_pushboolean( L, true );
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -1290,6 +1290,7 @@ void luaRegister() {
|
|||||||
assingGlobalFunction( "GuiGetState", lguiGuiGetState );
|
assingGlobalFunction( "GuiGetState", lguiGuiGetState );
|
||||||
/* Font. */
|
/* Font. */
|
||||||
assingGlobalFunction( "GuiSetFont", lguiGuiSetFont );
|
assingGlobalFunction( "GuiSetFont", lguiGuiSetFont );
|
||||||
|
assingGlobalFunction( "GuiGetFont", lguiGuiGetFont );
|
||||||
/* Style. */
|
/* Style. */
|
||||||
assingGlobalFunction( "GuiSetStyle", lguiGuiSetStyle );
|
assingGlobalFunction( "GuiSetStyle", lguiGuiSetStyle );
|
||||||
assingGlobalFunction( "GuiGetStyle", lguiGuiGetStyle );
|
assingGlobalFunction( "GuiGetStyle", lguiGuiGetStyle );
|
||||||
|
|||||||
16
src/rgui.c
16
src/rgui.c
@@ -131,7 +131,7 @@ int lguiGuiGetState( lua_State *L ) {
|
|||||||
/*
|
/*
|
||||||
> success = RL.GuiSetFont( Font font )
|
> success = RL.GuiSetFont( Font font )
|
||||||
|
|
||||||
Set gui custom font ( Global state )
|
Set gui custom font ( global state )
|
||||||
|
|
||||||
- Failure return false
|
- Failure return false
|
||||||
- Success return true
|
- Success return true
|
||||||
@@ -143,6 +143,7 @@ int lguiGuiSetFont( lua_State *L ) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
size_t fontId = lua_tointeger( L, 1 );
|
size_t fontId = lua_tointeger( L, 1 );
|
||||||
|
state->guiFont = fontId;
|
||||||
|
|
||||||
GuiSetFont( *state->fonts[ fontId ] );
|
GuiSetFont( *state->fonts[ fontId ] );
|
||||||
lua_pushboolean( L, true );
|
lua_pushboolean( L, true );
|
||||||
@@ -150,6 +151,19 @@ int lguiGuiSetFont( lua_State *L ) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> font = RL.GuiGetFont()
|
||||||
|
|
||||||
|
Get gui custom font ( global state )
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
*/
|
||||||
|
int lguiGuiGetFont( lua_State *L ) {
|
||||||
|
lua_pushinteger( L, state->guiFont );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
## Gui - Style
|
## Gui - Style
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ bool stateInit( const char *exePath ) {
|
|||||||
state->resolution = (Vector2){ 800, 600 };
|
state->resolution = (Vector2){ 800, 600 };
|
||||||
state->luaState = NULL;
|
state->luaState = NULL;
|
||||||
state->textureSource = TEXTURE_SOURCE_TEXTURE;
|
state->textureSource = TEXTURE_SOURCE_TEXTURE;
|
||||||
|
state->guiFont = 0;
|
||||||
/* Images. */
|
/* Images. */
|
||||||
state->imageAlloc = ALLOC_PAGE_SIZE;
|
state->imageAlloc = ALLOC_PAGE_SIZE;
|
||||||
state->imageCount = 0;
|
state->imageCount = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user