-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfo.lua2p
111 lines (91 loc) · 2.83 KB
/
info.lua2p
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
local Log = require("modules.log.log")
local Utils = require("utils")
local Info = {
data = {},
options = {},
}
local filename = $_LOG_INFO
local function insert_str(src, dest)
@@assert(type(src) == "table")
@@assert(type(dest) == "table")
for k, v in pairs(src) do
local str = string.format("\t%s: %s\n", k, v)
table.insert(dest, str)
end
end
function Info.init()
Log.info("System information checking...")
local data = Info.data
local system_limits = {}
local canvas_formats = {}
local image_formats = {}
local texture_types = {}
local supported = {}
local name, version, vendor, device = love.graphics.getRendererInfo()
data.renderer = {
name = name,
version = version,
vendor = vendor,
device = device
}
data.info_os = love.system.getOS()
data.processor_count = love.system.getProcessorCount()
data.game_version = $_GAME_VERSION
data.git_version = $_COMMIT_VERSION
data.limits = love.graphics.getSystemLimits()
data.canvasformats = love.graphics.getCanvasFormats()
data.imageformats = love.graphics.getImageFormats()
data.texturetypes = love.graphics.getTextureTypes()
data.supported = love.graphics.getSupported()
insert_str(data.limits, system_limits)
insert_str(data.canvasformats, canvas_formats)
insert_str(data.imageformats, image_formats)
insert_str(data.texturetypes, texture_types)
insert_str(data.supported, supported)
local str = {
string.format("Game Version: %s", data.game_version),
string.format("Git Commit Version: %s", data.git_version),
string.format("OS: %s", data.info_os),
string.format("Processor Count: %s", data.processor_count),
"Renderer Info:",
string.format("\tName: %s", data.renderer.name),
string.format("\tVersion: %s", data.renderer.version),
string.format("\tVendor: %s", data.renderer.vendor),
string.format("\tDevice: %s", data.renderer.device),
"System Limits:",
table.concat(system_limits),
"Canvas Formats:",
table.concat(canvas_formats),
"Image Formats:",
table.concat(image_formats),
"Texture Types:",
table.concat(texture_types),
"Supported:",
table.concat(supported),
"Other Info:",
string.format("Developer Mode: %s", !(_DEV)),
}
local to_write = table.concat(str, "\n")
local content, exists = Utils.file.read(filename)
if exists then
Info.validate_file(content, to_write)
else
Utils.file.write(filename, to_write)
love.filesystem.write("PLEASE_DO_NOT_EDIT_ANY_FILES",
"Editing any files in this directory will invalidate all your progress")
end
end
function Info.validate_file(content, to_write)
local same = Utils.hash.compare(content, to_write)
if same then
Log.info(filename, "untouched")
else
love.filesystem.write(filename, to_write)
Log.info(filename, "overwritten")
end
end
function Info.is_texturesize_compatible(size)
local max_size = Info.data.limits.texturesize
return size <= max_size
end
return Info