Improve FOF alpha/blendmode handling

This commit is contained in:
spherallic 2024-02-10 00:38:06 +01:00
parent 1952932cc1
commit 26b0a8c6ec
1 changed files with 11 additions and 13 deletions

View File

@ -24,6 +24,7 @@ using CodeImp.DoomBuilder.Geometry;
using System.Drawing;
using System.Text.RegularExpressions;
using CodeImp.DoomBuilder.IO;
using SlimDX.DirectWrite;
#endregion
@ -819,32 +820,29 @@ namespace CodeImp.DoomBuilder.Map
//Read translucency value from texture name (#000-#255)
private int ParseTranslucency(string tex)
{
int result = 128;
if (tex.StartsWith("#"))
{
int alpha;
if (int.TryParse(tex.Substring(1, 3), out alpha) && alpha >= 0 && alpha <= 255) result = alpha;
}
return result;
if (tex.StartsWith("#") && tex.Length >= 4 && int.TryParse(tex.Substring(1, 3), out int alpha))
return General.Clamp(alpha, 0, 255);
else
return 128;
}
private bool ParseAdditive(string tex)
{
if (tex.StartsWith("#") && tex.Length >= 5)
return int.TryParse(tex.Substring(4, 1), out int value) && value == 1;
if (tex.StartsWith("#") && tex.Length >= 5 && int.TryParse(tex.Substring(4, 1), out int value))
return value == 1;
else
return false;
}
private bool ParseSubtractive(string tex)
{
if (tex.StartsWith("#") && tex.Length >= 5)
return int.TryParse(tex.Substring(4, 1), out int value) && value == 2;
if (tex.StartsWith("#") && tex.Length >= 5 && int.TryParse(tex.Substring(4, 1), out int value))
return value == 2;
else
return false;
}
private bool ParseReverseSubtractive(string tex)
{
if (tex.StartsWith("#") && tex.Length >= 5)
return int.TryParse(tex.Substring(4, 1), out int value) && value == 3;
if (tex.StartsWith("#") && tex.Length >= 5 && int.TryParse(tex.Substring(4, 1), out int value))
return value == 3;
else
return false;
}