-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings.lua
151 lines (141 loc) · 4.71 KB
/
settings.lua
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
require("scripts.utils")
-- Settings order:
-- <mod_prefix><setting_group>[<order_override or prototype_type>][<name>]<setting_type>
function add_bool_setting(name, order_type, localised_name, localised_description)
data:extend({
{
name = config_name(name),
type = "bool-setting",
setting_type = "startup",
default_value = false,
order = order_prefix .. "b[" .. order_type .. "][" .. name .. "]b",
localised_name = localised_name or { "item-name." .. name },
localised_description = localised_description or { "colorblind_ultimate-description.custom-overlay" },
},
})
end
function add_option_setting(name, order_type, localised_name, options)
data:extend({
{
name = config_name(name),
type = "string-setting",
setting_type = "startup",
default_value = Options.none,
allowed_values = { Options.none, table.unpack(options) },
order = order_prefix .. "b[" .. order_type .. "][" .. name .. "]d",
localised_name = localised_name,
localised_description = { "colorblind_ultimate-description.custom-overlay-all" },
},
})
end
function add_color_setting(name, order_type, default, localised_name)
data:extend({
{
name = config_name(name .. "-color"),
type = "color-setting",
setting_type = "startup",
default_value = default,
order = order_prefix .. "a[" .. order_type .. "][" .. name .. "]",
localised_name = localised_name,
},
})
end
function add_map_color_setting(name, order_type, default, localised_name)
data:extend({
{
name = config_name(name .. "-map-color"),
type = "color-setting",
setting_type = "startup",
default_value = default,
order = order_prefix .. "c[" .. order_type .. "][" .. name .. "]",
localised_name = { "", localised_name or { "entity-name." .. name }, " ", { "colorblind_ultimate-word.on-map" } },
},
})
end
function settings_from_prototypes(prototypes)
for name, proto in pairs(prototypes) do
if not proto.config_from then
local allowed_values = {}
local is_entity = proto.is_entity or proto.sprite_replacement
local localised_name = proto.localised_name or { ((is_entity and "entity" or "item") .. "-name." .. name) }
if proto.icon_replacement then
add_bool_setting(
name .. "-icon-replacement",
proto.order or proto.type,
{ "", localised_name, ": ", { "colorblind_ultimate-description.icon-replacement" } },
{ "colorblind_ultimate-description.custom-icon" }
)
end
if proto.sprite_replacement then
add_bool_setting(
name .. "-sprite-replacement",
proto.order or proto.type,
{ "", localised_name, ": ", { "colorblind_ultimate-description.sprite-replacement" } },
{ "colorblind_ultimate-description.custom-sprite" }
)
end
if proto.icon_overlay or proto.icon_overlay_from then
if proto.icon_overlay and string.sub(proto.icon_overlay, 1, 5) == "tier-" then
table.insert(allowed_values, Options.tier)
else
table.insert(allowed_values, Options.icon_overlay)
end
end
if proto.text_overlay then
table.insert(allowed_values, Options.text_overlay)
end
if next(allowed_values) ~= nil then
add_option_setting(
name .. "-icon-overlay",
proto.order or proto.type,
{ "", localised_name, ": ", { "colorblind_ultimate-description.icon-overlay" } },
allowed_values
)
if is_entity then
add_option_setting(
name .. "-sprite-overlay",
proto.order or proto.type,
{ "", localised_name, ": ", { "colorblind_ultimate-description.sprite-overlay" } },
allowed_values
)
end
end
end
end
end
order_prefix = "ac"
require("data.core.settings")
for mod, mod_stages in pairs(Mods) do
if mods[mod] and mod_stages.settings then
order_prefix = mod_stages.order
require("data." .. mod .. ".settings")
end
end
data:extend({
{
name = config_name("scale"),
type = "double-setting",
setting_type = "startup",
default_value = 0.5,
minimum_value = 0.1,
maximum_value = 1.0,
order = "aa",
localised_name = { "", { "gui-blueprint.icon" }, " ", { "gui-map-generator.scale" } },
},
{
name = config_name("overlay-corner"),
type = "string-setting",
setting_type = "startup",
default_value = "upper-left",
allowed_values = keys(Offsets),
order = "ab",
},
{
name = config_name("secondary-overlay-corner"),
type = "string-setting",
setting_type = "startup",
default_value = "upper-right",
allowed_values = keys(Offsets),
order = "ab",
},
})