Bläddra i källkod

added folders for cdb data elements

Nicolas Cannasse 3 år sedan
förälder
incheckning
93fd76bf95
5 ändrade filer med 141 tillägg och 31 borttagningar
  1. 25 1
      bin/cdb.css
  2. 26 2
      bin/cdb.less
  3. 62 15
      hide/comp/cdb/DataFiles.hx
  4. 6 2
      hide/comp/cdb/Line.hx
  5. 22 11
      hide/comp/cdb/Table.hx

+ 25 - 1
bin/cdb.css

@@ -80,14 +80,38 @@
   background-color: #3d3d3d;
 }
 .cdb .cdb-sheet tr.separator.seplevel-1 td .toggle {
-  padding-left: 30px;
+  padding-left: 25px;
 }
 .cdb .cdb-sheet tr.separator.seplevel-2 td {
   background-color: #383838;
 }
 .cdb .cdb-sheet tr.separator.seplevel-2 td .toggle {
+  padding-left: 40px;
+}
+.cdb .cdb-sheet tr.separator.seplevel-3 td {
+  background-color: #343434;
+}
+.cdb .cdb-sheet tr.separator.seplevel-3 td .toggle {
   padding-left: 50px;
 }
+.cdb .cdb-sheet tr.separator.seplevel-4 td {
+  background-color: #303030;
+}
+.cdb .cdb-sheet tr.separator.seplevel-4 td .toggle {
+  padding-left: 60px;
+}
+.cdb .cdb-sheet tr.separator.seplevel-5 td {
+  background-color: #303030;
+}
+.cdb .cdb-sheet tr.separator.seplevel-5 td .toggle {
+  padding-left: 70px;
+}
+.cdb .cdb-sheet tr.separator.seplevel-6 td {
+  background-color: #303030;
+}
+.cdb .cdb-sheet tr.separator.seplevel-6 td .toggle {
+  padding-left: 80px;
+}
 .cdb .cdb-sheet tr.locIgnored {
   background-color: #221C1C;
 }

+ 26 - 2
bin/cdb.less

@@ -89,16 +89,40 @@
 			}
 			&.seplevel-1 td {
 				.toggle {
-					padding-left : 30px;
+					padding-left : 25px;
 				}
 				background-color : #3d3d3d;
 			}
 			&.seplevel-2 td {
 				.toggle {
-					padding-left : 50px;
+					padding-left : 40px;
 				}
 				background-color : #383838;
 			}
+			&.seplevel-3 td {
+				.toggle {
+					padding-left : 50px;
+				}
+				background-color : #343434;
+			}
+			&.seplevel-4 td {
+				.toggle {
+					padding-left : 60px;
+				}
+				background-color : #303030;
+			}
+			&.seplevel-5 td {
+				.toggle {
+					padding-left : 70px;
+				}
+				background-color : #303030;
+			}
+			&.seplevel-6 td {
+				.toggle {
+					padding-left : 80px;
+				}
+				background-color : #303030;
+			}
 		}
 
 		tr.locIgnored {

+ 62 - 15
hide/comp/cdb/DataFiles.hx

@@ -7,6 +7,15 @@ typedef DataProps = {
 	var origin : String;
 }
 
+private typedef DataDef = {
+	var name : String;
+	var path : String;
+	var subs : Array<DataDef>;
+	var msubs : Map<String, DataDef>;
+	var lines : Array<Dynamic>;
+	var linesData: Array<DataProps>;
+}
+
 class DataFiles {
 
 	static var changed : Bool;
@@ -76,17 +85,17 @@ class DataFiles {
 	}
 
 	static function loadSheet( sheet : cdb.Sheet ) {
-		var lines : Array<Dynamic> = [];
-		var linesData : Array<DataProps> = [];
-		var separators = [];
 		var sheetName = getTypeName(sheet);
-		@:privateAccess {
-			sheet.sheet.lines = lines;
-			sheet.sheet.linesData = linesData;
-			sheet.sheet.separators = separators;
-		}
+		var root : DataDef = {
+			name : null,
+			path : null,
+			lines : null,
+			linesData : null,
+			subs : [],
+			msubs : new Map(),
+		};
 		function loadFile( file : String ) {
-			var needSep = true;
+			var content = null;
 			var levelID = file.split("/").pop().split(".").shift();
 			levelID = levelID.charAt(0).toUpperCase()+levelID.substr(1);
 			function loadRec( p : hrt.prefab.Prefab, parent : hrt.prefab.Prefab ) {
@@ -103,14 +112,24 @@ class DataFiles {
 							if( c.name == p.name ) dprops.index++;
 						}
 					}
-					if( needSep ) {
-						separators.push({ index : lines.length, title : file.split("/").join(" > ") });
-						needSep = false;
-					}
 					if( sheet.idCol != null && Reflect.field(p.props,sheet.idCol.name) == "" )
 						Reflect.setField(p.props,sheet.idCol.name,levelID+"_"+p.name+(dprops.index == 0 ? "" : ""+dprops.index));
-					linesData.push(dprops);
-					lines.push(p.props);
+					if( content == null ) {
+						content = root;
+						var path = [];
+						for( p in file.split("/") ) {
+							var n = content.msubs.get(p);
+							path.push(p);
+							if( n == null ) {
+								n = { name : p.split(".").shift(), path : path.join("/"), lines : [], linesData: [], subs : [], msubs : new Map() };
+								content.subs.push(n);
+								content.msubs.set(p, n);
+							}
+							content = n;
+						}
+					}
+					content.linesData.push(dprops);
+					content.lines.push(p.props);
 				}
 				for( c in p ) loadRec(c,p);
 			}
@@ -161,6 +180,34 @@ class DataFiles {
 
 		for( dir in sheet.props.dataFiles.split(";") )
 			gatherRec(dir.split("/"),[],0);
+
+
+		var lines : Array<Dynamic> = [];
+		var linesData : Array<DataProps> = [];
+		var separators = [];
+		@:privateAccess {
+			sheet.sheet.lines = lines;
+			sheet.sheet.linesData = linesData;
+			sheet.sheet.separators = separators;
+		}
+		function browseRec( d : DataDef, level : Int ) {
+			if( d.subs.length == 1 ) {
+				// shortcut
+				d.subs[0].name = d.name+" > "+d.subs[0].name;
+				browseRec(d.subs[0], level);
+				return;
+			}
+			separators.push({ title : d.name, level : level, index : lines.length, path : d.path });
+			for( i in 0...d.lines.length ) {
+				lines.push(d.lines[i]);
+				linesData.push(d.linesData[i]);
+			}
+			d.subs.sort(function(d1,d2) return Reflect.compare(d1.name.toLowerCase(), d2.name.toLowerCase()));
+			for( s in d.subs )
+				browseRec(s, level + 1);
+		}
+		for( r in root.subs )
+			browseRec(r, 0);
 	}
 
 	#if editor

+ 6 - 2
hide/comp/cdb/Line.hx

@@ -46,8 +46,12 @@ class Line extends Component {
 		}
 		for( i in 0...t.sheet.separators.length ) {
 			var sep = t.sheet.separators[t.sheet.separators.length - 1 - i];
-			if( sep.index < line.index && sep.title != null )
-				return sep.title.split(" > ").join("/");
+			if( sep.index < line.index ) {
+				if( sep.path != null )
+					return sep.path;
+				if( sep.title != null )
+					return sep.title;
+			}
 		}
 		return null;
 	}

+ 22 - 11
hide/comp/cdb/Table.hx

@@ -267,7 +267,7 @@ class Table extends Component {
 		var curLevel = sepInfo.level;
 		if( curLevel == null ) curLevel = 0;
 
-		function getLines() {
+		function getLines( ?filter ) {
 			var snext = 0, sref = -1, scur = -1;
 			var out = [];
 			for( i in 0...lines.length ) {
@@ -281,8 +281,8 @@ class Table extends Component {
 					}
 					snext++;
 				}
-				if( sref == sindex )
-					out.push({ line : lines[i], sep : scur });
+				if( sref == sindex && (filter == null || scur == filter) )
+					out.push(lines[i]);
 			}
 			return out;
 		}
@@ -325,10 +325,16 @@ class Table extends Component {
 			function expand(show) {
 				var subs = element.find("tr.separator");
 				function showRec(t:SepTree) {
+					if( !show ) {
+						for( s in t.subs )
+							showRec(s);
+					}
 					if( isSepHidden(t.index) == show )
 						new Element(subs[t.index]).find("a.toggle").click();
-					for( s in t.subs )
-						showRec(s);
+					if( show ) {
+						for( s in t.subs )
+							showRec(s);
+					}
 				}
 				showRec(makeSeparatorTree(sepInfo));
 			}
@@ -376,11 +382,11 @@ class Table extends Component {
 						sep.find("a.toggle").click();
 				}},
 			];
-			if( sheet.props.dataFiles != null && title != null )
+			if( sepInfo.path != null )
 				opts.unshift({
 					label : "Open",
 					click : function() {
-						ide.openFile(title.split(" > ").join("/"));
+						ide.openFile(sepInfo.path);
 					},
 				});
 			new hide.comp.ContextMenu(opts);
@@ -436,11 +442,12 @@ class Table extends Component {
 			hidden = !hidden;
 			saveDisplayState("sep/"+title, !hidden);
 			sync();
-			for( l in getLines() ) {
+
+			for( l in getLines( hidden ? null : sindex ) ) {
 				if( hidden ) {
-					l.line.hide();
+					l.hide();
 				} else {
-					if( l.sep == sindex || !isSepHidden(l.sep) ) l.line.create();
+					l.create();
 				}
 			}
 
@@ -448,7 +455,11 @@ class Table extends Component {
 			function toggleRec( t : SepTree ) {
 				var sid = sheet.separators.indexOf(t.sep);
 				subs[sid].style.display = hidden ? "none" : "";
-				if( !hidden && isSepHidden(sid) ) return;
+				if( !hidden ) {
+					if( isSepHidden(sid) ) return;
+					for( l in getLines(sid) )
+						l.create();
+				}
 				for( s in t.subs )
 					toggleRec(s);
 			}