add Limit FPS action

This commit is contained in:
gen2brain 2013-06-07 18:37:11 +02:00
parent b0cb5be057
commit c9c9475603
4 changed files with 41 additions and 1 deletions

View file

@ -275,6 +275,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.actionMute.setEnabled(action)
self.actionStop.setEnabled(action)
self.actionReset.setEnabled(action)
self.actionLimitFPS.setEnabled(action)
self.actionSlowDown.setEnabled(action)
self.actionSpeedUp.setEnabled(action)
self.actionFullscreen.setEnabled(action)
@ -299,6 +300,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.stack.setCurrentWidget(self.view)
self.actionMute.setChecked(False)
self.actionPause.setChecked(False)
self.actionLimitFPS.setChecked(True)
self.on_set_caption("M64Py")
self.update_status("ROM closed.")
del self.cheats
@ -393,6 +395,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
"""Resets emulator."""
self.worker.reset()
@pyqtSignature("")
def on_actionLimitFPS_triggered(self):
"""Toggles speed limit."""
self.worker.toggle_speed_limit()
@pyqtSignature("")
def on_actionSlowDown_triggered(self):
"""Speeds down emulator."""

View file

@ -264,6 +264,15 @@ class Worker(QThread):
else:
self.core_state_set(M64CORE_AUDIO_MUTE, 1)
def toggle_speed_limit(self):
"""Toggles speed limiter."""
if self.core_state_query(M64CORE_SPEED_LIMITER):
self.core_state_set(M64CORE_SPEED_LIMITER, 0)
log.info("Speed limiter disabled")
else:
self.core_state_set(M64CORE_SPEED_LIMITER, 1)
log.info("Speed limiter enabled")
def toggle_actions(self):
"""Toggles actions state."""
self.state = self.core_state_query(M64CORE_EMU_STATE)

View file

@ -119,6 +119,8 @@
<addaction name="actionStop"/>
<addaction name="actionReset"/>
<addaction name="separator"/>
<addaction name="actionLimitFPS"/>
<addaction name="separator"/>
<addaction name="actionSlowDown"/>
<addaction name="actionSpeedUp"/>
<addaction name="separator"/>
@ -576,6 +578,20 @@ QStatusBar { margin:0px; }</string>
<string>Save As...</string>
</property>
</action>
<action name="actionLimitFPS">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Limit FPS</string>
</property>
</action>
</widget>
<resources>
<include location="images.qrc"/>

View file

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'mainwindow.ui'
#
# Created: Fri Jun 7 14:15:00 2013
# Created: Fri Jun 7 16:09:00 2013
# by: PyQt4 UI code generator 4.10.1
#
# WARNING! All changes made in this file will be lost!
@ -248,6 +248,11 @@ class Ui_MainWindow(object):
self.actionSaveAs.setEnabled(False)
self.actionSaveAs.setIcon(icon9)
self.actionSaveAs.setObjectName(_fromUtf8("actionSaveAs"))
self.actionLimitFPS = QtGui.QAction(MainWindow)
self.actionLimitFPS.setCheckable(True)
self.actionLimitFPS.setChecked(True)
self.actionLimitFPS.setEnabled(False)
self.actionLimitFPS.setObjectName(_fromUtf8("actionLimitFPS"))
self.menuLoad.addAction(self.actionManually)
self.menuLoad.addAction(self.actionFromList)
self.menuFile.addAction(self.menuLoad.menuAction())
@ -276,6 +281,8 @@ class Ui_MainWindow(object):
self.menuEmulation.addAction(self.actionStop)
self.menuEmulation.addAction(self.actionReset)
self.menuEmulation.addSeparator()
self.menuEmulation.addAction(self.actionLimitFPS)
self.menuEmulation.addSeparator()
self.menuEmulation.addAction(self.actionSlowDown)
self.menuEmulation.addAction(self.actionSpeedUp)
self.menuEmulation.addSeparator()
@ -356,6 +363,7 @@ class Ui_MainWindow(object):
self.actionCheats.setShortcut(_translate("MainWindow", "F2", None))
self.actionLoadFrom.setText(_translate("MainWindow", "Load From...", None))
self.actionSaveAs.setText(_translate("MainWindow", "Save As...", None))
self.actionLimitFPS.setText(_translate("MainWindow", "Limit FPS", None))
import images_rc
import icons_rc