-
Notifications
You must be signed in to change notification settings - Fork 4
Alan/image refactor #36
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
base: master
Are you sure you want to change the base?
Changes from all commits
a6508d4
1deccc2
0c845f6
9ae9c46
31b457b
8620588
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../bbs/carts |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ bar_color_1=12 | |
bar_color_2=-4 | ||
|
||
cart_dir='games' | ||
label_dir='labels' | ||
label_dir='bbs' -- TODO: currently bbs is a symlink because I want to test p8.png loading. This should not be a symlink and instead games should have p8.png files when possible since those have more information. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this was a hack, because I wanted to test loading actual carts instead of image files. |
||
loaded_carts={} -- list of all carts that can be displayed in the menu | ||
carts={} -- menu for pexsplore ui | ||
|
||
|
@@ -75,6 +75,7 @@ function draw_label(x, y, w, slot) | |
sspr(i*64, slot*32 + j, 64, 1, x-w/2, y-w/2+j*2+i) | ||
end | ||
end | ||
-- sspr(0, 0, 128, 128, x-w/2, y-w/2+j*2+i, 64, 64) | ||
end | ||
end | ||
|
||
|
@@ -188,10 +189,16 @@ function make_cart_swipe_tween(dir) | |
cart_swipe_tween:register_step_callback(function(pos) | ||
cart_x_swipe=pos | ||
end) | ||
|
||
cart_swipe_tween:register_step_callback(function(_, frame) | ||
serial_load_image("bbs/"..carts:cur().filename, 0x0000, 64, 64, frame) | ||
end) | ||
|
||
cart_swipe_tween:register_finished_callback(function(tween) | ||
cart_x_swipe=64-1*dir*128 | ||
tween:remove() | ||
load_label(carts:cur(), 0) | ||
|
||
-- load_label(carts:cur(), 0) | ||
make_cart_swipe_tween_2(dir) | ||
end) | ||
cart_swipe_tween:restart() | ||
|
@@ -460,7 +467,7 @@ function build_new_cart_menu(resp) | |
item.menuitem = menuitem.cart | ||
add(new_menuitems, item) | ||
end | ||
|
||
-- TODO would like to disable this option for local categories, but also need to make sure we don't have an empty menu | ||
add(new_menuitems, {menuitem=menuitem.load}) | ||
|
||
|
@@ -505,7 +512,7 @@ function draw_carts_menu() | |
else | ||
local str="❎ load more carts" | ||
print(str, cart_x_swipe-#str*2, 64, 7) | ||
end | ||
end | ||
else | ||
draw_cart(cart_x_swipe, 64.5+cart_y_ease+cart_y_bob, 0) | ||
local str="❎view" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -491,6 +491,7 @@ function tween_machine:add_tween(instance) | |
start_time = 0, | ||
duration = 0, | ||
elapsed = 0, | ||
frame = 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be a hack. There is a tween when loading images. Frame is needed because the protocol for getting an image takes in how many bytes to read and the offset. That's because you can't load a full image in a single frame without getting fps throttle, so the idea was, read like 1/8th of the image each frame of an animation. A new cart image could load in like 8 frames while you are doing a screen swipe animation, so it could make it look seamless especially if the image is cached. |
||
finished = false, | ||
|
||
--- Callbacks | ||
|
@@ -583,6 +584,7 @@ end | |
function __tween:restart() | ||
self:init() | ||
self.elapsed = 0 | ||
self.frame = 0 | ||
self.finished = false | ||
end | ||
|
||
|
@@ -604,6 +606,7 @@ function __tween:update() | |
if (self.finished or self.func == nil) return | ||
|
||
self.elapsed = time() - self.start_time | ||
self.frame += 1 -- frame just increments by 1 each frame. | ||
if (self.elapsed > self.duration) self.elapsed = self.duration | ||
self.value = self.func( | ||
self.elapsed, | ||
|
@@ -614,7 +617,7 @@ function __tween:update() | |
|
||
if #self.step_callbacks > 0 then | ||
for v in all(self.step_callbacks) do | ||
v(self.value) | ||
v(self.value, self.frame-1) | ||
end | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moka is a cache system. The idea is that when parsing images, we async read from the file system then cache the image in moka, so when picolauncher requests for another image, no file system read is needed and the image can be loaded quickly.