-
Notifications
You must be signed in to change notification settings - Fork 59
Allow pausing #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow pausing #48
Conversation
Thanks! I'll try to review it soon! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good! Thank you!
I made some comments about where I think there need to be changes.
Sorry for the long delay! :(
@@ -71,7 +73,17 @@ static char* g_outputFilename = NULL; /* in case -p/-i flag we get a filename p | |||
static int g_sudokuCount = 1; /* in case of -n we can the numbers of sudoku that should end up in the PDf (-p) */ | |||
static bool g_outIsPDF; | |||
static DIFFICULTY g_level = D_EASY; | |||
static WINDOW *grid, *infobox, *status; | |||
static WINDOW *grid, *infobox, *status, *resume; | |||
static bool is_board_solved = false; /* if the board is solved, we do not save the state */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would propose to remove this variable and not check if the user solved/not ask him if he wants to save.
I would like to just have an option "lets save". And the user can do this when he wants but don't add the overhead of tracking this and asking him.
@@ -333,6 +345,8 @@ static void init_windows(void) | |||
wprintw(infobox, _(" r - Redraw\n")); | |||
wprintw(infobox, _(" S - Solve puzzle\n")); | |||
wprintw(infobox, _(" x - Delete number\n")); | |||
wprintw(infobox, _(" g - Save\n")); | |||
wprintw(infobox, _(" G - Save and quit\n")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think save
is enough. The user can use save
and then quit
.
const char* home_path = getenv("HOME"); | ||
size_t len_home_path = strlen(home_path); | ||
|
||
const char* dir_name = "/.nudoku/"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use something like: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
Most likely: $XDG_STATE_HOME defines the base directory relative to which user-specific state files should be stored. If $XDG_STATE_HOME is either not set or empty, a default equal to $HOME/.local/state should be used.
strcat(file_path, file_name); | ||
|
||
free(dir_path); | ||
return file_path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is this file removed again? I think in is_game_saved
you test for the presence of it. But I don't see where it get's removed when the game is finished.
@dogukanteber ping |
Wow! It has been quite some time. I completely forgot about this PR @jubalh. My apologies. I will try to allocate some time to finish up this PR. |
@dogukanteber @jubalh Do you mind if I try to finish up this PR? (will create a new one though) |
Sure! Go for it :) |
Resolves #47. Now the users can save the game and quit. If the game is saved, the next time they open nudoku, a pop-up asks them to resume where they left off or create a new game. Currently, there is no coloring in the pop-up. If there is a necessity to add colors, it is not a difficult task. It can be added easily as long as which colors is going to be used are provided.