Example #1
0
        /// <summary>
        /// Initializes a mainwindow GUI with logic.
        /// </summary>
        public MainWindow()
        {
            //Projectstate
            this.projectstate = new ProjectState();
            this.projectstate.PropertyChanged += projectstate_PropertyChanged;

            //Framescontainer
            this.framesContainer = new FramesContainer();
            this.framesContainer.PropertyChanged += framesContainer_PropertyChanged;
            this.timeLinePanel = new SliderPanel(framesContainer);

            InitPathCreation();

            InitializeComponent();

            InitOpenGL();
            CreateExporter();

            Interpolator interpolator = new PyramidOpticalFlowInterpolator(renderState);

            interpolationControl = new InterpolationControl(interpolator, framesContainer);
            interpolationControl.NextFrameContainsCurves += interpolationControl_NextFrameContainsCurves;

            InactivateUIElementsOnEmptyProject();
        }
        void Update()
        {
            if (_isGamePlaying && !EditorApplication.isPlaying)
            {
                _timeLineVar      = null;
                _scenesLineVar    = null;
                _soundLineVar     = null;
                _timeTextFieldVar = null;

                LoadData(_baseData);
                _isGamePlaying = false;
            }
            if (!_isGamePlaying && EditorApplication.isPlaying)
            {
                if (_baseData != null)
                {
                    CutsceneEngine[] engines = FindObjectsOfType <CutsceneEngine>();
                    foreach (CutsceneEngine engine in engines)
                    {
                        if (engine.Cutscene.GetInstanceID() == _baseData.GetInstanceID())
                        {
                            _timeLine.AssignExternalTimeFlowEngine(engine.TimeEngine);
                            break;
                        }
                    }
                    _isGamePlaying = true;
                }
            }


            float currentTime = Time.realtimeSinceStartup;
            float deltaTime   = currentTime - _lastTime;

            if (!_timeLine.TimeLineEngineIsExternal)
            {
                _timeLine.TimeLineEngine.HandleTime(deltaTime);
            }
            _lastTime = currentTime;

            if (_mousePressedOnHorizontal)
            {
                _timelinePanelHeightP = 1 - _mousePosNormalized.y;
                if (_timelinePanelHeightP < _timelinePanelHeightPMin)
                {
                    _timelinePanelHeightP = _timelinePanelHeightPMin;
                }
                if (_timelinePanelHeightP > _timelinePanelHeightPMax)
                {
                    _timelinePanelHeightP = _timelinePanelHeightPMax;
                }
            }
            if (_mousePressedOnVertical)
            {
                _scenesPanelWidthP = 1 - _mousePosNormalized.x;
                if (position.width * _scenesPanelWidthP < 83)
                {
                    _scenesPanelWidthP = 83 / position.width;
                }
            }
            bool allowDrag = (!_mousePressedOnHorizontal && !_mousePressedOnVertical) && !_mouseWasReleased;

            _timeLine.Update(allowDrag);
            _scenesLine.Update(allowDrag);
            _soundLine.Update(allowDrag);
            if (_mouseWasReleased)
            {
                _mouseWasReleased = false;
            }
        }