Display: removed interface that set up theme buttons

Unused now, since we're moving to GUI2 for the ingame UI. The functions to get buttons
are left, but they always return nullptr.
This commit is contained in:
Charles Dang 2018-03-21 14:08:44 +11:00
parent 39b05dd0db
commit e1e7f65ec1
7 changed files with 0 additions and 139 deletions

View file

@ -229,10 +229,6 @@ display::display(const display_context * dc, std::weak_ptr<wb::manager> wb, repo
init_flags();
if(!menu_buttons_.empty() || !action_buttons_.empty()) {
create_buttons();
}
rebuild_all();
assert(builder_);
//builder_->rebuild_cache_all();
@ -247,7 +243,6 @@ display::~display()
void display::set_theme(config theme_cfg) {
theme_ = theme(theme_cfg, video_.screen_area()); menu_buttons_.clear();
action_buttons_.clear();
create_buttons();
}
void display::init_flags() {
@ -801,122 +796,6 @@ std::shared_ptr<gui::button> display::find_menu_button(const std::string& id)
return nullptr;
}
void display::layout_buttons()
{
return;
DBG_DP << "positioning menu buttons...\n";
for(const auto& menu : theme_.menus()) {
std::shared_ptr<gui::button> b = find_menu_button(menu.get_id());
if(b) {
const SDL_Rect& loc = menu.location(video_.screen_area());
b->set_location(loc);
b->set_measurements(0,0);
b->set_label(menu.title());
b->set_image(menu.image());
}
}
DBG_DP << "positioning action buttons...\n";
for(const auto& action : theme_.actions()) {
std::shared_ptr<gui::button> b = find_action_button(action.get_id());
if(b) {
const SDL_Rect& loc = action.location(video_.screen_area());
b->set_location(loc);
b->set_measurements(0,0);
b->set_label(action.title());
b->set_image(action.image());
}
}
}
void display::create_buttons()
{
return;
std::vector<std::shared_ptr<gui::button>> menu_work;
std::vector<std::shared_ptr<gui::button>> action_work;
DBG_DP << "creating menu buttons...\n";
for(const auto& menu : theme_.menus()) {
if (!menu.is_button()) continue;
std::shared_ptr<gui::button> b(new gui::button(video_, menu.title(), gui::button::TYPE_PRESS, menu.image(),
gui::button::DEFAULT_SPACE, false, menu.overlay()));
DBG_DP << "drawing button " << menu.get_id() << "\n";
b->join_same(this);
b->set_id(menu.get_id());
if (!menu.tooltip().empty()){
b->set_tooltip_string(menu.tooltip());
}
std::shared_ptr<gui::button> b_prev = find_menu_button(b->id());
if(b_prev) {
b->enable(b_prev->enabled());
}
menu_work.push_back(b);
}
DBG_DP << "creating action buttons...\n";
for(const auto& action : theme_.actions()) {
std::shared_ptr<gui::button> b(new gui::button(video_, action.title(), string_to_button_type(action.type()), action.image(),
gui::button::DEFAULT_SPACE, false, action.overlay()));
DBG_DP << "drawing button " << action.get_id() << "\n";
b->set_id(action.get_id());
b->join_same(this);
if (!action.tooltip(0).empty()){
b->set_tooltip_string(action.tooltip(0));
}
std::shared_ptr<gui::button> b_prev = find_action_button(b->id());
if(b_prev) {
b->enable(b_prev->enabled());
if (b_prev->get_type() == gui::button::TYPE_CHECK) {
b->set_check(b_prev->checked());
}
}
action_work.push_back(b);
}
menu_buttons_.clear();
menu_buttons_.assign(menu_work.begin(), menu_work.end());
action_buttons_.clear();
action_buttons_.assign(action_work.begin(), action_work.end());
layout_buttons();
DBG_DP << "buttons created\n";
}
void display::render_buttons()
{
return;
for (std::shared_ptr<gui::button> btn : menu_buttons_) {
btn->set_dirty(true);
btn->draw();
}
for (std::shared_ptr<gui::button> btn : action_buttons_) {
btn->set_dirty(true);
btn->draw();
}
}
gui::button::TYPE display::string_to_button_type(std::string type)
{
gui::button::TYPE res = gui::button::TYPE_PRESS;
if (type == "checkbox") { res = gui::button::TYPE_CHECK; }
else if (type == "image") { res = gui::button::TYPE_IMAGE; }
else if (type == "radiobox") { res = gui::button::TYPE_RADIO; }
else if (type == "turbo") { res = gui::button::TYPE_TURBO; }
return res;
}
static const std::string& get_direction(std::size_t n)
{
static const std::array<std::string, 6> dirs {{ "-n", "-ne", "-se", "-s", "-sw", "-nw" }};
@ -1139,8 +1018,6 @@ void display::draw_all_panels()
for(const auto& label : theme_.labels()) {
draw_label(video(), screen, label);
}
render_buttons();
}
#if 0

View file

@ -534,13 +534,6 @@ public:
std::shared_ptr<gui::button> find_action_button(const std::string& id);
std::shared_ptr<gui::button> find_menu_button(const std::string& id);
static gui::button::TYPE string_to_button_type(std::string type);
void create_buttons();
void layout_buttons();
void render_buttons();
void refresh_report(const std::string& report_name, const config* new_cfg = nullptr);
void draw_minimap_units();

View file

@ -88,8 +88,6 @@ editor_controller::editor_controller(const config &game_config)
cursor::set(cursor::NORMAL);
join();
gui().create_buttons();
}
void editor_controller::init_gui()

View file

@ -117,7 +117,6 @@ void context_manager::refresh_all()
{
gui_.rebuild_all();
get_map_context().set_needs_terrain_rebuild(false);
gui_.create_buttons();
get_map_context().clear_changed_locations();
gui_.recalculate_minimap();
}

View file

@ -677,7 +677,6 @@ std::string game_display::current_team_name() const
void game_display::begin_game()
{
in_game_ = true;
create_buttons();
}
void game_display::needs_rebuild(bool b)

View file

@ -1402,8 +1402,6 @@ std::vector<std::string> menu_handler::get_commands_list()
void console_handler::do_refresh()
{
image::flush_cache();
menu_handler_.gui_->create_buttons();
}
void console_handler::do_droid()

View file

@ -75,7 +75,6 @@ replay_controller::replay_controller(play_controller& controller, bool control_v
vision_ = HUMAN_TEAM;
}
controller_.get_display().get_theme().theme_reset_event().attach_handler(this);
controller_.get_display().create_buttons();
}
replay_controller::~replay_controller()
{
@ -83,8 +82,6 @@ replay_controller::~replay_controller()
controller_.toggle_skipping_replay();
}
controller_.get_display().get_theme().theme_reset_event().detach_handler(this);
controller_.get_display().create_buttons();
controller_.get_display().create_buttons();
}
void replay_controller::add_replay_theme()
{