Skip to content

Commit

Permalink
Merge branch 'master' into ui-olympUI
Browse files Browse the repository at this point in the history
  • Loading branch information
Cruor committed Nov 4, 2023
2 parents 21e9771 + afcdde8 commit d060693
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 73 deletions.
10 changes: 10 additions & 0 deletions src/entities.lua
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@ function entities.getEntityDrawable(name, handler, room, entity, viewport)
end

return drawableSprites

else
-- No drawing defined for the entity, use fallback
-- Make sure the entity doesn't have color or any other special attributes
local position = {
x = entity.x,
y = entity.y
}

return entities.getDrawable(name, missingEntityHandler, room, position, viewport)
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/file_locations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function fileLocations.getStorageDir()
local linuxFolderName = fileLocations.loennLinuxFolderName

if userOS == "Windows" then
return filesystem.joinpath(utils.getenv("LocalAppData"), simpleFolderName)
return filesystem.joinpath(os.getenv("LocalAppData"), simpleFolderName)

elseif userOS == "Linux" then
local xdgConfig = os.getenv("XDG_CONFIG_HOME")
Expand Down
4 changes: 3 additions & 1 deletion src/snapshot_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ function snapshotUtils.multiSnapshot(description, snapshots)
end

local function backward(data)
for _, snap in ipairs(snapshots) do
for i = #snapshots, 1, -1 do
local snap = snapshots[i]

snap.backward(snap.data)
end
end
Expand Down
67 changes: 0 additions & 67 deletions src/utils/filesystem.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local lfs = require("lib.lfs_ffi")
local ffi = require("ffi")
local nfd = require("nfd")
local physfs = require("lib.physfs")
local requireUtils = require("utils.require")
Expand Down Expand Up @@ -479,70 +478,4 @@ function filesystem.unzip(zipPath, outputDir)
love.filesystem.unmount("temp")
end

if osUtils.getOS() ~= "Windows" then
local function identity(value)
return value
end

filesystem.codepageUtf8ToSys = identity
filesystem.codepageSysToUtf8 = identity

else
ffi.cdef[[
int MultiByteToWideChar(
unsigned int CodePage,
int dwFlags,
char* lpMultiByteStr,
int cbMultiByte,
wchar_t* lpWideCharStr,
int cchWideChar
);
int WideCharToMultiByte(
unsigned int CodePage,
int dwFlags,
wchar_t* lpWideCharStr,
int cchWideChar,
char* lpMultiByteStr,
int cbMultiByte,
char* lpDefaultChar,
bool* lpUsedDefaultChar
);
]]

local codepageSys = 0
local codepageUtf8 = 65001

local function convert(from, to, orig)
local length = #orig + 1
local valueC = ffi.new("char[?]", length)
ffi.copy(valueC, orig)
valueC[#orig] = 0

-- char from -> wchar_t
local size = ffi.C.MultiByteToWideChar(from, 0, valueC, length, nil, 0)
assert(size ~= 0)
local valueW = ffi.new("wchar_t[?]", size)
length = ffi.C.MultiByteToWideChar(from, 0, valueC, length, valueW, size)
assert(size == length)

-- wchar_t -> char to
length = ffi.C.WideCharToMultiByte(to, 0, valueW, size, nil, 0, nil, nil)
assert(length ~= 0)
valueC = ffi.new("char[?]", length + 1)
length = ffi.C.WideCharToMultiByte(to, 0, valueW, size, valueC, length, nil, nil)
assert(length == size)
valueC[length + 1] = 0

return ffi.string(valueC)
end

function filesystem.codepageUtf8ToSys(value)
return convert(codepageUtf8, codepageSys, value)
end

function filesystem.codepageSysToUtf8(value)
return convert(codepageSys, codepageUtf8, value)
end
end

return filesystem
4 changes: 0 additions & 4 deletions src/utils/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -842,10 +842,6 @@ for k, v <- filesystem do
utils[k] = v
end

function utils.getenv(key)
return filesystem.codepageSysToUtf8(os.getenv(key))
end

-- Add filesystem specific helper methods
local osFilename = utils.getOS():lower():gsub(" ", "_")
local hasOSHelper, osHelper = requireUtils.tryrequire("utils.system." .. osFilename)
Expand Down

0 comments on commit d060693

Please sign in to comment.