// This sets udmf texture offset public void SetUdmfTextureOffsetX(int offset) { this.Fields.BeforeFieldsChange(); //top if (longtexnamehigh != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(texnamehigh)) { ImageData texture = General.Map.Data.GetTextureImage(texnamehigh); double scaleTop = Fields.GetValue("scalex_top", 1.0); double value = Fields.GetValue("offsetx_top", 0.0); double result = Math.Round(value + offset * scaleTop); if (texture.IsImageLoaded) { result %= texture.Width; } UniFields.SetFloat(Fields, "offsetx_top", result); } //middle if (longtexnamemid != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(texnamemid)) { ImageData texture = General.Map.Data.GetTextureImage(texnamemid); double scaleMid = Fields.GetValue("scalex_mid", 1.0); double value = Fields.GetValue("offsetx_mid", 0.0); double result = Math.Round(value + offset * scaleMid); if (texture.IsImageLoaded) { result %= texture.Width; } UniFields.SetFloat(Fields, "offsetx_mid", result); } //bottom if (longtexnamelow != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(texnamelow)) { ImageData texture = General.Map.Data.GetTextureImage(texnamelow); double scaleLow = Fields.GetValue("scalex_bottom", 1.0); double value = Fields.GetValue("offsetx_bottom", 0.0); double result = Math.Round(value + offset * scaleLow); if (texture.IsImageLoaded) { result %= texture.Width; } UniFields.SetFloat(Fields, "offsetx_bottom", result); } }
// 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; }