mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
Update modules
This commit is contained in:
@@ -133,10 +133,9 @@ function Grid:applyPiece(piece)
|
||||
self:applyBigPiece(piece)
|
||||
return
|
||||
end
|
||||
offsets = piece:getBlockOffsets()
|
||||
for index, offset in pairs(offsets) do
|
||||
x = piece.position.x + offset.x
|
||||
y = piece.position.y + offset.y
|
||||
for index, offset in pairs(piece:getBlockOffsets()) do
|
||||
local x = piece.position.x + offset.x
|
||||
local y = piece.position.y + offset.y
|
||||
if y + 1 > 0 and y < self.height then
|
||||
self.grid[y+1][x+1] = {
|
||||
skin = piece.skin,
|
||||
|
||||
@@ -137,15 +137,16 @@ local global_toggle=false
|
||||
VCTRL={}
|
||||
VCTRL.focus=nil -- Focusing buttons
|
||||
|
||||
---@type table
|
||||
---@class VCTRL.data
|
||||
---@field type string
|
||||
---@field type 'button'
|
||||
---@field x number
|
||||
---@field y number
|
||||
---@field shape string
|
||||
---@field key string
|
||||
---@field iconSize number
|
||||
---@field alpha number
|
||||
---@field show boolean
|
||||
---@field shape? string
|
||||
---@field key? string
|
||||
---@field iconSize? number
|
||||
---@field alpha? number
|
||||
---@field show? boolean
|
||||
|
||||
---@param ... VCTRL.data
|
||||
---Adding (multiple) virtual button(s)
|
||||
|
||||
@@ -17,7 +17,7 @@ local function checkColorTableValidation(C)
|
||||
end
|
||||
|
||||
---@class BUTTON.button
|
||||
---@field text? string # Name of the button, will be used to show
|
||||
---@field text? string|function # Name of the button, will be used to show
|
||||
---@field textOrientation? "center"|"justify"|"left"|"right"
|
||||
---
|
||||
---@field x? number # Position of the button (x, y, w, h)
|
||||
@@ -86,14 +86,16 @@ function button:draw()
|
||||
love.graphics.setColor(self.textColor)
|
||||
love.graphics.setFont(self.font)
|
||||
|
||||
local text = type(self.text) == 'function' and self.text() or self.text
|
||||
|
||||
local lineAmount
|
||||
do
|
||||
local _, t = self.font:getWrap(self.text, self.w)
|
||||
local _, t = self.font:getWrap(text, self.w)
|
||||
lineAmount = #t
|
||||
end
|
||||
local textHeight = self.font:getHeight() * (lineAmount * 0.5)
|
||||
local textPos = self.y + (self.h * 0.5) - textHeight
|
||||
love.graphics.printf(self.text, self.x, textPos, self.w, self.textOrientation)
|
||||
love.graphics.printf(text, self.x, textPos, self.w, self.textOrientation)
|
||||
|
||||
love.graphics.setColor(self.borderColor)
|
||||
love.graphics.rectangle('line', self.x, self.y, self.w, self.h, self.r)
|
||||
@@ -150,7 +152,11 @@ local BUTTON = {}
|
||||
---***WARNING! THIS FUNCTION WILL RAISE EXCEPTION IF DATA IS INVALID!***
|
||||
function BUTTON.checkDataValidation(D, safe)
|
||||
if not safe then
|
||||
assert(type(D.text) == "string","[text] is missing, or you just passed an empty data?")
|
||||
if type(D.text) == 'function' then
|
||||
assert(type(D.text()) == 'string', "[text] is a function but it doesn't return any string?!")
|
||||
elseif type(D.text) ~= 'string' then
|
||||
error("[text] must be a string or a function returns string, got "..type(D.text))
|
||||
end
|
||||
|
||||
assert(type(D.x) == "number" , "[x] must be a integer")
|
||||
assert(type(D.y) == "number" , "[y] must be a integer")
|
||||
@@ -178,7 +184,7 @@ function BUTTON.checkDataValidation(D, safe)
|
||||
end
|
||||
|
||||
---@class BUTTON.newData
|
||||
---@field text string # Name of the button, will be used to show
|
||||
---@field text string|function # Name of the button, will be used to show. If function provided, it should return the string!
|
||||
---@field textOrientation? "center"|"justify"|"left"|"right"
|
||||
---
|
||||
---@field x number # Position of the button (x, y, w, h)
|
||||
@@ -210,6 +216,8 @@ end
|
||||
---@nodiscard
|
||||
---Create a new button, provide you a table with 4 functions inside: draw and update, press and release<br>
|
||||
---You need to put them into intended callbacks :)
|
||||
---
|
||||
---Remember to fill 5 necessary parameters: name, x, y, w and h
|
||||
function BUTTON.new(D)
|
||||
local B = setmetatable(D, button)
|
||||
BUTTON.checkDataValidation(B)
|
||||
@@ -231,7 +239,7 @@ end
|
||||
-- < EXTRA GENERAL OPTIONS >
|
||||
|
||||
---Draw all buttons in provided list
|
||||
---@param list table<BUTTON.button>
|
||||
---@param list table<any,BUTTON.button>
|
||||
function BUTTON.draw(list)
|
||||
for _, v in pairs(list) do v:draw() end
|
||||
end
|
||||
|
||||
11
load.lua
11
load.lua
@@ -1,6 +1,7 @@
|
||||
-- Bigint library
|
||||
bigint = require "libs.bigint.bigint"
|
||||
number_names = require "libs.bigint.named-powers-of-ten"
|
||||
require "libs.simple-slider"
|
||||
|
||||
-- Fonts
|
||||
FONT_tromi = love.graphics.newFont('res/fonts/monofonto rg.otf', 28)
|
||||
@@ -25,13 +26,15 @@ BUTTON.setDefaultOption{
|
||||
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(self.text, self.w * 2)
|
||||
_, t = FONT_big:getWrap(text, self.w * 2)
|
||||
else
|
||||
_, t = FONT_tromi:getWrap(self.text, self.w * 2)
|
||||
_, t = FONT_tromi:getWrap(text, self.w * 2)
|
||||
end
|
||||
lineAmount = #t
|
||||
end
|
||||
@@ -42,9 +45,9 @@ BUTTON.setDefaultOption{
|
||||
local textPos = self.y + (self.h * 0.5) - textHeight
|
||||
|
||||
if need_big_font then
|
||||
drawBigText(self.text, self.x, textPos, self.w, 'center')
|
||||
drawBigText(text, self.x, textPos, self.w, 'center')
|
||||
else
|
||||
drawText(self.text, self.x, textPos, self.w, 'center')
|
||||
drawText(text, self.x, textPos, self.w, 'center')
|
||||
end
|
||||
|
||||
love.graphics.setColor(1, 1, 1, 0.8)
|
||||
|
||||
21
main.lua
21
main.lua
@@ -1,9 +1,6 @@
|
||||
if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE")=="1" then
|
||||
lldebugger=require('lldebugger')
|
||||
lldebugger.start()
|
||||
REQUEST_BREAK=lldebugger.requestBreak
|
||||
else
|
||||
REQUEST_BREAK=function()end
|
||||
LLDEBUGGER=require('lldebugger')
|
||||
LLDEBUGGER.start()
|
||||
end
|
||||
|
||||
require 'funcs'
|
||||
@@ -97,10 +94,9 @@ function love.draw()
|
||||
love.graphics.push()
|
||||
|
||||
SCENE:render()
|
||||
|
||||
-- -- Grid system
|
||||
-- local grid_width, grid_height = 40, 20
|
||||
-- love.graphics.replaceTransform(GLOBAL_TRANSFORM)
|
||||
|
||||
-- love.graphics.setColor(1,1,1,0.5)
|
||||
-- love.graphics.setLineWidth(1)
|
||||
-- -- From 0 to X
|
||||
@@ -112,6 +108,15 @@ function love.draw()
|
||||
-- love.graphics.line(0, grid_height * iy, 640, grid_height * iy)
|
||||
-- end
|
||||
|
||||
local x, y = GLOBAL_TRANSFORM:inverseTransformPoint(love.mouse.getPosition())
|
||||
love.graphics.setColor(0, 0, 0, 0.8)
|
||||
love.graphics.rectangle("fill", 5, 450, 115, 25)
|
||||
drawText(string.format("X: %.1d; Y: %.1d", x, y), 10, 455, 110, "left")
|
||||
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.setLineWidth(2)
|
||||
love.graphics.rectangle("line", 0, 0, 640, 480)
|
||||
|
||||
love.graphics.pop()
|
||||
end
|
||||
|
||||
@@ -361,7 +366,7 @@ function love.run()
|
||||
end
|
||||
|
||||
function love.errorhandler(msg)
|
||||
local msg = msg or "REV! BÀ ĂN CÁI TỜ TIN NHẮN LỖI RỒI À?!"
|
||||
local msg = msg or "I don't know if mycophobia's real name is \"mycophobiatrophilusiania\" or not.\nBUT WHO ATE THE ERROR MESSAGE?! DTET_ENJOYER, DID YOU?\n"
|
||||
local showScreenshot = false
|
||||
local errorCopied = false
|
||||
local enter_fullscreen = SETTINGS and SETTINGS["fullscreen"] or false
|
||||
|
||||
Reference in New Issue
Block a user