diff --git a/core/overrides.lua b/core/overrides.lua index 990abe2e..46ef6854 100644 --- a/core/overrides.lua +++ b/core/overrides.lua @@ -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) @@ -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_') @@ -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 diff --git a/example_mods/Mods/EditionExamples/EditionExamples.lua b/example_mods/Mods/EditionExamples/EditionExamples.lua index 5133b644..908ab2f7 100644 --- a/example_mods/Mods/EditionExamples/EditionExamples.lua +++ b/example_mods/Mods/EditionExamples/EditionExamples.lua @@ -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 @@ -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'}) @@ -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 = { @@ -360,7 +336,6 @@ SMODS.Edition({ "and {X:mult,C:white}X#3#{} Mult" } }, - shader = "greyscale", discovered = true, unlocked = true, diff --git a/example_mods/Mods/EditionExamples/assets/shaders/anaglyphic.fs b/example_mods/Mods/EditionExamples/assets/shaders/anaglyphic.fs index 3d2dda50..2738964b 100644 --- a/example_mods/Mods/EditionExamples/assets/shaders/anaglyphic.fs +++ b/example_mods/Mods/EditionExamples/assets/shaders/anaglyphic.fs @@ -4,7 +4,7 @@ #define PRECISION mediump #endif -// Look ionized.fs for explanation +// Card rotation extern PRECISION vec2 anaglyphic; extern PRECISION number dissolve; diff --git a/example_mods/Mods/EditionExamples/assets/shaders/flipped.fs b/example_mods/Mods/EditionExamples/assets/shaders/flipped.fs index e26b72f3..63dc5382 100644 --- a/example_mods/Mods/EditionExamples/assets/shaders/flipped.fs +++ b/example_mods/Mods/EditionExamples/assets/shaders/flipped.fs @@ -4,7 +4,7 @@ #define PRECISION mediump #endif -// Look ionized.fs for explanation +// Card rotation extern PRECISION vec2 flipped; extern PRECISION number dissolve; diff --git a/example_mods/Mods/EditionExamples/assets/shaders/fluorescent.fs b/example_mods/Mods/EditionExamples/assets/shaders/fluorescent.fs index e785cebc..89687ce1 100644 --- a/example_mods/Mods/EditionExamples/assets/shaders/fluorescent.fs +++ b/example_mods/Mods/EditionExamples/assets/shaders/fluorescent.fs @@ -4,7 +4,7 @@ #define PRECISION mediump #endif -// Look ionized.fs for explanation +// Card rotation extern PRECISION vec2 fluorescent; extern PRECISION number dissolve; diff --git a/example_mods/Mods/EditionExamples/assets/shaders/foil.fs b/example_mods/Mods/EditionExamples/assets/shaders/foil.fs index 3f2cc487..2935a750 100644 --- a/example_mods/Mods/EditionExamples/assets/shaders/foil.fs +++ b/example_mods/Mods/EditionExamples/assets/shaders/foil.fs @@ -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; diff --git a/example_mods/Mods/EditionExamples/assets/shaders/gilded.fs b/example_mods/Mods/EditionExamples/assets/shaders/gilded.fs index 3dd6e4bc..5a02c4d7 100644 --- a/example_mods/Mods/EditionExamples/assets/shaders/gilded.fs +++ b/example_mods/Mods/EditionExamples/assets/shaders/gilded.fs @@ -4,7 +4,7 @@ #define PRECISION mediump #endif -// Look ionized.fs for explanation +// Card rotation extern PRECISION vec2 gilded; extern PRECISION number dissolve; diff --git a/example_mods/Mods/EditionExamples/assets/shaders/greyscale.fs b/example_mods/Mods/EditionExamples/assets/shaders/greyscale.fs index b99bf268..5135aa2f 100644 --- a/example_mods/Mods/EditionExamples/assets/shaders/greyscale.fs +++ b/example_mods/Mods/EditionExamples/assets/shaders/greyscale.fs @@ -4,7 +4,7 @@ #define PRECISION mediump #endif -// Look ionized.fs for explanation +// Card rotation extern PRECISION vec2 greyscale; extern PRECISION number dissolve; diff --git a/example_mods/Mods/EditionExamples/assets/shaders/ionized.fs b/example_mods/Mods/EditionExamples/assets/shaders/ionized.fs index 10958599..cc1e71a8 100644 --- a/example_mods/Mods/EditionExamples/assets/shaders/ionized.fs +++ b/example_mods/Mods/EditionExamples/assets/shaders/ionized.fs @@ -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; diff --git a/example_mods/Mods/EditionExamples/assets/shaders/laminated.fs b/example_mods/Mods/EditionExamples/assets/shaders/laminated.fs index 1e24f798..9d5576d5 100644 --- a/example_mods/Mods/EditionExamples/assets/shaders/laminated.fs +++ b/example_mods/Mods/EditionExamples/assets/shaders/laminated.fs @@ -4,7 +4,7 @@ #define PRECISION mediump #endif -// Look ionized.fs for explanation +// Card rotation extern PRECISION vec2 laminated; extern PRECISION number dissolve; diff --git a/example_mods/Mods/EditionExamples/assets/shaders/monochrome.fs b/example_mods/Mods/EditionExamples/assets/shaders/monochrome.fs index 6e90ab75..e25b31f2 100644 --- a/example_mods/Mods/EditionExamples/assets/shaders/monochrome.fs +++ b/example_mods/Mods/EditionExamples/assets/shaders/monochrome.fs @@ -4,7 +4,7 @@ #define PRECISION mediump #endif -// Look ionized.fs for explanation +// Card rotation extern PRECISION vec2 monochrome; extern PRECISION number dissolve; diff --git a/example_mods/Mods/EditionExamples/assets/shaders/overexposed.fs b/example_mods/Mods/EditionExamples/assets/shaders/overexposed.fs index 4f24124c..ddf097de 100644 --- a/example_mods/Mods/EditionExamples/assets/shaders/overexposed.fs +++ b/example_mods/Mods/EditionExamples/assets/shaders/overexposed.fs @@ -4,7 +4,7 @@ #define PRECISION mediump #endif -// Look ionized.fs for explanation +// Card rotation extern PRECISION vec2 overexposed; extern PRECISION number dissolve; diff --git a/example_mods/Mods/EditionExamples/assets/shaders/sepia.fs b/example_mods/Mods/EditionExamples/assets/shaders/sepia.fs index dc13329e..4715bb0a 100644 --- a/example_mods/Mods/EditionExamples/assets/shaders/sepia.fs +++ b/example_mods/Mods/EditionExamples/assets/shaders/sepia.fs @@ -4,7 +4,7 @@ #define PRECISION mediump #endif -// Look ionized.fs for explanation +// Card rotation extern PRECISION vec2 sepia; extern PRECISION number dissolve; diff --git a/lovely/edition.toml b/lovely/edition.toml index e5793640..c05e1e50 100644 --- a/lovely/edition.toml +++ b/lovely/edition.toml @@ -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]] diff --git a/lovely/fixes.toml b/lovely/fixes.toml index 87a9d223..8b68474d 100644 --- a/lovely/fixes.toml +++ b/lovely/fixes.toml @@ -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''' \ No newline at end of file diff --git a/lovely/number_formatting.toml b/lovely/number_formatting.toml index 10675b36..189356d7 100644 --- a/lovely/number_formatting.toml +++ b/lovely/number_formatting.toml @@ -94,12 +94,7 @@ payload = "scale_number(saved_game.GAME.round_scores.hand.amt, 0.8*scale, 100000 target = "functions/misc_functions.lua" pattern = 'function number_format(num)' position = "at" -payload = ''' -function number_format(num, e_switch_point) - if type(num) ~= 'number' then return num end - - local sign = (num >= 0 and "") or "-" - num = math.abs(num)''' +payload = 'function number_format(num, e_switch_point)' match_indent = true [[patches]] @@ -109,50 +104,6 @@ pattern = 'num >= G\.E_SWITCH_POINT' position = "at" payload = "num >= (e_switch_point or G.E_SWITCH_POINT)" -# 1. Fix floating point error (1.000e92 instead of 10.000e91) -# 2. Lower precision with higher numbers -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = ''' -return string.format("%.3f",x/(10^fac))..'e'..fac''' -position = "at" -payload = ''' -if num == math.huge then - return sign.."naneinf" -end - -local mantissa = round_number(x/(10^fac), 3) -if mantissa >= 10 then - mantissa = mantissa / 10 - fac = fac + 1 -end -return sign..(string.format(fac >= 100 and "%.1fe%i" or fac >= 10 and "%.2fe%i" or "%.3fe%i", mantissa, fac))''' -match_indent = true - -# Remove trailing zeroes -# E.g. X1.5 being displayed as X1.50 -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = ''' -return string.format(num ~= math.floor(num) and (num >= 100 and "%.0f" or num >= 10 and "%.1f" or "%.2f") or "%.0f", num):reverse():gsub("(%d%d%d)", "%1,"):gsub(",$", ""):reverse()''' -position = "at" -payload = ''' -local formatted -if num ~= math.floor(num) and num < 100 then - formatted = string.format(num >= 10 and "%.1f" or "%.2f", num) - if formatted:sub(-1) == "0" then - formatted = formatted:gsub("%.?0+$", "") - end - -- Return already to avoid comas being added - if num < 0.01 then return tostring(num) end -else - formatted = string.format("%.0f", num) -end -return sign..(formatted:reverse():gsub("(%d%d%d)", "%1,"):gsub(",$", ""):reverse())''' -match_indent = true - ## scale_number [[patches]] [patches.pattern] @@ -167,5 +118,5 @@ match_indent = true target = "functions/button_callbacks.lua" pattern = 'number >= G\.E_SWITCH_POINT' position = "at" -payload = "math.abs(number) >= (e_switch_point or G.E_SWITCH_POINT)" +payload = "number >= (e_switch_point or G.E_SWITCH_POINT)" diff --git a/lovely/ui.toml b/lovely/ui.toml index 463d4437..19536570 100644 --- a/lovely/ui.toml +++ b/lovely/ui.toml @@ -348,22 +348,4 @@ match_indent = true target = 'functions/UI_definitions.lua' pattern = '''(?[\t ]*)UIBox_button\(\{button = 'your_collection_blinds', label = \{localize\('b_blinds'\)\}, count = G\.DISCOVER_TALLIES\.blinds, minw = 5, minh = 2.0, id = 'your_collection_blinds', focus_args = \{snap_to = true\}\}\),''' position = 'after' -payload = '''UIBox_button({button = 'your_collection_other_gameobjects', label = {localize('k_other')}, minw = 5, id = 'your_collection_other_gameobjects', focus_args = {snap_to = true}, func = 'is_other_gameobject_tabs'}),''' - -# Fix UIElement.config.chosen being overriden if choice=true is set -# UIElement:click() -[[patches]] -[patches.pattern] -target = "engine/ui.lua" -match_indent = true -position = "after" -pattern = "if self.config.choice then" -payload = " local chosen_temp = self.config.chosen" - -[[patches]] -[patches.pattern] -target = "engine/ui.lua" -match_indent = true -position = "at" -pattern = "self.config.chosen = true" -payload = "self.config.chosen = chosen_temp or true" \ No newline at end of file +payload = '''UIBox_button({button = 'your_collection_other_gameobjects', label = {localize('k_other')}, minw = 5, id = 'your_collection_other_gameobjects', focus_args = {snap_to = true}, func = 'is_other_gameobject_tabs'}),''' \ No newline at end of file