Skip to content

Commit e99f9f5

Browse files
committed
+Camel
1 parent 90ad573 commit e99f9f5

3 files changed

Lines changed: 81 additions & 30 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ss_switch2fbf.zip

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
# moho-switch2fbf
2-
A simple Moho tool script to convert/translate a set of layers in a Switch group, into a series of Frame-by-Frame frames.
2+
A simple Moho tool script to convert/translate a set of layers into a series of Frame-by-Frame Switched frames.
33

44
### Version ###
55

6-
* version: MH12/13 001.1B #501125.01 -- by Sam Cogheil (SimplSam)
6+
* version: MH12/13 001.2 #510130.01 -- by Sam Cogheil (SimplSam)
77
* release: n/a
88

9+
* What's New:
10+
11+
- Convert any set of selected groups/layers into a Switched FBF group
12+
- Convert any single Group containing sublayers into a Switched FBF group
13+
914
### How do I get set up ? ###
1015

1116
* To install:
12-
17+
1318
- Save the 'ss_switch2fbf.lua' and 'ss_switch2fbf.png' file/s to your computer into your custom scripts/tools folder
14-
- Reload Moho/AnimeStudio scripts (or Restart Moho)
19+
- Reload Moho/AnimeStudio scripts (or Restart Moho)
1520

1621
* To use:
1722

1823
- Ensure the target layers are grouped into a Switch layer as uniquely named sub-layers.
1924
- Select the Switch layer, and run the tool.
20-
21-
* options:
25+
26+
* options:
2227
- You can optionally (in dialog) set:
2328
* **FBF Interval:** - The Frame by Frame interval. (default: 1)
2429
* **Start with:** - The translation sort order: _Top Layer_ for Top to Bottom (top => 1st frame), _Bottom Layer_ for Bottom to Top (bot => 1st frame). (default: Top Layer)

ss_switch2fbf.lua

Lines changed: 69 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,65 @@
11
-- -------------------------------
2-
-- Script config
2+
-- Intro
33
-- -------------------------------
44

55
ScriptName = "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+
755
SS_Switch2FBF = {}
856

957
function SS_Switch2FBF:Name()
1058
return 'SS Switch to FBF'
1159
end
1260

1361
function SS_Switch2FBF:Version()
14-
return '1.1B'
62+
return '1.2'
1563
end
1664

1765
function SS_Switch2FBF:UILabel()
@@ -40,11 +88,10 @@ SS_Switch2FBF_Dialog.UPDATE = MOHO.MSG_BASE
4088
SS_Switch2FBF_Dialog.SORTTOP = MOHO.MSG_BASE+2
4189
SS_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

4996
function 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
84129
end
85130

86131
function 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)
90135
end
91136

@@ -97,9 +142,9 @@ function SS_Switch2FBF_Dialog:OnValidate()
97142
end
98143

99144
function 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)
103148
end
104149

105150

@@ -109,23 +154,23 @@ end
109154

110155
function 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

Comments
 (0)