This commit is contained in:
2024-05-24 22:01:27 +08:00
parent 7f124132ed
commit 3f54d1f79b
42 changed files with 11201 additions and 11796 deletions

View File

@@ -108,6 +108,7 @@ function Moveable:set_alignment(args)
args.offset = nil
end
self.alignment.offset = args.offset or self.alignment.offset
self.alignment.lr_clamp = args.lr_clamp
end
function Moveable:align_to_major()
@@ -247,6 +248,7 @@ function Moveable:drag(offset)
end
function Moveable:juice_up(amount, rot_amt)
if G.SETTINGS.reduced_motion then return end
local amount = amount or 0.4
local end_time = G.TIMERS.REAL + 0.4
@@ -275,13 +277,14 @@ end
function Moveable:move(dt)
if self.FRAME.MOVE >= G.FRAMES.MOVE then return end
self.FRAME.OLD_MAJOR = self.FRAME.MAJOR
self.FRAME.MAJOR = nil
self.FRAME.MOVE = G.FRAMES.MOVE
if not self.created_on_pause and G.SETTINGS.paused then return end
--WHY ON EARTH DOES THIS LINE MAKE IT RUN 2X AS FAST???
-------------------------------------------------------
local timestart = love.timer.getTime()
--local timestart = love.timer.getTime()
-------------------------------------------------------
self:align_to_major()
@@ -309,9 +312,20 @@ function Moveable:move(dt)
self:move_wh(dt)
self:calculate_parrallax()
end
if self.alignment and self.alignment.lr_clamp then
self:lr_clamp()
end
self.NEW_ALIGNMENT = false
end
function Moveable:lr_clamp()
if self.T.x < 0 then self.T.x = 0 end
if self.VT.x < 0 then self.VT.x = 0 end
if (self.T.x + self.T.w) > G.ROOM.T.w then self.T.x = G.ROOM.T.w - self.T.w end
if (self.VT.x + self.VT.w) > G.ROOM.T.w then self.VT.x = G.ROOM.T.w - self.VT.w end
end
function Moveable:glue_to_major(major_tab)
self.T = major_tab.T
@@ -326,21 +340,19 @@ function Moveable:glue_to_major(major_tab)
self.shadow_parrallax = major_tab.shadow_parrallax
end
MWM = {
rotated_offset = {},
angles = {},
WH = {},
offs = {},
}
function Moveable:move_with_major(dt)
if self.role.role_type ~= 'Minor' then return end
local major_tab = self.role.major:get_major()
self:move_juice(dt)
if not MWM then
MWM = {
rotated_offset = {},
angles = {},
WH = {},
offs = {},
}
end
if self.role.r_bond == 'Weak' then
MWM.rotated_offset.x, MWM.rotated_offset.y = self.role.offset.x + major_tab.offset.x,self.role.offset.y+major_tab.offset.y
else
@@ -471,10 +483,11 @@ function Moveable:get_major()
if ( self.role.role_type ~= 'Major' and self.role.major ~= self) and (self.role.xy_bond ~= 'Weak' and self.role.r_bond ~= 'Weak') then
--First, does the major already have their offset precalculated for this frame?
if not self.FRAME.MAJOR or (G.REFRESH_FRAME_MAJOR_CACHE) then
self.FRAME.MAJOR = EMPTY(self.FRAME.MAJOR)
self.FRAME.MAJOR = self.FRAME.MAJOR or EMPTY(self.FRAME.OLD_MAJOR)
self.temp_offs = EMPTY(self.temp_offs)
local major = self.role.major:get_major()
self.FRAME.MAJOR.major = major.major
self.FRAME.MAJOR.offset = self.FRAME.MAJOR.offset or {}
self.FRAME.MAJOR.offset = self.FRAME.MAJOR.offset or self.temp_offs
self.FRAME.MAJOR.offset.x, self.FRAME.MAJOR.offset.y = major.offset.x + self.role.offset.x + self.layered_parallax.x, major.offset.y + self.role.offset.y + self.layered_parallax.y
end
return self.FRAME.MAJOR
@@ -488,14 +501,16 @@ function Moveable:get_major()
end
function Moveable:remove()
for k, v in ipairs(G.MOVEABLES) do
for k, v in pairs(G.MOVEABLES) do
if v == self then
table.remove(G.MOVEABLES, k)
break;
end
end
for k, v in ipairs(G.I.MOVEABLE) do
for k, v in pairs(G.I.MOVEABLE) do
if v == self then
table.remove(G.I.MOVEABLE, k)
break;
end
end
Node.remove(self)

View File

@@ -318,19 +318,19 @@ end
--Also calls the remove method of all children to have them do the same
function Node:remove()
for k, v in ipairs(G.I.POPUP) do
for k, v in pairs(G.I.POPUP) do
if v == self then
table.remove(G.I.POPUP, k)
break;
end
end
for k, v in ipairs(G.I.NODE) do
for k, v in pairs(G.I.NODE) do
if v == self then
table.remove(G.I.NODE, k)
break;
end
end
for k, v in ipairs(G.STAGE_OBJECTS[G.STAGE]) do
for k, v in pairs(G.STAGE_OBJECTS[G.STAGE]) do
if v == self then
table.remove(G.STAGE_OBJECTS[G.STAGE], k)
break;

View File

@@ -71,6 +71,7 @@ function Sprite:define_draw_steps(draw_step_definitions)
end
function Sprite:draw_shader(_shader, _shadow_height, _send, _no_tilt, other_obj, ms, mr, mx, my, custom_shader, tilt_shadow)
if G.SETTINGS.reduced_motion then _no_tilt = true end
local _draw_major = self.role.draw_major or self
if _shadow_height then
self.VT.y = self.VT.y - _draw_major.shadow_parrallax.y*_shadow_height

View File

@@ -212,27 +212,27 @@ function DynaText:align_letters()
end
letter.r = 0
letter.scale = 1
if self.config.rotate then letter.r = (self.config.rotate == 2 and -1 or 1)*(0.2*(-#self.strings[self.focused_string].letters/2 - 0.5 + k)/(#self.strings[self.focused_string].letters)+ 0.02*math.sin(2*G.TIMERS.REAL+k)) end
if self.config.rotate then letter.r = (self.config.rotate == 2 and -1 or 1)*(0.2*(-#self.strings[self.focused_string].letters/2 - 0.5 + k)/(#self.strings[self.focused_string].letters)+ (G.SETTINGS.reduced_motion and 0 or 1)*0.02*math.sin(2*G.TIMERS.REAL+k)) end
if self.config.pulse then
letter.scale = letter.scale + (1/self.config.pulse.width)*self.config.pulse.amount*(math.max(
letter.scale = letter.scale + (G.SETTINGS.reduced_motion and 0 or 1)*(1/self.config.pulse.width)*self.config.pulse.amount*(math.max(
math.min((self.config.pulse.start - G.TIMERS.REAL)*self.config.pulse.speed + k + self.config.pulse.width,
(G.TIMERS.REAL - self.config.pulse.start)*self.config.pulse.speed - k + self.config.pulse.width+ 2),
0))
letter.r = letter.r + (letter.scale - 1)*(0.02*(-#self.strings[self.focused_string].letters/2 - 0.5 + k))
letter.r = letter.r + (G.SETTINGS.reduced_motion and 0 or 1)*(letter.scale - 1)*(0.02*(-#self.strings[self.focused_string].letters/2 - 0.5 + k))
if self.config.pulse.start > G.TIMERS.REAL + 2*self.config.pulse.speed*#self.strings[self.focused_string].letters then
self.config.pulse = nil
end
end
if self.config.quiver then
letter.scale = letter.scale + (0.1*self.config.quiver.amount)
letter.r = letter.r + 0.3*self.config.quiver.amount*(
letter.scale = letter.scale + (G.SETTINGS.reduced_motion and 0 or 1)*(0.1*self.config.quiver.amount)
letter.r = letter.r + (G.SETTINGS.reduced_motion and 0 or 1)*0.3*self.config.quiver.amount*(
math.sin(41.12342*G.TIMERS.REAL*self.config.quiver.speed + k*1223.2) +
math.cos(63.21231*G.TIMERS.REAL*self.config.quiver.speed + k*1112.2)*math.sin(36.1231*G.TIMERS.REAL*self.config.quiver.speed) +
math.cos(95.123*G.TIMERS.REAL*self.config.quiver.speed + k*1233.2) -
math.sin(30.133421*G.TIMERS.REAL*self.config.quiver.speed + k*123.2))
end
if self.config.float then letter.offset.y = math.sqrt(self.scale)*(2+(self.font.FONTSCALE/G.TILESIZE)*2000*math.sin(2.666*G.TIMERS.REAL+200*k)) + 60*(letter.scale-1) end
if self.config.bump then letter.offset.y = self.bump_amount*math.sqrt(self.scale)*7*math.max(0, (5+self.bump_rate)*math.sin(self.bump_rate*G.TIMERS.REAL+200*k) - 3 - self.bump_rate) end
if self.config.float then letter.offset.y = (G.SETTINGS.reduced_motion and 0 or 1)*math.sqrt(self.scale)*(2+(self.font.FONTSCALE/G.TILESIZE)*2000*math.sin(2.666*G.TIMERS.REAL+200*k)) + 60*(letter.scale-1) end
if self.config.bump then letter.offset.y = (G.SETTINGS.reduced_motion and 0 or 1)*self.bump_amount*math.sqrt(self.scale)*7*math.max(0, (5+self.bump_rate)*math.sin(self.bump_rate*G.TIMERS.REAL+200*k) - 3 - self.bump_rate) end
end
end

View File

@@ -34,7 +34,8 @@ function UIBox:init(args)
major = args.config.major,
type = args.config.align or args.config.type or '',
bond = args.config.bond or 'Strong',
offset = args.config.offset or {x=0,y=0}
offset = args.config.offset or {x=0,y=0},
lr_clamp = args.config.lr_clamp
})
self:set_role{
xy_bond = args.config.xy_bond,
@@ -82,6 +83,10 @@ function UIBox:init(args)
self.VT.x = self.VT.x - self.Mid.role.offset.x + (self.Mid.parent.config.padding or 0)
self.VT.y = self.VT.y - self.Mid.role.offset.y + (self.Mid.parent.config.padding or 0)
end
if self.alignment and self.alignment.lr_clamp then
self:lr_clamp()
end
self.UIRoot:initialize_VT(true)
if getmetatable(self) == UIBox then
@@ -268,6 +273,7 @@ function UIBox:remove()
for k, v in pairs(G.I[self.config.instance_type or 'UIBOX']) do
if v == self then
table.remove(G.I[self.config.instance_type or 'UIBOX'], k)
break;
end
end
remove_all(self.children)
@@ -682,7 +688,6 @@ function UIElement:draw_self()
if self.config.button_UIE and not self.config.button_UIE.config.button then button_active = false end
end
if self.config.colour[4] > 0.01 then
if self.UIT == G.UIT.T and self.config.scale then
self.ARGS.text_parallax = self.ARGS.text_parallax or {}