Skip to content

Commit

Permalink
Revert "Edition improvements, number formatting fixes, small performa…
Browse files Browse the repository at this point in the history
…nce fix and UI tab triangles fix"
  • Loading branch information
Aurelius7309 committed Aug 4, 2024
1 parent 49ec26e commit 51c90a8
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 258 deletions.
40 changes: 1 addition & 39 deletions core/overrides.lua
Original file line number Diff line number Diff line change
Expand Up @@ -846,29 +846,6 @@ G.FUNCS.your_collection_editions_page = function(args)
end
end

-- Init custom card parameters.
local card_init = Card.init
function Card:init(X, Y, W, H, card, center, params)
card_init(self, X, Y, W, H, card, center, params)

-- This table contains object keys for layers (e.g. edition)
-- that dont want base layer to be drawn.
-- When layer is removed, layer's value should be set to nil.
self.ignore_base_shader = self.ignore_base_shader or {}
-- This table contains object keys for layers (e.g. edition)
-- that dont want shadow to be drawn.
-- When layer is removed, layer's value should be set to nil.
self.ignore_shadow = self.ignore_shadow or {}
end

function Card:should_draw_base_shader()
return not next(self.ignore_base_shader or {})
end

function Card:should_draw_shadow()
return not next(self.ignore_shadow or {})
end

-- self = pass the card
-- edition =
-- nil (removes edition)
Expand All @@ -889,12 +866,6 @@ function Card:set_edition(edition, immediate, silent)
end
end

local old_edition = self.edition and self.edition.key
if old_edition then
self.ignore_base_shader[old_edition] = nil
self.ignore_shadow[old_edition] = nil
end

local edition_type = nil
if type(edition) == 'string' then
assert(string.sub(edition, 1, 2) == 'e_')
Expand Down Expand Up @@ -938,16 +909,7 @@ function Card:set_edition(edition, immediate, silent)
self.edition.type = edition_type
self.edition.key = 'e_' .. edition_type

local p_edition = G.P_CENTERS['e_' .. edition_type]

if p_edition.override_base_shader then
self.ignore_base_shader[self.edition.key] = true
end
if p_edition.no_shadow then
self.ignore_shadow[self.edition.key] = true
end

for k, v in pairs(p_edition.config) do
for k, v in pairs(G.P_CENTERS['e_' .. edition_type].config) do
if type(v) == 'table' then
self.edition[k] = copy_table(v)
else
Expand Down
29 changes: 2 additions & 27 deletions example_mods/Mods/EditionExamples/EditionExamples.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
--- MOD_NAME: Edition Examples
--- MOD_ID: EditionExamples
--- PREFIX: edex
--- MOD_AUTHOR: [Eremel_, stupxd]
--- MOD_AUTHOR: [Eremel_]
--- MOD_DESCRIPTION: Adds editions that demonstrate Edition API.
--- BADGE_COLOUR: 3FC7EB

Expand Down Expand Up @@ -316,7 +316,7 @@ SMODS.Back({
})

SMODS.Shader({key = 'anaglyphic', path = 'anaglyphic.fs'})
SMODS.Shader({key = 'flipped', path = 'flipped.fs'})
-- SMODS.Shader({key = 'flipped', path = 'flipped.fs'})
SMODS.Shader({key = 'fluorescent', path = 'fluorescent.fs'})
-- SMODS.Shader({key = 'gilded', path = 'gilded.fs'})
SMODS.Shader({key = 'greyscale', path = 'greyscale.fs'})
Expand All @@ -326,30 +326,6 @@ SMODS.Shader({key = 'greyscale', path = 'greyscale.fs'})
SMODS.Shader({key = 'overexposed', path = 'overexposed.fs'})
-- SMODS.Shader({key = 'sepia', path = 'sepia.fs'})

SMODS.Edition({
key = "flipped",
loc_txt = {
name = "Flipped",
label = "Flipped",
text = {
"nothin"
}
},
no_shadow = true, -- This will stop shadow from being rendered under the card
override_base_shader = true, -- This will stop extra layer being rendered below the shader. Necessary for edition that modify shape of a card.
shader = "flipped",
discovered = true,
unlocked = true,
config = { },
in_shop = true,
weight = 8,
extra_cost = 6,
apply_to_float = true,
loc_vars = function(self)
return { vars = { } }
end
})

SMODS.Edition({
key = "greyscale",
loc_txt = {
Expand All @@ -360,7 +336,6 @@ SMODS.Edition({
"and {X:mult,C:white}X#3#{} Mult"
}
},

shader = "greyscale",
discovered = true,
unlocked = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define PRECISION mediump
#endif

// Look ionized.fs for explanation
// Card rotation
extern PRECISION vec2 anaglyphic;

extern PRECISION number dissolve;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define PRECISION mediump
#endif

// Look ionized.fs for explanation
// Card rotation
extern PRECISION vec2 flipped;

extern PRECISION number dissolve;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define PRECISION mediump
#endif

// Look ionized.fs for explanation
// Card rotation
extern PRECISION vec2 fluorescent;

extern PRECISION number dissolve;
Expand Down
2 changes: 1 addition & 1 deletion example_mods/Mods/EditionExamples/assets/shaders/foil.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#endif


// Look ionized.fs for explanation
// Card rotation
extern MY_HIGHP_OR_MEDIUMP vec2 foil;
extern MY_HIGHP_OR_MEDIUMP number dissolve;
extern MY_HIGHP_OR_MEDIUMP number time;
Expand Down
2 changes: 1 addition & 1 deletion example_mods/Mods/EditionExamples/assets/shaders/gilded.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define PRECISION mediump
#endif

// Look ionized.fs for explanation
// Card rotation
extern PRECISION vec2 gilded;

extern PRECISION number dissolve;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define PRECISION mediump
#endif

// Look ionized.fs for explanation
// Card rotation
extern PRECISION vec2 greyscale;

extern PRECISION number dissolve;
Expand Down
8 changes: 3 additions & 5 deletions example_mods/Mods/EditionExamples/assets/shaders/ionized.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
#define PRECISION mediump
#endif

// !! change this variable name to your Shader's name
// change this variable name to your Edition's name
// YOU MUST USE THIS VARIABLE IN THE vec4 effect AT LEAST ONCE

// Values of this variable:
// self.ARGS.send_to_shader[1] = math.min(self.VT.r*3, 1) + (math.sin(G.TIMERS.REAL/28) + 1) + (self.juice and self.juice.r*20 or 0) + self.tilt_var.amt
// self.ARGS.send_to_shader[2] = G.TIMERS.REAL
// ^^ CRITICALLY IMPORTANT (IDK WHY) <- because compiler optimization
// Card rotation
extern PRECISION vec2 ionized;

extern PRECISION number dissolve;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define PRECISION mediump
#endif

// Look ionized.fs for explanation
// Card rotation
extern PRECISION vec2 laminated;

extern PRECISION number dissolve;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define PRECISION mediump
#endif

// Look ionized.fs for explanation
// Card rotation
extern PRECISION vec2 monochrome;

extern PRECISION number dissolve;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define PRECISION mediump
#endif

// Look ionized.fs for explanation
// Card rotation
extern PRECISION vec2 overexposed;

extern PRECISION number dissolve;
Expand Down
2 changes: 1 addition & 1 deletion example_mods/Mods/EditionExamples/assets/shaders/sepia.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define PRECISION mediump
#endif

// Look ionized.fs for explanation
// Card rotation
extern PRECISION vec2 sepia;

extern PRECISION number dissolve;
Expand Down
48 changes: 0 additions & 48 deletions lovely/edition.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,54 +78,6 @@ for _, v in ipairs(G.P_CENTER_POOLS.Edition) do
G.BADGE_COL[v.key:sub(3)] = v.badge_colour
end'''

# Limit ARGS.send_to_shader[1] to wiggle between 0 and 2 instead of growing infinitely
# this makes shaders responsiveness on tilt reliable over time
# Card:draw()
[[patches]]
[patches.regex]
target = "card.lua"
pattern = '''
G\.TIMERS\.REAL/\(28\)'''
position = "at"
payload = '''math.sin(G.TIMERS.REAL/28) + 1'''

# Allow editions to not draw shadow
# Card:draw()
[[patches]]
[patches.regex]
target = "card.lua"
pattern = '''
self\.ability\.effect ~= 'Glass Card' and not self\.greyed'''
position = "after"
payload = ''' and self:should_draw_shadow() '''

# If shader modifies shape of card, this will stop "back" layer of the card being rendered.
# Card:draw()
[[patches]]
[patches.pattern]
target = "card.lua"
pattern = '''
elseif not self.greyed then'''
position = "before"
payload = '''
elseif not self:should_draw_base_shader() then
-- Don't render base dissolve shader.
'''
match_indent = true

# If shader modifies shape of card, this will stop "back" layer of the card being rendered.
# spectral cards and booster packs only.
# Card:draw()
[[patches]]
[patches.pattern]
target = "card.lua"
pattern = '''
if self.ability.set == 'Booster' or self.ability.set == 'Spectral' then'''
position = "at"
payload = '''
if (self.ability.set == 'Booster' or self.ability.set == 'Spectral') and self:should_draw_base_shader() then'''
match_indent = true

# Inject shaders applying to cards
# Card:draw()
[[patches]]
Expand Down
80 changes: 21 additions & 59 deletions lovely/fixes.toml
Original file line number Diff line number Diff line change
Expand Up @@ -382,75 +382,37 @@ position = "after"
payload = "self.scale = self.config.scale_function and self.config.scale_function() or self.scale"
match_indent = true


#
# Fix gold stake legendary infloop
# Do not try to roll for jokers that are not in_pool
# Fix floating point error (1.000e92 instead of 10.000e91)
# Lower precision with higher numbers
#

# generate_starting_seed()
[[patches]]
## number_format
[[patches]]
[patches.pattern]
target = "functions/misc_functions.lua"
pattern = '''if win_ante and (win_ante >= 8) then'''
match_indent = true
position = "at"
payload = '''if win_ante and (win_ante >= 8) or (v.in_pool and type(v.in_pool) == 'function' and not v:in_pool()) then'''

#
# Fix G.GAME.blind:set_blind(nil, true, nil)
# being called when not in blind.
#

# Card:add_to_deck
# Card:remove_from_deck
[[patches]]
[patches.regex]
target = "card.lua"
pattern = 'if G\.GAME\.blind then'
pattern = '''
return string.format("%.3f",x/(10^fac))..'e'..fac'''
position = "at"
payload = "if G.GAME.blind and G.GAME.blind.in_blind then"

# Blind:set_blind
[[patches]]
[patches.pattern]
target = "blind.lua"
match_indent = true
pattern = "if not reset then"
position = "after"
payload = '''
if blind then
self.in_blind = true
end'''

# end_round()
[[patches]]
[patches.pattern]
target = "functions/state_events.lua"
pattern = "local game_over = true"
position = "before"
payload = "G.GAME.blind.in_blind = false"
local mantissa = round_number(x/(10^fac), 3)
if mantissa >= 10 then
mantissa = mantissa / 10
fac = fac + 1
end
return string.format(fac >= 100 and "%.1fe%i" or fac >= 10 and "%.2fe%i" or "%.3fe%i", mantissa, fac)'''
match_indent = true

#
# Fix gold stake legendary infloop
# Do not try to roll for jokers that are not in_pool
#


# Make sure new param is loaded
[[patches]]
[patches.pattern]
target = "blind.lua"
match_indent = true
pattern = "function Blind:load(blindTable)"
position = "after"
payload = '''
self.in_blind = blindTable.in_blind'''

# Make sure new param is saved
# generate_starting_seed()
[[patches]]
[patches.pattern]
target = "blind.lua"
target = "functions/misc_functions.lua"
pattern = '''if win_ante and (win_ante >= 8) then'''
match_indent = true
pattern = "local blindTable = {"
position = "after"
payload = '''
in_blind = self.in_blind,'''

position = "at"
payload = '''if win_ante and (win_ante >= 8) or (v.in_pool and type(v.in_pool) == 'function' and not v:in_pool()) then'''
Loading

0 comments on commit 51c90a8

Please sign in to comment.