20
20
#ifndef WL_EDITOR_UI_MENUS_PLAYER_MENU_H
21
21
#define WL_EDITOR_UI_MENUS_PLAYER_MENU_H
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"
33
33
class EditorInteractive;
40
35
class EditorPlayerMenu : public UI::UniqueWindow {
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) {
53
UI::Dropdown<std::string>* tribe;
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];
54
std::vector<std::string> tribenames_;
56
/// List of the tribes currently selected for all players
57
std::string selected_tribes_[kMaxPlayers];
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);
67
void think() override;
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);
67
/// Resize window according to number of rows
68
void layout() override;
71
UI::Dropdown<uintptr_t> no_of_players_;
72
std::vector<std::unique_ptr<PlayerEditRow>> rows_;
74
const std::string default_tribe_;
70
77
#endif // end of include guard: WL_EDITOR_UI_MENUS_PLAYER_MENU_H