mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2025-02-10 09:41:22 +00:00
Things Mode: increased rendering speed
This commit is contained in:
parent
d138f29cda
commit
f3cb854bbd
1 changed files with 28 additions and 9 deletions
|
@ -73,7 +73,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private Dictionary<Thing, TextLabel> labels;
|
||||
private Dictionary<Sector, TextLabel[]> sectorlabels;
|
||||
private Dictionary<Sector, string[]> sectortexts;
|
||||
|
||||
|
||||
// Stores sizes of the text for text labels so that they only have to be computed once
|
||||
private Dictionary<string, float> textlabelsizecache;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -88,6 +91,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
//mxd. Associations now requre initializing...
|
||||
highlightasso = new Association(renderer);
|
||||
|
||||
textlabelsizecache = new Dictionary<string, float>();
|
||||
}
|
||||
|
||||
//mxd
|
||||
|
@ -295,21 +300,35 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
TextLabel l = labelarray[i];
|
||||
|
||||
// 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(requiredsize > group.Key.Labels[i].radius)
|
||||
if (!textlabelsizecache.ContainsKey(group.Value[0]))
|
||||
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(requiredsize > group.Key.Labels[i].radius)
|
||||
l.Text = (requiredsize > group.Key.Labels[i].radius * 4 ? string.Empty : "+");
|
||||
if (!textlabelsizecache.ContainsKey(group.Value[1]))
|
||||
textlabelsizecache[group.Value[1]] = General.Interface.MeasureString(group.Value[1], l.Font).Width;
|
||||
|
||||
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
|
||||
l.Text = group.Value[1];
|
||||
newtext = group.Value[1];
|
||||
|
||||
if (l.Text != newtext)
|
||||
l.Text = newtext;
|
||||
}
|
||||
else
|
||||
{
|
||||
l.Text = group.Value[0];
|
||||
if (group.Value[0] != l.Text)
|
||||
l.Text = group.Value[0];
|
||||
}
|
||||
|
||||
torender.Add(l);
|
||||
if (!string.IsNullOrEmpty(l.Text)) torender.Add(l);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue