mirror of
https://github.com/mupen64plus/mupen64plus-ui-python.git
synced 2025-04-02 10:51:53 -04:00
Python 3 support
This commit is contained in:
parent
2657f1494e
commit
84fce23417
8 changed files with 50 additions and 29 deletions
|
@ -131,7 +131,7 @@ class Config:
|
|||
def set_parameter(self, param_name, param_value):
|
||||
"""Sets the value of one of the emulator's parameters."""
|
||||
try:
|
||||
param_type = self.parameters[self.section][param_name]
|
||||
param_type = self.parameters[self.section][param_name.encode()]
|
||||
param_ctype = M64_CTYPE[param_type]
|
||||
except KeyError:
|
||||
return
|
||||
|
@ -156,7 +156,7 @@ class Config:
|
|||
def get_parameter(self, param_name):
|
||||
"""Retrieves the value of one of the emulator's parameters."""
|
||||
try:
|
||||
param_type = self.parameters[self.section][param_name]
|
||||
param_type = self.parameters[self.section][param_name.encode()]
|
||||
param_ctype = M64_CTYPE[param_type]
|
||||
except KeyError:
|
||||
return
|
||||
|
|
|
@ -153,7 +153,7 @@ class Core:
|
|||
def error_message(self, return_code):
|
||||
"""Returns description of the error"""
|
||||
self.m64p.CoreErrorMessage.restype = C.c_char_p
|
||||
rval = self.m64p.CoreErrorMessage(return_code)
|
||||
rval = self.m64p.CoreErrorMessage(return_code).decode()
|
||||
return rval
|
||||
|
||||
def core_startup(self, path, use_vidext):
|
||||
|
|
|
@ -212,6 +212,7 @@ class Input(QDialog, Ui_InputDialog):
|
|||
def set_opts(self):
|
||||
for key, val in self.opts.items():
|
||||
param, tooltip, widget, ptype = val
|
||||
tooltip = tooltip.decode()
|
||||
if ptype == M64TYPE_BOOL:
|
||||
if param:
|
||||
widget.setChecked(param)
|
||||
|
@ -220,6 +221,7 @@ class Input(QDialog, Ui_InputDialog):
|
|||
elif ptype == M64TYPE_INT:
|
||||
widget.setCurrentIndex(widget.findData(param))
|
||||
elif ptype == M64TYPE_STRING:
|
||||
param = param.decode()
|
||||
if key in ["AnalogDeadzone", "AnalogPeak"]:
|
||||
if param:
|
||||
paramX, paramY = param.split(",")
|
||||
|
@ -245,11 +247,11 @@ class Input(QDialog, Ui_InputDialog):
|
|||
elif ptype == M64TYPE_STRING:
|
||||
if key in ["AnalogDeadzone", "AnalogPeak"]:
|
||||
spin1, spin2 = widget
|
||||
self.config.set_parameter(key,"%s,%s" % (
|
||||
spin1.value(), spin2.value()))
|
||||
value = "%s,%s" % (spin1.value(), spin2.value())
|
||||
self.config.set_parameter(key, value.encode())
|
||||
else:
|
||||
self.config.set_parameter(
|
||||
key, str(widget.text()))
|
||||
key, widget.text().encode())
|
||||
|
||||
def get_keys(self):
|
||||
self.keys = {
|
||||
|
@ -316,12 +318,13 @@ class Input(QDialog, Ui_InputDialog):
|
|||
else:
|
||||
value = self.get_sdl_key(widget.text())
|
||||
if value:
|
||||
self.config.set_parameter(key, "key(%s)" % value)
|
||||
v = "key(%s)" % value
|
||||
self.config.set_parameter(key, v.encode())
|
||||
else:
|
||||
continue
|
||||
|
||||
def get_axis(self, axis):
|
||||
param = self.config.get_parameter(axis)
|
||||
param = self.config.get_parameter(axis).decode()
|
||||
if param:
|
||||
return AXIS_RE.findall(param)
|
||||
|
||||
|
@ -356,26 +359,30 @@ class Input(QDialog, Ui_InputDialog):
|
|||
xr = KEY_RE.findall(str(self.pushX_Axis_R.text()))
|
||||
if xl and xr:
|
||||
xl, xr = xl[0], xr[0]
|
||||
self.config.set_parameter("X Axis", "%s(%s,%s)" % (xl[0], xl[1], xr[1]))
|
||||
axis = "%s(%s,%s)" % (xl[0], xl[1], xr[1])
|
||||
self.config.set_parameter("X Axis", axis.encode())
|
||||
else:
|
||||
xl = self.get_sdl_key(self.pushX_Axis_L.text())
|
||||
xr = self.get_sdl_key(self.pushX_Axis_R.text())
|
||||
if xl and xr:
|
||||
self.config.set_parameter("X Axis", "key(%s,%s)" % (xl, xr))
|
||||
axis = "key(%s,%s)" % (xl, xr)
|
||||
self.config.set_parameter("X Axis", axis.encode())
|
||||
|
||||
yu = KEY_RE.findall(str(self.pushY_Axis_U.text()))
|
||||
yd = KEY_RE.findall(str(self.pushY_Axis_D.text()))
|
||||
if yu and yd:
|
||||
yu, yd = yu[0], yd[0]
|
||||
self.config.set_parameter("Y Axis", "%s(%s,%s)" % (yu[0], yu[1], yd[1]))
|
||||
axis = "%s(%s,%s)" % (yu[0], yu[1], yd[1])
|
||||
self.config.set_parameter("Y Axis", axis.encode())
|
||||
else:
|
||||
yu = self.get_sdl_key(self.pushY_Axis_U.text())
|
||||
yd = self.get_sdl_key(self.pushY_Axis_D.text())
|
||||
if yu and yd:
|
||||
self.config.set_parameter("Y Axis", "key(%s,%s)" % (yu, yd))
|
||||
axis = "key(%s,%s)" % (yu, yd)
|
||||
self.config.set_parameter("Y Axis", axis.encode())
|
||||
|
||||
def get_key(self, key):
|
||||
param = self.config.get_parameter(key)
|
||||
param = self.config.get_parameter(key).decode()
|
||||
if not param:
|
||||
return [0, 0]
|
||||
|
||||
|
@ -400,6 +407,7 @@ class Input(QDialog, Ui_InputDialog):
|
|||
from m64py.SDL2.keyboard import SDL_GetScancodeFromName
|
||||
if "Shift" in text or "Ctrl" in text or "Alt" in text:
|
||||
text = "Left %s" % text
|
||||
text = text.encode()
|
||||
return SCANCODE2KEYCODE[SDL_GetScancodeFromName(text)]
|
||||
else:
|
||||
try:
|
||||
|
@ -420,6 +428,7 @@ class Input(QDialog, Ui_InputDialog):
|
|||
else:
|
||||
from m64py.SDL.keyboard import SDL_GetKeyName
|
||||
text = SDL_GetKeyName(int(sdl_key)).title()
|
||||
text = text.decode()
|
||||
if not text:
|
||||
return self.tr("Select...")
|
||||
if "Shift" in text or "Ctrl" in text or "Alt" in text:
|
||||
|
|
|
@ -69,7 +69,8 @@ class Plugin(QDialog, Ui_PluginDialog):
|
|||
row1, row2 = 0, 0
|
||||
for count, item in enumerate(self.items):
|
||||
param_name, param_type = item
|
||||
param_help = self.config.get_parameter_help(param_name)
|
||||
param_name = param_name.decode()
|
||||
param_help = self.config.get_parameter_help(param_name).decode()
|
||||
opts = format_options(param_help)
|
||||
|
||||
if param_type == M64TYPE_STRING:
|
||||
|
@ -115,7 +116,7 @@ class Plugin(QDialog, Ui_PluginDialog):
|
|||
for param_name, item in self.widgets.items():
|
||||
widget, widget_class, opts = item
|
||||
if widget_class == QLineEdit:
|
||||
widget.setText(str(self.config.get_parameter(param_name)))
|
||||
widget.setText(self.config.get_parameter(param_name).decode())
|
||||
elif widget_class == QSpinBox:
|
||||
param = self.config.get_parameter(param_name)
|
||||
if param is not None:
|
||||
|
@ -134,7 +135,7 @@ class Plugin(QDialog, Ui_PluginDialog):
|
|||
for param_name, item in self.widgets.items():
|
||||
widget, widget_class, opts = item
|
||||
if widget_class == QLineEdit:
|
||||
param_value = str(widget.text())
|
||||
param_value = widget.text().encode()
|
||||
elif widget_class == QSpinBox:
|
||||
param_value = int(widget.value())
|
||||
elif widget_class == QComboBox:
|
||||
|
|
|
@ -28,9 +28,9 @@ class RomInfo():
|
|||
self.parent = parent
|
||||
self.core = self.parent.worker.core
|
||||
rom_info = [
|
||||
('GoodName', self.core.rom_settings.goodname),
|
||||
('Name', self.core.rom_header.Name),
|
||||
('MD5', self.core.rom_settings.MD5),
|
||||
('GoodName', self.core.rom_settings.goodname.decode()),
|
||||
('Name', self.core.rom_header.Name.decode()),
|
||||
('MD5', self.core.rom_settings.MD5.decode()),
|
||||
('CRC1', '%x' % sl(self.core.rom_header.CRC1)),
|
||||
('CRC2', '%x' % sl(self.core.rom_header.CRC2)),
|
||||
('Type', self.core.rom_type),
|
||||
|
|
|
@ -57,7 +57,12 @@ class ROMList(QMainWindow, Ui_ROMList):
|
|||
self.splitter.setStretchFactor(1, 2)
|
||||
|
||||
self.reader = ROMReader(self)
|
||||
self.rom_list = self.qset.value("rom_list", [])
|
||||
|
||||
try:
|
||||
self.rom_list = self.qset.value("rom_list", [])
|
||||
except TypeError:
|
||||
self.rom_list = []
|
||||
|
||||
self.user_data_path = self.core.config.get_path("UserData")
|
||||
|
||||
if self.rom_list:
|
||||
|
@ -91,8 +96,10 @@ class ROMList(QMainWindow, Ui_ROMList):
|
|||
for rom in self.rom_list:
|
||||
if len(rom) == 4:
|
||||
crc, goodname, path, fname = rom
|
||||
list_item = QListWidgetItem(goodname.decode())
|
||||
list_item.setData(Qt.UserRole, (crc, goodname.decode(), path, fname))
|
||||
if isinstance(goodname, bytes):
|
||||
goodname = goodname.decode()
|
||||
list_item = QListWidgetItem(goodname)
|
||||
list_item.setData(Qt.UserRole, (crc, goodname, path, fname))
|
||||
self.listWidget.addItem(list_item)
|
||||
self.progressBar.setValue(0)
|
||||
self.progressBar.hide()
|
||||
|
|
|
@ -202,7 +202,10 @@ class Settings(QDialog, Ui_Settings):
|
|||
return default
|
||||
|
||||
def get_size_safe(self):
|
||||
size = self.qset.value("size", SIZE_1X)
|
||||
try:
|
||||
size = self.qset.value("size", SIZE_1X)
|
||||
except TypeError:
|
||||
size = SIZE_1X
|
||||
if not type(size) == tuple:
|
||||
size = SIZE_1X
|
||||
if len(size) != 2:
|
||||
|
@ -253,15 +256,15 @@ class Settings(QDialog, Ui_Settings):
|
|||
self.checkOSD.setChecked(
|
||||
self.core.config.get_parameter("OnScreenDisplay"))
|
||||
self.checkOSD.setToolTip(
|
||||
self.core.config.get_parameter_help("OnScreenDisplay"))
|
||||
self.core.config.get_parameter_help("OnScreenDisplay").decode())
|
||||
self.checkNoCompiledJump.setChecked(
|
||||
self.core.config.get_parameter("NoCompiledJump"))
|
||||
self.checkNoCompiledJump.setToolTip(
|
||||
self.core.config.get_parameter_help("NoCompiledJump"))
|
||||
self.core.config.get_parameter_help("NoCompiledJump").decode())
|
||||
self.checkDisableExtraMem.setChecked(
|
||||
self.core.config.get_parameter("DisableExtraMem"))
|
||||
self.checkDisableExtraMem.setToolTip(
|
||||
self.core.config.get_parameter_help("DisableExtraMem"))
|
||||
self.core.config.get_parameter_help("DisableExtraMem").decode())
|
||||
|
||||
delay_si = self.core.config.get_parameter("DelaySI")
|
||||
if delay_si is not None:
|
||||
|
@ -270,7 +273,7 @@ class Settings(QDialog, Ui_Settings):
|
|||
self.checkDelaySI.setChecked(False)
|
||||
self.checkDelaySI.setEnabled(False)
|
||||
self.checkDelaySI.setToolTip(
|
||||
self.core.config.get_parameter_help("DelaySI"))
|
||||
self.core.config.get_parameter_help("DelaySI").decode())
|
||||
|
||||
count_per_op = self.core.config.get_parameter("CountPerOp")
|
||||
if count_per_op is not None:
|
||||
|
@ -278,7 +281,7 @@ class Settings(QDialog, Ui_Settings):
|
|||
else:
|
||||
self.comboCountPerOp.setEnabled(False)
|
||||
self.comboCountPerOp.setToolTip(
|
||||
self.core.config.get_parameter_help("CountPerOp"))
|
||||
self.core.config.get_parameter_help("CountPerOp").decode())
|
||||
|
||||
def set_plugins(self):
|
||||
plugin_map = self.core.plugin_map
|
||||
|
@ -327,7 +330,7 @@ class Settings(QDialog, Ui_Settings):
|
|||
self.core.config.set_parameter("DisableExtraMem", self.checkDisableExtraMem.isChecked())
|
||||
self.core.config.set_parameter("DelaySI", self.checkDelaySI.isChecked())
|
||||
self.core.config.set_parameter("CountPerOp", self.comboCountPerOp.currentIndex())
|
||||
self.core.config.set_parameter("SharedDataPath", self.pathData.text())
|
||||
self.core.config.set_parameter("SharedDataPath", self.pathData.text().encode())
|
||||
|
||||
def save_plugins(self):
|
||||
for plugin_type in self.combomap:
|
||||
|
|
|
@ -71,6 +71,7 @@ class InputButton(QPushButton):
|
|||
else:
|
||||
from m64py.SDL.keyboard import SDL_GetKeyName
|
||||
text = SDL_GetKeyName(QT2SDL[key]).title()
|
||||
text = text.decode()
|
||||
|
||||
text = text.replace("Left ", "")
|
||||
self.setText(text.title())
|
||||
|
|
Loading…
Add table
Reference in a new issue