-
Notifications
You must be signed in to change notification settings - Fork 0
/
storyboard.lua
executable file
·182 lines (121 loc) · 3.22 KB
/
storyboard.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
--TODO store stamps by line ,
-- and render whole project
local widgets={}
local stamps={}
local boardWidth=math.floor(uiw*0.8)
--local defaultStampW= math.floor( boardWidth/32 )
local defaultStampW= math.floor( boardWidth/8 )
local defaultStampH= math.floor(defaultStampW*conf.cvsh/conf.cvsw)
local stampZoom= defaultStampW/conf.cvsw
--when the algorithm below
function allocateStamp(x,frame,line)
stamp={}
stamp.x=x
-- stamp.y=y
stamp.w=frame.tc*defaultStampW
stamp.h=defaultStampH
stamp.pic=frame.pic
stamp.tc=frame.tc
table.insert(line,stamp)
end
--we build a representation of the stamps to be displayed,
--taking into account the width to fill,
--and the height of the screen
function maintainStamps()
stamps={}
--we start at line 0
--TODO handle width
--TODO start at current idx
local tx=0
-- local ty=0
-- y not relevant, we use line info
currentLine={}
lineNumber=1
stamps[lineNumber]=currentLine
for i=1,maxframe
do
frame=frames[i]
if frame.tc>0 then
--TODO allocation code duplicated mmmm
if tx+(defaultStampW*frame.tc)<boardWidth then
--we use the space
allocateStamp(tx,frame,currentLine)
tx=tx+defaultStampW*frame.tc
else
-- ty=ty+defaultStampH
tx=0
lineNumber=lineNumber+1
currentLine={}
stamps[lineNumber]=currentLine
-- if ty>uih then return end
--then we use the space
allocateStamp(tx,frame,currentLine)
tx=tx+defaultStampW*frame.tc
end
end
end
end
function storyBoardKey(key, code, isrepeat)
if key=="enter" then
print('enter')
toPaintMode()
return
end
end
function toStoryboard()
print('to story board ')
maintainStamps()
keyFunc=storyBoardKey
drawFunc=drawStoryboard
updateFunc=updateStoryboard
end
local function renderStamps()
local ly=0
for i,l in ipairs(stamps)
do
for j,s in ipairs(l)
do
love.graphics.setColor(1.0,0.0,0.0,1.0)
love.graphics.rectangle('line',s.x,ly*defaultStampH,s.w,s.h)
love.graphics.setColor(1.0,1.0,1.0,1.0)
for k=1,s.tc
do
love.graphics.draw(s.pic,s.x+defaultStampW*k,ly*defaultStampH,0,stampZoom,stampZoom)
end
end
ly=ly+1
end
end
--external hook for preview save
function renderProjectPreviewToCurrentCvs()
--WIP might have extra logic in the feature,such as screen index for long
--projects with multiple sb screens
maintainStamps()
renderStamps()
end
local function rendertouicanvas()
love.graphics.setCanvas(ui)
love.graphics.clear(1.0,1.0,1.0,0.0)
love.graphics.setColor(1.0,1.0,1.0,1.0)
-- love.graphics.draw(frames[2].pic)
-- love.graphics.draw(frames[2].pic,0,0,0,0.1,0.1)
--not sure if stamps should be widgets,
-- as selection is across stamps
renderStamps()
renderWidgets(widgets)
msgToCvs()
love.graphics.setCanvas()
end
function drawStoryboard()
-- love.graphics.draw(buttonsPic)
rendertouicanvas()
--this is the background image of our paint
love.graphics.clear(1.,1.,1.,1.0)
love.graphics.setColor(1.0,1.0,1.0,1.0)
love.graphics.draw(ui,0,0,0,scrsx,scrsy)
end
function updateStoryboard()
if npress==true then
print('storyboard click ')
end
end