mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
171 lines
5.9 KiB
Lua
171 lines
5.9 KiB
Lua
-- Fonts
|
|
FONT_tromi = love.graphics.newFont('res/fonts/monofonto rg.otf', 28)
|
|
FONT_big = love.graphics.newFont('res/fonts/monofonto rg.otf', 56)
|
|
|
|
FONT_tromi:setFallbacks(love.graphics.newFont('res/fonts/icon.otf', 28))
|
|
FONT_big :setFallbacks(love.graphics.newFont('res/fonts/icon.otf', 56))
|
|
CHAR = require("char")
|
|
|
|
local font_height = FONT_tromi:getHeight() * 0.5
|
|
local font_big_height = FONT_big:getHeight() * 0.5
|
|
|
|
-- Bigint library
|
|
bigint = require "libs.bigint.bigint"
|
|
number_names = require "libs.bigint.named-powers-of-ten"
|
|
|
|
-- BUTTON library
|
|
require "libs.simple-slider"
|
|
BUTTON = require "libs.simple-button"
|
|
BUTTON.setDefaultOption{
|
|
draw = function(self)
|
|
local need_big_font = (self.font == FONT_big)
|
|
|
|
love.graphics.setColor(self.backgroundColor)
|
|
love.graphics.rectangle('fill', self.x, self.y, self.w, self.h, self.r)
|
|
|
|
if self._pressed then
|
|
love.graphics.setColor(self.pressColor)
|
|
love.graphics.rectangle('fill', self.x, self.y, self.w, self.h, self.r)
|
|
elseif self._hovering then
|
|
love.graphics.setColor(self.hoverColor)
|
|
love.graphics.rectangle('fill', self.x, self.y, self.w, self.h, self.r)
|
|
end
|
|
|
|
local text = type(self.text) == 'function' and self.text() or self.text
|
|
|
|
local lineAmount
|
|
do
|
|
local _, t
|
|
if need_big_font then
|
|
_, t = FONT_big:getWrap(text, (self.w - 5) * 2)
|
|
else
|
|
_, t = FONT_tromi:getWrap(text, (self.w - 5) * 2)
|
|
end
|
|
lineAmount = #t
|
|
end
|
|
|
|
local _font_height = need_big_font and font_big_height or font_height
|
|
|
|
local textHeight = _font_height * (lineAmount * 0.5)
|
|
local textPos = self.y + (self.h * 0.5) - textHeight
|
|
|
|
if need_big_font then
|
|
drawBigText(text, self.x + 2.5, textPos, self.w - 5, self.textOrientation, self.textColor)
|
|
else
|
|
drawText(text, self.x + 2.5, textPos, self.w - 5, self.textOrientation, self.textColor)
|
|
end
|
|
|
|
love.graphics.setColor(self.borderColor)
|
|
love.graphics.setLineWidth(1)
|
|
love.graphics.rectangle('line', self.x, self.y, self.w, self.h, self.r)
|
|
end,
|
|
backgroundColor = {0, 0, 0, 0.8},
|
|
pressColor = {0.4, 1, 1, 0.5},
|
|
borderColor = {1, 1, 1, 0.8},
|
|
}
|
|
|
|
-- Graphics
|
|
ShowLoadingText('backgrounds')
|
|
local gc_newImage, gc_newVideo = love.graphics.newImage, love.graphics.newVideo
|
|
BACKGROUNDS = {
|
|
[0] = gc_newVideo("res/backgrounds/green_waterfall.ogv", {audio=false}),
|
|
gc_newVideo("res/backgrounds/water.ogv", {audio=false}),
|
|
gc_newVideo("res/backgrounds/green_streams.ogv", {audio=false}),
|
|
gc_newVideo("res/backgrounds/streams.ogv", {audio=false}),
|
|
gc_newVideo("res/backgrounds/red_forest_waterfall.ogv", {audio=false}),
|
|
gc_newVideo("res/backgrounds/flowers_rain.ogv", {audio=false}),
|
|
gc_newVideo("res/backgrounds/moonlight_tree.ogv", {audio=false}),
|
|
gc_newVideo("res/backgrounds/lisa_frank.ogv", {audio=false}),
|
|
gc_newVideo("res/backgrounds/snowy_trees.ogv", {audio=false}),
|
|
gc_newVideo("res/backgrounds/snowy_cabin.ogv", {audio=false}),
|
|
}
|
|
|
|
ShowLoadingText('blocks')
|
|
BLOCKS = {
|
|
["2tie"] = {
|
|
R = gc_newImage("res/img/r.png"),
|
|
O = gc_newImage("res/img/o.png"),
|
|
Y = gc_newImage("res/img/y.png"),
|
|
G = gc_newImage("res/img/g.png"),
|
|
C = gc_newImage("res/img/b.png"),
|
|
B = gc_newImage("res/img/i.png"),
|
|
M = gc_newImage("res/img/v.png"),
|
|
F = gc_newImage("res/img/bl.png"),
|
|
A = gc_newImage("res/img/bl.png"),
|
|
X = gc_newImage("res/img/t.png"),
|
|
W = gc_newImage("res/img/w.png"),
|
|
R_d = gc_newImage("res/img/r_d.png"),
|
|
O_d = gc_newImage("res/img/o_d.png"),
|
|
Y_d = gc_newImage("res/img/y_d.png"),
|
|
G_d = gc_newImage("res/img/g_d.png"),
|
|
C_d = gc_newImage("res/img/b_d.png"),
|
|
B_d = gc_newImage("res/img/i_d.png"),
|
|
M_d = gc_newImage("res/img/v_d.png"),
|
|
}
|
|
}
|
|
|
|
COLOUR_SCHEMES = {
|
|
Arika = {
|
|
I = "R",
|
|
L = "O",
|
|
J = "B",
|
|
S = "M",
|
|
Z = "G",
|
|
O = "Y",
|
|
T = "C",
|
|
}
|
|
}
|
|
|
|
-- BGMs and SFXs
|
|
ShowLoadingText('BGMs & SFXs')
|
|
local audio_newSource = love.audio.newSource
|
|
SOUNDS = {
|
|
bottom = audio_newSource("res/se/bottom.wav", "static"),
|
|
lock = audio_newSource("res/se/lock.wav", "static"),
|
|
erase = audio_newSource("res/se/erase.wav", "static"),
|
|
fall = audio_newSource("res/se/fall.wav", "static"),
|
|
ready = audio_newSource("res/se/ready.wav", "static"),
|
|
promote = audio_newSource("res/se/promote.wav", "static"),
|
|
demote = audio_newSource("res/se/demote.wav", "static"),
|
|
autopromote = audio_newSource("res/se/autopromote.wav", "static"),
|
|
bgm_firsthalf = audio_newSource("res/bgm/firsthalf.flac", "static"),
|
|
bgm_secondhalf = audio_newSource("res/bgm/secondhalf.flac", "static"),
|
|
bgm_title = audio_newSource("res/bgm/title.flac", "static")
|
|
}
|
|
|
|
function PlaySE(sound, subsound)
|
|
if sound ~= nil then
|
|
if subsound ~= nil then
|
|
SOUNDS[sound][subsound]:setVolume(0.4)
|
|
if SOUNDS[sound][subsound]:isPlaying() then
|
|
SOUNDS[sound][subsound]:stop()
|
|
end
|
|
SOUNDS[sound][subsound]:play()
|
|
else
|
|
SOUNDS[sound]:setVolume(0.4)
|
|
if SOUNDS[sound]:isPlaying() then
|
|
SOUNDS[sound]:stop()
|
|
end
|
|
SOUNDS[sound]:play()
|
|
end
|
|
end
|
|
end
|
|
|
|
function PlaySEOnce(sound, subsound)
|
|
if sound ~= nil then
|
|
if subsound ~= nil then
|
|
SOUNDS[sound][subsound]:setVolume(0.4)
|
|
if SOUNDS[sound][subsound]:isPlaying() then
|
|
return
|
|
end
|
|
SOUNDS[sound][subsound]:play()
|
|
else
|
|
SOUNDS[sound]:setVolume(0.4)
|
|
if SOUNDS[sound]:isPlaying() then
|
|
return
|
|
end
|
|
SOUNDS[sound]:play()
|
|
end
|
|
end
|
|
end
|