Beispiel #1
0
        public void SaveMetadata(Entities.EntityBase entity, string connectionString)
        {
            SaveModes sm = SaveModes.New;

            try
            {
                if (entity.IsNewDescription)
                {
                    sm = SaveModes.New;
                }
                else
                {
                    sm = SaveModes.Update;
                }

                if (string.IsNullOrEmpty(entity.Description))
                {
                    sm = SaveModes.Delete;
                }

                if (entity.HasChanges)
                {
                    SaveDescription(sm, connectionString, entity.Level1Type, entity.Description, entity.Schema, entity.Level1Name, entity.Level2Type, entity.Level2Name);
                    entity.IsNewDescription = false;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #2
0
        public SaveModes GetSaveMode()
        {
            SaveModes sm = SaveModes.NoAction;

            if (!HasChanges)
            {
                return(sm);
            }

            // Figure out if the description is new or if it exists and should be updated.
            if (IsNewDescription)
            {
                sm = SaveModes.New;
            }
            else
            {
                sm = SaveModes.Update;
            }
            // If the Description is empty then we should drop the extended property
            if (string.IsNullOrEmpty(Description))
            {
                sm = SaveModes.Delete;
            }

            return(sm);
        }
Beispiel #3
0
        private string GetSQLTextForSaveMode(SaveModes saveMode)
        {
            string sql = string.Empty;

            if (string.IsNullOrEmpty(ApplicationSettings.Default.ExtendedPropKey))
            {
                throw new ArgumentException("The ExtendedPropertyKey must have a value. Please change it in the Options");
            }

            switch (saveMode)
            {
            case SaveModes.New:
                sql = sqlAdd;
                break;

            case SaveModes.Update:
                sql = sqlUpdate;
                break;

            case SaveModes.Delete:
                sql = sqlDrop;
                break;

            default:
                break;
            }
            return(sql);
        }
Beispiel #4
0
        internal string GetSQLQueryText(EntityBase entity, string ConnectionString)
        {
            SaveModes saveMode = SaveModes.New;

            if (entity.IsNewDescription)
            {
                saveMode = SaveModes.New;
            }
            else
            {
                saveMode = SaveModes.Update;
            }

            if (string.IsNullOrEmpty(entity.Description))
            {
                saveMode = SaveModes.Delete;
            }

            if (entity.HasChanges)
            {
                string sql = GetSQLTextForSaveMode(saveMode);

                using (DbCommand cmd = CommandFactory.Create(sql, ConnectionString, System.Data.CommandType.StoredProcedure))
                {
                    FillCommand(cmd, saveMode, entity.Level1Type, entity.Description, entity.Schema, entity.Level1Name, entity.Level2Type, entity.Level2Name);

                    return(SqlCommandDumper.GetCommandText((System.Data.SqlClient.SqlCommand)cmd));
                }
            }
            else
            {
                return("");
            }
        }
Beispiel #5
0
        private string GetSerializedContent(object content, SaveModes mode)
        {
            // String to store the serialized content
            string serialized = "";

            // Get save mode
            switch (mode)
            {
            // If its json..
            case SaveModes.Json:
                serialized = JsonConvert.SerializeObject(content, Formatting.Indented);
                break;

            // If its xml..
            case SaveModes.Xml:
                serialized = XmlSerializer.Serialize(content);
                break;

            // If its binary..
            case SaveModes.Binary:
                serialized = BinarySerializer.Serialize(content);
                break;
            }

            return(serialized);
        }
Beispiel #6
0
        /// <summary>
        /// Method for save figures to xml file by XmlWriter
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="filename"></param>
        public void SaveFiguresByXmlWriter(SaveModes mode, string filename)
        {
            XmlWriter         writer;
            XmlWriterSettings writerSettings = new XmlWriterSettings();

            writerSettings.Indent = true;
            writer = XmlWriter.Create(filename, writerSettings);
            writer.WriteStartDocument();
            writer.WriteStartElement("figures");
            foreach (var figure in figures)
            {
                switch (mode)
                {
                case SaveModes.All:
                    writer.WriteStartElement("figure");
                    figure.WriteByXmlWriterHelper(writer);
                    writer.WriteEndElement();
                    break;

                case SaveModes.OnlyEnvelope:
                    if (figure.Material.MaterialType == MaterialTypes.Envelope)
                    {
                        writer.WriteStartElement("figure");
                        figure.WriteByXmlWriterHelper(writer);
                        writer.WriteEndElement();
                    }
                    break;

                case SaveModes.OnlyPaper:
                    if (figure.Material.MaterialType == MaterialTypes.Paper)
                    {
                        writer.WriteStartElement("figure");
                        figure.WriteByXmlWriterHelper(writer);
                        writer.WriteEndElement();
                    }
                    break;
                }
            }
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();
            figures.Clear();
        }
Beispiel #7
0
        private static void FillCommand(DbCommand cmd, SaveModes saveMode, Level1Types level1Type, string descriptionValue, string objectSchema, string level1Name, Level2Types level2Type, string level2Name)
        {
            cmd.Connection.Open();

            if (saveMode != SaveModes.Delete)
            {
                cmd.Parameters.Add(CommandFactory.CreateParameter("@value", descriptionValue));
            }

            cmd.Parameters.Add(CommandFactory.CreateParameter("@name", ApplicationSettings.Default.ExtendedPropKey));
            cmd.Parameters.Add(CommandFactory.CreateParameter("@level0type", "SCHEMA"));
            cmd.Parameters.Add(CommandFactory.CreateParameter("@level0name", objectSchema));
            cmd.Parameters.Add(CommandFactory.CreateParameter("@level1type", level1Type.ToString()));
            cmd.Parameters.Add(CommandFactory.CreateParameter("@level1name", level1Name));
            if (level2Type != Level2Types.NULL)
            {
                cmd.Parameters.Add(CommandFactory.CreateParameter("@level2type", level2Type.ToString()));
                cmd.Parameters.Add(CommandFactory.CreateParameter("@level2name", level2Name));
            }
        }
Beispiel #8
0
        protected bool SaveDescription(SaveModes saveMode, string connStr, Level1Types level1Type, string descriptionValue, string objectSchema, string level1Name, Level2Types level2Type, string level2Name)
        {
            string sql = GetSQLTextForSaveMode(saveMode);

            try
            {
                using (DbCommand cmd = CommandFactory.Create(sql, connStr, System.Data.CommandType.StoredProcedure))
                {
                    FillCommand(cmd, saveMode, level1Type, descriptionValue, objectSchema, level1Name, level2Type, level2Name);

                    cmd.ExecuteNonQuery();
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(true);
        }
Beispiel #9
0
        /// <summary>
        /// Method for save figures to xml file by StreamWriter
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="filename"></param>
        public void SaveFiguresByStreamWriter(SaveModes mode, string filename)
        {
            StreamWriter writer = new StreamWriter(filename);

            writer.WriteLine(string.Format("<?xml version={0}1.0{1} encoding={2}utf-8{3} ?>", @"""", @"""", @"""", @""""));
            writer.WriteLine("<figures>");
            foreach (var figure in figures)
            {
                switch (mode)
                {
                case SaveModes.All:
                    writer.WriteLine("  <figure>");
                    figure.WriteByStreamWriterHelper(writer);
                    writer.WriteLine("  </figure>");
                    break;

                case SaveModes.OnlyEnvelope:
                    if (figure.Material.MaterialType == MaterialTypes.Envelope)
                    {
                        writer.WriteLine("  <figure>");
                        figure.WriteByStreamWriterHelper(writer);
                        writer.WriteLine("  </figure>");
                    }
                    break;

                case SaveModes.OnlyPaper:
                    if (figure.Material.MaterialType == MaterialTypes.Paper)
                    {
                        writer.WriteLine("  <figure>");
                        figure.WriteByStreamWriterHelper(writer);
                        writer.WriteLine("  </figure>");
                    }
                    break;
                }
            }
            writer.WriteLine("</figures>");
            writer.Close();
            figures.Clear();
        }
        public static async Task <SaveModes> Save(ActorViewModel?actor, SaveModes mode = SaveModes.All)
        {
            if (actor == null)
            {
                return(mode);
            }

            SaveResult result = await FileService.Save <CharacterFile>();

            if (string.IsNullOrEmpty(result.Path) || result.Info == null)
            {
                return(CharacterFileOptions.Result);
            }

            CharacterFile file = new CharacterFile();

            file.WriteToFile(actor, mode);

            using FileStream stream = new FileStream(result.Path, FileMode.Create);
            result.Info.SerializeFile(file, stream);

            return(CharacterFileOptions.Result);
        }
Beispiel #11
0
        public async Task Apply(Actor actor, SaveModes mode)
        {
            Log.Write("Reading appearance from file", "AppearanceFile");

            using IMemory <int> modelTypeMem = actor.GetMemory(Offsets.Main.ModelType);

            if (modelTypeMem.Value != this.ModelType)
            {
                modelTypeMem.Value = (int)this.ModelType;
                await actor.ActorRefreshAsync();
            }

            if (!actor.IsCustomizable())
            {
                return;
            }

            using IMemory <Appearance> appearanceMem = actor.GetMemory(Offsets.Main.ActorAppearance);
            using IMemory <Equipment> equipmentMem   = actor.GetMemory(Offsets.Main.ActorEquipment);
            using IMemory <Weapon> mainHandMem       = actor.GetMemory(Offsets.Main.MainHand);
            using IMemory <Weapon> offHandMem        = actor.GetMemory(Offsets.Main.OffHand);

            Appearance appearance = appearanceMem.Value;
            Equipment  equipment  = equipmentMem.Value;
            Weapon     mainHand   = mainHandMem.Value;
            Weapon     offHand    = offHandMem.Value;

            if (this.IncludeSection(SaveModes.EquipmentGear, mode))
            {
                mainHand.Base    = this.MainHand.ModelBase;
                mainHand.Dye     = this.MainHand.DyeId;
                mainHand.Set     = this.MainHand.ModelSet;
                mainHand.Variant = this.MainHand.ModelVariant;

                if (this.OffHand != null)
                {
                    offHand.Base    = this.OffHand.ModelBase;
                    offHand.Dye     = this.OffHand.DyeId;
                    offHand.Set     = this.OffHand.ModelSet;
                    offHand.Variant = this.OffHand.ModelVariant;
                }

                equipment.Head  = this.HeadGear;
                equipment.Chest = this.Body;
                equipment.Arms  = this.Hands;
                equipment.Legs  = this.Legs;
                equipment.Feet  = this.Feet;
            }

            if (this.IncludeSection(SaveModes.EquipmentAccessories, mode))
            {
                equipment.Ear     = this.Ears;
                equipment.Neck    = this.Neck;
                equipment.Wrist   = this.Wrists;
                equipment.RFinger = this.RightRing;
                equipment.LFinger = this.LeftRing;
            }

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

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

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

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

            await Task.Delay(100);

            appearanceMem.Value = appearance;
            equipmentMem.Value  = equipment;
            mainHandMem.Value   = mainHand;
            offHandMem.Value    = offHand;

            await actor.ActorRefreshAsync();

            await Task.Delay(1000);

            // write everything that is reset by actor refreshes
            if (this.IncludeSection(SaveModes.EquipmentGear, mode))
            {
                using IMemory <Color> mainHandTintMem   = actor.GetMemory(Offsets.Main.MainHandColor);
                using IMemory <Vector> mainHandScaleMem = actor.GetMemory(Offsets.Main.MainHandScale);

                mainHandScaleMem.Value = this.MainHand.Scale;
                mainHandTintMem.Value  = this.MainHand.Color;

                if (this.OffHand != null)
                {
                    using IMemory <Color> offHandTintMem   = actor.GetMemory(Offsets.Main.OffhandColor);
                    using IMemory <Vector> offHandScaleMem = actor.GetMemory(Offsets.Main.OffhandScale);

                    offHandScaleMem.Value = this.OffHand.Scale;
                    offHandTintMem.Value  = this.OffHand.Color;
                }
            }

            if (this.IncludeSection(SaveModes.AppearanceHair, mode))
            {
                if (this.HairTint != null)
                {
                    using IMemory <Color> hairTintColorMem = actor.GetMemory(Offsets.Main.HairColor);
                    hairTintColorMem.Value = (Color)this.HairTint;
                }

                if (this.HairGlow != null)
                {
                    using IMemory <Color> hairGlowColorMem = actor.GetMemory(Offsets.Main.HairGloss);
                    hairGlowColorMem.Value = (Color)this.HairGlow;
                }

                if (this.HighlightTint != null)
                {
                    using IMemory <Color> highlightTintColorMem = actor.GetMemory(Offsets.Main.HairHiglight);
                    highlightTintColorMem.Value = (Color)this.HighlightTint;
                }
            }

            if (this.IncludeSection(SaveModes.AppearanceFace, mode))
            {
                if (this.LeftEyeColor != null)
                {
                    using IMemory <Color> leftEyeColorMem = actor.GetMemory(Offsets.Main.LeftEyeColor);
                    leftEyeColorMem.Value = (Color)this.LeftEyeColor;
                }

                if (this.RightEyeColor != null)
                {
                    using IMemory <Color> rightEyeColorMem = actor.GetMemory(Offsets.Main.RightEyeColor);
                    rightEyeColorMem.Value = (Color)this.RightEyeColor;
                }

                if (this.LimbalRingColor != null)
                {
                    using IMemory <Color> limbalRingColorMem = actor.GetMemory(Offsets.Main.LimbalColor);
                    limbalRingColorMem.Value = (Color)this.LimbalRingColor;
                }

                if (this.LipTint != null)
                {
                    using IMemory <Color> lipTintMem  = actor.GetMemory(Offsets.Main.MouthColor);
                    using IMemory <float> lipGlossMem = actor.GetMemory(Offsets.Main.MouthGloss);

                    Color4 c = (Color4)this.LipTint;
                    lipTintMem.Value  = c.Color;
                    lipGlossMem.Value = c.A;
                }
            }

            if (this.IncludeSection(SaveModes.AppearanceBody, mode))
            {
                if (this.SkinTint != null)
                {
                    using IMemory <Color> skinTintMem = actor.GetMemory(Offsets.Main.SkinColor);
                    skinTintMem.Value = (Color)this.SkinTint;
                }

                if (this.SkinGlow != null)
                {
                    using IMemory <Color> skinGlowMem = actor.GetMemory(Offsets.Main.SkinGloss);
                    skinGlowMem.Value = (Color)this.SkinGlow;
                }
            }
        }
Beispiel #12
0
        public void Read(Actor actor, SaveModes mode)
        {
            Log.Write("Writing appearance to file", "AppearanceFile");

            using IMemory <int> modelTypeMem = actor.GetMemory(Offsets.Main.ModelType);
            this.ModelType = modelTypeMem.Value;

            if (!actor.IsCustomizable())
            {
                return;
            }

            using IMemory <Appearance> appearanceMem = actor.GetMemory(Offsets.Main.ActorAppearance);
            using IMemory <Equipment> equipmentMem   = actor.GetMemory(Offsets.Main.ActorEquipment);
            using IMemory <Weapon> mainHandMem       = actor.GetMemory(Offsets.Main.MainHand);
            using IMemory <Weapon> offHandMem        = actor.GetMemory(Offsets.Main.OffHand);

            Appearance appearance = appearanceMem.Value;
            Equipment  equipment  = equipmentMem.Value;
            Weapon     mainHand   = mainHandMem.Value;
            Weapon     offHand    = offHandMem.Value;

            this.SaveMode = mode;

            if (this.IncludeSection(SaveModes.EquipmentGear, mode))
            {
                using IMemory <Color> mainHandTintMem   = actor.GetMemory(Offsets.Main.MainHandColor);
                using IMemory <Vector> mainHandScaleMem = actor.GetMemory(Offsets.Main.MainHandScale);
                using IMemory <Color> offHandTintMem    = actor.GetMemory(Offsets.Main.OffhandColor);
                using IMemory <Vector> offHandScaleMem  = actor.GetMemory(Offsets.Main.OffhandScale);

                this.MainHand              = new WeaponSave();
                this.MainHand.DyeId        = mainHand.Dye;
                this.MainHand.ModelBase    = mainHand.Base;
                this.MainHand.ModelSet     = mainHand.Set;
                this.MainHand.ModelVariant = mainHand.Variant;
                this.MainHand.Color        = mainHandTintMem.Value;
                this.MainHand.Scale        = mainHandScaleMem.Value;

                this.OffHand              = new WeaponSave();
                this.OffHand.DyeId        = offHand.Dye;
                this.OffHand.ModelBase    = offHand.Base;
                this.OffHand.ModelSet     = offHand.Set;
                this.OffHand.ModelVariant = offHand.Variant;
                this.OffHand.Color        = offHandTintMem.Value;
                this.OffHand.Scale        = offHandScaleMem.Value;

                this.HeadGear = new ItemSave(equipment.Head);
                this.Body     = new ItemSave(equipment.Chest);
                this.Hands    = new ItemSave(equipment.Arms);
                this.Legs     = new ItemSave(equipment.Legs);
                this.Feet     = new ItemSave(equipment.Feet);
            }

            if (this.IncludeSection(SaveModes.EquipmentAccessories, mode))
            {
                this.Ears      = new ItemSave(equipment.Ear);
                this.Neck      = new ItemSave(equipment.Neck);
                this.Wrists    = new ItemSave(equipment.Wrist);
                this.LeftRing  = new ItemSave(equipment.LFinger);
                this.RightRing = new ItemSave(equipment.RFinger);
            }

            if (this.IncludeSection(SaveModes.AppearanceHair, mode))
            {
                using IMemory <Color> hairTintColorMem      = actor.GetMemory(Offsets.Main.HairColor);
                using IMemory <Color> hairGlowColorMem      = actor.GetMemory(Offsets.Main.HairGloss);
                using IMemory <Color> highlightTintColorMem = actor.GetMemory(Offsets.Main.HairHiglight);

                this.Hair             = appearance.Hair;
                this.EnableHighlights = appearance.EnableHighlights;
                this.HairTone         = appearance.HairTone;
                this.Highlights       = appearance.Highlights;
                this.HairTint         = hairTintColorMem.Value;
                this.HairGlow         = hairGlowColorMem.Value;
                this.HighlightTint    = highlightTintColorMem.Value;
            }

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

            if (this.IncludeSection(SaveModes.AppearanceFace, mode))
            {
                using IMemory <Color> leftEyeColorMem    = actor.GetMemory(Offsets.Main.LeftEyeColor);
                using IMemory <Color> rightEyeColorMem   = actor.GetMemory(Offsets.Main.RightEyeColor);
                using IMemory <Color> limbalRingColorMem = actor.GetMemory(Offsets.Main.LimbalColor);
                using IMemory <Color> lipTintMem         = actor.GetMemory(Offsets.Main.MouthColor);
                using IMemory <float> lipGlossMem        = actor.GetMemory(Offsets.Main.MouthGloss);

                this.Head               = appearance.Head;
                this.REyeColor          = appearance.REyeColor;
                this.LimbalEyes         = appearance.LimbalEyes;
                this.FacialFeatures     = appearance.FacialFeatures;
                this.Eyebrows           = appearance.Eyebrows;
                this.LEyeColor          = appearance.LEyeColor;
                this.Eyes               = appearance.Eyes;
                this.Nose               = appearance.Nose;
                this.Jaw                = appearance.Jaw;
                this.Mouth              = appearance.Mouth;
                this.LipsToneFurPattern = appearance.LipsToneFurPattern;
                this.FacePaint          = appearance.FacePaint;
                this.FacePaintColor     = appearance.FacePaintColor;
                this.LeftEyeColor       = leftEyeColorMem.Value;
                this.RightEyeColor      = rightEyeColorMem.Value;
                this.LimbalRingColor    = limbalRingColorMem.Value;

                this.LipTint = new Color4(lipTintMem.Value, lipGlossMem.Value);
            }

            if (this.IncludeSection(SaveModes.AppearanceBody, mode))
            {
                using IMemory <Color> skinColorMem = actor.GetMemory(Offsets.Main.SkinColor);
                using IMemory <Color> skinGlowMem  = actor.GetMemory(Offsets.Main.SkinGloss);

                this.Height            = appearance.Height;
                this.Skintone          = appearance.Skintone;
                this.EarMuscleTailSize = appearance.EarMuscleTailSize;
                this.TailEarsType      = appearance.TailEarsType;
                this.Bust     = appearance.Bust;
                this.SkinTint = skinColorMem.Value;
                this.SkinGlow = skinGlowMem.Value;
            }
        }
        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 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;
            }
        }
Beispiel #15
0
        /// <summary>
        /// Indicates the manager to use an specific save mode
        /// </summary>
        /// <param name="mode">The mode to use</param>
        public ConfigurationManagerSettings WithSaveMode(SaveModes mode)
        {
            SaveMode = mode;

            return(this);
        }
Beispiel #16
0
        public void Write(AppearanceEditor ap, EquipmentEditor eq, SaveModes mode)
        {
            if (mode.HasFlag(SaveModes.EquipmentGear))
            {
                if (this.MainHand?.ModelSet != 0)
                {
                    this.MainHand?.Write(eq.MainHand);
                }

                this.OffHand?.Write(eq.OffHand);
                this.HeadGear?.Write(eq.Head);
                this.Body?.Write(eq.Body);
                this.Hands?.Write(eq.Hands);
                this.Legs?.Write(eq.Legs);
                this.Feet?.Write(eq.Feet);

                Write(this.MainHandScale, (v) => eq.MainHand.Scale = v);
                Write(this.MainHandColor, (v) => eq.MainHand.Color = v);
                Write(this.OffHandScale, (v) => eq.OffHand.Scale   = v);
                Write(this.OffHandColor, (v) => eq.OffHand.Color   = v);
            }

            if (mode.HasFlag(SaveModes.EquipmentAccessories))
            {
                this.Ears?.Write(eq.Ears);
                this.Neck?.Write(eq.Neck);
                this.Wrists?.Write(eq.Wrists);
                this.LeftRing?.Write(eq.LeftRing);
                this.RightRing?.Write(eq.RightRing);
            }

            if (mode.HasFlag(SaveModes.AppearanceHair))
            {
                Write(this.Hair, (v) => ap.Appearance.Hair = v);
                Write(this.EnableHighlights, (v) => ap.Appearance.EnableHighlights = v);
                Write(this.HairTone, (v) => ap.Appearance.HairTone     = v);
                Write(this.Highlights, (v) => ap.Appearance.Highlights = v);

                ap.HairTint      = this.HairTint;
                ap.HairGlow      = this.HairGlow;
                ap.HighlightTint = this.HighlightTint;
            }

            if (mode.HasFlag(SaveModes.AppearanceFace) || mode.HasFlag(SaveModes.AppearanceBody))
            {
                Write(this.Race, (v) => ap.Appearance.Race     = v);
                Write(this.Gender, (v) => ap.Appearance.Gender = v);
                Write(this.Tribe, (v) => ap.Appearance.Tribe   = v);
                Write(this.Age, (v) => ap.Appearance.Age       = v);
            }

            if (mode.HasFlag(SaveModes.AppearanceFace))
            {
                Write(this.Head, (v) => ap.Appearance.Head                     = v);
                Write(this.REyeColor, (v) => ap.Appearance.REyeColor           = v);
                Write(this.FacialFeatures, (v) => ap.Appearance.FacialFeatures = v);
                Write(this.LimbalEyes, (v) => ap.Appearance.LimbalEyes         = v);
                Write(this.Eyebrows, (v) => ap.Appearance.Eyebrows             = v);
                Write(this.LEyeColor, (v) => ap.Appearance.LEyeColor           = v);
                Write(this.Eyes, (v) => ap.Appearance.Eyes                     = v);
                Write(this.Nose, (v) => ap.Appearance.Nose                     = v);
                Write(this.Jaw, (v) => ap.Appearance.Jaw     = v);
                Write(this.Mouth, (v) => ap.Appearance.Mouth = v);
                Write(this.LipsToneFurPattern, (v) => ap.Appearance.LipsToneFurPattern = v);
                Write(this.FacePaint, (v) => ap.Appearance.FacePaint           = v);
                Write(this.FacePaintColor, (v) => ap.Appearance.FacePaintColor = v);

                ap.LeftEyeColor    = this.LeftEyeColor;
                ap.RightEyeColor   = this.RightEyeColor;
                ap.LimbalRingColor = this.LimbalRingColor;
                ap.LipTint         = this.LipTint;
            }

            if (mode.HasFlag(SaveModes.AppearanceBody))
            {
                Write(this.Height, (v) => ap.Appearance.Height     = v);
                Write(this.Skintone, (v) => ap.Appearance.Skintone = v);
                Write(this.EarMuscleTailSize, (v) => ap.Appearance.EarMuscleTailSize = v);
                Write(this.TailEarsType, (v) => ap.Appearance.TailEarsType           = v);
                Write(this.Bust, (v) => ap.Appearance.Bust = v);

                ap.SkinTint = this.SkinTint;
                ap.SkinGlow = this.SkinGlow;
            }
        }
Beispiel #17
0
 private bool IncludeSection(SaveModes section, SaveModes mode)
 {
     return(this.SaveMode.HasFlag(section) && mode.HasFlag(section));
 }
        public static List <MultiplicationSum> Main(string path, bool save = false, string savePath = null, SaveModes saveMode = SaveModes.Full)
        {
            var workingList = Multiply(path);

            if (!save)
            {
                return(workingList);
            }

            var pathToSave = savePath ?? Path.Combine(Directory.GetCurrentDirectory(), "\\multiplied.txt");

            var sw      = File.CreateText(pathToSave);
            var toWrite = string.Empty;

            foreach (var sum in workingList)
            {
                if (saveMode == SaveModes.Full)
                {
                    toWrite += $"{sum.ToString()}\n";
                }
                else
                {
                    toWrite += $"{sum.GetProduct()}\n";
                }
            }
            sw.Write(toWrite);
            sw.Dispose();
            return(workingList);
        }
Beispiel #19
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;
        }
Beispiel #20
0
        public static bool Validate(DataObject dataObject, SaveModes saveMode, List <Guid> saveFlags = null)
        {
            if (validationDefinitionsBySchemaObject == null)
            {
                InitializeRules();
            }

            SchemaObject thisSchemaObject = Schema.Schema.GetSchemaObject(dataObject.GetType());
            List <IValidationDefinition> validationDefinitionsForObject = validationDefinitionsBySchemaObject.GetOrDefault(thisSchemaObject);

            if (validationDefinitionsBySchemaObject == null)
            {
                return(true);
            }

            Func <ValidationRule, bool> validRulesDelegate = vr => saveFlags == null ? true : !saveFlags.Contains(vr.ID);

            DataObject           objectToValidate = dataObject;
            IEnumerable <string> extraFields      = validationDefinitionsForObject.SelectMany(def => def.ValidationRules.Where(validRulesDelegate).SelectMany(vr => vr.Condition.AdditionalDataObjectFields));

            if (extraFields.Any())
            {
                objectToValidate = DataObject.GetEditableByPrimaryKey(dataObject.GetType(), objectToValidate.PrimaryKeyField.GetValue(objectToValidate) as long?);
                if (objectToValidate == null)
                {
                    objectToValidate = dataObject;
                }
                else
                {
                    dataObject.Copy(objectToValidate);
                }
            }

            bool success = true;

            foreach (ValidationRule validationRule in validationDefinitionsForObject.SelectMany(vd => vd.ValidationRules.Where(vr =>
            {
                switch (saveMode)
                {
                case SaveModes.Delete:
                    return(vr.ApplyOnDelete);

                case SaveModes.Insert:
                    return(vr.ApplyOnInsert);

                case SaveModes.Update:
                    return(vr.ApplyOnUpdate);
                }

                return(false);
            })))
            {
                bool result = validationRule.Condition.Evaluate(objectToValidate);
                if (!result)
                {
                    dataObject.Errors.Add(validationRule.Field, validationRule.Message);
                }

                success = result && success;
            }

            return(success);
        }
 internal void SetSaveMode(SaveModes mode)
 => mSaveMode = mode;
Beispiel #22
0
        public void Read(AppearanceEditor ed, EquipmentEditor eq, SaveModes mode)
        {
            if (mode.HasFlag(SaveModes.EquipmentGear))
            {
                this.MainHand      = new Weapon(eq.MainHand);
                this.MainHandScale = eq.MainHand.Scale;
                this.MainHandColor = eq.MainHand.Color;

                this.OffHand      = new Weapon(eq.OffHand);
                this.OffHandScale = eq.OffHand.Scale;
                this.OffHandColor = eq.OffHand.Color;

                this.HeadGear = new Item(eq.Head);
                this.Body     = new Item(eq.Body);
                this.Hands    = new Item(eq.Hands);
                this.Legs     = new Item(eq.Legs);
                this.Feet     = new Item(eq.Feet);
            }

            if (mode.HasFlag(SaveModes.EquipmentAccessories))
            {
                this.Ears      = new Item(eq.Ears);
                this.Neck      = new Item(eq.Neck);
                this.Wrists    = new Item(eq.Wrists);
                this.LeftRing  = new Item(eq.LeftRing);
                this.RightRing = new Item(eq.RightRing);
            }

            if (mode.HasFlag(SaveModes.AppearanceHair))
            {
                this.Hair             = ed.Appearance.Hair;
                this.EnableHighlights = ed.Appearance.EnableHighlights;
                this.HairTone         = ed.Appearance.HairTone;
                this.Highlights       = ed.Appearance.Highlights;
                this.HairTint         = ed.HairTint;
                this.HairGlow         = ed.HairGlow;
                this.HighlightTint    = ed.HighlightTint;
            }

            if (mode.HasFlag(SaveModes.AppearanceFace) || mode.HasFlag(SaveModes.AppearanceBody))
            {
                this.Race   = ed.Appearance.Race;
                this.Gender = ed.Appearance.Gender;
                this.Tribe  = ed.Appearance.Tribe;
                this.Age    = ed.Appearance.Age;
            }

            if (mode.HasFlag(SaveModes.AppearanceFace))
            {
                this.Head               = ed.Appearance.Head;
                this.REyeColor          = ed.Appearance.REyeColor;
                this.LimbalEyes         = ed.Appearance.LimbalEyes;
                this.FacialFeatures     = ed.Appearance.FacialFeatures;
                this.Eyebrows           = ed.Appearance.Eyebrows;
                this.LEyeColor          = ed.Appearance.LEyeColor;
                this.Eyes               = ed.Appearance.Eyes;
                this.Nose               = ed.Appearance.Nose;
                this.Jaw                = ed.Appearance.Jaw;
                this.Mouth              = ed.Appearance.Mouth;
                this.LipsToneFurPattern = ed.Appearance.LipsToneFurPattern;
                this.FacePaint          = ed.Appearance.FacePaint;
                this.FacePaintColor     = ed.Appearance.FacePaintColor;
                this.LeftEyeColor       = ed.LeftEyeColor;
                this.RightEyeColor      = ed.RightEyeColor;
                this.LimbalRingColor    = ed.LimbalRingColor;
                this.LipTint            = ed.LipTint;
            }

            if (mode.HasFlag(SaveModes.AppearanceBody))
            {
                this.Height            = ed.Appearance.Height;
                this.Skintone          = ed.Appearance.Skintone;
                this.EarMuscleTailSize = ed.Appearance.EarMuscleTailSize;
                this.TailEarsType      = ed.Appearance.TailEarsType;
                this.Bust     = ed.Appearance.Bust;
                this.SkinTint = ed.SkinTint;
                this.SkinGlow = ed.SkinGlow;
            }
        }