private void ShowRecentHistoryMenu() { var recentHistoryMenu = new EditorMenu(); this.History.Cleanup(); recentHistoryMenu.AddCommand(this.SelectedObject.HistoryName) .Visible(this.SelectedObject != null && this.SelectedObject.Exists) .Checked(true) .Action(this.RecentHistoryMenu_Select, this.SelectedObject); foreach (IHistoryObject recent in this.History.Recent) { if (!ReferenceEquals(recent, this.SelectedObject)) { recentHistoryMenu.AddCommand(recent.HistoryName) .Checked(ReferenceEquals(recent, this.SelectedObject)) .Action(this.RecentHistoryMenu_Select, recent); } } recentHistoryMenu.AddSeparator(); recentHistoryMenu.AddCommand(TileLang.ParticularText("Action", "Clear Recent History")) .Action(() => { this.History.Clear(); }); this._recentHistoryButtonPosition.height -= 2; recentHistoryMenu.ShowAsDropdown(this._recentHistoryButtonPosition); }
/// <summary> /// Prepare and display drop down menu. /// </summary> /// <param name="position">Position of menu button.</param> private void DisplayMenu(Rect position) { var menu = new EditorMenu(); this.AddItemsToMenu(menu); menu.ShowAsDropdown(position); }
private static void DropDownSpacingCoordinate(Rect position, SnapAxis axis) { s_DropDownSnapAxis = axis; var menu = new EditorMenu(); menu.AddCommand(TileLang.Text("Fraction of Cell Size")) .Checked(axis.GridType == SnapGridType.Fraction) .Action(DoSelectSpacingType, SnapGridType.Fraction); menu.AddCommand(TileLang.Text("Custom Size")) .Checked(axis.GridType == SnapGridType.Custom) .Action(DoSelectSpacingType, SnapGridType.Custom); menu.AddSeparator(); foreach (int fractionValue in new int[] { 1, 2, 4, 8, 16 }) { menu.AddCommand(string.Format("{0} \u2044 {1}", 1, fractionValue)) .Action(s_DropDownSnapAxis.SetFraction, fractionValue); } menu.AddSeparator(); foreach (float decimalValue in new float[] { 0.1f, 0.25f, 0.5f, 1f, 2f }) { menu.AddCommand(string.Format("{0}", decimalValue)) .Action(s_DropDownSnapAxis.SetCustomSize, decimalValue); } menu.ShowAsDropdown(position); }
private void DrawHelpButton() { GUILayout.Space(33); Rect position = new Rect(Window.position.width - 37, 2, 34, 26); using (var helpMenuContent = ControlContent.Basic( RotorzEditorStyles.Skin.ContextHelp, TileLang.ParticularText("Action", "Help") )) { if (EditorInternalUtility.DropdownMenu(position, helpMenuContent, RotorzEditorStyles.Instance.FlatButton)) { var helpMenu = new EditorMenu(); helpMenu.AddCommand(TileLang.ParticularText("Action", "Show Tips")) .Checked(ControlContent.TrailingTipsVisible) .Action(() => { ControlContent.TrailingTipsVisible = !ControlContent.TrailingTipsVisible; }); --position.y; helpMenu.ShowAsDropdown(position); } } }
public static void Export() { if (mMenu == null) { mMenu = GetWindow(typeof(EditorMenu)) as EditorMenu; } mMenu.Show(); }
/// <summary> /// Populates a menu with element adder commands. /// </summary> /// <param name="menu">Editor menu.</param> /// <exception cref="System.ArgumentNullException"> /// If <paramref name="menu"/> is <c>null</c>. /// </exception> public void PopulateWithCommands(EditorMenu menu) { ExceptionUtility.CheckArgumentNotNull(menu, "menu"); menu.AddSeparator(); foreach (var command in ElementAdderMenuCommandMeta.InstantiateAnnotatedCommands <TContext>(this.ElementContractType)) { menu.AddCommand(command.FullPath) .Enabled(this.ElementAdder != null && command.CanExecute(this.ElementAdder)) .Action(command.Execute, this.ElementAdder); } }
public Client(Scene scene, List<ISystem<ClientSystemUpdate>> clientSystems, Dictionary<int, Action<MemoryStream, World>> recievers, Dictionary<Type, Action<object, MemoryStream>> serializers) : base(scene, recievers, serializers) { _clientSystems = clientSystems; _camerasSet = scene.World.GetEntities().With<Transform>().With<Camera>().AsSet(); _editorMenu = new EditorMenu(); _editorMenu.Editors.Add(new ConstructEditor(scene.World)); _editorMenu.Editors.Add(new InfoViewer()); _client = new RuffleSocket(_clientConfig); _messageTimer = new Stopwatch(); }
public void Menu() { Game game = Game.Get(); if (game.editMode) { EditorMenu.Create(); } else { GameMenu.Create(); } }
static void Main(string[] args) { WindowCreateInfo wci = new WindowCreateInfo { X = 100, Y = 100, WindowWidth = 1280, WindowHeight = 720, WindowTitle = "Tortuga Demo" }; GraphicsDeviceOptions options = new GraphicsDeviceOptions( debug: false, swapchainDepthFormat: PixelFormat.R16_UNorm, syncToVerticalBlank: true, resourceBindingModel: ResourceBindingModel.Improved, preferDepthRangeZeroToOne: true, preferStandardClipSpaceYDirection: true); #if DEBUG options.Debug = true; #endif _editorMenu = new EditorMenu(); Message <TransformMessageApplier>(); Message <InputForceApplier>(); Message <SimpleCameraMover>(); Message <ClientEntityAssignmentApplier>(); Message <VoxelSpaceMessageApplier>(); Message <VoxelGridMessageApplier>(); Message <VoxelGridChangeMessageApplier>(); Message <EntityRemover>(); Message <VoxelEditReceiver>(); Message <VoxelSpaceLoadReciever>(); Message <ComponentSyncMessageApplier <EntityMetaData> >(); _messageTargetMap = new MessageTargetMap(_byType, _byNum); _clientMessagingChannel = new MessagingChannel(_messageTargetMap); _client = new ClunkerClientApp(new ResourceLoader(), _messageTargetMap, _clientMessagingChannel); _client.Started += _client_Started; _server = new ClunkerServerApp(); _server.Started += _server_Started; var serverTask = _server.Start(); _client.Start(wci, options).Wait(); }
public bool DrawInputMode(string fallback = "Search", string splitBy = " ", string endSymbol = "+") { EditorGUILayout.BeginHorizontal(); var color = EditorStyles.textField.normal.textColor.SetAlpha(0.5f); var baseStyle = EditorStyles.textField.Alignment("MiddleCenter"); var symbolStyle = baseStyle.FixedWidth(24).FontSize(16).TextColor(color); var inputStyle = baseStyle.FontStyle("BoldAndItalic"); EditorUI.SetLayout(-1, 30); if ("∗".ToLabel().DrawButton(symbolStyle.ContentOffset(1, 0).Overflow(0, 3, 0, 0), false)) { var menu = new EditorMenu(); Action clear = () => this.queue = ""; menu.Add("Search", this.inputMode == 0, (() => { this.inputMode = 0; }) + clear); //menu.Add("Split",this.inputMode==1,(()=>{this.inputMode=1;})+clear); menu.Draw(); } var filter = this.inputTerms.Join(splitBy).Replace("~", " ").Draw(null, inputStyle); var inputChanged = EditorUI.lastChanged; EditorUI.lastChanged = false; endSymbol.ToLabel().DrawButton(symbolStyle.ContentOffset(-2, 0).Overflow(3, 0, 0, 0), false); EditorUI.SetLayout(-1, 0); EditorGUILayout.EndHorizontal(); bool open = false; var output = new StringBuilder(); foreach (var symbol in filter) { if (symbol == '[') { open = true; } if (symbol == ']') { open = false; } output.Append(symbol == ' ' && open ? '~' : symbol); } this.queue = this.queue ?? (output.ToString().Trim().IsEmpty() ? fallback : output.ToString()); this.queueSplit = splitBy; Utility.SetPref <string>("GUISkin-" + fallback + "-" + this.hash, this.inputTerms.Join(splitBy)); GUI.changed = false; return(inputChanged); }
/// <summary> /// Populates a menu with concrete element types. /// </summary> /// <param name="menu">Editor menu.</param> /// <exception cref="System.ArgumentNullException"> /// If <paramref name="menu"/> is <c>null</c>. /// </exception> public void PopulateWithConcreteTypes(EditorMenu menu) { ExceptionUtility.CheckArgumentNotNull(menu, "menu"); menu.AddSeparator(); foreach (var concreteType in ApplyTypeFilter(TypeMeta.DiscoverImplementations(this.ElementContractType))) { menu.AddCommand(this.FormatTypeDisplayName(concreteType)) .Enabled(this.ElementAdder != null && this.ElementAdder.CanAddElement(concreteType)) .Action(() => { if (this.ElementAdder.CanAddElement(concreteType)) { this.ElementAdder.AddElement(concreteType); } }); } }
private void ShowServiceInstallerContextMenu(ZenjectServiceInstaller installer, bool active) { var menu = new EditorMenu(); menu.AddCommand("Reset to Default Values") .Enabled(active) .Action(() => { var serviceInstallerType = installer.GetType(); Undo.RecordObject(installer, "Reset to Default Values"); var clone = ScriptableObject.CreateInstance(serviceInstallerType); clone.hideFlags = HideFlags.HideAndDontSave; EditorUtility.CopySerialized(clone, installer); DestroyImmediate(clone); }); menu.AddSeparator(); menu.AddCommand("Copy Values") .Action(() => { s_ClipboardReference = installer; }); menu.AddCommand("Paste Values") .Enabled(active && s_ClipboardReference != null && s_ClipboardReference != installer && s_ClipboardReference.GetType().IsAssignableFrom(installer.GetType())) .Action(() => { Undo.RecordObject(installer, "Paste Values"); EditorUtility.CopySerialized(s_ClipboardReference, installer); }); menu.AddSeparator(); menu.AddCommand("Edit Script") .Action(() => { var script = MonoScript.FromScriptableObject(installer); var assetPath = AssetDatabase.GetAssetPath(script); if (!string.IsNullOrEmpty(assetPath)) { var filePath = Path.Combine(Directory.GetCurrentDirectory(), assetPath); InternalEditorUtility.OpenFileAtLineExternal(filePath, 0); } }); menu.ShowAsContext(); }
protected override void SetCollectionUpdater() { _hoverAlsoHandles = false; if (_handlePointsUpdater == null) { _handlePointsUpdater = new HandlesPointsUpdater(); } _updater = _handlePointsUpdater as UpdaterBase; _updater.Init(); if (EditorMenu == null) { return; } EditorMenu.Init(_updater); }
private void DrawHelpButton() { using (var content = ControlContent.Basic(RotorzEditorStyles.Skin.ContextHelp)) { Rect position = GUILayoutUtility.GetRect(content, RotorzEditorStyles.Instance.ToolbarButtonPadded); if (EditorInternalUtility.DropdownMenu(position, content, RotorzEditorStyles.Instance.ToolbarButtonPadded)) { var helpMenu = new EditorMenu(); helpMenu.AddCommand(TileLang.ParticularText("Action", "Show Tips")) .Checked(ControlContent.TrailingTipsVisible) .Action(() => { ControlContent.TrailingTipsVisible = !ControlContent.TrailingTipsVisible; }); --position.y; helpMenu.ShowAsDropdown(position); } } }
private static void DropDownAlignment(Rect position, SnapAxis axis) { s_DropDownSnapAxis = axis; var menu = new EditorMenu(); menu.AddCommand(TileLang.ParticularText("SnapAlignment", "Free")) .Checked(axis.Alignment == SnapAlignment.Free) .Action(DoSelectSnapAlignment, SnapAlignment.Free); menu.AddCommand(TileLang.ParticularText("SnapAlignment", "Points")) .Checked(axis.Alignment == SnapAlignment.Points) .Action(DoSelectSnapAlignment, SnapAlignment.Points); menu.AddCommand(TileLang.ParticularText("SnapAlignment", "Cells")) .Checked(axis.Alignment == SnapAlignment.Cells) .Action(DoSelectSnapAlignment, SnapAlignment.Cells); menu.ShowAsDropdown(position); }
protected override void SetCollectionUpdater() { if (_pathObjectUpdater == null) { _pathObjectUpdater = new PathObjectUpdater(); } _updater = _pathObjectUpdater as UpdaterBase; _updater.Init(); if (EditorMenu == null) { return; } EditorMenu.Init(_updater); }
public void DrawMenu(GUIStyle style, bool editable = false) { if (GUILayoutUtility.GetLastRect().Clicked(1)) { var menu = new EditorMenu(); Action select = () => GUISkinEditor.focus = style; menu["Copy Style"] = (() => GUISkinEditor.action = "copy") + select; if (editable) { menu["Duplicate Style"] = (() => GUISkinEditor.action = "duplicate") + select; menu["Delete Style"] = (() => GUISkinEditor.action = "delete") + select; } if (!GUISkinEditor.focus.IsNull()) { Action paste = () => style.Use(GUISkinEditor.focus); menu["/"] = null; menu["Paste Style"] = (() => GUISkinEditor.action = "paste") + paste; } menu.Draw(); } }
void OnGUI() { if (GUI.Button(new Rect(10f, 10f, 200f, 50f), "Step(1) : ExportFiles")) { ExportFiles(Selection.objects); if (mMenu == null) { mMenu = GetWindow(typeof(EditorMenu)) as EditorMenu; } mMenu.Close(); } if (GUI.Button(new Rect(10f, 80f, 200f, 50f), "Step(2) : ExportFolders")) { ExportFolders(Selection.objects); if (mMenu == null) { mMenu = GetWindow(typeof(EditorMenu)) as EditorMenu; } mMenu.Close(); } }
/// <inheritdoc/> public override void AddItemsToMenu(EditorMenu menu) { base.AddItemsToMenu(menu); menu.AddCommand(TileLang.ParticularText("Action", "Reveal Material")) .Action(() => { EditorInternalUtility.FocusInspectorWindow(); EditorGUIUtility.PingObject(Tileset.AtlasMaterial); Selection.activeObject = Tileset.AtlasMaterial; }); menu.AddCommand(TileLang.ParticularText("Action", "Reveal Texture")) .Action(() => { if (Tileset.AtlasMaterial.mainTexture != null) { EditorInternalUtility.FocusInspectorWindow(); EditorGUIUtility.PingObject(Tileset.AtlasMaterial.mainTexture); Selection.activeObject = Tileset.AtlasMaterial.mainTexture; } }); // Only display "Cleanup Meshes" command when meshes are actually present! if (Tileset.tileMeshes != null && Tileset.tileMeshes.Length != 0) { menu.AddSeparator(); menu.AddCommand(TileLang.OpensWindow(TileLang.ParticularText("Action", "Cleanup Meshes"))) .Action(() => { CleanupTilesetMeshesWindow.ShowWindow(Tileset); }); } menu.AddSeparator(); menu.AddCommand(TileLang.OpensWindow(TileLang.ParticularText("Action", "Delete Tileset"))) .Action(() => { DeleteTilesetWindow.ShowWindow(Tileset); }); }
private EditorMenu BuildServiceInstallerMenu(ServiceEntry service) { int distinctInstallerTypeNamespaces = service.AvailableInstallerTypes .Select(type => type.Namespace) .Distinct() .Count(); var serviceInstallerMenu = new EditorMenu(); foreach (var serviceInstallerType in service.AvailableInstallerTypes) { string installerTitle = distinctInstallerTypeNamespaces > 1 ? NicifyNamespaceQualifiedInstallerTitle(serviceInstallerType) : NicifyInstallerTitle(serviceInstallerType); serviceInstallerMenu.AddCommand(installerTitle) .Action(() => { this.CreateServiceInstaller(serviceInstallerType); this.SetServiceExpanded(service, true); }); } return(serviceInstallerMenu); }
protected override void Initialize() { //Load Content string basePath = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName; basePath = Path.GetFullPath(Path.Combine(basePath, @"..\")); Content.RootDirectory = Path.Combine(basePath, @"Cirrus\bin\DesktopGL\AnyCPU\Debug\Content"); Sprites.Init(Content); // _imGuiRenderer = new ImGuiRenderer(this); _imGuiRenderer.RebuildFontAtlas(); //Create Custom Sampler PointWrap.Filter = TextureFilter.Point; PointWrap.AddressU = TextureAddressMode.Wrap; PointWrap.AddressV = TextureAddressMode.Wrap; CurrentRunningMenu = new StartMenu(_imGuiRenderer, this); spriteBatch = new SpriteBatch(GraphicsDevice); base.Initialize(); }
private void ShowContextMenu(Rect menuPosition) { var menu = new EditorMenu(); string labelResetToDefault3D = string.Format( /* 0: name of previous state */ TileLang.ParticularText("Action", "Reset to '{0}'"), TileLang.ParticularText("Preset Name", "Default: 3D") ); menu.AddCommand(labelResetToDefault3D) .Action(() => { Undo.RecordObjects(targets, labelResetToDefault3D); foreach (var target in targets) { ((TileSystemPreset)target).SetDefaults3D(); } }); string labelResetToDefault2D = string.Format( /* 0: name of previous state */ TileLang.ParticularText("Action", "Reset to '{0}'"), TileLang.ParticularText("Preset Name", "Default: 2D") ); menu.AddCommand(labelResetToDefault2D) .Action(() => { Undo.RecordObjects(targets, labelResetToDefault2D); foreach (var target in targets) { ((TileSystemPreset)target).SetDefaults2D(); } }); menu.ShowAsDropdown(menuPosition); }
/// <summary> /// Add items to designer menu. /// </summary> /// <param name="menu">The menu.</param> public virtual void AddItemsToMenu(EditorMenu menu) { }
void Awake() { EditorMenu._instance = this; resourceManager = ResourceManager.Instance; string storageDir; #if UNITY_IPHONE && !UNITY_EDITOR storageDir = Path.Combine (Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Game Editor Resources/"); #elif UNITY_EDITOR storageDir = Path.Combine (Application.dataPath, "Resources/Game Editor Resources/"); #else storageDir = Path.Combine (Application.dataPath, "Game Editor Resources/"); #endif Debug.Log (storageDir); resourceManager.SetStoragePath (storageDir); }
/// <summary> /// Populates a menu with element adder commands and concrete element types. /// </summary> /// <remarks> /// <para>Use <see cref="PopulateWithCommands(EditorMenu)"/> or <see cref="PopulateWithConcreteTypes(EditorMenu)"/> /// instead for greater control over how the editor menu is populated.</para> /// </remarks> /// <param name="menu">Editor menu.</param> /// <exception cref="System.ArgumentNullException"> /// If <paramref name="menu"/> is <c>null</c>. /// </exception> public void Populate(EditorMenu menu) { this.PopulateWithCommands(menu); this.PopulateWithConcreteTypes(menu); }
private void _brushList_BrushContextMenu(Brush brush) { // Do not attempt to display context menu for "(Erase)" item. if (brush == null) { return; } var brushRecord = BrushDatabase.Instance.FindRecord(brush); var brushContextMenu = new EditorMenu(); brushContextMenu.AddCommand(TileLang.OpensWindow(TileLang.ParticularText("Action", "Show in Designer"))) .Enabled(!brushRecord.IsMaster) // Cannot edit a master brush :) .Action(() => { ToolUtility.ShowBrushInDesigner(brush); }); var selectedTilesetBrush = brush as TilesetBrush; if (selectedTilesetBrush != null) { brushContextMenu.AddCommand(TileLang.ParticularText("Action", "Goto Tileset")) .Action(() => { this.brushList.Model.View = BrushListView.Tileset; this.brushList.Model.SelectedTileset = selectedTilesetBrush.Tileset; var designerWindow = RotorzWindow.GetInstance <DesignerWindow>(); if (designerWindow != null && !designerWindow.IsLocked) { designerWindow.SelectedObject = selectedTilesetBrush.Tileset; } this.Repaint(); }); } brushContextMenu.AddCommand(TileLang.ParticularText("Action", "Reveal Asset")) .Action(() => { EditorGUIUtility.PingObject(brush); }); brushContextMenu.AddSeparator(); brushContextMenu.AddCommand(TileLang.ParticularText("Action", "Refresh Preview")) .Action(() => { BrushUtility.RefreshPreviewIncludingDependencies(brush); }); brushContextMenu.AddSeparator(); brushContextMenu.AddCommand(TileLang.OpensWindow(TileLang.ParticularText("Action", "Create Duplicate"))) .Action(() => { var window = CreateBrushWindow.ShowWindow <DuplicateBrushCreator>(); window.SharedProperties["targetBrush"] = brush; }); var brushDescriptor = BrushUtility.GetDescriptor(brush.GetType()); brushContextMenu.AddCommand(TileLang.OpensWindow(TileLang.ParticularText("Action", "Create Alias"))) .Enabled(brushDescriptor.SupportsAliases) .Action(() => { var window = CreateBrushWindow.ShowWindow <AliasBrushCreator>(); window.SharedProperties["targetBrush"] = brush; }); brushContextMenu.AddCommand(TileLang.OpensWindow(TileLang.ParticularText("Action", "Delete Brush"))) .Action(() => { TileSystemCommands.DeleteBrush(brush, ToolUtility.SharedBrushListModel.View == BrushListView.Tileset); }); brushContextMenu.ShowAsContext(); }
//!TODO: The following should be refactored so that the tile system is passed in // as the context object rather than using a closure. private EditorMenu BuildContextMenu(TileSystem system) { var contextMenu = new EditorMenu(); contextMenu.AddCommand(TileLang.ParticularText("Action", "Inspect")) .Action(() => { EditorInternalUtility.FocusInspectorWindow(); }); contextMenu.AddSeparator(); contextMenu.AddCommand(TileLang.ParticularText("Action", "Rename")) .Action(() => { this.BeginEditingName(system); }); contextMenu.AddCommand(TileLang.ParticularText("Action", "Lock")) .Checked(system.Locked) .Action(() => { Undo.RecordObject(system, system.Locked ? TileLang.ParticularText("Action", "Unlock Tile System") : TileLang.ParticularText("Action", "Lock Tile System")); system.Locked = !system.Locked; EditorUtility.SetDirty(system); ToolUtility.RepaintScenePalette(); }); contextMenu.AddSeparator(); contextMenu.AddCommand(TileLang.OpensWindow(TileLang.ParticularText("Action", "Refresh Tiles"))) .Enabled(!system.Locked) .Action(() => { TileSystemCommands.Command_Refresh(system); }); contextMenu.AddCommand(TileLang.OpensWindow(TileLang.ParticularText("Action", "Repair Tiles"))) .Enabled(!system.Locked) .Action(() => { TileSystemCommands.Command_Repair(system); }); contextMenu.AddCommand(TileLang.OpensWindow(TileLang.ParticularText("Action", "Clear Tiles"))) .Enabled(!system.Locked) .Action(() => { TileSystemCommands.Command_Clear(system); }); //contextMenu.AddSeparator(); //contextMenu.AddCommand(TileLang.OpensWindow(TileLang.ParticularText("Action", "Refresh Plops"))) // .Enabled(!system.Locked) // .Action(() => { // TileSystemCommands.Command_RefreshPlops(system); // }); //contextMenu.AddCommand(TileLang.OpensWindow(TileLang.ParticularText("Action", "Clear Plops"))) // .Enabled(!system.Locked) // .Action(() => { // TileSystemCommands.Command_ClearPlops(system); // }); contextMenu.AddSeparator(); contextMenu.AddCommand(TileLang.ParticularText("Action", "Delete")) .Enabled(!system.Locked) .Action(() => { Undo.DestroyObjectImmediate(system.gameObject); }); contextMenu.AddSeparator(); contextMenu.AddCommand(TileLang.OpensWindow(TileLang.ParticularText("Action", "Build Prefab"))) .Action(() => { TileSystemCommands.Command_BuildPrefab(system); }); return(contextMenu); }