Summary: | Provide a pause option | ||
---|---|---|---|
Product: | [Applications] ksudoku | Reporter: | Richard Hartmann <richih-kde> |
Component: | general | Assignee: | spmorton |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | CC: | eaglecomputers.ok, marco.mattiolo, spmorton, voxeltek |
Priority: | NOR | ||
Version First Reported In: | 0.5 | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/games/ksudoku/-/commit/605a12918027088c77ea76762ff43d200d4b967d | Version Fixed In: | |
Sentry Crash Report: |
Description
Richard Hartmann
2008-08-07 16:05:53 UTC
Confirmed in Ksudoku 0.5 on Kde4.2.98 (kde4.3 RC3). It would also be great to automatically pause the timer when the game windows is minimized. opened 12 years ago, has any progress been made on this? I am also interested in a pause ability, and despite the fact I am absolutely NOT a C or C++ programmer, I took a look at the code for timing how long your game takes, in order to see if it might be modifiable to support pausing the game (and the timer). By the looks of it, the game counts the number of milliseconds since game start using a "QElapsedTimer" object. Now, this doesn't have the ability to be paused, but it may be possible to subtract time spent paused from the final time. For example, if another "QElapsedTimer" was started once the game was paused, it would record the duration spent not playing the game. Once the game is resumed, this could then be added to a variable (e.g. pausedTime), and then the QElapsedTimer object can be stopped and reset. The line calculating game playing time is: return (m_private->accumTime + m_private->time.elapsed()); This could potentially be modified to something like: return (m_private->accumTime + m_private->time.elapsed() - m_private->pausedTime); and then supporting code (such as another QElapsedTimer, and then naturally all the other code to pause the game) Again, I am very much NOT a C++ programmer, and I wouldn't feel confident changing stuff myself. Besides, I wouldn't have the first clue where to start with modifying the game and GUI to introduce a pause menu. However, I hope this might be able to help, even somewhat. I have a solution for this in the works (In reply to Marco Mattiolo from comment #1) > Confirmed in Ksudoku 0.5 on Kde4.2.98 (kde4.3 RC3). > It would also be great to automatically pause the timer when the game > windows is minimized. I'll see if I can work this in (In reply to VoxelTek from comment #3) > I am also interested in a pause ability, and despite the fact I am > absolutely NOT a C or C++ programmer, I took a look at the code for timing > how long your game takes, in order to see if it might be modifiable to > support pausing the game (and the timer). > > By the looks of it, the game counts the number of milliseconds since game > start using a "QElapsedTimer" object. Now, this doesn't have the ability to > be paused, but it may be possible to subtract time spent paused from the > final time. > > For example, if another "QElapsedTimer" was started once the game was > paused, it would record the duration spent not playing the game. Once the > game is resumed, this could then be added to a variable (e.g. pausedTime), > and then the QElapsedTimer object can be stopped and reset. > > The line calculating game playing time is: > > return (m_private->accumTime + m_private->time.elapsed()); > > > > This could potentially be modified to something like: > > return (m_private->accumTime + m_private->time.elapsed() - > m_private->pausedTime); > > and then supporting code (such as another QElapsedTimer, and then naturally > all the other code to pause the game) > > Again, I am very much NOT a C++ programmer, and I wouldn't feel confident > changing stuff myself. Besides, I wouldn't have the first clue where to > start with modifying the game and GUI to introduce a pause menu. However, I > hope this might be able to help, even somewhat. It would be easier to stop the timer, capture the current timer value in a var, and restore the time from the var just to be sure, once game play is resumed. For your last comments, yeah, this one is written like a java program... everything is a class and in C++ everything does not have to be and should not be a class IMO. A possibly relevant merge request was started @ https://invent.kde.org/games/ksudoku/-/merge_requests/36 Git commit 605a12918027088c77ea76762ff43d200d4b967d by Albert Astals Cid, on behalf of Scott Morton. Committed on 23/03/2025 at 22:35. Pushed by aacid into branch 'master'. Added pause functionality Added ability to minimize and pause the timer automatically Corrected restart game did not restart timer A +5 -0 src/Background.qrc M +11 -9 src/CMakeLists.txt M +108 -2 src/gui/ksudoku.cpp M +20 -2 src/gui/ksudoku.h M +2 -0 src/gui/ksudokuui.rc A +- -- src/shapes/icon_pause.png https://invent.kde.org/games/ksudoku/-/commit/605a12918027088c77ea76762ff43d200d4b967d |