Bläddra i källkod

fixes for cdb props: ctrl+s on script propagate, allow large cdb object view

Nicolas Cannasse 4 år sedan
förälder
incheckning
6349b74bd5

+ 19 - 0
bin/style.css

@@ -663,6 +663,25 @@ input[type=checkbox]:checked:after {
 .hide-properties .vector {
   flex-direction: row;
 }
+.hide-properties .btn-cdb-large {
+  width: 16px;
+  font-size: 14px;
+  margin: 3px;
+  opacity: 0.5;
+}
+.hide-properties .cdb-large .cdb-obj-editor {
+  position: fixed;
+  bottom: 0px;
+  right: 0px;
+  z-index: 99;
+  width: 600px;
+  overflow: auto;
+  padding: 10px;
+  background: #111;
+}
+.hide-properties .cdb-large .btn-cdb-large {
+  opacity: 1;
+}
 /* Curve editor */
 .hide-curve-editor {
   position: relative;

+ 23 - 0
bin/style.less

@@ -728,6 +728,29 @@ input[type=checkbox] {
 		flex-direction: row;
 	}
 
+	.btn-cdb-large {
+		width : 16px;
+		font-size : 14px;
+		margin : 3px;
+		opacity : 0.5;
+	}
+
+	.cdb-large {
+		.cdb-obj-editor {
+			position: fixed;
+			bottom : 0px;
+			right : 0px;
+			z-index: 99;
+			width: 600px;
+			overflow: auto;
+			padding: 10px;
+			background: #111;
+		}
+		.btn-cdb-large {
+			opacity: 1;
+		}
+	}
+
 }
 
 /* Curve editor */

+ 5 - 1
hide/comp/CodeEditor.hx

@@ -6,12 +6,16 @@ class CodeEditor extends Component {
 	var errorMessage : Element;
 	var currrentDecos : Array<String> = [];
 	public var code(get,never) : String;
+	public var propagateKeys : Bool = false;
 
 	public function new( code : String, lang : String, ?parent : Element, ?root : Element ) {
 		super(parent,root);
 		var root = element;
 		root.addClass("codeeditor");
-		root.on("keydown", function(e) { if( e.keyCode == 27 && root.find(".suggest-widget.visible").length == 0 ) onClose(); e.stopPropagation(); });
+		root.on("keydown", function(e) {
+			if( e.keyCode == 27 && root.find(".suggest-widget.visible").length == 0 ) onClose();
+			if( !propagateKeys ) e.stopPropagation();
+		});
 		editor = monaco.ScriptEditor.create(root[0],{
 			value : code,
 			language : lang == null ? "javascript" : lang,

+ 14 - 1
hide/comp/SceneEditor.hx

@@ -1404,10 +1404,23 @@ class SceneEditor {
 
 		var group = new hide.Element('
 			<div class="group" name="CDB">
-				<dl><dt>Type</dt><dd><select><option value="">- No props -</option></select></dd>
+				<dl>
+				<dt>
+					<div class="btn-cdb-large fa fa-file-text"></div>
+					Type
+				</dt>
+				<dd><select><option value="">- No props -</option></select></dd>
 			</div>
 		');
 
+		var cdbLarge = @:privateAccess view.getDisplayState("cdbLarge");
+		group.find(".btn-cdb-large").click((_) -> {
+			cdbLarge = !cdbLarge;
+			@:privateAccess view.saveDisplayState("cdbLarge", cdbLarge);
+			group.toggleClass("cdb-large", cdbLarge);
+		});
+		group.toggleClass("cdb-large", cdbLarge == true);
+
 		var select = group.find("select");
 		for(t in types) {
 			var id = DataFiles.getTypeName(t);

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

@@ -748,9 +748,13 @@ class Cell extends Component {
 
 	public function open( ?immediate : Bool ) {
 		if( column.type == TString && column.kind == Script ) {
-			if( immediate ) return;
+
+			// prevent opening the script if we are undo/redo-ing as this
+			// will get our script windowed focus and prevent further undo/redo action
+			if( immediate && !Editor.inRefreshAll ) return;
+
 			var str = value == null ? "" : editor.base.valToString(column.type, value);
-			@:privateAccess table.toggleList(this, function() return new ScriptTable(editor, this));
+			@:privateAccess table.toggleList(this, immediate, function() return new ScriptTable(editor, this));
 		} else
 			@:privateAccess table.toggleList(this, immediate);
 	}

+ 3 - 0
hide/comp/cdb/Editor.hx

@@ -504,9 +504,11 @@ class Editor extends Component {
 		api.save();
 	}
 
+	public static var inRefreshAll(default,null) : Bool;
 	public static function refreshAll( eraseUndo = false ) {
 		var editors : Array<Editor> = [for( e in new Element(".is-cdb-editor").elements() ) e.data("cdb")];
 		DataFiles.load();
+		inRefreshAll = true;
 		for( e in editors ) {
 			e.syncSheet(Ide.inst.database);
 			e.refresh();
@@ -517,6 +519,7 @@ class Editor extends Component {
 				e.undoState = [];
 			}
 		}
+		inRefreshAll = false;
 	}
 
 	function showReferences() {

+ 5 - 1
hide/comp/cdb/ScriptTable.hx

@@ -48,7 +48,10 @@ class ScriptTable extends SubTable {
 			if( st != null ) obj = st.cell.line.obj;
 		}
 
-		div.on("keypress keydown keyup", (e) -> e.stopPropagation());
+		div.on("keypress keydown keyup", (e) -> {
+			// let pass Ctrl+S if ObjEditor (allow save script)
+			if( e.keyCode != "S".code || !Std.is(editor, ObjEditor) ) e.stopPropagation();
+		});
 		var checker = new ScriptEditor.ScriptChecker(editor.config,"cdb."+cell.getDocumentName(),[
 			"cdb."+cell.table.sheet.name => cell.line.obj,
 			"cdb.objID" => ids.join(":"),
@@ -56,6 +59,7 @@ class ScriptTable extends SubTable {
 		]);
 		script = new ScriptEditor(cell.value, checker, div);
 		script.onSave = saveValue;
+		script.propagateKeys = true;
 		script.onClose = function() { close(); cell.focus(); }
 		lines = [new Line(this,[],0,script.element)];
 		insertedTR.addClass("code");