mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2024-11-10 06:41:49 +00:00
Sectors Mode: significantly increased rendering speed
This commit is contained in:
parent
5884ca770e
commit
550683daab
1 changed files with 26 additions and 7 deletions
|
@ -76,6 +76,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
BlockMap<BlockEntry> blockmap;
|
BlockMap<BlockEntry> blockmap;
|
||||||
bool addedlinedefstoblockmap;
|
bool addedlinedefstoblockmap;
|
||||||
|
|
||||||
|
// Stores sizes of the text for text labels so that they only have to be computed once
|
||||||
|
private Dictionary<string, float> textlabelsizecache;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Properties
|
#region ================== Properties
|
||||||
|
@ -89,6 +92,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
// Constructor
|
// Constructor
|
||||||
public SectorsMode()
|
public SectorsMode()
|
||||||
{
|
{
|
||||||
|
textlabelsizecache = new Dictionary<string, float>();
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
effects = new Dictionary<int, string[]>();
|
effects = new Dictionary<int, string[]>();
|
||||||
foreach(SectorEffectInfo info in General.Map.Config.SortedSectorEffects)
|
foreach(SectorEffectInfo info in General.Map.Config.SortedSectorEffects)
|
||||||
|
@ -241,18 +246,32 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
l.Color = General.Colors.InfoLine;
|
l.Color = General.Colors.InfoLine;
|
||||||
|
|
||||||
// Render only when enough space for the label to see
|
// Render only when enough space for the label to see
|
||||||
float requiredsize = (General.Interface.MeasureString(group.Value[0], l.Font).Width / 2) / renderer.Scale;
|
if (!textlabelsizecache.ContainsKey(group.Value[0]))
|
||||||
if(requiredsize > group.Key.Labels[i].radius)
|
textlabelsizecache[group.Value[0]] = General.Interface.MeasureString(group.Value[0], l.Font).Width;
|
||||||
|
|
||||||
|
float requiredsize = textlabelsizecache[group.Value[0]] / 2 / renderer.Scale;
|
||||||
|
|
||||||
|
if (requiredsize > group.Key.Labels[i].radius)
|
||||||
{
|
{
|
||||||
requiredsize = (General.Interface.MeasureString(group.Value[1], l.Font).Width / 2) / renderer.Scale;
|
if (!textlabelsizecache.ContainsKey(group.Value[1]))
|
||||||
if(requiredsize > group.Key.Labels[i].radius)
|
textlabelsizecache[group.Value[1]] = General.Interface.MeasureString(group.Value[1], l.Font).Width;
|
||||||
l.Text = (requiredsize > group.Key.Labels[i].radius * 4 ? string.Empty : "+");
|
|
||||||
|
requiredsize = textlabelsizecache[group.Value[1]] / 2 / renderer.Scale;
|
||||||
|
|
||||||
|
string newtext;
|
||||||
|
|
||||||
|
if (requiredsize > group.Key.Labels[i].radius)
|
||||||
|
newtext = (requiredsize > group.Key.Labels[i].radius * 4 ? string.Empty : "+");
|
||||||
else
|
else
|
||||||
l.Text = group.Value[1];
|
newtext = group.Value[1];
|
||||||
|
|
||||||
|
if (l.Text != newtext)
|
||||||
|
l.Text = newtext;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
l.Text = group.Value[0];
|
if(group.Value[0] != l.Text)
|
||||||
|
l.Text = group.Value[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
torender.Add(l);
|
torender.Add(l);
|
||||||
|
|
Loading…
Reference in a new issue