예제 #1
0
 // String
 public static void SetString(UniFields fields, string key, string value, string defaultvalue)
 {
     if (fields == null)
     {
         return;
     }
     if (value != defaultvalue)
     {
         if (!fields.ContainsKey(key))
         {
             fields.Add(key, new UniValue(UniversalType.String, value));
         }
         else
         {
             fields[key].Value = value;
         }
     }
     // Don't save default value
     else if (fields.ContainsKey(key))
     {
         fields.Remove(key);
     }
 }
예제 #2
0
        //mxd. This translates UDMF fields back into the normal flags and activations
        internal void TranslateFromUDMF()
        {
            // Try to translate UDMF texture offsets to regular ones
            if (longtexnamemid != MapSet.EmptyLongName && MiddleRequired())
            {
                offsetx += (int)UniFields.GetFloat(this.Fields, "offsetx_mid");
                offsety += (int)UniFields.GetFloat(this.Fields, "offsety_mid");
            }
            else if (longtexnamehigh != MapSet.EmptyLongName && HighRequired())
            {
                offsetx += (int)UniFields.GetFloat(this.Fields, "offsetx_top");
                offsety += (int)UniFields.GetFloat(this.Fields, "offsety_top");
            }
            else if (longtexnamelow != MapSet.EmptyLongName && LowRequired())
            {
                offsetx += (int)UniFields.GetFloat(this.Fields, "offsetx_bottom");
                offsety += (int)UniFields.GetFloat(this.Fields, "offsety_bottom");
            }

            // Clear UDMF-related properties
            this.Fields.Clear();
            this.Flags.Clear();
        }
예제 #3
0
 /// <summary>This compares types and values of given UniFields by 2 keys. Returns true when both values match.</summary>
 public static bool ValuesMatch(string key1, string key2, UniFields fields1, UniFields fields2)
 {
     return(ValuesMatch(key1, fields1, fields2) && ValuesMatch(key2, fields1, fields2));
 }
예제 #4
0
 public static int GetInteger(UniFields fields, string key)
 {
     return(GetInteger(fields, key, 0));
 }
예제 #5
0
 // int
 public static void SetInteger(UniFields fields, string key, int value)
 {
     SetInteger(fields, key, value, 0);
 }
예제 #6
0
 public static float GetFloat(UniFields fields, string key)
 {
     return(GetFloat(fields, key, 0f));
 }
예제 #7
0
 // float
 public static void SetFloat(UniFields fields, string key, float value)
 {
     SetFloat(fields, key, value, 0f);
 }
예제 #8
0
 // Constructor
 internal MapElement()
 {
     // Initialize
     fields = new UniFields(this);
 }
예제 #9
0
 // Copy constructor
 ///<summary></summary>
 public UniFields(MapElement owner, UniFields copyfrom) : base(copyfrom)
 {
     this.owner = owner;
 }
예제 #10
0
        // This copies textures to another sidedef
        // And possibly also the offsets
        public void AddTexturesTo(Sidedef s)
        {
            int copyoffsets = 0;

            // s cannot be null
            if (s == null)
            {
                return;
            }

            s.BeforePropsChange();

            // Upper texture set?
            if ((texnamehigh.Length > 0) && (texnamehigh != "-"))
            {
                // Copy upper texture
                s.texnamehigh     = texnamehigh;
                s.longtexnamehigh = longtexnamehigh;

                // Counts as a half coice for copying offsets
                copyoffsets += 1;

                //mxd. Also copy UDMF offsets and scale
                if (General.Map.UDMF)
                {
                    UniFields.SetFloat(s.Fields, "offsetx_top", Fields.GetValue("offsetx_top", 0.0), 0.0);
                    UniFields.SetFloat(s.Fields, "offsety_top", Fields.GetValue("offsety_top", 0.0), 0.0);
                    UniFields.SetFloat(s.Fields, "scalex_top", Fields.GetValue("scalex_top", 1.0), 1.0);
                    UniFields.SetFloat(s.Fields, "scaley_top", Fields.GetValue("scaley_top", 1.0), 1.0);
                }
            }

            // Middle texture set?
            if ((texnamemid.Length > 0) && (texnamemid != "-"))
            {
                // Copy middle texture
                s.texnamemid     = texnamemid;
                s.longtexnamemid = longtexnamemid;

                // Counts for copying offsets
                copyoffsets += 2;

                //mxd. Also copy UDMF offsets and scale
                if (General.Map.UDMF)
                {
                    UniFields.SetFloat(s.Fields, "offsetx_mid", Fields.GetValue("offsetx_mid", 0.0), 0.0);
                    UniFields.SetFloat(s.Fields, "offsety_mid", Fields.GetValue("offsety_mid", 0.0), 0.0);
                    UniFields.SetFloat(s.Fields, "scalex_mid", Fields.GetValue("scalex_mid", 1.0), 1.0);
                    UniFields.SetFloat(s.Fields, "scaley_mid", Fields.GetValue("scaley_mid", 1.0), 1.0);
                }
            }

            // Lower texture set?
            if ((texnamelow.Length > 0) && (texnamelow != "-"))
            {
                // Copy middle texture
                s.texnamelow     = texnamelow;
                s.longtexnamelow = longtexnamelow;

                // Counts as a half coice for copying offsets
                copyoffsets += 1;

                //mxd. Also copy UDMF offsets and scale
                if (General.Map.UDMF)
                {
                    UniFields.SetFloat(s.Fields, "offsetx_bottom", Fields.GetValue("offsetx_bottom", 0.0), 0.0);
                    UniFields.SetFloat(s.Fields, "offsety_bottom", Fields.GetValue("offsety_bottom", 0.0), 0.0);
                    UniFields.SetFloat(s.Fields, "scalex_bottom", Fields.GetValue("scalex_bottom", 1.0), 1.0);
                    UniFields.SetFloat(s.Fields, "scaley_bottom", Fields.GetValue("scaley_bottom", 1.0), 1.0);
                }
            }

            // Copy offsets also?
            if (copyoffsets >= 2)
            {
                // Copy offsets
                s.offsetx = offsetx;
                s.offsety = offsety;
            }

            General.Map.IsChanged = true;
        }
예제 #11
0
        // ano - used for swapping indices, sort of,
        // except not really, because we're really swapping
        // all the data of the linedef.
        // the reason for this approach is related to
        // architectural complications
        // with the way the undo system works.
        public void SwapProperties(Linedef l)
        {
            l.BeforePropsChange();
            BeforePropsChange();

            // ano - a bit ugly, but i don't see a better solution
            // because of the inability to make a Linedef that
            // is not a part of the MapSet and doesn't pollute
            // the undo state either
            int tempaction = l.action;

            int[] tempargs = l.args;
            Dictionary <string, bool> tempflags = l.flags;
            int       temptag            = l.tag;
            int       tempactivate       = l.activate;
            bool      tempimpassableflag = l.impassableflag;
            bool      tempblocksoundflag = l.blocksoundflag;
            UniFields tempfields         = l.fields;

            l.fields         = fields;
            l.action         = action;
            l.args           = args;
            l.flags          = flags;
            l.tag            = tag;
            l.activate       = activate;
            l.impassableflag = impassableflag;
            l.blocksoundflag = blocksoundflag;

            action         = tempaction;
            args           = tempargs;
            flags          = tempflags;
            tag            = temptag;
            activate       = tempactivate;
            impassableflag = tempimpassableflag;
            blocksoundflag = tempblocksoundflag;
            fields         = tempfields;

            // ano - ok so we have a choice here
            // choice 1: add selection groups to the undo manager
            // choice 2: swapping linedef indices does not swap the selection
            //           group, meaning the selection group appears to "swap"
            // choice 3: swapping linedef indices DOES swap, making it appear
            //           normal, until you undo, which does not revert that,
            //           making it appear to swap on undo.

            // choice 2 & 3 essentially appear to the enduser as bugs (yuck)
            // but i really do not have the energy to deal with choice 1 at
            // this time, and i'm unsure of the larger architectural
            // consquences. also. a quick poll of discord shows that mappers
            // seems unaware that the selection group feature exists??
            // (need to examine if this is just bad discoverability,
            // or if it's just actually not very useful?)

            // so for now we are doing choice #3
            l.SwapSelectionGroup(this);

            // flipping this boolean makes sure that we
            // vertices don't get auto deleted when we detach them
            // (i would not have architected this with this pseudo-global)
            bool oldautoremove = General.Map.Map.AutoRemove;

            General.Map.Map.AutoRemove = false;

            // note that calling setstartvertex / setendvertex handles setting updateneeded
            Vertex tempstart = start;

            SetStartVertex(l.start);
            l.SetStartVertex(tempstart);

            Vertex tempend = end;

            SetEndVertex(l.end);
            l.SetEndVertex(tempend);

            // have to record before detaching and call Attach P version
            // because otherwise detaching wont record undo correctly
            Sidedef tempfront = front;

            General.Map.UndoRedo.RecRefLinedefFront(l);
            AttachFront(l.front);
            l.AttachFrontP(tempfront);

            Sidedef tempback = back;

            General.Map.UndoRedo.RecRefLinedefBack(l);
            AttachBack(l.back);
            l.AttachBackP(tempback);


            General.Map.Map.AutoRemove = oldautoremove;
        }
예제 #12
0
 public static double GetFloat(UniFields fields, string key)
 {
     return(GetFloat(fields, key, 0.0));
 }
예제 #13
0
 // float
 public static void SetFloat(UniFields fields, string key, double value)
 {
     SetFloat(fields, key, value, 0.0);
 }