Skip to content

Commit 9e42cb0

Browse files
committed
Add FPS counter
Resolves: #30
1 parent 8088265 commit 9e42cb0

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/app/qml/dialogs/ProjectSettingsDialog.qml

+8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import ScratchCPP.Render
99

1010
CustomDialog {
1111
property ProjectPlayer projectPlayer: null
12+
property bool showCurrentFps: false
1213
title: qsTr("Project settings")
1314
standardButtons: Dialog.Close
1415

@@ -44,6 +45,13 @@ CustomDialog {
4445
onCheckedChanged: projectPlayer.hqPen = checked
4546
}
4647

48+
CheckBox {
49+
id: showFpsCheckBox
50+
text: qsTr("Show current FPS")
51+
checked: showCurrentFps
52+
onCheckedChanged: showCurrentFps = checked
53+
}
54+
4755
// Remove limits
4856
Label {
4957
text: qsTr("Remove limits")

src/app/qml/main.qml

+19
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,25 @@ ApplicationWindow {
170170
onLoaded: {
171171
if(unsupportedBlocks.length > 0)
172172
unsupportedBlocksDialog.open()
173+
174+
currentFps.enable = true;
175+
}
176+
177+
Loader {
178+
id: currentFps
179+
property bool enable: false
180+
active: projectSettingsDialog.showCurrentFps && enable
181+
anchors.right: player.stageRect.right
182+
anchors.top: player.stageRect.top
183+
184+
sourceComponent: Text {
185+
text: player.renderFps
186+
font.pointSize: 20 * player.stageScale
187+
font.family: "mono"
188+
color: Qt.rgba(1, 0, 0, 0.75)
189+
style: Text.Outline
190+
styleColor: "black"
191+
}
173192
}
174193
}
175194
}

0 commit comments

Comments
 (0)