Skip to content

Commit aea77ba

Browse files
committed
toggle vidext without restart
1 parent f1188bf commit aea77ba

File tree

3 files changed

+55
-43
lines changed

3 files changed

+55
-43
lines changed

src/m64py/frontend/settings.py

Lines changed: 53 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def __init__(self, parent):
4444
self.qset = QSettings("m64py", "m64py")
4545
self.qset.setDefaultFormat(QSettings.IniFormat)
4646

47-
self.input = Input(self.parent)
4847
self.add_items()
4948
self.connect_signals()
5049

@@ -67,7 +66,7 @@ def add_items(self):
6766
Plugin(self.parent)),
6867
M64PLUGIN_INPUT: (
6968
self.comboInput, self.pushButtonInput,
70-
self.input)
69+
Input(self.parent))
7170
}
7271

7372
self.emumode = [
@@ -100,6 +99,13 @@ def set_config(self):
10099
self.set_video()
101100
self.set_core()
102101

102+
def on_vidext_changed(self, state):
103+
self.parent.vidext = state
104+
self.comboResolution.setEnabled(not self.parent.vidext)
105+
self.checkFullscreen.setEnabled(not self.parent.vidext)
106+
self.parent.worker.quit()
107+
self.parent.worker.init()
108+
103109
def connect_signals(self):
104110
self.browseLibrary.clicked.connect(lambda: self.browse_dialog(
105111
(self.pathLibrary, self.groupLibrary, False)))
@@ -109,6 +115,7 @@ def connect_signals(self):
109115
(self.pathData, self.groupData, True)))
110116
self.browseROM.clicked.connect(lambda: self.browse_dialog(
111117
(self.pathROM, self.groupROM, True)))
118+
self.checkEnableVidExt.clicked.connect(self.on_vidext_changed)
112119
for plugin_type in self.combomap:
113120
self.connect_combo_signals(self.combomap[plugin_type])
114121

@@ -154,6 +161,27 @@ def browse_dialog(self, args):
154161
self.parent.worker.plugins_startup()
155162
self.set_plugins()
156163

164+
def get_int_safe(self, key, default):
165+
try:
166+
return int(self.qset.value(key, default))
167+
except ValueError:
168+
return default
169+
170+
def get_size_safe(self):
171+
try:
172+
size = self.qset.value("size", SIZE_1X)
173+
except TypeError:
174+
size = SIZE_1X
175+
if not type(size) == tuple:
176+
size = SIZE_1X
177+
if len(size) != 2:
178+
size = SIZE_1X
179+
if type(size[0]) != int or type(size[1]) != int:
180+
size = SIZE_1X
181+
if size[0] <= 0 or size[1] <= 0:
182+
size = SIZE_1X
183+
return size
184+
157185
def get_section(self, combo):
158186
plugin = combo.currentText()
159187
index = combo.findText(plugin)
@@ -201,42 +229,10 @@ def set_paths(self):
201229
self.pathPlugins.setText(path_plugins)
202230
self.pathData.setText(path_data)
203231

204-
def get_int_safe(self, key, default):
205-
try:
206-
return int(self.qset.value(key, default))
207-
except ValueError:
208-
return default
209-
210-
def get_size_safe(self):
211-
try:
212-
size = self.qset.value("size", SIZE_1X)
213-
except TypeError:
214-
size = SIZE_1X
215-
if not type(size) == tuple:
216-
size = SIZE_1X
217-
if len(size) != 2:
218-
size = SIZE_1X
219-
if type(size[0]) != int or type(size[1]) != int:
220-
size = SIZE_1X
221-
if size[0] <= 0 or size[1] <= 0:
222-
size = SIZE_1X
223-
return size
224-
225232
def set_video(self):
226-
self.comboResolution.clear()
227-
for mode in MODES:
228-
width, height = mode
229-
self.comboResolution.addItem(
230-
"%sx%s" % (width, height), (width, height))
231-
self.comboResolution.setCurrentIndex(0)
232-
self.comboResolution.setEnabled(not self.parent.vidext)
233233
self.core.config.open_section("Video-General")
234-
width = self.core.config.get_parameter("ScreenWidth")
235-
height = self.core.config.get_parameter("ScreenHeight")
236-
index = self.comboResolution.findText(
237-
"%sx%s" % (width, height))
238-
if index == -1: index = 0
239-
self.comboResolution.setCurrentIndex(index)
234+
235+
self.set_resolution()
240236

241237
self.checkEnableVidExt.setChecked(
242238
bool(self.get_int_safe("enable_vidext", 1)))
@@ -310,19 +306,35 @@ def set_plugins(self):
310306
combo.setCurrentIndex(index)
311307
self.set_section(combo, button, settings)
312308

309+
def set_resolution(self):
310+
self.comboResolution.clear()
311+
for mode in MODES:
312+
width, height = mode
313+
self.comboResolution.addItem(
314+
"%sx%s" % (width, height), (width, height))
315+
316+
width = self.core.config.get_parameter("ScreenWidth")
317+
height = self.core.config.get_parameter("ScreenHeight")
318+
index = self.comboResolution.findText("%sx%s" % (width, height))
319+
if index == -1: index = 0
320+
self.comboResolution.setCurrentIndex(index)
321+
self.comboResolution.setEnabled(not self.parent.vidext)
322+
313323
def save_paths(self):
314324
self.qset.setValue("Paths/Library", self.pathLibrary.text())
315325
self.qset.setValue("Paths/Plugins", self.pathPlugins.text())
316326
self.qset.setValue("Paths/Data", self.pathData.text())
317327
self.qset.setValue("Paths/ROM", self.pathROM.text())
318328

319329
def save_video(self):
320-
if not self.parent.vidext:
321-
self.core.config.open_section("Video-General")
330+
self.core.config.open_section("Video-General")
331+
if self.parent.vidext:
332+
width, height = self.get_size_safe()
333+
else:
322334
width, height = self.comboResolution.currentText().split("x")
323-
self.core.config.set_parameter("ScreenWidth", int(width))
324-
self.core.config.set_parameter("ScreenHeight", int(height))
325-
self.core.config.set_parameter("Fullscreen", self.checkFullscreen.isChecked())
335+
self.core.config.set_parameter("ScreenWidth", int(width))
336+
self.core.config.set_parameter("ScreenHeight", int(height))
337+
self.core.config.set_parameter("Fullscreen", self.checkFullscreen.isChecked())
326338
self.qset.setValue("keep_aspect", int(self.checkKeepAspect.isChecked()))
327339
self.qset.setValue("disable_screensaver", int(self.checkDisableScreenSaver.isChecked()))
328340
self.qset.setValue("enable_vidext", int(self.checkEnableVidExt.isChecked()))

src/m64py/ui/i18n/m64py_en.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@
765765
</message>
766766
<message>
767767
<location filename="settings.ui" line="431"/>
768-
<source>Enable embedding of OpenGL window. This option needs restart.</source>
768+
<source>Enable embedding of OpenGL window.</source>
769769
<translation type="unfinished"></translation>
770770
</message>
771771
<message>

src/m64py/ui/settings.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ QGroupBox::title {
457457
<item row="2" column="0">
458458
<widget class="QCheckBox" name="checkEnableVidExt">
459459
<property name="toolTip">
460-
<string>Enable embedding of OpenGL window. This option needs restart.</string>
460+
<string>Enable embedding of OpenGL window.</string>
461461
</property>
462462
<property name="text">
463463
<string>Enable Video Extension</string>

0 commit comments

Comments
 (0)