mirror of
https://github.com/mupen64plus/mupen64plus-ui-python.git
synced 2025-04-02 10:51:53 -04:00
support window resizing
This commit is contained in:
parent
d52c7cc669
commit
d84815c4a7
7 changed files with 30 additions and 17 deletions
|
@ -40,9 +40,11 @@ def debug_callback(context, level, message):
|
||||||
|
|
||||||
def state_callback(context, param, value):
|
def state_callback(context, param, value):
|
||||||
if param == M64CORE_VIDEO_SIZE:
|
if param == M64CORE_VIDEO_SIZE:
|
||||||
sys.stderr.write("%s: %s: %s\n" % (context, "M64CORE_VIDEO_SIZE", value))
|
#sys.stderr.write("%s: %s: %s\n" % (context, "M64CORE_VIDEO_SIZE", value))
|
||||||
|
pass
|
||||||
elif param == M64CORE_VIDEO_MODE:
|
elif param == M64CORE_VIDEO_MODE:
|
||||||
sys.stderr.write("%s: %s: %s\n" % (context, "M64CORE_VIDEO_MODE", value))
|
#sys.stderr.write("%s: %s: %s\n" % (context, "M64CORE_VIDEO_MODE", value))
|
||||||
|
pass
|
||||||
|
|
||||||
DEBUGFUNC = C.CFUNCTYPE(None, C.c_char_p, C.c_int, C.c_char_p)
|
DEBUGFUNC = C.CFUNCTYPE(None, C.c_char_p, C.c_int, C.c_char_p)
|
||||||
STATEFUNC = C.CFUNCTYPE(None, C.c_char_p, C.c_int, C.c_int)
|
STATEFUNC = C.CFUNCTYPE(None, C.c_char_p, C.c_int, C.c_int)
|
||||||
|
@ -220,9 +222,9 @@ class Core:
|
||||||
plugin_name = os.path.basename(plugin_path)
|
plugin_name = os.path.basename(plugin_path)
|
||||||
self.plugin_map[plugin_type][plugin_name] = (plugin_handle, plugin_path,
|
self.plugin_map[plugin_type][plugin_name] = (plugin_handle, plugin_path,
|
||||||
PLUGIN_NAME[plugin_type], plugin_desc, plugin_version)
|
PLUGIN_NAME[plugin_type], plugin_desc, plugin_version)
|
||||||
self.plugin_startup(plugin_handle, PLUGIN_NAME[plugin_type])
|
self.plugin_startup(plugin_handle, PLUGIN_NAME[plugin_type], plugin_desc)
|
||||||
|
|
||||||
def plugin_startup(self, handle, name):
|
def plugin_startup(self, handle, name, desc):
|
||||||
"""This function initializes plugin for use by allocating memory,
|
"""This function initializes plugin for use by allocating memory,
|
||||||
creating data structures, and loading the configuration data."""
|
creating data structures, and loading the configuration data."""
|
||||||
rval = handle.PluginStartup(C.c_void_p(self.m64p._handle),
|
rval = handle.PluginStartup(C.c_void_p(self.m64p._handle),
|
||||||
|
@ -230,7 +232,7 @@ class Core:
|
||||||
if rval not in [M64ERR_SUCCESS, M64ERR_ALREADY_INIT]:
|
if rval not in [M64ERR_SUCCESS, M64ERR_ALREADY_INIT]:
|
||||||
log.debug("plugin_startup()")
|
log.debug("plugin_startup()")
|
||||||
log.warn(self.error_message(rval))
|
log.warn(self.error_message(rval))
|
||||||
log.warn("%s plugin failed to start." % (name))
|
log.warn("%s failed to start." % (desc))
|
||||||
|
|
||||||
def plugin_shutdown(self, handle):
|
def plugin_shutdown(self, handle):
|
||||||
"""This function destroys data structures and releases
|
"""This function destroys data structures and releases
|
||||||
|
@ -271,7 +273,7 @@ class Core:
|
||||||
(plugin_handle, plugin_path, plugin_name,
|
(plugin_handle, plugin_path, plugin_name,
|
||||||
plugin_desc, plugin_version) = plugin_map
|
plugin_desc, plugin_version) = plugin_map
|
||||||
|
|
||||||
self.plugin_startup(plugin_handle, plugin_name)
|
self.plugin_startup(plugin_handle, plugin_name, plugin_desc)
|
||||||
rval = self.m64p.CoreAttachPlugin(
|
rval = self.m64p.CoreAttachPlugin(
|
||||||
C.c_int(plugin_type),
|
C.c_int(plugin_type),
|
||||||
C.c_void_p(plugin_handle._handle))
|
C.c_void_p(plugin_handle._handle))
|
||||||
|
|
|
@ -20,7 +20,7 @@ CORE_NAME = "mupen64plus"
|
||||||
CORE_API_VERSION = 0x20001
|
CORE_API_VERSION = 0x20001
|
||||||
CONFIG_API_VERSION = 0x20000
|
CONFIG_API_VERSION = 0x20000
|
||||||
MINIMUM_CORE_VERSION = 0x016300
|
MINIMUM_CORE_VERSION = 0x016300
|
||||||
FRONTEND_VERSION = "0.1.1"
|
FRONTEND_VERSION = "0.1.2"
|
||||||
|
|
||||||
SIZE_1X = (320, 240)
|
SIZE_1X = (320, 240)
|
||||||
SIZE_2X = (640, 480)
|
SIZE_2X = (640, 480)
|
||||||
|
@ -183,7 +183,7 @@ class m64p_2d_size(C.Structure):
|
||||||
('uiHeight', C.c_uint)
|
('uiHeight', C.c_uint)
|
||||||
]
|
]
|
||||||
|
|
||||||
FuncInit =C.CFUNCTYPE(m64p_error)
|
FuncInit = C.CFUNCTYPE(m64p_error)
|
||||||
FuncQuit = C.CFUNCTYPE(m64p_error)
|
FuncQuit = C.CFUNCTYPE(m64p_error)
|
||||||
FuncListModes = C.CFUNCTYPE(m64p_error, C.POINTER(m64p_2d_size), C.POINTER(C.c_int))
|
FuncListModes = C.CFUNCTYPE(m64p_error, C.POINTER(m64p_2d_size), C.POINTER(C.c_int))
|
||||||
FuncSetMode = C.CFUNCTYPE(m64p_error, C.c_int, C.c_int, C.c_int, C.c_int)
|
FuncSetMode = C.CFUNCTYPE(m64p_error, C.c_int, C.c_int, C.c_int, C.c_int)
|
||||||
|
@ -192,7 +192,8 @@ FuncGLSetAttr = C.CFUNCTYPE(m64p_error, m64p_GLattr, C.c_int)
|
||||||
FuncGLGetAttr = C.CFUNCTYPE(m64p_error, m64p_GLattr, C.POINTER(C.c_int))
|
FuncGLGetAttr = C.CFUNCTYPE(m64p_error, m64p_GLattr, C.POINTER(C.c_int))
|
||||||
FuncGLSwapBuf = C.CFUNCTYPE(m64p_error)
|
FuncGLSwapBuf = C.CFUNCTYPE(m64p_error)
|
||||||
FuncSetCaption = C.CFUNCTYPE(m64p_error, C.c_char_p)
|
FuncSetCaption = C.CFUNCTYPE(m64p_error, C.c_char_p)
|
||||||
FuncToggleFS= C.CFUNCTYPE(m64p_error)
|
FuncToggleFS = C.CFUNCTYPE(m64p_error)
|
||||||
|
FuncResizeWindow = C.CFUNCTYPE(m64p_error, C.c_int, C.c_int)
|
||||||
|
|
||||||
class m64p_video_extension_functions(C.Structure):
|
class m64p_video_extension_functions(C.Structure):
|
||||||
_fields_ = [
|
_fields_ = [
|
||||||
|
@ -207,4 +208,5 @@ class m64p_video_extension_functions(C.Structure):
|
||||||
('VidExtFuncGLSwapBuf', FuncGLSwapBuf),
|
('VidExtFuncGLSwapBuf', FuncGLSwapBuf),
|
||||||
('VidExtFuncSetCaption', FuncSetCaption),
|
('VidExtFuncSetCaption', FuncSetCaption),
|
||||||
('VidExtFuncToggleFS', FuncToggleFS),
|
('VidExtFuncToggleFS', FuncToggleFS),
|
||||||
|
('VidExtFuncResizeWindow', FuncResizeWindow)
|
||||||
]
|
]
|
||||||
|
|
|
@ -149,9 +149,14 @@ class Video():
|
||||||
self.widget.swapBuffers()
|
self.widget.swapBuffers()
|
||||||
return M64ERR_SUCCESS
|
return M64ERR_SUCCESS
|
||||||
|
|
||||||
|
def resize_window(self, width, height):
|
||||||
|
"""Called when the video plugin has resized its OpenGL
|
||||||
|
output viewport in response to a ResizeVideoOutput() call"""
|
||||||
|
return M64ERR_SUCCESS
|
||||||
|
|
||||||
video = Video()
|
video = Video()
|
||||||
vidext = m64p_video_extension_functions()
|
vidext = m64p_video_extension_functions()
|
||||||
vidext.Functions = 10
|
vidext.Functions = 11
|
||||||
vidext.VidExtFuncInit = FuncInit(video.init)
|
vidext.VidExtFuncInit = FuncInit(video.init)
|
||||||
vidext.VidExtFuncQuit = FuncQuit(video.quit)
|
vidext.VidExtFuncQuit = FuncQuit(video.quit)
|
||||||
vidext.VidExtFuncListModes = FuncListModes(video.list_fullscreen_modes)
|
vidext.VidExtFuncListModes = FuncListModes(video.list_fullscreen_modes)
|
||||||
|
@ -162,3 +167,4 @@ vidext.VidExtFuncGLGetAttr = FuncGLGetAttr(video.gl_get_attr)
|
||||||
vidext.VidExtFuncGLSwapBuf = FuncGLSwapBuf(video.gl_swap_buf)
|
vidext.VidExtFuncGLSwapBuf = FuncGLSwapBuf(video.gl_swap_buf)
|
||||||
vidext.VidExtFuncSetCaption = FuncSetCaption(video.set_caption)
|
vidext.VidExtFuncSetCaption = FuncSetCaption(video.set_caption)
|
||||||
vidext.VidExtFuncToggleFS = FuncToggleFS(video.toggle_fs)
|
vidext.VidExtFuncToggleFS = FuncToggleFS(video.toggle_fs)
|
||||||
|
vidext.VidExtFuncResizeWindow = FuncResizeWindow(video.resize_window)
|
||||||
|
|
|
@ -101,10 +101,14 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||||
if self.worker.use_vidext and self.worker.m64p.get_handle():
|
if self.worker.use_vidext and self.worker.m64p.get_handle():
|
||||||
# FIXME event.ignore() doesn't work on windows
|
# FIXME event.ignore() doesn't work on windows
|
||||||
if not sys.platform == "win32":
|
if not sys.platform == "win32":
|
||||||
width, height = self.keep_aspect(size)
|
if not self.window().isFullScreen():
|
||||||
|
width, height = self.keep_aspect(size)
|
||||||
self.worker.m64p.config.open_section("Video-General")
|
self.worker.m64p.config.open_section("Video-General")
|
||||||
self.worker.m64p.config.set_parameter("ScreenWidth", width)
|
self.worker.m64p.config.set_parameter("ScreenWidth", width)
|
||||||
self.worker.m64p.config.set_parameter("ScreenHeight", height)
|
self.worker.m64p.config.set_parameter("ScreenHeight", height)
|
||||||
|
if self.worker.state in (M64EMU_RUNNING, M64EMU_PAUSED):
|
||||||
|
self.worker.core_state_set(
|
||||||
|
M64CORE_VIDEO_SIZE, (width << 16) + height)
|
||||||
self.set_sizes((width, height))
|
self.set_sizes((width, height))
|
||||||
self.settings.qset.setValue("size", (width, height))
|
self.settings.qset.setValue("size", (width, height))
|
||||||
self.resize(width, height + self.widgets_height)
|
self.resize(width, height + self.widgets_height)
|
||||||
|
|
|
@ -70,7 +70,7 @@ class ROMList(QMainWindow, Ui_ROMList):
|
||||||
def init(self):
|
def init(self):
|
||||||
self.read_rom_list()
|
self.read_rom_list()
|
||||||
self.roms = self.qset.value("rom_list", [])
|
self.roms = self.qset.value("rom_list", [])
|
||||||
if bool(self.qset.value("show_available", 0)):
|
if bool(int(self.qset.value("show_available", 0))):
|
||||||
self.add_available_items(self.roms)
|
self.add_available_items(self.roms)
|
||||||
else:
|
else:
|
||||||
self.add_items()
|
self.add_items()
|
||||||
|
|
|
@ -225,7 +225,7 @@ class Settings(QDialog, Ui_Settings):
|
||||||
if tooltip:
|
if tooltip:
|
||||||
self.checkFullscreen.setToolTip(tooltip)
|
self.checkFullscreen.setToolTip(tooltip)
|
||||||
|
|
||||||
enable_vidext = bool(self.qset.value("enable_vidext", 1))
|
enable_vidext = bool(int(self.qset.value("enable_vidext", 1)))
|
||||||
self.checkEnableVidExt.setChecked(enable_vidext)
|
self.checkEnableVidExt.setChecked(enable_vidext)
|
||||||
|
|
||||||
def set_core(self):
|
def set_core(self):
|
||||||
|
@ -281,8 +281,7 @@ class Settings(QDialog, Ui_Settings):
|
||||||
width, height = self.comboResolution.currentText().split("x")
|
width, height = self.comboResolution.currentText().split("x")
|
||||||
self.m64p.config.set_parameter("ScreenWidth", int(width))
|
self.m64p.config.set_parameter("ScreenWidth", int(width))
|
||||||
self.m64p.config.set_parameter("ScreenHeight", int(height))
|
self.m64p.config.set_parameter("ScreenHeight", int(height))
|
||||||
self.m64p.config.set_parameter("Fullscreen",
|
self.m64p.config.set_parameter("Fullscreen", self.checkFullscreen.isChecked())
|
||||||
self.checkFullscreen.isChecked())
|
|
||||||
self.qset.setValue("enable_vidext", int(self.checkEnableVidExt.isChecked()))
|
self.qset.setValue("enable_vidext", int(self.checkEnableVidExt.isChecked()))
|
||||||
|
|
||||||
def save_core(self):
|
def save_core(self):
|
||||||
|
|
|
@ -39,8 +39,8 @@ class Worker(QThread):
|
||||||
self.m64p = Core()
|
self.m64p = Core()
|
||||||
self.video = video
|
self.video = video
|
||||||
self.settings = Settings(self.parent)
|
self.settings = Settings(self.parent)
|
||||||
self.use_vidext = bool(
|
self.use_vidext = bool(int(
|
||||||
self.settings.qset.value("enable_vidext", 1))
|
self.settings.qset.value("enable_vidext", 1)))
|
||||||
self.core_load()
|
self.core_load()
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue