多语言逻辑

This commit is contained in:
bob
2025-06-13 17:35:29 +08:00
parent f862c7514c
commit e060f9eb02
18 changed files with 561 additions and 221 deletions

View File

@@ -22,6 +22,16 @@ namespace FairyGUI
/// </summary>
public object data;
/// <summary>
/// 多语言key
/// </summary>
public string lang;
/// <summary>
/// 多语言参数
/// </summary>
public object[] langArgs;
/// <summary>
/// The source width of the object.
/// </summary>
@@ -325,10 +335,7 @@ namespace FairyGUI
public float x
{
get { return _x; }
set
{
SetPosition(value, _y, _z);
}
set { SetPosition(value, _y, _z); }
}
/// <summary>
@@ -337,10 +344,7 @@ namespace FairyGUI
public float y
{
get { return _y; }
set
{
SetPosition(_x, value, _z);
}
set { SetPosition(_x, value, _z); }
}
/// <summary>
@@ -349,10 +353,7 @@ namespace FairyGUI
public float z
{
get { return _z; }
set
{
SetPosition(_x, _y, value);
}
set { SetPosition(_x, _y, value); }
}
/// <summary>
@@ -481,14 +482,8 @@ namespace FairyGUI
/// </summary>
public float width
{
get
{
return _width;
}
set
{
SetSize(value, _rawHeight);
}
get { return _width; }
set { SetSize(value, _rawHeight); }
}
/// <summary>
@@ -496,14 +491,8 @@ namespace FairyGUI
/// </summary>
public float height
{
get
{
return _height;
}
set
{
SetSize(_rawWidth, value);
}
get { return _height; }
set { SetSize(_rawWidth, value); }
}
/// <summary>
@@ -615,10 +604,7 @@ namespace FairyGUI
/// </summary>
public float xMin
{
get
{
return _pivotAsAnchor ? (_x - _width * _pivotX) : _x;
}
get { return _pivotAsAnchor ? (_x - _width * _pivotX) : _x; }
set
{
if (_pivotAsAnchor)
@@ -633,10 +619,7 @@ namespace FairyGUI
/// </summary>
public float yMin
{
get
{
return _pivotAsAnchor ? (_y - _height * _pivotY) : _y;
}
get { return _pivotAsAnchor ? (_y - _height * _pivotY) : _y; }
set
{
if (_pivotAsAnchor)
@@ -652,10 +635,7 @@ namespace FairyGUI
public float scaleX
{
get { return _scaleX; }
set
{
SetScale(value, _scaleY);
}
set { SetScale(value, _scaleY); }
}
/// <summary>
@@ -664,10 +644,7 @@ namespace FairyGUI
public float scaleY
{
get { return _scaleY; }
set
{
SetScale(_scaleX, value);
}
set { SetScale(_scaleX, value); }
}
/// <summary>
@@ -722,10 +699,7 @@ namespace FairyGUI
public float pivotX
{
get { return _pivotX; }
set
{
SetPivot(value, _pivotY, _pivotAsAnchor);
}
set { SetPivot(value, _pivotY, _pivotAsAnchor); }
}
/// <summary>
@@ -734,10 +708,7 @@ namespace FairyGUI
public float pivotY
{
get { return _pivotY; }
set
{
SetPivot(_pivotX, value, _pivotAsAnchor);
}
set { SetPivot(_pivotX, value, _pivotAsAnchor); }
}
/// <summary>
@@ -752,10 +723,7 @@ namespace FairyGUI
public bool pivotAsAnchor
{
get { return _pivotAsAnchor; }
set
{
SetPivot(_pivotX, _pivotY, value);
}
set { SetPivot(_pivotX, _pivotY, value); }
}
/// <summary>
@@ -792,10 +760,7 @@ namespace FairyGUI
/// </summary>
public bool touchable
{
get
{
return _touchable;
}
get { return _touchable; }
set
{
if (_touchable != value)
@@ -814,10 +779,7 @@ namespace FairyGUI
/// </summary>
public bool grayed
{
get
{
return _grayed;
}
get { return _grayed; }
set
{
if (_grayed != value)
@@ -834,10 +796,7 @@ namespace FairyGUI
/// </summary>
public bool enabled
{
get
{
return !_grayed && _touchable;
}
get { return !_grayed && _touchable; }
set
{
this.grayed = !value;
@@ -850,10 +809,7 @@ namespace FairyGUI
/// </summary>
public float rotation
{
get
{
return _rotation;
}
get { return _rotation; }
set
{
_rotation = value;
@@ -868,10 +824,7 @@ namespace FairyGUI
/// </summary>
public float rotationX
{
get
{
return _rotationX;
}
get { return _rotationX; }
set
{
_rotationX = value;
@@ -885,10 +838,7 @@ namespace FairyGUI
/// </summary>
public float rotationY
{
get
{
return _rotationY;
}
get { return _rotationY; }
set
{
_rotationY = value;
@@ -902,11 +852,7 @@ namespace FairyGUI
/// </summary>
public float alpha
{
get
{
return _alpha;
}
get { return _alpha; }
set
{
@@ -921,10 +867,7 @@ namespace FairyGUI
/// </summary>
public bool visible
{
get
{
return _visible;
}
get { return _visible; }
set
{
@@ -942,26 +885,17 @@ namespace FairyGUI
internal bool internalVisible
{
get
{
return _internalVisible && (group == null || group.internalVisible);
}
get { return _internalVisible && (group == null || group.internalVisible); }
}
internal bool internalVisible2
{
get
{
return _visible && (group == null || group.internalVisible2);
}
get { return _visible && (group == null || group.internalVisible2); }
}
internal bool internalVisible3
{
get
{
return _visible && _internalVisible;
}
get { return _visible && _internalVisible; }
}
/// <summary>
@@ -991,7 +925,10 @@ namespace FairyGUI
public bool focusable
{
get { return displayObject != null && displayObject.focusable; }
set { if (displayObject != null) displayObject.focusable = value; }
set
{
if (displayObject != null) displayObject.focusable = value;
}
}
/// <summary>
@@ -1000,7 +937,10 @@ namespace FairyGUI
public bool tabStop
{
get { return displayObject != null && displayObject.tabStop; }
set { if (displayObject != null) displayObject.tabStop = value; }
set
{
if (displayObject != null) displayObject.tabStop = value;
}
}
/// <summary>
@@ -1083,7 +1023,10 @@ namespace FairyGUI
virtual public IFilter filter
{
get { return displayObject != null ? displayObject.filter : null; }
set { if (displayObject != null) displayObject.filter = value; }
set
{
if (displayObject != null) displayObject.filter = value;
}
}
/// <summary>
@@ -1092,7 +1035,10 @@ namespace FairyGUI
virtual public BlendMode blendMode
{
get { return displayObject != null ? displayObject.blendMode : BlendMode.None; }
set { if (displayObject != null) displayObject.blendMode = value; }
set
{
if (displayObject != null) displayObject.blendMode = value;
}
}
/// <summary>
@@ -1130,10 +1076,7 @@ namespace FairyGUI
/// </summary>
public bool inContainer
{
get
{
return displayObject != null && displayObject.parent != null;
}
get { return displayObject != null && displayObject.parent != null; }
}
/// <summary>
@@ -1141,10 +1084,7 @@ namespace FairyGUI
/// </summary>
public bool onStage
{
get
{
return displayObject != null && displayObject.stage != null;
}
get { return displayObject != null && displayObject.stage != null; }
}
/// <summary>
@@ -1166,10 +1106,7 @@ namespace FairyGUI
/// </summary>
public GearXY gearXY
{
get
{
return (GearXY)GetGear(1);
}
get { return (GearXY)GetGear(1); }
}
/// <summary>
@@ -1177,10 +1114,7 @@ namespace FairyGUI
/// </summary>
public GearSize gearSize
{
get
{
return (GearSize)GetGear(2);
}
get { return (GearSize)GetGear(2); }
}
/// <summary>
@@ -1188,10 +1122,7 @@ namespace FairyGUI
/// </summary>
public GearLook gearLook
{
get
{
return (GearLook)GetGear(3);
}
get { return (GearLook)GetGear(3); }
}
public GearBase GetGear(int index)
@@ -1234,8 +1165,10 @@ namespace FairyGUI
default:
throw new System.Exception("FairyGUI: invalid gear index!");
}
_gears[index] = gear;
}
return gear;
}
@@ -1323,6 +1256,7 @@ namespace FairyGUI
if (gear != null && gear.controller == c)
gear.Apply();
}
_handlingController = false;
CheckGearDisplay();
@@ -1421,7 +1355,10 @@ namespace FairyGUI
virtual public string text
{
get { return null; }
set { /*override in child*/}
set
{
/*override in child*/
}
}
/// <summary>
@@ -1430,7 +1367,10 @@ namespace FairyGUI
virtual public string icon
{
get { return null; }
set { /*override in child*/}
set
{
/*override in child*/
}
}
/// <summary>
@@ -1505,6 +1445,7 @@ namespace FairyGUI
pt.x += _width * _pivotX;
pt.y += _height * _pivotY;
}
return displayObject.LocalToGlobal(pt);
}
@@ -1521,6 +1462,7 @@ namespace FairyGUI
pt.x -= _width * _pivotX;
pt.y -= _height * _pivotY;
}
return pt;
}
@@ -1594,6 +1536,7 @@ namespace FairyGUI
}
else
pt = r.LocalToGlobal(pt);
return GlobalToLocal(pt);
}
@@ -1634,6 +1577,7 @@ namespace FairyGUI
pt.x += _width * _pivotX;
pt.y += _height * _pivotY;
}
return this.displayObject.TransformPoint(pt, targetSpace != null ? targetSpace.displayObject : Stage.inst);
}
@@ -1650,6 +1594,7 @@ namespace FairyGUI
rect.x += _width * _pivotX;
rect.y += _height * _pivotY;
}
return this.displayObject.TransformRect(rect, targetSpace != null ? targetSpace.displayObject : Stage.inst);
}
@@ -1681,11 +1626,13 @@ namespace FairyGUI
if (gear != null)
gear.Dispose();
}
if (displayObject != null)
{
displayObject.gOwner = null;
displayObject.Dispose();
}
data = null;
}
@@ -1853,6 +1800,7 @@ namespace FairyGUI
xv += _width * _pivotX;
yv += _height * _pivotY;
}
displayObject.location = new Vector3(xv, yv, _z);
}
}
@@ -1999,6 +1947,7 @@ namespace FairyGUI
}
#region Drag support
Vector2 _dragTouchStartPos;
bool _dragTesting;
@@ -2135,9 +2084,11 @@ namespace FairyGUI
DispatchEvent("onDragEnd", null);
}
}
#endregion
#region Tween Helpers
public GTweener TweenMove(Vector2 endValue, float duration)
{
return GTween.To(this.xy, endValue, duration).SetTarget(this, TweenPropType.XY);
@@ -2182,6 +2133,7 @@ namespace FairyGUI
{
return GTween.To(_rotation, endValue, duration).SetTarget(this, TweenPropType.Rotation);
}
#endregion
}
}
}