// Edit button released
        public void OnEditEnd()
        {
            if (General.Interface.IsActiveWindow)
            {
                List <Thing> things = mode.GetSelectedThings();
                //mxd
                updateList = new List <BaseVisualThing>();
                foreach (Thing t in things)
                {
                    VisualThing vt = mode.GetVisualThing(t);
                    if (vt != null)
                    {
                        updateList.Add((BaseVisualThing)vt);
                    }
                }

                General.Interface.OnEditFormValuesChanged += Interface_OnEditFormValuesChanged;
                mode.StartRealtimeInterfaceUpdate(SelectionType.Things);
                General.Interface.ShowEditThings(things);
                mode.StopRealtimeInterfaceUpdate(SelectionType.Things);
                General.Interface.OnEditFormValuesChanged -= Interface_OnEditFormValuesChanged;

                updateList.Clear();
                updateList = null;
            }
        }
예제 #2
0
        // This shows the picked target information
        public void ShowTargetInfo()
        {
            // Any result?
            if (target.picked != null)
            {
                // Geometry picked?
                if (target.picked is VisualGeometry)
                {
                    VisualGeometry pickedgeo = (target.picked as VisualGeometry);

                    if (pickedgeo.Sidedef != null)
                    {
                        General.Interface.ShowLinedefInfo(pickedgeo.Sidedef.Line);
                    }
                    else if (pickedgeo.Sidedef == null)
                    {
                        General.Interface.ShowSectorInfo(pickedgeo.Sector.Sector);
                    }
                    else
                    {
                        General.Interface.HideInfo();
                    }
                }
                // Thing picked?
                if (target.picked is VisualThing)
                {
                    VisualThing pickedthing = (target.picked as VisualThing);
                    General.Interface.ShowThingInfo(pickedthing.Thing);
                }
            }
            else
            {
                General.Interface.HideInfo();
            }
        }
예제 #3
0
 // Edit button released
 public virtual void OnEditEnd()
 {
     if (General.Interface.IsActiveWindow)
     {
         List <Thing> things = mode.GetSelectedThings();
         DialogResult result = General.Interface.ShowEditThings(things);
         if (result == DialogResult.OK)
         {
             foreach (Thing t in things)
             {
                 VisualThing vt = mode.GetVisualThing(t);
                 if (vt != null)
                 {
                     (vt as BaseVisualThing).Changed = true;
                 }
             }
         }
     }
 }
예제 #4
0
        // This collects a visual sector's geometry for rendering
        public void AddThingGeometry(VisualThing t)
        {
            // Make sure the distance to camera is calculated
            t.CalculateCameraDistance(cameraposition);
            thingsbydistance.Add(t);

            // Must have a texture!
            if (t.Texture != null)
            {
                // Texture group not yet collected?
                if (!things[t.RenderPassInt].ContainsKey(t.Texture))
                {
                    // Create texture group
                    things[t.RenderPassInt].Add(t.Texture, new List <VisualThing>());
                }

                // Add geometry to texture group
                things[t.RenderPassInt][t.Texture].Add(t);
            }
        }
예제 #5
0
 // Edit button released
 public virtual void OnEditEnd()
 {
     // Not using any modifier buttons
     if (!General.Interface.ShiftState && !General.Interface.CtrlState && !General.Interface.AltState)
     {
         if (General.Interface.IsActiveWindow)
         {
             List <Thing> things = mode.GetSelectedThings();
             DialogResult result = General.Interface.ShowEditThings(things);
             if (result == DialogResult.OK)
             {
                 foreach (Thing t in things)
                 {
                     VisualThing vt = mode.GetVisualThing(t);
                     if (vt != null)
                     {
                         (vt as BaseVisualThing).Changed = true;
                     }
                 }
             }
         }
     }
 }
예제 #6
0
        internal static float GetLowerThingZ(BaseVisualMode mode, SectorData sd, VisualThing thing)
        {
            Vector3D pos         = thing.Thing.Position;
            float    thingheight = thing.Thing.Height;
            bool     absolute    = thing.Info.AbsoluteZ;
            bool     hangs       = thing.Info.Hangs;

            if (absolute && hangs)
            {
                General.Interface.DisplayStatus(StatusType.Warning, "Sorry, can't have both 'absolute' and 'hangs' flags...");
                return(pos.z);
            }

            // Get things, which bounding boxes intersect with target thing
            IEnumerable <Thing> intersectingthings = GetIntersectingThings(mode, thing.Thing);

            float fz = (absolute ? 0 : sd.Floor.plane.GetZ(pos));
            float cz = sd.Ceiling.plane.GetZ(pos);

            if (hangs)
            {
                // Transform to floor-aligned position
                Vector3D floorpos    = new Vector3D(pos, (cz - fz) - pos.z - thingheight);
                float    lowertingz  = GetNextLowerThingZ(mode, intersectingthings, floorpos.z, thingheight);
                float    lowerfloorz = float.MaxValue;

                // Do it only when there are extrafloors
                if (sd.LightLevels.Count > 2)
                {
                    // Unlike sd.ExtraFloors, these are sorted by height
                    for (int i = sd.LightLevels.Count - 1; i > -1; i--)
                    {
                        SectorLevel level = sd.LightLevels[i];
                        if (level.type == SectorLevelType.Light || level.type == SectorLevelType.Glow)
                        {
                            continue;                                                                                                   // Skip lights and glows
                        }
                        float z = level.plane.GetZ(floorpos) - fz;
                        if (level.type == SectorLevelType.Ceiling)
                        {
                            z -= thingheight;
                        }
                        if (z < floorpos.z)
                        {
                            lowerfloorz = z;
                            break;
                        }
                    }
                }

                float floorz = cz - fz;                 // Floor height when counted from ceiling

                if (lowerfloorz != float.MaxValue && lowertingz != float.MinValue)
                {
                    // Transform back to ceiling-aligned position
                    return(cz - fz - Math.Min(Math.Max(lowerfloorz, lowertingz), floorz) - thingheight);
                }

                if (lowerfloorz != float.MaxValue)
                {
                    // Transform back to ceiling-aligned position
                    return(cz - fz - Math.Min(lowerfloorz, floorz) - thingheight);
                }

                if (lowertingz != float.MinValue)
                {
                    // Transform back to ceiling-aligned position
                    return(cz - fz - Math.Min(lowertingz, floorz) - thingheight);
                }

                return(floorz - thingheight);                // Align to real floor
            }
            else
            {
                float lowertingz  = GetNextLowerThingZ(mode, intersectingthings, (absolute ? pos.z - fz : pos.z), thingheight);
                float lowerfloorz = float.MaxValue;

                // Do it only when there are extrafloors
                if (sd.LightLevels.Count > 2)
                {
                    // Unlike sd.ExtraFloors, these are sorted by height
                    for (int i = sd.LightLevels.Count - 1; i > -1; i--)
                    {
                        SectorLevel level = sd.LightLevels[i];
                        if (level.type == SectorLevelType.Light || level.type == SectorLevelType.Glow)
                        {
                            continue;                                                                                                   // Skip lights and glows
                        }
                        float z = level.plane.GetZ(pos) - fz;
                        if (level.type == SectorLevelType.Ceiling)
                        {
                            z -= thingheight;
                        }
                        if (z < pos.z)
                        {
                            lowerfloorz = z;
                            break;
                        }
                    }
                }

                float floorz   = sd.Floor.plane.GetZ(pos);               // Floor-aligned relative target thing z
                float floorpos = 0;

                if (lowerfloorz != float.MaxValue && lowertingz != float.MinValue)
                {
                    floorpos = Math.Max(Math.Max(lowerfloorz, lowertingz), floorz);
                }
                if (lowerfloorz != float.MaxValue)
                {
                    floorpos = Math.Max(lowerfloorz, floorz);
                }
                if (lowertingz != float.MinValue)
                {
                    floorpos = Math.Max(lowertingz, floorz);
                }

                return(absolute ? floorpos + floorz : floorpos);                  // Convert to absolute position if necessary
            }
        }
예제 #7
0
        internal static double GetHigherThingZ(BaseVisualMode mode, SectorData sd, VisualThing thing)
        {
            Vector3D pos         = thing.Thing.Position;
            double   thingheight = thing.Thing.Height;
            bool     absolute    = thing.Info.AbsoluteZ;
            bool     hangs       = thing.Info.Hangs;

            if (absolute && hangs)
            {
                General.Interface.DisplayStatus(StatusType.Warning, "Sorry, can't have both 'absolute' and 'hangs' flags...");
                return(pos.z);
            }

            // Get things, which bounding boxes intersect with target thing
            IEnumerable <Thing> intersectingthings = GetIntersectingThings(mode, thing.Thing);

            double fz = (absolute ? 0 : sd.Floor.plane.GetZ(pos));
            double cz = sd.Ceiling.plane.GetZ(pos);

            if (hangs)
            {
                // Transform to floor-aligned position
                Vector3D floorpos     = new Vector3D(pos, (cz - fz) - pos.z - thingheight);
                double   highertingz  = GetNextHigherThingZ(mode, intersectingthings, floorpos.z, thingheight);
                double   higherfloorz = double.MinValue;

                // Do it only when there are extrafloors
                if (sd.LightLevels.Count > 2)
                {
                    // Unlike sd.ExtraFloors, these are sorted by height
                    foreach (SectorLevel level in sd.LightLevels)
                    {
                        if (level.type == SectorLevelType.Light || level.type == SectorLevelType.Glow)
                        {
                            continue;                                                                                                   // Skip lights and glows
                        }
                        double z = level.plane.GetZ(floorpos) - fz;
                        if (level.type == SectorLevelType.Ceiling)
                        {
                            z -= thingheight;
                        }
                        if (z > floorpos.z)
                        {
                            higherfloorz = z;
                            break;
                        }
                    }
                }

                if (higherfloorz != float.MinValue && highertingz != float.MaxValue)
                {
                    // Transform back to ceiling-aligned position
                    return(cz - fz - Math.Max(Math.Min(higherfloorz, highertingz), 0) - thingheight);
                }

                if (higherfloorz != float.MinValue)
                {
                    // Transform back to ceiling-aligned position
                    return(Math.Max(cz - fz - higherfloorz - thingheight, 0));
                }

                if (highertingz != float.MaxValue)
                {
                    // Transform back to ceiling-aligned position
                    return(Math.Max(cz - fz - highertingz - thingheight, 0));
                }

                return(0);                // Align to real ceiling
            }
            else
            {
                double highertingz  = GetNextHigherThingZ(mode, intersectingthings, (absolute ? pos.z - fz : pos.z), thingheight);
                double higherfloorz = double.MinValue;

                // Do it only when there are extrafloors
                if (sd.LightLevels.Count > 2)
                {
                    // Unlike sd.ExtraFloors, these are sorted by height
                    foreach (SectorLevel level in sd.LightLevels)
                    {
                        if (level.type == SectorLevelType.Light || level.type == SectorLevelType.Glow)
                        {
                            continue;                                                                                                   // Skip lights and glows
                        }
                        double z = level.plane.GetZ(pos) - fz;
                        if (level.type == SectorLevelType.Ceiling)
                        {
                            z -= thingheight;
                        }
                        if (z > pos.z)
                        {
                            higherfloorz = z;
                            break;
                        }
                    }
                }

                double floorz  = sd.Floor.plane.GetZ(pos);
                double ceilpos = cz - floorz - thingheight;                 // Ceiling-aligned relative target thing z

                if (higherfloorz != double.MinValue && highertingz != double.MaxValue)
                {
                    ceilpos = Math.Min(ceilpos, Math.Min(higherfloorz, highertingz));
                }
                if (higherfloorz != double.MinValue)
                {
                    ceilpos = Math.Min(ceilpos, higherfloorz);
                }
                if (highertingz != double.MaxValue)
                {
                    ceilpos = Math.Min(ceilpos, highertingz);
                }

                return(absolute ? ceilpos + floorz : ceilpos);                  // Convert to absolute position if necessary
            }
        }