~widelands-dev/widelands/frisian-buildings

« back to all changes in this revision

Viewing changes to src/editor/ui_menus/player_menu.h

  • Committer: Benedikt Straub
  • Date: 2018-07-17 10:13:49 UTC
  • mfrom: (8692.1.59 trunk)
  • Revision ID: benedikt-straub@web.de-20180717101349-yu2o6y2l5czmdbhr
Merged trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#ifndef WL_EDITOR_UI_MENUS_PLAYER_MENU_H
21
21
#define WL_EDITOR_UI_MENUS_PLAYER_MENU_H
22
22
 
23
 
#include <cstring>
24
 
#include <map>
 
23
#include <memory>
25
24
#include <string>
26
25
#include <vector>
27
26
 
28
 
#include "graphic/playercolor.h"
29
 
#include "logic/widelands.h"
 
27
#include "ui_basic/box.h"
30
28
#include "ui_basic/button.h"
 
29
#include "ui_basic/dropdown.h"
 
30
#include "ui_basic/editbox.h"
31
31
#include "ui_basic/unique_window.h"
32
32
 
33
33
class EditorInteractive;
34
 
namespace UI {
35
 
struct Textarea;
36
 
struct EditBox;
37
 
struct Button;
38
 
}
39
34
 
40
35
class EditorPlayerMenu : public UI::UniqueWindow {
41
36
public:
44
39
        }
45
40
 
46
41
private:
 
42
        // Container with UI elements to set a player slot's properties
 
43
        struct PlayerEditRow {
 
44
                explicit PlayerEditRow(UI::Box* init_box,
 
45
                                       UI::EditBox* init_name,
 
46
                                       UI::Button* init_position,
 
47
                                       UI::Dropdown<std::string>* init_tribe)
 
48
                   : box(init_box), name(init_name), position(init_position), tribe(init_tribe) {
 
49
                }
 
50
                UI::Box* box;
 
51
                UI::EditBox* name;
 
52
                UI::Button* position;
 
53
                UI::Dropdown<std::string>* tribe;
 
54
        };
 
55
 
47
56
        EditorInteractive& eia();
48
 
        UI::UniqueWindow::Registry allow_buildings_menu_;
49
 
        UI::Textarea* nr_of_players_ta_;
50
 
        UI::EditBox* plr_names_[kMaxPlayers];
51
 
        UI::Button add_player_, remove_last_player_;
52
 
        UI::Button *plr_set_pos_buts_[kMaxPlayers], *plr_set_tribes_buts_[kMaxPlayers];
53
 
 
54
 
        std::vector<std::string> tribenames_;
55
 
 
56
 
        /// List of the tribes currently selected for all players
57
 
        std::string selected_tribes_[kMaxPlayers];
58
 
 
59
 
        int32_t posy_;
60
 
 
61
 
        void name_changed(int32_t);
62
 
        void clicked_add_player();
63
 
        void clicked_remove_last_player();
64
 
        void player_tribe_clicked(uint8_t);
65
 
        void set_starting_pos_clicked(uint8_t);
66
 
        void update();
67
 
        void think() override;
 
57
 
 
58
        /// Update player name on map for the given row's player
 
59
        void name_changed(size_t row);
 
60
        /// Update number of player slots available on the map
 
61
        void no_of_players_clicked();
 
62
        /// Select tribe for the given row's player
 
63
        void player_tribe_clicked(size_t row);
 
64
        /// Select starting position for the given row's player
 
65
        void set_starting_pos_clicked(size_t row);
 
66
 
 
67
        /// Resize window according to number of rows
 
68
        void layout() override;
 
69
 
 
70
        UI::Box box_;
 
71
        UI::Dropdown<uintptr_t> no_of_players_;
 
72
        std::vector<std::unique_ptr<PlayerEditRow>> rows_;
 
73
 
 
74
        const std::string default_tribe_;
68
75
};
69
76
 
70
77
#endif  // end of include guard: WL_EDITOR_UI_MENUS_PLAYER_MENU_H