← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1526916 into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1526916 into lp:widelands.

Commit message:
When selecting a map, the parent directory now has a lower sort order than all other directories.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1526916 in widelands: "Name of folders before <parent> entry"
  https://bugs.launchpad.net/widelands/+bug/1526916

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1526916/+merge/283912

When selecting a map, the parent directory now has a lower sort order than all other directories.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1526916 into lp:widelands.
=== modified file 'src/ui_basic/table.cc'
--- src/ui_basic/table.cc	2016-01-22 20:05:02 +0000
+++ src/ui_basic/table.cc	2016-01-26 09:12:02 +0000
@@ -345,7 +345,7 @@
 				curx += curw;
 				continue;
 			}
-			const Image* entry_text_im = UI::g_fh1->render(as_uifont(entry_string, m_fontsize));
+			const Image* entry_text_im = UI::g_fh1->render(as_uifont(richtext_escape(entry_string), m_fontsize));
 
 			if (alignment & Align_Right) {
 				point.x += curw - 2 * picw;

=== modified file 'src/wui/mapdata.h'
--- src/wui/mapdata.h	2016-01-24 20:11:53 +0000
+++ src/wui/mapdata.h	2016-01-26 09:12:02 +0000
@@ -112,6 +112,12 @@
 		maptype = MapData::MapType::kDirectory;
 	}
 
+	/// The localized name of the parent directory
+	static const std::string parent_name() {
+		/** TRANSLATORS: Parent directory/folder */
+		return (boost::format("\\<%s\\>") % _("parent")).str();
+	}
+
 	/// Get the ".." directory
 	static MapData create_parent_dir(const std::string& current_dir) {
 #ifndef _WIN32
@@ -119,7 +125,7 @@
 #else
 		const std::string filename = current_dir.substr(0, current_dir.rfind('\\'));
 #endif
-		return MapData(filename, (boost::format("\\<%s\\>") % _("parent")).str());
+		return MapData(filename, parent_name());
 	}
 
 	/// Create a subdirectory
@@ -149,6 +155,13 @@
 	MapData::DisplayType displaytype;
 
 	bool compare_names(const MapData& other) {
+		// The parent directory gets special treatment.
+		if (localized_name == parent_name() && maptype == MapData::MapType::kDirectory) {
+			return true;
+		} else if (other.localized_name == parent_name() && other.maptype == MapData::MapType::kDirectory)  {
+			return false;
+		}
+
 		std::string this_name;
 		std::string other_name;
 		switch (displaytype) {


References