11-- -------------------------------
2- -- Script config
2+ -- Intro
33-- -------------------------------
44
55ScriptName = " SS_Switch2FBF"
66
7+ -- SS_Switch2FBF - Convert/translate a set of layers in a Switch group, into a series of Frame-by-Frame frames.
8+ -- version: MH12/13 001.2 #5101 - by Sam Cogheil (SimplSam)
9+
10+ --[[ ***** Licence & Warranty *****
11+
12+ This work is licensed under a GNU General Public License v3.0 license
13+ Please see: https://www.gnu.org/licenses/gpl-3.0.en.html
14+
15+ You can:
16+ Usage - Use/Reuse Freely
17+ Adapt — remix, transform, and build upon the material for any purpose, even commercially
18+ Share — copy and redistribute the material in any medium or format
19+
20+ Adapt / Share under the following terms:
21+ Attribution — You must give appropriate credit, provide a link to the GPL-3.0 license, and
22+ indicate if changes were made. You may do so in any reasonable manner, but not in any way
23+ that suggests the licensor endorses you or your use.
24+
25+ ShareAlike — If you remix, transform, or build upon the material, you must distribute your
26+ contributions under the same license as this original.
27+
28+ Warranty:
29+
30+ Your use of this software material is at your own risk.
31+
32+ By accepting to use this material you acknowledge that Sam Cogheil / SimplSam
33+ ("The Developer") make no warranties whatsoever - expressed or implied for the
34+ merchantability or fitness for a particular purpose of the software provided.
35+
36+ The Developer will not be liable for any direct, indirect or consequential loss
37+ of actual or anticipated - data, revenue, profits, business, trade or goodwill
38+ that is suffered as a result of the use of the software provided.
39+
40+ --]]
41+
42+
43+ --[[
44+ ***** SPECIAL THANKS to:
45+ * Stan (and team) @ MOHO Scripting -- http://mohoscripting.com
46+ * The friendly faces @ Lost Marble Moho forum -- https://www.lostmarble.com/forum
47+ *****
48+ ]]
49+
50+
51+ -- -------------------------------
52+ -- Script config
53+ -- -------------------------------
54+
755SS_Switch2FBF = {}
856
957function SS_Switch2FBF :Name ()
1058 return ' SS Switch to FBF'
1159end
1260
1361function SS_Switch2FBF :Version ()
14- return ' 1.1B '
62+ return ' 1.2 '
1563end
1664
1765function SS_Switch2FBF :UILabel ()
@@ -40,11 +88,10 @@ SS_Switch2FBF_Dialog.UPDATE = MOHO.MSG_BASE
4088SS_Switch2FBF_Dialog .SORTTOP = MOHO .MSG_BASE + 2
4189SS_Switch2FBF_Dialog .SORTBOT = MOHO .MSG_BASE + 4
4290
43- SS_Switch2FBF .fbf_interval = 1 -- Frame by Frame interval
44- SS_Switch2FBF .sort_by_toptobot = true -- If false Bottom to Top
45- SS_Switch2FBF .SORTBy = SS_Switch2FBF_Dialog .SORTTOP
46-
47- SS_Switch2FBF .start_frame = 1 -- 1st animation frame
91+ SS_Switch2FBF .fbfInterval = 1 -- Frame by Frame interval
92+ SS_Switch2FBF .sortByToptobot = true -- If false Bottom to Top
93+ SS_Switch2FBF .sortBy = SS_Switch2FBF_Dialog .SORTTOP
94+ SS_Switch2FBF .startFrame = 1 -- 1st animation frame
4895
4996function SS_Switch2FBF_Dialog :new (moho )
5097 local d = LM .GUI .SimpleDialog (" Switch to Frame-by-Frame configuration" , SS_Switch2FBF_Dialog )
@@ -76,16 +123,14 @@ function SS_Switch2FBF_Dialog:new(moho)
76123 l :AddChild (LM .GUI .StaticText (" - \" Which layer should be the 1st frame?\" " ), LM .GUI .ALIGN_LEFT )
77124 l :Pop ()
78125 l :Pop () -- H
79- -- d.currentframe = LM.GUI.CheckBox("Use current frame for start of FBF?...")
80- -- d.setframezero = LM.GUI.CheckBox("Set Frame zero to Switch value of start frame?...")
81126 l :Pop () -- V
82127 l :Pop () -- H
83128 return d
84129end
85130
86131function SS_Switch2FBF_Dialog :UpdateWidgets ()
87- self .interval :SetValue (SS_Switch2FBF .fbf_interval )
88- self .sortbymode :SetChecked (SS_Switch2FBF .SORTBy , true )
132+ self .interval :SetValue (SS_Switch2FBF .fbfInterval )
133+ self .sortbymode :SetChecked (SS_Switch2FBF .sortBy , true )
89134 -- self:HandleMessage(self.UPDATE)
90135end
91136
@@ -97,9 +142,9 @@ function SS_Switch2FBF_Dialog:OnValidate()
97142end
98143
99144function SS_Switch2FBF_Dialog :OnOK ()
100- SS_Switch2FBF .fbf_interval = self .interval :IntValue ()
101- SS_Switch2FBF .SORTBy = self .sortbymode :FirstCheckedMsg ()
102- SS_Switch2FBF .sort_by_toptobot = (SS_Switch2FBF .SORTBy == SS_Switch2FBF_Dialog .SORTTOP )
145+ SS_Switch2FBF .fbfInterval = self .interval :IntValue ()
146+ SS_Switch2FBF .sortBy = self .sortbymode :FirstCheckedMsg ()
147+ SS_Switch2FBF .sortByToptobot = (SS_Switch2FBF .sortBy == SS_Switch2FBF_Dialog .SORTTOP )
103148end
104149
105150
@@ -109,23 +154,23 @@ end
109154
110155function SS_Switch2FBF :Run (moho )
111156
112- local switch_layer , switch_frame , sublayer_count
113- SS_Switch2FBF .start_frame = moho .document :StartFrame ()
157+ local switchLayer , switchFrame , sublayerCount
158+ SS_Switch2FBF .startFrame = moho .document :StartFrame ()
114159
115160 local dlog = SS_Switch2FBF_Dialog :new (moho )
116161 if (dlog :DoModal () ~= LM .GUI .MSG_OK ) then
117162 return false -- Cancelled so Quit
118163 end
119164
120- switch_layer = moho :LayerAsSwitch (moho .layer )
121- switch_layer :SetFBFLayer (true )
122- sublayer_count = switch_layer :CountLayers () - 1
123- for i_sublayer = 0 , sublayer_count do
124- switch_frame = SS_Switch2FBF .start_frame + (i_sublayer * SS_Switch2FBF .fbf_interval )
125- if (SS_Switch2FBF .sort_by_toptobot ) then
126- switch_layer :SetValue (switch_frame , switch_layer :Layer (sublayer_count - i_sublayer ):Name ()) -- top to bottom
165+ switchLayer = moho :LayerAsSwitch (moho .layer )
166+ switchLayer :SetFBFLayer (true )
167+ sublayerCount = switchLayer :CountLayers () - 1
168+ for iSublayer = 0 , sublayerCount do
169+ switchFrame = SS_Switch2FBF .startFrame + (iSublayer * SS_Switch2FBF .fbfInterval )
170+ if (SS_Switch2FBF .sortByToptobot ) then
171+ switchLayer :SetValue (switchFrame , switchLayer :Layer (sublayerCount - iSublayer ):Name ()) -- top to bottom
127172 else
128- switch_layer :SetValue (switch_frame , switch_layer :Layer (i_sublayer ):Name ()) -- bottom to top
173+ switchLayer :SetValue (switchFrame , switchLayer :Layer (iSublayer ):Name ()) -- bottom to top
129174 end
130175 end
131176
0 commit comments