Example #1
0
 public override void Init(IEntity entity)
 {
     base.Init(entity);
     entity.Bind <IImageComponent>(c => { _obj = c; c.CustomRenderer = _labelRenderer; }, _ => _obj = null);
     entity.Bind <IScaleComponent>(c => { _scale = c; }, _ => { _scale = null; });
     _events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
 }
Example #2
0
 public static void Play(IImageComponent component, bool loop)
 {
     if (MovieSystem.instance != null)
     {
         MovieSystem.instance.Play_INTERNAL(component, loop, pause: false);
     }
 }
Example #3
0
 private void Pause_INTERNAL(IImageComponent component)
 {
     if (component.IsMovie() == true && component.IsPlaying() == true)
     {
         this.movieModule.Pause(component);
     }
 }
 public AGSCharacter(string id, Resolver resolver, IOutfit outfit) : base(id, resolver)
 {
     _hasRoom               = AddComponent <IHasRoom>();
     _animationContainer    = AddComponent <IAnimationContainer>();
     _inObjectTree          = AddComponent <IInObjectTree>();
     _collider              = AddComponent <ICollider>();
     _visibleComponent      = AddComponent <IVisibleComponent>();
     _enabledComponent      = AddComponent <IEnabledComponent>();
     _customProperties      = AddComponent <ICustomPropertiesComponent>();
     _drawableInfo          = AddComponent <IDrawableInfo>();
     _hotspotComponent      = AddComponent <IHotspotComponent>();
     _shaderComponent       = AddComponent <IShaderComponent>();
     _translateComponent    = AddComponent <ITranslateComponent>();
     _imageComponent        = AddComponent <IImageComponent>();
     _scaleComponent        = AddComponent <IScaleComponent>();
     _rotateComponent       = AddComponent <IRotateComponent>();
     _pixelPerfectComponent = AddComponent <IPixelPerfectComponent>();
     _faceDirectionBehavior = AddComponent <IFaceDirectionBehavior>();
     _hasOutfit             = AddComponent <IHasOutfit>();
     _hasInventory          = AddComponent <IHasInventory>();
     _followBehavior        = AddComponent <IFollowBehavior>();
     _modelMatrixComponent  = AddComponent <IModelMatrixComponent>();
     beforeInitComponents(resolver, outfit);
     InitComponents();
     afterInitComponents(resolver, outfit);
 }
Example #5
0
 public static void Stop(IImageComponent component, int instanceId = 0)
 {
     if (MovieSystem.instance != null)
     {
         MovieSystem.instance.Stop_INTERNAL(component, instanceId);
     }
 }
Example #6
0
 public static void Play(IImageComponent component, bool loop, System.Action onComplete = null)
 {
     if (MovieSystem.instance != null)
     {
         MovieSystem.instance.Play_INTERNAL(component, loop, pause: false, onComplete: onComplete);
     }
 }
		protected override IEnumerator LoadTexture_YIELD(ResourceAsyncOperation asyncOperation, IImageComponent component, ResourceBase resource) {

			var filePath = resource.GetStreamPath();

			var task = new WWW(filePath);
			while (task.isDone == false) {

				asyncOperation.SetValues(isDone: false, progress: task.progress, asset: null);
				yield return false;

			}

			var movie = task.movie;

			asyncOperation.SetValues(isDone: false, progress: 1f, asset: movie);

			task.Dispose();
			task = null;
			System.GC.Collect();

			//Debug.LogWarning("GetTexture_YIELD: " + filePath + " :: " + movie.isReadyToPlay);

			while (movie.isReadyToPlay == false) {

				yield return false;

			}

			asyncOperation.SetValues(isDone: true, progress: 1f, asset: movie);

		}
Example #8
0
 public static void Pause(IImageComponent component)
 {
     if (MovieSystem.instance != null)
     {
         MovieSystem.instance.Pause_INTERNAL(component);
     }
 }
Example #9
0
 public override void Init()
 {
     base.Init();
     Entity.Bind <IBoundingBoxComponent>(c => _boundingBox = c, _ => _boundingBox = null);
     Entity.Bind <IImageComponent>(c => _image             = c, _ => _image = null);
     _pipeline.Subscribe(Entity.ID, this, -200);
 }
Example #10
0
 public static void Unload(IImageComponent resourceController, ResourceBase resource)
 {
     if (MovieSystem.instance != null)
     {
         MovieSystem.instance.movieModule.Unload(resourceController, resource);
     }
 }
        private MovieItem GetMovieItem(IImageComponent component, ResourceBase resource)
        {
            var item = this.current.FirstOrDefault(x => x.id == resource.GetId());

            //Debug.Log("GetMovieItem: " + (item != null) + " :: " + resource.GetId() + " :: " + component, component as MonoBehaviour);
            if (item != null)
            {
                var c = component as IResourceReference;
                if (item.components.Contains(c) == false)
                {
                    item.components.Add(c);
                }
            }
            else
            {
                //Debug.Log("new MOVIE ITEM: " + resource.GetId());
                item = new MovieItem()
                {
                    resource = WindowSystemResources.GetItem(resource),
                    state    = MovieItem.State.Stopped,
                };

                this.current.Add(item);
            }

            return(item);
        }
 public void SetUpdateTexture(IImageComponent component, Texture material)
 {
     if (this.onUpdateTexture != null)
     {
         this.onUpdateTexture.Invoke(component, material);
     }
 }
        public void Pause(IImageComponent component)
        {
            //var image = component.GetRawImageSource();
            //if (image == null) return;

            var resource = component.GetResource();

            if (resource.loaded == false)
            {
                Debug.LogWarning("Resource was not loaded yet. Pause interrupted.", component as MonoBehaviour);
                return;
            }

            var movie = resource.loadedObject as Texture;

            var item = this.current.FirstOrDefault(x => x.id == resource.GetId());

            if (item != null)
            {
                //item.components.Remove(component as WindowComponent);

                //if (item.components.Count == 0) {

                if (item.state != MovieItem.State.Paused)
                {
                    item.state = MovieItem.State.Paused;
                    this.OnPause(resource, movie);
                }

                //}
            }
        }
 private void Stop_INTERNAL(IImageComponent component, int instanceId)
 {
     if (component.IsMovie() == true && component.IsPlaying() == true)
     {
         this.movieModule.Stop(component, instanceId);
     }
 }
Example #15
0
 public AGSButton(string id, Resolver resolver) : base(id, resolver)
 {
     _uIEvents              = AddComponent <IUIEvents>();
     _skinComponent         = AddComponent <ISkinComponent>();
     _hasRoom               = AddComponent <IHasRoom>();
     _animationContainer    = AddComponent <IAnimationContainer>();
     _inObjectTree          = AddComponent <IInObjectTree>();
     _collider              = AddComponent <ICollider>();
     _visibleComponent      = AddComponent <IVisibleComponent>();
     _enabledComponent      = AddComponent <IEnabledComponent>();
     _customProperties      = AddComponent <ICustomPropertiesComponent>();
     _drawableInfo          = AddComponent <IDrawableInfo>();
     _hotspotComponent      = AddComponent <IHotspotComponent>();
     _shaderComponent       = AddComponent <IShaderComponent>();
     _translateComponent    = AddComponent <ITranslateComponent>();
     _imageComponent        = AddComponent <IImageComponent>();
     _scaleComponent        = AddComponent <IScaleComponent>();
     _rotateComponent       = AddComponent <IRotateComponent>();
     _pixelPerfectComponent = AddComponent <IPixelPerfectComponent>();
     _textComponent         = AddComponent <ITextComponent>();
     _buttonComponent       = AddComponent <IButtonComponent>();
     _modelMatrixComponent  = AddComponent <IModelMatrixComponent>();
     beforeInitComponents(resolver);
     InitComponents();
     afterInitComponents(resolver);
 }
        public AGSCheckBox(string id, Resolver resolver) : base(id, resolver)
        {            
            _uIEvents = AddComponent<IUIEvents>();            
            _skinComponent = AddComponent<ISkinComponent>();            
            _hasRoom = AddComponent<IHasRoom>();            
            _animationContainer = AddComponent<IAnimationContainer>();            
            _inObjectTree = AddComponent<IInObjectTree>();            
            _collider = AddComponent<ICollider>();            
            _visibleComponent = AddComponent<IVisibleComponent>();            
            _enabledComponent = AddComponent<IEnabledComponent>();            
            _customProperties = AddComponent<ICustomPropertiesComponent>();            
            _drawableInfo = AddComponent<IDrawableInfo>();            
            _hotspotComponent = AddComponent<IHotspotComponent>();            
            _shaderComponent = AddComponent<IShaderComponent>();            
            _translateComponent = AddComponent<ITranslateComponent>();            
            _imageComponent = AddComponent<IImageComponent>();            
            _scaleComponent = AddComponent<IScaleComponent>();            
            _rotateComponent = AddComponent<IRotateComponent>();            
            _pixelPerfectComponent = AddComponent<IPixelPerfectComponent>();            
            _textComponent = AddComponent<ITextComponent>();            
            _checkboxComponent = AddComponent<ICheckboxComponent>();
			beforeInitComponents(resolver);            
			InitComponents();
            afterInitComponents(resolver);            
        }
        public AGSCharacter(string id, Resolver resolver, IOutfit outfit) : base(id, resolver)
        {            
            _hasRoom = AddComponent<IHasRoom>();            
            _animationContainer = AddComponent<IAnimationContainer>();            
            _inObjectTree = AddComponent<IInObjectTree>();            
            _collider = AddComponent<ICollider>();            
            _visibleComponent = AddComponent<IVisibleComponent>();            
            _enabledComponent = AddComponent<IEnabledComponent>();            
            _customProperties = AddComponent<ICustomPropertiesComponent>();            
            _drawableInfo = AddComponent<IDrawableInfo>();            
            _hotspotComponent = AddComponent<IHotspotComponent>();            
            _shaderComponent = AddComponent<IShaderComponent>();            
            _transformComponent = AddComponent<ITranslateComponent>();            
            _imageComponent = AddComponent<IImageComponent>();            
            _scaleComponent = AddComponent<IScaleComponent>();            
            _rotateComponent = AddComponent<IRotateComponent>();            
            _pixelPerfectComponent = AddComponent<IPixelPerfectComponent>();            
            _faceDirectionBehavior = AddComponent<IFaceDirectionBehavior>();            
            _hasOutfit = AddComponent<IHasOutfit>();            
            _hasInventory = AddComponent<IHasInventory>();            
            _followBehavior = AddComponent<IFollowBehavior>();
			beforeInitComponents(resolver, outfit);            
			InitComponents();
            afterInitComponents(resolver, outfit);            
        }
 public void Setup(IImageComponent component)
 {
     if (this.IsChanged(ParameterFlag.BP1) == true)
     {
         component.SetPreserveAspectState(this.preserveAspect);
     }
     if (this.IsChanged(ParameterFlag.BP2) == true)
     {
         component.SetImage(this.image);
     }
     if (this.IsChanged(ParameterFlag.BP3) == true)
     {
         component.SetImage(this.rawImage);
     }
     if (this.IsChanged(ParameterFlag.BP7) == true)
     {
         component.SetImageLocalizationKey(this.imageLocalizationKey);
     }
     if (this.IsChanged(ParameterFlag.BP4) == true)
     {
         component.SetColor(this.imageColor);
     }
     if (this.IsChanged(ParameterFlag.BP5) == true)
     {
         component.SetPlayOnShow(this.playOnShow);
     }
     if (this.IsChanged(ParameterFlag.BP6) == true)
     {
         component.SetLoop(this.loop);
     }
 }
Example #19
0
        public override void Init(IEntity entity)
        {
            base.Init(entity);
            _textComponent  = entity.GetComponent <ITextComponent>();
            _imageComponent = entity.GetComponent <IImageComponent>();
            _uiEvents       = entity.GetComponent <IUIEvents>();
            _tree           = entity.GetComponent <IInObjectTree>();
            _room           = entity.GetComponent <IHasRoom>();
            var visible = entity.GetComponent <IVisibleComponent>();

            _game.Events.OnRepeatedlyExecute.Subscribe((_, __) =>
            {
                if (!visible.Visible)
                {
                    IsFocused = false;
                }
            });

            _caretFlashCounter = (int)CaretFlashDelay;
            _withCaret         = _game.Factory.UI.GetLabel(entity.ID + " Caret", "|", 1f, 1f, 0f, 0f, new AGSTextConfig(autoFit: AutoFit.LabelShouldFitText));
            _withCaret.Anchor  = new PointF(0f, 0f);

            _game.Events.OnBeforeRender.Subscribe(onBeforeRender);
            _uiEvents.MouseDown.Subscribe(onMouseDown);
            _uiEvents.LostFocus.Subscribe(onMouseDownOutside);
        }
Example #20
0
        public void Play(IImageComponent component, bool loop, bool pause, System.Action onComplete)
        {
            var resource = component.GetResource();

            if (resource.loaded == false)
            {
                if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true)
                {
                    UnityEngine.Debug.LogWarning("Resource was not loaded yet. Play interrupted.", component as MonoBehaviour);
                }
                return;
            }

            var item  = this.GetMovieItem(component, resource);
            var movie = resource.loadedObject as Texture;

            if (item.state != MovieItem.State.Playing)
            {
                item.state = MovieItem.State.Playing;
                this.OnPlay(resource, movie, loop, onComplete);
            }

            if (pause == true || MovieSystem.CanPlayByQuality(movie) == false)
            {
                this.StartCoroutine(this.PauseWithDelay_YIELD(component, this.delayToPause));
            }
        }
        public override void AfterInit()
        {
            _entity.Bind <IAnimationComponent>(
                c => { _animationComponent = c; _animationComponent.PropertyChanged += onAnimationChanged; onSomethingChanged(); },
                c => { _animationComponent = null; _animationComponent.PropertyChanged -= onAnimationChanged; onSomethingChanged(); });
            _entity.Bind <IHasRoomComponent>(
                c => { _room = c; refreshAreaScaling(); subscribeRoom(); onSomethingChanged(); },
                c => { unsubscribeRoom(c); _room = null; refreshAreaScaling(); onSomethingChanged(); });

            _entity.Bind <IScaleComponent>(
                c => { _scale = c; c.PropertyChanged += onScaleChanged; onSomethingChanged(); },
                c => { c.PropertyChanged -= onScaleChanged; _scale = null; onSomethingChanged(); });
            _entity.Bind <ITranslateComponent>(
                c => { _translate = c; c.PropertyChanged += onTranslateChanged; onSomethingChanged(); },
                c => { c.PropertyChanged -= onTranslateChanged; _translate = null; onSomethingChanged(); }
                );
            _entity.Bind <IJumpOffsetComponent>(
                c => { _jump = c; c.PropertyChanged += onJumpOffsetChanged; onSomethingChanged(); },
                c => { c.PropertyChanged -= onJumpOffsetChanged; _jump = null; onSomethingChanged(); }
                );
            _entity.Bind <IRotateComponent>(
                c => { _rotate = c; c.PropertyChanged += onRotateChanged; onSomethingChanged(); },
                c => { c.PropertyChanged -= onRotateChanged; _rotate = null; onSomethingChanged(); }
                );
            _entity.Bind <IImageComponent>(
                c => { _image = c; subscribeLabelRenderer(); c.PropertyChanged += onImageChanged; onSomethingChanged(); },
                c => { c.PropertyChanged -= onImageChanged; _image = null; onSomethingChanged(); }
                );

            _entity.Bind <IDrawableInfoComponent>(
                c =>
            {
                _drawable          = c;
                c.PropertyChanged += onDrawableChanged;
                onSomethingChanged();
            }, c =>
            {
                c.PropertyChanged -= onDrawableChanged;
                _drawable          = null;
                onSomethingChanged();
            });

            _entity.Bind <IInObjectTreeComponent>(
                c =>
            {
                _tree   = c;
                _parent = _tree.TreeNode.Parent;
                _tree.TreeNode.OnParentChanged.Subscribe(onParentChanged);
                _parent?.OnMatrixChanged.Subscribe(onSomethingChanged);
                onSomethingChanged();
            }, c =>
            {
                c.TreeNode.OnParentChanged.Unsubscribe(onParentChanged);
                c.TreeNode.Parent?.OnMatrixChanged.Unsubscribe(onSomethingChanged);
                _tree   = null;
                _parent = null;
                onSomethingChanged();
            });
        }
Example #22
0
        public override void Init(IEntity entity)
        {
            base.Init(entity);
            _entity = entity;
            entity.Bind <ITextComponent>(c =>
            {
                _textComponent     = c;
                c.PropertyChanged += onTextPropertyChanged;
            }, c =>
            {
                _textComponent     = null;
                c.PropertyChanged -= onTextPropertyChanged;
            });
            entity.Bind <IImageComponent>(c => _imageComponent = c, _ => _imageComponent = null);
            entity.Bind <IUIEvents>(c =>
            {
                _uiEvents = c;
                c.MouseDown.Subscribe(onMouseDown);
                c.LostFocus.Subscribe(onMouseDownOutside);
            }, c =>
            {
                _uiEvents = null;
                c.MouseDown.Unsubscribe(onMouseDown);
                c.LostFocus.Unsubscribe(onMouseDownOutside);
            });
            entity.Bind <IInObjectTreeComponent>(c => _tree        = c, _ => _tree = null);
            entity.Bind <IHasRoomComponent>(c => _room             = c, _ => _room = null);
            entity.Bind <IVisibleComponent>(c => _visibleComponent = c, _ => _visibleComponent = null);

            _game.Events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);

            _caretFlashCounter = (int)CaretFlashDelay;
            _withCaret         = _game.Factory.UI.GetLabel(entity.ID + " Caret", "|", 1f, 1f, 0f, 0f, config: new AGSTextConfig(autoFit: AutoFit.LabelShouldFitText));
            _withCaret.Pivot   = new PointF(0f, 0f);
            _withCaret.TextBackgroundVisible = false;

            entity.Bind <IAnimationComponent>(c =>
            {
                c.PropertyChanged  += onAnimationPropertyChanged;
                _animationComponent = c;
                updateBorder();
            }, c =>
            {
                c.PropertyChanged  -= onAnimationPropertyChanged;
                _animationComponent = null;
                updateBorder();
            });

            entity.Bind <IDrawableInfoComponent>(c =>
            {
                _drawableComponent = c;
                c.PropertyChanged += onDrawableChanged;
                onRenderLayerChanged();
            }, c =>
            {
                c.PropertyChanged -= onDrawableChanged;
                _drawableComponent = null;
            });
        }
		public ResourceAsyncOperation LoadTexture(IImageComponent component) {

			var request = new ResourceAsyncOperation();
			this.StartCoroutine(this.LoadTexture_YIELD(request, component, component.GetResource()));

			return request;

		}
Example #24
0
 public override void Init()
 {
     base.Init();
     Entity.Bind <IScaleComponent>(c => _scale = c, c => _scale = null);
     Entity.Bind <IImageComponent>(
         c => { _image = c; c.PropertyChanged += onSpriteRenderPropertyChanged; },
         c => { c.PropertyChanged -= onSpriteRenderPropertyChanged; _image = null; });
 }
		public void Setup(IImageComponent component) {
			
			if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P1) == true) component.SetPreserveAspectState(this.preserveAspect);
			if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P2) == true) component.SetImage(this.image);
			if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P3) == true) component.SetImage(this.rawImage);
			if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P4) == true) component.SetColor(this.imageColor);

		}
Example #26
0
        public ResourceAsyncOperation LoadTexture(IImageComponent component)
        {
            var request = new ResourceAsyncOperation();

            this.StartCoroutine(this.LoadTexture_YIELD(request, component, component.GetResource()));

            return(request);
        }
Example #27
0
        public override void Init(IEntity entity)
        {
            base.Init(entity);
            IImageComponent image      = entity.GetComponent <IImageComponent>();
            TypedParameter  imageParam = new TypedParameter(typeof(IHasImage), image);

            _scale = _resolver.Resolve <IScale>(imageParam);
        }
Example #28
0
 private void Stop_INTERNAL(IImageComponent component, int instanceId)
 {
     //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.LogWarning("Stop_INTERNAL: " + instanceId + " :: " + component, component as MonoBehaviour);
     if (component.IsMovie() == true && component.IsPlaying() == true)
     {
         this.movieModule.Stop(component, instanceId);
     }
 }
Example #29
0
        public static bool IsPlaying(IImageComponent component)
        {
            if (MovieSystem.instance == null)
            {
                return(false);
            }

            return(MovieSystem.instance.IsPlaying_INTERNAL(component));
        }
Example #30
0
 public override void Init()
 {
     base.Init();
     Entity.Bind <IDrawableInfoComponent>(c => _drawableInfo = c, _ => _drawableInfo = null);
     Entity.Bind <IImageComponent>(c => _obj   = c, _ => _obj = null);
     Entity.Bind <IScaleComponent>(c => _scale = c, _ => _scale = null);
     Entity.Bind <IPixelPerfectComponent>(c => _pixelPerfect = c, _ => _pixelPerfect = null);
     Entity.Bind <IBoundingBoxComponent>(c => _boundingBox   = c, _ => _boundingBox = null);
 }
Example #31
0
        private void LoadAndSetup_INTERNAL <T>(IImageComponent image, Graphic graphic, System.Action <T> callbackOnLoad, string customResourcePath = null) where T : Object
        {
            //var key = (image as WindowComponent).GetInstanceID();

            //Coroutine coroutine;

            /*if (this.loading.TryGetValue(key, out coroutine) == true) {
             *
             *      this.StopCoroutine(coroutine);
             *      this.loading.Remove(key);
             *
             * }*/

            /*this.loaded.ForEach(z => { z.references.Remove(image as WindowComponent); });
             * this.loaded.RemoveAll(x => {
             *
             *      if (x.references.Count == 0) {
             *
             *              //if (x.loadedObjectId < 0) Object.Destroy(x.loadedObject);
             *              return true;
             *
             *      }
             *
             *      return false;
             *
             * });*/

            Item item;

            if (this.IsLoaded <T>(image as WindowComponent, image.GetResource(), out item, callbackOnLoad) == false)
            {
                /*coroutine = */ this.StartCoroutine(image.GetResource().Load <T>(image, graphic, customResourcePath, (data) => {
                    if (data == null)
                    {
                        WindowSystemLogger.Error(image, string.Format("Error in ResourcesManager: Required resource can't loaded. Resource: {0}", image.GetResource().GetId()));
                        return;
                    }

                    item.@object = data;

                    item.loadedObject   = data;
                    item.loadedObjectId = data.GetInstanceID();
                    item.loaded         = true;

                    if (item.onObjectLoaded != null)
                    {
                        item.onObjectLoaded.Invoke();
                    }
                    callbackOnLoad(data);

                    //this.loading.Remove(key);
                }));

                //this.loading.Add(key, coroutine);
            }
        }
Example #32
0
        public void Play(IImageComponent component, bool loop, bool pause)
        {
            var image = component.GetRawImageSource();

            if (image == null)
            {
                return;
            }

            var resource = component.GetResource();

            if (resource.loaded == false)
            {
                Debug.LogWarning("Resource was not loaded yet. Play interrupted.", component as MonoBehaviour);
                return;
            }

            var movie = resource.loadedObject as Texture;

            var item = this.current.FirstOrDefault(x => x.id == resource.GetId());

            if (item != null)
            {
                var c = component as WindowComponent;
                if (item.components.Contains(c) == false)
                {
                    item.components.Add(c);
                }
            }
            else
            {
                item = new Item()
                {
                    id         = resource.GetId(),
                    components = new List <WindowComponent>()
                    {
                        component as WindowComponent
                    },
                    loadedObject   = resource.loadedObject,
                    loadedObjectId = resource.loadedObjectId,
                };

                this.current.Add(item);
            }

            if (item.state != Item.State.Playing)
            {
                item.state = Item.State.Playing;
                this.OnPlay(resource, movie, loop);
            }

            if (pause == true || MovieSystem.CanPlayByQuality(movie) == false)
            {
                this.StartCoroutine(this.PauseWithDelay_YIELD(component, this.delayToPause));
            }
        }
Example #33
0
 public override void Init()
 {
     base.Init();
     Entity.Bind <IBoundingBoxComponent>(
         c => { _box = c; c.OnBoundingBoxesChanged.Subscribe(refresh); refresh(); },
         c => { _box = null; c.OnBoundingBoxesChanged.Unsubscribe(refresh); });
     Entity.Bind <IImageComponent>(
         c => { _image = c; c.PropertyChanged += onImagePropertyChanged; refresh(); },
         c => { _image = null; c.PropertyChanged -= onImagePropertyChanged; });
 }
 public override void Init(IEntity entity)
 {
     base.Init(entity);
     entity.Bind <IBoundingBoxComponent>(
         c => { _box = c; c.OnBoundingBoxesChanged.Subscribe(refresh); refresh(); },
         _ => _box = null);
     entity.Bind <IImageComponent>(
         c => { _image = c; c.PropertyChanged += onImagePropertyChanged; refresh(); },
         _ => _image = null);
 }
        private IEnumerator LoadResource_INTERNAL <T>(ResourceBase resource, IImageComponent component, Graphic graphic, string customResourcePath, System.Action <T> callback) where T : Object
        {
            if (this.taskInterations == null)
            {
                this.taskInterations = new Dictionary <Graphic, int>();
            }

            var iteration = 0;

            if (graphic != null)
            {
                if (this.taskInterations.TryGetValue(graphic, out iteration) == false)
                {
                    this.taskInterations.Add(graphic, ++iteration);
                }
            }

            var task = new TaskItem();

            task.id                 = resource.GetId();
            task.resource           = resource;
            task.component          = component;
            task.graphic            = graphic;
            task.customResourcePath = customResourcePath;
            task.onSuccess          = (obj) => {
                if (graphic != null)
                {
                    var iterationFailed = !(graphic == null || iteration == this.taskInterations[graphic]);
                    if (iterationFailed == false)
                    {
                        callback.Invoke(obj as T);
                    }
                    else
                    {
                        task.onFailed.Invoke();
                    }
                }
                else
                {
                    callback.Invoke(obj as T);
                }
            };
            task.onFailed = () => {
                callback.Invoke(null);
            };

            this.tasks.Add(task);

            //Debug.Log("Resource Task: " + task.resource.assetPath);

            yield return(this.StartCoroutine(this.StartTask <T>(task)));

            task.Dispose();
            this.tasks.Remove(task);
        }
		public void Setup(IImageComponent component) {
			
			if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P1) == true) component.SetPreserveAspectState(this.preserveAspect);
			if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P2) == true) component.SetImage(this.image);
			if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P3) == true) component.SetImage(this.rawImage);
			if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P7) == true) component.SetImage(this.imageLocalizationKey);
			if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P4) == true) component.SetColor(this.imageColor);
			if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P5) == true) component.SetPlayOnStart(this.playOnStart);
			if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P6) == true) component.SetLoop(this.loop);

		}
        public override void Init(IEntity entity)
        {
            base.Init(entity);
            _textComponent = entity.GetComponent<ITextComponent>();
            _imageComponent = entity.GetComponent<IImageComponent>();
            _uiEvents = entity.GetComponent<IUIEvents>();
            _tree = entity.GetComponent<IInObjectTree>();
            _room = entity.GetComponent<IHasRoom>();

            _caretFlashCounter = (int)CaretFlashDelay;
            _withCaret = _game.Factory.UI.GetLabel(entity.ID + " Caret", "|", 1f, 1f, 0f, 0f, new AGSTextConfig(autoFit: AutoFit.LabelShouldFitText));
            _withCaret.Anchor = new PointF(0f, 0f);

            _game.Events.OnBeforeRender.Subscribe(onBeforeRender);
            _uiEvents.MouseDown.Subscribe(onMouseDown);
            _uiEvents.LostFocus.Subscribe(onMouseDownOutside);
        }
		public static void Stop(IImageComponent component) {
			
			if (MovieSystem.instance != null) MovieSystem.instance.Stop_INTERNAL(component);

		}
		public static void Pause(IImageComponent component) {
			
			if (MovieSystem.instance != null) MovieSystem.instance.Pause_INTERNAL(component);

		}
		public static bool IsPlaying(IImageComponent component) {

			if (MovieSystem.instance == null) return false;

			return MovieSystem.instance.IsPlaying_INTERNAL(component);

		}
		protected virtual IEnumerator LoadTexture_YIELD(ResourceAsyncOperation asyncOperation, IImageComponent component, ResourceBase resource) {

			yield return false;

		}
		public static void PlayAndPause(IImageComponent component, bool loop) {

			MovieSystem.instance.Play_INTERNAL(component, loop, pause: true);

		}
		private void Stop_INTERNAL(IImageComponent component) {

			this.movieModule.Stop(component);

		}
		private bool IsPlaying_INTERNAL(IImageComponent component) {
			
			return this.movieModule.IsPlaying(component);

		}
		public void Play(IImageComponent component, bool loop, bool pause) {
			
			var image = component.GetRawImageSource();
			if (image == null) return;

			var resource = component.GetResource();
			if (resource.loaded == false) {

				Debug.LogWarning("Resource was not loaded yet. Play interrupted.", component as MonoBehaviour);
				return;

			}

			var movie = resource.loadedObject as Texture;

			var item = this.current.FirstOrDefault(x => x.id == resource.GetId());
			if (item != null) {
				
				var c = component as WindowComponent;
				if (item.components.Contains(c) == false) {

					item.components.Add(c);

				}

			} else {

				item = new Item() {

					id = resource.GetId(),
					components = new List<WindowComponent>() { component as WindowComponent },
					loadedObject = resource.loadedObject,
					loadedObjectId = resource.loadedObjectId,

				};

				this.current.Add(item);
				
			}

			if (item.state != Item.State.Playing) {

				item.state = Item.State.Playing;
				this.OnPlay(resource, movie, loop);

			}
			
			if (pause == true || MovieSystem.CanPlayByQuality(movie) == false) {
				
				this.StartCoroutine(this.PauseWithDelay_YIELD(component, this.delayToPause));
				
			}

		}
		public void Pause(IImageComponent component) {
			
			var image = component.GetRawImageSource();
			if (image == null) return;
			
			var resource = component.GetResource();
			if (resource.loaded == false) {
				
				Debug.LogWarning("Resource was not loaded yet. Pause interrupted.", component as MonoBehaviour);
				return;
				
			}
			
			var movie = resource.loadedObject as Texture;

			var item = this.current.FirstOrDefault(x => x.id == resource.GetId());
			if (item != null) {
				
				//item.components.Remove(component as WindowComponent);

				//if (item.components.Count == 0) {

					if (item.state != Item.State.Paused) {
						
						item.state = Item.State.Paused;
						this.OnPause(resource, movie);
						
					}
					
				//}

			}

		}
		public bool IsPlaying(IImageComponent component) {
			
			var image = component.GetRawImageSource();
			if (image == null) return false;
			
			return this.IsPlaying(component.GetResource(), image.mainTexture);
			
		}
		protected IEnumerator PauseWithDelay_YIELD(IImageComponent component, Texture movie, float delay, System.Action<ResourceBase, Texture> callback) {
			
			var timer = 0f;
			while (timer < delay) {
				
				timer += Time.unscaledDeltaTime;
				yield return false;
				
			}
			
			yield return false;

			callback.Invoke(component.GetResource(), movie);
			
		}
		protected override IEnumerator LoadTexture_YIELD(ResourceAsyncOperation asyncOperation, IImageComponent component, ResourceBase resource) {
			
			var filePath = resource.GetStreamPath();
			
			var instance = this.FindInstance(resource);
			if (instance != null) {

				instance.Load(asyncOperation, filePath);

			} else {

				var item = new VideoPlayerInterface(this.system);
				this.playingInstances.Add(filePath, item);
				item.Load(asyncOperation, filePath);

			}

			yield return false;

		}
 public ImagesController(IImageComponent imageComponent, ILoggingComponent loggingComponent)
 {
     ImageComponent = imageComponent;
     LoggingComponennt = loggingComponent;
 }
		public static void Play(IImageComponent component, bool loop) {

			if (MovieSystem.instance != null) MovieSystem.instance.Play_INTERNAL(component, loop, pause: false);

		}
Example #52
0
 public override void Init(IEntity entity)
 {
     base.Init(entity);
     _obj = entity.GetComponent<IImageComponent>();
     _obj.CustomRenderer = _labelRenderer;
 }
		private void Pause_INTERNAL(IImageComponent component) {

			this.movieModule.Pause(component);

		}
		public static long GetKey(ResourceBase resource, IImageComponent component) {

			return resource.GetId();

		}
		private void Play_INTERNAL(IImageComponent component, bool loop, bool pause) {

			this.movieModule.Play(component, loop, pause);

		}
		public static ResourceAsyncOperation LoadTexture(IImageComponent component) {

			return MovieSystem.instance.movieModule.LoadTexture(component);

		}
		protected IEnumerator PauseWithDelay_YIELD(IImageComponent component, float delay) {
			
			var timer = 0f;
			while (timer < delay) {
				
				timer += Time.unscaledDeltaTime;
				yield return false;
				
			}
			
			yield return false;

			this.Pause(component);
			
		}
 public ImageController(IImageComponent imageComponent)
 {
     ImageComponent = imageComponent;
 }