Skip to content

Commit

Permalink
v1.8.8
Browse files Browse the repository at this point in the history
  • Loading branch information
vovgou committed Jul 30, 2019
1 parent fc56961 commit 6a02977
Show file tree
Hide file tree
Showing 32 changed files with 834 additions and 219 deletions.
Binary file modified Assets/LoxodonFramework/Docs/LoxodonFramework.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<string name="app.name">Loxodon Framework Examples</string>
<string name="framework.name">LoxodonFramework</string>
<vector3 name="user.position">(20 , 20.2 , 30)</vector3>
<rect name="button.coordinates">(100.0,100.0,240,60)</rect>
<color name="color.black">#000000</color>
<color-array name="button.transition.colors">
<item>#FFFFFFFF</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<string name="app.name">Loxodon Framework 示例</string>
<string name="framework.name">LoxodonFramework</string>
<vector3 name="user.position">(20 , 20.2 , 30)</vector3>
<rect name="button.coordinates">(100.0,100.0,200,60)</rect>
<color name="color.black">#000000</color>
<color-array name="button.transition.colors">
<item>#FFFFFFFF</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class LoginWindow : Window
protected override void OnCreate(IBundle bundle)
{
BindingSet<LoginWindow, LoginViewModel> bindingSet = this.CreateBindingSet<LoginWindow, LoginViewModel>();
bindingSet.Bind().For(v => v.OnInteractionFinished(null, null)).To(vm => vm.InteractionFinished);
bindingSet.Bind().For(v => v.OnToastShow(null, null)).To(vm => vm.ToastRequest);
bindingSet.Bind().For(v => v.OnInteractionFinished).To(vm => vm.InteractionFinished);
bindingSet.Bind().For(v => v.OnToastShow).To(vm => vm.ToastRequest);

bindingSet.Bind(this.username).For(v => v.text, v => v.onEndEdit).To(vm => vm.Username).TwoWay();
bindingSet.Bind(this.usernameErrorPrompt).For(v => v.text).To(vm => vm.Errors["username"]).OneWay();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ protected override void OnCreate(IBundle bundle)

/* databinding, Bound to the ViewModel. */
BindingSet<StartupWindow, StartupViewModel> bindingSet = this.CreateBindingSet(viewModel);
bindingSet.Bind().For(v => v.OnOpenLoginWindow(null, null)).To(vm => vm.LoginRequest);
bindingSet.Bind().For(v => v.OnDismissRequest(null, null)).To(vm => vm.DismissRequest);
bindingSet.Bind().For(v => v.OnOpenLoginWindow).To(vm => vm.LoginRequest);
bindingSet.Bind().For(v => v.OnDismissRequest).To(vm => vm.DismissRequest);

bindingSet.Bind(this.progressBarSlider).For("value", "onValueChanged").To("ProgressBar.Progress").TwoWay();
//bindingSet.Bind (this.progressBarSlider).For (v => v.value, v => v.onValueChanged).To (vm => vm.ProgressBar.Progress).TwoWay ();
Expand Down
7 changes: 6 additions & 1 deletion Assets/LoxodonFramework/Readme.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Loxodon Framework
Version: 1.8.6
Version: 1.8.8
© 2016, Clark Yang
=======================================

Expand All @@ -16,6 +16,11 @@ AOT Compilation Options: "nrgctx-trampolines=8192,nimt-trampolines=8192,ntrampol

UPDATE NOTES
----------------------------------------
version 1.8.7
Added encryption and decryption feature.
Added lua precompilation tools
Added lua script loader

version 1.8.6
Changed Localization.GetText(string key, params object[] args) to GetFormattedText(string key, params object[] args).
Changed IConfiguration.GetString(string key, params object[] args) to GetFormattedString(string key, params object[] args).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Loxodon.Log;
using Loxodon.Framework.Binding.Contexts;
using Loxodon.Framework.Binding.Converters;
using Loxodon.Framework.Interactivity;

namespace Loxodon.Framework.Binding.Builder
{
Expand Down Expand Up @@ -55,6 +56,7 @@ public BindingBuilder<TTarget, TSource> For<TResult>(Expression<Func<TTarget, TR
return this;
}

[Obsolete("Please use \"For(v => v.MethodName)\" instead of this method.")]
public BindingBuilder<TTarget, TSource> For(Expression<Action<TTarget>> memberExpression)
{
string targetName = this.PathParser.ParseMemberName(memberExpression);
Expand All @@ -64,6 +66,15 @@ public BindingBuilder<TTarget, TSource> For(Expression<Action<TTarget>> memberEx
return this;
}

public BindingBuilder<TTarget, TSource> For(Expression<Func<TTarget, EventHandler<InteractionEventArgs>>> memberExpression)
{
string targetName = this.PathParser.ParseMemberName(memberExpression);
this.description.TargetName = targetName;
this.description.UpdateTrigger = null;
this.OneWayToSource();
return this;
}

public BindingBuilder<TTarget, TSource> To(string path)
{
this.SetMemberPath(path);
Expand All @@ -76,12 +87,25 @@ public BindingBuilder<TTarget, TSource> To<TResult>(Expression<Func<TSource, TRe
return this;
}

[Obsolete("Please use \"To(vm => vm.MethodName)\" or \"To<TParameter>(vm => vm.MethodName)\" instead of this method.")]
public BindingBuilder<TTarget, TSource> To(Expression<Action<TSource>> path)
{
this.SetMemberPath(this.PathParser.Parse(path));
return this;
}

public BindingBuilder<TTarget, TSource> To<TParameter>(Expression<Func<TSource, Action<TParameter>>> path)
{
this.SetMemberPath(this.PathParser.Parse(path));
return this;
}

public BindingBuilder<TTarget, TSource> To(Expression<Func<TSource, Action>> path)
{
this.SetMemberPath(this.PathParser.Parse(path));
return this;
}

public BindingBuilder<TTarget, TSource> ToExpression<TResult>(Expression<Func<TSource, TResult>> expression)
{
this.SetExpression(expression);
Expand Down Expand Up @@ -185,6 +209,7 @@ public BindingBuilder<TTarget> For<TResult>(Expression<Func<TTarget, TResult>> m
return this;
}

[Obsolete("Please use \"For(v => v.MethodName)\" instead of this method.")]
public BindingBuilder<TTarget> For(Expression<Action<TTarget>> memberExpression)
{
string targetName = this.PathParser.ParseMemberName(memberExpression);
Expand All @@ -194,6 +219,15 @@ public BindingBuilder<TTarget> For(Expression<Action<TTarget>> memberExpression)
return this;
}

public BindingBuilder<TTarget> For(Expression<Func<TTarget, EventHandler<InteractionEventArgs>>> memberExpression)
{
string targetName = this.PathParser.ParseMemberName(memberExpression);
this.description.TargetName = targetName;
this.description.UpdateTrigger = null;
this.OneWayToSource();
return this;
}

public BindingBuilder<TTarget> To(string path)
{
this.SetStaticMemberPath(path);
Expand All @@ -208,12 +242,25 @@ public BindingBuilder<TTarget> To<TResult>(Expression<Func<TResult>> path)
return this;
}

[Obsolete("Please use \"To(() => Class.MethodName)\" or \"To<TParameter>(() => Class.MethodName)\" instead of this method.")]
public BindingBuilder<TTarget> To(Expression<Action> path)
{
this.SetStaticMemberPath(this.PathParser.ParseStaticPath(path));
return this;
}

public BindingBuilder<TTarget> To<TParameter>(Expression<Func<Action<TParameter>>> path)
{
this.SetStaticMemberPath(this.PathParser.ParseStaticPath(path));
return this;
}

public BindingBuilder<TTarget> To(Expression<Func<Action>> path)
{
this.SetStaticMemberPath(this.PathParser.ParseStaticPath(path));
return this;
}

public BindingBuilder<TTarget> ToValue(object value)
{
this.SetLiteral(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ private void Parse(Expression expression, Path path)
return;
}

//Delegate.CreateDelegate(Type type, object firstArgument, MethodInfo method)
if (methodCall.Method.Name.Equals("CreateDelegate") && methodCall.Arguments.Count == 3)
{
var info = (MethodInfo)(methodCall.Arguments[2] as ConstantExpression).Value;
Expand Down Expand Up @@ -265,12 +266,25 @@ public virtual string ParseMemberName(LambdaExpression expression)
if (method != null)
return method.Method.Name;

//Delegate.CreateDelegate(Type type, object firstArgument, MethodInfo method)
var unary = expression.Body as UnaryExpression;
if (unary != null && unary.NodeType == ExpressionType.Convert)
{
MethodCallExpression methodCall = (MethodCallExpression)unary.Operand;
if (methodCall.Method.Name.Equals("CreateDelegate") && methodCall.Arguments.Count == 3)
{
var info = (MethodInfo)(methodCall.Arguments[2] as ConstantExpression).Value;
return info.Name;
}
throw new ArgumentException(string.Format("Invalid argument:{0}", expression), "expression");
}

var body = expression.Body as MemberExpression;
if (body == null)
throw new ArgumentException("Invalid argument", "expression");
throw new ArgumentException(string.Format("Invalid argument:{0}", expression), "expression");

if (!(body.Expression is ParameterExpression))
throw new NotSupportedException("Invalid argument");
throw new ArgumentException(string.Format("Invalid argument:{0}", expression), "expression");

return body.Member.Name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public virtual bool Support(Type type)
return true;
if (type.Equals(typeof(Vector4)))
return true;
if (type.Equals(typeof(Rect)))
return true;
return false;
}
}
Expand Down Expand Up @@ -187,6 +189,26 @@ public virtual object Convert(Type type, object value)
throw new FormatException(string.Format("This value \"{0}\" cannot be converted to the type \"{1}\"", value, type.Name), e);
}
}
else if (type.Equals(typeof(Rect)))
{
if (value is Rect)
return (Rect)value;

if (!(value is string))
throw new FormatException(string.Format("This value \"{0}\" cannot be converted to the type \"{1}\"", value, type.Name));

try
{
var val = Regex.Replace(((string)value).Trim(), @"(^\()|(\)$)", "");
string[] s = val.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 4)
return new Rect(float.Parse(s[0]), float.Parse(s[1]), float.Parse(s[2]), float.Parse(s[3]));
}
catch (Exception e)
{
throw new FormatException(string.Format("This value \"{0}\" cannot be converted to the type \"{1}\"", value, type.Name), e);
}
}

throw new FormatException(string.Format("This value \"{0}\" cannot be converted to the type \"{1}\"", value, type.Name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public AbstractDocumentParser(List<ITypeConverter> converters)
this.converters.AddRange(converters);
this.converters.Add(new ColorTypeConverter());
this.converters.Add(new VectorTypeConverter());
this.converters.Add(new PrimitiveTypeConverter());
this.converters.Add(new RectTypeConverter());
this.converters.Add(new PrimitiveTypeConverter());
}

public abstract Dictionary<string, object> Parse(Stream input, CultureInfo cultureInfo);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Text.RegularExpressions;
using UnityEngine;

namespace Loxodon.Framework.Localizations
{
public class RectTypeConverter : ITypeConverter
{
public bool Support(string typeName)
{
switch (typeName)
{
case "rect":
return true;
default:
return false;
}
}

public Type GetType(string typeName)
{
switch (typeName)
{
case "rect":
return typeof(Rect);
default:
throw new NotSupportedException();
}
}

public object Convert(Type type, object value)
{
if (type == null)
throw new NotSupportedException();

try
{
var val = Regex.Replace(((string)value).Trim(), @"(^\()|(\)$)", "");
string[] s = val.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 4)
return new Rect(float.Parse(s[0]), float.Parse(s[1]), float.Parse(s[2]), float.Parse(s[3]));

}
catch (Exception)
{
}
throw new FormatException(string.Format("The '{0}' is illegal Rect.", value));
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Loxodon.Framework.Localizations;
using System;
using System.Collections;
using UnityEngine;

namespace Loxodon.Framework.Localizations
{
[RequireComponent(typeof(AudioSource))]
public class LocalizedAudioSourceInResources : AbstractLocalized<AudioSource>
{
protected override void OnValueChanged(object sender, EventArgs e)
{
string path = (string)this.value.Value;
this.StartCoroutine(DoLoad(path));
}

protected virtual IEnumerator DoLoad(string path)
{
var result = Resources.LoadAsync<AudioClip>(path);
yield return result;
this.target.clip = (AudioClip)result.asset;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Loxodon.Framework.Localizations;
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;

namespace Loxodon.Framework.Localizations
{
[RequireComponent(typeof(Image))]
public class LocalizedImageInResources : AbstractLocalized<Image>
{
protected override void OnValueChanged(object sender, EventArgs e)
{
string path = (string)this.value.Value;
this.StartCoroutine(DoLoad(path));
}

protected virtual IEnumerator DoLoad(string path)
{
var result = Resources.LoadAsync<Sprite>(path);
yield return result;
this.target.sprite = (Sprite)result.asset;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6a02977

Please sign in to comment.