mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
Using Lily to speed up assets loading
This commit is contained in:
@@ -52,18 +52,19 @@ Navigate to where you put ``tromi_mobile.love`` in the File manager (the one you
|
|||||||
* Update ``binser`` library, this fixes some weird bugs related to saving
|
* Update ``binser`` library, this fixes some weird bugs related to saving
|
||||||
* Add ``simple-button`` module, made by me (SweetSea)
|
* Add ``simple-button`` module, made by me (SweetSea)
|
||||||
* Replaced old Cambridge's ``config`` module with the new one inspired by "the sequel of Techmino"s ``SETTINGS`` module".
|
* Replaced old Cambridge's ``config`` module with the new one inspired by "the sequel of Techmino"s ``SETTINGS`` module".
|
||||||
|
* Using `lily` to improve the loading speed of animated backgrounds and sounds.
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
- [x] Add a way to export replay data for Android > 11
|
- [x] Add a way to export replay data for Android 11+
|
||||||
- [x] Revert ``bitser`` with ``binser`` (if and only if I can make it works)
|
- [x] Revert ``bitser`` with ``binser`` (if and only if I can make it works)
|
||||||
- [x] Design a new on-screen buttons skin (the current one is come from [C₂₉H₂₅N₃O₅](https://github.com/C29H25N3O5), I am aware that it's not fit to Tromi's design language)
|
- [x] Design a new on-screen buttons skin (the current one is come from [C₂₉H₂₅N₃O₅](https://github.com/C29H25N3O5), I am aware that it's not fit to Tromi's design language)
|
||||||
- [x] Updating on-screen control configuration screen
|
- [x] Updating on-screen control configuration screen
|
||||||
- [x] (Low priority) Design a new menu screen
|
- [x] (Low priority) Design a new menu screen
|
||||||
|
- [x] Add shortcut to open replay converter at https://sweetsea-butimnotsweet.github.io/tromi_replay_converter
|
||||||
|
- [x] Redesign the replay selector screen
|
||||||
|
|
||||||
- [ ] Add user data management
|
- [ ] Add user data management
|
||||||
- [ ] Redesign "the Control method selection" screen
|
- [ ] Redesign "the Control method selection" screen
|
||||||
- [ ] Redesign the replay screen
|
|
||||||
- [ ] Add shortcut to open replay converter at https://sweetsea-butimnotsweet.github.io/tromi_replay_converter
|
|
||||||
|
|
||||||
# License (GNU GPLv3)
|
# License (GNU GPLv3)
|
||||||
Please read ``COPYING.txt`` for more information.<br>
|
Please read ``COPYING.txt`` for more information.<br>
|
||||||
|
|||||||
1009
libs/lily.lua
Normal file
1009
libs/lily.lua
Normal file
File diff suppressed because it is too large
Load Diff
68
load.lua
68
load.lua
@@ -60,22 +60,25 @@ BUTTON.setDefaultOption{
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- Graphics
|
-- Graphics
|
||||||
ShowLoadingText('backgrounds')
|
|
||||||
local gc_newImage, gc_newVideo = love.graphics.newImage, love.graphics.newVideo
|
local gc_newImage, gc_newVideo = love.graphics.newImage, love.graphics.newVideo
|
||||||
BACKGROUNDS = {
|
BACKGROUNDS = {}
|
||||||
[0] = gc_newVideo("res/backgrounds/green_waterfall.ogv", {audio=false}),
|
LILY.loadMulti{
|
||||||
gc_newVideo("res/backgrounds/water.ogv", {audio=false}),
|
{'newVideo', "res/backgrounds/green_waterfall.ogv", {audio=false}},
|
||||||
gc_newVideo("res/backgrounds/green_streams.ogv", {audio=false}),
|
{'newVideo', "res/backgrounds/water.ogv", {audio=false}},
|
||||||
gc_newVideo("res/backgrounds/streams.ogv", {audio=false}),
|
{'newVideo', "res/backgrounds/green_streams.ogv", {audio=false}},
|
||||||
gc_newVideo("res/backgrounds/red_forest_waterfall.ogv", {audio=false}),
|
{'newVideo', "res/backgrounds/streams.ogv", {audio=false}},
|
||||||
gc_newVideo("res/backgrounds/flowers_rain.ogv", {audio=false}),
|
{'newVideo', "res/backgrounds/red_forest_waterfall.ogv", {audio=false}},
|
||||||
gc_newVideo("res/backgrounds/moonlight_tree.ogv", {audio=false}),
|
{'newVideo', "res/backgrounds/flowers_rain.ogv", {audio=false}},
|
||||||
gc_newVideo("res/backgrounds/lisa_frank.ogv", {audio=false}),
|
{'newVideo', "res/backgrounds/moonlight_tree.ogv", {audio=false}},
|
||||||
gc_newVideo("res/backgrounds/snowy_trees.ogv", {audio=false}),
|
{'newVideo', "res/backgrounds/lisa_frank.ogv", {audio=false}},
|
||||||
gc_newVideo("res/backgrounds/snowy_cabin.ogv", {audio=false}),
|
{'newVideo', "res/backgrounds/snowy_trees.ogv", {audio=false}},
|
||||||
}
|
{'newVideo', "res/backgrounds/snowy_cabin.ogv", {audio=false}},
|
||||||
|
}:onComplete(
|
||||||
|
function(_, lilies)
|
||||||
|
for i = 0, 9 do BACKGROUNDS[i] = lilies[i + 1][1] end
|
||||||
|
LOADED_BACKGROUND = true;
|
||||||
|
end)
|
||||||
|
|
||||||
ShowLoadingText('blocks')
|
|
||||||
BLOCKS = {
|
BLOCKS = {
|
||||||
["2tie"] = {
|
["2tie"] = {
|
||||||
R = gc_newImage("res/img/r.png"),
|
R = gc_newImage("res/img/r.png"),
|
||||||
@@ -112,21 +115,30 @@ COLOUR_SCHEMES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- BGMs and SFXs
|
-- BGMs and SFXs
|
||||||
ShowLoadingText('BGMs & SFXs')
|
|
||||||
local audio_newSource = love.audio.newSource
|
local audio_newSource = love.audio.newSource
|
||||||
SOUNDS = {
|
SOUNDS = {}
|
||||||
bottom = audio_newSource("res/se/bottom.wav", "static"),
|
LILY.loadMulti{
|
||||||
lock = audio_newSource("res/se/lock.wav", "static"),
|
{"newSource", "res/se/bottom.wav", "static"},
|
||||||
erase = audio_newSource("res/se/erase.wav", "static"),
|
{"newSource", "res/se/lock.wav", "static"},
|
||||||
fall = audio_newSource("res/se/fall.wav", "static"),
|
{"newSource", "res/se/erase.wav", "static"},
|
||||||
ready = audio_newSource("res/se/ready.wav", "static"),
|
{"newSource", "res/se/fall.wav", "static"},
|
||||||
promote = audio_newSource("res/se/promote.wav", "static"),
|
{"newSource", "res/se/ready.wav", "static"},
|
||||||
demote = audio_newSource("res/se/demote.wav", "static"),
|
{"newSource", "res/se/promote.wav", "static"},
|
||||||
autopromote = audio_newSource("res/se/autopromote.wav", "static"),
|
{"newSource", "res/se/demote.wav", "static"},
|
||||||
bgm_firsthalf = audio_newSource("res/bgm/firsthalf.flac", "static"),
|
{"newSource", "res/se/autopromote.wav", "static"},
|
||||||
bgm_secondhalf = audio_newSource("res/bgm/secondhalf.flac", "static"),
|
{"newSource", "res/bgm/firsthalf.flac", "static"},
|
||||||
bgm_title = audio_newSource("res/bgm/title.flac", "static")
|
{"newSource", "res/bgm/secondhalf.flac", "static"},
|
||||||
}
|
{"newSource", "res/bgm/title.flac", "static"},
|
||||||
|
}:onComplete(
|
||||||
|
function(_, lilies)
|
||||||
|
SOUNDS.bottom, SOUNDS.lock, SOUNDS.erase, SOUNDS.fall = unpack(lilies, 1, 4)
|
||||||
|
SOUNDS.ready, SOUNDS.promote, SOUNDS.demote, SOUNDS.autopromote = unpack(lilies, 5, 8)
|
||||||
|
SOUNDS.bgm_firsthalf, SOUNDS.bgm_secondhalf, SOUNDS.bgm_title = unpack(lilies, 9)
|
||||||
|
|
||||||
|
for k, v in pairs(SOUNDS) do SOUNDS[k] = v[1] end -- Again, to avoid userdata
|
||||||
|
LOADED_MUSIC = true;
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
function PlaySE(sound, subsound)
|
function PlaySE(sound, subsound)
|
||||||
if sound ~= nil then
|
if sound ~= nil then
|
||||||
|
|||||||
33
main.lua
33
main.lua
@@ -17,21 +17,7 @@ BACKGROUND_COLOR = {32/255, 120/255, 88/255}
|
|||||||
CURRENT_OS = love.system.getOS()
|
CURRENT_OS = love.system.getOS()
|
||||||
MOBILE = CURRENT_OS == "Android" or CURRENT_OS == "iOS"
|
MOBILE = CURRENT_OS == "Android" or CURRENT_OS == "iOS"
|
||||||
|
|
||||||
LOADING_IMAGE_FILE = love.graphics.newImage('res/loading.png')
|
LILY = require "libs.lily"
|
||||||
--- Show the loading text while we are loading resources<br>
|
|
||||||
--- **WARNING**: should only be used while loading the game!
|
|
||||||
function ShowLoadingText(thing)
|
|
||||||
love.resize(love.graphics.getDimensions())
|
|
||||||
love.graphics.replaceTransform(GLOBAL_TRANSFORM)
|
|
||||||
love.graphics.setFont(love.graphics.newFont(20))
|
|
||||||
love.graphics.clear()
|
|
||||||
|
|
||||||
love.graphics.draw(LOADING_IMAGE_FILE,0,0,0,0.5)
|
|
||||||
drawText("Loading ".. thing .. "...", 15, 455, 1e99, "left")
|
|
||||||
|
|
||||||
love.graphics.flushBatch()
|
|
||||||
love.graphics.present()
|
|
||||||
end
|
|
||||||
|
|
||||||
function love.load()
|
function love.load()
|
||||||
require 'funcs'
|
require 'funcs'
|
||||||
@@ -53,17 +39,6 @@ function love.load()
|
|||||||
require "game.vctrl" -- VCTRL
|
require "game.vctrl" -- VCTRL
|
||||||
|
|
||||||
SCENE = LoadingScene()
|
SCENE = LoadingScene()
|
||||||
|
|
||||||
-- VCTRL.new{ -- up down left right --- right left down up
|
|
||||||
-- -- {type='button',x= 100,y=320,key= 'up',r=35,iconSize=60,alpha=0.75},
|
|
||||||
-- -- {type='button',x= 100,y=440,key= 'down',r=35,iconSize=60,alpha=0.75},
|
|
||||||
-- -- {type='button',x= 40,y=380,key= 'left',r=35,iconSize=60,alpha=0.75},
|
|
||||||
-- -- {type='button',x= 160,y=380,key= 'right',r=35,iconSize=60,alpha=0.75},
|
|
||||||
-- -- {type='button',x=640- 40,y=380,key= 'rotate_left',r=35,iconSize=60,alpha=0.75},
|
|
||||||
-- -- {type='button',x=640-160,y=380,key= 'rotate_left2',r=35,iconSize=60,alpha=0.75},
|
|
||||||
-- -- {type='button',x=640-100,y=440,key= 'rotate_right',r=35,iconSize=60,alpha=0.75},
|
|
||||||
-- -- {type='button',x=640-100,y=320,key='rotate_right2',r=35,iconSize=60,alpha=0.75},
|
|
||||||
-- }
|
|
||||||
VCTRL.new(SETTINGS.input.virtual)
|
VCTRL.new(SETTINGS.input.virtual)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -148,7 +123,7 @@ function love.keypressed(key, scancode)
|
|||||||
love.resize(love.graphics.getDimensions())
|
love.resize(love.graphics.getDimensions())
|
||||||
elseif scancode == "f2" and SCENE.title ~= "Input Config" and SCENE.title ~= "Game" then
|
elseif scancode == "f2" and SCENE.title ~= "Input Config" and SCENE.title ~= "Game" then
|
||||||
SCENE = InputConfigScene()
|
SCENE = InputConfigScene()
|
||||||
elseif scancode == "f3" then SCENE = DataManagementScene()
|
elseif scancode == "f3" then SCENE = UserManagementScene()
|
||||||
elseif scancode == "f12" then LLDEBUGGER.requestBreak()
|
elseif scancode == "f12" then LLDEBUGGER.requestBreak()
|
||||||
-- elseif scancode == "f11" then SETTINGS.firstTime = true
|
-- elseif scancode == "f11" then SETTINGS.firstTime = true
|
||||||
-- function keys are reserved
|
-- function keys are reserved
|
||||||
@@ -305,6 +280,10 @@ end
|
|||||||
|
|
||||||
function love.focus(f) end
|
function love.focus(f) end
|
||||||
|
|
||||||
|
function love.quit()
|
||||||
|
LILY.quit()
|
||||||
|
end
|
||||||
|
|
||||||
local TARGET_FPS = 60
|
local TARGET_FPS = 60
|
||||||
|
|
||||||
function love.run()
|
function love.run()
|
||||||
|
|||||||
@@ -1,10 +1,21 @@
|
|||||||
local LoadingScene = SCENE:extend()
|
local LoadingScene = SCENE:extend()
|
||||||
|
local LoadingImageFile = love.graphics.newImage('res/loading.png')
|
||||||
|
|
||||||
function LoadingScene.update()
|
function LoadingScene.update()
|
||||||
SCENE = SETTINGS.firstTime and InputConfigScene(true) or TitleScene()
|
if LOADED_BACKGROUND and LOADED_MUSIC then
|
||||||
|
SCENE = SETTINGS.firstTime and InputConfigScene(true) or TitleScene()
|
||||||
|
LILY.quit()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
function LoadingScene.render()
|
function LoadingScene.render()
|
||||||
love.graphics.draw(LOADING_IMAGE_FILE,0,0,0,0.5)
|
love.graphics.draw(LoadingImageFile,0,0,0,0.5)
|
||||||
|
drawText(
|
||||||
|
("Background: %s\nMusic & SFX: %s"):format(
|
||||||
|
LOADED_BACKGROUND and "loaded" or "...",
|
||||||
|
LOADED_MUSIC and "loaded" or "..."
|
||||||
|
),
|
||||||
|
15, 440, 1e99, "left"
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
return LoadingScene
|
return LoadingScene
|
||||||
Reference in New Issue
Block a user