Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge "113-improve-and-clean-codebase" into develop #114

Merged
merged 29 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c782ef5
rename file_util to FileUtils to follow the naming pattern
ofoxsmith Feb 23, 2023
7e1bf60
rename util.lua to Utils.lua
ofoxsmith Feb 23, 2023
19c5cfa
refactor the noita component scripts
ofoxsmith Feb 24, 2023
3b62e7d
cleanup init files
ofoxsmith Mar 1, 2023
6f86a9e
ensure consistent naming of extension files
ofoxsmith Mar 1, 2023
e0e194d
rename test files
ofoxsmith Mar 1, 2023
1a29098
clean Ui file
ofoxsmith Mar 1, 2023
de45a6a
fix custom profiler using old fileutils path
ofoxsmith Mar 1, 2023
77c89ba
fix failing tests
ofoxsmith Mar 2, 2023
d9ed7f1
#113 Added some logging.
Ismoh Mar 5, 2023
d8fd5a3
Updated version to v4.1.0-alpha+1184 in https://github.com/Ismoh/Noit…
actions-user Mar 5, 2023
54fed47
Updated version to v4.1.0-alpha+1195 in https://github.com/Ismoh/Noit…
actions-user Mar 5, 2023
9b3b3ae
Updated CHANGELOG.md in https://github.com/Ismoh/NoitaMP/pull/114
actions-user Mar 5, 2023
f1a0539
Merge branch 'develop' into 113-improve-and-clean-codebase
Ismoh Mar 5, 2023
b431b5f
remove line causing test env to fail
ofoxsmith Mar 7, 2023
b852ff2
Merge branch '113-improve-and-clean-codebase' of https://github.com/I…
ofoxsmith Mar 7, 2023
954d010
#113 Fixed os detections.
Ismoh Mar 8, 2023
45cbb1e
#113 Manually fixed version, because of workflow issue some days ago.
Ismoh Mar 8, 2023
92dd211
Change way that the test files are run
ofoxsmith Mar 8, 2023
e0320eb
Delete init_logger_test.lua
Ismoh Mar 8, 2023
2a3e48c
Update unitTestRunner.lua
Ismoh Mar 8, 2023
02f9a58
remove output.txt
ofoxsmith Mar 9, 2023
6b5173f
Merge branch '113-improve-and-clean-codebase' of https://github.com/I…
ofoxsmith Mar 9, 2023
1442e79
remove unneeded luaunit call
ofoxsmith Mar 9, 2023
ff6bbb4
remove mocking and require calls from each test file that should be m…
ofoxsmith Mar 9, 2023
d1d4f94
#113 Fixed ffiExtensions issue where it was loaded more than once. Ad…
Ismoh Mar 9, 2023
0668d2c
#113 Fixed recursive unitTestRunner execution.
Ismoh Mar 9, 2023
2220044
#113 Removed unnecessary lfs_ffi again. Removed hack, for not loading…
Ismoh Mar 9, 2023
19a047b
#113 Fixed Logger.
Ismoh Mar 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"Lua.diagnostics.disable": [
"lowercase-global",
"undefined-field"
"deprecated"
],
"files.associations": {
"stdbool.h": "c",
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## [v4.1.0-alpha+1195](https://github.com/Ismoh/NoitaMP/tree/v4.1.0-alpha+1195) (05.03.2023)

[Full Changelog](https://github.com/Ismoh/NoitaMP/compare/v4.1.0-alpha+1184...v4.1.0-alpha+1195)

## [v4.1.0-alpha+1184](https://github.com/Ismoh/NoitaMP/tree/v4.1.0-alpha+1184) (05.03.2023)

[Full Changelog](https://github.com/Ismoh/NoitaMP/compare/v4.0.1-alpha+792...v4.1.0-alpha+1184)

**Implemented enhancements:**

- Developer want to sync children and components [\#107](https://github.com/Ismoh/NoitaMP/issues/107) [[enhancement](https://github.com/Ismoh/NoitaMP/labels/enhancement)]

**Closed issues:**

- Update CHANGELOG.md [\#112](https://github.com/Ismoh/NoitaMP/issues/112) [[documentation](https://github.com/Ismoh/NoitaMP/labels/documentation)] [[github_actions](https://github.com/Ismoh/NoitaMP/labels/github_actions)]

## [v4.0.1-alpha+792](https://github.com/Ismoh/NoitaMP/tree/v4.0.1-alpha+792) (17.02.2023)

[Full Changelog](https://github.com/Ismoh/NoitaMP/compare/v4.0.0-alpha+1302...v4.0.1-alpha+792)
Expand Down
2 changes: 1 addition & 1 deletion mods/noita-mp/.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"v4.0.1-alpha+792"}
{"version":"v4.0.1-alpha+1195"}
14 changes: 7 additions & 7 deletions mods/noita-mp/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ local NoitaApiModSettingGet = ModSettingGet
local NoitaApiModSettingSetNextValue = ModSettingSetNextValue
local NoitaApiModSettingGetNextValue = ModSettingGetNextValue

if not util then
if not Utils then
if require then
util = require("util")
Utils = require("Utils")
else
-- when NoitaComponents with their own restricted LuaContext load this file,
-- util isn't available!
util = dofile_once("mods/noita-mp/files/scripts/util/util.lua")
Utils = dofile_once("mods/noita-mp/files/scripts/util/Utils.lua")
if not MinaUtils and not require then
MinaUtils = dofile_once("mods/noita-mp/files/scripts/util/MinaUtils.lua")
end
Expand All @@ -74,7 +74,7 @@ end
ModSettingGet = function(id)
if id == "noita-mp.name" then
local name = MinaUtils.getLocalMinaName()
if not util.IsEmpty(name) then
if not Utils.IsEmpty(name) then
return name
else
name = NoitaApiModSettingGet(id)
Expand All @@ -84,7 +84,7 @@ ModSettingGet = function(id)
end
if id == "noita-mp.guid" then
local guid = MinaUtils.getLocalMinaGuid()
if not util.IsEmpty(guid) then
if not Utils.IsEmpty(guid) then
return guid
else
guid = NoitaApiModSettingGet(id)
Expand All @@ -108,13 +108,13 @@ end
ModSettingGetNextValue = function(id)
if id == "noita-mp.name" and name then
local name = MinaUtils.getLocalMinaName()
if not util.IsEmpty(name) then
if not Utils.IsEmpty(name) then
return name
end
end
if id == "noita-mp.guid" and guid then
local guid = MinaUtils.getLocalMinaGuid()
if not util.IsEmpty(guid) then
if not Utils.IsEmpty(guid) then
return guid
end
end
Expand Down
24 changes: 12 additions & 12 deletions mods/noita-mp/files/scripts/NoitaMpSettings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
------------------------------------------------------------------------------------------------------------------------
--- 'Imports'
------------------------------------------------------------------------------------------------------------------------
local fu = require("file_util")
local fu = require("FileUtils")
local lfs = require("lfs")
local winapi = require("winapi")
local json = require("json")
local util = require("util")
local Utils = require("Utils")

------------------------------------------------------------------------------------------------------------------------
--- NoitaMpSettings
Expand All @@ -23,9 +23,9 @@ NoitaMpSettings = {}

function NoitaMpSettings.clearAndCreateSettings()
local cpc = CustomProfiler.start("NoitaMpSettings.clearAndCreateSettings")
local settingsDir = fu.getAbsolutePathOfNoitaMpSettingsDirectory()
if fu.exists(settingsDir) then
fu.removeContentOfDirectory(settingsDir)
local settingsDir = fu.GetAbsolutePathOfNoitaMpSettingsDirectory()
if fu.Exists(settingsDir) then
fu.RemoveContentOfDirectory(settingsDir)
Logger.info(Logger.channels.initialize, ("Removed old settings in '%s'!"):format(settingsDir))
else
lfs.mkdir(settingsDir)
Expand All @@ -36,11 +36,11 @@ end

function NoitaMpSettings.writeSettings(key, value)
local cpc = CustomProfiler.start("NoitaMpSettings.writeSettings")
if util.IsEmpty(key) or type(key) ~= "string" then
if Utils.IsEmpty(key) or type(key) ~= "string" then
error(("'key' must not be nil or is not type of string!"):format(key), 2)
end

if util.IsEmpty(value) or type(value) ~= "string" then
if Utils.IsEmpty(value) or type(value) ~= "string" then
error(("'value' must not be nil or is not type of string!"):format(value), 2)
end

Expand All @@ -51,9 +51,9 @@ function NoitaMpSettings.writeSettings(key, value)
who = whoAmI()
end
local settingsFile = ("%s%s%s%s.json")
:format(fu.getAbsolutePathOfNoitaMpSettingsDirectory(), pathSeparator, pid, who)
:format(fu.GetAbsolutePathOfNoitaMpSettingsDirectory(), pathSeparator, pid, who)

if not fu.exists(settingsFile) then
if not fu.Exists(settingsFile) then
fu.WriteFile(settingsFile, "{}")
end

Expand All @@ -75,16 +75,16 @@ function NoitaMpSettings.getSetting(key)
local pid = winapi.get_current_pid()

local settingsFile = ("%s%s%s%s.json")
:format(fu.getAbsolutePathOfNoitaMpSettingsDirectory(), pathSeparator, pid, whoAmI())
:format(fu.GetAbsolutePathOfNoitaMpSettingsDirectory(), pathSeparator, pid, whoAmI())

if not fu.exists(settingsFile) then
if not fu.Exists(settingsFile) then
fu.WriteFile(settingsFile, "{}")
end

local contentString = fu.ReadFile(settingsFile)
local contentJson = json.decode(contentString)

if util.IsEmpty(contentJson[key]) then
if Utils.IsEmpty(contentJson[key]) then
error(("Unable to find '%s' in NoitaMpSettings: %s"):format(key, contentString), 2)
end
local value = contentJson[key]
Expand Down
44 changes: 20 additions & 24 deletions mods/noita-mp/files/scripts/Ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
----------------------------------------
-- 'Imports'
----------------------------------------
local renderEzgui = dofile_once("mods/noita-mp/lua_modules/share/lua/5.1/ezgui/EZGUI.lua").init("mods/noita-mp/lua_modules/share/lua/5.1/ezgui")
local fu = require("file_util")
local renderEzgui = dofile_once("mods/noita-mp/lua_modules/share/lua/5.1/ezgui/EZGUI.lua").init(
"mods/noita-mp/lua_modules/share/lua/5.1/ezgui")
local fu = require("FileUtils")

----------------------------------------------------------------------------------------------------
--- Ui
--- @see PlayerList.xml
--- @see FoldingMenu.xml
----------------------------------------------------------------------------------------------------
Ui = {}
Ui = {}

----------------------------------------
-- Global private variables:
Expand Down Expand Up @@ -50,7 +51,7 @@ end
--- Ui constructor
----------------------------------------------------------------------------------------------------
function Ui.new()
local self = {}
local self = {}

------------------------------------
-- Private variables:
Expand Down Expand Up @@ -87,31 +88,31 @@ function Ui.new()
cellWidth = 50,
},
methods = {
toggleAddress = function()
toggleAddress = function()
showAddress = not showAddress
end,
copyAddress = function()
util.copyToClipboard(("%s:%s"):format(_G.Server:getAddress(), _G.Server:getPort()))
copyAddress = function()
Utils.copyToClipboard(("%s:%s"):format(_G.Server:getAddress(), _G.Server:getPort()))
end,
kick = function(data, element, arg1)
kick = function(data, element, arg1)
_G.Server.kick(arg1)
end,
ban = function(data, element, arg1)
ban = function(data, element, arg1)
_G.Server.ban(arg1)
end,
start = function()
start = function()
_G.Server.start(nil, nil)
end,
stop = function()
stop = function()
_G.Server.stop()
end,
connect = function()
connect = function()
_G.Client.connect()
end,
disconnect = function()
disconnect = function()
_G.Client.disconnect()
end,
toggleDebug = function()
toggleDebug = function()
debug = not debug
end,
reportCustomProfiler = function()
Expand Down Expand Up @@ -150,12 +151,12 @@ function Ui.new()
local text = ""
if foldingOpen then
self.ezguiFoldingData.data.text = ("[- NoitaMP] %s eCache:%s pCache:%s nCache:%s %s")
:format(fu.getVersionByFile(), EntityCache.size(), CustomProfiler.getSize(),
NetworkUtils.getClientOrServer().getAckCacheSize(), GameGetFrameNum())
:format(fu.GetVersionByFile(), EntityCache.size(), CustomProfiler.getSize(),
NetworkUtils.getClientOrServer().getAckCacheSize(), GameGetFrameNum())
else
self.ezguiFoldingData.data.text = ("[+ NoitaMP] eCache:%s pCache:%s nCache:%s %s")
:format(EntityCache.size(), CustomProfiler.getSize(),
NetworkUtils.getClientOrServer().getAckCacheSize(), GameGetFrameNum())
:format(EntityCache.size(), CustomProfiler.getSize(),
NetworkUtils.getClientOrServer().getAckCacheSize(), GameGetFrameNum())
end

renderEzgui(0, height - 10, "mods/noita-mp/files/data/ezgui/FoldingMenu.xml", self.ezguiFoldingData)
Expand All @@ -181,9 +182,6 @@ function Ui.new()
})
table.insertAllButNotDuplicates(player, _G.Server.clients)
for i = 2, #player do
--player[i].name = string.ExtendOrCutStringToLength(player[i].name, 12, ".", true)
--player[i].health = { current = i, max = 2 }
--player[i].transform = { x = 123, y = 12334 }
player[i].rtt = player[i]:getRoundTripTime()
end
else
Expand Down Expand Up @@ -271,7 +269,7 @@ function Ui.new()
if clicked then
missingModGuiDismissed = true
Client:send(NetworkUtils.events.needModContent.name,
{ NetworkUtils.getNextNetworkMessageId(), Client.missingMods })
{ NetworkUtils.getNextNetworkMessageId(), Client.missingMods })
end
if hovered then
missingModGuiButton1Hovered = true
Expand Down Expand Up @@ -318,7 +316,6 @@ function Ui.new()
GuiZSetForNextWidget(gui, 110)
GuiImageNinePiece(gui, npID, 73, 73, w + 3, y - 71)
end

end

------------------------------------
Expand All @@ -328,7 +325,6 @@ function Ui.new()
drawFolding()
drawMenu()
drawModConflictWarning()

if EntityCache.size() >= EntityUtils.maxPoolSize then
gui = gui or GuiCreate()
GuiStartFrame(gui)
Expand Down
Loading