Beispiel #1
0
 public ScriptableSlicingView(SpriteEditorProWindow model) : base(model)
 {
     _topView     = new ScriptableSlicingTopView(model);
     _blobsView   = new ScriptableSlicingBlobsView(model);
     _editView    = new ScriptableSlicingEditView(model);
     _previewView = new ScriptableSlicingPreviewView(model);
 }
Beispiel #2
0
 public ChunksView(SpriteEditorProWindow model) : base(model)
 {
     _chunksPanelStyle        = _model.Skin.GetStyle(ChunksPanelStyleName);
     _chunkEditPanelStyle     = _model.Skin.GetStyle(ChunkEditPanelStyleName);
     _chunkButtonStyle        = _model.Skin.GetStyle(ChunkButtonStyleName);
     _chunkButtonPressedStyle = _model.Skin.GetStyle(ChunkButtonPressedStyleName);
 }
 public GroupsMainPanelView(SpriteEditorProWindow model) : base(model)
 {
     _panelStyle = model.Skin.GetStyle("GroupsMainPanel");
     _panelDragAcceptanceStyle = model.Skin.GetStyle("GroupsMainPanelDragAcceptence");
     _blobStyle         = model.Skin.GetStyle("BlobStyle");
     _selectedBlobStyle = model.Skin.GetStyle("SelectedBlobStyle");
 }
Beispiel #4
0
 public MainView(SpriteEditorProWindow model) : base(model)
 {
     _background        = new BackgroundView(model);
     _image             = new TextureView(model);
     _controlPanel      = new ControlPanelView(model);
     _previewSpriteView = new PreviewSpriteView(model);
     _foreground        = new ForegroundView(model);
 }
        public ControlPanelTabsView(SpriteEditorProWindow model) : base(model)
        {
            _radioButtonDefaultStyle         = model.Skin.GetStyle("RadioButtonDefault");
            _radioButtonDefaultSelectedStyle = model.Skin.GetStyle("RadioButtonSelectedDefault");

            ChunksView            = new ChunksView(model);
            GlobalSettingsView    = new GlobalSettingsView(model);
            ScriptableSlicingView = new ScriptableSlicingView(model);
            GroupsView            = new GroupsView(model);
            DraggableButtonsView  = new DraggableButtonView(model);
        }
 public BackgroundView(SpriteEditorProWindow model) : base(model)
 {
 }
Beispiel #7
0
 public ViewBase(SpriteEditorProWindow model)
 {
     _model = model;
 }
Beispiel #8
0
 public PreviewSpriteView(SpriteEditorProWindow model) : base(model)
 {
     _subWindow = new SpritePreviewWindow(model);
 }
Beispiel #9
0
 public GroupEditPanelView(SpriteEditorProWindow model) : base(model)
 {
     _panelStyle = model.Skin.GetStyle("GroupsEditPanel");
 }
 public LayoutViewBase(SpriteEditorProWindow model) : base(model)
 {
 }
 public ScriptableSlicingTopView(SpriteEditorProWindow model) : base(model)
 {
     _panelStyle   = model.Skin.GetStyle("GroupsTopPanel");
     _buttonsStyle = model.Skin.GetStyle("GroupsTopPanelButton");
 }
Beispiel #12
0
        public static void DrawPreview(Rect windowRect, SpriteEditorProWindow model)
        {
            var area       = model.PreviewedArea.Value;
            var scaledPart = area.position - model.TextureRect.position;

            area = new Rect(model.TextureRect.position + Vector2.Scale(model.TextureScale, scaledPart), Vector2.Scale(model.TextureScale, area.size));

            var texture   = model.Texture;
            var localArea = area;

            localArea.x -= model.TextureRect.x;
            localArea.y -= model.TextureRect.y;
            var ratio          = area.width / area.height;
            var textureRect    = new Rect(windowRect.position, new Vector2(windowRect.width, windowRect.width / ratio));
            var rect           = GUILayoutUtility.GetRect(textureRect.width, textureRect.height);
            var textureSubRect = new Rect(localArea.x / model.TextureRect.width, localArea.y / model.TextureRect.height, area.width / model.TextureRect.width, area.height / model.TextureRect.height);

            textureSubRect.y = 1f - textureSubRect.y - textureSubRect.height;
            var currentScale = rect.width / (textureSubRect.width * model.Texture.width);

            if (model.PinPivot)
            {
                currentScale = model.PinnedScale;
            }

            var offsetRect = rect;

            if (model.PinPivot)
            {
                var currentPivot      = model.PreviewedPivotPoint.Value - model.PreviewedArea.Value.position;
                var pinnedPivotScaled = rect.position + model.PinnedPivotPoint * rect.width / (textureSubRect.width * model.Texture.width);
                var diff       = model.PinnedPivotPoint - currentPivot;
                var scaledDiff = diff * currentScale;
                offsetRect.position += scaledDiff;
                //var currentPivot = model.PreviewedPivotPoint.Value - model.PreviewedArea.Value.position;
                //var pivotDiff = model.PinnedPivotPoint - currentPivot;
                //var scaledPinnedPivotDiff = pivotDiff * currentScale;
                //Debug.LogWarning($"currentPivot = {currentPivot}, pivotDiff = {pivotDiff}, scaledPinnedPivot = {scaledPinnedPivotDiff}");
                //offsetRect.position -= scaledPinnedPivotDiff;
                //offsetRect.size = Vector2.Scale(textureSubRect.size, new Vector2(model.Texture.width, model.Texture.height)) * currentScale;
            }
            GUI.DrawTextureWithTexCoords(rect, _previewSpriteStyle.normal.background, new Rect(0, 0, rect.width / _previewSpriteStyle.normal.background.width, rect.height / _previewSpriteStyle.normal.background.height));
            GUI.DrawTextureWithTexCoords(offsetRect, texture, textureSubRect);

            var pivot = model.PreviewedPivotPoint.Value - model.PreviewedArea.Value.position;

            pivot = offsetRect.position + pivot * currentScale;
            //Debug.Log($"pivot = {model.PreviewedPivotPoint.Value - model.PreviewedArea.Value.position}. pivot position = {pivot}. rect = {rect}. textureSubRect.width = {textureSubRect.width}. model.Texture.width = {model.Texture.width}");
            var worldPos    = new Vector3(pivot.x, pivot.y, 0);
            var newWorldPos = DraggableDisc.Draw(worldPos, Vector3.back, 4f, Color.gray * 0.5f);

            Handles.BeginGUI();
            Handles.color = new Color(0, 0, 0, 0.4f);
            Handles.DrawSolidDisc(worldPos, Vector3.back, 5);
            Handles.color = new Color(1, 1, 1, 0.4f);
            Handles.DrawSolidDisc(worldPos, Vector3.back, 2);
            Handles.color = new Color(1, 1, 1, 1);
            Handles.DrawSolidDisc(worldPos, Vector3.back, 1);
            Handles.EndGUI();

            if (model.ControlPanelTab == ControlPanelTabs.ManualSlicing)
            {
                var newIterationMode = (SpriteIterationMode)EditorGUILayout.EnumPopup(new GUIContent($"Iteration Mode:", $"You can iterate through sprites with right and left arrow buttons. This option allows you to choose what do you want to iterate through."), model.IterationMode);
                if (newIterationMode != model.IterationMode)
                {
                    Undo.RecordObject(model, $"Iteration mode changed");
                    model.IterationMode = newIterationMode;
                    EditorUtility.SetDirty(model);
                }
            }

            var newPinPivot = EditorGUILayout.Toggle(new GUIContent($"Pin pivot point"), model.PinPivot);

            if (model.PinPivot != newPinPivot)
            {
                Undo.RecordObject(model, $"Pin pivot point setting changed");
                model.PinPivot = newPinPivot;
                if (newPinPivot)
                {
                    model.PinnedPivotPoint = model.PreviewedPivotPoint.Value - model.PreviewedArea.Value.position;
                    model.PinnedScale      = currentScale;
                    //Debug.LogError($"newPinPivot = {newPinPivot}. model.PinnedPivotPoint = {model.PinnedPivotPoint}. model.PinnedScale = {model.PinnedScale}");
                }
                EditorUtility.SetDirty(model);
            }
        }
Beispiel #13
0
        public ControlPanelWindow(SpriteEditorProWindow model) : base(model)
        {
            _topPanelView = new TopPanelView(model);

            TabsView = new ControlPanelTabsView(model);
        }
 public GroupsView(SpriteEditorProWindow model) : base(model)
 {
     _groupsTopPanel  = new GroupsTopPanelView(model);
     _groupsMainPanel = new GroupsMainPanelView(model);
     _groupEditPanel  = new GroupEditPanelView(model);
 }
Beispiel #15
0
 public GlobalSettingsView(SpriteEditorProWindow model) : base(model)
 {
 }
 public DraggableButtonView(SpriteEditorProWindow model) : base(model)
 {
 }
Beispiel #17
0
 public ScriptableSlicingPreviewBottomView(SpriteEditorProWindow model) : base(model)
 {
     _previewTextStyle = model.Skin.GetStyle("ScriptableSlicePreviewText");
     _panelStyle       = model.Skin.GetStyle("GroupsEditPanel");
 }
Beispiel #18
0
 public AreasView(SpriteEditorProWindow model) : base(model)
 {
 }
 public ScriptableSlicingPreviewCenterView(SpriteEditorProWindow model) : base(model)
 {
     _panelStyle = model.Skin.GetStyle("GroupsMainPanel");
 }
 public TextureView(SpriteEditorProWindow model) : base(model)
 {
     _areas = new AreasView(model);
 }
Beispiel #21
0
 public ControlPanelView(SpriteEditorProWindow model) : base(model)
 {
     _backgroundStyle = model.Skin.GetStyle("ControlPanel");
     _subWindow       = new ControlPanelWindow(model);
 }
 public ScriptableSlicingEditView(SpriteEditorProWindow model) : base(model)
 {
     _panelStyle = model.Skin.GetStyle("GroupsEditPanel");
 }
 public TopPanelView(SpriteEditorProWindow model) : base(model)
 {
     _panelStyle = _model.Skin.GetStyle("ControlTopPanel");
 }
Beispiel #24
0
 public SpritePreviewWindow(SpriteEditorProWindow model) : base(model)
 {
     _previewSpriteStyle = _model.Skin.GetStyle($"PreviewSprite");
 }