Bug 168613 - Provide a pause option
Summary: Provide a pause option
Status: RESOLVED FIXED
Alias: None
Product: ksudoku
Classification: Applications
Component: general (other bugs)
Version First Reported In: 0.5
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: spmorton
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-07 16:05 UTC by Richard Hartmann
Modified: 2025-03-23 22:35 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Hartmann 2008-08-07 16:05:53 UTC
Version:           0.5 (using 4.1.00 (KDE 4.1.0), Debian packages)
Compiler:          cc
OS:                Linux (i686) release 2.6.26-1-686

As the game is timed, a pause option would be great. :)
Comment 1 Marco Mattiolo 2009-08-02 10:43:11 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.
Comment 2 SDEbey74074 2021-10-23 23:05:34 UTC
opened 12 years ago, has any progress been made on this?
Comment 3 VoxelTek 2025-01-31 04:36:59 UTC
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.
Comment 4 spmorton 2025-02-17 00:31:02 UTC
I have a solution for this in the works
Comment 5 spmorton 2025-02-17 00:31:24 UTC
(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
Comment 6 spmorton 2025-02-17 00:37:17 UTC
(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.
Comment 7 Bug Janitor Service 2025-02-19 02:45:54 UTC
A possibly relevant merge request was started @ https://invent.kde.org/games/ksudoku/-/merge_requests/36
Comment 8 Albert Astals Cid 2025-03-23 22:35:27 UTC
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