private void OutlineThresholdChanged(GUIBase sender)
        {
            GUISlider threshold = sender as GUISlider;

            _previewOutline.depthThreshold = threshold.value;
            RenderPreview(_guiCurrentFrame.value);
        }
        void OnDisable()
        {
            SavePaletteIfDirty();
            StorePrefs();

            Undo.undoRedoPerformed -= UndoRedoPerformed;
            _gui            = null;
            _guiTexture     = null;
            _guiColorFields = null;
            _guiEditMode    = null;
            _guiHue         = null;
            _guiSaturation  = null;
            _guiLuminance   = null;
        }
        private void UpdateGUI()
        {
            RemoveAll();

            int count = _materials != null ? _materials.Length : 0;

            _guiStartLights      = new GUIVector3Field[count];
            _guiEndLights        = new GUIVector3Field[count];
            _guiStartPaletteMixs = new GUISlider[count];
            _guiEndPaletteMixs   = new GUISlider[count];
            _guiDithers          = new GUISlider[count];

            if (count < 1)
            {
                return;
            }

            Vector4 light;

            GUIFoldout foldout = Add(new GUIFoldout(new GUIContent("PixelArt Materials"))) as GUIFoldout;

            for (int i = 0; i < count; i++)
            {
                _guiStartLights[i]      = new GUIVector3Field(new GUIContent("Start Light Direction"), ChangeHandler) as GUIVector3Field;
                _guiEndLights[i]        = new GUIVector3Field(new GUIContent("End Light Direction"), ChangeHandler) as GUIVector3Field;
                _guiStartPaletteMixs[i] = new GUISlider(new GUIContent("Start Palette Mix"), 0, 0, 1, ChangeHandler) as GUISlider;
                _guiEndPaletteMixs[i]   = new GUISlider(new GUIContent("End Palette Mix"), 0, 0, 1, ChangeHandler) as GUISlider;
                _guiDithers[i]          = new GUISlider(new GUIContent("Dither Threshold"), 0, 0, 1, ChangeHandler) as GUISlider;

                light = _materials[i].GetVector("_LightDir");
                _guiStartLights[i].vector = _guiEndLights[i].vector = new Vector3(light.x, light.y, light.z);

                _guiStartPaletteMixs[i].value = _guiEndPaletteMixs[i].value = _materials[i].GetFloat("_PaletteMix");
                _guiDithers[i].value          = _materials[i].GetFloat("_DitherThreshold");

                foldout.Add(_guiStartLights[i]);
                foldout.Add(_guiEndLights[i]);
                foldout.Add(_guiStartPaletteMixs[i]);
                foldout.Add(_guiEndPaletteMixs[i]);
                foldout.Add(_guiDithers[i]);

                if (i < count - 1)
                {
                    foldout.Add(new GUISpace());
                }
            }
        }
 void OnDisable()
 {
     _gui                = null;
     _guiSide            = null;
     _guiFrameCount      = null;
     _guiFrameWidth      = null;
     _guiFrameHeight     = null;
     _guiCurrentFrame    = null;
     _guiPositionOffset  = null;
     _guiScaleOffset     = null;
     _guiAnimationClips  = null;
     _guiAnimationClips  = null;
     _guiMaterials       = null;
     _guiStartRotation   = null;
     _guiEndRotation     = null;
     _guiLoopCount       = null;
     _guiPingPong        = null;
     _guiSpriteSheetName = null;
     _guiExport          = null;
     _guiPreview         = null;
 }
Exemplo n.º 5
0
        public static string GetSpriteUsageReport(int spriteNumber, Game game)
        {
            StringBuilder usageReport = new StringBuilder(5000);

            FindSpriteUsageInViews(spriteNumber, usageReport, game.RootViewFolder);

            if (spriteNumber == 0)
            {
                usageReport.AppendLine("Sprite 0 is the default sprite and can never be deleted");
            }

            foreach (MouseCursor cursor in game.Cursors)
            {
                if (cursor.Image == spriteNumber)
                {
                    usageReport.AppendLine("Mouse cursor " + cursor.ID + " (" + cursor.Name + ")");
                }
            }

            foreach (InventoryItem item in game.RootInventoryItemFolder.AllItemsFlat)
            {
                if (item.Image == spriteNumber)
                {
                    usageReport.AppendLine("Inventory item " + item.ID + " (" + item.Name + ")");
                }
            }

            if (game.Settings.DialogOptionsBullet == spriteNumber)
            {
                usageReport.AppendLine("Dialog bullet point image");
            }

            if ((game.Settings.InventoryHotspotMarker.Style == InventoryHotspotMarkerStyle.Sprite) &&
                (game.Settings.InventoryHotspotMarker.Image == spriteNumber))
            {
                usageReport.AppendLine("Inventory hotspot dot");
            }

            foreach (GUI gui in game.RootGUIFolder.AllItemsFlat)
            {
                if (gui.BackgroundImage == spriteNumber)
                {
                    usageReport.AppendLine("GUI " + gui.Name + " background image");
                }

                foreach (GUIControl control in gui.Controls)
                {
                    GUIButton button = control as GUIButton;
                    if (button != null)
                    {
                        if ((button.Image == spriteNumber) ||
                            (button.MouseoverImage == spriteNumber) ||
                            (button.PushedImage == spriteNumber))
                        {
                            usageReport.AppendLine("GUI button " + control.Name + " on GUI " + gui.Name);
                        }
                    }
                    GUISlider slider = control as GUISlider;
                    if ((slider != null) && (slider.HandleImage == spriteNumber))
                    {
                        usageReport.AppendLine("GUI slider " + control.Name + " on GUI " + gui.Name);
                    }
                    GUITextWindowEdge edge = control as GUITextWindowEdge;
                    if ((edge != null) && (edge.Image == spriteNumber))
                    {
                        usageReport.AppendLine("Text window edge " + control.Name + " on GUI " + gui.Name);
                    }
                }
            }

            if (usageReport.Length > 0)
            {
                string resultText = "Sprite " + spriteNumber + " is used in the following places. It may also be used in text script commands and in rooms (for example, room object graphics); we cannot detect those uses automatically.";
                resultText += Environment.NewLine + Environment.NewLine + usageReport.ToString();
                return(resultText);
            }
            return(null);
        }
Exemplo n.º 6
0
        private void CreateNewControl()
        {
            int left, top, width, height;

            GetSelectionRectangle(out left, out top, out width, out height);
            left   = _state.WindowXToGUI(left);
            top    = _state.WindowYToGUI(top);
            width  = _state.WindowSizeToGUI(width);
            height = _state.WindowSizeToGUI(height);

            if ((width < 2) || (height < 2))
            {
                return;
            }

            GUIControl newControl = null;

            switch (_controlAddMode)
            {
            case GUIAddType.Button:
                newControl = new GUIButton(left, top, width, height);
                break;

            case GUIAddType.Label:
                newControl = new GUILabel(left, top, width, height);
                break;

            case GUIAddType.TextBox:
                newControl = new GUITextBox(left, top, width, height);
                break;

            case GUIAddType.ListBox:
                newControl = new GUIListBox(left, top, width, height);
                break;

            case GUIAddType.Slider:
                newControl = new GUISlider(left, top, width, height);
                break;

            case GUIAddType.InvWindow:
                newControl = new GUIInventory(left, top, width, height);
                break;

            default:
                throw new AGSEditorException("Unknown control type added: " + _controlAddMode.ToString());
            }

            newControl.Name   = Factory.AGSEditor.GetFirstAvailableScriptName(newControl.ControlType);
            newControl.ZOrder = _gui.Controls.Count;
            newControl.ID     = _gui.Controls.Count;
            _gui.Controls.Add(newControl);
            _selectedControl = newControl;
            _selected.Clear();
            _selected.Add(newControl);

            RaiseOnControlsChanged();
            Factory.AGSEditor.CurrentGame.NotifyClientsGUIControlAddedOrRemoved(_gui, newControl);

            Factory.GUIController.SetPropertyGridObject(newControl);

            bgPanel.Invalidate();
            UpdateCursorImage();
            // Revert back to Select cursor
            OnCommandClick(Components.GuiComponent.MODE_SELECT_CONTROLS);
        }
        private void RebuildGUI(Texture2D texture)
        {
            StorePrefs();

            _gui = new GUIVertical();
            GUIScrollView scroll = _gui.Add(new GUIScrollView()) as GUIScrollView;

            _guiTexture = scroll.Add(new GUITextureField(new GUIContent("Palette Texture"),
                                                         PaletteTextureChanged,
                                                         PaletteTextureWillChange)) as GUITextureField;
            _guiTexture.texture = texture;

            if (texture == null)
            {
                return;
            }

            if (IsTextureReadWrite(texture))
            {
                _guiEditMode = scroll.Add(new GUIEnumPopup(new GUIContent("Edit Mode",
                                                                          "Palette edit operations affect either the single color or all colors in row/column/palette."),
                                                           PaletteEditMode.Single)) as GUIEnumPopup;

                scroll.Add(new GUIIntSlider(new GUIContent("Shades", "Number of shades per color in palette"),
                                            texture.height, 2, 16, ShadeCountChanged));
                _guiColorFields = new List <GUIColorField>();

                // Adding 15 accounts for horizontal scrollbar if needed.
                // Need a non-hardcoded-hacky way of getting this info...
                float         maxHeight     = texture.height * 20.0f + 15.0f;
                GUIScrollView paletteScroll = scroll.Add(new GUIScrollView(GUILayout.MaxHeight(maxHeight))) as GUIScrollView;
                for (int y = texture.height - 1; y >= 0; y--)
                {
                    GUIHorizontal horizontal = paletteScroll.Add(new GUIHorizontal()) as GUIHorizontal;
                    for (int x = 0; x < texture.width; x++)
                    {
                        GUIColorField color = horizontal.Add(new GUIColorField(null, ColorChanged)) as GUIColorField;
                        color.color       = texture.GetPixel(x, y);
                        color.tag         = y * texture.width + x;
                        color.controlName = PaletteControlName + color.tag;
                        _guiColorFields.Add(color);
                    }
                }

                scroll.Add(new GUISpace());
                _guiHue = scroll.Add(new GUISlider(new GUIContent("Hue Offset",
                                                                  "Amount to offset hue when generating shades"), 0.0f, -1.0f, 1.0f)) as GUISlider;
                _guiSaturation = scroll.Add(new GUISlider(new GUIContent("Saturation Offset",
                                                                         "Amount to offset saturation when generating shades"), 0.0f, -1.0f, 1.0f)) as GUISlider;
                _guiLuminance = scroll.Add(new GUISlider(new GUIContent("Luminance Offset",
                                                                        "Amount to offset luminance when generating shades"), 0.0f, -1.0f, 1.0f)) as GUISlider;
                scroll.Add(new GUIButton(new GUIContent("Generate Shades", "Generate shades from root colors"), GenerateShadesClicked));

                LoadPrefs();
            }
            else
            {
                HandleTextureNotReadWrite();
            }

            Repaint();
        }
Exemplo n.º 8
0
        void CreateGUI()
        {
            int      padding = 4;
            GUIStyle style   = new GUIStyle();

            style.padding = new RectOffset(padding, padding, padding, padding);

            _gui = new GUIVertical();

            GUIHorizontal toolLayout = new GUIHorizontal(style);

            toolLayout.Add(new GUIButton(Localize.GUI(null, "Toggle properties panel",
                                                      "Assets/kode80/Clouds/Editor/gui/button_properties.png"),
                                         TogglePropertiesPanel));
            toolLayout.Add(new GUISpace());
            toolLayout.Add(new GUIButton(Localize.GUI(null, "Create a new coverage map",
                                                      "Assets/kode80/Clouds/Editor/gui/button_new.png"),
                                         NewCoverageMapAction));
            toolLayout.Add(new GUIButton(Localize.GUI(null, "Save the current coverage map",
                                                      "Assets/kode80/Clouds/Editor/gui/button_save.png"),
                                         SaveCoverageMapAction));
            toolLayout.Add(new GUIButton(Localize.GUI(null, "Save the current coverage map as a new file",
                                                      "Assets/kode80/Clouds/Editor/gui/button_saveas.png"),
                                         SaveCoverageMapAsAction));
            toolLayout.Add(new GUISpace());
            toolLayout.Add(new GUIButton(Localize.GUI(null, "Export cubemap from current camera",
                                                      "Assets/kode80/Clouds/Editor/gui/button_cubemap.png"),
                                         ExportCubemapAction));

            toolLayout.Add(new GUISpace(true));
            GUIContent[] toolbarContent = new GUIContent[] {
                Localize.GUI(null, null, "Assets/kode80/Clouds/Editor/gui/button_camera.png"),
                Localize.GUI(null, null, "Assets/kode80/Clouds/Editor/gui/button_coverage.png"),
                Localize.GUI(null, null, "Assets/kode80/Clouds/Editor/gui/button_type.png")
            };
            _guiToolbar = toolLayout.Add(new GUIToolbar(toolbarContent, ChangeModeAction)) as GUIToolbar;
            toolLayout.Add(new GUISpace(true));
            toolLayout.Add(new GUIButton(Localize.GUI(null, "Clear the current coverage map",
                                                      "Assets/kode80/Clouds/Editor/gui/button_clearmap.png"),
                                         ClearCoverageMapAction));

            GUIFoldout helpFoldout = CreateHelpFoldout();

            GUIFoldout editorFoldout = new GUIFoldout(Localize.GUI("Editor Properties"));

            editorFoldout.Add(new GUIToggle(Localize.GUI("Continuous Update",
                                                         "If disabled, the editor will only render on changes"),
                                            ContinuousUpdateToggleAction));

            if (_cameraComponents.Length > 0)
            {
                _guiCameraFoldout = new GUIFoldout(Localize.GUI("Editor Camera"));
                foreach (MonoBehaviour component in _cameraComponents)
                {
                    GUIToggle toggle = new GUIToggle(new GUIContent(component.GetType().Name), CameraComponentToggled);
                    toggle.isToggled = component.enabled;
                    _guiCameraFoldout.Add(toggle);
                }
            }

            GUIFoldout brushFoldout = new GUIFoldout(Localize.GUI("Brush Properties"));

            _guiBrushBlendValues = brushFoldout.Add(new GUIToggle(Localize.GUI("Blend Values", "Blend values when painting or set to a specific value"),
                                                                  UpdateBrushPropertiesAction)) as GUIToggle;
            _guiBrushOpacity = brushFoldout.Add(new GUISlider(Localize.GUI("Opacity", "Brush opacity"),
                                                              0.2f, 0.0f, 1.0f,
                                                              UpdateBrushPropertiesAction)) as GUISlider;
            _guiBrushSize = brushFoldout.Add(new GUIIntSlider(Localize.GUI("Size", "Brush size"), 2, 2,
                                                              (int)EditorState.MaxCursorRadius,
                                                              UpdateBrushPropertiesAction)) as GUIIntSlider;
            _guiBrushTexture = brushFoldout.Add(new GUITextureField(Localize.GUI("Brush", "Brush texture"),
                                                                    UpdateBrushPropertiesAction)) as GUITextureField;

            GUIFoldout sunFoldout = new GUIFoldout(Localize.GUI("Sun Properties"));

            _guiSunRotation = sunFoldout.Add(new GUIVector3Field(Localize.GUI("Rotation", "Sun's rotation"),
                                                                 UpdateSunPropertiesAction)) as GUIVector3Field;
            _guiSunColor = sunFoldout.Add(new GUIColorField(Localize.GUI("Color", "Sun's color"),
                                                            UpdateSunPropertiesAction)) as GUIColorField;

            GUIFoldout cloudsFoldout = new GUIFoldout(Localize.GUI("Clouds Properties"));

            GUIHorizontal subLayout = new GUIHorizontal();

            subLayout.Add(new GUISpace());
            subLayout.Add(new GUIButton(Localize.GUI("Load Settings",
                                                     "Load key render settings from asset"),
                                        LoadRenderSettingsAction));
            subLayout.Add(new GUIButton(Localize.GUI("Save Settings",
                                                     "Save key render settings to asset"),
                                        SaveRenderSettingsAction));

            cloudsFoldout.Add(subLayout);
            cloudsFoldout.Add(new GUISpace());
            cloudsFoldout.Add(new GUIDefaultInspector(_clouds));

            GUIScrollView scrollView = new GUIScrollView();

            scrollView.Add(helpFoldout);
            scrollView.Add(editorFoldout);
            if (_cameraComponents.Length > 0)
            {
                scrollView.Add(_guiCameraFoldout);
            }
            scrollView.Add(brushFoldout);
            scrollView.Add(sunFoldout);
            scrollView.Add(cloudsFoldout);

            _guiPropertiesPanel = new GUIVertical(GUILayout.MaxWidth(320.0f));
            _guiPropertiesPanel.Add(scrollView);

            _guiScenePlaceholder = new GUIVertical(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            _guiScenePlaceholder.shouldStoreLastRect = true;

            GUIHorizontal lowerLayout = new GUIHorizontal();

            lowerLayout.Add(_guiPropertiesPanel);
            lowerLayout.Add(_guiScenePlaceholder);

            _gui.Add(toolLayout);
            _gui.Add(lowerLayout);

            // Update properties
            _guiBrushBlendValues.isToggled = _editorState.cursorBlendValues;
            _guiBrushOpacity.value         = _editorState.cursorOpacity;
            _guiBrushSize.value            = (int)_editorState.cursorRadius * 2;
            _guiBrushTexture.texture       = _editorState.brushTexture;
            _guiSunColor.color             = _clouds.sunLight.color;
            _guiSunRotation.vector         = _clouds.sunLight.transform.eulerAngles;
        }
        void OnEnable()
        {
            CreateExportFolderIfNeeded();

            _lastFrameTime = Time.realtimeSinceStartup;

            _gui = new GUIHorizontal();

            GUIVertical sideContainer = _gui.Add(new GUIVertical(GUILayout.MaxWidth(290.0f))) as GUIVertical;

            _guiSide = sideContainer.Add(new GUIScrollView()) as GUIScrollView;

            GUIObjectField <GameObject> guiGameObject = _guiSide.Add(new GUIObjectField <GameObject>(new GUIContent("GameObject", "GameObject to render as sprite sheet"),
                                                                                                     true, GameObjectChanged)) as GUIObjectField <GameObject>;

            _guiFrameCount = _guiSide.Add(new GUIIntSlider(new GUIContent("Frame Count", "Number of frames in the sprite sheet"),
                                                           12, 1, 64, FrameCountChanged)) as GUIIntSlider;
            _guiFrameWidth = _guiSide.Add(new GUIIntSlider(new GUIContent("Frame Width", "Width of each frame in the sprite sheet"),
                                                           100, 32, 512, ResizeFrame)) as GUIIntSlider;
            _guiFrameHeight = _guiSide.Add(new GUIIntSlider(new GUIContent("Frame Height", "Height of each frame in the sprite sheet"),
                                                            100, 32, 512, ResizeFrame)) as GUIIntSlider;
            _guiFOV = _guiSide.Add(new GUISlider(new GUIContent("FOV"), 20, 1, 179, OffsetChanged)) as GUISlider;

            _guiSide.Add(new GUISpace());
            _guiCurrentFrame = _guiSide.Add(new GUIIntSlider(new GUIContent("Current Frame"),
                                                             0, 0, _guiFrameCount.value - 1, RenderPreviewAction)) as GUIIntSlider;
            _guiDuration = _guiSide.Add(new GUISlider(new GUIContent("Duration"),
                                                      1, 0, 100, RenderPreviewAction)) as GUISlider;
            _guiPlay = _guiSide.Add(new GUIToggle(new GUIContent("Play"))) as GUIToggle;

            _guiSide.Add(new GUISpace());
            GUIFoldout offsetFoldout = _guiSide.Add(new GUIFoldout(new GUIContent("Position/Scale"))) as GUIFoldout;

            _guiPositionOffset = offsetFoldout.Add(new GUIVector3Field(new GUIContent("Position Offset"), OffsetChanged)) as GUIVector3Field;
            _guiScaleOffset    = offsetFoldout.Add(new GUISlider(new GUIContent("Scale Offset"), 0.0f, -10.0f, 10.0f, OffsetChanged)) as GUISlider;

            _guiAnimationClips = _guiSide.Add(new GUISpriteSheetClips(RenderPreviewAction)) as GUISpriteSheetClips;
            _guiMaterials      = _guiSide.Add(new GUISpriteSheetMaterials(RenderPreviewAction)) as GUISpriteSheetMaterials;

            GUIFoldout rotationFoldout = _guiSide.Add(new GUIFoldout(new GUIContent("Rotation"))) as GUIFoldout;

            _guiStartRotation = rotationFoldout.Add(new GUIVector3Field(new GUIContent("Start Rotation"), RenderPreviewAction)) as GUIVector3Field;
            _guiEndRotation   = rotationFoldout.Add(new GUIVector3Field(new GUIContent("End Rotation"), RenderPreviewAction)) as GUIVector3Field;

            GUIFoldout loopFoldout = _guiSide.Add(new GUIFoldout(new GUIContent("Rotation/Material Looping"))) as GUIFoldout;

            _guiLoopCount = loopFoldout.Add(new GUIIntSlider(new GUIContent("Loop Count"), 1, 1, 10, RenderPreviewAction)) as GUIIntSlider;
            _guiPingPong  = loopFoldout.Add(new GUIToggle(new GUIContent("Pingpong"), RenderPreviewAction)) as GUIToggle;

            GUIFoldout    outlineFoldout = _guiSide.Add(new GUIFoldout(new GUIContent("Outline Effect"))) as GUIFoldout;
            GUIColorField outlineColor   = outlineFoldout.Add(new GUIColorField(new GUIContent("Color"),
                                                                                OutlineColorChanged)) as GUIColorField;
            GUISlider outlineThreshold = outlineFoldout.Add(new GUISlider(new GUIContent("Threshold"),
                                                                          0.05f, 0.0f, 0.05f, OutlineThresholdChanged)) as GUISlider;

            _guiSide.Add(new GUISpace());
            _guiSpriteSheetName = _guiSide.Add(new GUITextField(new GUIContent("Sprite Sheet Name"))) as GUITextField;
            _guiExport          = _guiSide.Add(new GUIButton(new GUIContent("Export Sprite Sheet"), ExportSpriteSheet)) as GUIButton;

            _guiPreview = _gui.Add(new GUIVertical(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) as GUIVertical;
            _guiPreview.shouldStoreLastRect = true;

            InitPreviewRenderTexture();
            InitPreviewCamera();
            InitRootGameObject();
            guiGameObject.value = _modelGameObject;
            GameObjectChanged(guiGameObject);
            RenderPreview(0);

            _guiStartRotation.vector = Vector3.zero;
            _guiEndRotation.vector   = Vector3.zero;
            outlineColor.color       = _previewOutline.outlineColor;
            outlineThreshold.value   = _previewOutline.depthThreshold;
        }