Repository navigation
Expand file tree
/
Copy pathindicators.lua
More file actions
126 lines (112 loc) · 3.84 KB
/
Copy pathindicators.lua
File metadata and controls
126 lines (112 loc) · 3.84 KB
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
if not next(SMODS.find_mod("paperback")) then
local indicators = {
flags = {
{ key = "perma_mult", pos = { x = 0, y = 0 } },
{ key = "perma_x_mult", pos = { x = 1, y = 0 } },
{ key = "perma_bonus", pos = { x = 2, y = 0 } },
{ key = "perma_x_chips", pos = { x = 3, y = 0 } },
{ key = "perma_p_dollars", pos = { x = 4, y = 0 } },
{ key = "perma_paperback_plus_odds", pos = { x = 5, y = 0 } },
{ key = "perma_repetitions", pos = { x = 6, y = 0 } },
-- { key = "perma_balance", pos = { x = 7, y = 0 } },
{ key = "perma_score", pos = { x = 8, y = 0 } },
{ key = "perma_x_score", pos = { x = 9, y = 0 } },
{ key = "perma_blind_size", pos = { x = 10, y = 0 } },
{ key = "perma_x_blind_size", pos = { x = 11, y = 0 } },
},
pins = {
{ key = "perma_h_mult", pos = { x = 0, y = 1 } },
{ key = "perma_h_x_mult", pos = { x = 1, y = 1 } },
{ key = "perma_h_chips", pos = { x = 2, y = 1 } },
{ key = "perma_h_x_chips", pos = { x = 3, y = 1 } },
{ key = "perma_h_dollars", pos = { x = 4, y = 1 } },
{ key = "perma_paperback_h_plus_odds", pos = { x = 5, y = 1 } },
-- { key = "perma_h_repetitions", pos = { x = 6, y = 1 } },
-- { key = "perma_h_balance", pos = { x = 7, y = 1 } },
{ key = "perma_h_score", pos = { x = 8, y = 1 } },
{ key = "perma_h_x_score", pos = { x = 9, y = 1 } },
{ key = "perma_h_blind_size", pos = { x = 10, y = 1 } },
{ key = "perma_h_x_blind_size", pos = { x = 11, y = 1 } },
}
}
-- Registers the upgrade indicators atlas
SMODS.Atlas {
key = "indicators",
px = 71,
py = 95,
path = "Indicators.png",
inject = function(self)
SMODS.Atlas.inject(self)
for _, side in pairs(indicators) do
for _, v in ipairs(side) do
v.sprite = Sprite(0, 0, G.CARD_W, G.CARD_H, self, v.pos)
end
end
end
}
local FLAG_OFFSET_X = -8
local PIN_OFFSET_X = -1
local PIN_OFFSET_Y = 1
local HEIGHT = 7
local GAP = 1
local function should_draw_indicator(card, key)
return card and card.ability
and type(card.ability[key]) == "number"
and ((string.find(key, "blind_size") and card.ability[key] < 0) or (not string.find(key, "blind_size") and card.ability[key] > 0)) -- why
and card.area and card.area.config.type ~= 'deck'
and card.facing == 'front'
end
local function draw_single_indicator(card, sprite, x_offset, y_offset, shader)
x_offset = (card.T.w / 71) * (x_offset or 0) * card.T.scale
y_offset = (card.T.h / 95) * (y_offset or 0) * card.T.scale
sprite.role.draw_major = card
sprite:draw_shader(
(card.greyed and 'played') or shader or 'dissolve',
nil, nil, nil,
card.children.center,
nil, nil,
x_offset, y_offset
)
end
local function draw_indicators(indicators, card, x_offset, y_offset)
local y = GAP
for _, v in ipairs(indicators) do
if should_draw_indicator(card, v.key) then
draw_single_indicator(
card,
v.sprite,
x_offset,
y + (y_offset or 0),
string.find(v.key, "blind_size") and "indicators_blindcolor"
)
y = y + HEIGHT + GAP
end
end
end
SMODS.DrawStep {
key = "indicators_front",
order = 40,
func = function(card)
if card and card.ability then
draw_indicators(indicators.pins, card, PIN_OFFSET_X, PIN_OFFSET_Y)
end
end
}
SMODS.DrawStep {
key = "indicators_back",
order = -30,
func = function(card)
if card and card.ability then
draw_indicators(indicators.flags, card, FLAG_OFFSET_X)
end
end
}
-- shader for blindsize indicators
SMODS.Shader {
key = "blindcolor",
path = "blindcolor.fs",
send_vars = function(sprite, card)
return { blind_color = G.C.DYN_UI.DARK }
end
}
end