Esempio n. 1
0
        /// <summary>
        /// Handles the GlobalApply it. Applies all altered data to their
        /// <c>structs</c>.
        /// </summary>
        /// <param name="sender">
        /// <list type="bullet">
        /// <item><c><see cref="it_ApplyGlobal"/></c></item>
        /// <item><c><see cref="it_Save"/></c></item>
        /// <item><c><see cref="it_Saveas"/></c></item>
        /// </list></param>
        /// <param name="e"></param>
        /// <remarks>See <c><see cref="Click_apply()">Click_apply()</see></c> to
        /// apply altered data to only the selected <c>struct</c>.</remarks>
        void Click_applyGlobal(object sender, EventArgs e)
        {
            SetTitleText();             // TitleText will be written again (properly) by Write2daFile() if saved.

            it_ApplyGlobal.Enabled = false;

            int total;

            switch (Type)
            {
            case Type2da.Spells:
            {
                Spell spell;

                total = Spells.Count;
                for (int id = 0; id != total; ++id)
                {
                    spell = Spells[id];

                    if (spell.differ != control_Spells.bit_clean)
                    {
                        spell.differ    = control_Spells.bit_clean;
                        spell.isChanged = true;                                 // this flag will be cleared by Write2daFile()

                        SpellChanged spellchanged = SpellsChanged[id];

                        spell.spellinfo    = spellchanged.spellinfo;
                        spell.targetinfo   = spellchanged.targetinfo;
                        spell.effectweight = spellchanged.effectweight;
                        spell.effecttypes  = spellchanged.effecttypes;
                        spell.damageinfo   = spellchanged.damageinfo;
                        spell.savetype     = spellchanged.savetype;
                        spell.savedctype   = spellchanged.savedctype;

                        Spells[id] = spell;

                        SpellsChanged.Remove(id);

                        if (id == Id)                                 // is currently selected tree-node
                        {
                            HenchControl.SetResetColor(DefaultForeColor);
                            AfterSelect_node(null, null);                                     // refresh all displayed data for the current spell jic
                        }

                        Tree.Nodes[id].ForeColor = Color.Blue;
                    }
                }
                break;
            }

            case Type2da.Racial:
            {
                Race race;

                total = Races.Count;
                for (int id = 0; id != total; ++id)
                {
                    race = Races[id];

                    if (race.differ != control_Racial.bit_clean)
                    {
                        race.differ    = control_Racial.bit_clean;
                        race.isChanged = true;                                 // this flag will be cleared by Write2daFile()

                        RaceChanged racechanged = RacesChanged[id];

                        race.flags = racechanged.flags;
                        race.feat1 = racechanged.feat1;
                        race.feat2 = racechanged.feat2;
                        race.feat3 = racechanged.feat3;
                        race.feat4 = racechanged.feat4;
                        race.feat5 = racechanged.feat5;

                        Races[id] = race;

                        RacesChanged.Remove(id);

                        if (id == Id)                                 // is currently selected tree-node
                        {
                            HenchControl.SetResetColor(DefaultForeColor);
                            AfterSelect_node(null, null);                                     // refresh all displayed data for the current race jic
                        }

                        Tree.Nodes[id].ForeColor = Color.Blue;
                    }
                }
                break;
            }

            case Type2da.Classes:
            {
                Class @class;

                total = Classes.Count;
                for (int id = 0; id != total; ++id)
                {
                    @class = Classes[id];

                    if (@class.differ != control_Classes.bit_clean)
                    {
                        @class.differ    = control_Classes.bit_clean;
                        @class.isChanged = true;                                 // this flag will be cleared by Write2daFile()

                        ClassChanged classchanged = ClassesChanged[id];

                        @class.flags  = classchanged.flags;
                        @class.feat1  = classchanged.feat1;
                        @class.feat2  = classchanged.feat2;
                        @class.feat3  = classchanged.feat3;
                        @class.feat4  = classchanged.feat4;
                        @class.feat5  = classchanged.feat5;
                        @class.feat6  = classchanged.feat6;
                        @class.feat7  = classchanged.feat7;
                        @class.feat8  = classchanged.feat8;
                        @class.feat9  = classchanged.feat9;
                        @class.feat10 = classchanged.feat10;
                        @class.feat11 = classchanged.feat11;

                        Classes[id] = @class;

                        ClassesChanged.Remove(id);

                        if (id == Id)                                 // is currently selected tree-node
                        {
                            HenchControl.SetResetColor(DefaultForeColor);
                            AfterSelect_node(null, null);                                     // refresh all displayed data for the current class jic
                        }

                        Tree.Nodes[id].ForeColor = Color.Blue;
                    }
                }
                break;
            }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// This funct is used only for
        /// <c><see cref="Click_clearCoreAiVersion()">Click_clearCoreAiVersion()</see></c>.
        /// </summary>
        /// <param name="str"></param>
        /// <param name="all"><c>true</c> to apply version to all classes else
        /// apply to changed classes only</param>
        /// <remarks>Used to be a helper for <c>Click_setCoreAiVersion()</c>.</remarks>
        void SetInfoVersion_classes(string str, bool all)
        {
            Class        @class;
            ClassChanged classchanged;

            int  classflags0, classflags, differ;
            bool dirty;

            int ver = (Int32.Parse(str) << HENCH_SPELL_INFO_VERSION_SHIFT);                     // the return from the dialog.


            int total = Classes.Count;

            for (int id = 0; id != total; ++id)
            {
                @class = Classes[id];

                if (dirty = ((@class.differ & control_Classes.bit_flags) != 0))
                {
                    classflags0 = ClassesChanged[id].flags;
                }
                else if (all || @class.isChanged)
                {
                    classflags0 = @class.flags;
                }
                else
                {
                    continue;                                                                                                                           // ignore clean class-structs if !all
                }
                if ((classflags0 & hc.HENCH_SPELL_INFO_VERSION_MASK) != ver)
                {
                    if (!BypassInfoVersion)
                    {
                        classflags = ((classflags0 & ~hc.HENCH_SPELL_INFO_VERSION_MASK) | ver);
                    }
                    else
                    {
                        classflags = (classflags0 & ~hc.HENCH_SPELL_INFO_VERSION_MASK);                          // wipe version info for TonyAI 2.3+
                    }
                    if (id == Id)
                    {
                        HenchControl.SetMasterText(classflags.ToString());                                      // firing the TextChanged event takes care of it.
                    }
                    else
                    {
                        if (dirty)
                        {
                            classchanged = ClassesChanged[id];
                        }
                        else
                        {
                            classchanged = new ClassChanged();

                            classchanged.feat1  = @class.feat1;
                            classchanged.feat2  = @class.feat2;
                            classchanged.feat3  = @class.feat3;
                            classchanged.feat4  = @class.feat4;
                            classchanged.feat5  = @class.feat5;
                            classchanged.feat6  = @class.feat6;
                            classchanged.feat7  = @class.feat7;
                            classchanged.feat8  = @class.feat8;
                            classchanged.feat9  = @class.feat9;
                            classchanged.feat10 = @class.feat10;
                            classchanged.feat11 = @class.feat11;
                        }

                        classchanged.flags = classflags;

                        // check it
                        differ        = control_Classes.ClassDiffer(@class, classchanged);
                        @class.differ = differ;
                        Classes[id]   = @class;

                        Color color;
                        if (differ != control_Classes.bit_clean)
                        {
                            ClassesChanged[id] = classchanged;
                            color = Color.Crimson;
                        }
                        else
                        {
                            ClassesChanged.Remove(id);

                            if (@class.isChanged)
                            {
                                color = Color.Blue;
                            }
                            else
                            {
                                color = DefaultForeColor;
                            }
                        }
                        Tree.Nodes[id].ForeColor = color;
                    }
                }
            }
        }