Пример #1
0
        private void DrawToolbar()
        {
            GUILayout.BeginHorizontal(EditorStyles.toolbar);

            EditorGUI.BeginDisabledGroup(PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab || this.targets.Length != 1);
            if (this.target.IsEditable && GUILayout.Button(TileLang.OpensWindow(TileLang.ParticularText("Action", "Build Prefab")), RotorzEditorStyles.Instance.ToolbarButtonPaddedExtra))
            {
                TileSystemCommands.Command_BuildPrefab(this.target);
                GUIUtility.ExitGUI();
            }
            EditorGUI.EndDisabledGroup();

            GUILayout.FlexibleSpace();

            using (var content = ControlContent.Basic(
                       RotorzEditorStyles.Skin.GridToggle,
                       TileLang.ParticularText("Action", "Toggle Grid Display")
                       )) {
                RtsPreferences.ShowGrid.Value = GUILayout.Toggle(RtsPreferences.ShowGrid, content, RotorzEditorStyles.Instance.ToolbarButtonPadded);
            }

            using (var content = ControlContent.Basic(
                       RotorzEditorStyles.Skin.ChunkToggle,
                       TileLang.ParticularText("Action", "Toggle Chunk Display")
                       )) {
                RtsPreferences.ShowChunks.Value = GUILayout.Toggle(RtsPreferences.ShowChunks, content, RotorzEditorStyles.Instance.ToolbarButtonPadded);
            }

            EditorGUILayout.Space();

            this.DrawHelpButton();

            GUILayout.EndHorizontal();
        }
        //!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);
        }