@@ -295,8 +295,8 @@ function plugindef()
295
295
finaleplugin .Author = " Jacob Winkler"
296
296
finaleplugin .Copyright = " ©2024 Jacob Winkler"
297
297
finaleplugin .AuthorEmail = " jacob.winkler@mac.com"
298
- finaleplugin .Date = " 2024/1/21 "
299
- finaleplugin .Version = " 1.1 "
298
+ finaleplugin .Date = " 2024/1/25 "
299
+ finaleplugin .Version = " 1.2 "
300
300
finaleplugin .HandlesUndo = true
301
301
finaleplugin .NoStore = false
302
302
finaleplugin .MinJWLuaVersion = 0.70
@@ -370,12 +370,13 @@ function bold_control(control)
370
370
font :SetBold (true )
371
371
control :SetFont (font )
372
372
end
373
- function math . sign (number )
373
+ function math_sign (number )
374
374
return (number >= 0 and 1 ) or - 1
375
375
end
376
- function math .round (number , round_to )
376
+ function math_round (number , round_to )
377
+ number = number or 0
377
378
round_to = round_to or 1
378
- return math.floor (number / round_to + math .sign (number ) * 0.5 ) * round_to
379
+ return math.floor (math.abs (number )/ round_to + 0.5 ) * round_to * math_sign ( number )
379
380
end
380
381
local function mm_to_efix (mm )
381
382
local efix = mm * (18432 / 25.4 )
392
393
local function efix_to_mm_string (efix )
393
394
str :SetMeasurement (efix / 64 * 10 , finale .MEASUREMENTUNIT_CENTIMETERS )
394
395
local temp = str .LuaString
395
- temp = math . round (tonumber (temp ), .1 )
396
+ temp = math_round (tonumber (temp ), .1 )
396
397
str .LuaString = tostring (temp )
397
398
return str
398
399
end
@@ -459,8 +460,8 @@ local special_enable_checkbox
459
460
local special_ctrls = {}
460
461
local special_ctrls_collection = {}
461
462
local function match_page (w , h )
462
- w = math . round (w , 1 )
463
- h = math . round (h , 1 )
463
+ w = math_round (w , 1 )
464
+ h = math_round (h , 1 )
464
465
local matched = - 1
465
466
local landscape = 0
466
467
for k , v in pairs (page_sizes ) do
@@ -527,11 +528,6 @@ local function orientation_set(w, h, mode)
527
528
else
528
529
return h , w
529
530
end
530
- if mode == 1 and w > h then
531
- return w , h
532
- else
533
- return h , w
534
- end
535
531
end
536
532
local function orientation_set_popup (w , h , popup )
537
533
if not hold then
@@ -769,7 +765,7 @@ local function format_wizard()
769
765
controls .first_system_left_edit :SetMeasurement (page_settings .first_system_left_margin , page_settings .system_units )
770
766
controls .system_bottom_edit :SetMeasurement (page_settings .system_bottom_margin - 96 , page_settings .system_units )
771
767
772
- temp = math . round (efix_to_mm (page_settings .staff_h )* 10 , 1 )
768
+ temp = math_round (efix_to_mm (page_settings .staff_h )* 10 , 1 )
773
769
controls .staff_h_invisible :SetInteger (temp )
774
770
controls .staff_h_updown :SetValue (temp )
775
771
controls .staff_h_edit :SetText (efix_to_mm_string (page_settings .staff_h ))
@@ -870,7 +866,6 @@ local function format_wizard()
870
866
end
871
867
local function format_pages_and_save ()
872
868
local controls = {}
873
- local page_settings = {}
874
869
local score_format_prefs = finale .FCPageFormatPrefs ()
875
870
local parts_format_prefs = finale .FCPageFormatPrefs ()
876
871
parts_format_prefs :LoadParts ()
@@ -936,7 +931,7 @@ local function format_wizard()
936
931
end
937
932
local function check_for_special (part_num )
938
933
for i = 0 , special_ctrls .parts_datalist :GetCount ()- 1 do
939
- local row = special_ctrls .parts_datalist :GetItemAt (i )
934
+ row = special_ctrls .parts_datalist :GetItemAt (i )
940
935
str = row :GetItemAt (1 )
941
936
if part_num == tonumber (str .LuaString ) then
942
937
if row :GetCheck () then
@@ -1027,9 +1022,7 @@ local function format_wizard()
1027
1022
end
1028
1023
1029
1024
staff_height_set (system , page_settings .staff_h )
1030
- if controls .staff_spacing_popup :GetSelectedItem () == 0 then
1031
-
1032
- else
1025
+ if controls .staff_spacing_popup :GetSelectedItem () > 0 then
1033
1026
local sysstaves = finale .FCSystemStaves ()
1034
1027
sysstaves :LoadAllForItem (system :GetItemNo ())
1035
1028
local last_staff_pos = 0
@@ -1162,7 +1155,7 @@ local function format_wizard()
1162
1155
special_enable_checkbox = add_ctrl (dialog , " checkbox" , " " , x , 0 , 10 , 10 )
1163
1156
special_enable_checkbox :SetCheck (config .special_enable )
1164
1157
local special_static = add_ctrl (dialog , " static" , " SPECIAL PARTS" , x + 12 , 0 , col_w , row_h )
1165
- local function section_create (controls , page_settings , ctrls_collection , section_n )
1158
+ local function section_create (controls , page_settings , ctrls_collection )
1166
1159
row = 1
1167
1160
y = row * row_h
1168
1161
x = section_n * section_w
@@ -1401,7 +1394,7 @@ local function format_wizard()
1401
1394
controls .staff_h_updown :ConnectIntegerEdit (controls .staff_h_invisible , 30 , 100 )
1402
1395
controls .staff_h_mm_static = add_ctrl (dialog , " static" , " mm" , x + col [4 ]+ 12 , y , 20 , row_h )
1403
1396
1404
- temp = math . round (efix_to_mm (page_settings .staff_h )* 10 , .1 )
1397
+ temp = math_round (efix_to_mm (page_settings .staff_h )* 10 , .1 )
1405
1398
controls .staff_h_invisible :SetInteger (temp ,1 )
1406
1399
controls .staff_h_edit :SetText (efix_to_mm_string (page_settings .staff_h ))
1407
1400
controls .staff_h_updown :SetValue (controls .staff_h_invisible :GetInteger ())
@@ -1470,7 +1463,7 @@ local function format_wizard()
1470
1463
for part in each (parts ) do
1471
1464
if part :IsPart () then
1472
1465
part :GetName (str )
1473
- local row = controls .parts_datalist :CreateRow ()
1466
+ row = controls .parts_datalist :CreateRow ()
1474
1467
row :GetItemAt (0 ).LuaString = str .LuaString
1475
1468
row :GetItemAt (1 ).LuaString = part :GetItemNo ()
1476
1469
end
@@ -1550,9 +1543,15 @@ local function format_wizard()
1550
1543
page_size_update (controls , page_settings , ctrls_collection )
1551
1544
return controls , page_settings , ctrls_collection
1552
1545
end
1553
- score_ctrls , score_settings , score_ctrls_collection = section_create (score_ctrls , score_settings , score_ctrls_collection , 0 )
1554
- parts_ctrls , parts_settings , parts_ctrls_collection = section_create (parts_ctrls , parts_settings , parts_ctrls_collection , 1 )
1555
- special_ctrls , special_settings , special_ctrls_collection = section_create (special_ctrls , special_settings , special_ctrls_collection , 2 )
1546
+ section_n = 0
1547
+ score_ctrls , score_settings , score_ctrls_collection = section_create (score_ctrls , score_settings , score_ctrls_collection )
1548
+ section_n = 1
1549
+
1550
+ parts_ctrls , parts_settings , parts_ctrls_collection = section_create (parts_ctrls , parts_settings , parts_ctrls_collection )
1551
+ section_n = 2
1552
+
1553
+ special_ctrls , special_settings , special_ctrls_collection = section_create (special_ctrls , special_settings , special_ctrls_collection )
1554
+
1556
1555
section_enable (score_enable_checkbox , score_ctrls , score_settings , score_ctrls_collection )
1557
1556
section_enable (parts_enable_checkbox , parts_ctrls , parts_settings , parts_ctrls_collection )
1558
1557
section_enable (special_enable_checkbox , special_ctrls , special_settings , special_ctrls_collection )
@@ -1791,7 +1790,7 @@ local function format_wizard()
1791
1790
if not hold then
1792
1791
hold = true
1793
1792
page_settings .staff_h = mm_to_efix (controls .staff_h_edit :GetMeasurement (finale .MEASUREMENTUNIT_MILLIMETERS ))
1794
- temp = math . round (controls .staff_h_edit :GetMeasurement (finale .MEASUREMENTUNIT_MILLIMETERS )* 10 , 1 )
1793
+ temp = math_round (controls .staff_h_edit :GetMeasurement (finale .MEASUREMENTUNIT_MILLIMETERS )* 10 , 1 )
1795
1794
controls .staff_h_invisible :SetInteger (temp )
1796
1795
controls .staff_h_updown :SetValue (temp )
1797
1796
hold = false
@@ -1871,7 +1870,7 @@ local function format_wizard()
1871
1870
end )
1872
1871
dialog :RegisterHandleControlEvent (controls .clear_datalist_button , function (control )
1873
1872
for i = 0 , controls .parts_datalist :GetCount ()- 1 do
1874
- local row = controls .parts_datalist :GetItemAt (i )
1873
+ row = controls .parts_datalist :GetItemAt (i )
1875
1874
row :SetCheck (false )
1876
1875
end
1877
1876
end )
0 commit comments