Skip to content

Commit

Permalink
Better mod UI; perf: no_blueprint on check_enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurelius7309 committed Dec 29, 2024
1 parent 4a9dece commit c88333b
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 42 deletions.
Binary file modified assets/1x/mod_tags.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/2x/mod_tags.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion lovely/center.toml
Original file line number Diff line number Diff line change
Expand Up @@ -503,4 +503,13 @@ local seal = G.P_SEALS[self.seal or {}] or {}
if type(seal.draw) == 'function' then
seal:draw(self, layer)
elseif self.seal then
'''
'''

# no_blueprint check
[[patches]]
[patches.pattern]
target = 'card.lua'
match_indent = true
position = 'at'
pattern = 'if other_joker and other_joker ~= self then'
payload = 'if other_joker and other_joker ~= self and not context.no_blueprint then'
4 changes: 2 additions & 2 deletions src/game_object.lua
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,9 @@ Set `prefix_config.key = false` on your object instead.]]):format(obj.key), obj.
'assets/sounds/' .. file_path
if prev_path == self.full_path then return end
self.data = NFS.read('data', self.full_path)
self.decoder = love.sound.newDecoder(self.data)
--self.decoder = love.sound.newDecoder(self.data)
self.should_stream = string.find(self.key, 'music') or string.find(self.key, 'stream') or string.find(self.key, 'ambient')
self.sound = love.audio.newSource(self.decoder, self.should_stream and 'stream' or 'static')
--self.sound = love.audio.newSource(self.decoder, self.should_stream and 'stream' or 'static')
if prev_path then G.SOUND_MANAGER.channel:push({ type = 'stop' }) end
G.SOUND_MANAGER.channel:push({ type = 'sound_source', sound_code = self.sound_code, data = self.data, should_stream = self.should_stream, per = self.pitch, vol = self.volume })
end,
Expand Down
4 changes: 2 additions & 2 deletions src/loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -626,10 +626,10 @@ end

local function initializeModUIFunctions()
for id, modInfo in pairs(SMODS.mod_list) do
G.FUNCS["openModUI_" .. modInfo.id] = function(arg_736_0)
G.FUNCS["openModUI_" .. modInfo.id] = function(e)
G.ACTIVE_MOD_UI = modInfo
G.FUNCS.overlay_menu({
definition = create_UIBox_mods(arg_736_0)
definition = create_UIBox_mods(e)
})
end
end
Expand Down
54 changes: 20 additions & 34 deletions src/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -868,16 +868,24 @@ local function createClickableModBox(modInfo, scale)
config.colour = mix_colours(invert(col), G.C.UI.TEXT_INACTIVE, 0.8)
config.scale = scale * .8
end
if modInfo.version ~= '0.0.0' then
if modInfo.version and modInfo.version ~= '0.0.0' then
table.insert(but.nodes[1].nodes[1].nodes, {
n = G.UIT.T,
config = {
text = ('(%s)'):format(modInfo.version),
text = ('(%s) '):format(modInfo.version),
scale = scale*0.8,
colour = mix_colours(invert(col), G.C.UI.TEXT_INACTIVE, 0.8),
shadow = true,
},
})
end
if modInfo.config_tab then
table.insert(but.nodes[1].nodes[1].nodes, {
n = G.UIT.O,
config = {
object = Sprite(0,0,0.4,0.4, G.ASSET_ATLAS['mod_tags'], {x=2,y=0})
}
})
end
return {
n = G.UIT.R,
Expand Down Expand Up @@ -923,11 +931,7 @@ local function createClickableModBox(modInfo, scale)
end

function G.FUNCS.openModsDirectory(options)
if not love.filesystem.exists("Mods") then
love.filesystem.createDirectory("Mods")
end

love.system.openURL("file://"..love.filesystem.getSaveDirectory().."/Mods")
love.system.openURL(SMODS.MODS_DIR)
end

function G.FUNCS.mods_buttons_page(options)
Expand Down Expand Up @@ -1513,15 +1517,15 @@ function SMODS.GUI.staticModListContent()
align = "cm"
},
nodes = {
{
n = G.UIT.T,
config = {
text = localize('b_mod_list'),
shadow = true,
scale = scale * 0.6,
colour = G.C.UI.TEXT_LIGHT
}
}
UIBox_button({
label = { localize('b_mod_list') },
shadow = true,
scale = scale*0.85,
colour = G.C.BOOSTER,
button = "openModsDirectory",
minh = scale,
minw = 9
}),
}
},

Expand Down Expand Up @@ -1608,24 +1612,6 @@ function SMODS.GUI.dynamicModListContent(page)
}
}
})
table.insert(modNodes, {
n = G.UIT.R,
config = {
padding = 0,
align = "cm",
},
nodes = {
UIBox_button({
label = { localize('b_open_mods_dir') },
shadow = true,
scale = scale,
colour = G.C.BOOSTER,
button = "openModsDirectory",
minh = 0.8,
minw = 8
})
}
})
else
local modCount = 0
local id = 0
Expand Down
14 changes: 12 additions & 2 deletions src/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ function SMODS.get_enhancements(card, extra_only)
end
if G.jokers and G.jokers.cards then
for i=1, #G.jokers.cards do
local eval = G.jokers.cards[i]:calculate_joker({other_card = card, check_enhancement = true})
local eval = G.jokers.cards[i]:calculate_joker({other_card = card, check_enhancement = true, no_blueprint = true })
if eval then
for k, _ in pairs(eval) do
if G.P_CENTERS[k] then
Expand All @@ -837,7 +837,7 @@ function SMODS.has_enhancement(card, key)
if card.config.center.key == key then return true end
if G.jokers and G.jokers.cards then
for i=1, #G.jokers.cards do
local eval = G.jokers.cards[i]:calculate_joker({other_card = card, check_enhancement = true})
local eval = G.jokers.cards[i]:calculate_joker({other_card = card, check_enhancement = true, no_blueprint = true })
if eval and type(eval) == 'table' and eval[key] then return true end
end
end
Expand Down Expand Up @@ -892,3 +892,13 @@ SMODS.find_mod = function(id)
end
return ret
end

-- this is for debugging
SMODS.debug_calculation = function()
G.contexts = {}
local cj = Card.calculate_joker
function Card:calculate_joker(context)
for k,v in pairs(context) do G.contexts[k] = (G.contexts[k] or 0) + 1 end
return cj(self, context)
end
end
2 changes: 1 addition & 1 deletion version.lua
Original file line number Diff line number Diff line change
@@ -1 +1 @@
return "1.0.0~ALPHA-1229a-STEAMODDED"
return "1.0.0~ALPHA-1229b-STEAMODDED"

0 comments on commit c88333b

Please sign in to comment.