Skip to content

Commit

Permalink
词典滚动效果优化
Browse files Browse the repository at this point in the history
  • Loading branch information
MrZ626 committed Nov 19, 2024
1 parent fe717a3 commit 67289cd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions assets/scene/dictionary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ local aboveScene
local searchTimer,lastSearchText
local time,quiting
local selected
---@class Techmino.DictContent
local contents={
_width=0,
maxScroll=0,
scroll=0,
scroll1=0,
title=GC.newText(FONT.get(30),''),
texts={},
}
Expand Down Expand Up @@ -70,6 +74,7 @@ local function selectItem(item)
contents.title=selected.titleText
contents._width,contents.texts=FONT.get(item.contentSize):getWrap(item.content,mainW-30)
contents.scroll=0
contents.scroll1=0
contents.maxScroll=126+(contents.title:getHeight()+5)-(mainH-searchH)
for i=1,#contents.texts do
local str=contents.texts[i]
Expand All @@ -91,10 +96,10 @@ local function selectItem(item)
else
contents.title="x"
contents.texts=NONE
contents.scroll=0
contents.maxScroll=0
end
contents.scroll=0
contents.scroll1=0
end
local function openLink()
if selected.link then
Expand Down Expand Up @@ -414,6 +419,7 @@ function scene.wheelMove(_,y)
end

function scene.update(dt)
contents.scroll1=MATH.expApproach(contents.scroll1,contents.scroll,dt*26)
if aboveScene.update then
aboveScene.update(dt)
end
Expand Down Expand Up @@ -485,7 +491,7 @@ function scene.draw()
gc_stc_reset()
gc_stc_rect(0,-mainH/2,mainW,mainH-searchH-5,5)
gc_setColor(categoryColor[selected.cat].content)
gc_translate(0,-contents.scroll)
gc_translate(0,-contents.scroll1)
-- Title
gc_draw(contents.title,15,-mainH/2+5,nil,math.min(1,(mainW-25)/contents.title:getWidth()),1)
gc_translate(0,contents.title:getHeight())
Expand Down

0 comments on commit 67289cd

Please sign in to comment.