Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc cleanups #6570

Merged
merged 5 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 24 additions & 17 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,30 @@ void display::layout_buttons()
}
}

namespace
{
gui::button::TYPE string_to_button_type(const std::string& type)
{
if(type == "checkbox") {
return gui::button::TYPE_CHECK;
} else if(type == "image") {
return gui::button::TYPE_IMAGE;
} else if(type == "radiobox") {
return gui::button::TYPE_RADIO;
} else if(type == "turbo") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…what on earth is a "turbo"?

(Not an issue, I just don't understand.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea!

return gui::button::TYPE_TURBO;
} else {
return gui::button::TYPE_PRESS;
}
}

const std::string& get_direction(std::size_t n)
{
static const std::array<std::string, 6> dirs{"-n", "-ne", "-se", "-s", "-sw", "-nw"};
return dirs[n >= dirs.size() ? 0 : n];
}
} // namespace

void display::create_buttons()
{
std::vector<std::shared_ptr<gui::button>> menu_work;
Expand Down Expand Up @@ -949,23 +973,6 @@ void display::render_buttons()
}
}


gui::button::TYPE display::string_to_button_type(const 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" };
return dirs[n >= dirs.size() ? 0 : n];
}

std::vector<surface> display::get_fog_shroud_images(const map_location& loc, image::TYPE image_type)
{
std::vector<std::string> names;
Expand Down
1 change: 0 additions & 1 deletion src/display.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ class display : public video2::draw_layering
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(const std::string& type);
void create_buttons();

void layout_buttons();
Expand Down