Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delayed and enlarged unhighlight transitions. #182

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion data/objects/choose_deck_controller.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@
",

deck_mouseoff: "def(obj deck_avatar deck) ->commands
schedule(8,
if(deck != _selected_deck,
animate(deck, {
halo: 0.0,
}, {
duration: 10,
duration: 16,
})
)
)
",

_deck_preview_widget: { type: "null|obj deck_preview_widget" },
Expand Down
4 changes: 2 additions & 2 deletions data/objects/library_archive_controller.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
deck_leave: "def(obj deck_avatar avi, Deck deck) ->commands
[
set(_remove_button, null),
animate(avi, { halo: 0.0 }, { duration: 10 })
schedule(8, animate(avi, { halo: 0.0 }, { duration: 16 })),
]
",

Expand All @@ -53,7 +53,7 @@
map(filter(level.chars, value is obj library_deck_summary), value.pulse()),
],
summary = null, [
animate(avi, { halo: 0.0 }, { duration: 10 }),
schedule(8, animate(avi, { halo: 0.0 }, { duration: 16 })),
set(deck.archived, false);
set(deck.creation_time, time().unix);
controller.return_deck_from_archive(deck)
Expand Down
6 changes: 5 additions & 1 deletion data/objects/library_controller.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -711,11 +711,15 @@
y: _deck_summary_ypos(count(level.chars, value is obj library_deck_summary)),
}, [
add(_deck_summaries, [child]),
// Schedule added as a lazy way of preventing
// the Anura Gear(TM) from showing up.
schedule(8,
animate(child, {
alpha: 255,
}, {
duration: 10,
duration: 26,
})
)
]),
])",

Expand Down
163 changes: 145 additions & 18 deletions data/objects/library_deck_summary.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,35 @@
default: false,
set: "[
set(_data, value),
bind_command(render),
bind_command(render, [true, false]),
]",
},

highlighted: {
type: "bool",
default: false,
set: "[
set(_data, value),
bind_command(render),
]",
set: "
if (
_data != value,
[
set(_data, value),
;
render([true, false])
],
// else
// I don't know yet why this
// gets called... but gets
// called.
[
;
// This rendering
// prevents the Anura
// Gear(TM) from
// appearing.
render([true, true])
]
)
",
},

pulse: "def() ->commands
Expand Down Expand Up @@ -117,30 +135,79 @@
[
map(range(6), schedule(6*value, [
set(_force_highlight_card_limit, index%2 = 0);
render()
render([true, false])
]))
])
",

_force_highlight_card_limit: { type: "bool", default: false },

render: "def(bool show_name=true) ->commands [
_disable_schedules: { type: "bool", default: false },

render: "def
// Array of two elements: `show_name` and `creating`.
([bool] flags) -> commands
// Starting top function scope.
[
// If FPS run below a dangerous level, stops scheduling
// transition steps and subsequent renderings will be using a
// single step. When FPS return over a confident level, starts
// allowing multi step transitions back again.
if (
fps < fps_low_level,
set(_disable_schedules, true),
fps > fps_high_level,
set(_disable_schedules, false)
),
map(range(transition_steps),
schedule(step + delay,
if (
// If schedules are disabled, only allow instant
// transitions.
(transition_steps = 1 and _disable_schedules)
// Multi step transitions only if
// schedules are enabled.
or (transition_steps > 1 and not _disable_schedules)
// Unhighlighting transitions always
// allowed and help render correctly
// on object creation.
or not highlighting
,
if (area.width > 0 and area.height > 0, // needed to prevent crashes when alt tabbing
set(animation, {
id: 'fbo',
image: 'fbo',
x: 0, y: 0, w: area.width, h: area.height,
scale: 1, frames: 1,
fbo:
query_cache(global_cache(24), [show_name, area, deck_name, selected or highlighted, _controller and _controller.editing_deck, num_creatures, num_buildings, num_spells, num_lands, _force_highlight_card_limit],
query_cache(global_cache(24),
[
show_name, area, deck_name,
selected or highlighted,
_controller and _controller.editing_deck,
num_creatures, num_buildings, num_spells,
num_lands, _force_highlight_card_limit,
creating, transition_steps_dec, step + 1,
],
c.render(area.width, area.height, [
c.rectangle(0, area.height*0.1, area.width, area.height*0.8),
c.set_source_rgba(0.06, 0.09, 0.13, 1.0),
c.fill(),

if(selected or highlighted,
c.set_source_rgba(1.0, 1.0, 1.0, 1.0),
c.set_source_rgba(0.29, 0.33, 0.36, 1.0)),
c.set_source_rgba(
if (creating, 1.0, clamp(mix(.29, 1.0, (step + 1) / transition_steps_dec), .29, 1.0)),
if (creating, 1.0, clamp(mix(.33, 1.0, (step + 1) / transition_steps_dec), .33, 1.0)),
if (creating, 1.0, clamp(mix(.36, 1.0, (step + 1) / transition_steps_dec), .36, 1.0)),
1.0
),
c.set_source_rgba(
if (creating, .29, clamp(mix(1.0, .29, (step + 1) / transition_steps_dec), .29, 1.0)),
if (creating, .33, clamp(mix(1.0, .33, (step + 1) / transition_steps_dec), .33, 1.0)),
if (creating, .36, clamp(mix(1.0, .36, (step + 1) / transition_steps_dec), .36, 1.0)),
1.0
)
),
c.rectangle(0, area.height*0.1, area.width, area.height*0.8),
c.set_line_width(py(20)/10.0),
c.stroke(),
Expand Down Expand Up @@ -210,11 +277,22 @@
if(num_spells, str(num_spells) + ' spells', ''),
if(num_lands, str(num_lands) + ' lands', ''),
], if(a and b, a + ', ' + b, a + b))*/
])),
// end of the c.render(int, int, [cairo_op]) operation.
])
// end of the query_cache(cache, list, commands) operation.
)
,
// End of the dictionary for the `animation`.
}
// End of the `set(animation, ...)` operation.
)
where c = canvas()
) // if ((transition_steps = 1 and _disable_schedules) ...
// End if (area.width > 0 and area.height > 0, ...
)
) // schedule(...)
where step = value
) // map(range, ...)
where school_counts = map(range(5), count(deck_cards, school in value.school_list) where school = value+1)
where num_creatures = count(deck_cards, value.creature_object and value.creature_object.is_land = false and value.creature_object.is_building = false)
where num_buildings = count(deck_cards, value.creature_object and value.creature_object.is_land = false and value.creature_object.is_building)
Expand All @@ -225,7 +303,56 @@
where entries = filter(level.chars, value is obj library_deck_entry),

set(_last_cards, cards),
]",
] // Ending top function scope.
where transition_steps_dec = transition_steps * 1.0
where transition_steps = if (
highlighting,
if (
creating,
1,
// else
if (
_disable_schedules,
1,
// else
10
)
),
// else
if (
creating,
1,
// else
if (
_disable_schedules,
1,
// else
16
)
)
)
where delay = if (
highlighting,
0,
// else
if (
creating,
0,
// else
if (
_disable_schedules,
2,
// else
8
)
)
)
where fps = get_perf_info().fps
where fps_low_level = 35, fps_high_level = 50
where highlighting = highlighted
where show_name = if (size(flags) > 0, flags[0], true)
where creating = if (size(flags) > 1, flags[1], false)
",

change_deck_name: "def(string raw_name) ->commands

Expand All @@ -239,7 +366,7 @@
),
remove_object(_name_entry_widget),
set(_name_entry_widget, null),
bind_command(render),
bind_command(render, [true, false]),
] asserting _controller != null
",
},
Expand All @@ -250,7 +377,7 @@
set(_card_avatar.mid_y, mid_y),
]),
if(_controller != null and _controller.editing_deck and cards != _last_cards, [
fire_event('render')
fire_event('render', [true])
])
]",

Expand Down Expand Up @@ -285,7 +412,7 @@
set(_name_entry_widget, child),
]),

render(false),
render([false, false]),
]
)
where title_area = canvas().text_extents(_font, _font_size*2, deck_name)
Expand Down Expand Up @@ -339,11 +466,11 @@
change_deck_name(_name_entry_widget.text asserting _name_entry_widget != null)
",

on_create: "[fire_event('render'), set(x2, x2), set(y, y)]",
on_render: "[show_avatar(), render()]",
on_create: "[fire_event('render', [true, true]), set(x2, x2), set(y, y)]",
on_render: "[show_avatar(), render([true, false])]",

on_being_added: "if(_card_avatar != null, add_object(_card_avatar))",
on_being_removed: "remove_object(_card_avatar)",

on_type_updated: "fire_event('render')",
on_type_updated: "fire_event('render', [true, true])",
}
Loading