Skip to content

Commit

Permalink
Add custom FPS option
Browse files Browse the repository at this point in the history
  • Loading branch information
adazem009 committed Apr 10, 2024
1 parent 6bc8120 commit d2649ea
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/app/qml/dialogs/ProjectSettingsDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import ScratchCPP
import ScratchCPP.UiComponents
import ScratchCPP.Render

Expand All @@ -29,5 +30,23 @@ CustomDialog {
checked: !projectPlayer.spriteFencing
onCheckedChanged: projectPlayer.spriteFencing = !checked
}

RowLayout {
Label {
text: qsTr("FPS (frames per second)")
}

SpinBox {
editable: true
from: 1
to: 250
stepSize: 10
value: projectPlayer.fps
onValueChanged: {
projectPlayer.fps = value;
AppMenuBar.fps60Mode = (value === 60);
}
}
}
}
}
10 changes: 8 additions & 2 deletions src/app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ApplicationWindow {
id: root
minimumWidth: layout.implicitWidth + layout.anchors.margins * 2
minimumHeight: menuBar.height + layout.implicitHeight + layout.anchors.margins * 2
visible: true
visible: true
title: Qt.application.displayName
color: Material.background
Material.accent: "orange"
Expand All @@ -33,6 +33,13 @@ ApplicationWindow {
player.fileName = fileName;
}

function onFps60ModeChanged() {
if(AppMenuBar.fps60Mode)
player.fps = 60;
else if(player.fps === 60)
player.fps = 30;
}

function onProjectSettingsTriggered() {
projectSettingsDialog.open();
}
Expand Down Expand Up @@ -134,7 +141,6 @@ ApplicationWindow {
activeFocusOnTab: true
focus: true
turboMode: AppMenuBar.turboMode
fps: AppMenuBar.fps60Mode ? 60 : 30
}
}
}

0 comments on commit d2649ea

Please sign in to comment.