mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 22:41:46 +00:00
"Raise" and "Lower Floor/Ceiling to adjacent sector" actions: when the action is not able to find suitable height from the elements of the same type, element of opposite type is used instead (damn that's cryptic :) ). Example: when no ceiling lower than lowest in selection was found while lowering selected ceilings, highest floor height of sectors, selected ceilings belong to, will be used instead. Even shorter: these actions can now be used to "close" and "open" doors quickly.
This commit is contained in:
parent
bf2f520a8e
commit
55fb9f872d
3 changed files with 42 additions and 33 deletions
|
@ -75,7 +75,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
reader.ReadInt16();
|
||||
|
||||
// Valid width and height?
|
||||
if((width <= 0) || (height <= 0)) return false;
|
||||
if(width < 1 || height < 1) return false;
|
||||
|
||||
// Go for all columns
|
||||
for(int x = 0; x < width; x++)
|
||||
|
|
|
@ -146,7 +146,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
private const int IL_UTX = 0x0451; //!< Unreal (and Unreal Tournament) Texture - .utx extension
|
||||
private const int IL_MP3 = 0x0452; //!< MPEG-1 Audio Layer 3 - .mp3 extension*/
|
||||
|
||||
private const int IL_JASC_PAL = 0x0475; //!< PaintShop Pro Palette
|
||||
//private const int IL_JASC_PAL = 0x0475; //!< PaintShop Pro Palette
|
||||
|
||||
|
||||
// Error Types
|
||||
|
|
|
@ -1827,6 +1827,31 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//process floors...
|
||||
int maxSelectedHeight = int.MinValue;
|
||||
int minSelectedCeilingHeight = int.MaxValue;
|
||||
int targetCeilingHeight = int.MaxValue;
|
||||
|
||||
//get highest ceiling height from selection
|
||||
foreach(KeyValuePair<Sector, VisualCeiling> group in ceilings) {
|
||||
if(group.Key.CeilHeight > maxSelectedHeight)
|
||||
maxSelectedHeight = group.Key.CeilHeight;
|
||||
}
|
||||
|
||||
if(withinSelection) {
|
||||
//we are raising, so we don't need to check anything
|
||||
targetCeilingHeight = maxSelectedHeight;
|
||||
} else {
|
||||
//get next higher ceiling from surrounding unselected sectors
|
||||
foreach(KeyValuePair<Sector, VisualCeiling> group in ceilings) {
|
||||
foreach(Sidedef side in group.Key.Sidedefs) {
|
||||
if(side.Other == null || ceilings.ContainsKey(side.Other.Sector) || floors.ContainsKey(side.Other.Sector))
|
||||
continue;
|
||||
if(side.Other.Sector.CeilHeight < targetCeilingHeight && side.Other.Sector.CeilHeight > maxSelectedHeight)
|
||||
targetCeilingHeight = side.Other.Sector.CeilHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//ceilings...
|
||||
maxSelectedHeight = int.MinValue;
|
||||
int targetFloorHeight = int.MaxValue;
|
||||
|
||||
//get maximum floor and minimum ceiling heights from selection
|
||||
|
@ -1858,36 +1883,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
|
||||
//ceilings...
|
||||
maxSelectedHeight = int.MinValue;
|
||||
int targetCeilingHeight = int.MaxValue;
|
||||
|
||||
//get highest ceiling height from selection
|
||||
foreach(KeyValuePair<Sector, VisualCeiling> group in ceilings) {
|
||||
if(group.Key.CeilHeight > maxSelectedHeight)
|
||||
maxSelectedHeight = group.Key.CeilHeight;
|
||||
}
|
||||
|
||||
if(withinSelection) {
|
||||
//we are raising, so we don't need to check anything
|
||||
targetCeilingHeight = maxSelectedHeight;
|
||||
} else {
|
||||
//get next higher ceiling from surrounding unselected sectors
|
||||
foreach(KeyValuePair<Sector, VisualCeiling> group in ceilings) {
|
||||
foreach(Sidedef side in group.Key.Sidedefs) {
|
||||
if(side.Other == null || ceilings.ContainsKey(side.Other.Sector) || floors.ContainsKey(side.Other.Sector))
|
||||
continue;
|
||||
if(side.Other.Sector.CeilHeight < targetCeilingHeight && side.Other.Sector.CeilHeight > maxSelectedHeight)
|
||||
targetCeilingHeight = side.Other.Sector.CeilHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//CHECK VALUES
|
||||
string alignFailDescription = string.Empty;
|
||||
|
||||
if(floors.Count > 0 && targetFloorHeight == int.MaxValue)
|
||||
alignFailDescription = floors.Count > 1 ? "floors" : "floor";
|
||||
if (floors.Count > 0 && targetFloorHeight == int.MaxValue) {
|
||||
//raise to lowest ceiling?
|
||||
if(!withinSelection && minSelectedCeilingHeight > maxSelectedHeight) {
|
||||
targetFloorHeight = minSelectedCeilingHeight;
|
||||
} else {
|
||||
alignFailDescription = floors.Count > 1 ? "floors" : "floor";
|
||||
}
|
||||
}
|
||||
|
||||
if(ceilings.Count > 0 && targetCeilingHeight == int.MaxValue) {
|
||||
if(!string.IsNullOrEmpty(alignFailDescription))
|
||||
|
@ -2056,10 +2062,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
alignFailDescription = floors.Count > 1 ? "floors" : "floor";
|
||||
|
||||
if(ceilings.Count > 0 && targetCeilingHeight == int.MinValue) {
|
||||
if(!string.IsNullOrEmpty(alignFailDescription))
|
||||
alignFailDescription += " and ";
|
||||
|
||||
alignFailDescription += ceilings.Count > 1 ? "ceilings" : "ceiling";
|
||||
//drop to highest floor?
|
||||
if(!withinSelection && maxSelectedFloorHeight < minSelectedHeight) {
|
||||
targetCeilingHeight = maxSelectedFloorHeight;
|
||||
} else {
|
||||
if (!string.IsNullOrEmpty(alignFailDescription)) alignFailDescription += " and ";
|
||||
alignFailDescription += ceilings.Count > 1 ? "ceilings" : "ceiling";
|
||||
}
|
||||
}
|
||||
|
||||
if(!string.IsNullOrEmpty(alignFailDescription)) {
|
||||
|
|
Loading…
Reference in a new issue