Skip to content

Commit 170ad3b

Browse files
committed
Update configurator
1 parent 7c077e2 commit 170ad3b

File tree

1 file changed

+117
-28
lines changed

1 file changed

+117
-28
lines changed

pycfg/pycfg.py

Lines changed: 117 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ def __init__(self, game, platform):
211211
if game == "xcom1" or game == "xcom2":
212212
midi_values += "/adlib-dosbox_opl"
213213
if platform == "pc" or platform == "pyra":
214-
midi_values += "/mt32-munt"
215-
midi_values += "/mt32-alsa"
214+
midi_values += "/mt32-munt/awe32-emu8k"
215+
midi_values += "/mt32-alsa"
216216
self.AddEntry("Audio_MIDI_Subsystem", midi_values, "adlmidi")
217217

218218
if "alsa" in midi_values or "mt32-alsa" in midi_values:
@@ -224,9 +224,15 @@ def __init__(self, game, platform):
224224
if "mt32-munt" in midi_values:
225225
self.AddEntry("Audio_MT32_Roms_Path", "*", "")
226226

227+
if "awe32-emu8k" in midi_values:
228+
self.AddEntry("Audio_AWE32_Rom_Path", "*", "")
229+
227230
if game == "xcom1" or game == "xcom2":
228231
self.AddEntry("Audio_OPL3_BankNumber", "0-77", "77")
229232

233+
if "mt32-alsa" in midi_values:
234+
self.AddEntry("Audio_MT32_Delay_Sysex", "yes/no", "no")
235+
230236
if platform == "pc" or platform == "pyra":
231237
self.AddEntry("Audio_OPL3_Emulator", "fast/precise", "precise" if platform == "pc" else "fast")
232238

@@ -504,9 +510,9 @@ def __init__(self, game, platform, file_path):
504510
if self.CfgFile.HasEntry("Audio_Channels"):
505511
vbox = self.AddPageFrameVBox(notebook, "Audio", "Audio parameters")
506512

507-
self.CreateRadioSet(vbox, "Channels:", "Audio_Channels", "Number of audio channels.")
513+
self.CreateRadioSet2(vbox, "Channels:", "Audio_Channels", None, "Number of audio channels.")
508514
self.CreateSeparator(vbox)
509-
self.CreateRadioSet(vbox, "Resolution:", "Audio_Resolution", "Audio resolution - 8 or 16 bits.")
515+
self.CreateRadioSet2(vbox, "Resolution:", "Audio_Resolution", None, "Audio resolution - 8 or 16 bits.")
510516
self.CreateSeparator(vbox)
511517
self.CreateRadioSet2(vbox, "Sample Rate:", "Audio_Sample_Rate", "11025/22050/44100/48000/96000/192000/384000", "Audio frequency in Hz.")
512518
self.CreateSeparator(vbox)
@@ -523,7 +529,7 @@ def __init__(self, game, platform, file_path):
523529
description = "Select whether to swap left and right sound channel or not."
524530
if game == "albion":
525531
description += "\nAlbion has the channels swapped, so swapping them corrects it."
526-
self.CreateRadioSet(vbox, "Swap Channels ?", "Audio_Swap_Channels", description)
532+
self.CreateRadioSet2(vbox, "Swap Channels ?", "Audio_Swap_Channels", None, description)
527533

528534
if self.CfgFile.HasEntry("Audio_Music_Volume"):
529535
self.CreateSeparator(vbox)
@@ -548,9 +554,6 @@ def __init__(self, game, platform, file_path):
548554
if "alsa" in self.CfgFile.GetEntryFormat("Audio_MIDI_Subsystem"):
549555
description += "\nALSA sequencer can use hardware or software synth (like Fluidsynth or TiMidity++)."
550556

551-
if game == "albion":
552-
description += "\nSDL_mixer can only play one MIDI stream simultaneously."
553-
554557
description += "\nWildMIDI uses GUS patch files for playback."
555558
if self.CfgFile.HasEntry("Audio_SoundFont_Path"):
556559
description += "\nBASSMIDI uses soundfont for playback."
@@ -566,10 +569,21 @@ def __init__(self, game, platform, file_path):
566569

567570
if self.CfgFile.HasEntry("Audio_MT32_Roms_Path"):
568571
description += "\nMT-32 music is played using MUNT emulator or ALSA sequencer. (DOS game version)"
569-
elif "mt32-alsa" in self.CfgFile.GetEntryFormat("Audio_MIDI_Subsystem"):
570-
description += "\nMT-32 music is played using ALSA sequencer. (DOS game version)"
571572

572-
self.CreateRadioSet(vbox, "MIDI Subsystem:", "Audio_MIDI_Subsystem", description)
573+
if "awe32-emu8k" in self.CfgFile.GetEntryFormat("Audio_MIDI_Subsystem"):
574+
description += "\nGeneral MIDI music can be played using AWE32 emulator. (DOS game version)"
575+
576+
if "mt32-alsa" in self.CfgFile.GetEntryFormat("Audio_MIDI_Subsystem"):
577+
if "adlib-dosbox_opl" in self.CfgFile.GetEntryFormat("Audio_MIDI_Subsystem"):
578+
description += "\nMusic can be played on MT-32 synth using ALSA sequencer.\n (MT-32 music in DOS game version / General MIDI music in Gold edition)"
579+
else:
580+
description += "\nMusic can be played on MT-32 synth using ALSA sequencer."
581+
582+
self.CreateRadioSet2(vbox, "MIDI Subsystem:", "Audio_MIDI_Subsystem", (2 if self.CfgFile.HasEntry("Audio_MT32_Roms_Path") else 1), description)
583+
584+
if self.CfgFile.HasEntry("Audio_MT32_Delay_Sysex"):
585+
self.CreateSeparator(vbox)
586+
self.CreateRadioSet2(vbox, "MT32 Delay Sysex:", "Audio_MT32_Delay_Sysex", None, "Add delays when sending sysex messages on MT-32 ? (to prevent buffer overflow with Rev.0 MT-32)")
573587

574588
num_extra_options = 0
575589

@@ -579,6 +593,9 @@ def __init__(self, game, platform, file_path):
579593
if self.CfgFile.HasEntry("Audio_SoundFont_Path"):
580594
num_extra_options += 1
581595

596+
if self.CfgFile.HasEntry("Audio_AWE32_Rom_Path"):
597+
num_extra_options += 1
598+
582599
if self.CfgFile.HasEntry("Audio_MT32_Roms_Path"):
583600
num_extra_options += 1
584601

@@ -588,9 +605,7 @@ def __init__(self, game, platform, file_path):
588605
if self.CfgFile.HasEntry("Audio_OPL3_Emulator"):
589606
num_extra_options += 1
590607

591-
if num_extra_options == 1:
592-
self.CreateSeparator(vbox)
593-
elif num_extra_options > 1:
608+
if num_extra_options >= 1:
594609
vbox = self.AddPageFrameVBox(notebook, "MIDI 2", "MIDI")
595610

596611
if self.CfgFile.HasEntry("Audio_MIDI_Device"):
@@ -602,9 +617,13 @@ def __init__(self, game, platform, file_path):
602617
if self.CfgFile.HasEntry("Audio_SoundFont_Path"):
603618
self.CreateSoundfontSelector(vbox, "SoundFont Path:", "Audio_SoundFont_Path", "Set path to soundfont file. No value = autodetection in game's directory.\nThis is used when MIDI playback using BASSMIDI is selected.")
604619
num_extra_options -= 1
605-
if num_extra_options == 1:
620+
if num_extra_options >= 1:
606621
self.CreateSeparator(vbox)
607622

623+
if self.CfgFile.HasEntry("Audio_AWE32_Rom_Path"):
624+
self.CreateROMFileSelector(vbox, "AWE32 Rom Path:", "Audio_AWE32_Rom_Path", "Set path to AWE32 rom file. (Default filename is awe32.raw)\nThis is necessary when MIDI playback using AWE32 emulator is selected.")
625+
num_extra_options -= 1
626+
608627
if num_extra_options >= 2:
609628
vbox = self.AddPageFrameVBox(notebook, "MIDI 3", "MIDI")
610629

@@ -631,7 +650,7 @@ def __init__(self, game, platform, file_path):
631650
description += "Adlib music"
632651

633652
description = "Use fast (DOSBox) or precise (Nuked) OPL3 emulator.\nThis is used when " + description + " is selected."
634-
self.CreateRadioSet(vbox, "OPL3 Emulator:", "Audio_OPL3_Emulator", description)
653+
self.CreateRadioSet2(vbox, "OPL3 Emulator:", "Audio_OPL3_Emulator", None, description)
635654
num_extra_options -= 1
636655
if num_extra_options != 0:
637656
self.CreateSeparator(vbox)
@@ -648,28 +667,28 @@ def __init__(self, game, platform, file_path):
648667
else:
649668
description += "\nOriginal game resolution is 320x200 displayed with aspect ratio 4:3.\ndouble_pixels = 640x400\nfullscreen = 800x480\ncorrect_aspect_ratio = 640x480"
650669

651-
self.CreateRadioSet(vbox, "Display Mode:", "Display_Mode", description)
670+
self.CreateRadioSet2(vbox, "Display Mode:", "Display_Mode", None, description)
652671
elif self.CfgFile.HasEntry("Tvout_Scaling"):
653672
IsFirst = False
654-
self.CreateRadioSet(vbox, "Tvout Scaling:", "Tvout_Scaling", "If the TV-output mode of the GP2X is being used, this setting allows to select\nwhether the image will be scaled down from a width of 360 to 320 or just left at 360.\nMost users will want to leave this on.")
673+
self.CreateRadioSet2(vbox, "Tvout Scaling:", "Tvout_Scaling", None, "If the TV-output mode of the GP2X is being used, this setting allows to select\nwhether the image will be scaled down from a width of 360 to 320 or just left at 360.\nMost users will want to leave this on.")
655674
elif self.CfgFile.HasEntry("Display"):
656675
IsFirst = False
657676
description = "Select whether game is displayed in original resolution or stretched to fullscreen."
658677
if self.CfgFile.HasEntry("Touchscreen"):
659678
description += "\nNote: Display is forced into stretched mode on F200s when using touchscreen."
660679

661-
self.CreateRadioSet(vbox, "Display:", "Display", description)
680+
self.CreateRadioSet2(vbox, "Display:", "Display", None, description)
662681
elif self.CfgFile.HasEntry("Display_Fullscreen"):
663682
IsFirst = False
664683
self.CreateRadioSet2(vbox, "Display Scaled Width:", "Display_ScaledWidth", ("640/720" if game == "albion" else "640") + "/960/1280/1600/1920/2240/2560/2880/3840", "Default value is " + ("720" if game == "albion" else "640") + ". Correct display aspect ratio is 4:3.")
665684
self.CreateSeparator(vbox)
666685
self.CreateRadioSet2(vbox, "Display Scaled Height:", "Display_ScaledHeight", ("480" if game == "albion" else "400/480") + "/720/960/1080/1200/1440/1680/1920/2160", "Default value is " + ("480" if game == "albion" else "400") + ". Correct display aspect ratio is 4:3.")
667686
self.CreateSeparator(vbox)
668-
self.CreateRadioSet(vbox, "Display Fullscreen:", "Display_Fullscreen", "Select whether game is displayed fullscreen or in a window.")
687+
self.CreateRadioSet2(vbox, "Display Fullscreen:", "Display_Fullscreen", None, "Select whether game is displayed fullscreen or in a window.")
669688

670689
if self.CfgFile.HasEntry("Display_MouseCursor"):
671690
self.CreateSeparator(vbox)
672-
self.CreateRadioSet(vbox, "Display MouseCursor:", "Display_MouseCursor", "Select mouse cursor type when the game is displayed in a window.")
691+
self.CreateRadioSet2(vbox, "Display MouseCursor:", "Display_MouseCursor", None, "Select mouse cursor type when the game is displayed in a window.")
673692
if self.CfgFile.HasEntry("Display_Enhanced_3D_Rendering") or self.CfgFile.HasEntry("Display_Scaling"):
674693
vbox = self.AddPageFrameVBox(notebook, "Display 2", "Display")
675694

@@ -705,13 +724,10 @@ def __init__(self, game, platform, file_path):
705724
if self.CfgFile.HasEntry("Screenshot_Format"):
706725
vbox = self.AddPageFrameVBox(notebook, "Screenshots", "Screenshot settings")
707726

708-
self.CreateRadioSet(vbox, "Screenshot Format:", "Screenshot_Format", "Original = original image format (LBM)\nLBM = image format is LBM\nLBM_pad16 = image format is LBM with lines in file padded to 16 bytes\nTGA = image format is TGA\nBMP = image format is BMP\nPNG = image format is PNG (requires zlib library)")
709-
710-
vbox = self.AddPageFrameVBox(notebook, "Screenshots 2", "Screenshot settings")
711-
712-
self.CreateRadioSet(vbox, "Screenshot Enhanced Resolution:", "Screenshot_Enhanced_Resolution", "if enabled then create screenshots in enhanced resolution (720x480) when it's possible,\notherwise create screenshots in original resolution (360x240)")
713-
self.CreateRadioSet(vbox, "Screenshot Enabled ?", "Screenshot_Enabled", "select whether making screenshots (using F4 key) is enabled without entering developer mode")
714-
self.CreateRadioSet(vbox, "Screenshot Automatic Filename ?", "Screenshot_Automatic_Filename", "select whether screenshot filename is generated automatically (Screenshot????.???) or not")
727+
self.CreateRadioSet2(vbox, "Screenshot Format:", "Screenshot_Format", None, "Original = original image format (LBM)\nLBM/TGA/BMP = image format is LBM/TGA/BMP\nLBM_pad16 = image format is LBM with lines in file padded to 16 bytes\nPNG = image format is PNG (requires zlib library)")
728+
self.CreateRadioSet2(vbox, "Screenshot Enhanced Resolution:", "Screenshot_Enhanced_Resolution", None, "Create screenshots in enhanced (when it's possible) or original (360x240) resolution.")
729+
self.CreateRadioSet2(vbox, "Screenshot Enabled ?", "Screenshot_Enabled", None, "Select whether making screenshots (using F4 key) is enabled without entering developer mode.")
730+
self.CreateRadioSet2(vbox, "Screenshot Automatic Filename ?", "Screenshot_Automatic_Filename", None, "Select whether screenshot filename is generated automatically (Screenshot????.???) or not.")
715731

716732
if self.CfgFile.HasEntry("Keys_WSAD"):
717733
vbox = self.AddPageFrameVBox(notebook, "Keys", "Keys")
@@ -1008,6 +1024,34 @@ def CreateSoundfontSelector(self, parentvbox, entry_label, entry_name, entry_des
10081024
parentvbox.pack_start(vbox, False, False, 5)
10091025
vbox.show()
10101026

1027+
def CreateROMFileSelector(self, parentvbox, entry_label, entry_name, entry_description = None):
1028+
vbox = gtk.VBox(homogeneous=False, spacing=0)
1029+
self.CreateEntryLabel(vbox, entry_label, 5)
1030+
1031+
hbox = gtk.HBox(homogeneous=False, spacing=0)
1032+
vbox.pack_start(hbox, False, False, 5)
1033+
hbox.show()
1034+
1035+
entry = gtk.Entry()
1036+
entry.set_max_length(256)
1037+
entry.set_text(self.CfgFile.GetEntryValue(entry_name))
1038+
entry.connect("changed", self.EntryChanged, entry_name)
1039+
hbox.pack_start(entry, True, True, 5)
1040+
entry.show()
1041+
1042+
self.widgets.append(("entry", entry_name, entry))
1043+
1044+
button = gtk.Button(label="Select ROM file")
1045+
button.connect("clicked", self.SelectROMFile, entry)
1046+
hbox.pack_start(button, False, False, 5)
1047+
button.show()
1048+
1049+
if not entry_description is None:
1050+
self.CreateEntryLabel(vbox, entry_description, 20)
1051+
1052+
parentvbox.pack_start(vbox, False, False, 5)
1053+
vbox.show()
1054+
10111055
def CreateROMsDirectorySelector(self, parentvbox, entry_label, entry_name, entry_description = None):
10121056
vbox = gtk.VBox(homogeneous=False, spacing=0)
10131057
self.CreateEntryLabel(vbox, entry_label, 5)
@@ -1074,9 +1118,13 @@ def CreateRadioSet2(self, parentvbox, entry_label, entry_name, entry_values, ent
10741118
vbox = gtk.VBox(homogeneous=False, spacing=0)
10751119
self.CreateEntryLabel(vbox, entry_label, 5)
10761120

1121+
num_lines = 1
10771122
current_value = self.CfgFile.GetEntryValue(entry_name).lower()
10781123
if entry_values is None:
10791124
entry_format = self.CfgFile.GetEntryFormat(entry_name).split("/")
1125+
elif isinstance(entry_values, int):
1126+
entry_format = self.CfgFile.GetEntryFormat(entry_name).split("/")
1127+
num_lines = entry_values
10801128
else:
10811129
entry_format = entry_values.split("/")
10821130
if not current_value in entry_format:
@@ -1089,6 +1137,8 @@ def CreateRadioSet2(self, parentvbox, entry_label, entry_name, entry_values, ent
10891137

10901138
buttons = []
10911139

1140+
num_values = len(entry_format)
1141+
value_num = 0
10921142
for entry_value in entry_format:
10931143
button = gtk.RadioButton(group=group, label=entry_value)
10941144
button.set_use_underline(False)
@@ -1102,6 +1152,16 @@ def CreateRadioSet2(self, parentvbox, entry_label, entry_name, entry_values, ent
11021152
if group is None:
11031153
group = button
11041154

1155+
value_num = value_num + 1
1156+
if num_lines > 1 and value_num * num_lines >= num_values:
1157+
hbox = gtk.HBox(homogeneous=False, spacing=0)
1158+
vbox.pack_start(hbox, False, False, 0)
1159+
hbox.show()
1160+
1161+
num_lines = num_lines - 1
1162+
num_values = num_values - value_num
1163+
value_num = 0
1164+
11051165
self.widgets.append(("radioset", entry_name, buttons))
11061166

11071167
if not entry_description is None:
@@ -1250,6 +1310,35 @@ def SelectSoundfont(self, widget, entry=None):
12501310

12511311
dialog.destroy()
12521312

1313+
def SelectROMFile(self, widget, entry=None):
1314+
dialog = gtk.FileChooserDialog(title="Select ROM file", parent=self.window, action=GTK_FILE_CHOOSER_ACTION_OPEN)
1315+
dialog.add_buttons(gtk.STOCK_CANCEL,GTK_RESPONSE_CANCEL, gtk.STOCK_OK,GTK_RESPONSE_OK);
1316+
1317+
dialog.set_local_only(True)
1318+
1319+
filename = entry.get_text()
1320+
if filename is None or filename == "":
1321+
dialog.set_current_folder(os.getcwd())
1322+
else:
1323+
dialog.set_filename(filename)
1324+
1325+
dialog_filter = gtk.FileFilter()
1326+
dialog_filter.set_name("ROM file (awe32.raw)")
1327+
dialog_filter.add_pattern("awe32.raw")
1328+
dialog.add_filter(dialog_filter)
1329+
1330+
dialog_filter = gtk.FileFilter()
1331+
dialog_filter.set_name("All files (*)")
1332+
dialog_filter.add_pattern("*")
1333+
dialog.add_filter(dialog_filter)
1334+
1335+
response = dialog.run()
1336+
1337+
if response == GTK_RESPONSE_OK:
1338+
entry.set_text(dialog.get_filename())
1339+
1340+
dialog.destroy()
1341+
12531342
def SelectROMsDirectory(self, widget, entry=None):
12541343
dialog = gtk.FileChooserDialog(title="Select ROMs directory", parent=self.window, action=GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
12551344
dialog.add_buttons(gtk.STOCK_CANCEL,GTK_RESPONSE_CANCEL, gtk.STOCK_OK,GTK_RESPONSE_OK)

0 commit comments

Comments
 (0)