mirror of
https://github.com/ershisan99/Fantoms-Preview.git
synced 2025-12-16 20:49:23 +00:00
added button to get score along with delay before showing
This commit is contained in:
@@ -14,6 +14,9 @@ end
|
|||||||
|
|
||||||
function FN.PRE.simulate()
|
function FN.PRE.simulate()
|
||||||
-- Guard against simulating in redundant places:
|
-- Guard against simulating in redundant places:
|
||||||
|
if FN.PRE.five_second_coroutine and coroutine.status(FN.PRE.five_second_coroutine) == "suspended" then
|
||||||
|
coroutine.resume(FN.PRE.five_second_coroutine)
|
||||||
|
end
|
||||||
if not (G.STATE == G.STATES.SELECTING_HAND or
|
if not (G.STATE == G.STATES.SELECTING_HAND or
|
||||||
G.STATE == G.STATES.DRAW_TO_HAND or
|
G.STATE == G.STATES.DRAW_TO_HAND or
|
||||||
G.STATE == G.STATES.PLAY_TAROT)
|
G.STATE == G.STATES.PLAY_TAROT)
|
||||||
@@ -59,6 +62,9 @@ end
|
|||||||
local orig_hl = CardArea.parse_highlighted
|
local orig_hl = CardArea.parse_highlighted
|
||||||
function CardArea:parse_highlighted()
|
function CardArea:parse_highlighted()
|
||||||
orig_hl(self)
|
orig_hl(self)
|
||||||
|
if not FN.PRE.lock_updates and FN.PRE.show_preview then
|
||||||
|
FN.PRE.show_preview = false
|
||||||
|
end
|
||||||
FN.PRE.add_update_event("immediate")
|
FN.PRE.add_update_event("immediate")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -86,6 +92,8 @@ function FN.PRE.update_on_card_order_change(cardarea)
|
|||||||
then return end
|
then return end
|
||||||
-- Important not to update on G.STATES.HAND_PLAYED, because it would reset the preview text!
|
-- Important not to update on G.STATES.HAND_PLAYED, because it would reset the preview text!
|
||||||
|
|
||||||
|
if (G.STATE == G.STATES.HAND_PLAYED) then return end
|
||||||
|
|
||||||
local prev_order = nil
|
local prev_order = nil
|
||||||
if cardarea.config.type == 'joker' and cardarea.cards[1].ability.set == 'Joker' then
|
if cardarea.config.type == 'joker' and cardarea.cards[1].ability.set == 'Joker' then
|
||||||
if cardarea.cards[1].edition and cardarea.cards[1].edition.mp_phantom then
|
if cardarea.cards[1].edition and cardarea.cards[1].edition.mp_phantom then
|
||||||
@@ -118,7 +126,9 @@ function FN.PRE.update_on_card_order_change(cardarea)
|
|||||||
elseif cardarea.config.type == 'hand' then
|
elseif cardarea.config.type == 'hand' then
|
||||||
FN.PRE.hand_order = prev_order
|
FN.PRE.hand_order = prev_order
|
||||||
end
|
end
|
||||||
|
if FN.PRE.show_preview and not FN.PRE.lock_updates then
|
||||||
|
FN.PRE.show_preview = false
|
||||||
|
end
|
||||||
FN.PRE.add_update_event("immediate")
|
FN.PRE.add_update_event("immediate")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -159,41 +169,59 @@ end
|
|||||||
function G.FUNCS.fn_pre_score_UI_set(e)
|
function G.FUNCS.fn_pre_score_UI_set(e)
|
||||||
local new_preview_text = ""
|
local new_preview_text = ""
|
||||||
local should_juice = false
|
local should_juice = false
|
||||||
if FN.PRE.data then
|
if FN.PRE.lock_updates then
|
||||||
if true and (FN.PRE.data.score.min ~= FN.PRE.data.score.max) then
|
if e.config.id == "fn_pre_l" then
|
||||||
-- Format as 'X - Y' :
|
new_preview_text = " CALCULATING "
|
||||||
if e.config.id == "fn_pre_l" then
|
should_juice = true
|
||||||
new_preview_text = FN.PRE.format_number(FN.PRE.data.score.min) .. " - "
|
end
|
||||||
if FN.PRE.is_enough_to_win(FN.PRE.data.score.min) then should_juice = true end
|
else
|
||||||
elseif e.config.id == "fn_pre_r" then
|
if FN.PRE.data then
|
||||||
new_preview_text = FN.PRE.format_number(FN.PRE.data.score.max)
|
if FN.PRE.show_preview and (FN.PRE.data.score.min ~= FN.PRE.data.score.max) then
|
||||||
if FN.PRE.is_enough_to_win(FN.PRE.data.score.max) then should_juice = true end
|
-- Format as 'X - Y' :
|
||||||
|
if e.config.id == "fn_pre_l" then
|
||||||
|
new_preview_text = FN.PRE.format_number(FN.PRE.data.score.min) .. " - "
|
||||||
|
if FN.PRE.is_enough_to_win(FN.PRE.data.score.min) then should_juice = true end
|
||||||
|
elseif e.config.id == "fn_pre_r" then
|
||||||
|
new_preview_text = FN.PRE.format_number(FN.PRE.data.score.max)
|
||||||
|
if FN.PRE.is_enough_to_win(FN.PRE.data.score.max) then should_juice = true end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- Format as single number:
|
||||||
|
if e.config.id == "fn_pre_l" then
|
||||||
|
if true then
|
||||||
|
-- Spaces around number necessary to distinguish Min/Max text from Exact text,
|
||||||
|
-- which is itself necessary to force a HUD update when switching between Min/Max and Exact.
|
||||||
|
if FN.PRE.show_preview then
|
||||||
|
new_preview_text = " " .. FN.PRE.format_number(FN.PRE.data.score.min) .. " "
|
||||||
|
if FN.PRE.is_enough_to_win(FN.PRE.data.score.min) then should_juice = true end
|
||||||
|
else
|
||||||
|
if FN.PRE.is_enough_to_win(FN.PRE.data.score.min) then
|
||||||
|
should_juice = true
|
||||||
|
new_preview_text = " "
|
||||||
|
else
|
||||||
|
if FN.PRE.is_enough_to_win(FN.PRE.data.score.max) then
|
||||||
|
new_preview_text = " "
|
||||||
|
should_juice = true
|
||||||
|
else
|
||||||
|
new_preview_text = " "
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
new_preview_text = ""
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- Format as single number:
|
-- Spaces around number necessary to distinguish Min/Max text from Exact text, same as above ^
|
||||||
if e.config.id == "fn_pre_l" then
|
if e.config.id == "fn_pre_l" then
|
||||||
if true then
|
if true then new_preview_text = " ?????? "
|
||||||
-- Spaces around number necessary to distinguish Min/Max text from Exact text,
|
else new_preview_text = "??????"
|
||||||
-- which is itself necessary to force a HUD update when switching between Min/Max and Exact.
|
|
||||||
new_preview_text = " " .. FN.PRE.format_number(FN.PRE.data.score.min) .. " "
|
|
||||||
if FN.PRE.is_enough_to_win(FN.PRE.data.score.min) then should_juice = true end
|
|
||||||
else
|
|
||||||
new_preview_text = number_format(FN.PRE.data.score.exact)
|
|
||||||
if FN.PRE.is_enough_to_win(FN.PRE.data.score.exact) then should_juice = true end
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
new_preview_text = ""
|
new_preview_text = ""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
|
||||||
-- Spaces around number necessary to distinguish Min/Max text from Exact text, same as above ^
|
|
||||||
if e.config.id == "fn_pre_l" then
|
|
||||||
if true then new_preview_text = " ?????? "
|
|
||||||
else new_preview_text = "??????"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
new_preview_text = ""
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if (not FN.PRE.text.score[e.config.id:sub(-1)]) or new_preview_text ~= FN.PRE.text.score[e.config.id:sub(-1)] then
|
if (not FN.PRE.text.score[e.config.id:sub(-1)]) or new_preview_text ~= FN.PRE.text.score[e.config.id:sub(-1)] then
|
||||||
|
|||||||
@@ -14,9 +14,42 @@ FN.PRE = {
|
|||||||
dollars = {top = "", bot = ""}
|
dollars = {top = "", bot = ""}
|
||||||
},
|
},
|
||||||
joker_order = {},
|
joker_order = {},
|
||||||
hand_order = {}
|
hand_order = {},
|
||||||
|
show_preview = false,
|
||||||
|
lock_updates = false,
|
||||||
|
on_startup = true,
|
||||||
|
five_second_coroutine = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function FN.PRE.start_new_coroutine()
|
||||||
|
if FN.PRE.five_second_coroutine and coroutine.status(FN.PRE.five_second_coroutine) ~= "dead" then
|
||||||
|
FN.PRE.five_second_coroutine = nil -- Reset the coroutine
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Create and start a new coroutine
|
||||||
|
FN.PRE.five_second_coroutine = coroutine.create(function()
|
||||||
|
-- Show UI updates
|
||||||
|
FN.PRE.lock_updates = true
|
||||||
|
FN.PRE.show_preview = true
|
||||||
|
FN.PRE.add_update_event("immediate") -- Force UI refresh
|
||||||
|
|
||||||
|
local start_time = os.time()
|
||||||
|
while os.time() - start_time < 5 do
|
||||||
|
FN.PRE.simulate() -- Force a simulation run
|
||||||
|
FN.PRE.add_update_event("immediate") -- Ensure UI updates
|
||||||
|
coroutine.yield() -- Allow game to continue running
|
||||||
|
end
|
||||||
|
-- Delay for 5 seconds
|
||||||
|
FN.PRE.lock_updates = false
|
||||||
|
FN.PRE.show_preview = true
|
||||||
|
FN.PRE.add_update_event("immediate") -- Refresh UI again
|
||||||
|
end)
|
||||||
|
|
||||||
|
coroutine.resume(FN.PRE.five_second_coroutine) -- Start it immediately
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FN.PRE._start_up = Game.start_up
|
FN.PRE._start_up = Game.start_up
|
||||||
function Game:start_up()
|
function Game:start_up()
|
||||||
FN.PRE._start_up(self)
|
FN.PRE._start_up(self)
|
||||||
|
|||||||
@@ -7,17 +7,41 @@ local orig_hud = create_UIBox_HUD
|
|||||||
function create_UIBox_HUD()
|
function create_UIBox_HUD()
|
||||||
local contents = orig_hud()
|
local contents = orig_hud()
|
||||||
|
|
||||||
local score_node_wrap = {n=G.UIT.R, config={id = "fn_pre_score_wrap", align = "cm", padding = 0.1}, nodes={}}
|
|
||||||
if G.SETTINGS.FN.preview_score then table.insert(score_node_wrap.nodes, FN.PRE.get_score_node()) end
|
|
||||||
table.insert(contents.nodes[1].nodes[1].nodes[4].nodes[1].nodes, score_node_wrap)
|
|
||||||
|
|
||||||
local dollars_node_wrap = {n=G.UIT.C, config={id = "fn_pre_dollars_wrap", align = "cm"}, nodes={}}
|
local score_node_wrap = {n=G.UIT.R, config={id = "fn_pre_score_wrap", align = "cm", padding = 0.05}, nodes={}}
|
||||||
|
table.insert(score_node_wrap.nodes, FN.PRE.get_score_node())
|
||||||
|
local calculate_score_button = {n = G.UIT.R,
|
||||||
|
config = {
|
||||||
|
align = "cm",
|
||||||
|
padding = 0.01,
|
||||||
|
},
|
||||||
|
nodes = {
|
||||||
|
UIBox_button({
|
||||||
|
id = "calculate_score_button",
|
||||||
|
label = {
|
||||||
|
"Calculate Score"
|
||||||
|
},
|
||||||
|
colour = G.C.RED,
|
||||||
|
button = "calculate_score_button",
|
||||||
|
scale = 0.5,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
table.insert(contents.nodes[1].nodes[1].nodes[4].nodes[1].nodes, score_node_wrap)
|
||||||
|
table.insert(contents.nodes[1].nodes[1].nodes[4].nodes[1].nodes, calculate_score_button)
|
||||||
|
|
||||||
|
--[[local dollars_node_wrap = {n=G.UIT.C, config={id = "fn_pre_dollars_wrap", align = "cm"}, nodes={}}
|
||||||
if G.SETTINGS.FN.preview_dollars then table.insert(dollars_node_wrap.nodes, FN.PRE.get_dollars_node()) end
|
if G.SETTINGS.FN.preview_dollars then table.insert(dollars_node_wrap.nodes, FN.PRE.get_dollars_node()) end
|
||||||
table.insert(contents.nodes[1].nodes[1].nodes[5].nodes[2].nodes[3].nodes[1].nodes[1].nodes[1].nodes, dollars_node_wrap)
|
table.insert(contents.nodes[1].nodes[1].nodes[5].nodes[2].nodes[3].nodes[1].nodes[1].nodes[1].nodes, dollars_node_wrap) --]]
|
||||||
|
|
||||||
return contents
|
return contents
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function G.FUNCS.calculate_score_button()
|
||||||
|
FN.PRE.start_new_coroutine()
|
||||||
|
end
|
||||||
|
|
||||||
function FN.PRE.get_score_node()
|
function FN.PRE.get_score_node()
|
||||||
local text_scale = nil
|
local text_scale = nil
|
||||||
if true then text_scale = 0.5
|
if true then text_scale = 0.5
|
||||||
@@ -29,7 +53,7 @@ function FN.PRE.get_score_node()
|
|||||||
}}
|
}}
|
||||||
end
|
end
|
||||||
|
|
||||||
function FN.PRE.get_dollars_node()
|
--[[function FN.PRE.get_dollars_node()
|
||||||
local top_color = FN.PRE.get_dollar_colour(0)
|
local top_color = FN.PRE.get_dollar_colour(0)
|
||||||
local bot_color = top_color
|
local bot_color = top_color
|
||||||
if FN.PRE.data ~= nil then
|
if FN.PRE.data ~= nil then
|
||||||
@@ -46,7 +70,7 @@ function FN.PRE.get_dollars_node()
|
|||||||
{n=G.UIT.O, config={id = "fn_pre_dollars_bot", func = "fn_pre_dollars_UI_set", object = DynaText({string = {{ref_table = FN.PRE.text.dollars, ref_value = "bot"}}, colours = {bot_color}, shadow = true, spacing = 2, bump = true, scale = 0.5})}},
|
{n=G.UIT.O, config={id = "fn_pre_dollars_bot", func = "fn_pre_dollars_UI_set", object = DynaText({string = {{ref_table = FN.PRE.text.dollars, ref_value = "bot"}}, colours = {bot_color}, shadow = true, spacing = 2, bump = true, scale = 0.5})}},
|
||||||
}}
|
}}
|
||||||
}}
|
}}
|
||||||
end
|
end--]]
|
||||||
|
|
||||||
--
|
--
|
||||||
-- SETTINGS:
|
-- SETTINGS:
|
||||||
|
|||||||
Reference in New Issue
Block a user