make7libre
0.8.6
|
Main class contains the graphical interface (set by Glade and imported with Gtk::Builder) and the main functions of the game. More...
#include <game.h>
Public Member Functions | |
Game () | |
Constructor. More... | |
void | connect_every_button () |
Function containing a lot of lines. More... | |
void | display (Glib::RefPtr< Gtk::Application > app) |
Here is actually displayed the window. More... | |
void | import_every_widget () |
Function containing a lot of lines too. More... | |
void | launch_game () |
All initializations needed at the beginning of a new game. More... | |
Private Member Functions | |
void | big_badaboom (std::list< int > hexas) |
Erase all hexas around three (or more) matching "7" hexas. More... | |
void | check_end () |
void | display_error (int i) |
Spawns a Gtk::MessageDialog containing an appropriated message. More... | |
void | define_hexa (int ref, Glib::ustring valref) |
Define the new hexa then check neighbors while there are. More... | |
void | erase_hexa (int ref) |
Erase value and color of the given hexa. More... | |
std::map< int, Glib::ustring > | get_board_snapshot () |
Backup the whole Board and SelectionArea in a std::map. More... | |
void | game_button_selected (int ref) |
Called when any Board button is clicked. More... | |
Glib::ustring | get_config_file () |
Create config file if it doesn't exist, then return its path. More... | |
bool | get_confirmation () |
Ask user to confirm the quitting. More... | |
Glib::ustring | get_main_hexa () |
Returns the value of the main hexa button label. More... | |
int | get_neighbour (int rel, int givenRef) |
Calculates the position of a neighbor button. More... | |
int | get_pos2 () |
Returns pos2 (not very useful) More... | |
void | get_random_hexas () |
Generate random numbers and fill valHexa1 and valHexa2 with them. More... | |
void | get_scores () |
Read users scores from saved file. More... | |
Glib::ustring | get_second_hexa () |
Same as get_main_hexa () but with the second. More... | |
void | merge_hexas (int newHexa, std::list< int > oldHexas) |
Erase values and colors of matching neighbors. More... | |
void | on_cancel_action_activate () |
Signal function activated by button_cancel. More... | |
void | on_close_scores_activate () |
Signal function activated by button_close_scores. More... | |
void | on_display_credits_activate () |
Signal function activated by button_credits. More... | |
void | on_display_help_activate () |
Signal function activated by button_help. More... | |
void | on_display_scores_activate () |
Signal function activated by button_scores. More... | |
void | on_entry_editing_done () |
Activates button_apply_save when user hits 'Enter'. More... | |
bool | on_make7window_hide (_GdkEventAny *event) |
Signal function activated when user wants to quit. More... | |
void | on_new_game_activate () |
Signal function activated by button_new. More... | |
void | on_next_hexa_activate () |
Signal function activated by button_next. More... | |
void | on_quit_game_activate () |
Signal function activated by button_quit. More... | |
int | refresh_score () |
Update the amount of points in the score label. More... | |
void | refresh_selection_area () |
Re-display the content of the SelectionArea. More... | |
void | reset_board () |
Erase values and colors of all hexas on the Board. More... | |
void | reset_selection_area () |
Erase values and colors of all hexas on the SelectionArea. More... | |
void | reset_snapshot () |
Re-display an old configuration of Board and SelectionArea, using the std::map created by get_snapshot () More... | |
void | rotate_hexas_left () |
Signal function activated when user left-clicks on main hexa. More... | |
bool | rotate_hexas_right (GdkEventButton *event) |
Signal function activated when user right-clicks on main hexa. More... | |
bool | scan_neighbours (int ref, std::list< int > &oldRefs) |
Check if the neighbors of a given hexa have the same value as it. More... | |
void | set_main_hexa (Glib::ustring Snum) |
Put the string to the label of the main hexa in SelectionArea. More... | |
void | set_pos2 (int givenPos2) |
Set pos2 to the given value (not very useful) More... | |
void | set_second_hexa (Glib::ustring Snum) |
Same as set_main_hexa (), but with the second. More... | |
void | store_oldvalhexas () |
bool | triggers (int ref) |
Deal with a new hexa on the board. More... | |
void | update_hexa_color (int hexa) |
Change the color of a given hexa. More... | |
void | write_scores () |
Save the score in a file. More... | |
Private Attributes | |
Gtk::Window * | make7window |
Gtk::Window * | make7scores |
Gtk::MessageDialog * | make7message |
Gtk::MessageDialog * | make7error_board |
Gtk::MessageDialog * | make7confirm |
Gtk::MessageDialog * | make7askname |
Gtk::AboutDialog * | make7credits |
Gtk::HeaderBar * | headerbar |
Gtk::Menu * | appmenu |
Gtk::MenuItem * | newgame |
Gtk::MenuItem * | scores |
Gtk::MenuItem * | credits |
Gtk::MenuItem * | quit |
Gtk::Button * | button_cancel |
Gtk::Button * | button_close_scores |
Gtk::Button * | button_credits |
Gtk::Button * | button_help |
Gtk::Button * | button_new |
Gtk::Button * | button_next |
Gtk::Button * | button_quit |
Gtk::Button * | button_rotate |
Gtk::Button * | button_save |
Gtk::Button * | button_scores |
Gtk::ToggleButton * | button_erase |
Gtk::Button * | nnw |
Gtk::Button * | nn |
Gtk::Button * | nne |
Gtk::Button * | nww |
Gtk::Button * | nw |
Gtk::Button * | ne |
Gtk::Button * | nee |
Gtk::Button * | ww |
Gtk::Button * | w |
Gtk::Button * | m |
Gtk::Button * | e |
Gtk::Button * | ee |
Gtk::Button * | sww |
Gtk::Button * | sw |
Gtk::Button * | se |
Gtk::Button * | see |
Gtk::Button * | ssw |
Gtk::Button * | ss |
Gtk::Button * | sse |
Gtk::Button * | mainNw |
Gtk::Button * | mainNe |
Gtk::Button * | mainW |
Gtk::Button * | mainM |
Gtk::Button * | mainE |
Gtk::Button * | mainSw |
Gtk::Button * | mainSe |
Gtk::Label * | current_score |
Gtk::Box * | box_score |
Gtk::Entry * | user_entry |
std::map< int, Gtk::Button * > | Board |
std::map< int, Gtk::Button * > | SelectionArea |
std::map< int, Glib::ustring > | BoardSnapshotMap |
std::map< int, Glib::ustring > | Colors |
std::list< int > | BoardKeys |
std::list< int > | SelectionAreaKeys |
std::list< int > | ColorsKeys |
int | pos2 |
int | max |
int | valHexa1 |
int | valHexa2 |
int | score |
int | nMatch |
Glib::ustring | oldValHexa1 |
Glib::ustring | oldValHexa2 |
Glib::RefPtr< Gtk::CssProvider > | CssProvider |
Main class contains the graphical interface (set by Glade and imported with Gtk::Builder) and the main functions of the game.
Game::Game | ( | ) |
Constructor.
Here are defined the private variables, the GTK widgets, etc.
Maps and lists containing static informations are initialized, and CssProvider is created and set.
Definition at line 41 of file game.cc.
References BoardKeys, Colors, ColorsKeys, CssProvider, and SelectionAreaKeys.
|
private |
Erase all hexas around three (or more) matching "7" hexas.
Definition at line 262 of file game.cc.
References Board, get_neighbour(), SelectionAreaKeys, and update_hexa_color().
Referenced by merge_hexas().
|
private |
Definition at line 280 of file game.cc.
References get_board_snapshot(), launch_game(), make7message, and write_scores().
Referenced by erase_hexa(), and triggers().
void Game::connect_every_button | ( | ) |
Function containing a lot of lines.
Definition at line 83 of file game.cc.
References Board, BoardKeys, button_cancel, button_close_scores, button_help, button_next, credits, game_button_selected(), newgame, on_cancel_action_activate(), on_close_scores_activate(), on_display_credits_activate(), on_display_help_activate(), on_display_scores_activate(), on_entry_editing_done(), on_new_game_activate(), on_next_hexa_activate(), on_quit_game_activate(), quit, rotate_hexas_left(), rotate_hexas_right(), scores, SelectionArea, and user_entry.
Referenced by main().
|
private |
Define the new hexa then check neighbors while there are.
Definition at line 336 of file game.cc.
References Board, triggers(), and update_hexa_color().
Referenced by game_button_selected().
void Game::display | ( | Glib::RefPtr< Gtk::Application > | app | ) |
Here is actually displayed the window.
Accelerators settings
Window settings
Definition at line 130 of file game.cc.
References button_cancel, button_erase, button_help, button_next, credits, CssProvider, make7window, newgame, on_make7window_hide(), quit, and scores.
Referenced by main().
|
private |
Spawns a Gtk::MessageDialog containing an appropriated message.
Definition at line 318 of file game.cc.
References make7error_board.
Referenced by erase_hexa(), game_button_selected(), and refresh_score().
|
private |
Erase value and color of the given hexa.
Definition at line 347 of file game.cc.
References Board, button_erase, check_end(), display_error(), nMatch, refresh_score(), and update_hexa_color().
Referenced by game_button_selected().
|
private |
Called when any Board button is clicked.
Definition at line 376 of file game.cc.
References Board, BoardSnapshotMap, button_cancel, button_erase, define_hexa(), display_error(), erase_hexa(), get_board_snapshot(), get_main_hexa(), get_neighbour(), get_random_hexas(), get_second_hexa(), pos2, refresh_selection_area(), and store_oldvalhexas().
Referenced by connect_every_button().
|
private |
Backup the whole Board and SelectionArea in a std::map.
Definition at line 367 of file game.cc.
References Board, and BoardKeys.
Referenced by check_end(), and game_button_selected().
|
private |
Create config file if it doesn't exist, then return its path.
Definition at line 423 of file game.cc.
Referenced by get_scores(), and write_scores().
|
private |
Ask user to confirm the quitting.
Definition at line 448 of file game.cc.
References current_score, make7confirm, and write_scores().
Referenced by on_make7window_hide(), and on_new_game_activate().
|
private |
Returns the value of the main hexa button label.
Definition at line 463 of file game.cc.
References mainM.
Referenced by game_button_selected(), and store_oldvalhexas().
|
private |
Calculates the position of a neighbor button.
Get the hexa around the given one (ref)
Definition at line 472 of file game.cc.
Referenced by big_badaboom(), game_button_selected(), and scan_neighbours().
|
private |
Returns pos2 (not very useful)
Definition at line 498 of file game.cc.
References pos2.
Referenced by rotate_hexas_left(), and rotate_hexas_right().
|
private |
Generate random numbers and fill valHexa1 and valHexa2 with them.
Definition at line 504 of file game.cc.
References max, set_pos2(), valHexa1, and valHexa2.
Referenced by game_button_selected(), launch_game(), and on_next_hexa_activate().
|
private |
Read users scores from saved file.
Definition at line 521 of file game.cc.
References box_score, and get_config_file().
Referenced by launch_game().
|
private |
Same as get_main_hexa () but with the second.
Definition at line 551 of file game.cc.
References pos2, and SelectionArea.
Referenced by game_button_selected(), and store_oldvalhexas().
void Game::import_every_widget | ( | ) |
Function containing a lot of lines too.
Definition at line 165 of file game.cc.
References appmenu, Board, box_score, button_cancel, button_close_scores, button_erase, button_help, button_next, button_save, credits, current_score, e, ee, headerbar, m, mainE, mainM, mainNe, mainNw, mainSe, mainSw, mainW, make7askname, make7confirm, make7credits, make7error_board, make7message, make7scores, make7window, ne, nee, newgame, nn, nne, nnw, nw, nww, quit, scores, se, see, SelectionArea, ss, sse, ssw, sw, sww, user_entry, w, and ww.
Referenced by main().
void Game::launch_game | ( | ) |
All initializations needed at the beginning of a new game.
Definition at line 239 of file game.cc.
References current_score, get_random_hexas(), get_scores(), max, refresh_selection_area(), and reset_board().
Referenced by check_end(), main(), and on_new_game_activate().
|
private |
Erase values and colors of matching neighbors.
Definition at line 559 of file game.cc.
References big_badaboom(), Board, max, nMatch, refresh_score(), and update_hexa_color().
Referenced by triggers().
|
private |
Signal function activated by button_cancel.
Definition at line 591 of file game.cc.
References nMatch, refresh_score(), and reset_snapshot().
Referenced by connect_every_button().
|
private |
Signal function activated by button_close_scores.
Definition at line 599 of file game.cc.
References make7scores.
Referenced by connect_every_button().
|
private |
Signal function activated by button_credits.
Definition at line 605 of file game.cc.
References make7credits.
Referenced by connect_every_button().
|
private |
Signal function activated by button_help.
Definition at line 612 of file game.cc.
Referenced by connect_every_button().
|
private |
Signal function activated by button_scores.
Definition at line 620 of file game.cc.
References make7scores.
Referenced by connect_every_button().
|
private |
Activates button_apply_save when user hits 'Enter'.
Definition at line 626 of file game.cc.
References button_save.
Referenced by connect_every_button().
|
private |
Signal function activated when user wants to quit.
Definition at line 633 of file game.cc.
References get_confirmation().
Referenced by display().
|
private |
Signal function activated by button_new.
Definition at line 642 of file game.cc.
References get_confirmation(), and launch_game().
Referenced by connect_every_button().
|
private |
Signal function activated by button_next.
Definition at line 649 of file game.cc.
References get_random_hexas(), nMatch, refresh_score(), and refresh_selection_area().
Referenced by connect_every_button().
|
private |
Signal function activated by button_quit.
Definition at line 660 of file game.cc.
References make7window.
Referenced by connect_every_button().
|
private |
Update the amount of points in the score label.
Definition at line 666 of file game.cc.
References current_score, display_error(), and nMatch.
Referenced by erase_hexa(), merge_hexas(), on_cancel_action_activate(), on_next_hexa_activate(), and triggers().
|
private |
Re-display the content of the SelectionArea.
Definition at line 682 of file game.cc.
References reset_selection_area(), set_main_hexa(), set_second_hexa(), valHexa1, and valHexa2.
Referenced by game_button_selected(), launch_game(), on_next_hexa_activate(), reset_snapshot(), rotate_hexas_left(), and rotate_hexas_right().
|
private |
Erase values and colors of all hexas on the Board.
Definition at line 690 of file game.cc.
References Board, BoardKeys, and update_hexa_color().
Referenced by launch_game().
|
private |
Erase values and colors of all hexas on the SelectionArea.
Definition at line 700 of file game.cc.
References SelectionArea, SelectionAreaKeys, and update_hexa_color().
Referenced by refresh_selection_area(), reset_snapshot(), rotate_hexas_left(), and rotate_hexas_right().
|
private |
Re-display an old configuration of Board and SelectionArea, using the std::map created by get_snapshot ()
Definition at line 714 of file game.cc.
References Board, BoardKeys, BoardSnapshotMap, button_cancel, oldValHexa1, oldValHexa2, pos2, refresh_selection_area(), reset_selection_area(), set_pos2(), update_hexa_color(), valHexa1, and valHexa2.
Referenced by on_cancel_action_activate().
|
private |
Signal function activated when user left-clicks on main hexa.
Definition at line 733 of file game.cc.
References get_pos2(), refresh_selection_area(), reset_selection_area(), and set_pos2().
Referenced by connect_every_button().
|
private |
Signal function activated when user right-clicks on main hexa.
Definition at line 753 of file game.cc.
References get_pos2(), refresh_selection_area(), reset_selection_area(), and set_pos2().
Referenced by connect_every_button().
|
private |
Check if the neighbors of a given hexa have the same value as it.
Definition at line 777 of file game.cc.
References Board, get_neighbour(), nMatch, and SelectionAreaKeys.
Referenced by triggers().
|
private |
Put the string to the label of the main hexa in SelectionArea.
Definition at line 809 of file game.cc.
References mainM, and update_hexa_color().
Referenced by refresh_selection_area().
|
private |
Set pos2 to the given value (not very useful)
Definition at line 820 of file game.cc.
References pos2.
Referenced by get_random_hexas(), reset_snapshot(), rotate_hexas_left(), and rotate_hexas_right().
|
private |
Same as set_main_hexa (), but with the second.
Definition at line 826 of file game.cc.
References pos2, SelectionArea, and update_hexa_color().
Referenced by refresh_selection_area().
|
private |
Definition at line 840 of file game.cc.
References get_main_hexa(), get_second_hexa(), oldValHexa1, and oldValHexa2.
Referenced by game_button_selected().
|
private |
Deal with a new hexa on the board.
Definition at line 850 of file game.cc.
References check_end(), merge_hexas(), nMatch, refresh_score(), and scan_neighbours().
Referenced by define_hexa().
|
private |
Change the color of a given hexa.
Definition at line 873 of file game.cc.
References Board, Colors, ColorsKeys, CssProvider, and SelectionArea.
Referenced by big_badaboom(), define_hexa(), erase_hexa(), merge_hexas(), reset_board(), reset_selection_area(), reset_snapshot(), set_main_hexa(), and set_second_hexa().
|
private |
Save the score in a file.
Definition at line 905 of file game.cc.
References current_score, get_config_file(), make7askname, make7scores, and user_entry.
Referenced by check_end(), and get_confirmation().
|
private |
Definition at line 105 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 126 of file game.h.
Referenced by big_badaboom(), connect_every_button(), define_hexa(), erase_hexa(), game_button_selected(), get_board_snapshot(), import_every_widget(), merge_hexas(), reset_board(), reset_snapshot(), scan_neighbours(), and update_hexa_color().
|
private |
Definition at line 128 of file game.h.
Referenced by connect_every_button(), Game(), get_board_snapshot(), reset_board(), and reset_snapshot().
|
private |
Definition at line 127 of file game.h.
Referenced by game_button_selected(), and reset_snapshot().
|
private |
Definition at line 122 of file game.h.
Referenced by get_scores(), and import_every_widget().
|
private |
Definition at line 110 of file game.h.
Referenced by connect_every_button(), display(), game_button_selected(), import_every_widget(), and reset_snapshot().
|
private |
Definition at line 110 of file game.h.
Referenced by connect_every_button(), and import_every_widget().
|
private |
Definition at line 113 of file game.h.
Referenced by display(), erase_hexa(), game_button_selected(), and import_every_widget().
|
private |
Definition at line 110 of file game.h.
Referenced by connect_every_button(), display(), and import_every_widget().
|
private |
Definition at line 110 of file game.h.
Referenced by connect_every_button(), display(), and import_every_widget().
|
private |
Definition at line 110 of file game.h.
Referenced by import_every_widget(), and on_entry_editing_done().
|
private |
Definition at line 127 of file game.h.
Referenced by Game(), and update_hexa_color().
|
private |
Definition at line 128 of file game.h.
Referenced by Game(), and update_hexa_color().
|
private |
Definition at line 106 of file game.h.
Referenced by connect_every_button(), display(), and import_every_widget().
|
private |
Definition at line 131 of file game.h.
Referenced by display(), Game(), and update_hexa_color().
|
private |
Definition at line 121 of file game.h.
Referenced by get_confirmation(), import_every_widget(), launch_game(), refresh_score(), and write_scores().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 104 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by get_main_hexa(), import_every_widget(), and set_main_hexa().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 100 of file game.h.
Referenced by import_every_widget(), and write_scores().
|
private |
Definition at line 100 of file game.h.
Referenced by get_confirmation(), and import_every_widget().
|
private |
Definition at line 101 of file game.h.
Referenced by import_every_widget(), and on_display_credits_activate().
|
private |
Definition at line 100 of file game.h.
Referenced by display_error(), and import_every_widget().
|
private |
Definition at line 100 of file game.h.
Referenced by check_end(), and import_every_widget().
|
private |
Definition at line 99 of file game.h.
Referenced by import_every_widget(), on_close_scores_activate(), on_display_scores_activate(), and write_scores().
|
private |
Definition at line 99 of file game.h.
Referenced by display(), import_every_widget(), and on_quit_game_activate().
|
private |
Definition at line 129 of file game.h.
Referenced by get_random_hexas(), launch_game(), and merge_hexas().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 106 of file game.h.
Referenced by connect_every_button(), display(), and import_every_widget().
|
private |
Definition at line 129 of file game.h.
Referenced by erase_hexa(), merge_hexas(), on_cancel_action_activate(), on_next_hexa_activate(), refresh_score(), scan_neighbours(), and triggers().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 130 of file game.h.
Referenced by reset_snapshot(), and store_oldvalhexas().
|
private |
Definition at line 130 of file game.h.
Referenced by reset_snapshot(), and store_oldvalhexas().
|
private |
Definition at line 129 of file game.h.
Referenced by game_button_selected(), get_pos2(), get_second_hexa(), reset_snapshot(), set_pos2(), and set_second_hexa().
|
private |
Definition at line 106 of file game.h.
Referenced by connect_every_button(), display(), and import_every_widget().
|
private |
Definition at line 106 of file game.h.
Referenced by connect_every_button(), display(), and import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 126 of file game.h.
Referenced by connect_every_button(), get_second_hexa(), import_every_widget(), reset_selection_area(), set_second_hexa(), and update_hexa_color().
|
private |
Definition at line 128 of file game.h.
Referenced by big_badaboom(), Game(), reset_selection_area(), and scan_neighbours().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 123 of file game.h.
Referenced by connect_every_button(), import_every_widget(), and write_scores().
|
private |
Definition at line 129 of file game.h.
Referenced by get_random_hexas(), refresh_selection_area(), and reset_snapshot().
|
private |
Definition at line 129 of file game.h.
Referenced by get_random_hexas(), refresh_selection_area(), and reset_snapshot().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().
|
private |
Definition at line 115 of file game.h.
Referenced by import_every_widget().