Compare commits

...

5 Commits
latest ... main

Author SHA1 Message Date
c70d05af54 sync with mobx version
All checks were successful
AutoRelease / release (push) Successful in 4m23s
2024-07-12 16:37:34 +07:00
e3b507b435 update action
All checks were successful
AutoRelease / release (push) Successful in 2m44s
2024-05-31 05:59:45 +07:00
fae6a5f97c modified: .github/workflows/autorelease.yml
Some checks failed
AutoRelease / release (push) Failing after 1m49s
2024-05-31 05:38:51 +07:00
b91f95d296 modified: .github/workflows/autorelease.yml
Some checks failed
AutoRelease / release (push) Failing after 3m8s
2024-05-31 05:32:48 +07:00
61cdbb3b7a update
Some checks failed
AutoRelease / release (push) Failing after 3m51s
2024-05-31 05:18:24 +07:00
5 changed files with 62 additions and 82 deletions

View File

@ -19,20 +19,19 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '18.x'
node-version: "18.x"
- name: Install dependencies NUI
working-directory: ./web
run: yarn install --frozen-lockfile
run: npm install --frozen-lockfile
- name: Build UI
working-directory: ./web
run: yarn build
run: npm run build
- name: Zip Folder
run: zip -r ${{ github.event.repository.name }}.zip config.lua fxmanifest.lua impl.lua main.lua README.md LICENSE web/build/* locales/* client/* server/*
- uses: 'marvinpinto/action-automatic-releases@latest'
- uses: "akkuman/gitea-release-action@v1"
with:
repo_token: '${{ secrets.GITHUB_TOKEN }}'
title: '${{ github.event.head_commit.message }}'
automatic_release_tag: 'latest'
name: "${{ github.event.head_commit.message }}"
tag_name: "latest"
prerelease: false
files: |
*.zip

View File

@ -1,3 +1,4 @@
---@class TestImpl : Impl
local Impl = NewImpl("Test")
function Impl:Init()
@ -15,4 +16,4 @@ end
function Impl:Add(amount, amount2)
self.testVar = self.testVar + amount + amount2
return self.testVar
end
end

View File

@ -41,42 +41,6 @@ function Class:extend(obj)
return self:new(...)
end
--[[ -- allow for getters and setters
mt.__index = function(table, key)
local val = rawget(table._, key)
--print(key, type(val))
if val and type(val) == "table" and (rawget(val, '__cfx_functionReference') == nil) and (val.get ~= nil or val.value ~= nil) then
if val.get then
if type(val.get) == "function" then
return val.get(table, val.value)
else
return val.get
end
elseif val.value then
return val.value
end
else
return val
end
end
mt.__newindex = function(table, key, value)
local val = rawget(table._, key)
if val and type(val) == "table" and (rawget(val, '__cfx_functionReference') == nil) and ((val.set ~= nil and val._ == nil) or val.value ~= nil) then
local v = value
if val.set then
if type(val.set) == "function" then
v = val.set(table, value, val.value)
else
v = val.set
end
end
val.value = v
if val and val.afterSet then val.afterSet(table, v) end
else
table._[key] = value
end
end ]]
setmetatable(obj, mt)
@ -304,13 +268,25 @@ end
---Create a new Implemented class
---@param name string
---@return Impl
function NewImpl(name)
function NewImpl(name, sync)
---@type Impl
local impl = Impl:extend({
name = name,
config = Config[name] or {},
implType = "impl"
implType = sync and "syncImpl" or "impl"
})
main:RegisterImpl(name, impl)
return impl
end
function NewSyncImpl(name)
local impl = Impl:extend({
name = name,
config = Config[name] or {},
implType = sync and "syncImpl" or "impl",
})
impl.start = function()
main.initializedImpls[name] = impl(main)
end
return impl
end

View File

@ -49,26 +49,29 @@ function Main:Init()
o:Thread1()
else
o.ClientImpls = {}
for k, v in pairs(Config.EnableModules) do
if v then
local path = "client/impl/" .. k .. ".impl.lua"
local source = LoadResourceFile(ResourceName, path)
if source == nil then
self:LogWarning("Failed to load %s", path)
else
--[[ self:LogInfo("Loading %s", path)
self:LogInfo("Loaded %s", source) ]]
o.ClientImpls[k] = source
if Config.ClientLazyLoad then
for k, v in pairs(Config.EnableModules) do
if v and v.client then
local path = "client/impl/" .. k .. ".impl.lua"
local source = LoadResourceFile(ResourceName, path)
if source == nil then
self:LogWarning("Failed to load %s", path)
else
--[[ self:LogInfo("Loading %s", path)
self:LogInfo("Loaded %s", source) ]]
o.ClientImpls[k] = source
end
end
end
lib.callback.register(ResourceName .. ":getClientImpl", function(source, implName)
return o.ClientImpls[implName]
end)
end
lib.callback.register(ResourceName .. ":getClientImpl", function(source, implName)
return o.ClientImpls[implName]
end)
end
o:Exports()
o:RegisterCommands()
o:RegisterEvents()
o:LogInfo("Main initialized")
return o
end
@ -164,21 +167,21 @@ function Main:RegisterEvents()
end
function Main:LogError(msg, ...)
print(("[^1ERROR^0] " .. msg):format(...))
print(("[^1ERROR^0] " .. ("[%s] "):format(GetGameTimer()) .. msg):format(...))
end
function Main:LogWarning(msg, ...)
print(("[^3WARNING^0] " .. msg):format(...))
print(("[^3WARNING^0] " .. ("[%s] "):format(GetGameTimer()) .. msg):format(...))
end
function Main:LogSuccess(msg, ...)
if not Config.Debug then return end
print(("[^2INFO^0] " .. msg):format(...))
print(("[^2INFO^0] " .. ("[%s] "):format(GetGameTimer()) .. msg):format(...))
end
function Main:LogInfo(msg, ...)
if not Config.Debug then return end
print(("[^5INFO^0] " .. msg):format(...))
print(("[^5INFO^0] " .. ("[%s] "):format(GetGameTimer()) .. msg):format(...))
end
function Main:CheckValidImpl(name, impl)
@ -194,6 +197,9 @@ function Main:CheckValidImpl(name, impl)
end
function Main:RegisterImpl(name, impl)
if impl.implType == "syncImpl" then
return
end
if impl.implType == "impl" and (Config.EnableModules[name] == nil or not Config.EnableModules[name].enabled) then
self:LogWarning("Impl %s not enabled", name)
return
@ -357,6 +363,16 @@ function Main:Exports()
end)
end
function Main:ToggleUI(state)
self.showUI = state
if Config.Nui then
SendNUIMessage({
event = "main:setShow",
data = state
})
end
end
main = Main:Init()
AddEventHandler(("%s:onReady"):format(GetCurrentResourceName()), function(handler)
local invokingResource = GetInvokingResource()
@ -364,25 +380,7 @@ AddEventHandler(("%s:onReady"):format(GetCurrentResourceName()), function(handle
main:ListenOnReady(handler)
end)
--[[ local origAddEventHandler = AddEventHandler
function AddEventHandler(eventName, ...)
if RegisteredEvents[eventName] then
main:LogWarning("Event %s already registered. Removing", eventName)
RemoveEventHandler(RegisteredEvents[eventName])
end
RegisteredEvents[eventName] = origAddEventHandler(eventName, ...)
return RegisteredEvents[eventName]
end
local origRegisterNetEvent = RegisterNetEvent
function RegisterNetEvent(eventName, ...)
if RegisteredEvents[eventName] then
main:LogWarning("Event %s already registered. Removing", eventName)
RemoveEventHandler(RegisteredEvents[eventName])
end
RegisteredEvents[eventName] = origRegisterNetEvent(eventName, ...)
return RegisteredEvents[eventName]
end ]]
Citizen.CreateThread(function()
while GetGameTimer() < main.lastTimeImplRegistered + 1000 do
@ -417,6 +415,11 @@ Citizen.CreateThread(function()
Wait(100)
player = Framework.Functions.GetPlayerData()
end
elseif Config.Framework == 'ProjectStarboy' then
while not CORE.PlayerData.loaded do
Wait(100)
main:LogInfo("Waiting for player loaded")
end
end
while not NuiReady and Config.Nui do
Wait(100)

View File

@ -1,5 +1,6 @@
---@class TestImpl : Impl
local Impl = NewImpl("Test")
function Impl:OnReady()
main:LogInfo("%s ready", self:GetName())
end
end