Selaa lähdekoodia

New>Recents

Add a "recents" feature when creating object in l3d. The last 10 objects are stored in the context menu and available to be created again.
Jed 4 vuotta sitten
vanhempi
commit
0d9e4e1d37
1 muutettua tiedostoa jossa 20 lisäystä ja 0 poistoa
  1. 20 0
      hide/comp/SceneEditor.hx

+ 20 - 0
hide/comp/SceneEditor.hx

@@ -2254,8 +2254,15 @@ class SceneEditor {
 			}
 		}
 
+		var grecent = [];
 		var groups = [];
 		var gother = [];
+		var recents : Array<String> = ide.currentConfig.get("sceneeditor.newrecents", []);
+		for( g in recents) {
+			grecent.push(getNewTypeMenuItem(g, parent, onMake));
+
+		}
+
 		for( g in (view.config.get("sceneeditor.newgroups") : Array<String>) ) {
 			var parts = g.split("|");
 			var cl : Dynamic = Type.resolveClass(parts[1]);
@@ -2308,6 +2315,9 @@ class SceneEditor {
 				return gother;
 			newItems.push({ label : "Other", menu : gother });
 		}
+
+		newItems.unshift({label : "Recents", menu : grecent});
+
 		return newItems;
 	}
 
@@ -2324,6 +2334,11 @@ class SceneEditor {
 					autoName(p);
 					if(onMake != null)
 						onMake(p);
+					var recents : Array<String> = ide.currentConfig.get("sceneeditor.newrecents", []);
+					recents.remove(p.type);
+					recents.unshift(p.type);
+					if (recents.length > 10) recents.pop();
+					ide.currentConfig.set("sceneeditor.newrecents", recents);
 					return p;
 				}
 
@@ -2331,6 +2346,11 @@ class SceneEditor {
 					ide.chooseFile(pmodel.inf.fileSource, function(path) {
 						var p = make(path);
 						addElements([p]);
+						var recents : Array<String> = ide.currentConfig.get("sceneeditor.newrecents", []);
+						recents.remove(p.type);
+						recents.unshift(p.type);
+						if (recents.length > 10) recents.pop();
+						ide.currentConfig.set("sceneeditor.newrecents", recents);
 					});
 				else
 					addElements([make()]);