/// <inheritdoc /> public bool ConvertEditorConfig(GridEditor editor, JToken token, out IGridEditorConfig config) { config = configTypes.ContainsKey(editor.Alias) ? (IGridEditorConfig)Activator.CreateInstance(types[editor.Alias], editor, token) : null; return(config != null); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); GridEditor map = target as GridEditor; map.GridMap(); }
static void Init() { GridEditor window = (GridEditor)EditorWindow.GetWindow(typeof(GridEditor)); window.position = new Rect(Screen.width / 2, Screen.height / 2 - 150, 600, 700); window.Show(); }
/// <summary> /// Converts the specified <code>token</code> into an instance of <code>IGridEditorConfig</code>. /// </summary> /// <param name="editor"></param> /// <param name="token">The instance of <code>JToken</code> representing the editor config.</param> /// <param name="config">The converted config.</param> public bool ConvertEditorConfig(GridEditor editor, JToken token, out IGridEditorConfig config) { config = null; switch (editor.Alias) { case "media_wide": case "media_wide_cropped": config = GridEditorMediaConfig.Parse(editor, token as JObject); break; case "banner_headline": case "banner_tagline": case "headline_centered": case "abstract": case "paragraph": case "quote_D": case "code": config = GridEditorTextConfig.Parse(editor, token as JObject); break; } return config != null; }
/// <summary> /// Gets an instance of <code>GridEditorTextConfig</code> from the specified <code>JsonObject</code>. /// </summary> /// <param name="editor">The parent editor.</param> /// <param name="obj">The instance of <code>JObject</code> to be parsed.</param> public static GridEditorTextConfig Parse(GridEditor editor, JObject obj) { if (obj == null) return null; return new GridEditorTextConfig(editor, obj) { Style = obj.GetString("style"), Markup = obj.GetString("markup") }; }
/// <summary> /// Converts the specified <code>token</code> into an instance of <see cref="IGridEditorConfig"/>. /// </summary> /// <param name="editor"></param> /// <param name="token">The instance of <see cref="JToken"/> representing the editor config.</param> /// <param name="config">The converted editor config.</param> public bool ConvertEditorConfig(GridEditor editor, JToken token, out IGridEditorConfig config) { config = null; if (IsLinkPickerEditor(editor)) { config = GridEditorLinkPickerConfig.Parse(editor, token as JObject); } return config != null; }
public void CanParseManifest_GridEditors() { const string json = @"{ 'javascript': [ ], 'css': [ ], 'gridEditors': [ { 'name': 'Small Hero', 'alias': 'small-hero', 'view': '~/App_Plugins/MyPlugin/small-hero/editortemplate.html', 'render': '~/Views/Partials/Grid/Editors/SmallHero.cshtml', 'icon': 'icon-presentation', 'config': { 'image': { 'size': { 'width': 1200, 'height': 185 } }, 'link': { 'maxNumberOfItems': 1, 'minNumberOfItems': 0 } } }, { 'name': 'Document Links By Category', 'alias': 'document-links-by-category', 'view': '~/App_Plugins/MyPlugin/document-links-by-category/editortemplate.html', 'render': '~/Views/Partials/Grid/Editors/DocumentLinksByCategory.cshtml', 'icon': 'icon-umb-members' } ] }"; PackageManifest manifest = _parser.ParseManifest(json); Assert.AreEqual(2, manifest.GridEditors.Length); GridEditor editor = manifest.GridEditors[0]; Assert.AreEqual("small-hero", editor.Alias); Assert.AreEqual("Small Hero", editor.Name); Assert.AreEqual(_ioHelper.ResolveUrl("/App_Plugins/MyPlugin/small-hero/editortemplate.html"), editor.View); Assert.AreEqual(_ioHelper.ResolveUrl("/Views/Partials/Grid/Editors/SmallHero.cshtml"), editor.Render); Assert.AreEqual("icon-presentation", editor.Icon); IDictionary <string, object> config = editor.Config; Assert.AreEqual(2, config.Count); Assert.IsTrue(config.ContainsKey("image")); object c = config["image"]; Assert.IsInstanceOf <JObject>(c); // FIXME: is this what we want? Assert.IsTrue(config.ContainsKey("link")); c = config["link"]; Assert.IsInstanceOf <JObject>(c); // FIXME: is this what we want? // FIXME: should we resolveUrl in configs? }
private void DoGridOffsetHandle(ShopMoverGrid f) { GridEditor.DrawVec3Handle(f.transform.position + (Vector3)f.gridOffset, delegate(Vector3 offs) { Undo.RecordObject(f, "ShopMoverGrid Change Grid Corner Offset"); EditorUtility.SetDirty(target); f.gridOffset = offs - f.transform.position; }); }
private GridEditorLinkPickerConfig(GridEditor editor, JObject obj) : base(editor, obj) { Title = obj.GetObject("title", GridEditorLinkPickerConfigTitle.Parse); Limit = obj.GetInt32("limit"); Types = obj.GetObject("types", GridEditorLinkPickerConfigTypes.Parse); ShowTable = obj.GetBoolean("showTable"); Columns = obj.GetObject("columns", GridEditorLinkPickerConfigColumns.Parse); }
private static void OpenWindow() { GridEditor window = GetWindow <GridEditor>(); window.minSize = new Vector2(250, 240); window.titleContent = new GUIContent("Grid Editor"); buttonParams = new[] { GUILayout.Width(buttonSize.x), GUILayout.Height(buttonSize.y) }; }
private object GetEditor(GridEditor editor) { // Other properties are ommitted since I'm not sure we need them for SPA solutions (including the config) return(new { alias = editor.Alias, }); }
/// <summary> /// Converts the specified <paramref name="token"/> into an instance of <see cref="IGridEditorConfig"/>. /// </summary> /// <param name="editor">A reference to the parent <see cref="GridEditor"/>.</param> /// <param name="token">The instance of <see cref="JToken"/> representing the editor config.</param> /// <param name="config">The converted editor config.</param> public override bool ConvertEditorConfig(GridEditor editor, JToken token, out IGridEditorConfig config) { config = null; if (IsImagePickerEditor(editor)) { config = GridEditorImagePickerConfig.Parse(editor, token as JObject); } return(config != null); }
/// <summary> /// Converts the specified <paramref name="token"/> into an instance of <see cref="IGridEditorConfig"/>. /// </summary> /// <param name="editor"></param> /// <param name="token">The instance of <see cref="JToken"/> representing the editor config.</param> /// <param name="config">The converted editor config.</param> public bool ConvertEditorConfig(GridEditor editor, JToken token, out IGridEditorConfig config) { config = null; if (IsVideoPicker(editor)) { config = GridEditorVideoPickerConfig.Parse(editor, token as JObject); } return(config != null); }
protected override void RemoveSelectedColumn() { var xafGridColumn = gridView.CustomizationForm.ActiveListBox.SelectedItem as IXafGridColumn; if (xafGridColumn != null) { GridEditor.RemoveColumn(new XpandGridColumnWrapper(xafGridColumn)); } }
/// <summary> /// Converts the specified <paramref name="token"/> into an instance of <see cref="IGridEditorConfig"/>. /// </summary> /// <param name="editor"></param> /// <param name="token">The instance of <see cref="JToken"/> representing the editor config.</param> /// <param name="config">The converted config.</param> public override bool ConvertEditorConfig(GridEditor editor, JToken token, out IGridEditorConfig config) { config = null; if (IsDocTypeGridEditor(editor)) { config = GridEditorDtgeConfig.Parse(editor, token as JObject); } return(config != null); }
public static GridEditorLeBlenderConfig Parse(GridEditor editor, JObject obj) { if (obj == null) return null; return new GridEditorLeBlenderConfig(editor, obj) { FrontView = obj.GetString("frontView"), RenderInGrid = obj.GetString("renderInGrid") }; }
private GridEditorDtgeConfig(GridEditor editor, JObject obj) : base(editor, obj) { AllowedDocTypes = obj.GetStringArray("allowedDocTypes"); NameTemplate = obj.GetString("nameTemplate"); EnablePreview = obj.GetBoolean("enablePreview"); ViewPath = obj.GetString("viewPath"); PreviewViewPath = obj.GetString("previewViewPath"); PreviewCssFilePath = obj.GetString("previewCssFilePath"); PreviewJsFilePath = obj.GetString("previewJsFilePath"); }
private bool IsVideoPicker(GridEditor editor) { return( CultureInfo.InvariantCulture.CompareInfo.IndexOf(editor.View, VideoPickerConstants.GridEditorView, CompareOptions.IgnoreCase) >= 0 || editor.Alias.Equals(VideoPickerConstants.GridEditorAlias, StringComparison.InvariantCultureIgnoreCase) || CultureInfo.InvariantCulture.CompareInfo.IndexOf(editor.Alias, VideoPickerConstants.GridEditorAlias + ".", CompareOptions.IgnoreCase) >= 0 ); }
/// <summary> /// Converts the specified <paramref name="token" /> into an instance of <see cref="IGridEditorConfig" />. /// </summary> /// <param name="editor"></param> /// <param name="token">The instance of <see cref="JToken" /> representing the editor config.</param> /// <param name="config">The converted editor config.</param> /// <returns></returns> public bool ConvertEditorConfig(GridEditor editor, JToken token, out IGridEditorConfig config) { config = null; if (this.isLeBlenderEditor(editor)) { config = GridEditorLeBlenderConfig.Parse(editor, token as JObject); } return(config != null); }
public bool ConvertEditorConfig(GridEditor editor, JToken token, out IGridEditorConfig config) { config = null; if (editor.Alias == "richtextBlock") { config = GridEditorTextConfig.Parse(editor, token as JObject); } return(config != null); }
/// <inheritdoc /> public virtual GridControl CreateGridControl(JObject json, GridArea area) { // The saved JSON for the editor only contains the alias of the editor as other information may change over // time. As a result of this, we need to inject a new editor object into the JSON. ReplaceEditorObjectFromConfig(json); // Parse the Grid editor (undelrying type may be generic ... or not) GridEditor editor = json.GetObject("editor", CreateGridEditor); // Initialize a new Grid control GridControl control = new GridControl(json, area); // Make sure to set the editor before we parse the control value control.Editor = editor; // Parse the control value control.Value = ParseGridControlValue(control); // Get the type of the editor config (it may not have a config) Type configType = control.Editor.Config?.GetType(); // Determine the value type Type valueType = null; foreach (IGridConverter converter in _converters) { if (converter.GetValueType(control, out valueType)) { break; } } // If no converters specify a value type, we just return the control right away if (valueType == null) { return(control); } // If the editor doesn't have a configuration, we can create a new generic type from just the value type. // If we both have a value type and config type, we create a new generic type from both types if (configType == null) { Type genericType = typeof(GridControl <>).MakeGenericType(valueType); control = (GridControl)Activator.CreateInstance(genericType, control); } else { Type genericType = typeof(GridControl <,>).MakeGenericType(valueType, configType); control = (GridControl)Activator.CreateInstance(genericType, control, editor); } // Return the control return(control); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); GridEditor script = (GridEditor)target; if (GUILayout.Button("generateMap")) { script.constructGrid(script.map); } }
private void ScriptsMenu() { _showScriptsMenu = EditorGUILayout.Foldout(_showScriptsMenu, "Script"); if (_showScriptsMenu) { _gridEditor = EditorGUILayout.ObjectField(_gridEditor, typeof(GridEditor), true) as GridEditor; _boardEditor = EditorGUILayout.ObjectField(_boardEditor, typeof(BoardEditor), true) as BoardEditor; _floorEditor = EditorGUILayout.ObjectField(_floorEditor, typeof(FloorEditor), true) as FloorEditor; _tileEditor = EditorGUILayout.ObjectField(_tileEditor, typeof(TileEditor), true) as TileEditor; } }
private GridEditorLeBlenderConfig(GridEditor editor, JObject obj) : base(obj) { Editor = editor; JToken guidJToken; if ((guidJToken = editor.Control.JObject.GetValue("guid")) != null) { Guid = guidJToken.Value<string>(); } }
private bool IsDocTypeGridEditor(GridEditor editor) { // The editor may be NULL if it no longer exists in a package.manifest file if (editor?.View == null) { return(false); } const string view = "/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.html"; return(ContainsIgnoreCase(editor.View.Split('?')[0], view)); }
private bool IsImagePickerEditor(GridEditor editor) { // The editor may be NULL if it no longer exists in a package.manifest file if (editor == null) { return(false); } const string alias = "Skybrud.ImagePicker"; const string view = "/App_Plugins/Skybrud.ImagePicker/views/ImagePickerGridEditor.html"; return(ContainsIgnoreCase(editor.View.Split('?')[0], view) || EqualsIgnoreCase(editor.Alias, alias) || ContainsIgnoreCase(editor.Alias, alias + ".")); }
public override bool ConvertEditorConfig(GridEditor editor, JToken token, out IGridEditorConfig config) { config = null; switch (editor.View?.Split('?')[0]) { case "/App_Plugins/Skybrud.Umbraco.Elements/Views/Grid.html": config = GridEditorElementsConfig.Parse(editor, token as JObject); return(true); } return(false); }
public static void Init() { instance = ( GridEditor )EditorWindow.GetWindow(typeof(GridEditor)); instance.title = "Grid Editor"; // Delegate the framework so that it works in cooperation with Scene View if (!delegated) { SceneView.onSceneGUIDelegate += instance.LevelEditorUpdate; delegated = true; } Refresh(); }
public void OnEnable() { if (OnGUIActive) { GameObject editor = GameObject.Find("EditorManager"); _gridEditor = editor.GetComponent <GridEditor>(); _boardEditor = editor.GetComponent <BoardEditor>(); _floorEditor = editor.GetComponent <FloorEditor>(); _tileEditor = editor.GetComponent <TileEditor>(); _defaultPath = $"{Application.dataPath}/Resources/Text/"; _savePath = _defaultPath; ScriptsLoaded = true; } }
/// <summary> /// Converts the specified <paramref name="token"/> into an instance of <see cref="IGridEditorConfig"/>. /// </summary> /// <param name="editor"></param> /// <param name="token">The instance of <see cref="JToken"/> representing the editor config.</param> /// <param name="config">The converted config.</param> public override bool ConvertEditorConfig(GridEditor editor, JToken token, out IGridEditorConfig config) { config = null; if (IsMediaEditor(editor)) { config = new GridEditorMediaConfig(editor, token as JObject); } else if (IsTextStringEditor(editor)) { config = new GridEditorTextConfig(editor, token as JObject); } return(config != null); }
private void OnGUI() { if (focusedWindow != this) { this.Close(); } _selectedType = (TileGeneration.TileType)EditorGUILayout.EnumPopup("", _selectedType); if (_selectedType != _startingType) { GridEditor.SetSelectedTileType(_selectedType); GetWindow(typeof(GridEditor)).Focus(); this.Close(); } }
public override bool GetConfigType(GridEditor editor, out Type type) { type = null; if (IsMediaEditor(editor)) { type = typeof(GridEditorMediaConfig); } else if (IsTextStringEditor(editor)) { type = typeof(GridEditorTextConfig); } return(type != null); }
/// <summary> /// Converts the specified <paramref name="token"/> into an instance of <see cref="IGridEditorConfig"/>. /// </summary> /// <param name="editor"></param> /// <param name="token">The instance of <see cref="JToken"/> representing the editor config.</param> /// <param name="config">The converted config.</param> public virtual bool ConvertEditorConfig(GridEditor editor, JToken token, out IGridEditorConfig config) { // Just set the value to NULL initially (output parameters must be defined) config = null; // Check the alias of the grid editor switch (editor.Alias) { // Handle any further parsing of the value of our grid editor configugration case "SkriftContactPersons": config = SkriftGridEditorContactPersonsConfig.Parse(editor, token as JObject); break; } // Return whether our converter supported the editor return(config != null); }
void Start() { if (instance == null) { instance = this; loadScrollViewList = new List <GameObject>(); InitScrollViewButton(LayerDepth.Tile); InitScrollViewButton(LayerDepth.Object); CurrentShipGridEditor = EditorManager.Instance.CurrentShipEditGridManager; CurrentShipGridEditor.InitGridDisplay(ref gridDisplay); } else { Debug.LogError("Only one UIEditorManager"); Destroy(this); } }
/// <summary> /// Converts the specified <paramref name="token"/> into an instance of <see cref="IGridEditorConfig"/>. /// </summary> /// <param name="editor"></param> /// <param name="token">The instance of <see cref="JToken"/> representing the editor config.</param> /// <param name="config">The converted config.</param> public virtual bool ConvertEditorConfig(GridEditor editor, JToken token, out IGridEditorConfig config) { config = null; switch (editor.Alias) { case "media": config = GridEditorMediaConfig.Parse(editor, token as JObject); break; case "headline": case "quote": config = GridEditorTextConfig.Parse(editor, token as JObject); break; } return(config != null); }
/// <summary> /// Converts the specified <code>token</code> into an instance of <code>IGridEditorConfig</code>. /// </summary> /// <param name="editor"></param> /// <param name="token">The instance of <code>JToken</code> representing the editor config.</param> /// <param name="config">The converted config.</param> public virtual bool ConvertEditorConfig(GridEditor editor, JToken token, out IGridEditorConfig config) { config = null; switch (editor.Alias) { case "media": config = GridEditorMediaConfig.Parse(editor, token as JObject); break; case "headline": case "quote": config = GridEditorTextConfig.Parse(editor, token as JObject); break; } return config != null; }
private bool IsLinkPickerEditor(GridEditor editor) { return editor.Alias.ToLower() == "skybrud.linkpicker" || editor.Alias.ToLower().StartsWith("skybrud.linkpicker."); }
/// <summary> /// Gets an instance of <code>GridEditorMediaConfig</code> from the specified <code>JsonObject</code>. /// </summary> /// <param name="editor">The parent editor.</param> /// <param name="obj">The instance of <code>JObject</code> to be parsed.</param> public static GridEditorMediaConfig Parse(GridEditor editor, JObject obj) { if (obj == null) return null; return new GridEditorMediaConfig(editor, obj) { Size = obj.GetObject("size", GridEditorMediaConfigSize.Parse) }; }
private GridEditorMediaConfig(GridEditor editor, JObject obj) : base(obj) { Editor = editor; }
private GridEditorLinkPickerConfig(GridEditor editor, JObject obj) : base(obj) { Editor = editor; }
/// <summary> /// Gets an instance of <see cref="GridEditorLinkPickerConfig"/> from the specified <see cref="JObject"/>. /// </summary> /// <param name="editor">The parent editor.</param> /// <param name="obj">The instance of <see cref="JObject"/> to be parsed.</param> public static GridEditorLinkPickerConfig Parse(GridEditor editor, JObject obj) { return obj == null ? null : new GridEditorLinkPickerConfig(editor, obj); }