Merge lp:~widelands-dev/widelands/bug-1560454-mapdir into lp:widelands
- bug-1560454-mapdir
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 8015 | ||||
Proposed branch: | lp:~widelands-dev/widelands/bug-1560454-mapdir | ||||
Merge into: | lp:widelands | ||||
Diff against target: |
313 lines (+75/-11) 10 files modified
src/editor/ui_menus/main_menu_load_map.cc (+22/-2) src/editor/ui_menus/main_menu_load_map.h (+2/-0) src/editor/ui_menus/main_menu_load_or_save_map.cc (+14/-4) src/editor/ui_menus/main_menu_load_or_save_map.h (+7/-1) src/editor/ui_menus/main_menu_save_map.cc (+12/-3) src/editor/ui_menus/main_menu_save_map.h (+4/-0) src/editor/ui_menus/main_menu_save_map_make_directory.cc (+1/-0) src/wui/mapdata.cc (+9/-0) src/wui/mapdata.h (+3/-0) src/wui/maptable.cc (+1/-1) |
||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/bug-1560454-mapdir | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
SirVer | Approve | ||
kaputtnik (community) | testing | Approve | |
Review via email:
|
Commit message
UI improvements for saving maps:
- Maps are now saved in a "My Maps" subdirectory to prevent overwriting of official maps
- Show full save path to user
- After creating a new directory, enter it
- Automatically focus directory name editbox when creating new directory
- Got rid of blank space in load map screen
- Made show map names/filenames button wide
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Miroslav Remák (miroslavr256) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
kaputtnik (franku) wrote : | # |
> - Show full save path to user
This shows the wrong path. Here it is shown: /home/kaputtnik
Instead the map is saved in: /home/kaputtnik
> - After creating a new directory, enter it
Good idea :-) But it confuses a bit, because one couldn't see which folder is currently shown.
> - Automatically focus map name editbox when creating new map
I couldn't find this feature :-S Either it is not working or i do not understand it. If i create a new map nothing is shown to edit the name of the map. And if i want to save the map, the focus is always on the map, not in the menu (f.e. hitting "f" toggles Fullscreen). If i first choose the map options menu, there is also no focus on the map name edit box.
It is not possible anymore to store a map in a folder which was created prior this changes, because i couldn't go to the "previous folder". So my maps stored in folder ~/.widelands/
As mentioned in the bug report i would like to see the "Shipped maps" in a sub folder in menu "Load map" where the shipped maps could be found. In menu "Save map" this folder shouldn't be shown then. I believe this would be the better approach. Isn't that possible?
Needs fixing because of "Show full path to the user".
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
GunChleoc (gunchleoc) wrote : | # |
> > - Show full save path to user
> This shows the wrong path. Here it is shown: /home/kaputtnik
> repo/bug-1560454-mapdir/
> Instead the map is saved in: /home/kaputtnik
I'll look into this.
> > - After creating a new directory, enter it
> Good idea :-) But it confuses a bit, because one couldn't see which folder is
> currently shown.
I'll remove this feature then
> > - Automatically focus map name editbox when creating new map
> I couldn't find this feature :-S Either it is not working or i do not
> understand it.
Sorry, I meant create directory, not create map.
> It is not possible anymore to store a map in a folder which was created prior
> this changes, because i couldn't go to the "previous folder". So my maps
> stored in folder ~/.widelands/
> this folder anymore. One has to move the previous folders he created in
> ~/.widelands/maps into ~/.widelands/
> own folders again. Same goes for maps which are stored in ~/.widelands/maps/
Yes, they will have to be moved. Which is why I came up with the idea of displaying the full directory, so the user can go find the maps on their computer and fix.
> As mentioned in the bug report i would like to see the "Shipped maps" in a sub
> folder in menu "Load map" where the shipped maps could be found. In menu "Save
> map" this folder shouldn't be shown then. I believe this would be the better
> approach. Isn't that possible?
And how would this look when creating a new game then? All users, even those who don't have any own maps, will have to enter a "Shipped Maps" subfolder every time in order to start a new game?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
kaputtnik (franku) wrote : | # |
> > As mentioned in the bug report i would like to see the "Shipped maps" in a
> sub
> > folder in menu "Load map" where the shipped maps could be found. In menu
> "Save
> > map" this folder shouldn't be shown then. I believe this would be the better
> > approach. Isn't that possible?
>
> And how would this look when creating a new game then? All users, even those
> who don't have any own maps, will have to enter a "Shipped Maps" subfolder
> every time in order to start a new game?
Sorry, i forget always that "New game" and "Load map" is the same menu :-S
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 1127. State: passed. Details: https:/
Appveyor build 964. State: success. Details: https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
kaputtnik (franku) wrote : | # |
> > > - Automatically focus map name editbox when creating new map
> > I couldn't find this feature :-S Either it is not working or i do not
> > understand it.
>
> Sorry, I meant create directory, not create map.
If i create a new directory the map name editbox isn't focused here ("f" button toggles fullscreen).
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
GunChleoc (gunchleoc) wrote : | # |
Displaying the absolute path is less than trivial, because the LayeredFilesystem will iterate internally over all file systems until it finds a match. So, I decided to display the relative directory instead, both in the load and save screens.
> If i create a new directory the map name editbox isn't focused here ("f"
> button toggles fullscreen).
The shortcut for toggle fullscreen is CTRL+f, so I have no idea how you managed this.
What I am talking about is:
Old behaviour: Save Map -> Make Directory, click the edit box, start typing
New behaviour: Save Map -> Make Directory, start typing right away
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 1132. State: errored. Details: https:/
Appveyor build 969. State: success. Details: https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
kaputtnik (franku) wrote : | # |
Ahhh... now i got it. I've always tested the map name edit box (as the commit message says, even after you've changed it) but you meant the directory name edit box... This is a really good enhancement :-)
Showing the relative directory is IMHO ok. The position of this could be discussed... but i think we should discuss this if we have time to make a menu overhaul. I want to make some mockups with my suggestions if i am ready with the website code.
The "f" button toggles fullscreen without "CTRL" here. Just like it is explained in the help ;)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
GunChleoc (gunchleoc) wrote : | # |
Oops, I fixed the commit message. I don't get the problem with the fullscreen toggling while the text input is focused. You're right, it's without the Ctrl key.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
kaputtnik (franku) wrote : | # |
If the focus is in the directory name edit box, all works correct, no keyboard shortcuts works then.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
bunnybot (widelandsofficial) wrote : | # |
Bunnybot encountered an error while working on this merge proposal:
The read operation timed out
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 1132. State: errored. Details: https:/
Appveyor build 969. State: success. Details: https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
SirVer (sirver) wrote : | # |
look at me! I did a codereview!!!
code lgtm. only one nit.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
GunChleoc (gunchleoc) wrote : | # |
LOL thanks!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
GunChleoc (gunchleoc) wrote : | # |
@bunnybot merge
Preview Diff
1 | === modified file 'src/editor/ui_menus/main_menu_load_map.cc' | |||
2 | --- src/editor/ui_menus/main_menu_load_map.cc 2016-04-06 09:23:04 +0000 | |||
3 | +++ src/editor/ui_menus/main_menu_load_map.cc 2016-06-07 09:07:42 +0000 | |||
4 | @@ -19,6 +19,9 @@ | |||
5 | 19 | 19 | ||
6 | 20 | #include "editor/ui_menus/main_menu_load_map.h" | 20 | #include "editor/ui_menus/main_menu_load_map.h" |
7 | 21 | 21 | ||
8 | 22 | #include <boost/algorithm/string.hpp> | ||
9 | 23 | #include <boost/format.hpp> | ||
10 | 24 | |||
11 | 22 | #include "base/i18n.h" | 25 | #include "base/i18n.h" |
12 | 23 | #include "editor/editorinteractive.h" | 26 | #include "editor/editorinteractive.h" |
13 | 24 | #include "io/filesystem/layered_filesystem.h" | 27 | #include "io/filesystem/layered_filesystem.h" |
14 | @@ -30,7 +33,8 @@ | |||
15 | 30 | * Create all the buttons etc... | 33 | * Create all the buttons etc... |
16 | 31 | */ | 34 | */ |
17 | 32 | MainMenuLoadMap::MainMenuLoadMap(EditorInteractive& parent) | 35 | MainMenuLoadMap::MainMenuLoadMap(EditorInteractive& parent) |
19 | 33 | : MainMenuLoadOrSaveMap(parent, "load_map_menu", _("Load Map")) { | 36 | : MainMenuLoadOrSaveMap(parent, 2, "load_map_menu", _("Load Map")) { |
20 | 37 | set_current_directory(curdir_); | ||
21 | 34 | 38 | ||
22 | 35 | table_.selected.connect(boost::bind(&MainMenuLoadMap::entry_selected, this)); | 39 | table_.selected.connect(boost::bind(&MainMenuLoadMap::entry_selected, this)); |
23 | 36 | table_.double_clicked.connect(boost::bind(&MainMenuLoadMap::clicked_ok, boost::ref(*this))); | 40 | table_.double_clicked.connect(boost::bind(&MainMenuLoadMap::clicked_ok, boost::ref(*this))); |
24 | @@ -45,7 +49,7 @@ | |||
25 | 45 | const MapData& mapdata = maps_data_[table_.get_selected()]; | 49 | const MapData& mapdata = maps_data_[table_.get_selected()]; |
26 | 46 | if (g_fs->is_directory(mapdata.filename) && | 50 | if (g_fs->is_directory(mapdata.filename) && |
27 | 47 | !Widelands::WidelandsMapLoader::is_widelands_map(mapdata.filename)) { | 51 | !Widelands::WidelandsMapLoader::is_widelands_map(mapdata.filename)) { |
29 | 48 | curdir_ = mapdata.filename; | 52 | set_current_directory(mapdata.filename); |
30 | 49 | fill_table(); | 53 | fill_table(); |
31 | 50 | } else { | 54 | } else { |
32 | 51 | EditorInteractive& eia = dynamic_cast<EditorInteractive&>(*get_parent()); | 55 | EditorInteractive& eia = dynamic_cast<EditorInteractive&>(*get_parent()); |
33 | @@ -54,6 +58,22 @@ | |||
34 | 54 | } | 58 | } |
35 | 55 | } | 59 | } |
36 | 56 | 60 | ||
37 | 61 | void MainMenuLoadMap::set_current_directory(const std::string& filename) { | ||
38 | 62 | curdir_ = filename; | ||
39 | 63 | |||
40 | 64 | std::string display_dir = curdir_.substr(basedir_.size()); | ||
41 | 65 | if (boost::starts_with(display_dir, "/")) { | ||
42 | 66 | display_dir = display_dir.substr(1); | ||
43 | 67 | } | ||
44 | 68 | if (boost::starts_with(display_dir, "My_Maps")) { | ||
45 | 69 | boost::replace_first(display_dir, "My_Maps", _("My Maps")); | ||
46 | 70 | } else if (boost::starts_with(display_dir, "MP_Scenarios")) { | ||
47 | 71 | boost::replace_first(display_dir, "MP_Scenarios", _("Multiplayer Scenarios")); | ||
48 | 72 | } | ||
49 | 73 | /** TRANSLATORS: The folder that a file will be saved to. */ | ||
50 | 74 | directory_info_.set_text((boost::format(_("Current Directory: %s")) % display_dir).str()); | ||
51 | 75 | } | ||
52 | 76 | |||
53 | 57 | /** | 77 | /** |
54 | 58 | * Called when a entry is selected | 78 | * Called when a entry is selected |
55 | 59 | */ | 79 | */ |
56 | 60 | 80 | ||
57 | === modified file 'src/editor/ui_menus/main_menu_load_map.h' | |||
58 | --- src/editor/ui_menus/main_menu_load_map.h 2016-04-06 09:23:04 +0000 | |||
59 | +++ src/editor/ui_menus/main_menu_load_map.h 2016-06-07 09:07:42 +0000 | |||
60 | @@ -33,6 +33,8 @@ | |||
61 | 33 | 33 | ||
62 | 34 | protected: | 34 | protected: |
63 | 35 | void clicked_ok() override; | 35 | void clicked_ok() override; |
64 | 36 | // Sets the current dir and updates labels. | ||
65 | 37 | void set_current_directory(const std::string& filename) override; | ||
66 | 36 | 38 | ||
67 | 37 | private: | 39 | private: |
68 | 38 | void entry_selected(); | 40 | void entry_selected(); |
69 | 39 | 41 | ||
70 | === modified file 'src/editor/ui_menus/main_menu_load_or_save_map.cc' | |||
71 | --- src/editor/ui_menus/main_menu_load_or_save_map.cc 2016-04-20 07:58:14 +0000 | |||
72 | +++ src/editor/ui_menus/main_menu_load_or_save_map.cc 2016-06-07 09:07:42 +0000 | |||
73 | @@ -32,8 +32,10 @@ | |||
74 | 32 | #include "map_io/widelands_map_loader.h" | 32 | #include "map_io/widelands_map_loader.h" |
75 | 33 | 33 | ||
76 | 34 | MainMenuLoadOrSaveMap::MainMenuLoadOrSaveMap(EditorInteractive& parent, | 34 | MainMenuLoadOrSaveMap::MainMenuLoadOrSaveMap(EditorInteractive& parent, |
77 | 35 | int no_of_bottom_rows, | ||
78 | 35 | const std::string& name, | 36 | const std::string& name, |
80 | 36 | const std::string& title) | 37 | const std::string& title, |
81 | 38 | const std::string& basedir) | ||
82 | 37 | : UI::Window(&parent, name, 0, 0, parent.get_inner_w() - 40, parent.get_inner_h() - 40, title), | 39 | : UI::Window(&parent, name, 0, 0, parent.get_inner_w() - 40, parent.get_inner_h() - 40, title), |
83 | 38 | 40 | ||
84 | 39 | // Values for alignment and size | 41 | // Values for alignment and size |
85 | @@ -42,7 +44,7 @@ | |||
86 | 42 | tablex_(padding_), | 44 | tablex_(padding_), |
87 | 43 | tabley_(buth_ + 2 * padding_), | 45 | tabley_(buth_ + 2 * padding_), |
88 | 44 | tablew_(get_inner_w() * 7 / 12), | 46 | tablew_(get_inner_w() * 7 / 12), |
90 | 45 | tableh_(get_inner_h() - tabley_ - 3 * buth_ - 2 * padding_), | 47 | tableh_(get_inner_h() - tabley_ - (no_of_bottom_rows + 1) * buth_ - no_of_bottom_rows * padding_), |
91 | 46 | right_column_x_(tablew_ + 2 * padding_), | 48 | right_column_x_(tablew_ + 2 * padding_), |
92 | 47 | butw_((get_inner_w() - right_column_x_ - 2 * padding_) / 2), | 49 | butw_((get_inner_w() - right_column_x_ - 2 * padding_) / 2), |
93 | 48 | 50 | ||
94 | @@ -50,6 +52,11 @@ | |||
95 | 50 | map_details_( | 52 | map_details_( |
96 | 51 | this, right_column_x_, tabley_, get_inner_w() - right_column_x_ - padding_, tableh_, | 53 | this, right_column_x_, tabley_, get_inner_w() - right_column_x_ - padding_, tableh_, |
97 | 52 | MapDetails::Style::kWui), | 54 | MapDetails::Style::kWui), |
98 | 55 | directory_info_(this, | ||
99 | 56 | padding_, | ||
100 | 57 | get_inner_h() - 2 * buth_ - 4 * padding_, | ||
101 | 58 | "", | ||
102 | 59 | UI::Align::kLeft), | ||
103 | 53 | ok_(this, | 60 | ok_(this, |
104 | 54 | "ok", | 61 | "ok", |
105 | 55 | UI::g_fh1->fontset()->is_rtl() ? get_inner_w() / 2 - butw_ - padding_ : get_inner_w() / 2 + padding_, | 62 | UI::g_fh1->fontset()->is_rtl() ? get_inner_w() / 2 - butw_ - padding_ : get_inner_w() / 2 + padding_, |
106 | @@ -68,9 +75,10 @@ | |||
107 | 68 | buth_, | 75 | buth_, |
108 | 69 | g_gr->images().get("images/ui_basic/but1.png"), | 76 | g_gr->images().get("images/ui_basic/but1.png"), |
109 | 70 | _("Cancel")), | 77 | _("Cancel")), |
111 | 71 | basedir_("maps"), | 78 | basedir_(basedir), |
112 | 72 | has_translated_mapname_(false), | 79 | has_translated_mapname_(false), |
113 | 73 | showing_mapames_(false) { | 80 | showing_mapames_(false) { |
114 | 81 | g_fs->ensure_directory_exists(basedir_); | ||
115 | 74 | curdir_ = basedir_; | 82 | curdir_ = basedir_; |
116 | 75 | 83 | ||
117 | 76 | UI::Box* vbox = new UI::Box(this, tablex_, padding_, UI::Box::Horizontal, padding_, get_w()); | 84 | UI::Box* vbox = new UI::Box(this, tablex_, padding_, UI::Box::Horizontal, padding_, get_w()); |
118 | @@ -78,7 +86,7 @@ | |||
119 | 78 | "show_mapnames", | 86 | "show_mapnames", |
120 | 79 | 0, | 87 | 0, |
121 | 80 | 0, | 88 | 0, |
123 | 81 | butw_, | 89 | 2 * butw_, |
124 | 82 | buth_, | 90 | buth_, |
125 | 83 | g_gr->images().get("images/ui_basic/but1.png"), | 91 | g_gr->images().get("images/ui_basic/but1.png"), |
126 | 84 | _("Show Map Names")); | 92 | _("Show Map Names")); |
127 | @@ -155,6 +163,8 @@ | |||
128 | 155 | // about the absolute filesystem top!) we manually add ".." | 163 | // about the absolute filesystem top!) we manually add ".." |
129 | 156 | if (curdir_ != basedir_) { | 164 | if (curdir_ != basedir_) { |
130 | 157 | maps_data_.push_back(MapData::create_parent_dir(curdir_)); | 165 | maps_data_.push_back(MapData::create_parent_dir(curdir_)); |
131 | 166 | } else if (files.empty()) { | ||
132 | 167 | maps_data_.push_back(MapData::create_empty_dir(curdir_)); | ||
133 | 158 | } | 168 | } |
134 | 159 | 169 | ||
135 | 160 | MapData::DisplayType display_type; | 170 | MapData::DisplayType display_type; |
136 | 161 | 171 | ||
137 | === modified file 'src/editor/ui_menus/main_menu_load_or_save_map.h' | |||
138 | --- src/editor/ui_menus/main_menu_load_or_save_map.h 2016-04-06 09:23:04 +0000 | |||
139 | +++ src/editor/ui_menus/main_menu_load_or_save_map.h 2016-06-07 09:07:42 +0000 | |||
140 | @@ -25,6 +25,7 @@ | |||
141 | 25 | #include "editor/editorinteractive.h" | 25 | #include "editor/editorinteractive.h" |
142 | 26 | #include "ui_basic/button.h" | 26 | #include "ui_basic/button.h" |
143 | 27 | #include "ui_basic/checkbox.h" | 27 | #include "ui_basic/checkbox.h" |
144 | 28 | #include "ui_basic/textarea.h" | ||
145 | 28 | #include "ui_basic/window.h" | 29 | #include "ui_basic/window.h" |
146 | 29 | #include "wui/mapdetails.h" | 30 | #include "wui/mapdetails.h" |
147 | 30 | #include "wui/maptable.h" | 31 | #include "wui/maptable.h" |
148 | @@ -34,12 +35,16 @@ | |||
149 | 34 | */ | 35 | */ |
150 | 35 | struct MainMenuLoadOrSaveMap : public UI::Window { | 36 | struct MainMenuLoadOrSaveMap : public UI::Window { |
151 | 36 | MainMenuLoadOrSaveMap(EditorInteractive& parent, | 37 | MainMenuLoadOrSaveMap(EditorInteractive& parent, |
152 | 38 | int no_of_bottom_rows, | ||
153 | 37 | const std::string& name, | 39 | const std::string& name, |
155 | 38 | const std::string& title); | 40 | const std::string& title, |
156 | 41 | const std::string& basedir = "maps"); | ||
157 | 39 | 42 | ||
158 | 40 | protected: | 43 | protected: |
159 | 41 | virtual void clicked_ok() = 0; | 44 | virtual void clicked_ok() = 0; |
160 | 42 | void toggle_mapnames(); | 45 | void toggle_mapnames(); |
161 | 46 | // Sets the current dir and updates labels. | ||
162 | 47 | virtual void set_current_directory(const std::string& filename) = 0; | ||
163 | 43 | void fill_table(); | 48 | void fill_table(); |
164 | 44 | 49 | ||
165 | 45 | bool compare_players(uint32_t, uint32_t); | 50 | bool compare_players(uint32_t, uint32_t); |
166 | @@ -57,6 +62,7 @@ | |||
167 | 57 | std::vector<MapData> maps_data_; | 62 | std::vector<MapData> maps_data_; |
168 | 58 | MapDetails map_details_; | 63 | MapDetails map_details_; |
169 | 59 | 64 | ||
170 | 65 | UI::Textarea directory_info_; | ||
171 | 60 | UI::Button ok_, cancel_; | 66 | UI::Button ok_, cancel_; |
172 | 61 | 67 | ||
173 | 62 | const std::string basedir_; | 68 | const std::string basedir_; |
174 | 63 | 69 | ||
175 | === modified file 'src/editor/ui_menus/main_menu_save_map.cc' | |||
176 | --- src/editor/ui_menus/main_menu_save_map.cc 2016-05-07 18:54:04 +0000 | |||
177 | +++ src/editor/ui_menus/main_menu_save_map.cc 2016-06-07 09:07:42 +0000 | |||
178 | @@ -49,7 +49,7 @@ | |||
179 | 49 | 49 | ||
180 | 50 | // TODO(GunChleoc): Arabic: Make directory dialog: buttons need more height for Arabic. | 50 | // TODO(GunChleoc): Arabic: Make directory dialog: buttons need more height for Arabic. |
181 | 51 | MainMenuSaveMap::MainMenuSaveMap(EditorInteractive& parent) | 51 | MainMenuSaveMap::MainMenuSaveMap(EditorInteractive& parent) |
183 | 52 | : MainMenuLoadOrSaveMap(parent, "save_map_menu", _("Save Map")), | 52 | : MainMenuLoadOrSaveMap(parent, 3, "save_map_menu", _("Save Map"), "maps/My_Maps"), |
184 | 53 | 53 | ||
185 | 54 | make_directory_(this, | 54 | make_directory_(this, |
186 | 55 | "make_directory", | 55 | "make_directory", |
187 | @@ -74,6 +74,7 @@ | |||
188 | 74 | buth_, | 74 | buth_, |
189 | 75 | _("Filename:"), | 75 | _("Filename:"), |
190 | 76 | UI::Align::kLeft) { | 76 | UI::Align::kLeft) { |
191 | 77 | set_current_directory(curdir_); | ||
192 | 77 | 78 | ||
193 | 78 | // Make room for edit_options_ button | 79 | // Make room for edit_options_ button |
194 | 79 | map_details_.set_max_height(map_details_.get_h() - buth_ - padding_); | 80 | map_details_.set_max_height(map_details_.get_h() - buth_ - padding_); |
195 | @@ -131,7 +132,7 @@ | |||
196 | 131 | 132 | ||
197 | 132 | if (g_fs->is_directory(complete_filename.c_str()) && | 133 | if (g_fs->is_directory(complete_filename.c_str()) && |
198 | 133 | !Widelands::WidelandsMapLoader::is_widelands_map(complete_filename)) { | 134 | !Widelands::WidelandsMapLoader::is_widelands_map(complete_filename)) { |
200 | 134 | curdir_ = complete_filename; | 135 | set_current_directory(complete_filename); |
201 | 135 | fill_table(); | 136 | fill_table(); |
202 | 136 | } else { // Ok, save this map | 137 | } else { // Ok, save this map |
203 | 137 | Widelands::Map& map = eia().egbase().map(); | 138 | Widelands::Map& map = eia().egbase().map(); |
204 | @@ -151,6 +152,7 @@ | |||
205 | 151 | * Called, when the make directory button was clicked. | 152 | * Called, when the make directory button was clicked. |
206 | 152 | */ | 153 | */ |
207 | 153 | void MainMenuSaveMap::clicked_make_directory() { | 154 | void MainMenuSaveMap::clicked_make_directory() { |
208 | 155 | /** TRANSLATORS: A folder that hasn't been given a name yet */ | ||
209 | 154 | MainMenuSaveMapMakeDirectory md(this, _("unnamed")); | 156 | MainMenuSaveMapMakeDirectory md(this, _("unnamed")); |
210 | 155 | if (md.run<UI::Panel::Returncodes>() == UI::Panel::Returncodes::kOk) { | 157 | if (md.run<UI::Panel::Returncodes>() == UI::Panel::Returncodes::kOk) { |
211 | 156 | g_fs->ensure_directory_exists(curdir_); | 158 | g_fs->ensure_directory_exists(curdir_); |
212 | @@ -201,7 +203,7 @@ | |||
213 | 201 | assert(table_.has_selection()); | 203 | assert(table_.has_selection()); |
214 | 202 | const MapData& mapdata = maps_data_[table_.get_selected()]; | 204 | const MapData& mapdata = maps_data_[table_.get_selected()]; |
215 | 203 | if (mapdata.maptype == MapData::MapType::kDirectory) { | 205 | if (mapdata.maptype == MapData::MapType::kDirectory) { |
217 | 204 | curdir_ = mapdata.filename; | 206 | set_current_directory(mapdata.filename); |
218 | 205 | fill_table(); | 207 | fill_table(); |
219 | 206 | } else { | 208 | } else { |
220 | 207 | clicked_ok(); | 209 | clicked_ok(); |
221 | @@ -216,6 +218,13 @@ | |||
222 | 216 | ok_.set_enabled(!editbox_->text().empty()); | 218 | ok_.set_enabled(!editbox_->text().empty()); |
223 | 217 | } | 219 | } |
224 | 218 | 220 | ||
225 | 221 | void MainMenuSaveMap::set_current_directory(const std::string& filename) { | ||
226 | 222 | curdir_ = filename; | ||
227 | 223 | /** TRANSLATORS: The folder that a file will be saved to. */ | ||
228 | 224 | directory_info_.set_text((boost::format(_("Current Directory: %s")) | ||
229 | 225 | % (_("My Maps") + curdir_.substr(basedir_.size()))).str()); | ||
230 | 226 | } | ||
231 | 227 | |||
232 | 219 | /** | 228 | /** |
233 | 220 | * Save the map in the current directory with | 229 | * Save the map in the current directory with |
234 | 221 | * the current filename | 230 | * the current filename |
235 | 222 | 231 | ||
236 | === modified file 'src/editor/ui_menus/main_menu_save_map.h' | |||
237 | --- src/editor/ui_menus/main_menu_save_map.h 2016-04-06 09:23:04 +0000 | |||
238 | +++ src/editor/ui_menus/main_menu_save_map.h 2016-06-07 09:07:42 +0000 | |||
239 | @@ -34,6 +34,10 @@ | |||
240 | 34 | struct MainMenuSaveMap : public MainMenuLoadOrSaveMap { | 34 | struct MainMenuSaveMap : public MainMenuLoadOrSaveMap { |
241 | 35 | MainMenuSaveMap(EditorInteractive& parent); | 35 | MainMenuSaveMap(EditorInteractive& parent); |
242 | 36 | 36 | ||
243 | 37 | protected: | ||
244 | 38 | // Sets the current dir and updates labels. | ||
245 | 39 | void set_current_directory(const std::string& filename) override; | ||
246 | 40 | |||
247 | 37 | private: | 41 | private: |
248 | 38 | EditorInteractive & eia(); | 42 | EditorInteractive & eia(); |
249 | 39 | void clicked_ok(); | 43 | void clicked_ok(); |
250 | 40 | 44 | ||
251 | === modified file 'src/editor/ui_menus/main_menu_save_map_make_directory.cc' | |||
252 | --- src/editor/ui_menus/main_menu_save_map_make_directory.cc 2016-04-23 08:05:31 +0000 | |||
253 | +++ src/editor/ui_menus/main_menu_save_map_make_directory.cc 2016-06-07 09:07:42 +0000 | |||
254 | @@ -66,6 +66,7 @@ | |||
255 | 66 | boost::ref(*this), | 66 | boost::ref(*this), |
256 | 67 | UI::Panel::Returncodes::kBack)); | 67 | UI::Panel::Returncodes::kBack)); |
257 | 68 | center_to_parent(); | 68 | center_to_parent(); |
258 | 69 | edit_.focus(); | ||
259 | 69 | } | 70 | } |
260 | 70 | 71 | ||
261 | 71 | 72 | ||
262 | 72 | 73 | ||
263 | === modified file 'src/wui/mapdata.cc' | |||
264 | --- src/wui/mapdata.cc 2016-04-16 07:10:03 +0000 | |||
265 | +++ src/wui/mapdata.cc 2016-06-07 09:07:42 +0000 | |||
266 | @@ -131,11 +131,20 @@ | |||
267 | 131 | } | 131 | } |
268 | 132 | 132 | ||
269 | 133 | // static | 133 | // static |
270 | 134 | MapData MapData::create_empty_dir(const std::string& current_dir) { | ||
271 | 135 | /** TRANSLATORS: This label is shown when a folder is empty */ | ||
272 | 136 | return MapData(current_dir, (boost::format("<%s>") % _("empty")).str()); | ||
273 | 137 | } | ||
274 | 138 | |||
275 | 139 | // static | ||
276 | 134 | MapData MapData::create_directory(const std::string& directory) { | 140 | MapData MapData::create_directory(const std::string& directory) { |
277 | 135 | std::string localized_name; | 141 | std::string localized_name; |
278 | 136 | if (boost::equals(directory, "maps/MP_Scenarios")) { | 142 | if (boost::equals(directory, "maps/MP_Scenarios")) { |
279 | 137 | /** TRANSLATORS: Directory name for MP Scenarios in map selection */ | 143 | /** TRANSLATORS: Directory name for MP Scenarios in map selection */ |
280 | 138 | localized_name = _("Multiplayer Scenarios"); | 144 | localized_name = _("Multiplayer Scenarios"); |
281 | 145 | } else if (boost::equals(directory, "maps/My_Maps")) { | ||
282 | 146 | /** TRANSLATORS: Directory name for user maps in map selection */ | ||
283 | 147 | localized_name = _("My Maps"); | ||
284 | 139 | } else { | 148 | } else { |
285 | 140 | localized_name = FileSystem::fs_filename(directory.c_str()); | 149 | localized_name = FileSystem::fs_filename(directory.c_str()); |
286 | 141 | } | 150 | } |
287 | 142 | 151 | ||
288 | === modified file 'src/wui/mapdata.h' | |||
289 | --- src/wui/mapdata.h 2016-02-06 18:58:57 +0000 | |||
290 | +++ src/wui/mapdata.h 2016-06-07 09:07:42 +0000 | |||
291 | @@ -89,6 +89,9 @@ | |||
292 | 89 | /// Get the ".." directory | 89 | /// Get the ".." directory |
293 | 90 | static MapData create_parent_dir(const std::string& current_dir); | 90 | static MapData create_parent_dir(const std::string& current_dir); |
294 | 91 | 91 | ||
295 | 92 | /// To display if the directory is empty and has no parent | ||
296 | 93 | static MapData create_empty_dir(const std::string& current_dir); | ||
297 | 94 | |||
298 | 92 | /// Create a subdirectory | 95 | /// Create a subdirectory |
299 | 93 | static MapData create_directory(const std::string& directory); | 96 | static MapData create_directory(const std::string& directory); |
300 | 94 | 97 | ||
301 | 95 | 98 | ||
302 | === modified file 'src/wui/maptable.cc' | |||
303 | --- src/wui/maptable.cc 2016-01-29 08:37:22 +0000 | |||
304 | +++ src/wui/maptable.cc 2016-06-07 09:07:42 +0000 | |||
305 | @@ -34,7 +34,7 @@ | |||
306 | 34 | 34 | ||
307 | 35 | /** TRANSLATORS: Column title for number of players in map list */ | 35 | /** TRANSLATORS: Column title for number of players in map list */ |
308 | 36 | add_column(35, _("Pl."), _("Number of players"), UI::Align::kHCenter); | 36 | add_column(35, _("Pl."), _("Number of players"), UI::Align::kHCenter); |
310 | 37 | add_column(get_w() - 35 - 115, "", _("The name of the map or scenario"), UI::Align::kLeft); | 37 | add_column(get_w() - 35 - 115, _("Filename"), _("The name of the map or scenario"), UI::Align::kLeft); |
311 | 38 | add_column(115, _("Size"), _("The size of the map (Width x Height)"), UI::Align::kLeft); | 38 | add_column(115, _("Size"), _("The size of the map (Width x Height)"), UI::Align::kLeft); |
312 | 39 | set_sort_column(0); | 39 | set_sort_column(0); |
313 | 40 | } | 40 | } |
For me it shows a different save path than where the map is actually saved: /widelands_ working_ dir/maps/ My_Maps/ map.wmf instead of /home/user/ .widelands/ maps/My_ Maps/map. wmf. I guess that's because canonicalize_name does not take file system layers into account.