Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wordle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
repos.tanguy.cavagna
sequencial programming
wordle
Commits
723e7da2
Commit
723e7da2
authored
3 years ago
by
tanguy.cavagna
Browse files
Options
Downloads
Patches
Plain Diff
Better menu and returning to menu handling
parent
cffb3ddd
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
main.c
+6
-10
6 additions, 10 deletions
main.c
ui/ui.c
+14
-5
14 additions, 5 deletions
ui/ui.c
wordle/wordle.c
+6
-0
6 additions, 0 deletions
wordle/wordle.c
with
26 additions
and
15 deletions
main.c
+
6
−
10
View file @
723e7da2
...
@@ -9,17 +9,13 @@
...
@@ -9,17 +9,13 @@
int
main
(
void
)
{
int
main
(
void
)
{
setlocale
(
LC_ALL
,
""
);
setlocale
(
LC_ALL
,
""
);
init_term
();
init_term
();
int
menu_choice
;
int
menu_choice
=
show_menu
();
while
((
menu_choice
=
show_menu
())
!=
MENU_QUIT
)
{
clear
();
if
(
menu_choice
==
MENU_QUIT
)
{
set_gamemode
(
menu_choice
);
cleanup_term
();
launch_game
();
return
EXIT_SUCCESS
;
};
}
clear
();
set_gamemode
(
menu_choice
);
launch_game
();
cleanup_term
();
cleanup_term
();
...
...
This diff is collapsed.
Click to expand it.
ui/ui.c
+
14
−
5
View file @
723e7da2
...
@@ -44,6 +44,17 @@ void draw_menu(int menu_item) {
...
@@ -44,6 +44,17 @@ void draw_menu(int menu_item) {
}
}
}
}
/**
* @brief Hide the help subwindow
*/
void
hide_help
()
{
wclear
(
ui_window
);
delwin
(
help
);
refresh
();
help
=
NULL
;
}
//==========================
//==========================
// PUBLIC
// PUBLIC
//==========================
//==========================
...
@@ -80,6 +91,8 @@ void cleanup_term() {
...
@@ -80,6 +91,8 @@ void cleanup_term() {
}
}
int
show_menu
()
{
int
show_menu
()
{
hide_help
();
char
title
[
8
][
64
]
=
{
"$$
\\
$$
\\
$$$$$$
\\
$$$$$$$
\\
$$$$$$$
\\
$$
\\
$$$$$$$$
\\
"
,
char
title
[
8
][
64
]
=
{
"$$
\\
$$
\\
$$$$$$
\\
$$$$$$$
\\
$$$$$$$
\\
$$
\\
$$$$$$$$
\\
"
,
"$$ | $
\\
$$ |$$ __$$
\\
$$ __$$
\\
$$ __$$
\\
$$ | $$ _____|"
,
"$$ | $
\\
$$ |$$ __$$
\\
$$ __$$
\\
$$ __$$
\\
$$ | $$ _____|"
,
"$$ |$$$
\\
$$ |$$ / $$ |$$ | $$ |$$ | $$ |$$ | $$ | "
,
"$$ |$$$
\\
$$ |$$ / $$ |$$ | $$ |$$ | $$ |$$ | $$ | "
,
...
@@ -133,11 +146,7 @@ int show_menu() {
...
@@ -133,11 +146,7 @@ int show_menu() {
void
toggle_help
()
{
void
toggle_help
()
{
// Delete existing instance of the subwindow
// Delete existing instance of the subwindow
if
(
help
!=
NULL
)
{
if
(
help
!=
NULL
)
{
wclear
(
ui_window
);
hide_help
();
delwin
(
help
);
refresh
();
help
=
NULL
;
return
;
return
;
}
}
...
...
This diff is collapsed.
Click to expand it.
wordle/wordle.c
+
6
−
0
View file @
723e7da2
...
@@ -15,6 +15,12 @@ int current_try_letter_id = 0;
...
@@ -15,6 +15,12 @@ int current_try_letter_id = 0;
* @brief Initialize the game
* @brief Initialize the game
*/
*/
void
initialize_game
()
{
void
initialize_game
()
{
// Reset game variables
_game_finished
=
false
;
current_try_id
=
0
;
current_try_letter_id
=
0
;
// Tries and answer setup
chosen_word
=
"SALUT"
;
// Must be randomly picked in a dictionary
chosen_word
=
"SALUT"
;
// Must be randomly picked in a dictionary
tries
=
calloc
(
TRIES_COUNT
,
sizeof
(
char
*
));
tries
=
calloc
(
TRIES_COUNT
,
sizeof
(
char
*
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment