├── .gitignore ├── LICENSE ├── README.md ├── addon.txt ├── data └── glib_unicodedata.txt ├── logo.png ├── lua ├── autorun │ └── _libk_loader.lua └── libk │ ├── 3rdparty │ ├── circular_queue.lua │ ├── glib │ │ ├── addons.lua │ │ ├── bitconverter.lua │ │ ├── colors │ │ │ ├── color.lua │ │ │ └── colors.lua │ │ ├── containers │ │ │ ├── binarysetoperatorcontroller.lua │ │ │ ├── binarytree.lua │ │ │ ├── binarytreenode.lua │ │ │ ├── eventedset.lua │ │ │ ├── icollection.lua │ │ │ ├── linkedlist.lua │ │ │ ├── linkedlistnode.lua │ │ │ ├── list.lua │ │ │ ├── orderedset.lua │ │ │ ├── queue.lua │ │ │ ├── set.lua │ │ │ ├── stack.lua │ │ │ └── tree.lua │ │ ├── coroutine.lua │ │ ├── databases │ │ │ ├── idatabase.lua │ │ │ ├── mysqldatabase.lua │ │ │ ├── mysqloodatabase.lua │ │ │ └── sqlitedatabase.lua │ │ ├── enumeration │ │ │ ├── composition.lua │ │ │ ├── enumerable.lua │ │ │ ├── enumerators.lua │ │ │ ├── ienumerable.lua │ │ │ └── operations.lua │ │ ├── events │ │ │ ├── event.lua │ │ │ └── eventprovider.lua │ │ ├── formatting │ │ │ ├── date.lua │ │ │ └── tableformatter.lua │ │ ├── garrysmod │ │ │ ├── io │ │ │ │ ├── fileinbuffer.lua │ │ │ │ └── fileoutbuffer.lua │ │ │ ├── net │ │ │ │ ├── layer1 │ │ │ │ │ ├── netchannel.lua │ │ │ │ │ ├── netdispatcher.lua │ │ │ │ │ ├── netinbuffer.lua │ │ │ │ │ ├── pinnednetinbuffer.lua │ │ │ │ │ ├── pinnedusermessageinbuffer.lua │ │ │ │ │ ├── usermessagechannel.lua │ │ │ │ │ ├── usermessagedispatcher.lua │ │ │ │ │ └── usermessageinbuffer.lua │ │ │ │ ├── layer2 │ │ │ │ │ ├── channel.lua │ │ │ │ │ └── channelstatenetworker.lua │ │ │ │ └── net.lua │ │ │ └── servers │ │ │ │ ├── playermonitor.lua │ │ │ │ └── playermonitorentry.lua │ │ ├── geometry │ │ │ ├── bezierspline.lua │ │ │ ├── cubicbezierspline.lua │ │ │ ├── iparametriccurve.lua │ │ │ ├── iparametricsurface.lua │ │ │ ├── parametriccurverenderer.lua │ │ │ ├── parametricgeometry.lua │ │ │ └── quadraticbezierspline.lua │ │ ├── glib.lua │ │ ├── glue.lua │ │ ├── invoker.lua │ │ ├── io │ │ │ ├── inbuffer.lua │ │ │ ├── outbuffer.lua │ │ │ ├── stringinbuffer.lua │ │ │ └── stringoutbuffer.lua │ │ ├── loader │ │ │ ├── commands.lua │ │ │ ├── loader.lua │ │ │ ├── packfilemanager.lua │ │ │ └── packfilesystem.lua │ │ ├── lua │ │ │ ├── backup.lua │ │ │ ├── codeexporter.lua │ │ │ ├── decompiler │ │ │ │ ├── bytecodeflags.lua │ │ │ │ ├── bytecodereader.lua │ │ │ │ ├── framevariable.lua │ │ │ │ ├── functionbytecodereader.lua │ │ │ │ ├── functionconstant.lua │ │ │ │ ├── garbagecollectedconstant.lua │ │ │ │ ├── garbagecollectedconstanttype.lua │ │ │ │ ├── instruction.lua │ │ │ │ ├── loadstore.lua │ │ │ │ ├── opcode.lua │ │ │ │ ├── opcodeinfo.lua │ │ │ │ ├── opcodes.lua │ │ │ │ ├── operandtype.lua │ │ │ │ ├── precedence.lua │ │ │ │ ├── stringconstant.lua │ │ │ │ ├── tableconstant.lua │ │ │ │ └── tablekeyvaluetype.lua │ │ │ ├── detours.lua │ │ │ ├── lua.lua │ │ │ ├── namecache.lua │ │ │ ├── reflection │ │ │ │ ├── argumentlist.lua │ │ │ │ ├── function.lua │ │ │ │ ├── functioncache.lua │ │ │ │ ├── localvariableframe.lua │ │ │ │ ├── parameter.lua │ │ │ │ ├── parameterlist.lua │ │ │ │ ├── stackcaptureoptions.lua │ │ │ │ ├── stackframe.lua │ │ │ │ ├── stacktrace.lua │ │ │ │ ├── stacktracecache.lua │ │ │ │ ├── upvalueframe.lua │ │ │ │ └── variableframe.lua │ │ │ └── sessionvariables.lua │ │ ├── math │ │ │ ├── columnvector.lua │ │ │ ├── complex.lua │ │ │ ├── matrix.lua │ │ │ ├── polynomial.lua │ │ │ ├── rowvector.lua │ │ │ ├── vector.lua │ │ │ └── vmatrix.lua │ │ ├── memoryusagereport.lua │ │ ├── net │ │ │ ├── connections │ │ │ │ ├── connection.lua │ │ │ │ ├── connectionclosurereason.lua │ │ │ │ ├── connectionendpoint.lua │ │ │ │ ├── connectionpackettype.lua │ │ │ │ ├── connectionrunner.lua │ │ │ │ └── connectionstate.lua │ │ │ ├── datatype.lua │ │ │ ├── ichannel.lua │ │ │ ├── inbuffer.lua │ │ │ ├── isingleendpointchannel.lua │ │ │ ├── layer1 │ │ │ │ └── channel.lua │ │ │ ├── layer2 │ │ │ │ ├── channel.lua │ │ │ │ ├── inboundsplitpacket.lua │ │ │ │ ├── layer2.lua │ │ │ │ ├── outboundsplitpacket.lua │ │ │ │ ├── splitpacketchannel.lua │ │ │ │ └── splitpackettype.lua │ │ │ ├── layer3 │ │ │ │ ├── channel.lua │ │ │ │ ├── layer2channel.lua │ │ │ │ └── layer3.lua │ │ │ ├── layer5 │ │ │ │ ├── channel.lua │ │ │ │ ├── connectionchannel.lua │ │ │ │ ├── connectionrunner.lua │ │ │ │ ├── layer3channel.lua │ │ │ │ ├── layer5.lua │ │ │ │ ├── orderedchannel.lua │ │ │ │ ├── orderedchannelstate.lua │ │ │ │ ├── singleendpointconnectionchannel.lua │ │ │ │ └── singleendpointorderedchannel.lua │ │ │ ├── multiplexing │ │ │ │ └── endpointchannelmultiplexer.lua │ │ │ ├── net.lua │ │ │ ├── outbuffer.lua │ │ │ ├── singleendpointchannel.lua │ │ │ ├── singleendpointchanneltochanneladapter.lua │ │ │ ├── virtualchannel.lua │ │ │ └── virtualsingleendpointchannel.lua │ │ ├── networking │ │ │ ├── connectionnetworkable.lua │ │ │ ├── networkable.lua │ │ │ ├── networkablehost.lua │ │ │ ├── networkablehostmessagetype.lua │ │ │ ├── networkablestate.lua │ │ │ ├── singleendpointnetworkable.lua │ │ │ └── subscriberset.lua │ │ ├── oop │ │ │ ├── enum.lua │ │ │ ├── idisposable.lua │ │ │ └── oop.lua │ │ ├── parsing │ │ │ ├── durationparser.lua │ │ │ └── stringparser.lua │ │ ├── properties │ │ │ ├── properties.lua │ │ │ └── propertyserializable.lua │ │ ├── protocol │ │ │ ├── channel.lua │ │ │ ├── endpoint.lua │ │ │ ├── endpointmanager.lua │ │ │ ├── protocol.lua │ │ │ └── session.lua │ │ ├── rendering │ │ │ ├── buffers │ │ │ │ ├── bufferelement.lua │ │ │ │ ├── bufferelementsemantic.lua │ │ │ │ ├── bufferelementtype.lua │ │ │ │ ├── bufferelementtypes.lua │ │ │ │ ├── bufferflags.lua │ │ │ │ ├── bufferlayout.lua │ │ │ │ ├── igraphicsbuffer.lua │ │ │ │ ├── iindexbuffer.lua │ │ │ │ └── ivertexbuffer.lua │ │ │ ├── ibaserendercontext2d.lua │ │ │ ├── igraphicsdevice.lua │ │ │ ├── igraphicsview.lua │ │ │ ├── irendercontext.lua │ │ │ ├── irendercontext2d.lua │ │ │ ├── irendercontext2d2.lua │ │ │ ├── irendercontext3d.lua │ │ │ ├── matrices │ │ │ │ ├── imatrixstack.lua │ │ │ │ ├── matrixstack.lua │ │ │ │ └── projections.lua │ │ │ ├── matrixpushoperation.lua │ │ │ ├── meshes │ │ │ │ ├── imesh.lua │ │ │ │ ├── mesh.lua │ │ │ │ ├── meshflags.lua │ │ │ │ ├── primitivetopology.lua │ │ │ │ └── rendergroup.lua │ │ │ └── textures │ │ │ │ ├── itexture2d.lua │ │ │ │ └── pixelformat.lua │ │ ├── resources │ │ │ ├── resource.lua │ │ │ ├── resourcecache.lua │ │ │ ├── resources.lua │ │ │ └── resourcestate.lua │ │ ├── serialization │ │ │ └── iserializable.lua │ │ ├── servers │ │ │ ├── iplayermonitor.lua │ │ │ ├── iserver.lua │ │ │ ├── iuserlist.lua │ │ │ ├── playerdisconnectionwatcher.lua │ │ │ ├── playerdisconnectionwatcher2.lua │ │ │ └── playermonitorproxy.lua │ │ ├── stage1.lua │ │ ├── stage2.lua │ │ ├── string │ │ │ ├── escaping.lua │ │ │ └── string.lua │ │ ├── stringbuilder.lua │ │ ├── stringtable.lua │ │ ├── threading │ │ │ ├── blackmagic.lua │ │ │ ├── event.lua │ │ │ ├── iwaitable.lua │ │ │ ├── mainthread.lua │ │ │ ├── thread.lua │ │ │ ├── threading.lua │ │ │ ├── threadrunner.lua │ │ │ ├── threadstate.lua │ │ │ └── waitendreason.lua │ │ ├── timers.lua │ │ ├── transfers │ │ │ ├── inboundtransfer.lua │ │ │ ├── outboundtransfer.lua │ │ │ ├── transfers.lua │ │ │ └── vnet.lua │ │ ├── unicode │ │ │ ├── transliteration.lua │ │ │ ├── unicode.lua │ │ │ ├── unicodecategory.lua │ │ │ ├── unicodecategorytable.lua │ │ │ ├── utf8.lua │ │ │ └── wordtype.lua │ │ └── userid.lua │ ├── luadata.lua │ ├── mysqloolib.lua │ ├── png.lua │ ├── semver.lua │ ├── uuid.lua │ └── von.lua │ ├── client │ ├── cl_DCenteredImage.lua │ ├── cl_DMenuHack.lua │ ├── cl_DRTModelPanel.lua │ ├── cl_DSplitPanel.lua │ ├── cl_dermautil.lua │ ├── cl_libk_KPropertySheet.lua │ ├── cl_libk_baseView.lua │ ├── cl_libk_client.lua │ ├── cl_libk_dermaskin.lua │ └── cl_libk_gradient.lua │ ├── server │ ├── sv_database_transaction.lua │ ├── sv_libk_BaseController.lua │ ├── sv_libk_config.lua │ ├── sv_libk_database.lua │ ├── sv_libk_model.lua │ ├── sv_libk_player.lua │ ├── sv_libk_server.lua │ ├── sv_libk_util.lua │ ├── sv_permissionInterface.lua │ └── sv_versioning.lua │ └── shared │ ├── 0_sh_middleclass.lua │ ├── 1_sh_promises.lua │ ├── 2_sh_libk.lua │ ├── sh_KPlayer.lua │ ├── sh_Singleton.lua │ ├── sh_addonloader.lua │ ├── sh_debug.lua │ ├── sh_easing.lua │ ├── sh_logger.lua │ ├── sh_permissionInterface.lua │ ├── sh_thirdparty.lua │ ├── sh_underscore.lua │ └── sh_util.lua └── resource └── fonts ├── segoeui.ttf ├── segoeuil.ttf ├── segoeuisl.ttf └── seguisb.ttf /.gitignore: -------------------------------------------------------------------------------- 1 | lua/libk/shared/2_sh_libk.lua 2 | lua/libk/server/sv_libk_config.lua 3 | lua/libk/shared/2_sh_libk.lua -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2016 Valentin Funk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /addon.txt: -------------------------------------------------------------------------------- 1 | "AddonInfo" 2 | { 3 | "name" "LibK" 4 | "version" "1" 5 | "up_date" "00/00/00" 6 | "author_name" "Kamshak" 7 | "author_email" "contact.me@steam" 8 | "author_url" "http://steamcommunity.com/id/kamshak" 9 | "info" "Set of utility funcitons, ORM/database library. Do not modify or redistribute without written consent of the author" 10 | "override" "0" 11 | } 12 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ValentinFunk/LibK/62b006d3812a7873323ad1f144ee51034a7a7f51/logo.png -------------------------------------------------------------------------------- /lua/autorun/_libk_loader.lua: -------------------------------------------------------------------------------- 1 | local luaroot = "libk" 2 | local name = "LibK" 3 | 4 | --Shared modules 5 | local files = file.Find( luaroot .."/shared/*.lua", "LUA" ) 6 | table.sort( files ) 7 | if #files > 0 then 8 | for _, file in pairs( files ) do 9 | Msg( "[LibK] Loading SHARED file: " .. file .. "\n" ) 10 | include( luaroot .."/shared/" .. file ) 11 | if SERVER then 12 | AddCSLuaFile( luaroot .."/shared/" .. file ) 13 | end 14 | end 15 | end 16 | 17 | if SERVER then 18 | AddCSLuaFile( ) 19 | local folder = luaroot .. "/shared" 20 | local files = file.Find( folder .. "/" .. "*.lua", "LUA" ) 21 | for _, file in ipairs( files ) do 22 | AddCSLuaFile( folder .. "/" .. file ) 23 | end 24 | 25 | folder = luaroot .."/client" 26 | files = file.Find( folder .. "/" .. "*.lua", "LUA" ) 27 | for _, file in ipairs( files ) do 28 | AddCSLuaFile( folder .. "/" .. file ) 29 | end 30 | 31 | --Server modules 32 | local files = file.Find( luaroot .."/server/*.lua", "LUA" ) 33 | if #files > 0 then 34 | for _, file in ipairs( files ) do 35 | Msg( "[LibK] Loading SERVER file: " .. file .. "\n" ) 36 | include( luaroot .."/server/" .. file ) 37 | end 38 | end 39 | 40 | local path = luaroot .. "/shared/sh_KPlayer.lua" 41 | Msg( "[LibK] MANUAL: Loading file: " .. path .. "\n" ) 42 | include( path ) --Need to include models last 43 | 44 | MsgN( "LibK by Kamshak loaded" ) 45 | end 46 | 47 | if CLIENT then 48 | --Client modules 49 | local files = file.Find( luaroot .."/client/*.lua", "LUA" ) 50 | if #files > 0 then 51 | for _, file in ipairs( files ) do 52 | Msg( "[LibK] Loading CLIENT file: " .. file .. "\n" ) 53 | include( luaroot .."/client/" .. file ) 54 | end 55 | end 56 | MsgN( "LibK by Kamshak loaded" ) 57 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/addons.lua: -------------------------------------------------------------------------------- 1 | GLib.IncludeDirectory ("glib_addons") 2 | GLib.IncludeDirectory ("glib_addons/" .. (SERVER and "server" or "client")) 3 | 4 | GLib.AddCSLuaPackSystem ("GLibAddons") 5 | GLib.AddCSLuaPackFolder ("glib_addons") 6 | GLib.AddCSLuaPackFolderRecursive ("glib_addons/client") 7 | 8 | GLib:AddEventListener ("PackFileLoaded", "GLibAddonLoader", 9 | function (_, systemTableName) 10 | if systemTableName ~= "GLibAddons" then return end 11 | 12 | GLib.IncludeDirectory ("glib_addons") 13 | GLib.IncludeDirectory ("glib_addons/" .. (SERVER and "server" or "client")) 14 | end 15 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/containers/binarytree.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Containers.BinaryTree = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.Root = nil 6 | end 7 | 8 | function self:Clear () 9 | if not self.Root then return end 10 | 11 | self.Root:Orphan () 12 | end 13 | 14 | function self:GetLeftmost () 15 | if not self.Root then return nil end 16 | return self.Root:GetLeftmost () 17 | end 18 | 19 | function self:GetRightmost () 20 | if not self.Root then return nil end 21 | return self.Root:GetRightmost () 22 | end 23 | 24 | function self:GetRoot () 25 | return self.Root 26 | end 27 | 28 | function self:SetRoot (root) 29 | if self.Root == root then return end 30 | 31 | if self.Root then 32 | self.Root.Tree = nil 33 | end 34 | 35 | self.Root = root 36 | 37 | if self.Root then 38 | self.Root.Tree = self 39 | end 40 | end 41 | 42 | function self:ToString () 43 | if not self.Root then return "[nil]" end 44 | return self.Root:ToStringRecursive () 45 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/containers/eventedset.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Containers.EventedSet = GLib.MakeConstructor (self, GLib.Containers.Set) 3 | 4 | --[[ 5 | Events: 6 | Cleared () 7 | Fired when this set has been cleared. 8 | ItemAdded (item) 9 | Fired when an item has been added to this set. 10 | ItemRemoved (item) 11 | Fired when an item has been removed from this set. 12 | ]] 13 | 14 | function self:ctor () 15 | GLib.EventProvider (self) 16 | end 17 | 18 | function self:Add (item) 19 | if self:Contains (item) then return self end 20 | 21 | self.Count = self.Count + 1 22 | self.ItemSet [item] = true 23 | 24 | self:DispatchEvent ("ItemAdded", item) 25 | 26 | return self 27 | end 28 | 29 | function self:Clear () 30 | if self.Count == 0 then return end 31 | 32 | for item, _ in pairs (self.ItemSet) do 33 | self.ItemSet [item] = nil 34 | self:DispatchEvent ("ItemRemoved", item) 35 | end 36 | 37 | self.Count = 0 38 | 39 | self:DispatchEvent ("Cleared") 40 | end 41 | 42 | function self:Remove (item) 43 | if not self:Contains (item) then return end 44 | 45 | self.Count = self.Count - 1 46 | self.ItemSet [item] = nil 47 | 48 | self:DispatchEvent ("ItemRemoved", item) 49 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/containers/icollection.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Containers.ICollection = GLib.MakeConstructor (self, GLib.IEnumerable) 3 | 4 | function self:ctor () 5 | end 6 | 7 | function self:Add (item) 8 | GLib.Error ("ICollection:Add : Not implemented.") 9 | end 10 | 11 | function self:AddRange (enumerable) 12 | for item in enumerable:GetEnumerator () do 13 | self:Add (item) 14 | end 15 | end 16 | 17 | function self:Clear () 18 | GLib.Error ("ICollection:Clear : Not implemented.") 19 | end 20 | 21 | function self:Contains (item) 22 | GLib.Error ("ICollection:Contains : Not implemented.") 23 | end 24 | 25 | function self:GetCount () 26 | GLib.Error ("ICollection:GetCount : Not implemented.") 27 | end 28 | 29 | function self:IsEmpty () 30 | GLib.Error ("ICollection:IsEmpty : Not implemented.") 31 | end 32 | 33 | function self:Remove (item) 34 | GLib.Error ("ICollection:Remove : Not implemented.") 35 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/containers/linkedlistnode.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Containers.LinkedListNode = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.List = nil 6 | self.Next = nil 7 | self.Previous = nil 8 | self.Value = nil 9 | end 10 | 11 | function self:InsertNext (node) 12 | if node == nil then return end 13 | 14 | node.List = self.List 15 | node.Previous = self 16 | node.Next = self.Next 17 | 18 | self.Next = node 19 | 20 | if node.Next then node.Next.Previous = node end 21 | 22 | if self.List then 23 | self.List.Count = self.List.Count + 1 24 | if self.List.Last == self then 25 | self.List.Last = node 26 | end 27 | end 28 | end 29 | 30 | function self:InsertPrevious (node) 31 | if node == nil then return end 32 | 33 | node.List = self.List 34 | node.Next = self 35 | node.Previous = self.Previous 36 | 37 | self.Previous = node 38 | 39 | if node.Previous then node.Previous.Next = node end 40 | 41 | if self.List then 42 | self.List.Count = self.List.Count + 1 43 | if self.List.First == self then 44 | self.List.First = node 45 | end 46 | end 47 | end 48 | 49 | function self:ToString () 50 | if not self.Value then return "[nil]" end 51 | 52 | if type (self.Value) == "table" and self.Value.ToString then return self.Value:ToString () end 53 | if type (self.Value) == "string" then return "\"" .. GLib.String.Escape (self.Value) .. "\"" end 54 | return tostring (self.Value) 55 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/containers/orderedset.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Containers.OrderedSet = GLib.MakeConstructor (self, GLib.Containers.ICollection) 3 | 4 | function self:ctor () 5 | self.Count = 0 6 | 7 | self.Items = {} 8 | self.ItemSet = {} 9 | end 10 | 11 | -- ICollection 12 | function self:Add (item) 13 | if self:Contains (item) then return self end 14 | 15 | self.Count = self.Count + 1 16 | self.Items [self.Count] = item 17 | self.ItemSet [item] = true 18 | 19 | return self 20 | end 21 | 22 | function self:Clear () 23 | self.Count = 0 24 | 25 | self.Items = {} 26 | self.ItemSet = {} 27 | end 28 | 29 | function self:Contains (item) 30 | return self.ItemSet [item] ~= nil 31 | end 32 | 33 | function self:GetCount () 34 | return self.Count 35 | end 36 | 37 | function self:GetEnumerator () 38 | return GLib.ArrayEnumerator (self.Items) 39 | end 40 | 41 | function self:IsEmpty () 42 | return self.Count == 0 43 | end 44 | 45 | function self:Remove (item) 46 | if not self:Contains (item) then return end 47 | 48 | self:RemoveAt (self:IndexOf (item)) 49 | end 50 | 51 | -- OrderedSet 52 | function self:Get (index) 53 | return self.Items [index] 54 | end 55 | 56 | function self:IndexOf (item) 57 | for i = 1, self.Count do 58 | if self.Items [i] == item then return i end 59 | end 60 | return nil 61 | end 62 | 63 | function self:Insert (index, item) 64 | if self:Contains (item) then return self end 65 | 66 | table.insert (self.Items, index, item) 67 | self.Count = self.Count + 1 68 | self.ItemSet [item] = true 69 | 70 | return self 71 | end 72 | 73 | function self:RemoveAt (index) 74 | if not index then return end 75 | if index <= 0 then return end 76 | if index > self.Count then return end 77 | 78 | self.ItemSet [self.Items [i]] = nil 79 | table.remove (self.Items, i) 80 | self.Count = self.Count - 1 81 | end 82 | 83 | function self:Sort (comparator) 84 | table.sort (self.Items, comparator) 85 | end 86 | 87 | function self:ToArray () 88 | local array = {} 89 | for i = 1, self.Count do 90 | array [i] = self.Items [i] 91 | end 92 | return array 93 | end 94 | 95 | function self:ToString () 96 | local content = "" 97 | for item in self:GetEnumerator () do 98 | if content ~= "" then 99 | content = content .. ", " 100 | end 101 | 102 | if #content > 2048 then 103 | content = content .. "..." 104 | break 105 | end 106 | 107 | item = item or "[nil]" 108 | 109 | if type (item) == "table" and item.ToString then item = item:ToString () 110 | elseif type (item) == "string" then item = "\"" .. GLib.String.Escape (item) .. "\"" end 111 | item = tostring (item) 112 | 113 | content = content .. item 114 | end 115 | return "[" .. tostring (self.Count) .. "] : {" .. content .. "}" 116 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/containers/queue.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Containers.Queue = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.LinkedList = GLib.Containers.LinkedList () 6 | self.Front = nil 7 | 8 | self.Count = 0 9 | end 10 | 11 | function self:Clear () 12 | self.LinkedList:Clear () 13 | self.Front = nil 14 | self.Count = 0 15 | end 16 | 17 | function self:Dequeue () 18 | local node = self.LinkedList.First 19 | self.LinkedList:Remove (node) 20 | self.Count = self.Count - 1 21 | 22 | self.Front = self.LinkedList.First and self.LinkedList.First.Value or nil 23 | return node.Value 24 | end 25 | 26 | function self:Enqueue (item) 27 | self.LinkedList:AddLast (item) 28 | self.Count = self.Count + 1 29 | 30 | self.Front = self.LinkedList.First and self.LinkedList.First.Value or nil 31 | end 32 | 33 | function self:GetCount () 34 | return self.Count 35 | end 36 | 37 | function self:GetFront () 38 | return self.Front 39 | end 40 | 41 | function self:IsEmpty () 42 | return self.Count == 0 43 | end 44 | 45 | function self:ToString () 46 | return self.LinkedList:ToString () 47 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/containers/set.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Containers.Set = GLib.MakeConstructor (self, GLib.Containers.ICollection) 3 | 4 | function self:ctor () 5 | self.Count = 0 6 | 7 | self.ItemSet = {} 8 | end 9 | 10 | -- ICollection 11 | function self:Add (item) 12 | if self:Contains (item) then return self end 13 | 14 | self.Count = self.Count + 1 15 | self.ItemSet [item] = true 16 | 17 | return self 18 | end 19 | 20 | function self:Clear () 21 | if self.Count == 0 then return end 22 | 23 | self.Count = 0 24 | 25 | self.ItemSet = {} 26 | end 27 | 28 | function self:Contains (item) 29 | return self.ItemSet [item] ~= nil 30 | end 31 | 32 | function self:GetCount () 33 | return self.Count 34 | end 35 | 36 | function self:GetEnumerator () 37 | return GLib.KeyEnumerator (self.ItemSet) 38 | end 39 | 40 | function self:IsEmpty () 41 | return self.Count == 0 42 | end 43 | 44 | function self:Remove (item) 45 | if not self:Contains (item) then return end 46 | 47 | self.Count = self.Count - 1 48 | self.ItemSet [item] = nil 49 | end 50 | 51 | -- Set 52 | function self:Intersect (enumerable, out) 53 | out = out or self.__ictor () 54 | 55 | for item in enumerable:GetEnumerator () do 56 | if self:Contains (item) then 57 | out:Add (item) 58 | end 59 | end 60 | 61 | return out 62 | end 63 | 64 | function self:Subtract (set, out) 65 | out = out or self.__ictor () 66 | 67 | for item in self:GetEnumerator () do 68 | if not set:Contains (item) then 69 | out:Add (item) 70 | end 71 | end 72 | 73 | return out 74 | end 75 | 76 | function self:Union (enumerable, out) 77 | out = out or self.__ictor () 78 | 79 | for item in self:GetEnumerator () do 80 | out:Add (item) 81 | end 82 | for item in enumerable:GetEnumerator () do 83 | out:Add (item) 84 | end 85 | 86 | return out 87 | end 88 | 89 | function self:ToArray () 90 | local array = {} 91 | for item, _ in pairs (self.ItemSet) do 92 | array [#array + 1] = item 93 | end 94 | return array 95 | end 96 | 97 | function self:ToString () 98 | local content = "" 99 | for item in self:GetEnumerator () do 100 | if content ~= "" then 101 | content = content .. ", " 102 | end 103 | 104 | if #content > 2048 then 105 | content = content .. "..." 106 | break 107 | end 108 | 109 | item = item or "[nil]" 110 | 111 | if type (item) == "table" and item.ToString then item = item:ToString () 112 | elseif type (item) == "string" then item = "\"" .. GLib.String.Escape (item) .. "\"" end 113 | item = tostring (item) 114 | 115 | content = content .. item 116 | end 117 | return "[" .. tostring (self.Count) .. "] : {" .. content .. "}" 118 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/containers/stack.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Containers.Stack = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.Items = {} 6 | self.Count = 0 7 | self.Top = nil 8 | end 9 | 10 | --- Clears the stack 11 | function self:Clear () 12 | self.Count = 0 13 | self.Top = nil 14 | end 15 | 16 | --- Returns the item at the top of the stack 17 | -- @return The item at the top of the stack 18 | function self:GetTop () 19 | return self.Top 20 | end 21 | 22 | --- Returns whether the stack is empty 23 | -- @return true if the stack is empty 24 | function self:IsEmpty () 25 | return self.Count == 0 26 | end 27 | 28 | --- Returns the nth item from the top of the stack 29 | -- @return The nth item from the top of the stack 30 | function self:Peek (offset) 31 | offset = offset or 0 32 | if offset < 0 then offset = -offset end 33 | return self.Items [self.Count - offset] 34 | end 35 | 36 | --- Pops an item from the top of the stack 37 | -- @return The item that was popped from the top of the stack or nil if the stack was already empty 38 | function self:Pop () 39 | if self.Count == 0 then return nil end 40 | local top = self.Top 41 | self.Items [self.Count] = nil 42 | self.Count = self.Count - 1 43 | self.Top = self.Items [self.Count] 44 | return top 45 | end 46 | 47 | --- Pushes an item onto the top of the stack 48 | -- @param value The item to be pushed onto the top of the stack 49 | function self:Push (value) 50 | self.Count = self.Count + 1 51 | self.Items [self.Count] = value 52 | self.Top = value 53 | end 54 | 55 | --- Sets the item at the top of the stack 56 | -- @param value The item to replace the top of the stack 57 | function self:SetTop (value) 58 | self.Items [self.Count] = value 59 | self.Top = value 60 | end 61 | 62 | --- Returns a string representation of this stack 63 | -- @return A string representation of this stack 64 | function self:ToString () 65 | local stack = "[Stack (" .. string.format ("%02d", self.Count) .. ")]" 66 | for i = 1, self.Count do 67 | stack = stack .. "\n[" .. string.format ("%02d", i) .. "] " 68 | if type (self.Items [i]) == "table" and type (self.Items [i].ToString) == "function" then 69 | stack = stack .. self.Items [i]:ToString () 70 | else 71 | stack = stack .. tostring (self.Items [i]) 72 | end 73 | end 74 | return stack 75 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/containers/tree.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Containers.Tree = GLib.MakeConstructor (self) 3 | 4 | function self:ctor (value) 5 | self.Value = value 6 | self.Children = GLib.Containers.LinkedList () 7 | self.ChildCount = 0 8 | end 9 | 10 | function self:Add (value) 11 | local child = GLib.Containers.Tree (value) 12 | self.Children:AddLast (child) 13 | self.ChildCount = self.ChildCount + 1 14 | return child 15 | end 16 | 17 | function self:AddNode (tree) 18 | if type (tree) ~= "table" then 19 | GLib.PrintStackTrace () 20 | end 21 | self.Children:AddLast (tree) 22 | self.ChildCount = self.ChildCount + 1 23 | return tree 24 | end 25 | 26 | function self:AddRange (array) 27 | for _, value in ipairs (array) do 28 | self.Children:AddLast (GLib.Containers.Tree ()).Value.Value = value 29 | self.ChildCount = self.ChildCount + 1 30 | end 31 | end 32 | 33 | function self:Clear () 34 | self.Children:Clear () 35 | self.ChildCount = 0 36 | end 37 | 38 | function self:FindChild (value) 39 | for linkedListNode in self.Children:GetEnumerator () do 40 | if linkedListNode.Value.Value == value then 41 | return linkedListNode.Value 42 | end 43 | end 44 | return nil 45 | end 46 | 47 | function self:GetChild (n) 48 | return self.Children:GetItem (n) 49 | end 50 | 51 | function self:GetChildCount () 52 | return self.ChildCount 53 | end 54 | 55 | function self:GetFirstChild () 56 | if not self.Children.First then 57 | return 58 | end 59 | return self.Children.First.Value 60 | end 61 | 62 | function self:GetEnumerator () 63 | local enumerator = self.Children:GetEnumerator () 64 | return function () 65 | local childNode = enumerator () 66 | if not childNode then 67 | return nil 68 | end 69 | return childNode.Value 70 | end 71 | end 72 | 73 | function self:RemoveLast () 74 | if not self.Children.Last then 75 | return 76 | end 77 | self.ChildCount = self.ChildCount - 1 78 | self.Children:Remove (self.Children.Last) 79 | end 80 | 81 | function self:ToString (indent) 82 | indent = indent or 0 83 | local tree = string.rep (" ", indent) .. "+" .. tostring (self.Value) 84 | 85 | for linkedListNode in self.Children:GetEnumerator () do 86 | local treeNode = linkedListNode.Value 87 | local value 88 | if treeNode then 89 | value = treeNode:ToString (indent + 1) 90 | else 91 | value = string.rep (" ", indent + 1) .. "+[nil]" 92 | end 93 | tree = tree .. "\n" .. value 94 | end 95 | return tree 96 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/coroutine.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Coroutine = GLib.MakeConstructor (self) 3 | 4 | function self:ctor (f) 5 | self.Coroutine = coroutine.create (f) 6 | end 7 | 8 | function self:Call (f, ...) 9 | local ret = { coroutine.yield ("call", f, ...) } 10 | return unpack (ret) 11 | end 12 | 13 | function self:Resume (...) 14 | local inArguments = { ... } 15 | 16 | GLib.CoroutineStack:Push (self) 17 | while true do 18 | local successCommandArguments = { coroutine.resume (self.Coroutine, unpack (inArguments)) } 19 | local success = successCommandArguments [1] 20 | local command = successCommandArguments [2] 21 | if success then 22 | table.remove (successCommandArguments, 2) 23 | table.remove (successCommandArguments, 1) 24 | if command == "call" then 25 | local f = successCommandArguments [1] 26 | table.remove (successCommandArguments, 1) 27 | inArguments = { f (unpack (successCommandArguments)) } 28 | elseif command == "yield" or command == "" or command == nil then 29 | GLib.CoroutineStack:Pop (self) 30 | return success, unpack (successCommandArguments) 31 | else 32 | GLib.CoroutineStack:Pop (self) 33 | return success, unpack (successCommandArguments) 34 | end 35 | else 36 | GLib.CoroutineStack:Pop (self) 37 | return unpack (successCommandArguments) 38 | end 39 | end 40 | end 41 | 42 | function self:Status () 43 | return coroutine.status (self.Coroutine) 44 | end 45 | 46 | function self:Yield (...) 47 | return coroutine.yield ("yield", ...) 48 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/databases/idatabase.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Databases.IDatabase = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | end 6 | 7 | function self:Connect (hostname, port, username, password, databaseName, callback) 8 | GLib.Error ("IDatabase:Connect : Not implemented.") 9 | end 10 | 11 | function self:Disconnect (callback) 12 | GLib.Error ("IDatabase:Connect : Not implemented.") 13 | end 14 | 15 | function self:EscapeString (str) 16 | GLib.Error ("IDatabase:EscapeString : Not implemented.") 17 | end 18 | 19 | function self:GetDatabaseListQuery () 20 | GLib.Error ("IDatabase:GetDatabaseListQuery : Not implemented.") 21 | end 22 | 23 | function self:GetTableListQuery () 24 | GLib.Error ("IDatabase:GetDatabaseListQuery : Not implemented.") 25 | end 26 | 27 | function self:IsConnected () 28 | GLib.Error ("IDatabase:IsConnected : Not implemented.") 29 | end 30 | 31 | function self:Query (query, callback) 32 | GLib.Error ("IDatabase:Query : Not implemented.") 33 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/databases/mysqldatabase.lua: -------------------------------------------------------------------------------- 1 | -- MySQL1.8 2 | local self = {} 3 | GLib.Databases.MySqlDatabase = GLib.MakeConstructor (self, GLib.Databases.IDatabase) 4 | 5 | local loaded = false 6 | 7 | function self:ctor () 8 | self.Database = nil 9 | 10 | if not loaded then 11 | require ("mysql") 12 | loaded = true 13 | end 14 | end 15 | 16 | function self:Connect (server, port, username, password, databaseName, callback) 17 | if callback then GLib.CallSelfAsSync () return end 18 | 19 | if self:IsConnected () then 20 | self:Disconnect () 21 | return self:Connect (server, port, username, password, databaseName) 22 | end 23 | 24 | local database, error = mysql.connect (server, username, password, databaseName, port) 25 | if database == 0 then return false, error end 26 | 27 | self.Database = database 28 | 29 | return true 30 | end 31 | 32 | function self:Disconnect (callback) 33 | if callback then GLib.CallSelfAsSync () return end 34 | 35 | if not self:IsConnected () then return true end 36 | 37 | local success, error = mysql.disconnect (self.Database) 38 | if not success then return false, error end 39 | 40 | self.Database = nil 41 | 42 | return true 43 | end 44 | 45 | function self:EscapeString (string) 46 | if not self:IsConnected () then return "" end 47 | 48 | local string, error = mysql.escape (self.Database, string) 49 | 50 | return string or "" 51 | end 52 | 53 | function self:GetDatabaseListQuery () 54 | return "SHOW DATABASES" 55 | end 56 | 57 | function self:GetTableListQuery (database) 58 | if database then 59 | return "SHOW TABLES IN " .. database 60 | else 61 | return "SHOW TABLES" 62 | end 63 | end 64 | 65 | function self:IsConnected () 66 | return self.Database ~= nil 67 | end 68 | 69 | function self:Query (query, callback) 70 | if callback then GLib.CallSelfAsSync () return end 71 | 72 | if not self:IsConnected () then 73 | return false, "Not connected to the database." 74 | end 75 | 76 | local result, success, error = mysql.query (self.Database, query) 77 | if not success then return false, error end 78 | 79 | return true, result 80 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/databases/mysqloodatabase.lua: -------------------------------------------------------------------------------- 1 | -- MySQLOO 2 | local self = {} 3 | GLib.Databases.MySqlOODatabase = GLib.MakeConstructor (self, GLib.Databases.IDatabase) 4 | 5 | local loaded = false 6 | 7 | function self:ctor () 8 | self.Database = nil 9 | 10 | if not loaded then 11 | require ("mysqloo") 12 | loaded = true 13 | end 14 | end 15 | 16 | function self:Connect (server, port, username, password, databaseName, callback) 17 | if not callback then return I (GLib.CallSelfAsAsync ()) end 18 | 19 | if self:IsConnected () then 20 | self:Disconnect ( 21 | function () 22 | self:Connect (server, port, username, password, databaseName, callback) 23 | end 24 | ) 25 | return 26 | end 27 | 28 | self.Database = mysqloo.connect (server, username, password, databaseName, port) 29 | 30 | function self.Database:onConnected () 31 | callback (true) 32 | end 33 | 34 | function self.Database:onConnectionFailed (error) 35 | callback (false, error) 36 | end 37 | 38 | self.Database:connect () 39 | end 40 | 41 | function self:Disconnect (callback) 42 | if callback then GLib.CallSelfAsSync () return end 43 | 44 | self.Database = nil 45 | 46 | return true 47 | end 48 | 49 | function self:EscapeString (string) 50 | if not self:IsConnected () then return "" end 51 | return self.Database:escape (string) 52 | end 53 | 54 | function self:GetDatabaseListQuery () 55 | return "SHOW DATABASES" 56 | end 57 | 58 | function self:GetTableListQuery (database) 59 | if database then 60 | return "SHOW TABLES IN " .. database 61 | else 62 | return "SHOW TABLES" 63 | end 64 | end 65 | 66 | function self:IsConnected () 67 | return self.Database ~= nil 68 | end 69 | 70 | function self:Query (query, callback) 71 | if not callback then return I (GLib.CallSelfAsAsync ()) end 72 | 73 | if not self:IsConnected () then 74 | callback (false, "Not connected to database.") 75 | return 76 | end 77 | 78 | local q = self.Database:query (query) 79 | 80 | function q:onSuccess () 81 | callback (true, self:getData ()) 82 | end 83 | 84 | function q:onFailure (error) 85 | callback (false, error) 86 | end 87 | 88 | function q:onAborted () 89 | callback (false, "Query aborted.") 90 | end 91 | 92 | q:start () 93 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/databases/sqlitedatabase.lua: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | local self = {} 3 | GLib.Databases.SqliteDatabase = GLib.MakeConstructor (self, GLib.Databases.IDatabase) 4 | 5 | function self:ctor () 6 | end 7 | 8 | function self:Connect (server, port, username, password, databaseName, callback) 9 | if callback then GLib.CallSelfAsSync () return end 10 | 11 | return true 12 | end 13 | 14 | function self:Disconnect (callback) 15 | if callback then GLib.CallSelfAsSync () return end 16 | 17 | return true 18 | end 19 | 20 | function self:EscapeString (string) 21 | return sql.SQLStr (string, true) 22 | end 23 | 24 | function self:GetDatabaseListQuery () 25 | return "" 26 | end 27 | 28 | function self:GetTableListQuery (database) 29 | return "SELECT * FROM sqlite_master WHERE type = \"table\"" 30 | end 31 | 32 | function self:IsConnected () 33 | return true 34 | end 35 | 36 | function self:Query (query, callback) 37 | if callback then GLib.CallSelfAsSync () return end 38 | 39 | local result = sql.Query (query) 40 | if result == false then 41 | return false, sql.LastError () 42 | else 43 | return true, result 44 | end 45 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/enumeration/composition.lua: -------------------------------------------------------------------------------- 1 | function GLib.Enumerator.Join (enumerator1, enumerator2, enumerator3, ...) 2 | if not enumerator2 then 3 | return enumerator1 4 | elseif not enumerator3 then 5 | local i = 1 6 | return function () 7 | local a, b, c, d, e, f = nil 8 | if i == 1 then 9 | a, b, c, d, e, f = enumerator1 () 10 | if a == nil then i = i + 1 end 11 | end 12 | if i == 2 then 13 | a, b, c, d, e, f = enumerator2 () 14 | if a == nil then i = i + 1 end 15 | end 16 | 17 | return a, b, c, d, e, f 18 | end 19 | else 20 | local i = 1 21 | local enumerators = { enumerator1, enumerator2, enumerator3, ... } 22 | return function () 23 | local a, b, c, d, e, f = nil 24 | 25 | while a == nil do 26 | local enumerator = enumerators [i] 27 | if not enumerator then return nil end 28 | a, b, c, d, e, f = enumerator () 29 | if a == nil then i = i + 1 end 30 | end 31 | 32 | return a, b, c, d, e, f 33 | end 34 | end 35 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/enumeration/enumerable.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Enumerable = GLib.MakeConstructor (self, GLib.IEnumerable) 3 | 4 | function GLib.Enumerable.FromArray (array) 5 | return GLib.Enumerable (GLib.Enumerator.ArrayEnumerator, array) 6 | end 7 | 8 | function GLib.Enumerable.FromEnumeratorFactory (enumeratorFactory, argument1) 9 | return GLib.Enumerable (enumeratorFactory, argument1) 10 | end 11 | 12 | function GLib.Enumerable.FromKeys (t) 13 | return GLib.Enumerable (GLib.Enumerator.KeyEnumerator, t) 14 | end 15 | 16 | function GLib.Enumerable.FromValues (t) 17 | return GLib.Enumerable (GLib.Enumerator.ValueEnumerator, t) 18 | end 19 | 20 | function GLib.ToEnumerable (x) 21 | if x.GetEnumerator then return x end 22 | return GLib.Enumerable (GLib.Enumerator.ArrayEnumerator, x) 23 | end 24 | 25 | function self:ctor (enumeratorFactory, argument1) 26 | self.EnumeratorFactory = enumeratorFactory 27 | self.Argument1 = argument1 28 | end 29 | 30 | function self:GetEnumerator () 31 | return self.EnumeratorFactory (self.Argument1) 32 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/enumeration/enumerators.lua: -------------------------------------------------------------------------------- 1 | function GLib.Enumerator.ArrayEnumerator (tbl, maxIndex) 2 | maxIndex = maxIndex or math.huge 3 | 4 | if maxIndex == math.huge then 5 | local i = 0 6 | return function () 7 | i = i + 1 8 | return tbl [i] 9 | end 10 | else 11 | local i = 0 12 | return function () 13 | i = i + 1 14 | if i > maxIndex then return nil end 15 | return tbl [i] 16 | end 17 | end 18 | end 19 | 20 | function GLib.Enumerator.KeyEnumerator (tbl) 21 | local next, tbl, key = pairs (tbl) 22 | return function () 23 | key = next (tbl, key) 24 | return key 25 | end 26 | end 27 | 28 | function GLib.Enumerator.ValueEnumerator (tbl) 29 | local next, tbl, key = pairs (tbl) 30 | return function () 31 | key = next (tbl, key) 32 | return tbl [key] 33 | end 34 | end 35 | 36 | function GLib.Enumerator.KeyValueEnumerator (tbl) 37 | local next, tbl, key = pairs (tbl) 38 | return function () 39 | key = next (tbl, key) 40 | return key, tbl [key] 41 | end 42 | end 43 | 44 | function GLib.Enumerator.ValueKeyEnumerator (tbl) 45 | local next, tbl, key = pairs (tbl) 46 | return function () 47 | key = next (tbl, key) 48 | return tbl [key], key 49 | end 50 | end 51 | 52 | function GLib.Enumerator.NullEnumerator () 53 | return GLib.NullCallback 54 | end 55 | 56 | function GLib.Enumerator.SingleValueEnumerator (v) 57 | local done = false 58 | return function () 59 | if done then return nil end 60 | done = true 61 | return v 62 | end 63 | end 64 | 65 | function GLib.Enumerator.YieldEnumerator (f) 66 | local thread = coroutine.create (f) 67 | return function (...) 68 | if coroutine.status (thread) == "dead" then return nil end 69 | local success, a, b, c, d, e, f = coroutine.resume (thread, ...) 70 | if not success then 71 | GLib.Error (a) 72 | return nil 73 | end 74 | return a, b, c, d, e, f 75 | end 76 | end 77 | 78 | function GLib.Enumerator.YieldEnumeratorFactory (f) 79 | return function (...) 80 | local arguments = {...} 81 | local argumentCount = table.maxn (arguments) 82 | 83 | return GLib.Enumerator.YieldEnumerator ( 84 | function () 85 | return f (unpack (arguments, 1, argumentCount)) 86 | end 87 | ) 88 | end 89 | end 90 | 91 | GLib.ArrayEnumerator = GLib.Enumerator.ArrayEnumerator 92 | GLib.KeyEnumerator = GLib.Enumerator.KeyEnumerator 93 | GLib.ValueEnumerator = GLib.Enumerator.ValueEnumerator 94 | GLib.KeyValueEnumerator = GLib.Enumerator.KeyValueEnumerator 95 | GLib.ValueKeyEnumerator = GLib.Enumerator.ValueKeyEnumerator 96 | GLib.NullEnumerator = GLib.Enumerator.NullEnumerator 97 | GLib.SingleValueEnumerator = GLib.Enumerator.SingleValueEnumerator 98 | GLib.YieldEnumerator = GLib.Enumerator.YieldEnumerator 99 | GLib.YieldEnumeratorFactory = GLib.Enumerator.YieldEnumeratorFactory -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/enumeration/ienumerable.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.IEnumerable = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | end 6 | 7 | function self:GetEnumerator () 8 | GLib.Error ("IEnumerable:GetEnumerator : Not implemented.") 9 | end 10 | 11 | function self:Filter (filterFunction) 12 | return GLib.Enumerable.FromEnumeratorFactory ( 13 | function () 14 | return GLib.Enumerator.Filter (self:GetEnumerator (), filterFunction) 15 | end 16 | ) 17 | end 18 | 19 | function self:Map (mapFunction) 20 | return GLib.Enumerable.FromEnumeratorFactory ( 21 | function () 22 | return GLib.Enumerator.Map (self:GetEnumerator (), mapFunction) 23 | end 24 | ) 25 | end 26 | 27 | function self:Skip (n) 28 | return GLib.Enumerable.FromEnumeratorFactory ( 29 | function () 30 | return GLib.Enumerator.Skip (self:GetEnumerator (), n) 31 | end 32 | ) 33 | end 34 | 35 | function self:Take (n) 36 | return GLib.Enumerable.FromEnumeratorFactory ( 37 | function () 38 | return GLib.Enumerator.Take (self:GetEnumerator (), n) 39 | end 40 | ) 41 | end 42 | 43 | function self:Concat (separator) 44 | return table.concat (self:ToArray (), separator) 45 | end 46 | 47 | function self:ToArray () 48 | return GLib.Enumerator.ToArray (self:GetEnumerator ()) 49 | end 50 | 51 | function self:ToList () 52 | return GLib.Containers.List.FromEnumerable (self) 53 | end 54 | 55 | function self:Unpack () 56 | return unpack (self:ToArray ()) 57 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/enumeration/operations.lua: -------------------------------------------------------------------------------- 1 | local function ToFunction (f) 2 | if isfunction (f) then return f end 3 | 4 | return function (x, ...) 5 | return x [f] (x, ...) 6 | end 7 | end 8 | 9 | function GLib.Enumerator.Concat (enumerator, separator) 10 | return table.concat (GLib.Enumerator.ToArray (GLib.Enumerator.Map (enumerator, tostring)), separator) 11 | end 12 | 13 | function GLib.Enumerator.Filter (enumerator, filterFunction) 14 | filterFunction = ToFunction (filterFunction) 15 | 16 | return function () 17 | local a, b, c, d, e, f = nil 18 | repeat 19 | a, b, c, d, e, f = enumerator () 20 | if a == nil then return nil end 21 | until filterFunction (a, b, c, d, e, f) 22 | 23 | return a, b, c, d, e, f 24 | end 25 | end 26 | 27 | function GLib.Enumerator.Map (enumerator, mapFunction) 28 | mapFunction = ToFunction (mapFunction) 29 | 30 | return function () 31 | local a, b, c, d, e, f = enumerator () 32 | if a == nil then return nil end 33 | 34 | return mapFunction (a, b, c, d, e, f) 35 | end 36 | end 37 | 38 | function GLib.Enumerator.Skip (enumerator, n) 39 | local skipped = false 40 | return function () 41 | if not skipped then 42 | for i = 1, n do 43 | local item = enumerator () 44 | if item == nil then return nil end 45 | end 46 | skipped = true 47 | end 48 | 49 | return enumerator () 50 | end 51 | end 52 | 53 | function GLib.Enumerator.Take (enumerator, n) 54 | local i = 0 55 | return function () 56 | i = i + 1 57 | if i > n then return nil end 58 | 59 | return enumerator () 60 | end 61 | end 62 | 63 | function GLib.Enumerator.ToArray (enumerator) 64 | local t = {} 65 | 66 | for v in enumerator do 67 | t [#t + 1] = v 68 | end 69 | 70 | return t 71 | end 72 | 73 | function GLib.Enumerator.ToMap (enumerator) 74 | local t = {} 75 | 76 | for k, v in enumerator do 77 | t [k] = v 78 | end 79 | 80 | return t 81 | end 82 | GLib.Enumerator.ToTable = GLib.Enumerator.ToMap 83 | 84 | function GLib.Enumerator.Unpack (enumerator) 85 | local value = enumerator () 86 | if not value then return end 87 | return value, GLib.Enumerator.Unpack (enumerator) 88 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/events/event.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Event = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.Listeners = {} 6 | self.ShouldSuppressEvents = false 7 | end 8 | 9 | function self:dtor () 10 | self:ClearListeners () 11 | end 12 | 13 | function self:Clone (clone) 14 | clone = clone or self.__ictor () 15 | 16 | clone:Copy (self) 17 | 18 | return clone 19 | end 20 | 21 | function self:Copy (source) 22 | for callbackName, callback in pairs (source.Listeners) do 23 | self:AddListener (callbackName, callback) 24 | end 25 | 26 | return self 27 | end 28 | 29 | function self:AddListener (nameOrCallback, callback) 30 | callback = callback or nameOrCallback 31 | self.Listeners [nameOrCallback] = callback 32 | end 33 | 34 | function self:ClearListeners () 35 | self.Listeners = {} 36 | end 37 | 38 | function self:Dispatch (...) 39 | if self.ShouldSuppressEvents then return end 40 | 41 | local a, b, c = nil, nil, nil 42 | 43 | for callbackName, callback in pairs (self.Listeners) do 44 | local success, r0, r1, r2 = xpcall (callback, GLib.Error, ...) 45 | if not success then 46 | ErrorNoHalt ("Error in hook " .. eventName .. ": " .. tostring (callbackName) .. "!\n") 47 | else 48 | a = a or r0 49 | b = b or r1 50 | c = c or r2 51 | end 52 | end 53 | 54 | return a, b, c 55 | end 56 | 57 | function self:RemoveListener (nameOrCallback) 58 | self.Listeners [nameOrCallback] = nil 59 | end 60 | 61 | function self:SuppressEvents (suppress) 62 | self.ShouldSuppressEvents = suppress 63 | end 64 | 65 | function self:__call (...) 66 | return self:Dispatch (...) 67 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/formatting/date.lua: -------------------------------------------------------------------------------- 1 | function GLib.FormatDate (date) 2 | local dateTable = os.date ("*t", date) 3 | return string.format ("%02d/%02d/%04d %02d:%02d:%02d", dateTable.day, dateTable.month, dateTable.year, dateTable.hour, dateTable.min, dateTable.sec) 4 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/formatting/tableformatter.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.TableFormatter = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.ColumnWidths = {} 6 | self.Columns = {} 7 | 8 | self.RowCount = 0 9 | end 10 | 11 | function self:Append (...) 12 | local cells = {...} 13 | 14 | self.RowCount = self.RowCount + 1 15 | for k, v in ipairs (cells) do 16 | self.Columns [k] = self.Columns [k] or {} 17 | 18 | v = tostring (v) 19 | self.Columns [k] [self.RowCount] = v 20 | 21 | self.ColumnWidths [k] = math.max (self.ColumnWidths [k] or 0, GLib.UTF8.Length (v)) 22 | end 23 | 24 | return self 25 | end 26 | 27 | function self:Clear () 28 | self.ColumnWidths = {} 29 | self.Columns = {} 30 | 31 | self.RowCount = 0 32 | end 33 | 34 | function self:GetColumnCount () 35 | return #self.Columns 36 | end 37 | 38 | function self:ToString () 39 | local table = GLib.StringBuilder () 40 | 41 | local totalWidth = (self:GetColumnCount () - 1) * 3 42 | for i = 1, self:GetColumnCount () do 43 | totalWidth = totalWidth + self.ColumnWidths [i] 44 | end 45 | 46 | for i = 1, self.RowCount do 47 | for j = 1, self:GetColumnCount () do 48 | local cell = self.Columns [j] [i] or "" 49 | table:Append (cell) 50 | table:Append (string.rep (" ", self.ColumnWidths [j] - #cell)) 51 | 52 | if j < self:GetColumnCount () then 53 | table:Append (" | ") 54 | end 55 | end 56 | table:Append ("\n") 57 | 58 | -- if i < self.RowCount then 59 | -- table:Append (string.rep ("-", totalWidth)) 60 | -- table:Append ("\n") 61 | -- end 62 | end 63 | 64 | return table:ToString () 65 | end 66 | 67 | self.__tostring = self.ToString -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/garrysmod/io/fileinbuffer.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.FileInBuffer = GLib.MakeConstructor (self, GLib.InBuffer) 3 | 4 | function self:ctor (fileOrPath, pathId) 5 | if pathId then 6 | self.File = file.Open (fileOrPath, "rb", pathId) 7 | else 8 | self.File = fileOrPath 9 | end 10 | end 11 | 12 | function self:dtor () 13 | self.File:dtor () 14 | end 15 | 16 | -- Position 17 | function self:GetBytesRemaining () 18 | return self:GetSize () - self:GetPosition () 19 | end 20 | 21 | function self:GetPosition () 22 | return self.File:Tell () 23 | end 24 | 25 | function self:GetSize () 26 | return self.File:Size () 27 | end 28 | 29 | function self:IsEndOfStream () 30 | return self:GetPosition () >= self:GetSize () 31 | end 32 | 33 | function self:Pin () 34 | end 35 | 36 | function self:SeekRelative (relativeSeekPos) 37 | self:SeekAbsolute (self:GetPosition () + relativeSeekPos) 38 | end 39 | 40 | function self:SeekAbsolute (seekPos) 41 | seekPos = math.max (seekPos, self:GetSize ()) 42 | self.File:Seek (seekPos) 43 | end 44 | 45 | function self:UInt8 () 46 | return self.File:ReadByte () 47 | end 48 | 49 | function self:UInt16 () 50 | local n = self.File:ReadShort () 51 | if n < 0 then n = n + 65536 end 52 | return n 53 | end 54 | 55 | function self:UInt32 () 56 | local n = self.File:ReadLong () 57 | if n < 0 then n = n + 4294967296 end 58 | return n 59 | end 60 | 61 | function self:Int8 () 62 | local n = self.File:ReadByte () 63 | if n >= 128 then n = n - 256 end 64 | return n 65 | end 66 | 67 | function self:Int16 () 68 | return self.File:ReadShort () 69 | end 70 | 71 | function self:Int32 () 72 | return self.File:ReadLong () 73 | end 74 | 75 | function self:Float () 76 | return self.File:ReadFloat () 77 | end 78 | 79 | function self:Double () 80 | return self.File:ReadDouble () 81 | end 82 | 83 | function self:Bytes (length) 84 | if length == 0 then return "" end 85 | return self.File:Read (length) 86 | end 87 | -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/garrysmod/io/fileoutbuffer.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.FileOutBuffer = GLib.MakeConstructor (self, GLib.OutBuffer) 3 | -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/garrysmod/net/layer1/netchannel.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer1.NetChannel = GLib.MakeConstructor (self, GLib.Net.Layer1.Channel) 3 | 4 | local function PlayerFromUserId (userId) 5 | if type (userId) == "table" then 6 | -- Assume it's a SubscriberSet 7 | return userId:GetRecipientFilter () 8 | end 9 | 10 | if CLIENT and userId == GLib.GetServerId () then return nil end 11 | if userId == GLib.GetEveryoneId () then return player.GetAll () end 12 | 13 | local ply = GLib.PlayerMonitor:GetUserEntity (userId) 14 | if not ply then return {} end 15 | 16 | return ply 17 | end 18 | 19 | function self:ctor (channelName, handler) 20 | self.Open = false 21 | 22 | if SERVER then 23 | self:SetOpen (true) 24 | util.AddNetworkString (self:GetName ()) 25 | 26 | net.Receive (self:GetName (), 27 | function (bitCount, ply) 28 | self:GetHandler () (GLib.GetPlayerId (ply), GLib.Net.Layer1.NetInBuffer (math.ceil (bitCount / 8))) 29 | end 30 | ) 31 | else 32 | net.Receive (channelName, 33 | function (bitCount) 34 | self:GetHandler () (GLib.GetServerId (), GLib.Net.Layer1.NetInBuffer (math.ceil (bitCount / 8))) 35 | end 36 | ) 37 | end 38 | end 39 | 40 | -- Packets 41 | function self:DispatchPacket (destinationId, packet) 42 | if not self:IsOpen () then 43 | GLib.Error ("UsermessageChannel:DispatchPacket : Channel isn't open! (" .. tostring (destinationId) .. "." .. self:GetName () .. ")") 44 | end 45 | if packet:GetSize () > self:GetMTU () then 46 | GLib.Error ("UsermessageChannel:DispatchPacket : Packet for " .. tostring (destinationId) .. "." .. self:GetName () .. " exceeds MTU (" .. (packet:GetSize ()) .. ")!") 47 | end 48 | 49 | destinationId = PlayerFromUserId (destinationId) 50 | GLib.Net.Layer1.NetDispatcher:Dispatch (destinationId, self:GetName (), packet) 51 | end 52 | 53 | function self:GetMTU () 54 | return 65536 - #self:GetName () - 2 55 | end 56 | 57 | function self:IsDestinationRoutable (destinationId) 58 | if destinationId == GLib.GetEveryoneId () then return true end 59 | 60 | if CLIENT then return destinationId == GLib.GetServerId () end 61 | if SERVER then return GLib.PlayerMonitor:GetUserEntity (destinationId) ~= nil end 62 | 63 | return false 64 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/garrysmod/net/layer1/netdispatcher.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer1.NetDispatcher = GLib.MakeConstructor (self, GLib.OutBuffer) 3 | 4 | function self:ctor () 5 | end 6 | 7 | function self:Dispatch (ply, channelName, packet) 8 | net.Start (channelName) 9 | for i = 1, #packet.Data do 10 | local data = packet.Data [i] 11 | local typeId = packet.Types [i] 12 | 13 | self [GLib.Net.DataType [typeId]] (self, data) 14 | end 15 | if SERVER then 16 | net.Send (ply) 17 | else 18 | net.SendToServer () 19 | end 20 | end 21 | 22 | function self:UInt8 (n) 23 | net.WriteUInt (n, 8) 24 | end 25 | 26 | function self:UInt16 (n) 27 | net.WriteUInt (n, 16) 28 | end 29 | 30 | function self:UInt32 (n) 31 | if n >= 2147483648 then n = n - 4294967296 end -- Garry is special. 32 | net.WriteInt (n, 32) 33 | end 34 | 35 | function self:Int8 (n) 36 | net.WriteInt (n, 8) 37 | end 38 | 39 | function self:Int16 (n) 40 | net.WriteInt (n, 16) 41 | end 42 | 43 | function self:Int32 (n) 44 | net.WriteInt (n, 32) 45 | end 46 | 47 | function self:Float (f) 48 | net.WriteFloat (f) 49 | end 50 | 51 | function self:Double (f) 52 | net.WriteDouble (f) 53 | end 54 | 55 | function self:Bytes (data, length) 56 | length = length or #data 57 | length = math.min (length, #data) 58 | net.WriteData (data, length) 59 | end 60 | 61 | function self:String (data) 62 | self:StringN16 (data) 63 | end 64 | 65 | function self:LongString (data) 66 | self:StringN32 (data) 67 | end 68 | 69 | GLib.Net.Layer1.NetDispatcher = GLib.Net.Layer1.NetDispatcher () -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/garrysmod/net/layer1/netinbuffer.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer1.NetInBuffer = GLib.MakeConstructor (self, GLib.Net.InBuffer) 3 | 4 | function self:ctor (size) 5 | self.Position = 1 6 | 7 | self.Size = size or -1 8 | end 9 | 10 | function self:GetBytesRemaining () 11 | if self.Size == -1 then return -1 end 12 | return self.Size - self.Position + 1 13 | end 14 | 15 | function self:GetSize () 16 | return self.Size 17 | end 18 | 19 | function self:IsEndOfStream () 20 | return false 21 | end 22 | 23 | function self:Pin () 24 | local position = self:GetPosition () 25 | local data = self:Bytes (self:GetBytesRemaining ()) 26 | return GLib.Net.Layer1.PinnedNetInBuffer (self, position, data) 27 | end 28 | 29 | function self:UInt8 () 30 | self.Position = self.Position + 1 31 | return net.ReadUInt (8) 32 | end 33 | 34 | function self:UInt16 () 35 | self.Position = self.Position + 2 36 | return net.ReadUInt (16) 37 | end 38 | 39 | function self:UInt32 () 40 | self.Position = self.Position + 4 41 | local n = net.ReadUInt (32) 42 | if n < 0 then n = n + 4294967296 end -- So special. 43 | return n 44 | end 45 | 46 | function self:Int8 () 47 | self.Position = self.Position + 1 48 | return net.ReadInt (8) 49 | end 50 | 51 | function self:Int16 () 52 | self.Position = self.Position + 2 53 | return net.ReadInt (16) 54 | end 55 | 56 | function self:Int32 () 57 | self.Position = self.Position + 4 58 | return net.ReadInt (32) 59 | end 60 | 61 | function self:Float () 62 | self.Position = self.Position + 4 63 | return net.ReadFloat () 64 | end 65 | 66 | function self:Double () 67 | self.Position = self.Position + 8 68 | return net.ReadDouble () 69 | end 70 | 71 | function self:Bytes (length) 72 | self.Position = self.Position + length 73 | 74 | if length == 0 then return "" end -- Garry is special. 75 | local data = net.ReadData (length) 76 | return data 77 | end 78 | 79 | function self:String () 80 | return self:StringN16 () 81 | end 82 | 83 | function self:LongString () 84 | return self:StringN32 () 85 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/garrysmod/net/layer1/pinnednetinbuffer.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer1.PinnedNetInBuffer = GLib.MakeConstructor (self, GLib.Net.InBuffer) 3 | 4 | function self:ctor (netInBuffer, position, data) 5 | self.PositionOffset = position - 1 6 | self.InBuffer = GLib.StringInBuffer (data) 7 | end 8 | 9 | function self:GetBytesRemaining () 10 | return self.InBuffer:GetBytesRemaining () 11 | end 12 | 13 | function self:GetPosition () 14 | return self.InBuffer:GetPosition () + self.PositionOffset 15 | end 16 | 17 | function self:GetSize () 18 | return self.InBuffer:GetSize () + self.PositionOffset 19 | end 20 | 21 | function self:IsEndOfStream () 22 | return self.InBuffer:IsEndOfStream () 23 | end 24 | 25 | function self:Pin () 26 | return self 27 | end 28 | 29 | function self:UInt8 () 30 | return self.InBuffer:UInt8 () 31 | end 32 | 33 | function self:UInt16 () 34 | return self.InBuffer:UInt16 () 35 | end 36 | 37 | function self:UInt32 () 38 | return self.InBuffer:UInt32 () 39 | end 40 | 41 | function self:Int8 () 42 | return self.InBuffer:Int8 () 43 | end 44 | 45 | function self:Int16 () 46 | return self.InBuffer:Int16 () 47 | end 48 | 49 | function self:Int32 () 50 | return self.InBuffer:Int32 () 51 | end 52 | 53 | function self:Bytes (length) 54 | return self.InBuffer:Bytes (length) 55 | end 56 | 57 | function self:String () 58 | return self:StringN16 () 59 | end 60 | 61 | function self:LongString () 62 | return self:StringN32 () 63 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/garrysmod/net/layer1/pinnedusermessageinbuffer.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer1.PinnedUsermessageInBuffer = GLib.MakeConstructor (self, GLib.Net.InBuffer) 3 | 4 | function self:ctor (usermessageInBuffer) 5 | self.InBuffer = usermessageInBuffer:ToStringInBuffer () 6 | self.InBuffer:SeekAbsolute (usermessageInBuffer:GetPosition ()) 7 | end 8 | 9 | function self:GetBytesRemaining () 10 | return self.InBuffer:GetBytesRemaining () 11 | end 12 | 13 | function self:GetPosition () 14 | return self.InBuffer:GetPosition () 15 | end 16 | 17 | function self:GetSize () 18 | return self.InBuffer:GetSize () 19 | end 20 | 21 | function self:IsEndOfStream () 22 | return self.InBuffer:IsEndOfStream () 23 | end 24 | 25 | function self:Pin () 26 | return self 27 | end 28 | 29 | function self:UInt8 () 30 | return self.InBuffer:UInt8 () 31 | end 32 | 33 | function self:UInt16 () 34 | return self.InBuffer:UInt16 () 35 | end 36 | 37 | function self:UInt32 () 38 | return self.InBuffer:UInt32 () 39 | end 40 | 41 | function self:Int8 () 42 | return self.InBuffer:Int8 () 43 | end 44 | 45 | function self:Int16 () 46 | return self.InBuffer:Int16 () 47 | end 48 | 49 | function self:Int32 () 50 | return self.InBuffer:Int32 () 51 | end 52 | 53 | function self:Bytes (length) 54 | return self.InBuffer:Bytes (length) 55 | end 56 | 57 | function self:String () 58 | return self:StringN8 () 59 | end 60 | 61 | function self:LongString () 62 | return self:StringN32 () 63 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/garrysmod/net/layer1/usermessagechannel.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer1.UsermessageChannel = GLib.MakeConstructor (self, GLib.Net.Layer1.Channel) 3 | 4 | local function PlayerFromUserId (userId) 5 | if type (userId) == "table" then 6 | -- Assume it's a SubscriberSet 7 | return userId:GetRecipientFilter () 8 | end 9 | 10 | if CLIENT and userId == GLib.GetServerId () then return nil end 11 | if userId == GLib.GetEveryoneId () then 12 | local recipientFilter = RecipientFilter () 13 | recipientFilter:AddAllPlayers () 14 | return recipientFilter 15 | end 16 | 17 | local ply = GLib.PlayerMonitor:GetUserEntity (userId) 18 | if not ply then return nil end 19 | 20 | return ply 21 | end 22 | 23 | function self:ctor (channelName, handler) 24 | self.Open = false 25 | 26 | if SERVER then 27 | self:SetOpen (true) 28 | util.AddNetworkString (self:GetName ()) 29 | else 30 | usermessage.Hook (self:GetName (), 31 | function (umsg) 32 | self:GetHandler () (GLib.GetServerId (), GLib.Net.Layer1.UsermessageInBuffer (umsg)) 33 | end 34 | ) 35 | end 36 | end 37 | 38 | -- Packets 39 | function self:DispatchPacket (destinationId, packet) 40 | if not self:IsOpen () then 41 | GLib.Error ("UsermessageChannel:DispatchPacket : Channel isn't open! (" .. tostring (destinationId) .. "." .. self:GetName () .. ")") 42 | end 43 | if packet:GetSize () > self:GetMTU () then 44 | GLib.Error ("UsermessageChannel:DispatchPacket : Packet for " .. tostring (destinationId) .. "." .. self:GetName () .. " exceeds MTU (" .. (packet:GetSize ()) .. ")!") 45 | end 46 | 47 | destinationId = PlayerFromUserId (destinationId) 48 | if not destinationId then return end -- Drop packet 49 | 50 | GLib.Net.Layer1.UsermessageDispatcher:Dispatch (destinationId, self:GetName (), packet) 51 | end 52 | 53 | function self:GetMTU () 54 | if CLIENT then return -1 end 55 | 56 | return 256 - #self:GetName () - 2 57 | end 58 | 59 | function self:IsDestinationRoutable (destinationId) 60 | if destinationId == GLib.GetEveryoneId () then return true end 61 | 62 | if CLIENT then return destinationId == GLib.GetServerId () end 63 | if SERVER then return GLib.PlayerMonitor:GetUserEntity (destinationId) ~= nil end 64 | 65 | return false 66 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/garrysmod/net/layer1/usermessagedispatcher.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer1.UsermessageDispatcher = GLib.MakeConstructor (self, GLib.OutBuffer) 3 | 4 | function self:ctor () 5 | end 6 | 7 | function self:Dispatch (ply, channelName, packet) 8 | umsg.Start (channelName, ply) 9 | for i = 1, #packet.Data do 10 | local data = packet.Data [i] 11 | local typeId = packet.Types [i] 12 | 13 | self [GLib.Net.DataType [typeId]] (self, data) 14 | end 15 | umsg.End () 16 | end 17 | 18 | function self:UInt8 (n) 19 | if n >= 0x80 then n = n - 0x0100 end 20 | umsg.Char (n) 21 | end 22 | 23 | function self:UInt16 (n) 24 | if n >= 0x8000 then n = n - 0x00010000 end 25 | umsg.Short (n) 26 | end 27 | 28 | function self:UInt32 (n) 29 | if n >= 0x80000000 then n = n - 4294967296 end 30 | umsg.Long (n) 31 | end 32 | 33 | function self:Int8 (n) 34 | umsg.Char (n) 35 | end 36 | 37 | function self:Int16 (n) 38 | umsg.Short (n) 39 | end 40 | 41 | function self:Int32 (n) 42 | umsg.Long (n) 43 | end 44 | 45 | function self:Float (f) 46 | umsg.Float (f) 47 | end 48 | 49 | -- We don't use umsg.Vector because that doesn't actually send the vector as 3 floats 50 | 51 | function self:String (data) 52 | -- umsg.String can mix up uppercase / lowercase characters. 53 | self:StringN8 (data) 54 | end 55 | 56 | function self:LongString (data) 57 | self:StringN32 (data) 58 | end 59 | 60 | GLib.Net.Layer1.UsermessageDispatcher = GLib.Net.Layer1.UsermessageDispatcher () -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/garrysmod/net/layer1/usermessageinbuffer.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer1.UsermessageInBuffer = GLib.MakeConstructor (self, GLib.Net.InBuffer) 3 | 4 | function self:ctor (umsg) 5 | self.Usermessage = umsg 6 | 7 | -- Work out what our position really is 8 | self.Position = 1 9 | self.Usermessage:Reset () 10 | self:StringZ () -- The usermessage name 11 | end 12 | 13 | function self:GetBytesRemaining () 14 | return -1 15 | end 16 | 17 | function self:GetSize () 18 | return -1 19 | end 20 | 21 | function self:IsEndOfStream () 22 | return false 23 | end 24 | 25 | function self:Pin () 26 | return GLib.Net.Layer1.PinnedUsermessageInBuffer (self) 27 | end 28 | 29 | function self:UInt8 () 30 | self.Position = self.Position + 1 31 | 32 | local n = self.Usermessage:ReadChar () 33 | if n < 0 then n = n + 0x0100 end 34 | return n 35 | end 36 | 37 | function self:UInt16 () 38 | self.Position = self.Position + 2 39 | 40 | local n = self.Usermessage:ReadShort () 41 | if n < 0 then n = n + 0x00010000 end 42 | return n 43 | end 44 | 45 | function self:UInt32 () 46 | self.Position = self.Position + 4 47 | 48 | local n = self.Usermessage:ReadLong () 49 | if n < 0 then n = n + 4294967296 end 50 | return n 51 | end 52 | 53 | function self:Int8 () 54 | self.Position = self.Position + 1 55 | return self.Usermessage:ReadChar () 56 | end 57 | 58 | function self:Int16 () 59 | self.Position = self.Position + 2 60 | return self.Usermessage:ReadShort () 61 | end 62 | 63 | function self:Int32 () 64 | self.Position = self.Position + 4 65 | return self.Usermessage:ReadLong () 66 | end 67 | 68 | function self:Float () 69 | self.Position = self.Position + 4 70 | return self.Usermessage:ReadFloat () 71 | end 72 | 73 | function self:String () 74 | return self:StringN8 () 75 | end 76 | 77 | function self:LongString () 78 | return self:StringN32 () 79 | end 80 | 81 | function self:ToStringInBuffer () 82 | local outBuffer = GLib.StringOutBuffer () 83 | 84 | -- Copy buffer 85 | self.Usermessage:Reset () 86 | for i = 1, 256 do 87 | outBuffer:Int8 (self.Usermessage:ReadChar ()) 88 | end 89 | 90 | -- Reset position 91 | self.Usermessage:Reset () 92 | for i = 1, self.Position - 1 do 93 | self.Usermessage:ReadChar () 94 | end 95 | 96 | return GLib.StringInBuffer (outBuffer:GetString ()) 97 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/garrysmod/net/layer2/channel.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer2.Channel = GLib.MakeConstructor (self, GLib.Net.Layer2.Channel) 3 | 4 | function self:ctor (channelName, handler) 5 | self.UsermessageChannel = GLib.Net.Layer1.UsermessageChannel (channelName, handler) 6 | self.NetChannel = GLib.Net.Layer1.NetChannel (channelName, handler) 7 | self.SplitPacketChannel = GLib.Net.Layer2.SplitPacketChannel (channelName, handler, GLib.Net.Layer1.NetChannel (channelName .. "#")) 8 | 9 | self.Queue = {} 10 | 11 | self:Register () 12 | end 13 | 14 | function self:dtor () 15 | self.UsermessageChannel:dtor () 16 | self.NetChannel:dtor () 17 | self.SplitPacketChannel:dtor () 18 | 19 | self:Unregister () 20 | end 21 | 22 | -- Registration 23 | function self:Register () 24 | if self:IsRegistered () then return end 25 | 26 | GLib.Net.Layer2.RegisterChannel (self) 27 | self:SetRegistered (true) 28 | end 29 | 30 | function self:Unregister () 31 | if not self:IsRegistered () then return end 32 | 33 | GLib.Net.Layer2.UnregisterChannel (self) 34 | self:SetRegistered (false) 35 | end 36 | 37 | -- State 38 | function self:SetOpen (open) 39 | self.Open = open 40 | 41 | self.UsermessageChannel:SetOpen (open) 42 | self.NetChannel:SetOpen (open) 43 | self.SplitPacketChannel:GetInnerChannel ():SetOpen (open) 44 | self.SplitPacketChannel:SetOpen (open) 45 | 46 | -- Flush the queue if we've been opened 47 | if self.Open and #self.Queue > 0 then 48 | for _, packet in ipairs (self.Queue) do 49 | self:DispatchPacket (packet.DestinationId, packet) 50 | end 51 | 52 | self.Queue = {} 53 | end 54 | 55 | return self 56 | end 57 | 58 | -- Packets 59 | function self:DispatchPacket (destinationId, packet) 60 | if not self:IsOpen () then 61 | -- Channel not open, queue up message 62 | self.Queue [#self.Queue + 1] = packet 63 | packet.DestinationId = destinationId 64 | 65 | if #self.Queue == 1024 then 66 | GLib.Error ("Channel:DispatchPacket : " .. self:GetName () .. " queue is growing too long!") 67 | end 68 | 69 | return 70 | end 71 | 72 | if packet:GetSize () <= self.UsermessageChannel:GetMTU () then 73 | return self.UsermessageChannel:DispatchPacket (destinationId, packet) 74 | elseif packet:GetSize () <= self.NetChannel:GetMTU () then 75 | return self.NetChannel:DispatchPacket (destinationId, packet) 76 | else 77 | return self.SplitPacketChannel:DispatchPacket (destinationId, packet) 78 | end 79 | end 80 | 81 | function self:GetMTU () 82 | return self.SplitPacketChannel:GetMTU () 83 | end 84 | 85 | -- Handlers 86 | function self:GetHandler () 87 | return self.Handler 88 | end 89 | 90 | function self:SetHandler (handler) 91 | self.Handler = handler 92 | 93 | self.UsermessageChannel:SetHandler (handler) 94 | self.NetChannel:SetHandler (handler) 95 | self.SplitPacketChannel:SetHandler (handler) 96 | 97 | return self 98 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/garrysmod/net/net.lua: -------------------------------------------------------------------------------- 1 | function GLib.Net.DispatchPacket (destinationId, channelName, packet) 2 | local channel = GLib.Net.GetChannel (channelName) 3 | if not channel then return end 4 | 5 | return GLib.Net.GetChannel (channelName):DispatchPacket (destinationId, packet) 6 | end 7 | 8 | function GLib.Net.GetChannel (channelName) 9 | return GLib.Net.Layer5.GetChannel (channelName) or 10 | GLib.Net.Layer3.GetChannel (channelName) or 11 | GLib.Net.Layer2.GetChannel (channelName) 12 | end 13 | 14 | function GLib.Net.RegisterChannel (channelName, handler) 15 | return GLib.Net.Layer5.RegisterChannel (channelName, handler) 16 | end 17 | 18 | function GLib.Net.UnregisterChannel (channelName) 19 | return GLib.Net.Layer5.UnregisterChannel (channelName) 20 | end 21 | 22 | function GLib.Net.IsChannelOpen (channelName) 23 | local channel = GLib.Net.GetChannel (channelName) 24 | if not channel then return false end 25 | 26 | return channel:IsOpen () 27 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/garrysmod/servers/playermonitorentry.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.PlayerMonitorEntry = GLib.MakeConstructor (self) 3 | 4 | function self:ctor (ply) 5 | self.Player = ply 6 | self.Index = ply:EntIndex () 7 | self.SteamId = GLib.GetPlayerId (ply) 8 | self.UserId = ply:UserID () 9 | end 10 | 11 | function self:GetIndex () 12 | return self.Index 13 | end 14 | 15 | function self:GetPlayer () 16 | return self.Player 17 | end 18 | 19 | function self:GetSteamId () 20 | return self.SteamId 21 | end 22 | 23 | function self:GetUserId () 24 | return self.UserId 25 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/geometry/bezierspline.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Geometry.BezierSpline = GLib.MakeConstructor (self, GLib.Geometry.IParametricCurve) 3 | 4 | function self:ctor (dimensions) 5 | dimensions = dimensions or 3 6 | 7 | self.Dimensions = dimensions 8 | 9 | self.BezierMatrix = nil 10 | self.GeometryMatrix = GLib.Matrix (self.Dimensions, self:GetDegree () + 1) 11 | 12 | self.CMatrix = GLib.Matrix (self:GetDegree () + 1, self:GetDegree () + 1) 13 | self.CMatrixValid = false 14 | end 15 | 16 | function self:GetCMatrix () 17 | if not self.CMatrixValid then 18 | self.BezierMatrix:Multiply (self.GeometryMatrix, self.CMatrix) 19 | self.CMatrixValid = true 20 | end 21 | 22 | return self.CMatrix 23 | end 24 | 25 | function self:GetControlPoint (i, out) 26 | out = out or GLib.RowVector (self:GetDimensions ()) 27 | 28 | return self.GeometryMatrix:GetRow (i, out) 29 | end 30 | 31 | function self:GetDimensions () 32 | return self.Dimensions 33 | end 34 | 35 | function self:SetControlPoint (i, vector) 36 | self.GeometryMatrix:SetRow (i, vector) 37 | self.CMatrixValid = false 38 | end 39 | 40 | function self:Evaluate (t, out) 41 | if type (t) ~= "table" then 42 | t = GLib.Geometry.CreateParameterVector (self:GetDegree (), t, out) 43 | end 44 | 45 | out = out or GLib.RowVector () 46 | return t:Multiply (self:GetCMatrix (), out) 47 | end 48 | 49 | function self:EvaluateTangent (t, out) 50 | if type (t) ~= "table" then 51 | t = GLib.Geometry.CreateParameterTangentVector (self:GetDegree (), t, out) 52 | end 53 | 54 | out = out or GLib.RowVector () 55 | return t:Multiply (self:GetCMatrix (), out) 56 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/geometry/cubicbezierspline.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Geometry.CubicBezierSpline = GLib.MakeConstructor (self, GLib.Geometry.BezierSpline) 3 | 4 | GLib.Geometry.CubicBezierMatrix = GLib.Matrix (4, 4, 5 | -1, 3, -3, 1, 6 | 3, -6, 3, 0, 7 | -3, 3, 0, 0, 8 | 1, 0, 0, 0 9 | ) 10 | 11 | function self:ctor (dimensions) 12 | self.BezierMatrix = GLib.Geometry.CubicBezierMatrix 13 | end 14 | 15 | function self:GetDegree () 16 | return 3 17 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/geometry/iparametriccurve.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Geometry.IParametricCurve = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | end 6 | 7 | function self:Evaluate (t, out) 8 | GLib.Error ("IParametricCurve:Evaluate : Not implemented.") 9 | end 10 | 11 | function self:GetDegree () 12 | GLib.Error ("IParametricCurve:GetDegree : Not implemented.") 13 | return 2 14 | end 15 | 16 | function self:GetParameterMinimum () 17 | return 0 18 | end 19 | 20 | function self:GetParameterMaximum () 21 | return 1 22 | end 23 | 24 | function self:GetParameterRange () 25 | return self:GetParameterMinimum (), self:GetParameterMaximum () 26 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/geometry/iparametricsurface.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Geometry.IParametricSurface = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | end 6 | 7 | function self:Evaluate (t1, t2, out) 8 | GLib.Error ("IParametricSurface:Evaluate : Not implemented.") 9 | end 10 | 11 | function self:GetDegree () 12 | GLib.Error ("IParametricCurve:GetDegree : Not implemented.") 13 | return 2 14 | end 15 | 16 | function self:GetParameter1Minimum () 17 | return 0 18 | end 19 | 20 | function self:GetParameter1Maximum () 21 | return 1 22 | end 23 | 24 | function self:GetParameter2Minimum () 25 | return 0 26 | end 27 | 28 | function self:GetParameter2Maximum () 29 | return 1 30 | end 31 | 32 | function self:GetParameter1Range () 33 | return self:GetParameter1Minimum (), self:GetParameter1Maximum () 34 | end 35 | 36 | function self:GetParameter2Range () 37 | return self:GetParameter2Minimum (), self:GetParameter2Maximum () 38 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/geometry/parametriccurverenderer.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Geometry.ParametricCurveRenderer = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.ParameterVectors = {} 6 | self.ParameterTangentVectors = {} 7 | end 8 | 9 | function self:GetParameterVector (degree, t) 10 | self.ParameterVectors [degree] = GLib.Geometry.CreateParameterVector (degree, t, self.ParameterVectors [degree]) 11 | return self.ParameterVectors [degree] 12 | end 13 | 14 | function self:GetParameterTangentVector (degree, t) 15 | self.ParameterTangentVectors [degree] = GLib.Geometry.CreateParameterTangentVector (degree, t, self.ParameterTangentVectors [degree]) 16 | return self.ParameterTangentVectors [degree] 17 | end 18 | 19 | function self:Render (parametricCurve, lineSink) 20 | local range = parametricCurve:GetParameterMaximum () - parametricCurve:GetParameterMinimum () 21 | local interval = range / 100 22 | 23 | local degree = parametricCurve:GetDegree () 24 | 25 | local lastPoint = parametricCurve:Evaluate (self:GetParameterVector (degree, parametricCurve:GetParameterMinimum ())) 26 | local currentPoint 27 | for t = parametricCurve:GetParameterMinimum () + interval, parametricCurve:GetParameterMaximum (), interval do 28 | currentPoint = parametricCurve:Evaluate (self:GetParameterVector (degree, t), currentPoint) 29 | currentPoint:Clone (v2) 30 | 31 | lineSink (lastPoint, currentPoint) 32 | 33 | local temp = lastPoint 34 | lastPoint = currentPoint 35 | currentPoint = temp 36 | end 37 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/geometry/parametricgeometry.lua: -------------------------------------------------------------------------------- 1 | function GLib.Geometry.CreateParameterVector (degree, t, out) 2 | if degree == 1 then return t end 3 | 4 | out = out or GLib.RowVector (degree + 1) 5 | 6 | local element = 1 7 | for i = degree + 1, 1, -1 do 8 | out [i] = element 9 | element = element * t 10 | end 11 | 12 | return out 13 | end 14 | 15 | function GLib.Geometry.CreateParameterTangentVector (degree, t, out) 16 | if degree == 1 then return 1 end 17 | 18 | out = out or GLib.RowVector (degree + 1) 19 | 20 | for i = 1, degree do 21 | out [i] = (degree - i + 1) * t ^ (degree - i) 22 | end 23 | 24 | return out 25 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/geometry/quadraticbezierspline.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Geometry.QuadraticBezierSpline = GLib.MakeConstructor (self, GLib.Geometry.BezierSpline) 3 | 4 | GLib.Geometry.QuadraticBezierMatrix = GLib.Matrix (3, 3, 5 | 1, -2, 1, 6 | -2, 2, 0, 7 | 1, 0, 0 8 | ) 9 | 10 | function self:ctor (dimensions) 11 | self.BezierMatrix = GLib.Geometry.QuadraticBezierMatrix 12 | end 13 | 14 | function self:GetDegree () 15 | return 2 16 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/glib.lua: -------------------------------------------------------------------------------- 1 | include ("glib/stage1.lua") 2 | 3 | if SERVER or 4 | file.Exists ("glib/stage2.lua", "LUA") or 5 | file.Exists ("glib/stage2.lua", "LCL") and GetConVar ("sv_allowcslua"):GetBool () then 6 | include ("glib/stage2.lua") 7 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/glue.lua: -------------------------------------------------------------------------------- 1 | function GLib.BindCustomProperty (destinationObject, setterName, sourceObject, getterName, eventName, eventId) 2 | destinationObject [setterName] (destinationObject, sourceObject [getterName] (sourceObject)) 3 | 4 | if not eventName then return end 5 | eventId = eventId or tostring (destinationObject) 6 | 7 | if not sourceObject.AddEventListener then return end 8 | 9 | sourceObject:AddEventListener (eventName, eventId, 10 | function () 11 | destinationObject [setterName] (destinationObject, sourceObject [getterName] (sourceObject)) 12 | end 13 | ) 14 | end 15 | 16 | function GLib.BindProperty (destinationObject, sourceObject, propertyName, eventId) 17 | local setterName = "Set" .. propertyName 18 | local getterName = "Get" .. propertyName 19 | if not sourceObject [getterName] then 20 | getterName = "Is" .. propertyName 21 | end 22 | local eventName = propertyName .. "Changed" 23 | 24 | GLib.BindCustomProperty (destinationObject, setterName, sourceObject, getterName, eventName, eventId) 25 | end 26 | 27 | function GLib.UnbindCustomProperty (destinationObject, setterName, sourceObject, getterName, eventName, eventId) 28 | if not eventName then return end 29 | eventId = eventId or tostring (destinationObject) 30 | 31 | if not sourceObject.RemoveEventListener then return end 32 | 33 | sourceObject:RemoveEventListener (eventName, eventId) 34 | end 35 | 36 | function GLib.UnbindProperty (destinationObject, sourceObject, propertyName, eventId) 37 | local setterName = "Set" .. propertyName 38 | local getterName = "Get" .. propertyName 39 | if not sourceObject [getterName] then 40 | getterName = "Is" .. propertyName 41 | end 42 | local eventName = propertyName .. "Changed" 43 | 44 | GLib.UnbindCustomProperty (destinationObject, setterName, sourceObject, getterName, eventName, eventId) 45 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/invoker.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Invoker = GLib.MakeConstructor (self, GLib.Event) 3 | 4 | function self:ctor () 5 | end 6 | 7 | function self:dtor () 8 | self:Clear () 9 | end 10 | 11 | function self:AddDestructor (nameOrObject, object) 12 | object = object or nameOrObject 13 | self:AddListener (nameOrObject, 14 | function () 15 | object:dtor () 16 | end 17 | ) 18 | return self 19 | end 20 | 21 | function self:AddFunction (nameOrCallback, callback) 22 | self:AddListener (nameOrCallback, callback) 23 | return self 24 | end 25 | 26 | function self:AddThreadAbortion (nameOrThread, thread) 27 | thread = thread or nameOrThread 28 | self:AddListener (nameOrThread, 29 | function () 30 | thread:Terminate () 31 | end 32 | ) 33 | return self 34 | end 35 | 36 | function self:Clear () 37 | self:ClearListeners () 38 | end 39 | 40 | function self:Invoke (...) 41 | return self:Dispatch (...) 42 | end 43 | 44 | function self:Remove (nameOrCallback) 45 | self:RemoveListener (nameOrCallback) 46 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/io/stringoutbuffer.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.StringOutBuffer = GLib.MakeConstructor (self, GLib.OutBuffer) 3 | 4 | local bit_band = bit.band 5 | local bit_rshift = bit.rshift 6 | 7 | local math_floor = math.floor 8 | local math_min = math.min 9 | 10 | local string_char = string.char 11 | local string_sub = string.sub 12 | 13 | local table_concat = table.concat 14 | 15 | function self:ctor () 16 | self.Data = {} 17 | end 18 | 19 | function self:Clear () 20 | self.Data = {} 21 | end 22 | 23 | function self:GetSize () 24 | return #self:GetString () 25 | end 26 | 27 | function self:GetString () 28 | if #self.Data > 1 then 29 | self.Data = { table_concat (self.Data) } 30 | end 31 | return self.Data [1] or "" 32 | end 33 | 34 | function self:UInt8 (n) self.Data [#self.Data + 1] = string_char (GLib.BitConverter.UInt8ToUInt8s (n)) end 35 | function self:UInt16 (n) self.Data [#self.Data + 1] = string_char (GLib.BitConverter.UInt16ToUInt8s (n)) end 36 | function self:UInt32 (n) self.Data [#self.Data + 1] = string_char (GLib.BitConverter.UInt32ToUInt8s (n)) end 37 | function self:UInt64 (n) self.Data [#self.Data + 1] = string_char (GLib.BitConverter.UInt64ToUInt8s (n)) end 38 | function self:Int8 (n) self.Data [#self.Data + 1] = string_char (GLib.BitConverter.Int8ToUInt8s (n)) end 39 | function self:Int16 (n) self.Data [#self.Data + 1] = string_char (GLib.BitConverter.Int16ToUInt8s (n)) end 40 | function self:Int32 (n) self.Data [#self.Data + 1] = string_char (GLib.BitConverter.Int32ToUInt8s (n)) end 41 | function self:Int64 (n) self.Data [#self.Data + 1] = string_char (GLib.BitConverter.Int64ToUInt8s (n)) end 42 | 43 | function self:Bytes (data, length) 44 | length = length or #data 45 | length = math_min (length, #data) 46 | self.Data [#self.Data + 1] = length == #data and data or string_sub (data, 1, length) 47 | end 48 | 49 | function self:String (data) 50 | self:StringN16 (data) 51 | end 52 | 53 | function self:LongString (data) 54 | self:StringN32 (data) 55 | end 56 | 57 | self.__len = self.GetSize 58 | self.__tostring = self.GetString -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/backup.lua: -------------------------------------------------------------------------------- 1 | local backupTable = GLib.GetSessionVariable ("GLib", "LuaBackup", {}) 2 | 3 | function GLib.Lua.GetBackup (tableName, key) 4 | return GLib.Lua.GetBackupTable (tableName) [key] 5 | end 6 | 7 | function GLib.Lua.GetBackupTable (tableName) 8 | backupTable [tableName] = backupTable [tableName] or {} 9 | return backupTable [tableName] 10 | end 11 | 12 | function GLib.Lua.Backup (fullyQualifiedName) 13 | if type (fullyQualifiedName) == "table" then 14 | for _, v in ipairs (fullyQualifiedName) do 15 | GLib.Lua.Backup (v) 16 | end 17 | return 18 | end 19 | 20 | local value, table, tableName, key = GLib.Lua.GetTableValue (fullyQualifiedName) 21 | 22 | GLib.Lua.BackupTableMember (tableName, key, value) 23 | end 24 | 25 | function GLib.Lua.BackupTableMember (tableName, key, value) 26 | local backupTable = GLib.Lua.GetBackupTable (tableName) 27 | 28 | if value == nil then 29 | value = GLib.Lua.GetTable (tableName) [key] 30 | end 31 | 32 | backupTable [key] = backupTable [key] or value 33 | end 34 | 35 | function GLib.Lua.BackupTable (tableName, table) 36 | local backupTable = GLib.Lua.GetBackupTable (tableName) 37 | 38 | table = table or GLib.Lua.GetTable (tableName) 39 | 40 | for k, v in pairs (table) do 41 | backupTable [k] = backupTable [k] or v 42 | end 43 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/decompiler/bytecodeflags.lua: -------------------------------------------------------------------------------- 1 | GLib.Lua.BytecodeFlags = GLib.Enum ( 2 | { 3 | BigEndian = 0x01, 4 | DebugInformationStripped = 0x02, 5 | FFI = 0x04 6 | } 7 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/decompiler/functionconstant.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Lua.FunctionConstant = GLib.MakeConstructor (self, GLib.Lua.GarbageCollectedConstant) 3 | 4 | function self:ctor () 5 | self.Function = nil 6 | self.Type = GLib.Lua.GarbageCollectedConstantType.Function 7 | end 8 | 9 | function self:GetFunction () 10 | return self.Function 11 | end 12 | 13 | function self:Deserialize (type, inBuffer) 14 | end 15 | 16 | function self:GetLuaString () 17 | if self.Function then 18 | return self.Function:ToString () 19 | end 20 | return "function () --[[ Closure ]] end" 21 | end 22 | 23 | function self:SetFunction (functionBytecodeReader) 24 | self.Function = functionBytecodeReader 25 | end 26 | 27 | function self:ToString () 28 | return "{ Function: " .. self:GetLuaString () .. " }" 29 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/decompiler/garbagecollectedconstant.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Lua.GarbageCollectedConstant = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.Index = 1 6 | 7 | self.Type = nil 8 | self.Value = nil 9 | end 10 | 11 | function self:GetIndex () 12 | return self.Index 13 | end 14 | 15 | function self:GetType () 16 | return self.Type 17 | end 18 | 19 | function self:GetLuaString () 20 | return tostring (self:GetValue ()) 21 | end 22 | 23 | function self:GetValue () 24 | return self.Value 25 | end 26 | 27 | function self:Deserialize (type, inBuffer) 28 | GLib.Error ("GarbageCollectedConstant:Deserialize : Not implemented.") 29 | end 30 | 31 | function self:SetIndex (index) 32 | self.Index = index 33 | end 34 | 35 | function self:SetType (type) 36 | self.Type = type 37 | end 38 | 39 | function self:SetValue (value) 40 | self.Value = value 41 | end 42 | 43 | function self:ToString () 44 | return "{ " .. (GLib.Lua.GarbageCollectedConstantType [self:GetType ()] or "InvalidConstant") .. " }" 45 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/decompiler/garbagecollectedconstanttype.lua: -------------------------------------------------------------------------------- 1 | GLib.Lua.GarbageCollectedConstantType = GLib.Enum ( 2 | { 3 | Function = 0, 4 | Table = 1, 5 | Int64 = 2, 6 | UInt64 = 3, 7 | Complex = 4, 8 | String = 5 9 | } 10 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/decompiler/opcodeinfo.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Lua.OpcodeInfo = GLib.MakeConstructor (self) 3 | 4 | function self:ctor (opcode, name) 5 | self.Opcode = opcode 6 | self.Name = name 7 | 8 | self.OperandAType = GLib.Lua.OperandType.None 9 | self.OperandBType = GLib.Lua.OperandType.None 10 | self.OperandCType = GLib.Lua.OperandType.None 11 | self.OperandDType = GLib.Lua.OperandType.None 12 | 13 | self.FunctionName = nil 14 | end 15 | 16 | function self:GetFunctionName () 17 | return self.FunctionName 18 | end 19 | 20 | function self:GetName () 21 | return self.Name 22 | end 23 | 24 | function self:GetOpcode () 25 | return self.Opcode 26 | end 27 | 28 | function self:GetOperandAType () 29 | return self.OperandAType 30 | end 31 | 32 | function self:GetOperandBType () 33 | return self.OperandBType 34 | end 35 | 36 | function self:GetOperandCType () 37 | return self.OperandCType 38 | end 39 | 40 | function self:GetOperandDType () 41 | return self.OperandDType 42 | end 43 | 44 | function self:SetFunctionName (functionName) 45 | self.FunctionName = functionName 46 | end 47 | 48 | function self:SetName (name) 49 | self.Name = name 50 | end 51 | 52 | function self:SetOperandAType (operandAType) 53 | self.OperandAType = operandAType 54 | end 55 | 56 | function self:SetOperandBType (operandBType) 57 | self.OperandBType = operandBType 58 | end 59 | 60 | function self:SetOperandCType (operandCType) 61 | self.OperandCType = operandCType 62 | end 63 | 64 | function self:SetOperandDType (operandDType) 65 | self.OperandDType = operandDType 66 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/decompiler/opcodes.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Lua.Opcodes = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.Opcodes = {} 6 | end 7 | 8 | function self:AddOpcode (opcode, name) 9 | self.Opcodes [opcode] = GLib.Lua.OpcodeInfo (opcode, name) 10 | return self.Opcodes [opcode] 11 | end 12 | 13 | function self:GetOpcode (opcode) 14 | if type (opcode) == "string" then 15 | opcode = GLib.Lua.Opcode [opcode] 16 | end 17 | 18 | if type (opcode) ~= "number" then return nil end 19 | 20 | return self.Opcodes [opcode] 21 | end 22 | 23 | GLib.Lua.Opcodes = GLib.Lua.Opcodes () -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/decompiler/operandtype.lua: -------------------------------------------------------------------------------- 1 | GLib.Lua.OperandType = GLib.Enum ( 2 | { 3 | None = 0, 4 | Variable = 1, 5 | DestinationVariable = 2, 6 | WritableBase = 3, 7 | ReadOnlyBase = 4, 8 | UpvalueId = 5, 9 | Literal = 6, 10 | SignedLiteral = 7, 11 | Primitive = 8, 12 | NumericConstantId = 9, 13 | StringConstantId = 10, 14 | TableConstantId = 11, 15 | FunctionConstantId = 12, 16 | CDataConstantId = 13, 17 | RelativeJump = 14 18 | } 19 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/decompiler/precedence.lua: -------------------------------------------------------------------------------- 1 | GLib.Lua.Precedence = GLib.Enum ( 2 | { 3 | Lowest = 0, 4 | Addition = 1, 5 | Subtraction = 2, 6 | Multiplication = 3, 7 | Division = 4, 8 | Modulo = 5, 9 | Exponentiation = 6, 10 | LeftUnaryOperator = 7, 11 | Atom = 8 12 | } 13 | ) 14 | 15 | local associativePrecedences = 16 | { 17 | [GLib.Lua.Precedence.Addition] = true, 18 | [GLib.Lua.Precedence.Multiplication] = true, 19 | [GLib.Lua.Precedence.LeftUnaryOperator] = true 20 | } 21 | 22 | function GLib.Lua.IsPrecedenceAssociative (precedence) 23 | return associativePrecedences [precedence] or false 24 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/decompiler/stringconstant.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Lua.StringConstant = GLib.MakeConstructor (self, GLib.Lua.GarbageCollectedConstant) 3 | 4 | function self:ctor (str) 5 | self.Type = GLib.Lua.GarbageCollectedConstantType.String 6 | self.Length = 0 7 | self.Value = str or "" 8 | end 9 | 10 | function self:Deserialize (type, inBuffer) 11 | self.Length = type - GLib.Lua.GarbageCollectedConstantType.String 12 | self.Value = inBuffer:Bytes (self.Length) 13 | end 14 | 15 | function self:GetLuaString () 16 | return "\"" .. GLib.String.EscapeNonprintable (self.Value) .. "\"" 17 | end 18 | 19 | function self:ToString () 20 | return "{ String: " .. self:GetLuaString () .. " }" 21 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/decompiler/tablekeyvaluetype.lua: -------------------------------------------------------------------------------- 1 | GLib.Lua.TableKeyValueType = GLib.Enum ( 2 | { 3 | Nil = 0, 4 | False = 1, 5 | True = 2, 6 | Integer = 3, 7 | Double = 4, 8 | String = 5 9 | } 10 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/detours.lua: -------------------------------------------------------------------------------- 1 | function GLib.Lua.Detour (functionName, detourFunction) 2 | if type (functionName) == "table" then 3 | for _, v in ipairs (functionName) do 4 | GLib.Lua.Detour (v, detourFunction) 5 | end 6 | return 7 | end 8 | 9 | local originalFunction, table, tableName, functionName = GLib.Lua.GetTableValue (functionName) 10 | 11 | GLib.Lua.BackupTableMember (tableName, functionName, originalFunction) 12 | 13 | local backupTable = GLib.Lua.GetBackupTable (tableName) 14 | table [functionName] = function (...) 15 | return detourFunction (backupTable [functionName], ...) 16 | end 17 | end 18 | 19 | function GLib.Lua.Undetour (functionName) 20 | if type (functionName) == "table" then 21 | for _, v in ipairs (functionName) do 22 | GLib.Lua.Undetour (v) 23 | end 24 | return 25 | end 26 | 27 | local _, table, tableName, functionName = GLib.Lua.GetTableValue (functionName) 28 | table [functionName] = GLib.Lua.GetBackup (tableName, functionName) or table [functionName] 29 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/reflection/argumentlist.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Lua.ArgumentList = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | 6 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/reflection/function.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Lua.Function = GLib.MakeConstructor (self, GLib.Serialization.ISerializable) 3 | 4 | function GLib.Lua.Function.ctor (func) 5 | if func then 6 | return GLib.Lua.FunctionCache:GetFunction (func) 7 | end 8 | 9 | return GLib.Lua.Function.__ictor () 10 | end 11 | 12 | function GLib.Lua.Function.FromFunction (func) 13 | if type (func) == "table" then 14 | func = func:GetRawFunction () 15 | end 16 | 17 | return GLib.Lua.Function.__ictor (func) 18 | end 19 | 20 | function self:ctor (func) 21 | self.Function = func 22 | self.InfoTable = func and debug.getinfo (func) or nil 23 | 24 | self.ParameterList = nil 25 | 26 | -- Definition 27 | self.FilePath = self.InfoTable and self.InfoTable.short_src 28 | 29 | self.StartLine = self.InfoTable and self.InfoTable.linedefined 30 | self.EndLine = self.InfoTable and self.InfoTable.lastlinedefined 31 | 32 | self.Native = self.InfoTable and self.InfoTable.what == "C" 33 | end 34 | 35 | -- ISerializable 36 | function self:Serialize (outBuffer) 37 | self:GetParameterList ():Serialize (outBuffer) 38 | 39 | outBuffer:StringN32 (self.FilePath ) 40 | outBuffer:UInt32 (self.StartLine) 41 | outBuffer:UInt32 (self.EndLine ) 42 | outBuffer:Boolean (self.Native ) 43 | 44 | return outBuffer 45 | end 46 | 47 | function self:Deserialize (inBuffer) 48 | self:GetParameterList ():Deserialize (inBuffer) 49 | 50 | self.FilePath = inBuffer:StringN32 () 51 | self.StartLine = inBuffer:UInt32 () 52 | self.EndLine = inBuffer:UInt32 () 53 | self.Native = inBuffer:Boolean () 54 | 55 | return self 56 | end 57 | 58 | -- Function 59 | function self:GetStartLine () 60 | return self.StartLine 61 | end 62 | 63 | function self:GetEndLine () 64 | return self.EndLine 65 | end 66 | 67 | function self:GetLineRange () 68 | return self.StartLine, self.EndLine 69 | end 70 | 71 | function self:GetFilePath () 72 | return self.FilePath 73 | end 74 | 75 | function self:GetFunction () 76 | return self.Function 77 | end 78 | 79 | function self:GetInfoTable () 80 | return self.InfoTable 81 | end 82 | 83 | function self:GetName () 84 | return GLib.Lua.GetFunctionName (self.Function) 85 | end 86 | 87 | function self:GetPrototype () 88 | return "function " .. self:GetParameterList ():ToString () 89 | end 90 | 91 | function self:GetParameterList () 92 | if self.ParameterList == nil then 93 | self.ParameterList = GLib.Lua.ParameterList (self) 94 | end 95 | 96 | return self.ParameterList 97 | end 98 | 99 | function self:GetRawFunction () 100 | return self.Function 101 | end 102 | 103 | function self:IsNative () 104 | return self.Native 105 | end 106 | 107 | function self:ToString () 108 | return "function " .. self:GetParameterList ():ToString () 109 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/reflection/functioncache.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Lua.FunctionCache = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | -- Avoid having the cache directly accessible from _G 6 | local cache = GLib.WeakTable () 7 | self.GetCache = function () 8 | return cache 9 | end 10 | end 11 | 12 | function self:ContainsFunction (func) 13 | return self:GetCache () [func] ~= nil 14 | end 15 | 16 | function self:GetFunction (func) 17 | local cache = self:GetCache () 18 | 19 | if cache [func] then 20 | return cache [func] 21 | end 22 | 23 | local functionInfo = GLib.Lua.Function.FromFunction (func) 24 | cache [func] = functionInfo 25 | 26 | return functionInfo 27 | end 28 | 29 | GLib.Lua.FunctionCache = GLib.Lua.FunctionCache () -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/reflection/localvariableframe.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Lua.LocalVariableFrame = GLib.MakeConstructor (self, GLib.Lua.VariableFrame) 3 | 4 | function GLib.Lua.LocalVariableFrame.ctor (frameOffset) 5 | return GLib.Lua.LocalVariableFrame.__ictor (frameOffset, nil, GLib.Lua.StackCaptureOptions.None) 6 | end 7 | 8 | function GLib.Lua.LocalVariableFrame.CreateForStackFrame (frameOffset, stackFrame, stackCaptureOptions) 9 | return GLib.Lua.LocalVariableFrame.__ictor (frameOffset, stackFrame, stackCaptureOptions) 10 | end 11 | 12 | function self:ctor (frameOffset, stackFrame, stackCaptureOptions) 13 | frameOffset = frameOffset or 0 14 | frameOffset = 4 + frameOffset 15 | stackCaptureOptions = stackCaptureOptions or GLib.Lua.StackCaptureOptions.None 16 | 17 | local i = 1 18 | local localCount = math.huge 19 | 20 | if bit.band (stackCaptureOptions, GLib.Lua.StackCaptureOptions.Arguments) ~= 0 then 21 | localCount = stackFrame:GetFunction ():GetParameterList ():GetFixedParameterCount () 22 | 23 | if stackFrame:GetFunction ():IsNative () then 24 | localCount = math.huge 25 | end 26 | end 27 | 28 | for i = 1, localCount do 29 | local name, value = debug.getlocal (frameOffset, i) 30 | if name == nil and value == nil then break end 31 | 32 | self:AddVariableAtIndex (i, name, value) 33 | 34 | i = i + 1 35 | end 36 | 37 | -- Variadic arguments 38 | i = -1 39 | while true do 40 | local name, value = debug.getlocal (frameOffset, i) 41 | if name == nil and value == nil then break end 42 | 43 | self:AddVariableAtIndex (i, name, value) 44 | 45 | i = i - 1 46 | end 47 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/reflection/parameter.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Lua.Parameter = GLib.MakeConstructor (self, GLib.Serialization.ISerializable) 3 | 4 | function self:ctor (parameterList, name) 5 | self.ParameterList = parameterList 6 | 7 | self.Name = name 8 | self.Variadic = false 9 | 10 | self.FrameIndex = nil 11 | end 12 | 13 | -- ISerializable 14 | function self:Serialize (outBuffer) 15 | outBuffer:StringN32 (self.Name ) 16 | outBuffer:Boolean (self.Variadic) 17 | outBuffer:Int32 (self.FrameIndex or 0) 18 | 19 | return outBuffer 20 | end 21 | 22 | function self:Deserialize (inBuffer) 23 | self.Name = inBuffer:StringN32 () 24 | self.Variadic = inBuffer:Boolean () 25 | self.FrameIndex = inBuffer:Int32 () 26 | 27 | return self 28 | end 29 | 30 | -- Parameter 31 | function self:GetFrameIndex () 32 | return self.FrameIndex 33 | end 34 | 35 | function self:GetName () 36 | return self.Name 37 | end 38 | 39 | function self:GetParameterList () 40 | return self.ParameterList 41 | end 42 | 43 | function self:IsVariadic () 44 | return self.Variadic 45 | end 46 | 47 | function self:SetFrameIndex (frameIndex) 48 | self.FrameIndex = frameIndex 49 | return self 50 | end 51 | 52 | function self:SetName (name) 53 | self.Name = name 54 | return self 55 | end 56 | 57 | function self:SetVariadic (isVariadic) 58 | self.Variadic = isVariadic 59 | return self 60 | end 61 | 62 | function self:ToString () 63 | if self:IsVariadic () then return "..." end 64 | 65 | return self.Name 66 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/reflection/stackcaptureoptions.lua: -------------------------------------------------------------------------------- 1 | GLib.Lua.StackCaptureOptions = GLib.Enum ( 2 | { 3 | None = 0, 4 | Arguments = 1, 5 | Locals = 2, 6 | Upvalues = 4 7 | } 8 | ) 9 | -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/reflection/stacktracecache.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Lua.StackTraceCache = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.Cache = {} 6 | end 7 | 8 | function self:AddStackTrace (stackTrace) 9 | if self.Cache [stackTrace:GetHash ()] then 10 | return self.Cache [stackTrace:GetHash ()] 11 | end 12 | 13 | self.Cache [stackTrace:GetHash ()] = stackTrace 14 | 15 | return stackTrace 16 | end 17 | 18 | function self:CreateStackTrace (offset) 19 | offset = offset or 0 20 | local stackTrace = GLib.Lua.StackTrace (nil, offset + 1) 21 | stackTrace = self:AddStackTrace (stackTrace) 22 | return stackTrace 23 | end 24 | 25 | function self:Clear () 26 | self.Cache = {} 27 | end 28 | 29 | function self:GetStackTrace (hash) 30 | return self.Cache [hash] 31 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/reflection/upvalueframe.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Lua.UpvalueFrame = GLib.MakeConstructor (self, GLib.Lua.VariableFrame) 3 | 4 | function self:ctor (func) 5 | if type (func) == "table" then 6 | func = func:GetRawFunction () 7 | end 8 | 9 | local i = 1 10 | while true do 11 | local name, value = debug.getupvalue (func, i) 12 | if name == nil then break end 13 | 14 | self:AddVariableAtIndex (i, name, value) 15 | 16 | i = i + 1 17 | end 18 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/lua/sessionvariables.lua: -------------------------------------------------------------------------------- 1 | local sessionVariables = {} 2 | 3 | if GetGLibSessionVariables then 4 | sessionVariables = GetGLibSessionVariables () 5 | end 6 | 7 | function GetGLibSessionVariables () 8 | return sessionVariables 9 | end 10 | 11 | function GLib.GetSessionVariable (namespace, name, defaultValue) 12 | sessionVariables [namespace] = sessionVariables [namespace] or {} 13 | 14 | if sessionVariables [namespace] [name] == nil then 15 | sessionVariables [namespace] [name] = defaultValue 16 | end 17 | 18 | return sessionVariables [namespace] [name] 19 | end 20 | 21 | function GLib.SetSessionVariable (namespace, name, value) 22 | sessionVariables [namespace] = sessionVariables [namespace] or {} 23 | sessionVariables [namespace] [name] = value 24 | 25 | return sessionVariables [namespace] [name] 26 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/math/columnvector.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | local ctor = GLib.MakeConstructor (self, GLib.Vector) 3 | 4 | function GLib.ColumnVector (h, ...) 5 | return ctor (1, h, ...) 6 | end 7 | 8 | function self:SetElementCount (elementCount) 9 | self.Height = elementCount 10 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/math/rowvector.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | local ctor = GLib.MakeConstructor (self, GLib.Vector) 3 | 4 | function GLib.RowVector (w, ...) 5 | return ctor (w, 1, ...) 6 | end 7 | 8 | function self:SetElementCount (elementCount) 9 | self.Width = elementCount 10 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/math/vector.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Vector = GLib.MakeConstructor (self, GLib.Matrix) 3 | 4 | function self:ctor (w, h, m1, ...) 5 | end 6 | 7 | function self:Clone (clone) 8 | clone = clone or self.__ictor () 9 | 10 | clone:Copy (self) 11 | 12 | return clone 13 | end 14 | 15 | function self:Copy (source) 16 | self.Width = source.Width 17 | self.Height = source.Height 18 | 19 | for i = 1, source:GetElementCount () do 20 | self [i] = source [i] 21 | end 22 | 23 | return self 24 | end 25 | 26 | function self:Add (b, out) 27 | out = out or self.__ictor (self:GetElementCount ()) 28 | 29 | out.Width = self.Width 30 | out.Height = self.Height 31 | 32 | for i = 1, self:GetElementCount () do 33 | out [i] = self [i] + b [i] 34 | end 35 | 36 | return b 37 | end 38 | 39 | function self:Cross (b, out) 40 | out = out or self.__ictor (self:GetElementCount ()) 41 | 42 | out.Width = self.Width 43 | out.Height = self.Height 44 | 45 | out [1] = self [2] * b [3] - self [3] * b [2] 46 | out [2] = self [3] * b [1] - self [1] * b [3] 47 | out [3] = self [1] * b [2] - self [2] * b [1] 48 | 49 | return out 50 | end 51 | 52 | function self:Dot (b) 53 | local dot = 0 54 | 55 | for i = 1, self:GetElementCount () do 56 | dot = dot + self [i] * b [i] 57 | end 58 | 59 | return dot 60 | end 61 | 62 | function self:Length () 63 | return math.sqrt (self:LengthSquared ()) 64 | end 65 | 66 | function self:LengthSquared () 67 | local lengthSquared = 0 68 | 69 | for i = 1, self:GetElementCount () do 70 | lengthSquared = lengthSquared + self [i] * self [i] 71 | end 72 | 73 | return lengthSquared 74 | end 75 | 76 | function self:Negate (out) 77 | out = out or self.__ictor (self:GetElementCount ()) 78 | 79 | out.Width = self.Width 80 | out.Height = self.Height 81 | 82 | for i = 1, self:GetElementCount () do 83 | out [i] = -self [i] 84 | end 85 | 86 | return b 87 | end 88 | 89 | function self:Subtract (b, out) 90 | out = out or self.__ictor (self:GetElementCount ()) 91 | 92 | out.Width = self.Width 93 | out.Height = self.Height 94 | 95 | for i = 1, self:GetElementCount () do 96 | out [i] = self [i] - b [i] 97 | end 98 | 99 | return b 100 | end 101 | 102 | function self:Transpose (rowVector) 103 | rowVector = rowVector or self.__ictor (self:GetElementCount ()) 104 | rowVector.Width = self.Height 105 | rowVector.Height = 1 106 | 107 | for i = 1, self:GetElementCount () do 108 | rowVector [i] = self [i] 109 | end 110 | 111 | return rowVector 112 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/math/vmatrix.lua: -------------------------------------------------------------------------------- 1 | local self = debug.getregistry ().VMatrix 2 | GLib.VMatrix = {} 3 | 4 | local v = Vector () 5 | function GLib.VMatrix.FromMatrix (matrix, out) 6 | -- This better be a 3d affine transformation matrix 7 | if matrix.Width ~= 3 and matrix.Width ~= 4 then 8 | GLib.Error ("VMatrix.FromMatrix : This matrix is " .. matrix.Height .. " by " .. matrix.Width .. "!") 9 | elseif matrix.Height ~= 3 and matrix.Height ~= 4 then 10 | GLib.Error ("VMatrix.FromMatrix : This matrix is " .. matrix.Height .. " by " .. matrix.Width .. "!") 11 | end 12 | 13 | out = out or Matrix () 14 | 15 | -- First 3 rows 16 | out:SetForward (matrix:GetColumn (1, v)) 17 | 18 | v = matrix:GetColumn (2, v) 19 | v.x = -v.x 20 | v.y = -v.y 21 | v.z = -v.z 22 | out:SetRight (v) 23 | 24 | out:SetUp (matrix:GetColumn (3, v)) 25 | if matrix.Width == 4 then 26 | out:SetTranslation (matrix:GetColumn (4, v)) 27 | end 28 | 29 | -- Last row 30 | out:SetField (4, 1, matrix:GetElement (4, 1)) 31 | out:SetField (4, 2, matrix:GetElement (4, 2)) 32 | out:SetField (4, 3, matrix:GetElement (4, 3)) 33 | out:SetField (4, 4, matrix:GetElement (4, 4)) 34 | 35 | return out 36 | end 37 | 38 | function GLib.VMatrix.ToMatrix (vmatrix, out) 39 | out = out or GLib.Matrix (4, 4) 40 | out.Width = 4 41 | out.Height = 4 42 | 43 | -- First 3 rows 44 | out:SetColumn (1, vmatrix:GetForward ()) 45 | 46 | local right = vmatrix:GetRight () 47 | right.x = -right.x 48 | right.y = -right.y 49 | right.z = -right.z 50 | out:SetColumn (2, right) 51 | 52 | out:SetColumn (3, vmatrix:GetUp ()) 53 | out:SetColumn (4, vmatrix:GetTranslation ()) 54 | 55 | -- Last row 56 | out:SetElement (4, 1, vmatrix:GetField (4, 1)) 57 | out:SetElement (4, 2, vmatrix:GetField (4, 2)) 58 | out:SetElement (4, 3, vmatrix:GetField (4, 3)) 59 | out:SetElement (4, 4, vmatrix:GetField (4, 4)) 60 | 61 | return out 62 | end 63 | 64 | function self:ToMatrix (out) 65 | return GLib.VMatrix.ToMatrix (self, out) 66 | end 67 | 68 | function self:ToString () 69 | return self:ToMatrix ():ToString () 70 | end 71 | 72 | local self = debug.getregistry ().Vector 73 | 74 | function self:ToColumnVector (out) 75 | out = out or GLib.ColumnVector (3) 76 | 77 | out [1] = self.x 78 | out [2] = self.y 79 | out [3] = self.z 80 | 81 | return out 82 | end 83 | 84 | function self:ToRowVector (out) 85 | out = out or GLib.RowVector (3) 86 | 87 | out [1] = self.x 88 | out [2] = self.y 89 | out [3] = self.z 90 | 91 | return out 92 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/connections/connectionclosurereason.lua: -------------------------------------------------------------------------------- 1 | GLib.Net.ConnectionClosureReason = GLib.Enum ( 2 | { 3 | LocalClosure = 1, 4 | RemoteClosure = 2, 5 | Timeout = 4, 6 | CarrierLost = 8, 7 | TheApocalypse = 16 8 | } 9 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/connections/connectionendpoint.lua: -------------------------------------------------------------------------------- 1 | GLib.Net.ConnectionEndpoint = GLib.Enum ( 2 | { 3 | Local = 1, 4 | Remote = 2 5 | } 6 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/connections/connectionpackettype.lua: -------------------------------------------------------------------------------- 1 | GLib.Net.ConnectionPacketType = GLib.Enum ( 2 | { 3 | Open = 1, 4 | Data = 2, 5 | Close = 4 6 | } 7 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/connections/connectionstate.lua: -------------------------------------------------------------------------------- 1 | GLib.Net.ConnectionState = GLib.Enum ( 2 | { 3 | Opening = 1, -- Awaiting first packet 4 | Open = 2, -- First packet received 5 | Closing = 4, -- Needs to send closure packet 6 | Closed = 8 -- Closure packet sent 7 | } 8 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/datatype.lua: -------------------------------------------------------------------------------- 1 | GLib.Net.DataType = GLib.Enum ( 2 | { 3 | UInt8 = 0, 4 | UInt16 = 1, 5 | UInt32 = 2, 6 | UInt64 = 3, 7 | Int8 = 4, 8 | Int16 = 5, 9 | Int32 = 6, 10 | Int64 = 7, 11 | Float = 8, 12 | Double = 9, 13 | Vector = 10, 14 | Char = 11, 15 | Bytes = 12, 16 | String = 13, 17 | LongString = 14, 18 | Boolean = 15, 19 | } 20 | ) 21 | 22 | GLib.Net.DataTypeSizes = 23 | { 24 | Boolean = 1, 25 | UInt8 = 1, 26 | UInt16 = 2, 27 | UInt32 = 4, 28 | UInt64 = 8, 29 | Int8 = 1, 30 | Int16 = 2, 31 | Int32 = 4, 32 | Int64 = 8, 33 | Float = 4, 34 | Double = 8, 35 | Vector = 12, 36 | Char = 1, 37 | Bytes = function (data) return #data end, 38 | String = function (str) return #str + 1 end, 39 | LongString = function (str) return #str + 4 end 40 | } -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/ichannel.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.IChannel = GLib.MakeConstructor (self) 3 | 4 | --[[ 5 | Events: 6 | NameChanged (oldName, name) 7 | Fired when this channel's name has been changed. 8 | Registered () 9 | Fired when this channel has been registered. 10 | Unregistered () 11 | Fired when this channel has been unregistered. 12 | ]] 13 | 14 | function self:ctor (channelName, handler) 15 | -- Identity 16 | self.Name = channelName 17 | 18 | -- Registration 19 | self.Registered = false 20 | 21 | -- State 22 | self.Open = false 23 | 24 | -- Handlers 25 | self.Handler = handler or GLib.NullCallback 26 | 27 | GLib.EventProvider (self) 28 | end 29 | 30 | function self:dtor () 31 | if self:IsRegistered () then 32 | self:Unregister () 33 | end 34 | end 35 | 36 | -- Identity 37 | function self:GetName () 38 | return self.Name 39 | end 40 | 41 | function self:SetName (name) 42 | if self.Name == name then return self end 43 | 44 | local lastName = self.Name 45 | self.Name = name 46 | self:DispatchEvent ("NameChanged", lastName, self.Name) 47 | 48 | return self 49 | end 50 | 51 | -- Registration 52 | function self:IsRegistered () 53 | return self.Registered 54 | end 55 | 56 | function self:Register () 57 | GLib.Error ("IChannel:Register : Not implemented.") 58 | end 59 | 60 | function self:Unregister () 61 | GLib.Error ("IChannel:Unregister : Not implemented.") 62 | end 63 | 64 | function self:SetRegistered (registered) 65 | if self.Registered == registered then return self end 66 | 67 | self.Registered = registered 68 | self:DispatchEvent (self.Registered and "Registered" or "Unregistered") 69 | 70 | return self 71 | end 72 | 73 | -- State 74 | function self:IsOpen (destinationId) 75 | return self.Open 76 | end 77 | 78 | function self:SetOpen (open) 79 | self.Open = open 80 | return self 81 | end 82 | 83 | -- Packets 84 | function self:DispatchPacket (destinationId, packet) 85 | GLib.Error ("IChannel:DispatchPacket : Not implemented.") 86 | end 87 | 88 | function self:GetMTU () 89 | GLib.Error ("IChannel:GetMTU : Not implemented.") 90 | end 91 | 92 | function self:HandlePacket (sourceId, inBuffer) 93 | return self:GetHandler () (sourceId, inBuffer) 94 | end 95 | 96 | function self:IsDestinationRoutable (destinationId) 97 | GLib.Error ("IChannel:IsDestinationRoutable : Not implemented.") 98 | end 99 | 100 | -- Handlers 101 | function self:GetHandler () 102 | return self.Handler 103 | end 104 | 105 | function self:SetHandler (handler) 106 | self.Handler = handler 107 | return self 108 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/inbuffer.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.InBuffer = GLib.MakeConstructor (self, GLib.InBuffer) 3 | 4 | function self:ctor () 5 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/isingleendpointchannel.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.ISingleEndpointChannel = GLib.MakeConstructor (self) 3 | 4 | --[[ 5 | Events: 6 | NameChanged (oldName, name) 7 | Fired when this channel's name has been changed. 8 | RemoteIdChanged (oldRemoteId, remoteId) 9 | Fired when this channel's remote endpoint has been changed. 10 | ]] 11 | 12 | function self:ctor () 13 | -- Identity 14 | self.Name = nil 15 | self.RemoteId = nil 16 | 17 | -- State 18 | self.Open = false 19 | 20 | -- Handlers 21 | self.Handler = handler or GLib.NullCallback 22 | 23 | GLib.EventProvider (self) 24 | end 25 | 26 | -- Identity 27 | function self:GetName () 28 | return self.Name 29 | end 30 | 31 | function self:GetRemoteId () 32 | return self.RemoteId 33 | end 34 | 35 | function self:SetName (name) 36 | if self.Name == name then return self end 37 | 38 | local oldName = self.Name 39 | self.Name = name 40 | self:DispatchEvent ("NameChanged", oldName, self.Name) 41 | 42 | return self 43 | end 44 | 45 | function self:SetRemoteId (remoteId) 46 | if self.RemoteId == remoteId then return self end 47 | 48 | local oldRemoteId = self.RemoteId 49 | self.RemoteId = remoteId 50 | self:DispatchEvent ("RemoteIdChanged", oldRemoteId, self.RemoteId) 51 | 52 | return self 53 | end 54 | 55 | -- State 56 | function self:IsOpen () 57 | return self.Open 58 | end 59 | 60 | function self:SetOpen (open) 61 | self.Open = open 62 | return self 63 | end 64 | 65 | -- Packets 66 | function self:DispatchPacket (packet) 67 | GLib.Error ("ISingleEndpointChannel:DispatchPacket : Not implemented.") 68 | end 69 | 70 | function self:GetMTU () 71 | GLib.Error ("ISingleEndpointChannel:GetMTU : Not implemented.") 72 | end 73 | 74 | function self:HandlePacket (inBuffer) 75 | return self:GetHandler () (self:GetRemoteId (), inBuffer) 76 | end 77 | 78 | function self:IsDestinationRoutable (destinationId) 79 | return destinationId == self:GetRemoteId () 80 | end 81 | 82 | -- Handlers 83 | function self:GetHandler () 84 | return self.Handler 85 | end 86 | 87 | function self:SetHandler (handler) 88 | self.Handler = handler 89 | return self 90 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/layer1/channel.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer1.Channel = GLib.MakeConstructor (self, GLib.Net.IChannel) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/layer2/channel.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer2.Channel = GLib.MakeConstructor (self, GLib.Net.IChannel) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/layer2/inboundsplitpacket.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer2.InboundSplitPacket = GLib.MakeConstructor (self) 3 | 4 | function self:ctor (id) 5 | self.Id = id 6 | 7 | self.Data = nil 8 | 9 | self.EncodedData = nil 10 | self.EncodedLength = 0 11 | 12 | self.Chunks = {} 13 | self.ChunkSize = 0 14 | self.ChunkCount = 0 15 | self.NextChunk = 1 16 | end 17 | 18 | function self:GetData () 19 | return self.Data 20 | end 21 | 22 | function self:GetId () 23 | return self.Id 24 | end 25 | 26 | function self:IsFinished () 27 | return self.NextChunk > 1 and self.NextChunk > self.ChunkCount 28 | end 29 | 30 | function self:IsStarted () 31 | return self.NextChunk > 1 32 | end 33 | 34 | function self:DeserializeFirstChunk (inBuffer) 35 | self.EncodedLength = inBuffer:UInt32 () 36 | self:SetChunkSize (inBuffer:UInt32 ()) 37 | self:DeserializeNextChunk (inBuffer) 38 | end 39 | 40 | function self:DeserializeNextChunk (inBuffer) 41 | self.Chunks [#self.Chunks + 1] = inBuffer:LongString () 42 | self.NextChunk = self.NextChunk + 1 43 | 44 | if self:IsFinished () then 45 | self:DecodeData () 46 | end 47 | end 48 | 49 | function self:SetId (id) 50 | self.Id = id 51 | end 52 | 53 | -- Internal, do not call 54 | function self:DecodeData () 55 | self.EncodedData = table.concat (self.Chunks) 56 | self.Data = self.EncodedData 57 | end 58 | 59 | function self:SetChunkSize (chunkSize) 60 | if self:IsStarted () then 61 | GLib.Error ("InboundTransfer:SetChunkSize : Cannot set chunk size after a transfer has started.") 62 | end 63 | 64 | self.ChunkSize = chunkSize 65 | self.ChunkCount = math.ceil (self.EncodedLength / self.ChunkSize) 66 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/layer2/layer2.lua: -------------------------------------------------------------------------------- 1 | local channels = GLib_Net_Layer2_GetChannels and GLib_Net_Layer2_GetChannels () or {} 2 | GLib.Net.Layer2.Channels = channels 3 | 4 | function GLib_Net_Layer2_GetChannels () 5 | return channels 6 | end 7 | 8 | --[[ 9 | Events: 10 | ChannelRegistered (Channel channel) 11 | Fired when a channel has been registered. 12 | ChannelUnregistered (Channel channel) 13 | Fired when a channel has been unregistered. 14 | ]] 15 | 16 | GLib.EventProvider (GLib.Net.Layer2) 17 | 18 | function GLib.Net.Layer2.DispatchPacket (destinationId, channelName, packet) 19 | local channel = GLib.Net.Layer2.GetChannel (channelName) 20 | if not channel then 21 | GLib.Error ("GLib.Net.Layer2.DispatchPacket : Channel " .. channelName .. " doesn't exist.") 22 | return 23 | end 24 | 25 | return channel:DispatchPacket (destinationId, packet) 26 | end 27 | 28 | function GLib.Net.Layer2.GetChannel (channelName) 29 | return GLib.Net.Layer2.Channels [channelName] 30 | end 31 | 32 | function GLib.Net.Layer2.RegisterChannel (channel, ...) 33 | if type (channel) == "string" then 34 | return GLib.Net.Layer2.RegisterChannelByName (channel, ...) 35 | end 36 | 37 | local channelName = channel:GetName () 38 | 39 | if GLib.Net.Layer2.Channels [channelName] == channel then return channel end 40 | 41 | if GLib.Net.Layer2.Channels [channelName] then 42 | channel:SetOpen (GLib.Net.Layer2.Channels [channelName]:IsOpen ()) 43 | GLib.Net.Layer2.Channels [channelName]:dtor () 44 | end 45 | 46 | GLib.Net.Layer2.Channels [channelName] = channel 47 | 48 | if SERVER then 49 | channel:SetOpen (true) 50 | end 51 | 52 | GLib.Net.Layer2:DispatchEvent ("ChannelRegistered", channel) 53 | 54 | return channel 55 | end 56 | 57 | function GLib.Net.Layer2.RegisterChannelByName (channelName, handler) 58 | local channel = GLib.Net.Layer2.GetChannel (channelName) 59 | if channel then 60 | channel:SetHandler (handler) 61 | return channel 62 | end 63 | 64 | channel = GLib.Net.Layer2.Channel (channelName, handler) 65 | return GLib.Net.Layer2.RegisterChannel (channel) 66 | end 67 | 68 | function GLib.Net.Layer2.UnregisterChannel (channelOrChannelName) 69 | if type (channelOrChannelName) ~= "string" then 70 | channelOrChannelName = channelOrChannelName:GetName () 71 | end 72 | 73 | return GLib.Net.Layer2.UnregisterChannelByName (channelOrChannelName) 74 | end 75 | 76 | function GLib.Net.Layer2.UnregisterChannelByName (channelName) 77 | if not GLib.Net.Layer2.Channels [channelName] then return end 78 | 79 | local channel = GLib.Net.Layer2.Channels [channelName] 80 | GLib.Net.Layer2.Channels [channelName] = nil 81 | channel:dtor () 82 | 83 | GLib.Net.Layer2:DispatchEvent ("ChannelUnregistered", channel) 84 | end 85 | 86 | function GLib.Net.Layer2.IsChannelOpen (channelName) 87 | if not GLib.Net.Layer2.Channels [channelName] then return false end 88 | 89 | return GLib.Net.Layer2.Channels [channelName]:IsOpen () 90 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/layer2/outboundsplitpacket.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer2.OutboundSplitPacket = GLib.MakeConstructor (self) 3 | 4 | function self:ctor (id, data) 5 | self.Id = id 6 | 7 | self.Data = data 8 | 9 | self.EncodedData = data 10 | self.EncodedLength = #self.EncodedData 11 | 12 | self.ChunkSize = 0 13 | self.ChunkCount = 0 14 | self.NextChunk = 1 15 | end 16 | 17 | function self:GetId () 18 | return self.Id 19 | end 20 | 21 | function self:IsFinished () 22 | return self.NextChunk > 1 and self.NextChunk > self.ChunkCount 23 | end 24 | 25 | function self:IsStarted () 26 | return self.NextChunk > 1 27 | end 28 | 29 | function self:SerializeFirstChunk (outBuffer) 30 | outBuffer:UInt32 (self.EncodedLength) 31 | outBuffer:UInt32 (self.ChunkSize) 32 | self:SerializeNextChunk (outBuffer) 33 | end 34 | 35 | function self:SerializeNextChunk (outBuffer) 36 | -- Include the next chunk 37 | local chunkStart = (self.NextChunk - 1) * self.ChunkSize + 1 38 | local chunkEnd = self.NextChunk * self.ChunkSize 39 | local chunk = string.sub (self.EncodedData, chunkStart, chunkEnd) 40 | 41 | outBuffer:LongString (chunk) 42 | 43 | self.NextChunk = self.NextChunk + 1 44 | end 45 | 46 | function self:SetChunkSize (chunkSize) 47 | if self:IsStarted () then 48 | GLib.Error ("OutboundSplitPacket:SetChunkSize : Cannot set chunk size after transmission has started.") 49 | end 50 | 51 | self.ChunkSize = chunkSize 52 | self.ChunkCount = math.ceil (self.EncodedLength / self.ChunkSize) 53 | end 54 | 55 | function self:SetId (id) 56 | self.Id = id 57 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/layer2/splitpackettype.lua: -------------------------------------------------------------------------------- 1 | GLib.Net.Layer2.SplitPacketType = GLib.Enum ( 2 | { 3 | Start = 1, 4 | Continuation = 2 5 | } 6 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/layer3/channel.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer3.Channel = GLib.MakeConstructor (self, GLib.Net.IChannel) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/layer3/layer2channel.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer3.Layer2Channel = GLib.MakeConstructor (self, GLib.Net.Layer3.Channel) 3 | 4 | function GLib.Net.Layer3.Layer2Channel.ctor (channelName, handler, innerChannel) 5 | if type (channelName) ~= "string" then 6 | innerChannel = channelName 7 | channelName = innerChannel:GetName () 8 | end 9 | 10 | innerChannel = innerChannel or GLib.Net.Layer2.GetChannel (channelName) 11 | innerChannel = innerChannel or GLib.Net.Layer2.RegisterChannel (channelName) 12 | 13 | return GLib.Net.Layer3.Layer2Channel.__ictor (channelName, handler, innerChannel) 14 | end 15 | 16 | function self:ctor (channelName, handler, innerChannel) 17 | self.InnerChannel = innerChannel 18 | self.InnerChannel:SetHandler (handler) 19 | 20 | self:Register () 21 | end 22 | 23 | function self:dtor () 24 | self:Unregister () 25 | end 26 | 27 | -- Registration 28 | function self:Register () 29 | if self:IsRegistered () then return end 30 | 31 | GLib.Net.Layer3.RegisterChannel (self) 32 | self:SetRegistered (true) 33 | end 34 | 35 | function self:Unregister () 36 | if not self:IsRegistered () then return end 37 | 38 | GLib.Net.Layer3.UnregisterChannel (self) 39 | self:SetRegistered (false) 40 | end 41 | 42 | -- State 43 | function self:IsOpen (destinationId) 44 | return self.InnerChannel:IsOpen (destinationId) 45 | end 46 | 47 | function self:SetOpen (open) 48 | self.InnerChannel:SetOpen (open) 49 | return self 50 | end 51 | 52 | -- Packets 53 | function self:DispatchPacket (destinationId, packet) 54 | return self.InnerChannel:DispatchPacket (destinationId, packet) 55 | end 56 | 57 | function self:GetMTU () 58 | return self.InnerChannel:GetMTU () 59 | end 60 | 61 | function self:IsDestinationRoutable (destinationId) 62 | return self.InnerChannel:IsDestinationRoutable (destinationId) 63 | end 64 | 65 | -- Handlers 66 | function self:GetHandler () 67 | return self.InnerChannel:GetHandler () 68 | end 69 | 70 | function self:SetHandler (handler) 71 | self.InnerChannel:SetHandler (handler) 72 | self.Handler = handler 73 | return self 74 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/layer3/layer3.lua: -------------------------------------------------------------------------------- 1 | local channels = GLib_Net_Layer3_GetChannels and GLib_Net_Layer3_GetChannels () or {} 2 | GLib.Net.Layer3.Channels = channels 3 | 4 | function GLib_Net_Layer3_GetChannels () 5 | return channels 6 | end 7 | 8 | --[[ 9 | Events: 10 | ChannelRegistered (Channel channel) 11 | Fired when a channel has been registered. 12 | ChannelUnregistered (Channel channel) 13 | Fired when a channel has been unregistered. 14 | ]] 15 | 16 | GLib.EventProvider (GLib.Net.Layer3) 17 | 18 | function GLib.Net.Layer3.DispatchPacket (destinationId, channelName, packet) 19 | local channel = GLib.Net.Layer3.GetChannel (channelName) 20 | if not channel then 21 | GLib.Error ("GLib.Net.Layer3.DispatchPacket : Channel " .. channelName .. " doesn't exist.") 22 | return 23 | end 24 | 25 | return channel:DispatchPacket (destinationId, packet) 26 | end 27 | 28 | function GLib.Net.Layer3.GetChannel (channelName) 29 | return GLib.Net.Layer3.Channels [channelName] 30 | end 31 | 32 | function GLib.Net.Layer3.RegisterLayer2Channel (channelName, handler, innerChannel) 33 | local channel = GLib.Net.Layer3.Layer2Channel (channelName, handler, innerChannel) 34 | return GLib.Net.Layer3.RegisterChannel (channel) 35 | end 36 | 37 | function GLib.Net.Layer3.RegisterRoutedChannel (channelName, handler, innerChannel) 38 | local channel = GLib.Net.Layer3.RoutedChannel (channelName, handler, innerChannel) 39 | return GLib.Net.Layer3.RegisterChannel (channel) 40 | end 41 | 42 | function GLib.Net.Layer3.RegisterChannel (channel, ...) 43 | if type (channel) == "string" then 44 | return GLib.Net.Layer3.RegisterLayer2Channel (channel, ...) 45 | end 46 | 47 | local channelName = channel:GetName () 48 | 49 | if GLib.Net.Layer3.Channels [channelName] == channel then return channel end 50 | 51 | if GLib.Net.Layer3.Channels [channelName] then 52 | channel:SetOpen (GLib.Net.Layer3.Channels [channelName]:IsOpen ()) 53 | GLib.Net.Layer3.Channels [channelName]:dtor () 54 | end 55 | 56 | GLib.Net.Layer3.Channels [channelName] = channel 57 | 58 | if SERVER then 59 | channel:SetOpen (true) 60 | end 61 | 62 | GLib.Net.Layer3:DispatchEvent ("ChannelRegistered", channel) 63 | 64 | return channel 65 | end 66 | 67 | function GLib.Net.Layer3.UnregisterChannel (channelOrChannelName) 68 | if type (channelOrChannelName) ~= "string" then 69 | channelOrChannelName = channelOrChannelName:GetName () 70 | end 71 | 72 | return GLib.Net.Layer3.UnregisterChannelByName (channelOrChannelName) 73 | end 74 | 75 | function GLib.Net.Layer3.UnregisterChannelByName (channelName) 76 | if not GLib.Net.Layer3.Channels [channelName] then return end 77 | 78 | local channel = GLib.Net.Layer3.Channels [channelName] 79 | GLib.Net.Layer3.Channels [channelName] = nil 80 | channel:dtor () 81 | 82 | GLib.Net.Layer3:DispatchEvent ("ChannelUnregistered", channel) 83 | end 84 | 85 | function GLib.Net.Layer3.IsChannelOpen (channelName) 86 | if not GLib.Net.Layer3.Channels [channelName] then return false end 87 | 88 | return GLib.Net.Layer3.Channels [channelName]:IsOpen () 89 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/layer5/channel.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer5.Channel = GLib.MakeConstructor (self, GLib.Net.IChannel) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/layer5/connectionrunner.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer5.ConnectionRunner = GLib.MakeConstructor (self, GLib.Net.ConnectionRunner) 3 | 4 | function self:ctor () 5 | for _, channel in pairs (GLib.Net.Layer5.Channels) do 6 | self:RegisterChannel (channel) 7 | end 8 | 9 | GLib.Net.Layer5:AddEventListener ("ChannelRegistered", "GLib.Net.Layer5.ConnectionRunner", 10 | function (_, channel) 11 | self:RegisterChannel (channel) 12 | end 13 | ) 14 | 15 | GLib.Net.Layer5:AddEventListener ("ChannelUnregistered", "GLib.Net.Layer5.ConnectionRunner", 16 | function (_, channel) 17 | self:UnregisterChannel (channel) 18 | end 19 | ) 20 | end 21 | 22 | function self:dtor () 23 | GLib.Net.Layer5:RemoveEventListener ("ChannelRegistered", "GLib.Net.Layer5.ConnectionRunner") 24 | GLib.Net.Layer5:RemoveEventListener ("ChannelUnregistered", "GLib.Net.Layer5.ConnectionRunner") 25 | end 26 | 27 | GLib.Net.Layer5.ConnectionRunner = GLib.Net.Layer5.ConnectionRunner () -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/layer5/layer3channel.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer5.Layer3Channel = GLib.MakeConstructor (self, GLib.Net.Layer5.Channel) 3 | 4 | function GLib.Net.Layer5.Layer3Channel.ctor (channelName, handler, innerChannel) 5 | if type (channelName) ~= "string" then 6 | innerChannel = channelName 7 | channelName = innerChannel:GetName () 8 | end 9 | 10 | innerChannel = innerChannel or GLib.Net.Layer3.GetChannel (channelName) 11 | innerChannel = innerChannel or GLib.Net.Layer3.RegisterChannel (channelName) 12 | 13 | return GLib.Net.Layer5.Layer3Channel.__ictor (channelName, handler, innerChannel) 14 | end 15 | 16 | function self:ctor (channelName, handler, innerChannel) 17 | self.InnerChannel = innerChannel 18 | self.InnerChannel:SetHandler (handler) 19 | 20 | self:Register () 21 | end 22 | 23 | function self:dtor () 24 | self:Unregister () 25 | end 26 | 27 | -- Registration 28 | function self:Register () 29 | if self:IsRegistered () then return end 30 | 31 | GLib.Net.Layer5.RegisterChannel (self) 32 | self:SetRegistered (true) 33 | end 34 | 35 | function self:Unregister () 36 | if not self:IsRegistered () then return end 37 | 38 | GLib.Net.Layer5.UnregisterChannel (self) 39 | self:SetRegistered (false) 40 | end 41 | 42 | -- State 43 | function self:IsOpen () 44 | return self.InnerChannel:IsOpen () 45 | end 46 | 47 | function self:SetOpen (open) 48 | self.InnerChannel:SetOpen (open) 49 | return self 50 | end 51 | 52 | -- Packets 53 | function self:DispatchPacket (destinationId, packet) 54 | return self.InnerChannel:DispatchPacket (destinationId, packet) 55 | end 56 | 57 | function self:GetMTU () 58 | return self.InnerChannel:GetMTU () 59 | end 60 | 61 | -- Handlers 62 | function self:GetHandler () 63 | return self.InnerChannel:GetHandler () 64 | end 65 | 66 | function self:SetHandler (handler) 67 | self.InnerChannel:SetHandler (handler) 68 | self.Handler = handler 69 | return self 70 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/layer5/orderedchannel.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.Layer5.OrderedChannel = GLib.MakeConstructor (self, GLib.Net.EndpointChannelMultiplexer) 3 | 4 | function GLib.Net.Layer5.OrderedChannel.ctor (channelName, handler, innerChannel) 5 | if type (channelName) ~= "string" then 6 | innerChannel = channelName 7 | channelName = innerChannel:GetName () 8 | end 9 | 10 | innerChannel = innerChannel or GLib.Net.Layer3.GetChannel (channelName) 11 | innerChannel = innerChannel or GLib.Net.Layer3.RegisterChannel (channelName) 12 | 13 | return GLib.Net.Layer5.OrderedChannel.__ictor (channelName, handler, innerChannel) 14 | end 15 | 16 | function self:ctor (channelName, handler, innerChannel) 17 | self:Register () 18 | end 19 | 20 | function self:dtor () 21 | self:Unregister () 22 | end 23 | 24 | -- Registration 25 | function self:Register () 26 | if self:IsRegistered () then return end 27 | 28 | GLib.Net.Layer5.RegisterChannel (self) 29 | self:SetRegistered (true) 30 | end 31 | 32 | function self:Unregister () 33 | if not self:IsRegistered () then return end 34 | 35 | GLib.Net.Layer5.UnregisterChannel (self) 36 | self:SetRegistered (false) 37 | end 38 | 39 | -- Packets 40 | function self:GetMTU () 41 | return self.InnerChannel:GetMTU () - 4 42 | end 43 | 44 | function self:IsDestinationRoutable (destinationId) 45 | return self.InnerChannel:IsDestinationRoutable (destinationId) 46 | end 47 | 48 | -- Internal, do not call 49 | function self:CreateSingleEndpointChannel (remoteId) 50 | if self.SingleEndpointChannels [remoteId] then return self.SingleEndpointChannels [remoteId] end 51 | 52 | local singleEndpointChannel = GLib.Net.SingleEndpointChannel (self:GetInnerChannel (), remoteId) 53 | local singleEndpointOrderedChannel = GLib.Net.Layer5.SingleEndpointOrderedChannel (singleEndpointChannel) 54 | self.SingleEndpointChannels [remoteId] = singleEndpointOrderedChannel 55 | singleEndpointOrderedChannel:SetName (self:GetName ()) 56 | singleEndpointOrderedChannel:SetHandler (self:GetHandler ()) 57 | 58 | return self.SingleEndpointChannels [remoteId] 59 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/layer5/orderedchannelstate.lua: -------------------------------------------------------------------------------- 1 | GLib.Net.Layer5.OrderedChannelState = GLib.Enum ( 2 | { 3 | Uninitialized = 1, -- No packets received yet 4 | Initializing = 2, -- Initial 0.5 second buffering 5 | Initialized = 3 -- Normal operation 6 | } 7 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/net.lua: -------------------------------------------------------------------------------- 1 | function GLib.Net.DispatchPacket (destinationId, channelName, packet) 2 | GLib.Error ("GLib.Net.DispatchPacket : Not implemented.") 3 | end 4 | 5 | function GLib.Net.RegisterChannel (channelName, handler) 6 | GLib.Error ("GLib.Net.RegisterChannel : Not implemented.") 7 | end 8 | 9 | function GLib.Net.UnregisterChannel (channelName) 10 | GLib.Error ("GLib.Net.UnregisterChannel : Not implemented.") 11 | end 12 | 13 | function GLib.Net.IsChannelOpen (channelName) 14 | GLib.Error ("GLib.Net.IsChannelOpen : Not implemented.") 15 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/outbuffer.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.OutBuffer = GLib.MakeConstructor (self, GLib.OutBuffer) 3 | 4 | function self:ctor () 5 | self.Data = {} 6 | self.Types = {} 7 | 8 | self.NextDataId = 1 9 | self.Size = 0 10 | end 11 | 12 | for typeName, enumValue in pairs (GLib.Net.DataType) do 13 | self [typeName] = function (self, n) 14 | if n == nil then GLib.Error ("OutBuffer:" .. typeName .. " : Called with nil value") end 15 | 16 | self.Data [self.NextDataId] = n 17 | self.Types [self.NextDataId] = enumValue 18 | self.NextDataId = self.NextDataId + 1 19 | 20 | local typeSize = GLib.Net.DataTypeSizes [typeName] 21 | if type (typeSize) == "number" then 22 | self.Size = self.Size + typeSize 23 | else 24 | self.Size = self.Size + typeSize (n) 25 | end 26 | 27 | return self 28 | end 29 | 30 | self ["Prepend" .. typeName] = function (self, n) 31 | if n == nil then GLib.Error ("OutBuffer:Prepend" .. typeName .. " : Called with nil value") end 32 | 33 | table.insert (self.Data, 1, n) 34 | table.insert (self.Types, 1, enumValue) 35 | self.NextDataId = self.NextDataId + 1 36 | 37 | local typeSize = GLib.Net.DataTypeSizes [typeName] 38 | if type (typeSize) == "number" then 39 | self.Size = self.Size + typeSize 40 | else 41 | self.Size = self.Size + typeSize (n) 42 | end 43 | 44 | return self 45 | end 46 | end 47 | 48 | function self:GetSize () 49 | return self.Size 50 | end 51 | 52 | function self:Bytes (data, length) 53 | length = length or #data 54 | length = math.min (length, #data) 55 | 56 | data = string.sub (data, 1, length) 57 | self.Data [self.NextDataId] = data 58 | self.Types [self.NextDataId] = GLib.Net.DataType.Bytes 59 | self.NextDataId = self.NextDataId + 1 60 | 61 | self.Size = self.Size + length 62 | end 63 | 64 | --[[ 65 | OutBuffer:OutBuffer (OutBuffer outBuffer) 66 | 67 | Appends the contents of outBuffer to this OutBuffer 68 | ]] 69 | function self:OutBuffer (outBuffer) 70 | for i = 1, #outBuffer.Data do 71 | self.Data [self.NextDataId] = outBuffer.Data [i] 72 | self.Types [self.NextDataId] = outBuffer.Types [i] 73 | self.NextDataId = self.NextDataId + 1 74 | end 75 | 76 | self.Size = self.Size + outBuffer:GetSize () 77 | end 78 | 79 | function self:GetString () 80 | local outBuffer = GLib.StringOutBuffer () 81 | for i = 1, #self.Data do 82 | outBuffer [GLib.Net.DataType [self.Types [i]]] (outBuffer, self.Data [i]) 83 | end 84 | return outBuffer:GetString () 85 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/singleendpointchannel.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.SingleEndpointChannel = GLib.MakeConstructor (self, GLib.Net.ISingleEndpointChannel) 3 | 4 | function self:ctor (channel, remoteId, handler) 5 | -- Identity 6 | self.Channel = channel 7 | self.Name = nil 8 | self.RemoteId = remoteId 9 | 10 | -- State 11 | self.Open = nil 12 | 13 | -- Handlers 14 | self:SetHandler (handler or GLib.NullCallback) 15 | end 16 | 17 | -- Identity 18 | function self:GetName () 19 | return self.Channel:GetName () 20 | end 21 | 22 | function self:SetName (name) 23 | return self 24 | end 25 | 26 | -- State 27 | function self:IsOpen () 28 | return self.Channel:IsOpen (self:GetRemoteId ()) 29 | end 30 | 31 | function self:SetOpen () 32 | return self 33 | end 34 | 35 | -- Packets 36 | function self:DispatchPacket (packet) 37 | return self.Channel:DispatchPacket (self:GetRemoteId (), packet) 38 | end 39 | 40 | function self:GetMTU () 41 | return self.Channel:GetMTU () 42 | end 43 | 44 | function self:HandlePacket (inBuffer) 45 | self:GetHandler () (self:GetRemoteId (), inBuffer) 46 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/singleendpointchanneltochanneladapter.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.SingleEndpointChannelToChannelAdapter = GLib.MakeConstructor (self, GLib.Net.IChannel) 3 | 4 | function self:ctor (singleEndpointChannel) 5 | self.Channel = singleEndpointChannel 6 | 7 | self.Channel:SetHandler ( 8 | function (sourceId, inBuffer) 9 | self:GetHandler () (sourceId, inBuffer) 10 | end 11 | ) 12 | end 13 | 14 | -- Packets 15 | function self:DispatchPacket (destinationId, packet) 16 | if destinationId == GLib.GetEveryoneId () then destinationId = self.Channel:GetRemoteId () end 17 | if destinationId ~= self.Channel:GetRemoteId () then return end 18 | return self.Channel:DispatchPacket (packet) 19 | end 20 | 21 | function self:GetMTU () 22 | return self.Channel:GetMTU () 23 | end 24 | 25 | function self:HandlePacket (sourceId, inBuffer) 26 | return self.Channel:HandlePacket (inBuffer) 27 | end 28 | 29 | function self:IsDestinationRoutable (destinationId) 30 | return self.Channel:IsDestinationRoutable (destinationId) 31 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/virtualchannel.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.VirtualChannel = GLib.MakeConstructor (self, GLib.Net.ISingleEndpointChannel) 3 | 4 | --[[ 5 | Events: 6 | DispatchPacket (destinationId, OutBuffer packet) 7 | Fired when a packet needs to be dispatched. 8 | ]] 9 | 10 | function self:ctor () 11 | self.MTU = math.huge 12 | end 13 | 14 | -- Packets 15 | function self:DispatchPacket (destinationId, packet) 16 | self:DispatchEvent ("DispatchPacket", destinationId, packet) 17 | end 18 | 19 | function self:GetMTU () 20 | return self.MTU 21 | end 22 | 23 | function self:SetMTU (mtu) 24 | self.MTU = mtu 25 | return self 26 | end 27 | 28 | -- Handlers 29 | function self:HandlePacket (sourceId, inBuffer) 30 | return self:GetHandler () (sourceId, inBuffer) 31 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/net/virtualsingleendpointchannel.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Net.VirtualSingleEndpointChannel = GLib.MakeConstructor (self, GLib.Net.ISingleEndpointChannel) 3 | 4 | --[[ 5 | Events: 6 | DispatchPacket (OutBuffer packet) 7 | Fired when a packet needs to be dispatched. 8 | ]] 9 | 10 | function self:ctor () 11 | self.MTU = math.huge 12 | end 13 | 14 | -- Packets 15 | function self:DispatchPacket (packet) 16 | self:DispatchEvent ("DispatchPacket", packet) 17 | end 18 | 19 | function self:GetMTU () 20 | return self.MTU 21 | end 22 | 23 | function self:SetMTU (mtu) 24 | self.MTU = mtu 25 | return self 26 | end 27 | 28 | -- Handlers 29 | function self:HandlePacket (inBuffer) 30 | return self:GetHandler () (self:GetRemoteId (), inBuffer) 31 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/networking/networkable.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Networking.Networkable = GLib.MakeConstructor (self, GLib.IDisposable) 3 | 4 | --[[ 5 | Events: 6 | DispatchPacket (destinationId, OutBuffer packet) 7 | Fired when a packet needs to be dispatched. 8 | ]] 9 | 10 | function self:ctor () 11 | -- NetworkableHost 12 | self.NetworkableHost = nil 13 | 14 | -- Subscribers 15 | self.SubscriberSet = nil 16 | 17 | GLib.EventProvider (self) 18 | end 19 | 20 | function self:dtor () 21 | self:SetNetworkableHost (nil) 22 | end 23 | 24 | function self:IsHosting () 25 | return nil 26 | end 27 | 28 | -- NetworkableHost 29 | function self:GetNetworkableHost () 30 | return self.NetworkableHost 31 | end 32 | 33 | function self:SetNetworkableHost (networkableHost) 34 | if self.NetworkableHost == networkableHost then return self end 35 | 36 | if self.NetworkableHost then 37 | self.NetworkableHost:UnregisterNetworkable (self) 38 | end 39 | 40 | self.NetworkableHost = networkableHost 41 | 42 | if self.NetworkableHost and 43 | not self.NetworkableHost:IsNetworkableRegistered (self) then 44 | self.NetworkableHost:RegisterNetworkable (self) 45 | end 46 | 47 | return self 48 | end 49 | 50 | -- Subscribers 51 | function self:GetSubscriberSet () 52 | return self.SubscriberSet 53 | end 54 | 55 | function self:SetSubscriberSet (subscriberSet) 56 | if self.SubscriberSet == subscriberSet then return self end 57 | 58 | self.SubscriberSet = subscriberSet 59 | 60 | return self 61 | end 62 | 63 | -- Packets 64 | function self:DispatchPacket (destinationId, packet) 65 | destinationId = destinationId or self.SubscriberSet 66 | 67 | self:DispatchEvent ("DispatchPacket", destinationId, packet) 68 | end 69 | 70 | function self:HandlePacket (sourceId, inBuffer) 71 | end 72 | 73 | function self:HandleRemoteDestruction () 74 | self:dtor () 75 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/networking/networkablehostmessagetype.lua: -------------------------------------------------------------------------------- 1 | GLib.Networking.NetworkableHostMessageType = GLib.Enum ( 2 | { 3 | NetworkableDestroyed = 0x01, 4 | Custom = 0xFF 5 | } 6 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/networking/networkablestate.lua: -------------------------------------------------------------------------------- 1 | GLib.Networking.NetworkableState = GLib.Enum ( 2 | { 3 | Unsynchronized = 0, 4 | Synchronizing = 1, 5 | Synchronized = 2 6 | } 7 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/networking/singleendpointnetworkable.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Networking.SingleEndpointNetworkable = GLib.MakeConstructor (self, GLib.Networking.Networkable) 3 | 4 | function self:ctor () 5 | -- Remote endpoint 6 | self.RemoteId = nil 7 | end 8 | 9 | -- Remote endpoint 10 | function self:GetRemoteId () 11 | return self.RemoteId 12 | end 13 | 14 | function self:SetRemoteId (remoteId) 15 | if self.RemoteId == remoteId then return self end 16 | 17 | self.RemoteId = remoteId 18 | 19 | return self 20 | end 21 | 22 | -- Packets 23 | function self:DispatchPacket (destinationIdOrPacket, packet) 24 | local destinationId = destinationIdOrPacket 25 | 26 | if istable (destinationId) then 27 | destinationId = self:GetRemoteId () or self.SubscriberSet 28 | packet = destinationIdOrPacket 29 | end 30 | 31 | self:DispatchEvent ("DispatchPacket", destinationId, packet) 32 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/networking/subscriberset.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Networking.SubscriberSet = GLib.MakeConstructor (self) 3 | 4 | --[[ 5 | Cleared () 6 | Fired when this SubscriberSet has been cleared. 7 | PlayerAdded (Player ply) 8 | Fired when a player has been added to this SubscriberSet. 9 | PlayerRemoved (Player ply) 10 | Fired when a player has been removed from this SubscriberSet. 11 | ]] 12 | 13 | function self:ctor (userId) 14 | self.PlayerSet = {} 15 | self.Players = {} 16 | 17 | GLib.EventProvider (self) 18 | 19 | if userId then 20 | self:AddUser (userId) 21 | end 22 | end 23 | 24 | function self:AddPlayer (ply) 25 | if self.PlayerSet [ply] then 26 | self.PlayerSet [ply] = self.PlayerSet [ply] + 1 27 | else 28 | self.Players [#self.Players + 1] = ply 29 | self.PlayerSet [ply] = 1 30 | 31 | self:DispatchEvent ("PlayerAdded", ply) 32 | end 33 | end 34 | 35 | function self:AddUser (userId) 36 | self:AddPlayer (GLib.PlayerMonitor:GetUserEntity (userId)) 37 | end 38 | 39 | function self:Clear () 40 | self.PlayerSet = {} 41 | self.Players = {} 42 | 43 | self:DispatchEvent ("Cleared") 44 | end 45 | 46 | function self:ContainsPlayer (ply) 47 | return self.PlayerSet [ply] and true or false 48 | end 49 | 50 | function self:ContainsUser (userId) 51 | return self:ContainsPlayer (GLib.PlayerMonitor:GetUserEntity (userId)) 52 | end 53 | 54 | function self:GetPlayerEnumerator () 55 | self:CleanUp () 56 | 57 | return GLib.ArrayEnumerator (self.Players) 58 | end 59 | 60 | function self:GetRecipientFilter () 61 | self:CleanUp () 62 | return self.Players 63 | end 64 | 65 | function self:IsEmpty () 66 | self:CleanUp () 67 | return #self.Players == 0 68 | end 69 | 70 | function self:RemovePlayer (ply) 71 | if not self.PlayerSet [ply] then return end 72 | 73 | self.PlayerSet [ply] = self.PlayerSet [ply] - 1 74 | if self.PlayerSet [ply] > 0 then return end 75 | 76 | self.PlayerSet [ply] = nil 77 | for i = 1, #self.Players do 78 | if self.Players [i] == ply then 79 | table.remove (self.Players, i) 80 | break 81 | end 82 | end 83 | 84 | self:DispatchEvent ("PlayerRemoved", ply) 85 | end 86 | 87 | function self:RemoveUser (userId) 88 | self:RemovePlayer (GLib.PlayerMonitor:GetUserEntity (userId)) 89 | end 90 | 91 | function self:ToString () 92 | local subscriberSet = "" 93 | 94 | for ply in self:GetPlayerEnumerator () do 95 | if subscriberSet ~= "" then 96 | subscriberSet = subscriberSet .. ", " 97 | end 98 | subscriberSet = subscriberSet .. GLib.GetPlayerId (ply) .. " (" .. ply:Name () .. ")" 99 | end 100 | 101 | subscriberSet = "{" .. subscriberSet .. "}" 102 | return subscriberSet 103 | end 104 | 105 | self.__tostring = self.ToString 106 | 107 | -- Internal, do not call 108 | function self:CleanUp () 109 | for i = #self.Players, 1, -1 do 110 | if not self.Players [i]:IsValid () then 111 | self:DispatchEvent ("PlayerRemoved", self.Players [i]) 112 | self.PlayerSet [self.Players [i]] = nil 113 | table.remove (self.Players, i) 114 | end 115 | end 116 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/oop/enum.lua: -------------------------------------------------------------------------------- 1 | function GLib.Enum (enum) 2 | if not next (enum) then 3 | GLib.Error ("GLib.Enum : This enum appears to be empty!") 4 | end 5 | 6 | GLib.InvertTable (enum, enum) 7 | return enum 8 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/oop/idisposable.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.IDisposable = GLib.MakeConstructor (self) 3 | 4 | --[[ 5 | Events: 6 | Disposed () 7 | Fired when this object has been disposed. 8 | ]] 9 | 10 | function self:ctor () 11 | self.Disposed = false 12 | end 13 | 14 | function self:dtor () 15 | self:Dispose () 16 | end 17 | 18 | function self:Dispose () 19 | if self:IsDisposed () then return end 20 | 21 | self.Disposed = true 22 | 23 | if self.DispatchEvent then 24 | self:DispatchEvent ("Disposed") 25 | end 26 | 27 | self:dtor () 28 | end 29 | 30 | function self:IsDisposed () 31 | return self.Disposed 32 | end 33 | 34 | function self:IsValid () 35 | return not self.Disposed 36 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/properties/propertyserializable.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.PropertySerializable = GLib.MakeConstructor (self, GLib.Serialization.ISerializable) 3 | 4 | function self:ctor () 5 | end 6 | 7 | -- ISerializable 8 | function self:Serialize (outBuffer) 9 | self:SerializeProperties (outBuffer) 10 | 11 | return outBuffer 12 | end 13 | 14 | function self:Deserialize (inBuffer) 15 | self:DeserializeProperties (inBuffer) 16 | 17 | return self 18 | end 19 | 20 | -- PropertySerializable 21 | function self:SerializeProperties (outBuffer) 22 | for i = 1, #self._Properties do 23 | local property = self._Properties [i] 24 | outBuffer [property.Type] (outBuffer, self [property.GetterName] (self)) 25 | end 26 | 27 | return outBuffer 28 | end 29 | 30 | function self:DeserializeProperties (inBuffer) 31 | for i = 1, #self._Properties do 32 | local property = self._Properties [i] 33 | self [property.SetterName] (self, inBuffer [property.Type] (inBuffer)) 34 | end 35 | 36 | return self 37 | end 38 | 39 | function self:Clone (clone) 40 | clone = clone or self.__ictor () 41 | 42 | clone:Copy (self) 43 | 44 | return clone 45 | end 46 | 47 | function self:Copy (source) 48 | for i = 1, #self._Properties do 49 | local property = self._Properties [i] 50 | self [property.SetterName] (self, source [property.GetterName] (source)) 51 | end 52 | 53 | return source 54 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/protocol/channel.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Protocol.Channel = GLib.MakeConstructor (self) 3 | 4 | function self:ctor (channelName, handlerFunction) 5 | self.ChannelName = channelName 6 | self.StringTable = GLib.StringTable () 7 | self.PacketHandlers = {} 8 | self.HandlerFunction = handlerFunction or self.DefaultHandlerFunction 9 | GLib.EventProvider (self) 10 | 11 | GLib.Net.RegisterChannel (self.ChannelName, 12 | function (senderId, inBuffer) 13 | self:HandlerFunction (senderId, inBuffer) 14 | end 15 | ) 16 | end 17 | 18 | function self:CreatePacketHandler (packetTypeOrTypeId) 19 | if type (packetTypeOrTypeId) == "number" then 20 | packetTypeOrTypeId = self.StringTable:StringFromHash (packetTypeOrTypeId) 21 | end 22 | 23 | local ctor = self.PacketHandlers [packetType] 24 | end 25 | 26 | function self:DefaultHandlerFunction (senderId, inBuffer) 27 | end 28 | 29 | function self:GetChannelName () 30 | return self.ChannelName 31 | end 32 | 33 | function self:GetStringTable () 34 | return self.StringTable 35 | end 36 | 37 | function self:Register (packetType, class) 38 | self.StringTable:Add (packetType) 39 | class.Type = packetType 40 | class.TypeId = self.StringTable:HashFromString (packetType) 41 | end 42 | 43 | function self:RegisterResponse (packetType, ctor) 44 | self.StringTable:Add (packetType) 45 | self.PacketHandlers [packetType] = ctor 46 | local class = GLib.GetMetaTable (ctor) 47 | class.Type = packetType 48 | class.TypeId = self.StringTable:HashFromString (packetType) 49 | end 50 | 51 | GLib.Net.RegisterChannel ("glib_new_request", 52 | function (senderId, inBuffer) 53 | local client = GLib.NetServer:GetEndPoint (senderId) 54 | local requestId = inBuffer:UInt32 () 55 | local typeId = inBuffer:UInt32 () 56 | local packetType = GLib.Protocol.StringTable:StringFromHash (typeId) 57 | 58 | local ctor = GLib.Protocol.ResponseTable [packetType] 59 | if not ctor then 60 | ErrorNoHalt ("glib_new_request : No handler for " .. tostring (packetType) .. " is registered!") 61 | return 62 | end 63 | local response = ctor () 64 | response:SetRemoteEndPoint (client) 65 | response:SetId (requestId) 66 | client:HandleIncomingSession (response, inBuffer) 67 | end 68 | ) 69 | 70 | GLib.Net.RegisterChannel ("glib_request_data", 71 | function (senderId, inBuffer) 72 | local client = GLib.NetServer:GetEndPoint (senderId) 73 | end 74 | ) 75 | 76 | GLib.Net.RegisterChannel ("glib_response_data", 77 | function (senderId, inBuffer) 78 | local client = GLib.EndPointManager:GetEndPoint (senderId) 79 | client:HandleIncomingPacket (inBuffer:UInt32 (), inBuffer) 80 | end 81 | ) 82 | 83 | GLib.Net.RegisterChannel ("glib_notification", 84 | function (senderId, inBuffer) 85 | local client = GLib.EndPointManager:GetEndPoint (senderId) 86 | end 87 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/protocol/endpointmanager.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Protocol.EndPointManager = GLib.MakeConstructor (self) 3 | 4 | function self:ctor (systemName, endPointConstructor) 5 | self.SystemName = systemName 6 | self.EndPointConstructor = endPointConstructor or GLib.Protocol.EndPoint 7 | self.EndPoints = {} 8 | end 9 | 10 | function self:AddEndPoint (remoteId) 11 | if not self.EndPoints [remoteId] then 12 | self.EndPoints [remoteId] = self:CreateEndPoint (remoteId) 13 | end 14 | return self.EndPoints [remoteId] 15 | end 16 | 17 | --[[ 18 | EndPointManager:CreateEndPoint (remoteId) 19 | Returns: EndPoint endPointForRemoteId 20 | ]] 21 | function self:CreateEndPoint (remoteId) 22 | return self:GetEndPointConstructor () (remoteId, self:GetSystemName ()) 23 | end 24 | 25 | function self:GetEndPoint (remoteId) 26 | if not self.EndPoints [remoteId] then 27 | self.EndPoints [remoteId] = self:CreateEndPoint (remoteId) 28 | end 29 | return self.EndPoints [remoteId] 30 | end 31 | 32 | function self:GetEndPointEnumerator () 33 | return GLib.KeyValueEnumerator (self.EndPoints) 34 | end 35 | 36 | function self:GetEndPointConstructor () 37 | return self.EndPointConstructor 38 | end 39 | 40 | function self:GetSystemName () 41 | return self.SystemName 42 | end 43 | 44 | function self:RemoveEndPoint (endPointOrRemoteId) 45 | local endPoint = endPointOrRemoteId 46 | if type (endPointOrRemoteId) == "string" then 47 | endPoint = self.EndPoints [endPointOrRemoteId] 48 | end 49 | if not endPoint then return end 50 | endPoint:dtor () 51 | self.EndPoints [endPoint:GetRemoteId ()] = nil 52 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/protocol/protocol.lua: -------------------------------------------------------------------------------- 1 | GLib.Protocol = {} -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/protocol/session.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Protocol.Session = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.Id = 0 6 | 7 | self.RemoteEndPoint = nil 8 | 9 | self.PacketQueue = {} 10 | self.LastActivityTime = SysTime () 11 | 12 | self.Closing = false 13 | 14 | GLib.EventProvider (self) 15 | end 16 | 17 | function self:Close () 18 | if self.Closing then return end 19 | self.Closing = true 20 | end 21 | 22 | function self:CreatePacket () 23 | local outBuffer = GLib.Net.OutBuffer () 24 | outBuffer:UInt32 (self:GetId ()) 25 | 26 | return outBuffer 27 | end 28 | 29 | function self:DequeuePacket () 30 | local outBuffer = self.PacketQueue [1] 31 | table.remove (self.PacketQueue, 1) 32 | if outBuffer then 33 | self:ResetTimeout () 34 | end 35 | return outBuffer 36 | end 37 | 38 | function self:GetId () 39 | return self.Id 40 | end 41 | 42 | function self:GetRemoteEndPoint () 43 | return self.RemoteEndPoint 44 | end 45 | 46 | function self:GetType () 47 | return self.Type 48 | end 49 | 50 | --[[ 51 | Session:GetTypeId () 52 | Returns: Int32 typeId 53 | ]] 54 | function self:GetTypeId () 55 | return self.TypeId 56 | end 57 | 58 | -- overrideable 59 | function self:HandleInitialPacket (inBuffer) 60 | end 61 | 62 | -- overrideable 63 | function self:HandlePacket (inBuffer) 64 | end 65 | 66 | -- overrideable 67 | function self:HandleTimeOut () 68 | end 69 | 70 | function self:HasQueuedPackets () 71 | return #self.PacketQueue > 0 72 | end 73 | 74 | function self:HasTimedOut () 75 | return SysTime () - self.LastActivityTime > 120 76 | end 77 | 78 | function self:IsClosing () 79 | return self.Closing 80 | end 81 | 82 | function self:QueuePacket (outBuffer) 83 | self.PacketQueue [#self.PacketQueue + 1] = outBuffer 84 | self:ResetTimeout () 85 | end 86 | 87 | function self:ResetTimeout () 88 | self.LastActivityTime = SysTime () 89 | end 90 | 91 | function self:SetId (id) 92 | self.Id = id 93 | end 94 | 95 | function self:SetRemoteEndPoint (remoteEndPoint) 96 | self.RemoteEndPoint = remoteEndPoint 97 | end 98 | 99 | -- overrideable 100 | function self:Tick () 101 | end 102 | 103 | function self:ToString () 104 | return self:GetType () .. ":" .. self:GetId () 105 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/buffers/bufferelement.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.Buffers.BufferElement = GLib.MakeConstructor (self) 3 | 4 | function self:ctor (semantic, type) 5 | self.Semantic = nil 6 | self.Type = nil 7 | 8 | if semantic then 9 | self:SetSemantic (semantic) 10 | end 11 | if type then 12 | self:SetType (type) 13 | end 14 | end 15 | 16 | function self:GetSemantic () 17 | return self.Semantic 18 | end 19 | 20 | function self:SetSemantic (semantic) 21 | if self.Semantic == semantic then return self end 22 | 23 | self.Semantic = semantic 24 | self.Type = GLib.Rendering.Buffers.BufferElementTypes:GetType (self.Semantic) 25 | 26 | return self 27 | end 28 | 29 | function self:GetSize () 30 | return GLib.Rendering.Buffers.BufferElementTypes:GetTypeSize (self.Type) 31 | end 32 | 33 | function self:GetType () 34 | return self.Type 35 | end 36 | 37 | function self:SetType (type) 38 | if self.Type == type then return self end 39 | 40 | self.Type = type 41 | 42 | return self 43 | end 44 | 45 | GLib.Rendering.Buffers.BufferElement.Position2f = GLib.Rendering.Buffers.BufferElement (GLib.Rendering.Buffers.BufferElementSemantic.Position, GLib.Rendering.Buffers.BufferElementType.Float2); 46 | GLib.Rendering.Buffers.BufferElement.Position3f = GLib.Rendering.Buffers.BufferElement (GLib.Rendering.Buffers.BufferElementSemantic.Position, GLib.Rendering.Buffers.BufferElementType.Float3); 47 | GLib.Rendering.Buffers.BufferElement.Position4f = GLib.Rendering.Buffers.BufferElement (GLib.Rendering.Buffers.BufferElementSemantic.Position, GLib.Rendering.Buffers.BufferElementType.Float4); 48 | GLib.Rendering.Buffers.BufferElement.Color3b = GLib.Rendering.Buffers.BufferElement (GLib.Rendering.Buffers.BufferElementSemantic.Color, GLib.Rendering.Buffers.BufferElementType.UInt83); 49 | GLib.Rendering.Buffers.BufferElement.Color4b = GLib.Rendering.Buffers.BufferElement (GLib.Rendering.Buffers.BufferElementSemantic.Color, GLib.Rendering.Buffers.BufferElementType.UInt84); 50 | GLib.Rendering.Buffers.BufferElement.Color4f = GLib.Rendering.Buffers.BufferElement (GLib.Rendering.Buffers.BufferElementSemantic.Color, GLib.Rendering.Buffers.BufferElementType.Float4); 51 | GLib.Rendering.Buffers.BufferElement.TextureCoordinates2f = GLib.Rendering.Buffers.BufferElement (GLib.Rendering.Buffers.BufferElementSemantic.TextureCoordinates, GLib.Rendering.Buffers.BufferElementType.Float2); -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/buffers/bufferelementsemantic.lua: -------------------------------------------------------------------------------- 1 | GLib.Rendering.Buffers.BufferElementSemantic = GLib.Enum ( 2 | { 3 | None = 0, 4 | 5 | Binormal = 1, 6 | BlendIndices = 2, 7 | BlendWeight = 3, 8 | Color = 4, 9 | Normal = 5, 10 | Position = 6, 11 | PositionTransformed = 7, 12 | PointSize = 8, 13 | Tangent = 9, 14 | TextureCoordinates = 10, 15 | 16 | -- Output-specific 17 | Fog = 11, 18 | TessellationFactor = 12, 19 | Face = 13, 20 | ScreenPosition = 14 21 | } 22 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/buffers/bufferelementtype.lua: -------------------------------------------------------------------------------- 1 | GLib.Rendering.Buffers.BufferElementType = GLib.Enum ( 2 | { 3 | UInt8 = 0, 4 | UInt82 = 1, 5 | UInt83 = 2, 6 | UInt84 = 3, 7 | UInt16 = 4, 8 | UInt32 = 5, 9 | Float = 6, 10 | Float2 = 7, 11 | Float3 = 8, 12 | Float4 = 9, 13 | Float16 = 10 14 | } 15 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/buffers/bufferflags.lua: -------------------------------------------------------------------------------- 1 | GLib.Rendering.Buffers.BufferFlags = GLib.Enum ( 2 | { 3 | None = 0, 4 | Dynamic = 1 5 | } 6 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/buffers/bufferlayout.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.Buffers.BufferLayout = GLib.MakeConstructor (self) 3 | 4 | function self:ctor (...) 5 | self.Locked = false 6 | 7 | self.SemanticCounts = {} 8 | self.Elements = GLib.Containers.List () 9 | self.ElementIndices = {} 10 | 11 | self.SizeValid = false 12 | self.Size = nil 13 | 14 | self:AddRange ({...}) 15 | end 16 | 17 | function self:GetEnumerator () 18 | return self.Elements:GetEnumerator () 19 | end 20 | 21 | function self:Add (bufferElement) 22 | if self.Locked then 23 | GLib.Error ("BufferLayout:Add : This BufferLayout is locked!") 24 | end 25 | 26 | if type (bufferElement) == "number" then 27 | bufferElement = GLib.Rendering.Buffers.BufferElement (bufferElement) 28 | end 29 | 30 | if not self.SemanticCounts [bufferElement:GetSemantic ()] then 31 | self.SemanticCounts [bufferElement:GetSemantic ()] = 0 32 | end 33 | 34 | self.Elements:Add (bufferElement) 35 | self.ElementIndices [#self.ElementIndices + 1] = self.SemanticCounts [bufferElement:GetSemantic ()] 36 | self.SemanticCounts [bufferElement:GetSemantic ()] = self.SemanticCounts [bufferElement:GetSemantic ()] + 1 37 | 38 | self:InvalidateComputedSize () 39 | end 40 | 41 | function self:AddRange (bufferElements) 42 | for _, bufferElement in ipairs (bufferElements) do 43 | self:Add (bufferElement) 44 | end 45 | end 46 | 47 | function self:GetCount () 48 | return self.Elements.Count 49 | end 50 | 51 | function self:Lock () 52 | self.Locked = true 53 | end 54 | 55 | function self:GetElement (index) 56 | return self.Elements:Get (index) 57 | end 58 | 59 | function self:GetElementSemanticIndex (index) 60 | return self.ElementIndices [index] 61 | end 62 | 63 | function self:GetSize () 64 | if not self.SizeValid then 65 | local size = 0 66 | 67 | for bufferElement in self:GetEnumerator () do 68 | size = size + bufferElement:GetSize () 69 | end 70 | 71 | self.Size = size 72 | self.SizeValid = true 73 | end 74 | 75 | return self.Size 76 | end 77 | 78 | function self:InvalidateComputedSize () 79 | self.SizeValid = false 80 | end 81 | 82 | GLib.Rendering.Buffers.BufferLayout.PositionVertex = GLib.Rendering.Buffers.BufferLayout (GLib.Rendering.Buffers.BufferElement.Position4f) 83 | GLib.Rendering.Buffers.BufferLayout.TexturedVertex = GLib.Rendering.Buffers.BufferLayout (GLib.Rendering.Buffers.BufferElement.Position4f, GLib.Rendering.Buffers.BufferElement.TextureCoordinates2f) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/buffers/igraphicsbuffer.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.Buffers.IGraphicsBuffer = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.GraphicsDevice = nil 6 | self.Handle = nil 7 | 8 | self.Flags = GLib.Rendering.Buffers.BufferFlags.None 9 | 10 | self.Size = 0 11 | self.ElementCount = 0 12 | self.ElementSize = 0 13 | end 14 | 15 | function self:dtor () 16 | end 17 | 18 | function self:GetGraphicsDevice () 19 | return self.GraphicsDevice 20 | end 21 | 22 | function self:GetHandle () 23 | return self.Handle 24 | end 25 | 26 | function self:Destroy () 27 | self:dtor () 28 | end 29 | 30 | function self:GetFlags () 31 | return self.Flags 32 | end 33 | 34 | function self:GetSize () 35 | return self.Size 36 | end 37 | 38 | function self:GetElementCount () 39 | return self.ElementCount 40 | end 41 | 42 | function self:GetElementSize () 43 | return self.ElementSize 44 | end 45 | 46 | function self:Flush () 47 | GLib.Error ("IGraphicsBuffer:Flush : Not implemented.") 48 | end 49 | 50 | function self:SetElements (startElement, elementCount, elements) 51 | GLib.Error ("IGraphicsBuffer:SetElements : Not implemented.") 52 | end 53 | -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/buffers/iindexbuffer.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.Buffers.IIndexBuffer = GLib.MakeConstructor (self, GLib.Rendering.Buffers.IGraphicsBuffer) 3 | 4 | function self:ctor () 5 | self.IndexType = GLib.Rendering.Buffers.BufferElementType.UInt16 6 | end 7 | 8 | function self:GetIndexType () 9 | return self.IndexType 10 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/buffers/ivertexbuffer.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.Buffers.IVertexBuffer = GLib.MakeConstructor (self, GLib.Rendering.Buffers.IGraphicsBuffer) 3 | 4 | function self:ctor () 5 | self.VertexLayout = nil 6 | end 7 | 8 | function self:GetVertexLayout () 9 | return self.VertexLayout 10 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/ibaserendercontext2d.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.IBaseRenderContext2d = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.GraphicsDevice = nil 6 | self.GraphicsView = nil 7 | self.RenderContext = nil 8 | 9 | self.FillColor = GLib.Colors.White 10 | self.LineColor = GLib.Colors.Red 11 | 12 | self.Texture = nil 13 | end 14 | 15 | function self:GetGraphicsDevice () 16 | return self.GraphicsDevice 17 | end 18 | 19 | function self:GetGraphicsView () 20 | return self.GraphicsView 21 | end 22 | 23 | function self:GetRenderContext () 24 | return self.RenderContext 25 | end 26 | function self:GetFillColor () 27 | return self.FillColor 28 | end 29 | 30 | function self:GetLineColor () 31 | return self.LineColor 32 | end 33 | 34 | function self:SetFillColor (fillColor) 35 | if self.FillColor == fillColor then return self end 36 | 37 | self.FillColor = fillColor 38 | return self 39 | end 40 | 41 | function self:SetLineColor (lineColor) 42 | if self.LineColor == lineColor then return self end 43 | 44 | self.LineColor = lineColor 45 | return self 46 | end 47 | 48 | function self:GetTexture () 49 | return self.Texture 50 | end 51 | 52 | function self:SetTexture (texture) 53 | if self.Texture == texture then return self end 54 | 55 | self.Texture = texture 56 | return self 57 | end 58 | 59 | function self:DrawLine (start, end_) 60 | GLib.Error ("IBaseRenderContext2d:DrawLine : Not implemented.") 61 | end 62 | 63 | function self:DrawRectangle (position, size) 64 | GLib.Error ("IBaseRenderContext2d:DrawRectangle : Not implemented.") 65 | end 66 | 67 | function self:FillRectangle (position, size) 68 | GLib.Error ("IBaseRenderContext2d:FillRectangle : Not implemented.") 69 | end 70 | 71 | function self:DrawTexturedRectangle (position, size, uv0, uv1) 72 | GLib.Error ("IBaseRenderContext2d:DrawTexturedRectangle : Not implemented.") 73 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/igraphicsdevice.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.IGraphicsDevice = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.DefaultTextRenderer = nil 6 | end 7 | 8 | function self:dtor () 9 | end 10 | 11 | function self:Destroy () 12 | self:dtor () 13 | end 14 | 15 | function self:GetDefaultTextRenderer () 16 | return self.DefaultTextRenderer 17 | end 18 | 19 | function self:CreateView (windowHandle) 20 | GLib.Error ("IGraphicsDevice:CreateView : Not implemented.") 21 | end 22 | 23 | function self:CreateTextRenderer () 24 | GLib.Error ("IGraphicsDevice:CreateTextRenderer : Not implemented.") 25 | end 26 | 27 | -- Textures 28 | function self:CreateTexture (size, mipMapCount, pixelFormat) 29 | GLib.Error ("IGraphicsDevice:CreateTexture : Not implemented.") 30 | end 31 | 32 | -- Buffers 33 | function self:CreateVertexBuffer (elementCount, vertexLayout, bufferFlags) 34 | GLib.Error ("IGraphicsDevice:CreateVertexBuffer : Not implemented.") 35 | end 36 | 37 | function self:CreateIndexBuffer (elementCount, indexType, bufferFlags) 38 | GLib.Error ("IGraphicsDevice:CreateIndexBuffer : Not implemented.") 39 | end 40 | 41 | -- Meshes 42 | function self:CreateMesh (vertexLayout, vertexCount, indexCount, meshFlags) 43 | GLib.Error ("IGraphicsDevice:CreateMesh : Not implemented.") 44 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/igraphicsview.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.IGraphicsView = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.GraphicsDevice = nil 6 | self.WindowHandle = nil 7 | end 8 | 9 | function self:dtor () 10 | end 11 | 12 | function self:Destroy () 13 | self:dtor () 14 | end 15 | 16 | function self:GetGraphicsDevice () 17 | return self.GraphicsDevice 18 | end 19 | 20 | function self:GetWindowHandle () 21 | return self.WindowHandle 22 | end 23 | 24 | function self:Begin () 25 | GLib.Error ("IGraphicsView:Begin : Not implemented.") 26 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/irendercontext.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.IRenderContext = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.GraphicsDevice = nil 6 | self.GraphicsView = nil 7 | 8 | self.RenderContext2d = nil 9 | self.RenderContext3d = nil 10 | end 11 | 12 | function self:GetGraphicsDevice () 13 | return self.GraphicsDevice 14 | end 15 | 16 | function self:GetGraphicsView () 17 | return self.GraphicsView 18 | end 19 | 20 | function self:GetRenderContext2d () 21 | return self.RenderContext2d 22 | end 23 | 24 | function self:GetRenderContext3d () 25 | return self.RenderContext3d 26 | end 27 | 28 | function self:End () 29 | GLib.Error ("IRenderContext:End : Not implemented.") 30 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/irendercontext2d.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.IRenderContext2d = GLib.MakeConstructor (self, GLib.Rendering.IBaseRenderContext2d) 3 | 4 | function self:ctor () 5 | self.AntiAliasing = false 6 | 7 | self.Font = nil 8 | self.TextColor = GLib.Colors.Black 9 | end 10 | 11 | function self:GetAntiAliasing () 12 | return self.AntiAliasing 13 | end 14 | 15 | function self:SetAntiAliasing (antiAliasing) 16 | if self.AntiAliasing == antiAliasing then return self end 17 | 18 | self.AntiAliasing = antiAliasing 19 | return self 20 | end 21 | 22 | function self:GetFont () 23 | return self.Font 24 | end 25 | 26 | function self:GetTextColor () 27 | return self.TextColor 28 | end 29 | 30 | function self:SetFont (font) 31 | if self.Font == font then return self end 32 | 33 | self.Font = font 34 | return self 35 | end 36 | 37 | function self:SetTextColor (textColor) 38 | if self.TextColor == textColor then return self end 39 | 40 | self.TextColor = textColor 41 | return self 42 | end 43 | 44 | function self:DrawText (text, position, horizontalAlignment, verticalAlignment) 45 | GLib.Error ("IRenderContext2d:DrawText : Not implemented.") 46 | end 47 | 48 | function self:DrawText2 (text, position, size, horizontalAlignment, verticalAlignment) 49 | GLib.Error ("IRenderContext2d:DrawText2 : Not implemented.") 50 | end 51 | 52 | function self:GetTextSize (text) 53 | GLib.Error ("IRenderContext2d:GetTextSize : Not implemented.") 54 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/irendercontext2d2.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.IRenderContext2d2 = GLib.MakeConstructor (self, GLib.Rendering.IRenderContext2d) 3 | 4 | function self:ctor () 5 | self.AntiAliasingStack = GLib.Containers.Stack () 6 | end 7 | 8 | function self:PushAntiAliasing (antiAliasing) 9 | self.AntiAliasingStack:Push (self:GetAntiAliasing ()) 10 | self:SetAntiAliasing (antiAliasing) 11 | end 12 | 13 | function self:PopAntiAliasing () 14 | self:SetAntiAliasing (self.AntiAliasingStack:Pop ()) 15 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/matrices/imatrixstack.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.Matrices.IMatrixStack = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.RevisionId = 0 6 | 7 | self.Top = nil 8 | end 9 | 10 | function self:GetRevisionId () 11 | return self.RevisionId 12 | end 13 | 14 | function self:GetTop () 15 | GLib.Error ("IMatrixStack:GetTop : Not implemented.") 16 | 17 | return self.Top 18 | end 19 | 20 | function self:SetTop (matrix) 21 | GLib.Error ("IMatrixStack:SetTop : Not implemented.") 22 | 23 | self.Top = matrix 24 | end 25 | 26 | function self:Get () 27 | GLib.Error ("IMatrixStack:Get : Not implemented.") 28 | 29 | return self.Top 30 | end 31 | 32 | function self:Push (matrix, pushOperation) 33 | GLib.Error ("IMatrixStack:Push : Not implemented.") 34 | end 35 | 36 | function self:PushIdentity () 37 | GLib.Error ("IMatrixStack:PushIdentity : Not implemented.") 38 | end 39 | 40 | function self:Pop () 41 | GLib.Error ("IMatrixStack:Pop : Not implemented.") 42 | end 43 | 44 | function self:Set (matrix) 45 | GLib.Error ("IMatrixStack:Set : Not implemented.") 46 | 47 | self.Top = matrix 48 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/matrices/matrixstack.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.Matrices.MatrixStack = GLib.MakeConstructor (self, GLib.Rendering.Matrices.IMatrixStack) 3 | 4 | GLib.Rendering.Matrices.MatrixStack.NextStackId = 1 5 | self.IdentityRevisionId = 1 6 | 7 | function self:ctor (id) 8 | self.Top = GLib.Matrix.Identity (4) 9 | self.RevisionId = self.IdentityRevisionId 10 | 11 | self.Stack = GLib.Containers.Stack () 12 | self.RevisionIdStack = GLib.Containers.Stack () 13 | 14 | if id == nil then 15 | id = GLib.Rendering.Matrices.MatrixStack.NextStackId 16 | GLib.Rendering.Matrices.MatrixStack.NextStackId = GLib.Rendering.Matrices.MatrixStack.NextStackId + 1 17 | end 18 | 19 | self.NextRevisionId = id * 4294967296 + 2 20 | end 21 | 22 | function self:GetTop () 23 | return self.Top 24 | end 25 | 26 | function self:SetTop (matrix) 27 | self:Set (matrix) 28 | end 29 | 30 | function self:Get () 31 | return self.Top 32 | end 33 | 34 | function self:Push (matrix, pushOperation) 35 | pushOperation = pushOperation or GLib.Rendering.MatrixPushOperation.Override 36 | 37 | self.Stack:Push (self.Top) 38 | self.RevisionIdStack:Push (self.RevisionId) 39 | 40 | if pushOperation == GLib.Rendering.MatrixPushOperation.Override then 41 | self.Top = matrix 42 | elseif pushOperation == GLib.Rendering.MatrixPushOperation.PreMultiply then 43 | -- TODO: Do something about garbage. MatrixPool? 44 | self.Top = matrix * this.Top 45 | elseif pushOperation == GLib.Rendering.MatrixPushOperation.PostMultiply then 46 | -- TODO: Do something about garbage. MatrixPool? 47 | self.Top = this.Top * matrix 48 | end 49 | 50 | self.RevisionId = self.NextRevisionId 51 | self.NextRevisionId = self.NextRevisionId + 1 52 | end 53 | 54 | function self:PushIdentity () 55 | self.Stack:Push (self.Top) 56 | self.RevisionIdStack:Push (self.RevisionId) 57 | self.Top = GLib.Matrix.Identity (4) 58 | self.RevisionId = self.IdentityRevisionId 59 | end 60 | 61 | function self:Pop () 62 | if self.Stack.Count == 0 then 63 | GLib.Error ("MatrixStack:Pop : Underflow!") 64 | return 65 | end 66 | 67 | self.Top = self.Stack:Pop () 68 | self.RevisionId = self.RevisionIdStack:Pop () 69 | end 70 | 71 | function self:Set (matrix) 72 | self.Top = matrix 73 | self.RevisionId = self.NextRevisionId 74 | self.NextRevisionId = self.NextRevisionId + 1 75 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/matrices/projections.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.Matrices.Projections = GLib.MakeConstructor (self) 3 | 4 | -- Returns a projection matrix with (0, 0) at the top left of the screen, 5 | -- positive x rightwards and positive y downwards 6 | function GLib.Rendering.Matrices.Projections.OrthographicLeftHanded (width, height, near, far) 7 | return GLib.Matrix (4, 4, 8 | 2 / width, 0, 0, -1, 9 | 0, -2 / height, 0, 1, 10 | 0, 0, 1 / (far - near), 0, 11 | 0, 0, near / (near - far), 1 12 | ) 13 | end 14 | 15 | -- Returns a projection matrix with (0, 0) at the centre of the screen, 16 | -- positive x rightwards and positive y upwards 17 | function GLib.Rendering.Matrices.Projections.OrthographicLeftHanded2 (width, height, near, far) 18 | return GLib.Matrix (4, 4, 19 | 2 / width, 0, 0, 0, 20 | 0, 2 / height, 0, 0, 21 | 0, 0, 1 / (far - near), 0, 22 | 0, 0, near / (near - far), 1 23 | ) 24 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/matrixpushoperation.lua: -------------------------------------------------------------------------------- 1 | GLib.Rendering.MatrixPushOperation = GLib.Enum ( 2 | { 3 | Override = 1, 4 | PreMultiply = 2, 5 | PostMultiply = 3 6 | } 7 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/meshes/imesh.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.Meshes.IMesh = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.GraphicsDevice = nil 6 | 7 | self.Flags = GLib.Rendering.Meshes.MeshFlags.None 8 | 9 | -- Buffers 10 | self.VertexBuffer = nil 11 | self.IndexBuffer = nil 12 | 13 | self.NextFreeIndex = 1 14 | self.NextFreeVertex = 1 15 | 16 | -- Render Groups 17 | self.RenderGroups = GLib.Containers.List () 18 | end 19 | 20 | function self:dtor () 21 | end 22 | 23 | function self:GetGraphicsDevice () 24 | return self.GraphicsDevice 25 | end 26 | 27 | function self:Destroy () 28 | self:dtor () 29 | end 30 | 31 | function self:GetFlags () 32 | return self.Flags 33 | end 34 | 35 | -- Buffers 36 | function self:GetVertexBuffer () 37 | return self.VertexBuffer 38 | end 39 | 40 | function self:GetIndexBuffer () 41 | return self.IndexBuffer 42 | end 43 | 44 | function self:AppendVertices (vertexCount, vertices) 45 | GLib.Error ("IMesh:AppendVertices : Not implemented.") 46 | end 47 | 48 | function self:AppendIndices (vertexCount, vertices) 49 | GLib.Error ("IMesh:AppendIndices : Not implemented.") 50 | end 51 | 52 | function self:Clear () 53 | GLib.Error ("IMesh:Clear : Not implemented.") 54 | end 55 | 56 | function self:GetFreeIndexCount () 57 | if not self.IndexBuffer then return 0 end 58 | return self.IndexBuffer:GetElementCount () - self.NextFreeIndex 59 | end 60 | 61 | function self:GetFreeVertexCount () 62 | if not self.VertexBuffer then return 0 end 63 | return self.VertexBuffer:GetElementCount () - self.NextFreeVertex 64 | end 65 | 66 | function self:GetNextFreeIndex () 67 | return self.NextFreeIndex 68 | end 69 | 70 | function self:GetNextFreeVertex () 71 | return self.NextFreeVertex 72 | end 73 | 74 | -- Render Groups 75 | function self:AppendRenderGroup (primitiveTopology, startVertex, vertexCount, merge) 76 | GLib.Error ("IMesh:AppendRenderGroup : Not implemented.") 77 | end 78 | 79 | function self:ClearRenderGroups () 80 | GLib.Error ("IMesh:ClearRenderGroups : Not implemented.") 81 | end 82 | 83 | function self:DrawAllRenderGroups (renderContext) 84 | GLib.Error ("IMesh:DrawAllRenderGroups : Not implemented.") 85 | end 86 | 87 | function self:GetRenderGroups () 88 | return self.RenderGroups 89 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/meshes/mesh.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.Meshes.Mesh = GLib.MakeConstructor (self, GLib.Rendering.Meshes.IMesh) 3 | 4 | function self:ctor (graphicsDevice, vertexLayout, vertexCount, indexCount, meshFlags) 5 | self.GraphicsDevice = graphicsDevice 6 | 7 | self.Flags = meshFlags 8 | 9 | self.VertexBuffer = self.GraphicsDevice:CreateVertexBuffer (vertexCount, vertexLayout, bit.band (meshFlags, GLib.Rendering.Meshes.MeshFlags.Dynamic) ~= 0 and GLib.Rendering.Buffers.BufferFlags.Dynamic or GLib.Rendering.Buffers.BufferFlags.None) 10 | 11 | if indexCount > 0 then 12 | self.IndexBuffer = self.GraphicsDevice:CreateIndexBuffer (indexCount, GLib.Rendering.Buffers.BufferElementType.UInt16, bit.band (meshFlags, GLib.Rendering.Meshes.MeshFlags.Dynamic) ~= 0 and GLib.Rendering.Buffers.BufferFlags.Dynamic or GLib.Rendering.Buffers.BufferFlags.None) 13 | end 14 | end 15 | 16 | function self:dtor () 17 | if self.VertexBuffer then 18 | self.VertexBuffer:dtor () 19 | self.VertexBuffer = nil 20 | end 21 | if self.IndexBuffer then 22 | self.IndexBuffer:dtor () 23 | self.IndexBuffer = nil 24 | end 25 | end 26 | 27 | -- Buffers 28 | function self:AppendVertices (vertexCount, vertices) 29 | local firstVertex = self.NextFreeVertex 30 | 31 | self.VertexBuffer:SetElements (firstVertex, vertexCount, vertices) 32 | self.NextFreeVertex = self.NextFreeVertex + vertexCount 33 | 34 | return firstVertex 35 | end 36 | 37 | function self:AppendIndices (indexCount, indices) 38 | local firstIndex = self.NextFreeIndex 39 | 40 | self.IndexBuffer:SetElements (firstIndex, indexCount, indices) 41 | self.NextFreeIndex = self.NextFreeIndex + indexCount 42 | 43 | return firstIndex 44 | end 45 | 46 | function self:Clear () 47 | self.NextFreeVertex = 0 48 | self.NextFreeIndex = 0 49 | 50 | self:ClearRenderGroups () 51 | end 52 | 53 | -- Render Groups 54 | function self:AppendRenderGroup (primitiveTopology, startVertex, vertexCount, merge) 55 | if merge and self.RenderGroups.Count > 0 then 56 | local lastRenderGroup = self.RenderGroups [self.RenderGroups.Count] 57 | if lastRenderGroup.PrimitiveTopology == primitiveTopology and 58 | lastRenderGroup.StartElement + lastRenderGroup.ElementCount == startVertex then 59 | lastRenderGroup.ElementCount = lastRenderGroup.ElementCount + vertexCount 60 | self.RenderGroups [self.RenderGroups.Count] = lastRenderGroup 61 | end 62 | end 63 | 64 | self.RenderGroups:Add (GLib.Rendering.Meshes.RenderGroup (primitiveTopology, startVertex, vertexCount)) 65 | end 66 | 67 | function self:ClearRenderGroups () 68 | self.RenderGroups:Clear () 69 | end 70 | 71 | function self:DrawAllRenderGroups (renderContext) 72 | GLib.Error ("Mesh:DrawAllRenderGroups : Not implemented.") 73 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/meshes/meshflags.lua: -------------------------------------------------------------------------------- 1 | GLib.Rendering.Meshes.MeshFlags = GLib.Enum ( 2 | { 3 | None = 0, 4 | Dynamic = 1 5 | } 6 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/meshes/primitivetopology.lua: -------------------------------------------------------------------------------- 1 | GLib.Rendering.Meshes.PrimitiveTopology = GLib.Enum ( 2 | { 3 | PointList = 0, 4 | LineList = 1, 5 | LineStrip = 2, 6 | TriangleList = 3, 7 | TriangleStrip = 4 8 | } 9 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/meshes/rendergroup.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.Meshes.RenderGroup = GLib.MakeConstructor (self) 3 | 4 | function self:ctor (primitiveTopology, startElement, elementCount) 5 | self.PrimitiveTopology = primitiveTopology 6 | self.StartElement = startElement or 0 7 | self.ElementCount = elementCount or 0 8 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/textures/itexture2d.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Rendering.Textures.ITexture2d = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.GraphicsDevice = nil 6 | self.Handle = nil 7 | 8 | self.Size = nil 9 | self.PixelFormat = GLib.Rendering.Textures.PixelFormat.R8G8B8A8 10 | end 11 | 12 | function self:dtor () 13 | end 14 | 15 | function self:GetGraphicsDevice () 16 | return self.GraphicsDevice 17 | end 18 | 19 | function self:GetHandle () 20 | return self.Handle 21 | end 22 | 23 | function self:Destroy () 24 | self:dtor () 25 | end 26 | 27 | function self:GetSize () 28 | return self.Size 29 | end 30 | 31 | function self:GetPixelFormat () 32 | return self.PixelFormat 33 | end 34 | 35 | function self:SetPixels (mipMap, topLeft, size, pixels) 36 | GLib.Error ("ITexture2d:SetPixels : Not implemented.") 37 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/rendering/textures/pixelformat.lua: -------------------------------------------------------------------------------- 1 | GLib.Rendering.Textures.PixelFormat = GLib.Enum ( 2 | { 3 | R8G8B8 = 0, 4 | B8G8R8 = 1, 5 | R8G8B8A8 = 2, 6 | B8G8R8A8 = 3 7 | } 8 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/resources/resourcestate.lua: -------------------------------------------------------------------------------- 1 | GLib.Resources.ResourceState = GLib.Enum ( 2 | { 3 | Available = 1, -- Available locally (may have been received from the server) 4 | Unknown = 2, -- Not available locally, may be in cache, request needs to be sent to server 5 | Requested = 3, -- Requested from server, waiting for response 6 | Unavailable = 4, -- Server does not have the resource 7 | Receiving = 5 -- Server is sending the resource to us 8 | } 9 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/serialization/iserializable.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Serialization.ISerializable = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | end 6 | 7 | function self:Deserialize (inBuffer) 8 | GLib.Error ("ISerializable:Deserialize : Not implemented.") 9 | end 10 | 11 | function self:Serialize (outBuffer) 12 | GLib.Error ("ISerializable:Serialize : Not implemented.") 13 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/servers/iplayermonitor.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.IPlayerMonitor = GLib.MakeConstructor (self) 3 | 4 | --[[ 5 | Events: 6 | LocalPlayerConnected (Player ply, userId) 7 | Fired when the local client's player entity has been created. 8 | PlayerConnected (Player ply, userId, isLocalPlayer) 9 | Fired when a player has connected and has a player entity. 10 | PlayerDisconnected (Player ply, userId) 11 | Fired when a player has disconnected. 12 | ]] 13 | 14 | function self:ctor () 15 | GLib.EventProvider (self) 16 | end 17 | 18 | function self:AddPlayerExistenceListener (nameOrCallback, callback) 19 | GLib.Error ("IPlayerMonitor:AddPlayerExistenceListener : Not implemented.") 20 | end 21 | 22 | function self:RemovePlayerExistenceListener (nameOrCallback) 23 | GLib.Error ("IPlayerMonitor:RemovePlayerExistenceListener : Not implemented.") 24 | end 25 | 26 | -- Enumerates connected players. 27 | -- Returns: () -> (userId, Player player) 28 | function self:GetPlayerEnumerator () 29 | GLib.Error ("IPlayerMonitor:GetPlayerEnumerator : Not implemented.") 30 | end 31 | 32 | function self:GetUserEntity (userId) 33 | GLib.Error ("IPlayerMonitor:GetUserEntity : Not implemented.") 34 | end 35 | 36 | function self:GetUserEntities (userId) 37 | GLib.Error ("IPlayerMonitor:GetUserEntities : Not implemented.") 38 | end 39 | 40 | -- Enumerates user ids. 41 | -- Returns: () -> userId 42 | function self:GetUserEnumerator () 43 | GLib.Error ("IPlayerMonitor:GetUserEnumerator : Not implemented.") 44 | end 45 | 46 | function self:GetUserName (userId) 47 | GLib.Error ("IPlayerMonitor:GetUserName : Not implemented.") 48 | end 49 | 50 | function self:IsUserPresent (userId) 51 | GLib.Error ("IPlayerMonitor:IsUserPresent : Not implemented.") 52 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/servers/iserver.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.IServer = GLib.MakeConstructor (self) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/servers/iuserlist.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.IUserList = GLib.MakeConstructor (self) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/servers/playerdisconnectionwatcher.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.PlayerDisconnectionWatcher = GLib.MakeConstructor (self) 3 | 4 | --[[ 5 | Events: 6 | PlayerDisconnected (Player ply, userId) 7 | Fired when a player has disconnected. 8 | ]] 9 | 10 | function self:ctor () 11 | self.DisconnectionEvents = {} 12 | 13 | GLib.PlayerMonitor:AddEventListener ("PlayerDisconnected", "GLib.PlayerDisconnectionWatcher", 14 | function (_, ply, userId) 15 | if not self.DisconnectionEvents [userId] then return end 16 | 17 | self.DisconnectionEvents [userId]:Dispatch () 18 | 19 | self:DispatchEvent ("PlayerDisconnected", ply, userId) 20 | end 21 | ) 22 | 23 | GLib.EventProvider (self) 24 | end 25 | 26 | function self:dtor () 27 | GLib.PlayerMonitor:RemoveEventListener ("PlayerDisconnected", "GLib.PlayerDisconnectionWatcher") 28 | end 29 | 30 | function self:GetDisconnectionEvent (userId) 31 | if not self.DisconnectionEvents [userId] then 32 | if not GLib.PlayerMonitor:IsUserPresent (userId) then return nil end 33 | 34 | self.DisconnectionEvents [userId] = GLib.Event () 35 | self.DisconnectionEvents [userId]:AddListener ( 36 | function () 37 | self.DisconnectionEvents [userId] = nil 38 | end 39 | ) 40 | end 41 | 42 | return self.DisconnectionEvents [userId] 43 | end 44 | 45 | function self:__call (userId) 46 | return GLib.PlayerDisconnectionWatcher2 (userId) 47 | end 48 | 49 | GLib.PlayerDisconnectionWatcher = GLib.PlayerDisconnectionWatcher () -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/servers/playerdisconnectionwatcher2.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.PlayerDisconnectionWatcher2 = GLib.MakeConstructor (self, GLib.Invoker) 3 | 4 | function self:ctor (userId) 5 | local event = GLib.PlayerDisconnectionWatcher:GetDisconnectionEvent (self.UserId) 6 | event:AddListener (self:GetHashCode (), 7 | function () 8 | self:Invoke () 9 | end 10 | ) 11 | end 12 | 13 | function self:dtor () 14 | local event = GLib.PlayerDisconnectionWatcher:GetDisconnectionEvent (self.UserId) 15 | if event then 16 | event:RemoveListener (self:GetHashCode ()) 17 | end 18 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/string/string.lua: -------------------------------------------------------------------------------- 1 | function GLib.String.DumpHex (str, bytesPerLine) 2 | bytesPerLine = bytesPerLine or 16 3 | 4 | local lines = {} 5 | local i = 1 6 | 7 | while i <= #str do 8 | local line = string.sub (str, i, i + bytesPerLine - 1) 9 | local left = "" 10 | local right = "" 11 | 12 | for j = 1, #line do 13 | local char = string.byte (line, j) 14 | left = left .. string.format ("%02x ", char) 15 | 16 | if char >= 32 and char < 127 then 17 | right = right .. string.sub (line, j, j) 18 | else 19 | right = right .. "." 20 | end 21 | end 22 | 23 | if #left < 3 * bytesPerLine then 24 | left = left .. string.rep (" ", 3 * bytesPerLine - #left) 25 | end 26 | 27 | lines [#lines + 1] = left .. "| " .. right 28 | 29 | i = i + bytesPerLine 30 | end 31 | 32 | return table.concat (lines, "\n") 33 | end 34 | 35 | function GLib.String.GetLines (str) 36 | return GLib.String.Split (str, "\n") 37 | end 38 | 39 | function GLib.String.LineIterator (str) 40 | return GLib.String.SplitIterator (str, "\n") 41 | end 42 | 43 | function GLib.String.Split (str, separator) 44 | if #separator == 0 then 45 | return GLib.String.ToCharArray (str) 46 | end 47 | 48 | local parts = {} 49 | local stringLength = #str 50 | local separatorLength = #separator 51 | local lastSeparatorEndPos = 1 52 | 53 | while lastSeparatorEndPos <= stringLength do 54 | local nextSeparatorStartPos = string.find (str, separator, lastSeparatorEndPos, true) 55 | if not nextSeparatorStartPos then break end 56 | 57 | parts [#parts + 1] = string.sub (str, lastSeparatorEndPos, nextSeparatorStartPos - 1) 58 | lastSeparatorEndPos = nextSeparatorStartPos + separatorLength 59 | end 60 | parts [#parts + 1] = string.sub (str, lastSeparatorEndPos) 61 | 62 | return parts 63 | end 64 | 65 | function GLib.String.SplitIterator (str, separator) 66 | if #separator == 0 then 67 | return GLib.UTF8.Iterator (str) 68 | end 69 | 70 | local stringLength = #str 71 | local separatorLength = #separator 72 | local lastSeparatorEndPos = 1 73 | 74 | return function () 75 | if lastSeparatorEndPos > stringLength + 1 then return nil end 76 | 77 | local nextSeparatorStartPos = string.find (str, separator, lastSeparatorEndPos, true) 78 | local ret 79 | if nextSeparatorStartPos then 80 | ret = string.sub (str, lastSeparatorEndPos, nextSeparatorStartPos - 1) 81 | lastSeparatorEndPos = nextSeparatorStartPos + separatorLength 82 | else 83 | ret = string.sub (str, lastSeparatorEndPos) 84 | lastSeparatorEndPos = stringLength + 2 85 | end 86 | 87 | return ret 88 | end 89 | end 90 | 91 | function GLib.String.ToCharArray (str) 92 | local chars = {} 93 | for c in GLib.UTF8.Iterator (str) do 94 | chars [#chars + 1] = c 95 | end 96 | return chars 97 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/stringbuilder.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.StringBuilder = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.Buffer = { "" } 6 | self.Length = 0 7 | end 8 | 9 | function self:Append (str) 10 | str = tostring (str) 11 | if #self.Buffer [#self.Buffer] >= 1024 then 12 | self.Buffer [#self.Buffer + 1] = "" 13 | end 14 | self.Buffer [#self.Buffer] = self.Buffer [#self.Buffer] .. str 15 | self.Length = self.Length + #str 16 | 17 | return self 18 | end 19 | 20 | function self:Clear () 21 | self.Buffer = { "" } 22 | self.Length = 0 23 | end 24 | 25 | function self:GetLength () 26 | return self.Length 27 | end 28 | 29 | function self:ToString () 30 | return table.concat (self.Buffer) 31 | end 32 | 33 | self.__concat = function (a, b) 34 | if type (b) == "string" then 35 | return a:Append (b) 36 | end 37 | return tostring (a) .. tostring (b) 38 | end 39 | 40 | self.__len = self.GetLength 41 | self.__tostring = self.ToString -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/stringtable.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.StringTable = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | self.StringHashes = {} 6 | self.HashStrings = {} 7 | end 8 | 9 | function self:Add (str) 10 | if self.StringHashes [str] then return end 11 | 12 | local hash = tonumber (util.CRC (str)) 13 | if self.HashStrings [hash] then 14 | GLib.Error ("StringTable:Add : " .. str .. "'s hash collides with " .. self.HashStrings [hash] .. "'s hash!") 15 | end 16 | 17 | self.StringHashes [str] = hash 18 | self.HashStrings [hash] = str 19 | end 20 | 21 | function self:HashFromString (str) 22 | if not self.StringHashes [str] then 23 | GLib.Error ("StringTable:HashFromString : " .. str .. " is not in the table!") 24 | end 25 | return self.StringHashes [str] 26 | end 27 | 28 | function self:StringFromHash (hash) 29 | if not self.HashStrings [hash] then 30 | GLib.Error ("StringTable:StringFromHash : " .. tostring (hash) .. " is not in the table!") 31 | end 32 | return self.HashStrings [hash] 33 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/threading/event.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Threading.Event = GLib.MakeConstructor (self, GLib.Threading.IWaitable) 3 | 4 | function self:ctor () 5 | self.AutoReset = true 6 | self.Fired = false 7 | 8 | self.Waiters = {} 9 | end 10 | 11 | function self:Fire () 12 | if self:IsFired () then return end 13 | 14 | if not self:IsResetAutomatically () then 15 | self.Fired = true 16 | end 17 | 18 | local waiters = self.Waiters 19 | self.Waiters = {} 20 | 21 | for _, callback in pairs (waiters) do 22 | callback (GLib.Threading.WaitEndReason.Success) 23 | end 24 | end 25 | 26 | function self:IsFired () 27 | return self.Fired 28 | end 29 | 30 | function self:IsResetAutomatically () 31 | return self.AutoReset 32 | end 33 | 34 | function self:Reset () 35 | self.Fired = false 36 | end 37 | 38 | function self:SetAutoReset (autoReset) 39 | if self.AutoReset == autoReset then return self end 40 | 41 | self.AutoReset = autoReset 42 | 43 | if self.AutoReset and self.Fired then 44 | self.Fired = false 45 | end 46 | 47 | return self 48 | end 49 | 50 | function self:WaitCallback (callback) 51 | if self:IsFired () then 52 | callback (GLib.Threading.WaitEndReason.Success) 53 | return 54 | end 55 | 56 | self.Waiters [#self.Waiters + 1] = callback 57 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/threading/iwaitable.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Threading.IWaitable = GLib.MakeConstructor (self) 3 | 4 | function self:ctor () 5 | end 6 | 7 | function self:IsResolvableWaitable () 8 | return false 9 | end 10 | 11 | function self:ResolveWait (timeout) 12 | if self:IsResolvableWait () then 13 | GLib.Error ("IWaitable:ResolveWait : Not implemented.") 14 | else 15 | GLib.Error ("IWaitable:ResolveWait : This IWaitable is non-resolvable.") 16 | end 17 | return false 18 | end 19 | 20 | function self:Wait (callback) 21 | if callback then 22 | self:WaitCallback (callback) 23 | else 24 | return GLib.Threading.CurrentThread:WaitForSingleObject (self) 25 | end 26 | end 27 | 28 | function self:WaitCallback (callback) 29 | GLib.Error ("IWaitable:WaitCallback : Not implemented.") 30 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/threading/mainthread.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Threading.MainThread = GLib.MakeConstructor (self, GLib.Threading.Thread) 3 | 4 | function self:ctor () 5 | self:SetName ("Main") 6 | self:SetState (GLib.Threading.ThreadState.Running) 7 | self:SetYieldTimeSliceAllowed (false) 8 | end 9 | 10 | -- Thread 11 | function self:IsMainThread () 12 | return true 13 | end 14 | 15 | -- Thread control 16 | function self:Suspend () 17 | end 18 | 19 | function self:Start (f, ...) 20 | end 21 | 22 | function self:Terminate () 23 | GLib.Error ("MainThread:Terminate : You can't stop the signal.") 24 | end 25 | 26 | -- Waits 27 | function self:Wait (callback) 28 | GLib.Error ("MainThread:Wait : This method should never be called.") 29 | 30 | if callback then 31 | callback (GLib.Threading.WaitEndReason.Success) 32 | end 33 | 34 | return 35 | end 36 | 37 | -- IWaitable 38 | function self:IsResolvableWaitable () 39 | return false 40 | end 41 | 42 | -- Cooperative threading 43 | function self:CanYield () 44 | return false 45 | end 46 | 47 | function self:CanYieldTimeSlice () 48 | return false 49 | end 50 | 51 | function self:CheckYield () 52 | return false 53 | end 54 | 55 | function self:Yield () 56 | GLib.Error ("MainThread:Yield : This method should never be called.") 57 | end 58 | 59 | GLib.Threading.MainThread = GLib.Threading.MainThread () -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/threading/threading.lua: -------------------------------------------------------------------------------- 1 | GLib.Threading.CurrentThread = nil 2 | 3 | function GLib.CallAsync (f, ...) 4 | return GLib.Threading.Thread ():Start (f, ...) 5 | end 6 | 7 | function GLib.Curry (f, ...) 8 | local arguments = {...} 9 | local argumentCount = table.maxn (arguments) 10 | 11 | if argumentCount == 0 then return f end 12 | 13 | return function (...) 14 | return f (unpack (arguments, 1, argumentCount)) 15 | end 16 | end 17 | 18 | function GLib.Threading.CanYield () 19 | if not GLib.Threading.CurrentThread then 20 | return coroutine.running () ~= nil 21 | end 22 | 23 | return GLib.Threading.CurrentThread:CanYield () 24 | end 25 | 26 | function GLib.Threading.CanYieldTimeSlice () 27 | if not GLib.Threading.CurrentThread then 28 | return coroutine.running () ~= nil 29 | end 30 | 31 | return GLib.Threading.CurrentThread:CanYieldTimeSlice () 32 | end 33 | 34 | function GLib.Threading.CheckYield () 35 | if not GLib.Threading.CurrentThread then return false end 36 | 37 | return GLib.Threading.CurrentThread:CheckYield () 38 | end 39 | 40 | function GLib.Threading.GetCurrentThread () 41 | return GLib.Threading.CurrentThread 42 | end 43 | 44 | function GLib.Threading.InThread () 45 | return not GLib.Threading.GetCurrentThread ():IsMainThread () 46 | end 47 | 48 | GLib.Threading.IsInThread = GLib.Threading.InThread 49 | 50 | function GLib.Threading.Sleep (durationInMilliseconds) 51 | if not GLib.Threading.CurrentThread then return false end 52 | 53 | return GLib.Threading.CurrentThread:Sleep (durationInMilliseconds) 54 | end 55 | 56 | function GLib.Threading.Yield () 57 | if not GLib.Threading.CurrentThread then return false end 58 | 59 | return GLib.Threading.CurrentThread:Yield () 60 | end 61 | 62 | GLib.CheckYield = GLib.Threading.CheckYield 63 | GLib.GetCurrentThread = GLib.Threading.GetCurrentThread 64 | GLib.InThread = GLib.Threading.InThread 65 | GLib.IsInThread = GLib.Threading.IsInThread 66 | GLib.Sleep = GLib.Threading.Sleep 67 | GLib.Yield = GLib.Threading.Yield -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/threading/threadstate.lua: -------------------------------------------------------------------------------- 1 | GLib.Threading.ThreadState = GLib.Enum ( 2 | { 3 | Unstarted = 1, 4 | Running = 2, -- Runnable 5 | Waiting = 3, -- Not runnable 6 | Sleeping = 4, -- Not runnable 7 | Terminated = 5 8 | } 9 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/threading/waitendreason.lua: -------------------------------------------------------------------------------- 1 | GLib.Threading.WaitEndReason = GLib.Enum ( 2 | { 3 | Success = 1, 4 | Timeout = 2 5 | } 6 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/timers.lua: -------------------------------------------------------------------------------- 1 | local delayedCalls = {} 2 | GLib.SlowDelayedCalls = {} 3 | 4 | function GLib.CallDelayed (callback) 5 | if not callback then return end 6 | if type (callback) ~= "function" then 7 | GLib.Error ("GLib.CallDelayed : callback must be a function!") 8 | return 9 | end 10 | 11 | delayedCalls [#delayedCalls + 1] = callback 12 | end 13 | 14 | function GLib.PolledWait (interval, timeout, predicate, callback) 15 | if not callback then return end 16 | if not predicate then return end 17 | 18 | if predicate () then 19 | callback () 20 | return 21 | end 22 | 23 | if timeout < 0 then return end 24 | 25 | timer.Simple (interval, 26 | function () 27 | GLib.PolledWait (interval, timeout - interval, predicate, callback) 28 | end 29 | ) 30 | end 31 | 32 | hook.Add ("Think", "GLib.DelayedCalls", 33 | function () 34 | local lastCalled = nil 35 | local startTime = SysTime () 36 | while SysTime () - startTime < 0.005 and #delayedCalls > 0 do 37 | lastCalled = delayedCalls [1] 38 | xpcall (delayedCalls [1], GLib.Error) 39 | table.remove (delayedCalls, 1) 40 | end 41 | 42 | if SysTime () - startTime > 0.2 and lastCalled then 43 | MsgN ("GLib.DelayedCalls : " .. tostring (lastCalled) .. " took " .. GLib.FormatDuration (SysTime () - startTime) .. ".") 44 | GLib.SlowDelayedCalls [#GLib.SlowDelayedCalls + 1] = lastCalled 45 | end 46 | end 47 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/transfers/outboundtransfer.lua: -------------------------------------------------------------------------------- 1 | local self = {} 2 | GLib.Transfers.OutboundTransfer = GLib.MakeConstructor (self) 3 | 4 | function self:ctor (id, data) 5 | self.Id = id 6 | self.DisplayId = nil 7 | 8 | self.DestinationId = nil 9 | self.DestinationPlayer = nil 10 | 11 | self.ChannelName = nil 12 | self.Data = data 13 | 14 | self.EncodedData = self.Data 15 | self.EncodedLength = #self.EncodedData 16 | 17 | self.ChunkSize = 0 18 | self.ChunkCount = 0 19 | self.NextChunk = 1 20 | 21 | self:SetChunkSize (16384) 22 | end 23 | 24 | function self:GetChannelName () 25 | return self.ChannelName 26 | end 27 | 28 | function self:GetDestinationId () 29 | return self.DestinationId 30 | end 31 | 32 | function self:GetDisplayId () 33 | if self.DisplayId then return self.DisplayId end 34 | return self:GetDestinationId () .. "/" .. self:GetChannelName () .. "/" .. self:GetId () 35 | end 36 | 37 | function self:GetId () 38 | return self.Id 39 | end 40 | 41 | function self:IsDestinationValid () 42 | if CLIENT then return true end 43 | if SERVER and self:GetDestinationId () == GLib.GetEveryoneId () then return true end 44 | return self.DestinationPlayer and self.DestinationPlayer:IsValid () or false 45 | end 46 | 47 | function self:IsFinished () 48 | return self.NextChunk > 1 and self.NextChunk > self.ChunkCount 49 | end 50 | 51 | function self:IsStarted () 52 | return self.NextChunk > 1 53 | end 54 | 55 | function self:SerializeFirstChunk (outBuffer) 56 | outBuffer:UInt32 (self.EncodedLength) 57 | outBuffer:UInt32 (self.ChunkSize) 58 | self:SerializeNextChunk (outBuffer) 59 | end 60 | 61 | function self:SerializeNextChunk (outBuffer) 62 | -- Include the next chunk 63 | local chunkStart = (self.NextChunk - 1) * self.ChunkSize + 1 64 | local chunkEnd = self.NextChunk * self.ChunkSize 65 | local chunk = string.sub (self.EncodedData, chunkStart, chunkEnd) 66 | 67 | outBuffer:LongString (chunk) 68 | 69 | self.NextChunk = self.NextChunk + 1 70 | end 71 | 72 | function self:SetChannelName (channelName) 73 | self.ChannelName = channelName 74 | end 75 | 76 | function self:SetChunkSize (chunkSize) 77 | if self:IsStarted () then 78 | GLib.Error ("OutboundTransfer:SetChunkSize : Cannot set chunk size after a transfer has started.") 79 | end 80 | 81 | self.ChunkSize = chunkSize 82 | self.ChunkCount = math.ceil (self.EncodedLength / self.ChunkSize) 83 | end 84 | 85 | function self:SetDestinationId (destinationId) 86 | self.DestinationId = destinationId 87 | self.DestinationPlayer = nil 88 | if SERVER then 89 | for _, v in ipairs (player.GetAll ()) do 90 | if GLib.GetPlayerId (v) == destinationId then 91 | self.DestinationPlayer = v 92 | break 93 | end 94 | end 95 | end 96 | end 97 | 98 | function self:SetDisplayId (displayId) 99 | self.DisplayId = displayId 100 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/unicode/unicodecategory.lua: -------------------------------------------------------------------------------- 1 | GLib.UnicodeCategory = GLib.Enum ( 2 | { 3 | UppercaseLetter = 0, 4 | LowercaseLetter = 1, 5 | TitlecaseLetter = 2, 6 | ModifierLetter = 3, 7 | OtherLetter = 4, 8 | NonSpacingMark = 5, 9 | SpacingCombiningMark = 6, 10 | EnclosingMark = 7, 11 | DecimalDigitNumber = 8, 12 | LetterNumber = 9, 13 | OtherNumber = 10, 14 | SpaceSeparator = 11, 15 | LineSeparator = 12, 16 | ParagraphSeparator = 13, 17 | Control = 14, 18 | Format = 15, 19 | Surrogate = 16, 20 | PrivateUse = 17, 21 | ConnectorPunctuation = 18, 22 | DashPunctuation = 19, 23 | OpenPunctuation = 20, 24 | ClosePunctuation = 21, 25 | InitialQuotePunctuation = 22, 26 | FinalQuotePunctuation = 23, 27 | OtherPunctuation = 24, 28 | MathSymbol = 25, 29 | CurrencySymbol = 26, 30 | ModifierSymbol = 27, 31 | OtherSymbol = 28, 32 | OtherNotAssigned = 29 33 | } 34 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/unicode/wordtype.lua: -------------------------------------------------------------------------------- 1 | GLib.WordType = GLib.Enum ( 2 | { 3 | None = 0, 4 | Alphanumeric = 1, 5 | Whitespace = 2, 6 | LineBreak = 3, 7 | Other = 4, 8 | } 9 | ) -------------------------------------------------------------------------------- /lua/libk/3rdparty/glib/userid.lua: -------------------------------------------------------------------------------- 1 | local singleplayerId = nil 2 | 3 | function GLib.GetEveryoneId () 4 | return "Everyone" 5 | end 6 | 7 | if SERVER then 8 | function GLib.GetLocalId () 9 | return "Server" 10 | end 11 | elseif CLIENT then 12 | function GLib.GetLocalId () 13 | if not LocalPlayer or not LocalPlayer ().SteamID then 14 | return "STEAM_0:0:0" 15 | end 16 | return LocalPlayer ():SteamID () 17 | end 18 | end 19 | 20 | function GLib.GetPlayerId (ply) 21 | if not ply then return nil end 22 | if not ply:IsValid () then return nil end 23 | if type (ply.SteamID) ~= "function" then return nil end 24 | 25 | local steamId = ply:SteamID () 26 | 27 | if SERVER and game.SinglePlayer () and ply == ents.GetByIndex (1) then 28 | steamId = singleplayerId 29 | end 30 | 31 | if steamId == "NULL" then 32 | steamId = "BOT" 33 | end 34 | 35 | return steamId 36 | end 37 | 38 | function GLib.GetServerId () 39 | return "Server" 40 | end 41 | 42 | function GLib.GetSystemId () 43 | return "System" 44 | end 45 | 46 | if game.SinglePlayer () then 47 | if SERVER then 48 | concommand.Add ("glib_singleplayerid", 49 | function (_, _, args) 50 | singleplayerId = args [1] 51 | end 52 | ) 53 | 54 | umsg.Start ("glib_request_singleplayerid") 55 | umsg.End () 56 | elseif CLIENT then 57 | local function sendSinglePlayerId () 58 | GLib.WaitForLocalPlayer ( 59 | function () 60 | RunConsoleCommand ("glib_singleplayerid", GLib.GetLocalId ()) 61 | end 62 | ) 63 | end 64 | 65 | usermessage.Hook ("glib_request_singleplayerid", sendSinglePlayerId) 66 | sendSinglePlayerId () 67 | end 68 | end -------------------------------------------------------------------------------- /lua/libk/3rdparty/semver.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ValentinFunk/LibK/62b006d3812a7873323ad1f144ee51034a7a7f51/lua/libk/3rdparty/semver.lua -------------------------------------------------------------------------------- /lua/libk/client/cl_DCenteredImage.lua: -------------------------------------------------------------------------------- 1 | local PANEL = {} 2 | 3 | function PANEL:Init( ) 4 | self.container = vgui.Create( "DPanel", self ) 5 | self.container:Dock( FILL ) 6 | function self.container:Paint( w, h ) 7 | end 8 | 9 | self.image = vgui.Create( "DImage", self.container ) 10 | end 11 | 12 | function PANEL:SetImage( name ) 13 | self.image:SetMaterial( Material( name, "noclamp smooth" ) ) 14 | self.image:SizeToContents() 15 | end 16 | 17 | function PANEL:SetImageColor( col ) 18 | self.image:SetImageColor( col ) 19 | end 20 | 21 | function PANEL:SetMaterial( mat ) 22 | self.image:SetMaterial( mat ) 23 | end 24 | 25 | function PANEL:PerformLayout( ) 26 | local mulW = self.container:GetWide( ) / self.image.ActualWidth 27 | local mulH = self.container:GetTall( ) / self.image.ActualHeight 28 | 29 | local min = math.min( mulW, mulH ) 30 | if min < 1 then 31 | self.image:SetSize( self.image.ActualWidth * min, self.image.ActualHeight * min ) 32 | end 33 | self.image:Center( ) 34 | end 35 | 36 | function PANEL:Paint( w, h ) 37 | end 38 | 39 | vgui.Register( "DCenteredImage", PANEL, "DPanel" ) -------------------------------------------------------------------------------- /lua/libk/client/cl_DSplitPanel.lua: -------------------------------------------------------------------------------- 1 | local PANEL = {} 2 | 3 | AccessorFunc( PANEL, "Spacing", "Spacing" ) 4 | AccessorFunc( PANEL, "Padding", "Padding" ) 5 | AccessorFunc( PANEL, "Ratio", "Ratio" ) 6 | 7 | function PANEL:Init( ) 8 | self:SetLeft( vgui.Create( "DPanel" ) ) 9 | self.left.Paint = function( ) end 10 | self:SetRight( vgui.Create( "DPanel" ) ) 11 | self.right.Paint = function( ) end 12 | self:SetSpacing( 5 ) 13 | self:SetPadding( 0 ) 14 | self:SetRatio( 0.5 ) 15 | end 16 | 17 | function PANEL:SetLeft( panel ) 18 | if IsValid( self.left ) then 19 | self.left:Remove( ) 20 | end 21 | 22 | self.left = panel 23 | self.left:SetParent( self ) 24 | self.left:Dock( LEFT ) 25 | end 26 | 27 | function PANEL:SetRight( panel ) 28 | if IsValid( self.right ) then 29 | self.right:Remove( ) 30 | end 31 | 32 | self.right = panel 33 | self.right:SetParent( self ) 34 | self.right:Dock( RIGHT ) 35 | end 36 | 37 | function PANEL:PerformLayout( ) 38 | self.left:DockMargin( self.Padding, self.Padding, 0, self.Padding ) 39 | self.right:DockMargin( 0, self.Padding, self.Padding, self.Padding ) 40 | local w = self:GetWide( ) - self.Spacing 41 | self.left:SetWide( w * self.Ratio ) 42 | self.right:SetWide( w * ( 1- self.Ratio ) ) 43 | end 44 | 45 | Derma_Hook( PANEL, "Paint", "Paint", "InnerPanel" ) 46 | 47 | vgui.Register( "DSplitPanel", PANEL, "DPanel" ) -------------------------------------------------------------------------------- /lua/libk/client/cl_dermautil.lua: -------------------------------------------------------------------------------- 1 | local function getControlName(dermaInstance) 2 | return table.KeyFromValue(derma.GetControlList(), dermaInstance) 3 | end 4 | 5 | --[[ 6 | Somehow gmod fucks up the last entry and we would end up in and 7 | infine loop. A quirk is that the class name doesn't match the panel anymore 8 | ]]-- 9 | local function endOfChain(dermaInstance) 10 | local controlName = getControlName(dermaInstance) 11 | return derma.Controls[controlName].ClassName != controlName 12 | end 13 | 14 | --[[ 15 | Returns if aControlName inherits from controlName. 16 | e.g. LibK.DermaInherits() 17 | ]]-- 18 | function LibK.DermaInherits(aControlName, controlName) 19 | if aControlName == controlName then 20 | return true 21 | end 22 | 23 | local parentName = derma.Controls[aControlName].BaseClass 24 | local parent = derma.Controls[parentName] 25 | while parent and not endOfChain(parent) do 26 | if parentName == controlName then 27 | return true 28 | end 29 | 30 | parentName = parent.BaseClass 31 | if not parentName then 32 | break 33 | end 34 | 35 | parent = derma.Controls[parentName] 36 | end 37 | 38 | return false 39 | end -------------------------------------------------------------------------------- /lua/libk/client/cl_libk_client.lua: -------------------------------------------------------------------------------- 1 | LibK.InitPostEntityPromise = Deferred( ) 2 | hook.Add( "InitPostEntity", "LibK_InitPostEntity", function( ) 3 | LibK.InitPostEntityPromise:Resolve( ) 4 | end ) -------------------------------------------------------------------------------- /lua/libk/client/cl_libk_dermaskin.lua: -------------------------------------------------------------------------------- 1 | surface.CreateFont( "LibKText", { 2 | font = "Segoe UI Semilight 8", 3 | size = 11 4 | } ) 5 | 6 | surface.CreateFont( "LibKElement", { 7 | font = "Segoe UI", 8 | size = 9 9 | } ) 10 | 11 | surface.CreateFont( "LibKHeading", { 12 | font = "Segoe UI Light", 13 | size = 20 14 | } ) 15 | 16 | surface.CreateFont( "LibKLarge", { 17 | font ="Segoe UI Light", 18 | size = 42, 19 | weight = 300 20 | } ) -------------------------------------------------------------------------------- /lua/libk/server/sv_libk_config.lua: -------------------------------------------------------------------------------- 1 | LibK.SQL = {} 2 | --SQL Configuration 3 | LibK.SQL.UseMysql = false --Set to true to use MSQL, false will use SQLite(sv.db) 4 | --MySQL Settings 5 | LibK.SQL.Host = "127.0.0.1" 6 | LibK.SQL.Port = 3306 7 | LibK.SQL.User = "root" 8 | LibK.SQL.Password = "" 9 | LibK.SQL.Database = "dbname" 10 | -------------------------------------------------------------------------------- /lua/libk/server/sv_libk_player.lua: -------------------------------------------------------------------------------- 1 | --Give player their db id or create entry if they don't have one 2 | function LibK.playerInitialSpawn( ply ) 3 | LibK.Player.findByPlayer( ply ) 4 | :Then( function( dbPlayer ) 5 | if not IsValid( ply ) then 6 | -- Player disconnected during join, do nothing 7 | return 8 | end 9 | 10 | if dbPlayer then 11 | dbPlayer.name = ply:Nick( ) 12 | dbPlayer.steam64 = ply:SteamID64( ) 13 | return dbPlayer:save( ) 14 | else 15 | local dbPlayer = LibK.Player:new( ) 16 | dbPlayer.name = ply:Nick( ) 17 | dbPlayer.player = ply 18 | dbPlayer.steam64 = ply:SteamID64( ) 19 | dbPlayer.uid = ply:UniqueID( ) 20 | return dbPlayer:save( ) 21 | end 22 | end ) 23 | :Then( function( dbPlayer ) 24 | if not IsValid( ply ) then 25 | -- Player disconnected during join, do nothing 26 | return 27 | end 28 | 29 | KLogf( 4, "[LibK] Player %s(id %i)", ply:Nick( ), dbPlayer.id ) 30 | ply.libk_originalNick = ply:Nick( ) 31 | ply.dbPlayer = dbPlayer 32 | ply.kPlayerId = dbPlayer.id 33 | ply:SetNWInt( "KPlayerId", dbPlayer.id ) 34 | hook.Call( "LibK_PlayerInitialSpawn", GAMEMODE, ply, dbPlayer ) 35 | end, function( errid, err ) 36 | KLogf( 2, "[LibK] Error initializing player %s(%i: %s )", ply:Nick( ), errid, err ) 37 | end ) 38 | end 39 | hook.Add( "PlayerInitialSpawn", "LibKJoinPlayer", LibK.playerInitialSpawn ) 40 | 41 | function LibK.monitorNameChanges( ) 42 | for k, v in pairs( player.GetAll( ) ) do 43 | if v:Nick( ) != v.libk_originalNick and v.dbPlayer then 44 | KLogf( 4, "[LibK] Player %s changed name to %s", v.libk_originalNick, v:Nick( ) ) 45 | v.dbPlayer.name = v:Nick( ) 46 | v.dbPlayer:save( ) 47 | :Fail( function( errid, err ) 48 | KLogf( 3, "[LibK] Error saving rename for %s(%i: %s)", v.libk_originalNick, errid, err ) 49 | end ) 50 | v.libk_originalNick = v:Nick( ) 51 | end 52 | end 53 | end 54 | hook.Add( "Think", "LibKMonitorNameChange", LibK.monitorNameChanges ) 55 | -------------------------------------------------------------------------------- /lua/libk/server/sv_libk_util.lua: -------------------------------------------------------------------------------- 1 | function LibK.addContentFolder( path, noRecurse ) 2 | local files, folders = file.Find( path .. "/*", "GAME" ) 3 | for k, v in pairs( files ) do 4 | resource.AddFile( path .. "/" .. v ) 5 | if LibK.Debug then 6 | --print( "[LibK] Resource Added " .. path .. "/" .. v ) 7 | end 8 | end 9 | 10 | if noRecurse then return end 11 | for k, v in pairs( folders ) do 12 | LibK.addContentFolder( path .. "/" .. v ) 13 | end 14 | end -------------------------------------------------------------------------------- /lua/libk/server/sv_permissionInterface.lua: -------------------------------------------------------------------------------- 1 | --TODO: Evolve 2 | function PermissionInterface.banPlayer( ply, time, reason, admin ) 3 | if exsto then 4 | elseif ulx then 5 | ulx.ban( admin, ply, time, reason ) 6 | elseif sam then 7 | sam.player.ban( ply, time, reason, IsValid(admin) and admin:SteamID() ) 8 | end 9 | end 10 | 11 | function PermissionInterface.banId( steam, time, reason, admin ) 12 | if exsto then 13 | elseif ulx then 14 | ulx.banid( admin, steam, time, reason ) 15 | elseif sam then 16 | sam.player.ban_id( ply, time, reason, IsValid(admin) and admin:SteamID() ) 17 | end 18 | end 19 | 20 | 21 | function PermissionInterface.kickPlayer( ply, reason, admin ) 22 | if exsto then 23 | exsto.RunCommand( admin, "kick", { reason, ply:SteamID( ) } ) 24 | elseif ulx then 25 | ulx.kick( admin, ply, reason ) 26 | else 27 | ply:Kick(reason) 28 | end 29 | end 30 | 31 | function PermissionInterface.slayPlayer( ply, admin ) 32 | if ulx then 33 | ulx.slay( admin, { ply } ) 34 | elseif sam then 35 | RunConsoleCommand( "sam", "slay", "#" .. ply:EntIndex() ) 36 | end 37 | end 38 | 39 | function PermissionInterface.slayPlayerNr( ply, rounds, reason, admin ) 40 | markPlayerForSlay( ply, rounds, reason, admin ) --Urg 41 | end 42 | 43 | function PermissionInterface.printIfPermission( permission, fmtstring, ... ) 44 | local message = string.format( fmtstring, ... ) 45 | for k, v in pairs( player.GetAll( ) ) do 46 | if PermissionInterface.query( permission, v ) then 47 | v:PrintMessage( HUD_PRINTTALK, message ) 48 | end 49 | end 50 | end -------------------------------------------------------------------------------- /lua/libk/shared/2_sh_libk.lua: -------------------------------------------------------------------------------- 1 | LibK = {} 2 | 3 | LibK.Debug = false 4 | LibK.LogLevel = 4 --Requires Debug 5 | LibK.LogSQL = false 6 | -------------------------------------------------------------------------------- /lua/libk/shared/sh_KPlayer.lua: -------------------------------------------------------------------------------- 1 | LibK.Player = class( "KPlayer" ) 2 | LibK.Player.static.DB = "LibK" 3 | 4 | LibK.Player.static.model = { 5 | tableName = "libk_player", 6 | fields = { 7 | --Why save 3 different ids? Because Darkrp and the such all like to 8 | --use something different, save all for simplicity, even if it violates 9 | --db theory. 10 | name = "string", 11 | uid = "playerUid", 12 | steam64 = "playerUid", 13 | player = "player", 14 | created_at = "createdTime", 15 | updated_at = "updatedTime" 16 | } 17 | } 18 | 19 | LibK.Player:include( DatabaseModel ) 20 | 21 | function LibK.Player.static.findPlayers( subject, attribute, limit ) 22 | if not LibK.Player.model.fields[attribute] then 23 | return Promise.Reject( 1, "Invalid attribute " .. attribute ) 24 | end 25 | 26 | subject = "%%" .. subject .. "%%" 27 | subject = DATABASES[LibK.Player.DB].SQLStr( subject ) 28 | 29 | limit = limit or 10 30 | 31 | return LibK.Player.getDbEntries( Format( 'WHERE `%s` LIKE %s LIMIT %i', attribute, subject, limit ) ) 32 | end -------------------------------------------------------------------------------- /lua/libk/shared/sh_Singleton.lua: -------------------------------------------------------------------------------- 1 | Singleton = {} 2 | 3 | function Singleton:included( class ) 4 | function class.static.getInstance( ) 5 | class.static.instance = class.static.instance or class:new( ) 6 | return class.static.instance 7 | end 8 | end -------------------------------------------------------------------------------- /lua/libk/shared/sh_debug.lua: -------------------------------------------------------------------------------- 1 | LibK.reloadInitFiles = { 2 | "autorun/_libk_loader.lua", 3 | } 4 | 5 | function LibK.addReloadFile( file ) 6 | if not table.HasValue( LibK.reloadInitFiles, file ) then 7 | table.insert( LibK.reloadInitFiles, file ) 8 | end 9 | end 10 | 11 | 12 | local function reloadLibKAddons( ) 13 | for k, file in pairs( LibK.reloadInitFiles ) do 14 | local func = CompileFile( file ) 15 | if func then 16 | func( ) 17 | else 18 | KLogf( 3, "[WARN] Couldn't reload file %s", file ) 19 | end 20 | end 21 | end 22 | 23 | 24 | if SERVER then 25 | util.AddNetworkString( "KRELOAD" ) 26 | concommand.Add( "libk_reload", function( ply, cmd, args ) 27 | if not LibK.Debug or ( ply:IsValid( ) and not ply:IsAdmin( ) ) then 28 | return 29 | end 30 | reloadLibKAddons( ) 31 | net.Start( "KRELOAD" ) 32 | net.Send( ply ) 33 | timer.Simple( 1, function( ) 34 | --Delayed, give the client a chance to reload first 35 | hook.Call( "OnReloaded", GAMEMODE ) 36 | end ) 37 | end ) 38 | end 39 | 40 | if CLIENT then 41 | net.Receive( "KRELOAD", function( ) 42 | reloadLibKAddons( ) 43 | hook.Call( "OnReloaded", GAMEMODE ) 44 | end ) 45 | end -------------------------------------------------------------------------------- /lua/libk/shared/sh_logger.lua: -------------------------------------------------------------------------------- 1 | function KLog( intLogLevel, strMessage, ... ) 2 | /* 3 | 1: Error 4 | 2: Warning 5 | 3: Important messages 6 | 4: Debug messages 7 | */ 8 | if LibK.Debug or intLogLevel <= 2 then 9 | local colors = { 10 | Color( 255, 0, 0 ), 11 | Color( 255, 175, 0 ), 12 | Color( 255, 255, 0 ), 13 | Color( 150, 150, 150 ), 14 | } 15 | if SERVER then 16 | --Server can only do red: 17 | if intLogLevel <= 3 then 18 | MsgC( colors[1], strMessage .. "\n" ) 19 | else 20 | MsgN( strMessage ) 21 | end 22 | else 23 | MsgC( colors[intLogLevel], strMessage .. "\n" ) 24 | end 25 | end 26 | if( intLogLevel <= LibK.LogLevel ) then 27 | if SERVER then 28 | strMessage = strMessage .. table.concat( {...} , ", " ) 29 | if LibK.Debug then 30 | file.Append( "LibK_Debug.txt", os.date() .. " - " .. strMessage .. "\n" ) 31 | end 32 | if intLogLevel <= 3 then 33 | file.Append( "LibK_Error.txt", os.date() .. " - " .. strMessage .. "\n" ) 34 | end 35 | end 36 | end 37 | end 38 | 39 | function KLogf( intLogLevel, strMessage, ... ) 40 | local args = { ... } 41 | --If function is called without a number, assume debug 42 | if type( intLogLevel ) == "string" then 43 | table.insert( args, 1, strMessage ) 44 | strMessage = intLogLevel 45 | intLogLevel = 4 46 | end 47 | local result, msg = pcall( string.format, strMessage, unpack( args ) ) 48 | if result then 49 | KLog( intLogLevel, msg ) 50 | else 51 | error( msg, 2 ) 52 | end 53 | end -------------------------------------------------------------------------------- /lua/libk/shared/sh_permissionInterface.lua: -------------------------------------------------------------------------------- 1 | PermissionInterface = {} 2 | 3 | --Check if user has acces to "access" 4 | function PermissionInterface.query( ply, access ) 5 | --ULX 6 | if ULib then 7 | return ULib.ucl.query( ply, access ) 8 | end 9 | 10 | --Evolve 11 | if ply.EV_HasPrivilege then 12 | return ply:EV_HasPrivilege( access ) 13 | end 14 | 15 | --Exsto 16 | if exsto then 17 | return ply:IsAllowed( access ) 18 | end 19 | 20 | --SAM 21 | if sam then 22 | return ply:HasPermission( access ) 23 | end 24 | 25 | KLogf(4, "[KReport] No compatible admin mod detected. ULX, Evolve, Exsto and SAM are supported- Defaulting." ) 26 | 27 | if ply:IsSuperAdmin() then 28 | return true 29 | end 30 | 31 | return false 32 | end 33 | 34 | function PermissionInterface.anyAllowed( ply, tblAccess ) 35 | for k, v in pairs( tblAccess ) do 36 | if PermissionInterface.query( ply, v ) then 37 | return true 38 | end 39 | end 40 | end 41 | 42 | function PermissionInterface.getRankTitle( internalName ) 43 | local ranks = PermissionInterface.getRanks( ) 44 | for k, v in pairs( ranks ) do 45 | if v.internalName == internalName then 46 | return v.title 47 | end 48 | end 49 | end 50 | 51 | function PermissionInterface.getRanks( ) 52 | local ranks = { } --internalName: string, title: string 53 | if ULib then 54 | for internalName, rankInfo in pairs( ULib.ucl.groups ) do 55 | if v != ULib.ACCESS_ALL then 56 | table.insert( ranks, { internalName = internalName, title = internalName } ) 57 | end 58 | end 59 | return ranks 60 | end 61 | 62 | if evolve then 63 | for internalName, rankInfo in pairs( evolve.ranks ) do 64 | table.insert( ranks, { internalName = internalName, title = rankInfo.Title } ) 65 | end 66 | return ranks 67 | end 68 | 69 | 70 | if serverguard then 71 | for internalName, rankInfo in pairs( serverguard.ranks.stored ) do 72 | table.insert( ranks, { internalName = internalName, title = rankInfo.name } ) 73 | end 74 | return ranks 75 | end 76 | 77 | if sam then 78 | for internalName, rankInfo in pairs(sam.ranks.get_ranks()) do 79 | table.insert( ranks, { internalName = internalName, title = internalName } ) 80 | end 81 | end 82 | 83 | return ranks 84 | end -------------------------------------------------------------------------------- /resource/fonts/segoeui.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ValentinFunk/LibK/62b006d3812a7873323ad1f144ee51034a7a7f51/resource/fonts/segoeui.ttf -------------------------------------------------------------------------------- /resource/fonts/segoeuil.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ValentinFunk/LibK/62b006d3812a7873323ad1f144ee51034a7a7f51/resource/fonts/segoeuil.ttf -------------------------------------------------------------------------------- /resource/fonts/segoeuisl.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ValentinFunk/LibK/62b006d3812a7873323ad1f144ee51034a7a7f51/resource/fonts/segoeuisl.ttf -------------------------------------------------------------------------------- /resource/fonts/seguisb.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ValentinFunk/LibK/62b006d3812a7873323ad1f144ee51034a7a7f51/resource/fonts/seguisb.ttf --------------------------------------------------------------------------------