Example #1
0
        public ActionResult Update([DataSourceRequest]DataSourceRequest request, ActorViewModel model)
        {
            if (model != null && this.ModelState.IsValid)
            {
                var actor = this.actorsService.GetById(model.Id);
                actor.FirstName = model.FirstName;
                actor.LastName = model.LastName;

                this.actorsService.Update(actor);
            }

            return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState));
        }
Example #2
0
        private ActionResult ActorDetails(Func<ActorRecord> getActor)
        {
            var actor = getActor();
            if (actor == null)
            {
                return HttpNotFound();
            }

            var movieIds = actor.ActorMovies.Select(m => m.MoviePartRecord.Id);
            var movies = _contentManager.GetMany<MoviePart>(movieIds, VersionOptions.Published, QueryHints.Empty).OrderByDescending(m => m.YearReleased).ToList();
            var viewModel = new ActorViewModel { Name = actor.Name, Movies = movies };
            return View("Details", viewModel);
        }
        public IActionResult Post([FromBody] ActorViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            if (HttpContext.Session.GetObjectFromJson <User>("loggedUser") == null)
            {
                return(Unauthorized());
            }
            if (!HttpContext.Session.GetObjectFromJson <User>("loggedUser").IsAdmin)
            {
                return(Unauthorized());
            }

            Actor actor = new Actor(model.FirstName, model.LastName);

            actorRepo.Insert(actor);

            return(Ok(actor));
        }
        public async Task ReturnCorrectViewModel_OnGet()
        {
            // Arrange
            var actorServiceMock = new Mock <IActorService>();

            string actorName = "Dolph Lundgren";

            var actorViewModel = new ActorViewModel();

            actorServiceMock
            .Setup(g => g.GetActorByNameAsync(actorName))
            .ReturnsAsync(actorViewModel);

            var sut = new ActorController(actorServiceMock.Object);

            // Act
            var result = await sut.Details(actorName) as ViewResult;

            // Assert
            Assert.IsInstanceOfType(result.Model, typeof(ActorViewModel));
        }
        public async Task CallActorServiceOnce_OnGet()
        {
            // Arrange
            var actorServiceMock = new Mock <IActorService>();

            string actorName = "Dolph Lundgren";

            var actorViewModel = new ActorViewModel();

            actorServiceMock
            .Setup(g => g.GetActorByNameAsync(actorName))
            .ReturnsAsync(actorViewModel);

            var sut = new ActorController(actorServiceMock.Object);

            // Act
            await sut.Details(actorName);

            // Assert
            actorServiceMock.Verify(g => g.GetActorByNameAsync(actorName), Times.Once);
        }
        public async Task <IActionResult> Create(ActorViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                string imageName = null;

                if (model.ActorPicture != null)
                {
                    imageName = optimizer.OptimizeImage(model.ActorPicture, 268, 182);
                }

                var actor = await this.actorService.FindActorByNameAsync(model.FirstName, model.LastName);

                if (actor != null)
                {
                    StatusMessage = string.Format(WebConstants.ActorAlreadyExists, model.FirstName, model.LastName);
                    return(RedirectToAction("Create", "Actors"));
                }
                actor = await this.actorService
                        .CreateActorAsync(model.FirstName, model.LastName, imageName, model.Biography);

                if (actor.FirstName == model.FirstName && actor.LastName == model.LastName &&
                    actor.Picture == imageName && actor.Biography == model.Biography)
                {
                    StatusMessage = string.Format(WebConstants.ActorCreated, model.FirstName, model.LastName);
                }
                return(RedirectToAction("Details", "Actors", new { id = actor.Id }));
            }

            catch (ArgumentException ex)
            {
                StatusMessage = ex.Message;
                return(RedirectToAction("Create", "Actors"));
            }
        }
Example #7
0
        public ActionResult CreateEditActor(ActorViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var actor = new Actor()
                {
                    Bio         = viewModel.Bio,
                    DateOfBirth = viewModel.DateOfBirth,
                    Name        = viewModel.Name,
                    Sex         = viewModel.Sex
                };
                _actorRepository.Insert(actor);

                _actorRepository.Save();

                return(Json(new { success = true, actorId = actor.RowId }));
            }
            else
            {
                return(PartialView("_CreateEditActor", viewModel));
            }
        }
        public async Task <IActionResult> PutAsync(string id, [FromBody] ActorViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            if (HttpContext.Session.GetObjectFromJson <User>("loggedUser") == null)
            {
                return(Unauthorized());
            }
            if (!HttpContext.Session.GetObjectFromJson <User>("loggedUser").IsAdmin)
            {
                return(Unauthorized());
            }

            if (actorRepo.Get(a => a.Id == id) == null)
            {
                return(NotFound());
            }

            Actor actor;

            try
            {
                actor           = actorRepo.Get(a => a.Id == id);
                actor.FirstName = model.FirstName;
                actor.LastName  = model.LastName;

                actorRepo.Update(actor);
            }
            catch (Exception ex)
            {
                await _logger.LogCustomExceptionAsync(ex, null);

                return(BadRequest());
            }

            return(Ok(actor));
        }
Example #9
0
        public void WriteToFile(ActorViewModel actor, Configuration config)
        {
            this.Config = config;

            SkeletonViewModel?skeleton = actor?.ModelObject?.Skeleton?.Skeleton;

            if (skeleton == null)
            {
                throw new Exception("No skeleton in actor");
            }

            if (config.Groups.HasFlag(Groups.Body) && skeleton.Body != null)
            {
                this.Body = this.WriteToFile(skeleton.Body);
            }

            if (config.Groups.HasFlag(Groups.Head) && skeleton.Head != null)
            {
                this.Head = this.WriteToFile(skeleton.Head);
            }

            if (config.Groups.HasFlag(Groups.Hair) && skeleton.Hair != null)
            {
                this.Hair = this.WriteToFile(skeleton.Hair);
            }

            if (config.Groups.HasFlag(Groups.Met) && skeleton.Met != null)
            {
                this.Met = this.WriteToFile(skeleton.Met);
            }

            if (config.Groups.HasFlag(Groups.Top) && skeleton.Top != null)
            {
                this.Top = this.WriteToFile(skeleton.Top);
            }

            Log.Write("Saved skeleton to file");
        }
Example #10
0
        public static async Task <SkeletonVisual3d> GetVisual(ActorViewModel actor)
        {
            SkeletonVisual3d skeleton;

            if (actorSkeletons.ContainsKey(actor))
            {
                skeleton = actorSkeletons[actor];
                skeleton.Clear();
                actorSkeletons.Remove(actor);
            }

            // TODO: Why does a new skeleton work, but clearing an old one gives us "not a child of the specified visual" when writing?
            ////else
            {
                skeleton = new SkeletonVisual3d(actor);
                actorSkeletons.Add(actor, skeleton);
            }

            skeleton.Clear();
            await skeleton.GenerateBones();

            return(skeleton);
        }
        public ActionResult Create(ActorViewModel actorViewModel, HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                actorViewModel.Id = Guid.NewGuid();

                Actor actor = Mapper.Map <Actor>(actorViewModel);
                if (image != null)
                {
                    if (CheckImageUploadExtension.CheckImagePath(image.FileName) == true)
                    {
                        var path = Path.Combine(Server.MapPath("~/Images/Upload"), image.FileName);
                        image.SaveAs(path);
                        actor.Thumbnail = VariableUtils.UrlUpLoadImage + image.FileName;
                    }
                }
                _actorsService.Create(actor);

                return(RedirectToAction("Index"));
            }

            return(PartialView("_Create", actorViewModel));
        }
        public static SkeletonFile?GetSkeletonFile(this SkeletonViewModel self, ActorViewModel actor)
        {
            int          maxDepth = int.MinValue;
            SkeletonFile?maxSkel  = null;

            foreach (SkeletonFile template in PoseService.BoneNameFiles)
            {
                if (template.IsValid(self, actor))
                {
                    if (template.Depth > maxDepth)
                    {
                        maxDepth = template.Depth;
                        maxSkel  = template;
                    }
                }
            }

            if (maxSkel != null)
            {
                return(maxSkel);
            }

            return(null);
        }
Example #13
0
 public ActionResult CreateEditActor(int?actorId)
 {
     if (actorId.HasValue)
     {
         var actor = _actorRepository.GetById(actorId);
         if (actor == null)
         {
             return(HttpNotFound());
         }
         var viewModel = new ActorViewModel()
         {
             Bio         = actor.Bio,
             DateOfBirth = actor.DateOfBirth,
             Name        = actor.Name,
             Sex         = actor.Sex,
             RowId       = actor.RowId
         };
         return(PartialView("_CreateEditActor", viewModel));
     }
     else
     {
         return(PartialView("_CreateEditActor"));
     }
 }
Example #14
0
        public ActionResult Create()
        {
            var model = new ActorViewModel(Status.Active);

            return(View("CreateOrUpdate", model));
        }
Example #15
0
 public CommentViewModelDesigner()
 {
     Author = new ActorViewModel {
         Login = "******"
     };
 }
Example #16
0
    private void ProcessDamage(IGraphNode targetNode, ITacticalAct tacticalAct, IActor actor, ActorViewModel actorViewModel)
    {
        var targetActorViewModel        = ActorViewModels.SingleOrDefault(x => x.Actor.Node == targetNode);
        var targetStaticObjectViewModel = _staticObjectViewModels.SingleOrDefault(x => x.StaticObject.Node == targetNode);
        var canBeHitViewModel           = (ICanBeHitSectorObject)targetActorViewModel ?? targetStaticObjectViewModel;

        if (canBeHitViewModel is null)
        {
            return;
        }

        actorViewModel.GraphicRoot.ProcessHit(canBeHitViewModel.Position);

        var sfxObj = _container.InstantiatePrefab(HitSfx, transform);
        var sfx    = sfxObj.GetComponent <HitSfx>();

        canBeHitViewModel.AddHitEffect(sfx);

        // Проверяем, стрелковое оружие или удар ближнего боя
        if (tacticalAct.Stats.Range?.Max > 1)
        {
            sfx.EffectSpriteRenderer.sprite = sfx.ShootSprite;

            // Создаём снаряд
            CreateBullet(actor, targetNode);
        }
    }
Example #17
0
    private void ProcessDamage(IAttackTarget target, ITacticalAct tacticalAct, IActor actor, ActorViewModel actorViewModel)
    {
        var targetActorViewModel        = ActorViewModels.SingleOrDefault(x => ReferenceEquals(x.Item, target));
        var targetStaticObjectViewModel = _staticObjectViewModels.SingleOrDefault(x => ReferenceEquals(x.Item, target));
        var canBeHitViewModel           = (ICanBeHitSectorObject)targetActorViewModel ?? targetStaticObjectViewModel;

        if (canBeHitViewModel is null)
        {
            return;
        }

        actorViewModel.GraphicRoot.ProcessHit(canBeHitViewModel.Position);

        var sfx = Instantiate(HitSfx, transform);

        canBeHitViewModel.AddHitEffect(sfx);

        // Проверяем, стрелковое оружие или удар ближнего боя
        if (tacticalAct.Stats.Range?.Max > 1)
        {
            sfx.EffectSpriteRenderer.sprite = sfx.ShootSprite;

            // Создаём снараяд
            CreateBullet(actor, target);
        }
    }
Example #18
0
 private static void ProcessHeal(ActorViewModel actorViewModel)
 {
     actorViewModel.GraphicRoot.ProcessHit(actorViewModel.transform.position);
 }
Example #19
0
        public async Task Apply(ActorViewModel actor, SkeletonVisual3d skeleton, Configuration config, bool selectionOnly)
        {
            if (actor == null)
            {
                throw new ArgumentNullException(nameof(actor));
            }

            if (actor.ModelObject == null)
            {
                throw new Exception("Actor has no model");
            }

            if (actor.ModelObject.Skeleton == null)
            {
                throw new Exception("Actor model has no skeleton wrapper");
            }

            if (actor.ModelObject.Skeleton.Skeleton == null)
            {
                throw new Exception("Actor skeleton wrapper has no skeleton");
            }

            SkeletonViewModel skeletonMem = actor.ModelObject.Skeleton.Skeleton;

            skeletonMem.MemoryMode = MemoryModes.None;

            PoseService.Instance.SetEnabled(true);
            PoseService.Instance.CanEdit = false;
            await Task.Delay(100);

            // Facial expressions hack:
            // Since all facial bones are parented to the head, if we load the head rotation from
            // the pose that matches the expression, it wont break.
            // We then just set the head back to where it should be afterwards.
            BoneVisual3d?headBone = skeleton.GetIsHeadSelection() ? skeleton.GetBone("Head") : null;

            headBone?.ReadTransform(true);
            Quaternion?originalHeadRotation = headBone?.ViewModel.Rotation;

            if (this.Bones != null)
            {
                // Apply all transforms a few times to ensure parent-inherited values are caluclated correctly, and to ensure
                // we dont end up with some values read during a ffxiv frame update.
                for (int i = 0; i < 3; i++)
                {
                    foreach ((string name, Bone? savedBone) in this.Bones)
                    {
                        if (savedBone == null)
                        {
                            continue;
                        }

                        BoneVisual3d?bone = skeleton.GetBone(name);

                        if (bone == null)
                        {
                            Log.Warning($"Bone: \"{name}\" not found");
                            continue;
                        }

                        if (selectionOnly && !skeleton.GetIsBoneSelected(bone))
                        {
                            continue;
                        }

                        TransformPtrViewModel vm = bone.ViewModel;

                        if (PoseService.Instance.FreezePositions && savedBone.Position != null && config.LoadPositions)
                        {
                            vm.Position = (Vector)savedBone.Position;
                        }

                        if (PoseService.Instance.FreezeRotation && savedBone.Rotation != null && config.LoadRotations)
                        {
                            vm.Rotation = (Quaternion)savedBone.Rotation;
                        }

                        if (PoseService.Instance.FreezeScale && savedBone.Scale != null && config.LoadScales)
                        {
                            vm.Scale = (Vector)savedBone.Scale;
                        }

                        bone.ReadTransform();
                        bone.WriteTransform(skeleton, false);
                    }

                    await Task.Delay(1);
                }
            }

            // Restore the head bone rotation if we were only loading an expression
            if (headBone != null && originalHeadRotation != null)
            {
                headBone.ViewModel.Rotation = (Quaternion)originalHeadRotation;
                headBone.ReadTransform();
                headBone.WriteTransform(skeleton, true);
            }

            await Task.Delay(100);

            skeletonMem.MemoryMode = MemoryModes.ReadWrite;

            await skeletonMem.ReadFromMemoryAsync();

            PoseService.Instance.CanEdit = true;
        }
 private void SetActiveActor(ActorViewModel playerActorViewModel)
 {
     // Это нужно для UI, чтобы они реагировали на состояние текущего персонажа.
     // И это нужно для команд. Команды берут актуивного актёра из источника команд.
     _playerState.ActiveActor = playerActorViewModel;
 }
Example #21
0
        private async Task <ActorViewModel> CreateActor(ActorViewModel model)
        {
            var actor = await _actorRepository.Add(_mapper.Map <Actor>(model));

            return(_mapper.Map <ActorViewModel>(actor));
        }
 public ActorDetailsPage(ActorViewModel viewModel)
 {
     InitializeComponent();
     BindingContext = viewModel;
 }
Example #23
0
 private record Marker(Rectangle Rect, ActorViewModel ActorViewModel);
        public IActionResult Create()
        {
            var model = new ActorViewModel();

            return(View("Create", model));
        }
Example #25
0
        public async Task Apply(ActorViewModel actor, SkeletonVisual3d skeleton, Configuration config)
        {
            if (actor == null)
            {
                throw new ArgumentNullException(nameof(actor));
            }

            if (actor.ModelObject == null)
            {
                throw new Exception("Actor has no model");
            }

            if (actor.ModelObject.Skeleton == null)
            {
                throw new Exception("Actor model has no skeleton wrapper");
            }

            if (actor.ModelObject.Skeleton.Skeleton == null)
            {
                throw new Exception("Actor skeleton wrapper has no skeleton");
            }

            SkeletonViewModel skeletonMem = actor.ModelObject.Skeleton.Skeleton;

            skeletonMem.MemoryMode = MemoryModes.None;

            PoseService.Instance.SetEnabled(true);
            PoseService.Instance.CanEdit = false;
            await Task.Delay(100);

            if (this.Bones != null)
            {
                // Apply all transforms a few times to ensure parent-inherited values are caluclated correctly, and to ensure
                // we dont end up with some values read during a ffxiv frame update.
                for (int i = 0; i < 3; i++)
                {
                    foreach ((string name, Bone? savedBone) in this.Bones)
                    {
                        if (savedBone == null)
                        {
                            continue;
                        }

                        BoneVisual3d?bone = skeleton.GetBone(name);

                        if (bone == null)
                        {
                            Log.Warning($"Bone: \"{name}\" not found");
                            continue;
                        }

                        if (config.UseSelection && !skeleton.GetIsBoneSelected(bone))
                        {
                            continue;
                        }

                        TransformPtrViewModel vm = bone.ViewModel;

                        if (PoseService.Instance.FreezePositions && savedBone.Position != null && config.LoadPositions)
                        {
                            vm.Position = (Vector)savedBone.Position;
                        }

                        if (PoseService.Instance.FreezeRotation && savedBone.Rotation != null && config.LoadRotations)
                        {
                            vm.Rotation = (Quaternion)savedBone.Rotation;
                        }

                        if (PoseService.Instance.FreezeScale && savedBone.Scale != null && config.LoadScales)
                        {
                            vm.Scale = (Vector)savedBone.Scale;
                        }

                        bone.ReadTransform();
                        bone.WriteTransform(skeleton, false);
                    }

                    await Task.Delay(1);
                }
            }

            await Task.Delay(100);

            skeletonMem.MemoryMode = MemoryModes.ReadWrite;

            await skeletonMem.ReadFromMemoryAsync();

            PoseService.Instance.CanEdit = true;
        }
Example #26
0
        public ActionResult Destroy([DataSourceRequest]DataSourceRequest request, ActorViewModel model)
        {
            this.actorsService.Delete(model.Id);

            return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState));
        }
Example #27
0
        public void WriteToFile(ActorViewModel actor, SaveModes mode)
        {
            this.Nickname  = actor.Nickname;
            this.ModelType = actor.ModelType;

            if (actor.Customize == null)
            {
                return;
            }

            this.SaveMode = mode;

            if (this.IncludeSection(SaveModes.EquipmentWeapons, mode))
            {
                if (actor.MainHand != null)
                {
                    this.MainHand = new WeaponSave(actor.MainHand);
                }
                ////this.MainHand.Color = actor.GetValue(Offsets.Main.MainHandColor);
                ////this.MainHand.Scale = actor.GetValue(Offsets.Main.MainHandScale);

                if (actor.OffHand != null)
                {
                    this.OffHand = new WeaponSave(actor.OffHand);
                }
                ////this.OffHand.Color = actor.GetValue(Offsets.Main.OffhandColor);
                ////this.OffHand.Scale = actor.GetValue(Offsets.Main.OffhandScale);
            }

            if (this.IncludeSection(SaveModes.EquipmentGear, mode))
            {
                if (actor.Equipment?.Head != null)
                {
                    this.HeadGear = new ItemSave(actor.Equipment.Head);
                }

                if (actor.Equipment?.Chest != null)
                {
                    this.Body = new ItemSave(actor.Equipment.Chest);
                }

                if (actor.Equipment?.Arms != null)
                {
                    this.Hands = new ItemSave(actor.Equipment.Arms);
                }

                if (actor.Equipment?.Legs != null)
                {
                    this.Legs = new ItemSave(actor.Equipment.Legs);
                }

                if (actor.Equipment?.Feet != null)
                {
                    this.Feet = new ItemSave(actor.Equipment.Feet);
                }
            }

            if (this.IncludeSection(SaveModes.EquipmentAccessories, mode))
            {
                if (actor.Equipment?.Ear != null)
                {
                    this.Ears = new ItemSave(actor.Equipment.Ear);
                }

                if (actor.Equipment?.Neck != null)
                {
                    this.Neck = new ItemSave(actor.Equipment.Neck);
                }

                if (actor.Equipment?.Wrist != null)
                {
                    this.Wrists = new ItemSave(actor.Equipment.Wrist);
                }

                if (actor.Equipment?.LFinger != null)
                {
                    this.LeftRing = new ItemSave(actor.Equipment.LFinger);
                }

                if (actor.Equipment?.RFinger != null)
                {
                    this.RightRing = new ItemSave(actor.Equipment.RFinger);
                }
            }

            if (this.IncludeSection(SaveModes.AppearanceHair, mode))
            {
                this.Hair             = actor.Customize?.Hair;
                this.EnableHighlights = actor.Customize?.EnableHighlights;
                this.HairTone         = actor.Customize?.HairTone;
                this.Highlights       = actor.Customize?.Highlights;
                this.HairColor        = actor.ModelObject?.ExtendedAppearance?.HairColor;
                this.HairGloss        = actor.ModelObject?.ExtendedAppearance?.HairGloss;
                this.HairHighlight    = actor.ModelObject?.ExtendedAppearance?.HairHighlight;
            }

            if (this.IncludeSection(SaveModes.AppearanceFace, mode) || this.IncludeSection(SaveModes.AppearanceBody, mode))
            {
                this.Race   = actor.Customize?.Race;
                this.Gender = actor.Customize?.Gender;
                this.Tribe  = actor.Customize?.Tribe;
                this.Age    = actor.Customize?.Age;
            }

            if (this.IncludeSection(SaveModes.AppearanceFace, mode))
            {
                this.Head               = actor.Customize?.Head;
                this.REyeColor          = actor.Customize?.REyeColor;
                this.LimbalEyes         = actor.Customize?.LimbalEyes;
                this.FacialFeatures     = actor.Customize?.FacialFeatures;
                this.Eyebrows           = actor.Customize?.Eyebrows;
                this.LEyeColor          = actor.Customize?.LEyeColor;
                this.Eyes               = actor.Customize?.Eyes;
                this.Nose               = actor.Customize?.Nose;
                this.Jaw                = actor.Customize?.Jaw;
                this.Mouth              = actor.Customize?.Mouth;
                this.LipsToneFurPattern = actor.Customize?.LipsToneFurPattern;
                this.FacePaint          = actor.Customize?.FacePaint;
                this.FacePaintColor     = actor.Customize?.FacePaintColor;
                this.LeftEyeColor       = actor.ModelObject?.ExtendedAppearance?.LeftEyeColor;
                this.RightEyeColor      = actor.ModelObject?.ExtendedAppearance?.RightEyeColor;
                this.LimbalRingColor    = actor.ModelObject?.ExtendedAppearance?.LimbalRingColor;
                this.MouthColor         = actor.ModelObject?.ExtendedAppearance?.MouthColor;
            }

            if (this.IncludeSection(SaveModes.AppearanceBody, mode))
            {
                this.Height            = actor.Customize?.Height;
                this.Skintone          = actor.Customize?.Skintone;
                this.EarMuscleTailSize = actor.Customize?.EarMuscleTailSize;
                this.TailEarsType      = actor.Customize?.TailEarsType;
                this.Bust = actor.Customize?.Bust;

                this.HeightMultiplier = actor.ModelObject?.Height;
                this.SkinColor        = actor.ModelObject?.ExtendedAppearance?.SkinColor;
                this.SkinGloss        = actor.ModelObject?.ExtendedAppearance?.SkinGloss;
                this.MuscleTone       = actor.ModelObject?.ExtendedAppearance?.MuscleTone;
                this.BustScale        = actor.ModelObject?.Bust?.Scale;
                this.Transparency     = actor.Transparency;
            }
        }
Example #28
0
        public async Task Apply(ActorViewModel actor, SaveModes mode)
        {
            if (actor.Customize == null)
            {
                return;
            }

            Log.Information("Reading appearance from file");

            actor.AutomaticRefreshEnabled = false;
            actor.MemoryMode = MemoryModes.None;

            if (actor.ModelObject?.ExtendedAppearance != null)
            {
                actor.ModelObject.ExtendedAppearance.MemoryMode = MemoryModes.None;
            }

            if (!string.IsNullOrEmpty(this.Nickname))
            {
                actor.Nickname = this.Nickname;
            }

            actor.ModelType = this.ModelType;

            if (this.IncludeSection(SaveModes.EquipmentWeapons, mode))
            {
                this.MainHand?.Write(actor.MainHand);
                this.OffHand?.Write(actor.OffHand);
            }

            if (this.IncludeSection(SaveModes.EquipmentGear, mode))
            {
                this.HeadGear?.Write(actor.Equipment?.Head);
                this.Body?.Write(actor.Equipment?.Chest);
                this.Hands?.Write(actor.Equipment?.Arms);
                this.Legs?.Write(actor.Equipment?.Legs);
                this.Feet?.Write(actor.Equipment?.Feet);
            }

            if (this.IncludeSection(SaveModes.EquipmentAccessories, mode))
            {
                this.Ears?.Write(actor.Equipment?.Ear);
                this.Neck?.Write(actor.Equipment?.Neck);
                this.Wrists?.Write(actor.Equipment?.Wrist);
                this.RightRing?.Write(actor.Equipment?.RFinger);
                this.LeftRing?.Write(actor.Equipment?.LFinger);
            }

            if (this.IncludeSection(SaveModes.AppearanceHair, mode))
            {
                actor.Customize.Hair             = (byte)this.Hair !;
                actor.Customize.EnableHighlights = (bool)this.EnableHighlights !;
                actor.Customize.HairTone         = (byte)this.HairTone !;
                actor.Customize.Highlights       = (byte)this.Highlights !;
            }

            if (this.IncludeSection(SaveModes.AppearanceFace, mode) || this.IncludeSection(SaveModes.AppearanceBody, mode))
            {
                actor.Customize.Race   = (Appearance.Races) this.Race !;
                actor.Customize.Gender = (Appearance.Genders) this.Gender !;
                actor.Customize.Tribe  = (Appearance.Tribes) this.Tribe !;
                actor.Customize.Age    = (Appearance.Ages) this.Age !;
            }

            if (this.IncludeSection(SaveModes.AppearanceFace, mode))
            {
                actor.Customize.Head               = (byte)this.Head !;
                actor.Customize.REyeColor          = (byte)this.REyeColor !;
                actor.Customize.FacialFeatures     = (Appearance.FacialFeature) this.FacialFeatures !;
                actor.Customize.LimbalEyes         = (byte)this.LimbalEyes !;
                actor.Customize.Eyebrows           = (byte)this.Eyebrows !;
                actor.Customize.LEyeColor          = (byte)this.LEyeColor !;
                actor.Customize.Eyes               = (byte)this.Eyes !;
                actor.Customize.Nose               = (byte)this.Nose !;
                actor.Customize.Jaw                = (byte)this.Jaw !;
                actor.Customize.Mouth              = (byte)this.Mouth !;
                actor.Customize.LipsToneFurPattern = (byte)this.LipsToneFurPattern !;
                actor.Customize.FacePaint          = (byte)this.FacePaint !;
                actor.Customize.FacePaintColor     = (byte)this.FacePaintColor !;
            }

            if (this.IncludeSection(SaveModes.AppearanceBody, mode))
            {
                actor.Customize.Height            = (byte)this.Height !;
                actor.Customize.Skintone          = (byte)this.Skintone !;
                actor.Customize.EarMuscleTailSize = (byte)this.EarMuscleTailSize !;
                actor.Customize.TailEarsType      = (byte)this.TailEarsType !;
                actor.Customize.Bust = (byte)this.Bust !;
            }

            actor.WriteToMemory(true);
            await actor.RefreshAsync();

            // Setting customize values will reset the extended appearance, which me must read.
            await actor.ReadFromMemoryAsync(true);

            if (actor.ModelObject?.ExtendedAppearance != null)
            {
                await actor.ModelObject.ExtendedAppearance.ReadFromMemoryAsync(true);
            }

            // write everything that is reset by actor refreshes

            /*if (this.IncludeSection(SaveModes.EquipmentGear, mode))
             * {
             *      if (this.MainHand != null)
             *      {
             *              actor.SetValue(Offsets.Main.MainHandColor, this.MainHand.Color);
             *              actor.SetValue(Offsets.Main.MainHandScale, this.MainHand.Scale);
             *      }
             *
             *      if (this.OffHand != null)
             *      {
             *              actor.SetValue(Offsets.Main.OffhandColor, this.OffHand.Color);
             *              actor.SetValue(Offsets.Main.OffhandScale, this.OffHand.Scale);
             *      }
             * }*/

            if (actor.ModelObject?.ExtendedAppearance != null)
            {
                bool usedExAppearance = false;

                if (this.IncludeSection(SaveModes.AppearanceHair, mode))
                {
                    actor.ModelObject.ExtendedAppearance.HairColor     = this.HairColor ?? actor.ModelObject.ExtendedAppearance.HairColor;
                    actor.ModelObject.ExtendedAppearance.HairGloss     = this.HairGloss ?? actor.ModelObject.ExtendedAppearance.HairGloss;
                    actor.ModelObject.ExtendedAppearance.HairHighlight = this.HairHighlight ?? actor.ModelObject.ExtendedAppearance.HairHighlight;

                    usedExAppearance |= this.HairColor != null;
                    usedExAppearance |= this.HairGloss != null;
                    usedExAppearance |= this.HairHighlight != null;
                }

                if (this.IncludeSection(SaveModes.AppearanceFace, mode))
                {
                    actor.ModelObject.ExtendedAppearance.LeftEyeColor    = this.LeftEyeColor ?? actor.ModelObject.ExtendedAppearance.LeftEyeColor;
                    actor.ModelObject.ExtendedAppearance.RightEyeColor   = this.RightEyeColor ?? actor.ModelObject.ExtendedAppearance.RightEyeColor;
                    actor.ModelObject.ExtendedAppearance.LimbalRingColor = this.LimbalRingColor ?? actor.ModelObject.ExtendedAppearance.LimbalRingColor;
                    actor.ModelObject.ExtendedAppearance.MouthColor      = this.MouthColor ?? actor.ModelObject.ExtendedAppearance.MouthColor;

                    usedExAppearance |= this.LeftEyeColor != null;
                    usedExAppearance |= this.RightEyeColor != null;
                    usedExAppearance |= this.LimbalRingColor != null;
                    usedExAppearance |= this.MouthColor != null;
                }

                if (this.IncludeSection(SaveModes.AppearanceBody, mode))
                {
                    actor.ModelObject.ExtendedAppearance.SkinColor  = this.SkinColor ?? actor.ModelObject.ExtendedAppearance.SkinColor;
                    actor.ModelObject.ExtendedAppearance.SkinGloss  = this.SkinGloss ?? actor.ModelObject.ExtendedAppearance.SkinGloss;
                    actor.ModelObject.ExtendedAppearance.MuscleTone = this.MuscleTone ?? actor.ModelObject.ExtendedAppearance.MuscleTone;
                    actor.Transparency       = this.Transparency ?? actor.Transparency;
                    actor.ModelObject.Height = this.HeightMultiplier ?? actor.ModelObject.Height;

                    if (actor.ModelObject.Bust?.Scale != null)
                    {
                        actor.ModelObject.Bust.Scale = this.BustScale ?? actor.ModelObject.Bust.Scale;
                    }

                    usedExAppearance |= this.SkinColor != null;
                    usedExAppearance |= this.SkinGloss != null;
                    usedExAppearance |= this.MuscleTone != null;
                }

                ////actor.ModelObject.ExtendedAppearance.Freeze = usedExAppearance;
                actor.ModelObject.ExtendedAppearance.MemoryMode = MemoryModes.ReadWrite;
                actor.ModelObject.ExtendedAppearance.WriteToMemory(true);
            }

            actor.MemoryMode = MemoryModes.ReadWrite;
            actor.WriteToMemory(true);
            actor.AutomaticRefreshEnabled = true;
        }
 public ActorInfo(ActorViewModel actorViewModel)
 {
     InitializeComponent();
     DataContext = actorViewModel;
 }
Example #30
0
 public virtual void StartEncounter()
 {
     ActorViewModel.StartEncounter();
     TurnState = Types.TurnState.NotStarted;
 }
Example #31
0
        public async Task Apply(ActorViewModel actor, SaveModes mode)
        {
            if (actor.Customize == null)
            {
                return;
            }

            Log.Write("Reading appearance from file", "AppearanceFile");

            actor.AutomaticRefreshEnabled = false;
            actor.MemoryMode = MemoryModes.None;

            if (actor.ModelObject?.ExtendedAppearance != null)
            {
                actor.ModelObject.ExtendedAppearance.MemoryMode = MemoryModes.None;
            }

            actor.ModelType = this.ModelType;

            bool changedRace = actor.Customize.Race != this.Race;

            if (this.IncludeSection(SaveModes.EquipmentWeapons, mode))
            {
                this.MainHand?.Write(actor.MainHand);
                this.OffHand?.Write(actor.OffHand);
            }

            if (this.IncludeSection(SaveModes.EquipmentGear, mode))
            {
                this.HeadGear?.Write(actor.Equipment?.Head);
                this.Body?.Write(actor.Equipment?.Chest);
                this.Hands?.Write(actor.Equipment?.Arms);
                this.Legs?.Write(actor.Equipment?.Legs);
                this.Feet?.Write(actor.Equipment?.Feet);
            }

            if (this.IncludeSection(SaveModes.EquipmentAccessories, mode))
            {
                this.Ears?.Write(actor.Equipment?.Ear);
                this.Neck?.Write(actor.Equipment?.Neck);
                this.Wrists?.Write(actor.Equipment?.Wrist);
                this.RightRing?.Write(actor.Equipment?.RFinger);
                this.LeftRing?.Write(actor.Equipment?.LFinger);
            }

            if (this.IncludeSection(SaveModes.AppearanceHair, mode))
            {
                actor.Customize.Hair             = (byte)this.Hair !;
                actor.Customize.EnableHighlights = (bool)this.EnableHighlights !;
                actor.Customize.HairTone         = (byte)this.HairTone !;
                actor.Customize.Highlights       = (byte)this.Highlights !;
            }

            if (this.IncludeSection(SaveModes.AppearanceFace, mode) || this.IncludeSection(SaveModes.AppearanceBody, mode))
            {
                actor.Customize.Race   = (Appearance.Races) this.Race !;
                actor.Customize.Gender = (Appearance.Genders) this.Gender !;
                actor.Customize.Tribe  = (Appearance.Tribes) this.Tribe !;
                actor.Customize.Age    = (Appearance.Ages) this.Age !;
            }

            if (this.IncludeSection(SaveModes.AppearanceFace, mode))
            {
                actor.Customize.Head               = (byte)this.Head !;
                actor.Customize.REyeColor          = (byte)this.REyeColor !;
                actor.Customize.FacialFeatures     = (Appearance.FacialFeature) this.FacialFeatures !;
                actor.Customize.LimbalEyes         = (byte)this.LimbalEyes !;
                actor.Customize.Eyebrows           = (byte)this.Eyebrows !;
                actor.Customize.LEyeColor          = (byte)this.LEyeColor !;
                actor.Customize.Eyes               = (byte)this.Eyes !;
                actor.Customize.Nose               = (byte)this.Nose !;
                actor.Customize.Jaw                = (byte)this.Jaw !;
                actor.Customize.Mouth              = (byte)this.Mouth !;
                actor.Customize.LipsToneFurPattern = (byte)this.LipsToneFurPattern !;
                actor.Customize.FacePaint          = (byte)this.FacePaint !;
                actor.Customize.FacePaintColor     = (byte)this.FacePaintColor !;
            }

            if (this.IncludeSection(SaveModes.AppearanceBody, mode))
            {
                actor.Customize.Height            = (byte)this.Height !;
                actor.Customize.Skintone          = (byte)this.Skintone !;
                actor.Customize.EarMuscleTailSize = (byte)this.EarMuscleTailSize !;
                actor.Customize.TailEarsType      = (byte)this.TailEarsType !;
                actor.Customize.Bust = (byte)this.Bust !;
            }

            actor.WriteToMemory(true);
            await actor.RefreshAsync();

            // If we have changed race, we do a second actor refresh to avoid cases where
            // FFXIV has not loaded the correct skin texture for the new race in time for
            // the charater to render, causing the new model to show with the old skin.
            if (changedRace)
            {
                await actor.RefreshAsync();
            }

            // Setting customize values will reset the extended appearance, which me must read.
            await actor.ReadFromMemoryAsync(true);

            if (actor.ModelObject?.ExtendedAppearance != null)
            {
                await actor.ModelObject.ExtendedAppearance.ReadFromMemoryAsync(true);
            }

            // write everything that is reset by actor refreshes

            /*if (this.IncludeSection(SaveModes.EquipmentGear, mode))
             * {
             *      if (this.MainHand != null)
             *      {
             *              actor.SetValue(Offsets.Main.MainHandColor, this.MainHand.Color);
             *              actor.SetValue(Offsets.Main.MainHandScale, this.MainHand.Scale);
             *      }
             *
             *      if (this.OffHand != null)
             *      {
             *              actor.SetValue(Offsets.Main.OffhandColor, this.OffHand.Color);
             *              actor.SetValue(Offsets.Main.OffhandScale, this.OffHand.Scale);
             *      }
             * }*/

            if (actor.ModelObject?.ExtendedAppearance != null)
            {
                bool usedExAppearance = false;

                if (this.IncludeSection(SaveModes.AppearanceHair, mode))
                {
                    actor.ModelObject.ExtendedAppearance.HairColor     = this.HairColor ?? actor.ModelObject.ExtendedAppearance.HairColor;
                    actor.ModelObject.ExtendedAppearance.HairGloss     = this.HairGloss ?? actor.ModelObject.ExtendedAppearance.HairGloss;
                    actor.ModelObject.ExtendedAppearance.HairHighlight = this.HairHighlight ?? actor.ModelObject.ExtendedAppearance.HairHighlight;

                    usedExAppearance |= this.HairColor != null;
                    usedExAppearance |= this.HairGloss != null;
                    usedExAppearance |= this.HairHighlight != null;
                }

                if (this.IncludeSection(SaveModes.AppearanceFace, mode))
                {
                    actor.ModelObject.ExtendedAppearance.LeftEyeColor    = this.LeftEyeColor ?? actor.ModelObject.ExtendedAppearance.LeftEyeColor;
                    actor.ModelObject.ExtendedAppearance.RightEyeColor   = this.RightEyeColor ?? actor.ModelObject.ExtendedAppearance.RightEyeColor;
                    actor.ModelObject.ExtendedAppearance.LimbalRingColor = this.LimbalRingColor ?? actor.ModelObject.ExtendedAppearance.LimbalRingColor;
                    actor.ModelObject.ExtendedAppearance.MouthColor      = this.MouthColor ?? actor.ModelObject.ExtendedAppearance.MouthColor;

                    usedExAppearance |= this.LeftEyeColor != null;
                    usedExAppearance |= this.RightEyeColor != null;
                    usedExAppearance |= this.LimbalRingColor != null;
                    usedExAppearance |= this.MouthColor != null;
                }

                if (this.IncludeSection(SaveModes.AppearanceBody, mode))
                {
                    actor.ModelObject.ExtendedAppearance.SkinColor = this.SkinColor ?? actor.ModelObject.ExtendedAppearance.SkinColor;
                    actor.ModelObject.ExtendedAppearance.SkinGloss = this.SkinGloss ?? actor.ModelObject.ExtendedAppearance.SkinGloss;
                    ////actor.SetValue(Offsets.Main.Transparency, this.Transparency);
                    ////actor.SetValue(Offsets.Main.BustScale, this.BustScale);
                    ////actor.SetValue(Offsets.Main.UniqueFeatureScale, this.FeatureScale);

                    usedExAppearance |= this.SkinColor != null;
                    usedExAppearance |= this.SkinGloss != null;
                }

                actor.ModelObject.ExtendedAppearance.Freeze     = usedExAppearance;
                actor.ModelObject.ExtendedAppearance.MemoryMode = MemoryModes.ReadWrite;
                actor.ModelObject.ExtendedAppearance.WriteToMemory(true);
            }

            actor.MemoryMode = MemoryModes.ReadWrite;
            actor.WriteToMemory(true);
            actor.AutomaticRefreshEnabled = true;
        }
Example #32
0
        /// <summary>
        /// Loads the view model from octokit models.
        /// </summary>
        /// <param name="pullRequest">The pull request model.</param>
        public async Task Load(PullRequestDetailModel pullRequest)
        {
            try
            {
                var firstLoad = (Model == null);
                Model  = pullRequest;
                Author = new ActorViewModel(pullRequest.Author);
                Title  = Resources.PullRequestNavigationItemText + " #" + pullRequest.Number;

                IsBusy     = true;
                IsFromFork = !pullRequestsService.IsPullRequestFromRepository(LocalRepository, pullRequest);
                SourceBranchDisplayName = GetBranchDisplayName(IsFromFork, pullRequest.HeadRepositoryOwner, pullRequest.HeadRefName);
                TargetBranchDisplayName = GetBranchDisplayName(IsFromFork, pullRequest.BaseRepositoryOwner, pullRequest.BaseRefName);
                Body    = !string.IsNullOrWhiteSpace(pullRequest.Body) ? pullRequest.Body : Resources.NoDescriptionProvidedMarkdown;
                Reviews = PullRequestReviewSummaryViewModel.BuildByUser(Session.User, pullRequest).ToList();

                Checks = (IReadOnlyList <IPullRequestCheckViewModel>)PullRequestCheckViewModel.Build(viewViewModelFactory, pullRequest)?.ToList() ?? Array.Empty <IPullRequestCheckViewModel>();

                // Only show unresolved comments
                await Files.InitializeAsync(Session, c => !c.IsResolved);

                var localBranches = await pullRequestsService.GetLocalBranches(LocalRepository, pullRequest).ToList();

                var currentBranch = gitService.GetBranch(LocalRepository);
                IsCheckedOut = localBranches.Contains(currentBranch);

                if (IsCheckedOut)
                {
                    var divergence = await pullRequestsService.CalculateHistoryDivergence(LocalRepository, Model.Number);

                    var    pullEnabled = divergence.BehindBy > 0;
                    var    pushEnabled = divergence.AheadBy > 0 && !pullEnabled;
                    string pullToolTip;
                    string pushToolTip;

                    if (pullEnabled)
                    {
                        pullToolTip = string.Format(
                            CultureInfo.InvariantCulture,
                            Resources.PullRequestDetailsPullToolTip,
                            IsFromFork ? Resources.Fork : Resources.Remote,
                            SourceBranchDisplayName);
                    }
                    else
                    {
                        pullToolTip = Resources.NoCommitsToPull;
                    }

                    if (pushEnabled)
                    {
                        pushToolTip = string.Format(
                            CultureInfo.InvariantCulture,
                            Resources.PullRequestDetailsPushToolTip,
                            IsFromFork ? Resources.Fork : Resources.Remote,
                            SourceBranchDisplayName);
                    }
                    else if (divergence.AheadBy == 0)
                    {
                        pushToolTip = Resources.NoCommitsToPush;
                    }
                    else
                    {
                        pushToolTip = Resources.MustPullBeforePush;
                    }

                    var submodulesToSync = await pullRequestsService.CountSubmodulesToSync(LocalRepository);

                    var syncSubmodulesToolTip = string.Format(CultureInfo.InvariantCulture, Resources.SyncSubmodules, submodulesToSync);

                    UpdateState   = new UpdateCommandState(divergence, pullEnabled, pushEnabled, pullToolTip, pushToolTip, syncSubmodulesToolTip, submodulesToSync);
                    CheckoutState = null;
                }
                else
                {
                    var caption = localBranches.Count > 0 ?
                                  string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.PullRequestDetailsCheckout,
                        localBranches.First().DisplayName) :
                                  string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.PullRequestDetailsCheckoutTo,
                        await pullRequestsService.GetDefaultLocalBranchName(LocalRepository, Model.Number, Model.Title));
                    var clean = await pullRequestsService.IsWorkingDirectoryClean(LocalRepository);

                    string disabled = null;

                    if (pullRequest.HeadRepositoryOwner == null)
                    {
                        disabled = Resources.SourceRepositoryNoLongerAvailable;
                    }
                    else if (!clean)
                    {
                        disabled = Resources.WorkingDirectoryHasUncommittedCHanges;
                    }

                    CheckoutState = new CheckoutCommandState(caption, disabled);
                    UpdateState   = null;
                }

                sessionSubscription?.Dispose();
                sessionSubscription = Session.WhenAnyValue(x => x.HasPendingReview)
                                      .Skip(1)
                                      .Subscribe(x => Reviews = PullRequestReviewSummaryViewModel.BuildByUser(Session.User, Session.PullRequest).ToList());

                if (firstLoad)
                {
                    usageTracker.IncrementCounter(x => x.NumberOfPullRequestsOpened).Forget();
                }

                if (!isInCheckout)
                {
                    pullRequestsService.RemoveUnusedRemotes(LocalRepository).Subscribe(_ => { });
                }
            }
            finally
            {
                IsBusy = false;
            }
        }
Example #33
0
 public virtual void EndTurn()
 {
     TurnState = Types.TurnState.Ended;
     ActorViewModel.ActorUpdated();
 }