Files
NazaraEngine/build/scripts/actions/encodesresources.lua
S6066 55ca4a84ea Added CheckboxWidget (#130)
* Started Checkbox Widget (buggy)

* Added features

* Added enabling feature

* Almost finished Checkbox

* Bugfix

* Bugfixes

* Use a better name

* Optimizations

* Added explicit colors

* ...

* changed lots of things

* Almost finished CheckboxWidget

* Almost almost finished

* Use better UTF8 box

* Edited encode resources script to encode SDK resources

* Finished checkbox widget

* Forgot to delete old function

* Forgot to delete todo comment

* Fix Travis compilation

* Fix Travis compilation a second time

* Fix Travis Compilation a third time

* Fix indentation

* Fix Files encoding

* Moved CheckboxState enum in (new) Enum.hpp

* Probably looks like more generated now

* Reorder CheckboxWidget members

* Reorder checkbox state members

* Reorder members 2...

* Oops

* Reorder members functions

* Fix encoding

* Fix files encoding

* Forgot to fix one file encoding

* Fix SDK Server

* Fix encoding again -_-

* Oops

* Optimize Checkbox Widget

* Fix .gitignore

* Removed .vs in gitignore

* Moved Enums into Widgets folder

* Bugfix

* Fix Encode Resources script

* Remove double line feeds

* Rename SetNextState to SwitchToNextState
2017-08-30 10:25:42 +02:00

50 lines
1.6 KiB
Lua

ACTION.Name = "EncodeResources"
ACTION.Description = "Generate a includable header version of resources"
ACTION.Function = function ()
print("Encoding resources ...")
local startClock = os.clock()
local modules = os.matchdirs("../src/Nazara/*")
table.insert(modules, "../SDK/src/NDK")
for k, modulePath in pairs(modules) do
local moduleName
if (modulePath:sub(4, 6) == "src") then
moduleName = modulePath:sub(15, -1)
else
moduleName = "SDK"
end
local files = os.matchfiles(modulePath .. "/Resources/**")
for k, filePath in pairs(files) do
if (filePath:sub(-2) ~= ".h") then
local file = filePath:sub(modulePath:len() + 12, -1)
local resource, err = io.open(filePath, "rb")
if (not resource) then
error("Failed to read resource file " .. file .. ": " .. err)
end
local resourceContent = resource:read("*a")
resource:close()
local contentLength = resourceContent:len()
local headerContentTable = {}
for i = 1, contentLength do
table.insert(headerContentTable, string.format("%d,", resourceContent:byte(i)))
end
local headerContent = table.concat(headerContentTable)
local header, err = io.open(filePath .. ".h", "w+")
if (not header) then
error("Failed to create header file for " .. file .. ": " .. err)
end
header:write(headerContent)
header:close()
print(string.format("%s: %s (raw: %.3g kB, header: %.3g kB)", moduleName, file, contentLength/1024, string.format("%.3g", headerContent:len()/1024)))
end
end
end
print("Finished (took " .. os.clock() - startClock .. "s)")
end