Statistics done
This commit is contained in:
parent
6fbae10750
commit
e9f230d4cc
17 changed files with 218 additions and 153 deletions
|
|
@ -53,8 +53,13 @@ public partial class Previewport : SubViewport
|
|||
var keys = GetRequestedKeys(unparsedDescription);
|
||||
FillPlaceholders(keys, resource, current_display);
|
||||
var parsedDescription = ReplaceTextUsingDict(keys, unparsedDescription);
|
||||
var rwd = Tr("rwd_" + resource.NameKey);
|
||||
if (rwd == "rwd_" + resource.NameKey)
|
||||
{
|
||||
rwd = "";
|
||||
}
|
||||
|
||||
description.Text = Tr("rwd_" + resource.NameKey) + "\n" + parsedDescription;
|
||||
description.Text = rwd + "\n" + parsedDescription;
|
||||
}
|
||||
|
||||
private Dictionary<string, float> GetRequestedKeys(string text)
|
||||
|
|
@ -105,27 +110,61 @@ public partial class Previewport : SubViewport
|
|||
}
|
||||
|
||||
foreach (var key in placeholderDictionary.Keys)
|
||||
{
|
||||
string modifiers = "";
|
||||
string request = key.Split('|')[0];
|
||||
if (key.Split('|').Length == 2)
|
||||
{
|
||||
var namePropertyPair = key.Split('.');
|
||||
Variant property;
|
||||
if (namePropertyPair.Length == 2)
|
||||
{
|
||||
if ((namePropertyPair[0] == "?" && lookedObject != searchScene)||(namePropertyPair[0] != "?" && lookedObject is Node node && node.Name != namePropertyPair[0]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
property = lookedObject.Get(namePropertyPair[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
property = lookedObject.Get(namePropertyPair[0]);
|
||||
}
|
||||
if (property.VariantType == Variant.Type.Nil)
|
||||
modifiers = key.Split('|')[1];
|
||||
}
|
||||
var namePropertyPair = request.Split('.');
|
||||
Variant property;
|
||||
if (namePropertyPair.Length == 2)
|
||||
{
|
||||
if ((namePropertyPair[0] == "?" && lookedObject != searchScene)||(namePropertyPair[0] != "?" && lookedObject is Node node && node.Name != namePropertyPair[0]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
placeholderDictionary[key] = property.As<float>();
|
||||
property = lookedObject.Get(namePropertyPair[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
property = lookedObject.Get(namePropertyPair[0]);
|
||||
}
|
||||
if (property.VariantType == Variant.Type.Nil)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
float value = property.As<float>();
|
||||
|
||||
if (modifiers != "")
|
||||
{
|
||||
foreach (var c in modifiers)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '%':
|
||||
value *= 100;
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
value *= c - '0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
placeholderDictionary[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
private string ReplaceTextUsingDict(Dictionary<string, float> dictionary, string text)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue