~widelands-dev/widelands/handling-various-fs-errors

« back to all changes in this revision

Viewing changes to src/editor/ui_menus/main_menu_save_map_make_directory.cc

  • Committer: artydent
  • Date: 2018-11-14 10:47:13 UTC
  • Revision ID: artydent-20181114104713-968toz6tep7aq8h7
compliance to style guide

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
        vbox_.set_size(get_inner_w() - 2 * padding_, get_inner_h() - 3 * padding_ - buth_);
67
67
 
68
68
        edit_.set_text(dirname_);
69
 
        edit_.changed.connect(boost::bind(&MainMenuSaveMapMakeDirectory::edit_changed, this));
70
 
        edit_.ok.connect(boost::bind(&MainMenuSaveMapMakeDirectory::clicked_ok, this));
71
 
        ok_button_.sigclicked.connect(boost::bind(&MainMenuSaveMapMakeDirectory::clicked_ok, this));
 
69
        edit_.changed.connect(
 
70
           boost::bind(&MainMenuSaveMapMakeDirectory::edit_changed, this));
 
71
        edit_.ok.connect(
 
72
           boost::bind(&MainMenuSaveMapMakeDirectory::clicked_ok, this));
 
73
        ok_button_.sigclicked.connect(
 
74
           boost::bind(&MainMenuSaveMapMakeDirectory::clicked_ok, this));
72
75
        ok_button_.set_enabled(!dirname_.empty());
73
76
        cancel_button_.sigclicked.connect(
74
77
           boost::bind(&MainMenuSaveMapMakeDirectory::end_modal<UI::Panel::Returncodes>,
84
87
        const std::string& text = edit_.text();
85
88
        // Prevent the user from creating nonsense directory names, like e.g. ".." or "...".
86
89
        const bool is_legal_filename = FileSystem::is_legal_filename(text);
87
 
        // Prevent the user from creating directory names that the game would try to interpret as maps
 
90
        // Prevent the user from creating directory names that the game would
 
91
        // try to interpret as maps
88
92
        const bool has_map_extension =
89
93
                 boost::iends_with(text, kWidelandsMapExtension) ||
90
94
                 boost::iends_with(text, kS2MapExtension1) ||
91
95
                 boost::iends_with(text, kS2MapExtension2);
92
96
        ok_button_.set_enabled(is_legal_filename && !has_map_extension);
93
 
        edit_.set_tooltip(is_legal_filename ? (has_map_extension ? _("This extension is reserved!") : "" ) : illegal_filename_tooltip_);
 
97
        edit_.set_tooltip(is_legal_filename ?
 
98
           (has_map_extension ? _("This extension is reserved!") : "" ) :
 
99
           illegal_filename_tooltip_);
94
100
        dirname_ = text;
95
101
}
96
102