コード例 #1
0
        private void drawClip(ref MovieCurveClip clip, MovieTrack track, int trackIdx, int clipIdx)
        {
            Rect rect = new Rect((clip.frame * pixelsPerFrame) + ControlBase.FixedMargin,
                                 0,
                                 (clip.length * pixelsPerFrame),
                                 this.ControlHeight * 2);

            int pixelDiffToFramePos = (int)((Input.mousePosition.x - this.ScreenPos.x + this.scrollPosition.x - PANEL_WIDTH) / pixelsPerFrame);

            // GUI.Box(new Rect(pixelDiffToFramePos * pixelsPerFrame, 20, 40, 40), "");
            bool draggingBefore = clip.isDragging;

            clip.Draw(rect, this.ScreenPos);

            if (clip.wasPressed)
            {
                this.selectedTrackIndex = trackIdx;
                this.selectedClipIndex  = clipIdx;
            }

            if (clip.isDragging && !this.updated)
            {
                switch (this.dragMode)
                {
                case DragMode.Drag:
                    int newFrame = pixelDiffToFramePos - (clip.length / 2);
                    if (track.CanInsertClip(newFrame, clip.length, clip))
                    {
                        clip.frame = newFrame;
                    }
                    else if (newFrame <= 0)
                    {
                        clip.frame = 0;
                    }
                    break;

                case DragMode.RightResize:
                    int newEnd = pixelDiffToFramePos + (clip.length / 10);
                    if (track.CanInsertClip(clip.frame, newEnd - clip.length))
                    {
                        clip.end = newEnd;
                    }
                    break;

                default:
                    break;
                }

                this.updated = true;
            }
            else if (clip.wasClicked)
            {
                this.updated = true;
            }
            else if (draggingBefore == true && clip.isDragging == false)
            {
                track.ResolveCollision(clipIdx);
            }
        }
コード例 #2
0
        internal static XElement SerializeCurveTrackClips(MovieTrack track)
        {
            XElement elem = new XElement("Clips",
                                         from clip in track.clips
                                         select SerializeCurveClip(clip));

            return(elem);
        }
コード例 #3
0
        internal static XElement SerializeTrack(MovieTrack track)
        {
            XElement elem = new XElement("ERROR");

            if (track is MovieCameraTargetTrack)
            {
                elem = SerializeCameraTargetTrack((MovieCameraTargetTrack)track);
            }
            else if (track is MovieMaidAnimationTrack)
            {
                elem = SerializeMaidAnimationTrack((MovieMaidAnimationTrack)track);
            }
            else if (track is MovieMaidFaceTrack)
            {
                elem = SerializeMaidFaceTrack((MovieMaidFaceTrack)track);
            }
            else if (track is MoviePropertyTrack)
            {
                elem = SerializePropertyTrack((MoviePropertyTrack)track);
            }

            return(elem);
        }
コード例 #4
0
        internal static MovieTrack DeserializeTrack(XElement elem)
        {
            MovieTrack track = null;
            string     name  = elem.Name.ToString();

            if (name == "MovieCameraTargetTrack")
            {
                track = DeserializeCameraTargetTrack(elem);
            }
            else if (name == "MovieMaidAnimationTrack")
            {
                track = DeserializeMaidAnimationTrack(elem);
            }
            else if (name == "MovieMaidFaceTrack")
            {
                track = DeserializeMaidFaceTrack(elem);
            }
            else if (name == "MoviePropertyTrack")
            {
                track = DeserializePropertyTrack(elem);
            }

            return(track);
        }
コード例 #5
0
        override public void ShowPane()
        {
            try
            {
                GUI.enabled = this.GuiEnabled;

                if (!this.maidLoader.IsInitted)
                {
                    this.maidLoader.Init();
                }

                float seek       = this.seekerPos + PANEL_WIDTH - this.scrollPosition.x;
                Rect  seekerRect = new Rect(ControlBase.FixedMargin + seek, 0, 20, 40);

                Rect labelRect = new Rect(seekerRect.x + seekerRect.width + 5, seekerRect.y, 100, 40);
                GUI.Label(labelRect, Translation.GetText("Timeline", "frame") + " " + this.currentFrame);

                if (GUI.RepeatButton(seekerRect, "") || (draggingSeeker && Input.GetMouseButton(0)))
                {
                    draggingSeeker = true;
                    this.seekerPos = Input.mousePosition.x - this.ScreenPos.x + this.scrollPosition.x - 10 - PANEL_WIDTH;
                    this.updated   = true;
                }
                else
                {
                    draggingSeeker = false;
                }

                Rect trackPanelRect = new Rect(0, ControlBase.FixedMargin + 20, PANEL_WIDTH, 400 - ControlBase.FixedMargin * 4);

                GUILayout.BeginArea(trackPanelRect);
                for (int i = 0; i < this.take.tracks.Count; i++)
                {
                    MovieTrack track = this.take.tracks[i];
                    Rect       panel = new Rect(0,
                                                this.scrollPosition.y + (this.ControlHeight * 2 * i),
                                                PANEL_WIDTH - 150,
                                                this.ControlHeight * 2);

                    GUILayout.BeginArea(panel);

                    track.DrawPanel(this.currentFrame / framesPerSecond);

                    if (track.inserted)
                    {
                        this.updated = true;
                    }

                    GUILayout.EndArea();

                    GUIStyle style = new GUIStyle("label");
                    style.alignment = TextAnchor.MiddleLeft;
                    panel.x         = PANEL_WIDTH - 150 + ControlBase.FixedMargin;
                    panel.width     = 150 - ControlBase.FixedMargin * 2;
                    GUI.Label(panel, this.take.tracks[i].GetName(), style);
                }
                GUILayout.EndArea();

                Rect rectScroll     = new Rect(PANEL_WIDTH, ControlBase.FixedMargin + 20, this.rectGui.width - ControlBase.FixedMargin - PANEL_WIDTH, 400 - ControlBase.FixedMargin * 4);
                Rect rectScrollView = new Rect(0, 0, guiScrollWidth, guiScrollHeight);

                this.scrollPosition = GUI.BeginScrollView(rectScroll, this.scrollPosition, rectScrollView);


                for (int i = this.take.tracks.Count - 1; i >= 0; i--)
                {
                    if (this.take.tracks[i].wantsDelete)
                    {
                        // reset to the value at the beginning of the track, instead of in the middle
                        this.take.tracks[i].PreviewTime(0f);
                        this.take.tracks.RemoveAt(i);
                    }
                }
                for (int i = 0; i < this.take.tracks.Count; i++)
                {
                    this.drawTrack(i);
                }

                guiScrollHeight = (this.take.tracks.Count) * this.ControlHeight * 2;
                GUI.EndScrollView();

                Rect lineRect = new Rect(ControlBase.FixedMargin + seek, 0, 1, 400);
                GUI.DrawTexture(lineRect, this.lineTexture);

                this.playButton.Left    = this.Left + ControlBase.FixedMargin;
                this.playButton.Top     = rectScroll.yMax + ControlBase.FixedMargin;
                this.playButton.Width   = 50;
                this.playButton.Height  = this.ControlHeight;
                this.playButton.Visible = true;
                this.playButton.OnGUI();

                this.stopButton.Left    = this.playButton.Left + this.playButton.Width;
                this.stopButton.Top     = this.playButton.Top;
                this.stopButton.Width   = this.playButton.Width;
                this.stopButton.Height  = this.ControlHeight;
                this.stopButton.Visible = true;
                this.stopButton.OnGUI();

                this.addButton.Left    = this.stopButton.Left + this.stopButton.Width;
                this.addButton.Top     = this.stopButton.Top;
                this.addButton.Width   = 100;
                this.addButton.Height  = this.ControlHeight;
                this.addButton.Visible = true;
                this.addButton.OnGUI();

                this.copyClipButton.Left    = this.addButton.Left + this.addButton.Width;
                this.copyClipButton.Top     = this.addButton.Top;
                this.copyClipButton.Width   = this.addButton.Width;
                this.copyClipButton.Height  = this.ControlHeight;
                this.copyClipButton.Visible = true;
                this.copyClipButton.OnGUI();

                this.deleteClipButton.Left    = this.copyClipButton.Left + this.copyClipButton.Width;
                this.deleteClipButton.Top     = this.copyClipButton.Top;
                this.deleteClipButton.Width   = this.copyClipButton.Width;
                this.deleteClipButton.Height  = this.ControlHeight;
                this.deleteClipButton.Visible = true;
                this.deleteClipButton.OnGUI();

                Rect toggleRect = this.deleteClipButton.WindowRect;
                toggleRect.x     += toggleRect.width + ControlBase.FixedMargin * 2;
                toggleRect.width *= 1.5f;
                int iTmp;
                if ((iTmp = GUI.Toolbar(toggleRect, (int)this.dragMode, DRAG_MODES)) >= 0)
                {
                    this.dragMode = (DragMode)iTmp;
                }
                //this.Height = GUIUtil.GetHeightForParent(this) + 5 * this.ControlHeight;

                toggleRect.x     += toggleRect.width + ControlBase.FixedMargin * 2;
                toggleRect.width *= 1.80f;
                if ((iTmp = GUI.Toolbar(toggleRect, (int)this.curvePane.mode, CURVE_PANE_MODES)) >= 0)
                {
                    this.curvePane.mode = (CurvePane.CurvePaneMode)iTmp;
                }

                // toggleRect.x += toggleRect.width + ControlBase.FixedMargin * 4;
                // string sTmp =
                // toggleRect.x += toggleRect.width + ControlBase.FixedMargin * 4;

                Rect curveRect = new Rect(0, toggleRect.yMax, 1000, 300);
                this.curvePane.SetFromRect(curveRect);
                this.curvePane.UpdateOffsets(curveRect, this.rectGui);

                GUI.BeginGroup(curveRect);
                if (this.ClipIsSelected())
                {
                    this.curvePane.Draw(curveRect, this.take.tracks[this.selectedTrackIndex].clips, this.selectedClipIndex, this.selectedTrackIndex);
                }
                else if (this.IsDataView())
                {
                    this.curvePane.DrawDataView(curveRect);
                }
                GUI.EndGroup();

                if (this.curvePane.needsUpdate)
                {
                    this.updated = true;
                }
                if (this.curvePane.wantsSave)
                {
                    Serialize.Save(this.curvePane.typedSaveName, this.take);
                    this.curvePane.LoadSavefileNames();
                    this.curvePane.wantsSave = false;
                }
                if (this.curvePane.wantsLoad)
                {
                    XDocument doc = Deserialize.LoadFileFromSave(this.curvePane.selectedSaveName);

                    List <string> guids = Deserialize.GetMaidGuids(doc);
                    this.maidLoader.SelectMaidsWithGuids(guids);
                    this.maidLoader.onMaidsLoaded = () => {
                        this.take = Deserialize.DeserializeTake(doc);
                        this.Stop(this, new EventArgs());
                        this.Update();
                    };

                    this.maidLoader.StartLoad();

                    this.curvePane.wantsLoad = false;
                }

                ControlBase.TryFocusGUI(this.rectGui);
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
        }