@@ -3,8 +3,8 @@ function plugindef()
3
3
finaleplugin .Author = " Jacob Winkler"
4
4
finaleplugin .Copyright = " ©2024 Jacob Winkler"
5
5
finaleplugin .
AuthorEmail = " [email protected] "
6
- finaleplugin .Date = " 2024/1/21 "
7
- finaleplugin .Version = " 1.1 "
6
+ finaleplugin .Date = " 2024/1/25 "
7
+ finaleplugin .Version = " 1.2 "
8
8
finaleplugin .HandlesUndo = true
9
9
finaleplugin .NoStore = false
10
10
finaleplugin .MinJWLuaVersion = 0.70 -- https://robertgpatterson.com/-fininfo/-rgplua/rgplua.html
@@ -83,13 +83,14 @@ function bold_control(control)
83
83
control :SetFont (font )
84
84
end
85
85
86
- function math . sign (number )
86
+ function math_sign (number )
87
87
return (number >= 0 and 1 ) or - 1
88
88
end
89
89
90
- function math .round (number , round_to )
90
+ function math_round (number , round_to )
91
+ number = number or 0
91
92
round_to = round_to or 1
92
- return math.floor (number / round_to + math .sign (number ) * 0.5 ) * round_to
93
+ return math.floor (math.abs (number )/ round_to + 0.5 ) * round_to * math_sign ( number )
93
94
end
94
95
95
96
local function mm_to_efix (mm )
@@ -111,7 +112,7 @@ local function efix_to_mm_string(efix)
111
112
str :SetMeasurement (efix / 64 * 10 , finale .MEASUREMENTUNIT_CENTIMETERS )
112
113
-- str.LuaString = efix * (25.4 / 18432)
113
114
local temp = str .LuaString
114
- temp = math . round (tonumber (temp ), .1 )
115
+ temp = math_round (tonumber (temp ), .1 )
115
116
str .LuaString = tostring (temp )
116
117
return str
117
118
end
@@ -188,8 +189,8 @@ local special_ctrls = {}
188
189
local special_ctrls_collection = {}
189
190
190
191
local function match_page (w , h )
191
- w = math . round (w , 1 )
192
- h = math . round (h , 1 )
192
+ w = math_round (w , 1 )
193
+ h = math_round (h , 1 )
193
194
local matched = - 1
194
195
local landscape = 0
195
196
for k , v in pairs (page_sizes ) do
@@ -258,11 +259,6 @@ local function orientation_set(w, h, mode) -- mode 0 is portrait, mode 1 is land
258
259
else
259
260
return h , w
260
261
end
261
- if mode == 1 and w > h then
262
- return w , h
263
- else
264
- return h , w
265
- end
266
262
end
267
263
268
264
local function orientation_set_popup (w , h , popup )
@@ -536,7 +532,7 @@ local function format_wizard()
536
532
controls .first_system_left_edit :SetMeasurement (page_settings .first_system_left_margin , page_settings .system_units )
537
533
controls .system_bottom_edit :SetMeasurement (page_settings .system_bottom_margin - 96 , page_settings .system_units ) -- bottom margin is offset by 4 spaces (96 EVPUs) because Finale...
538
534
--[[ STAFF HEIGHT ]]
539
- temp = math . round (efix_to_mm (page_settings .staff_h )* 10 , 1 )
535
+ temp = math_round (efix_to_mm (page_settings .staff_h )* 10 , 1 )
540
536
controls .staff_h_invisible :SetInteger (temp )
541
537
controls .staff_h_updown :SetValue (temp )
542
538
controls .staff_h_edit :SetText (efix_to_mm_string (page_settings .staff_h ))
@@ -652,7 +648,6 @@ local function format_wizard()
652
648
653
649
local function format_pages_and_save ()
654
650
local controls = {}
655
- local page_settings = {}
656
651
657
652
local score_format_prefs = finale .FCPageFormatPrefs ()
658
653
local parts_format_prefs = finale .FCPageFormatPrefs ()
@@ -730,7 +725,7 @@ local function format_wizard()
730
725
731
726
local function check_for_special (part_num )
732
727
for i = 0 , special_ctrls .parts_datalist :GetCount ()- 1 do
733
- local row = special_ctrls .parts_datalist :GetItemAt (i )
728
+ row = special_ctrls .parts_datalist :GetItemAt (i )
734
729
str = row :GetItemAt (1 )
735
730
if part_num == tonumber (str .LuaString ) then
736
731
if row :GetCheck () then
@@ -834,9 +829,7 @@ local function format_wizard()
834
829
--
835
830
staff_height_set (system , page_settings .staff_h )
836
831
837
- if controls .staff_spacing_popup :GetSelectedItem () == 0 then
838
- -- Do nothing!
839
- else
832
+ if controls .staff_spacing_popup :GetSelectedItem () > 0 then
840
833
local sysstaves = finale .FCSystemStaves ()
841
834
sysstaves :LoadAllForItem (system :GetItemNo ())
842
835
@@ -993,7 +986,7 @@ local function format_wizard()
993
986
local special_static = add_ctrl (dialog , " static" , " SPECIAL PARTS" , x + 12 , 0 , col_w , row_h )
994
987
995
988
996
- local function section_create (controls , page_settings , ctrls_collection , section_n )
989
+ local function section_create (controls , page_settings , ctrls_collection )
997
990
row = 1
998
991
y = row * row_h
999
992
x = section_n * section_w
@@ -1240,7 +1233,7 @@ local function format_wizard()
1240
1233
controls .staff_h_updown :ConnectIntegerEdit (controls .staff_h_invisible , 30 , 100 )
1241
1234
controls .staff_h_mm_static = add_ctrl (dialog , " static" , " mm" , x + col [4 ]+ 12 , y , 20 , row_h )
1242
1235
-- Initialize the staff height edit boxes, starting with the invisible one connected to the UpDown
1243
- temp = math . round (efix_to_mm (page_settings .staff_h )* 10 , .1 )
1236
+ temp = math_round (efix_to_mm (page_settings .staff_h )* 10 , .1 )
1244
1237
controls .staff_h_invisible :SetInteger (temp ,1 )
1245
1238
controls .staff_h_edit :SetText (efix_to_mm_string (page_settings .staff_h ))
1246
1239
controls .staff_h_updown :SetValue (controls .staff_h_invisible :GetInteger ())
@@ -1311,7 +1304,7 @@ local function format_wizard()
1311
1304
for part in each (parts ) do
1312
1305
if part :IsPart () then
1313
1306
part :GetName (str )
1314
- local row = controls .parts_datalist :CreateRow ()
1307
+ row = controls .parts_datalist :CreateRow ()
1315
1308
row :GetItemAt (0 ).LuaString = str .LuaString
1316
1309
row :GetItemAt (1 ).LuaString = part :GetItemNo ()
1317
1310
end
@@ -1400,10 +1393,15 @@ local function format_wizard()
1400
1393
return controls , page_settings , ctrls_collection
1401
1394
end -- section_create()
1402
1395
1403
- score_ctrls , score_settings , score_ctrls_collection = section_create (score_ctrls , score_settings , score_ctrls_collection , 0 )
1404
- parts_ctrls , parts_settings , parts_ctrls_collection = section_create (parts_ctrls , parts_settings , parts_ctrls_collection , 1 )
1405
- special_ctrls , special_settings , special_ctrls_collection = section_create (special_ctrls , special_settings , special_ctrls_collection , 2 )
1406
-
1396
+ section_n = 0
1397
+ score_ctrls , score_settings , score_ctrls_collection = section_create (score_ctrls , score_settings , score_ctrls_collection )
1398
+ section_n = 1
1399
+ --
1400
+ parts_ctrls , parts_settings , parts_ctrls_collection = section_create (parts_ctrls , parts_settings , parts_ctrls_collection )
1401
+ section_n = 2
1402
+ --
1403
+ special_ctrls , special_settings , special_ctrls_collection = section_create (special_ctrls , special_settings , special_ctrls_collection )
1404
+ --
1407
1405
section_enable (score_enable_checkbox , score_ctrls , score_settings , score_ctrls_collection )
1408
1406
section_enable (parts_enable_checkbox , parts_ctrls , parts_settings , parts_ctrls_collection )
1409
1407
section_enable (special_enable_checkbox , special_ctrls , special_settings , special_ctrls_collection )
@@ -1677,7 +1675,7 @@ local function format_wizard()
1677
1675
if not hold then
1678
1676
hold = true
1679
1677
page_settings .staff_h = mm_to_efix (controls .staff_h_edit :GetMeasurement (finale .MEASUREMENTUNIT_MILLIMETERS ))
1680
- temp = math . round (controls .staff_h_edit :GetMeasurement (finale .MEASUREMENTUNIT_MILLIMETERS )* 10 , 1 )
1678
+ temp = math_round (controls .staff_h_edit :GetMeasurement (finale .MEASUREMENTUNIT_MILLIMETERS )* 10 , 1 )
1681
1679
controls .staff_h_invisible :SetInteger (temp )
1682
1680
controls .staff_h_updown :SetValue (temp )
1683
1681
hold = false
@@ -1766,7 +1764,7 @@ local function format_wizard()
1766
1764
1767
1765
dialog :RegisterHandleControlEvent (controls .clear_datalist_button , function (control )
1768
1766
for i = 0 , controls .parts_datalist :GetCount ()- 1 do
1769
- local row = controls .parts_datalist :GetItemAt (i )
1767
+ row = controls .parts_datalist :GetItemAt (i )
1770
1768
row :SetCheck (false )
1771
1769
end
1772
1770
end )
@@ -1858,7 +1856,6 @@ local function format_wizard()
1858
1856
bold_control (score_ctrls .staff_settings )
1859
1857
bold_control (parts_ctrls .staff_settings )
1860
1858
bold_control (special_ctrls .staff_settings )
1861
- -- finale.FCFileSaveAsDialog(finenv.UI()):GetFileName(str)
1862
1859
end
1863
1860
1864
1861
format_wizard ()
0 commit comments