Skip to content

Commit

Permalink
Minor prefs cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Feb 18, 2016
1 parent 33da792 commit eef5db9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 56 deletions.
7 changes: 3 additions & 4 deletions src/gui/dialogs/preferences_dialog.cpp
Expand Up @@ -80,7 +80,6 @@ const std::string bool_to_display_string(bool value)

namespace gui2 {

// TODO: probably should use a namespace alias instead
using namespace preferences;

REGISTER_DIALOG(preferences)
Expand Down Expand Up @@ -835,10 +834,10 @@ void tpreferences::on_advanced_prefs_list_select(tlistbox& list, twindow& window
if(selected_type == ADVANCED_PREF_TYPE::SPECIAL) {
if (selected_field == "advanced_graphic_options") {
gui2::tadvanced_graphics_options::display(window.video());
}

if (selected_field == "orb_color") {
} else if (selected_field == "orb_color") {
gui2::tselect_orb_colors::display(window.video());
} else {
WRN_GUI_L << "Invalid or unimplemented custom advanced prefs option: " << selected_field << "\n";
}

// Add more options here as needed
Expand Down
52 changes: 0 additions & 52 deletions src/preferences_display.cpp
Expand Up @@ -115,57 +115,5 @@ void set_idle_anim_rate(int rate) {
}
}


bool show_video_mode_dialog(CVideo& video)
{
const resize_lock prevent_resizing;
// For some reason, this line prevents the dialog from being opened from GUI2...
//const events::event_context dialog_events_context;

std::vector<std::pair<int,int> > resolutions
= video.get_available_resolutions();

if(resolutions.empty()) {
gui2::show_transient_message(
video
, ""
, _("There are no alternative video modes available"));

return false;
}

std::vector<std::string> options;
unsigned current_choice = 0;

for(size_t k = 0; k < resolutions.size(); ++k) {
std::pair<int, int> const& res = resolutions[k];

if (res == video.current_resolution())
current_choice = static_cast<unsigned>(k);

std::ostringstream option;
option << res.first << utils::unicode_multiplication_sign << res.second;
const int div = boost::math::gcd(res.first, res.second);
const int ratio[2] = {res.first/div, res.second/div};
if (ratio[0] <= 10 || ratio[1] <= 10)
option << " (" << ratio[0] << ':' << ratio[1] << ')';
options.push_back(option.str());
}

gui2::tsimple_item_selector dlg(_("Choose Resolution"), "", options);
dlg.set_selected_index(current_choice);
dlg.show(video);

int choice = dlg.selected_index();

if(choice == -1 || resolutions[static_cast<size_t>(choice)] == video.current_resolution()) {
return false;
}

video.set_resolution(resolutions[static_cast<size_t>(choice)]);

return true;
}

} // end namespace preferences

0 comments on commit eef5db9

Please sign in to comment.