1 /**********************************************************************
2  *
3  *   FreeDoko a Doppelkopf-Game
4  *
5  *   Copyright (C) 2001 – 2018 by Diether Knof and Borg Enders
6  *
7  *   This program is free software; you can redistribute it and/or
8  *   modify it under the terms of the GNU General Public License as
9  *   published by the Free Software Foundation; either version 2 of
10  *   the License, or (at your option) any later version.
11  *
12  *   This program is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *   You can find this license in the file 'gpl.txt'.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with this program; if not, write to the Free Software
20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  *   MA  02111-1307  USA
22  *
23  *  Contact:
24  *    Diether Knof dknof@posteo.de
25  *
26  **********************************************************************/
27 
28 #ifdef USE_UI_GTKMM
29 
30 #pragma once
31 
32 #include "base.h"
33 #include "widgets/sticky_dialog.h"
34 namespace Gtk {
35 class Notebook;
36 class Button;
37 class Label;
38 class SpinButton;
39 class CheckButton;
40 class RadioButton;
41 class Frame;
42 } // namespace Gtk
43 
44 class Setting;
45 class Player;
46 class Aiconfig;
47 
48 namespace UI_GTKMM_NS {
49 class Players;
50 class Rules;
51 
52 /**
53  ** the party settings dialog
54  **/
55 class PartySettings : public Base, public Gtk::StickyDialog {
56   public:
57     explicit PartySettings(Base* parent);
58     ~PartySettings() override;
59 
60     PartySettings() = delete;
61     PartySettings(PartySettings const&) = delete;
62     PartySettings& operator=(PartySettings const&) = delete;
63 
64     // get the party settings
65     void get();
66     // the shown signal
67     void on_show() override;
68 
69     // load a bug report
70     void load_bug_report();
71 
72     // update the sensitivity
73     void sensitivity_update();
74     // update the seed value sensitivity
75     void seed_value_sensitivity_update();
76 
77     // update all
78     void update();
79 
80     // update the rules (value, sensitivity)
81     void rules_update();
82     // the rules have changed
83     void rule_change(int type);
84 
85     // the players have been swapped
86     void players_swapped(::Player const& player_a,
87                          ::Player const& player_b);
88     // update the player
89     void player_update(::Player const& player);
90     // update the name of the player
91     void name_update(::Player const& player);
92   private:
93     // update the name and font of the player
94     void name_update_local(::Player const& player);
95   public:
96     // update the font of the player
97     void voice_update(::Player const& player);
98     // update the aiconfig
99     void aiconfig_update(::Aiconfig const& aiconfig);
100 
101   private:
102     // initialize the window
103     void init();
104 
105     // event: start the party
106     void start_party_event();
107 
108     // event: the seed has changed
109     void seed_change_event();
110     // event: the startplayer has changed
111     void startplayer_change_event();
112 
113     // event: players have changed
114     void swap_players_event(unsigned p);
115 
116     // event: a key press
117     bool key_press(GdkEventKey* key);
118 
119   public:
120     unique_ptr<Players> players;
121     unique_ptr<Rules> rules;
122 
123   private:
124     AutoDisconnector disconnector_;
125 
126     Gtk::Button* load_bug_report_button = nullptr;
127     Gtk::Button* start_party_button = nullptr;
128     Gtk::Button* close_button = nullptr;
129 
130     Gtk::Frame* seed_frame = nullptr;
131     Gtk::SpinButton* seed_value = nullptr;
132     Gtk::CheckButton* seed_random = nullptr;
133 
134     Gtk::CheckButton* rule_number_of_rounds_limited = nullptr;
135     Gtk::SpinButton* rule_number_of_rounds = nullptr;
136     Gtk::CheckButton* rule_points_limited = nullptr;
137     Gtk::SpinButton* rule_points = nullptr;
138 
139     Gtk::Frame* startplayer_frame = nullptr;
140     vector<Gtk::RadioButton*> startplayer;
141     Gtk::RadioButton* startplayer_random = nullptr;
142     vector<Gtk::Button*> swap_players_buttons;
143 
144     Gtk::Button* configure_players = nullptr;
145     Gtk::Button* configure_rules = nullptr;
146 }; // class PartySettings : public Base, public Gtk::StickyDialog
147 
148 } // namespace UI_GTKMM_NS
149 
150 #endif // #ifdef USE_UI_GTKMM
151