Skip to content

Commit

Permalink
Hack to get z:Lang working again, hack is that it can only return the…
Browse files Browse the repository at this point in the history
… first conditional result, irrespective of the condition result.
  • Loading branch information
Keflon committed Feb 26, 2024
1 parent 9ef8180 commit 2264ce8
Showing 1 changed file with 35 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using FunctionZero.ExpressionParserZero.BackingStore;
using FunctionZero.ExpressionParserZero.Evaluator;
using System.ComponentModel;
using static System.Net.Mime.MediaTypeNames;

namespace FunctionZero.Maui.MarkupExtensions
{
Expand Down Expand Up @@ -62,6 +63,27 @@ object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
public static readonly BindableProperty LookupProperty =
BindableProperty.CreateAttached("Lookup", typeof(List<List<(ExpressionTree, string)>>), typeof(Element), null, BindingMode.OneWay, null, LookupPropertyChanged);

//private static void LookupPropertyChanged(BindableObject bindable, object oldValue, object newValue)
//{
// var langHost = GetLangHost(bindable);

// List<List<(ExpressionTree, string)>> lookup = GetLookup(bindable);
// if (lookup != null)
// {
// string to = "???";
// if (lookup.Count > (int)(object)langHost.TextId)
// {
// List<(ExpressionTree, string)> thing = lookup[(int)(object)langHost.TextId];
// to = lookup[(int)(object)langHost.TextId];
// }
// if (langHost.ShowOff)
// CrossFadeText(langHost, to);
// else
// langHost.Text = GetLookup(bindable)[(int)(object)langHost.TextId];

// }
//}

private static void LookupPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var langHost = GetLangHost(bindable);
Expand All @@ -72,30 +94,28 @@ private static void LookupPropertyChanged(BindableObject bindable, object oldVal
string to = "???";
if (lookup.Count > (int)(object)langHost.TextId)
{
List<(ExpressionTree, string)> thing = lookup[(int)(object)langHost.TextId];
List<(ExpressionTree, string)> thing = lookup[(int)(object)langHost.TextId];




foreach ((ExpressionTree, string) item in thing)
{
var result = item.Item1.Evaluate(host).Pop();
if (result.Type == ExpressionParserZero.Operands.OperandType.Bool)
if ((bool)result.GetValue() == true)
return item.Item2;
}
return $"textId {textId} not found.";
foreach ((ExpressionTree, string) item in thing)
{
langHost.Text = item.Item2;
return;

//var result = item.Item1.Evaluate(host).Pop();
//if (result.Type == ExpressionParserZero.Operands.OperandType.Bool)
// if ((bool)result.GetValue() == true)
// return item.Item2;
}
//return $"textId {textId} not found.";



to = lookup[(int)(object)langHost.TextId];
}
if (langHost.ShowOff)
CrossFadeText(langHost, to);
else
langHost.Text = GetLookup(bindable)[(int)(object)langHost.TextId];

//to = lookup[(int)(object)langHost.TextId];
}
}
}

Expand Down

0 comments on commit 2264ce8

Please sign in to comment.