@@ -22,25 +22,27 @@ public partial struct Bordered : IEquatable<Bordered>, IAtlasDrawable
22
22
public static implicit operator FivePatch ( Bordered bordered )
23
23
{
24
24
return new FivePatch (
25
- bordered . mTexture ,
25
+ bordered . _texture ,
26
26
( int ) bordered . mX ,
27
27
( int ) bordered . mY ,
28
- ( int ) bordered . mWidth ,
29
- ( int ) bordered . mHeight ,
30
- bordered . mMargin ,
28
+ ( int ) bordered . _width ,
29
+ ( int ) bordered . _height ,
30
+ bordered . _margin ,
31
31
default
32
32
) ;
33
33
}
34
34
35
- private IGameTexture mTexture ;
35
+ private IGameTexture _texture ;
36
36
37
- private readonly SubRect [ ] mRects ;
37
+ private readonly SubRect [ ] _subRects ;
38
38
39
- private Margin mMargin ;
39
+ private Margin _margin ;
40
40
41
- private float mWidth ;
41
+ private float _width ;
42
42
43
- private float mHeight ;
43
+ private float _height ;
44
+
45
+ public Margin Margin => _margin ;
44
46
45
47
public Bordered (
46
48
IGameTexture texture ,
@@ -53,10 +55,10 @@ Margin inMargin
53
55
{
54
56
mX = x ;
55
57
mY = y ;
56
- mRects = new SubRect [ 9 ] ;
57
- for ( var i = 0 ; i < mRects . Length ; i ++ )
58
+ _subRects = new SubRect [ 9 ] ;
59
+ for ( var i = 0 ; i < _subRects . Length ; i ++ )
58
60
{
59
- mRects [ i ] . Uv = new float [ 4 ] ;
61
+ _subRects [ i ] . Uv = new float [ 4 ] ;
60
62
}
61
63
62
64
Init ( texture , x , y , w , h , inMargin ) ;
@@ -65,29 +67,29 @@ Margin inMargin
65
67
void DrawRect ( Renderer . Base render , int i , int x , int y , int w , int h , Color clr )
66
68
{
67
69
render . DrawTexturedRect (
68
- mTexture , new Rectangle ( x , y , w , h ) , clr , mRects [ i ] . Uv [ 0 ] , mRects [ i ] . Uv [ 1 ] , mRects [ i ] . Uv [ 2 ] ,
69
- mRects [ i ] . Uv [ 3 ]
70
+ _texture , new Rectangle ( x , y , w , h ) , clr , _subRects [ i ] . Uv [ 0 ] , _subRects [ i ] . Uv [ 1 ] , _subRects [ i ] . Uv [ 2 ] ,
71
+ _subRects [ i ] . Uv [ 3 ]
70
72
) ;
71
73
}
72
74
73
75
void SetRect ( int num , float x , float y , float w , float h )
74
76
{
75
- if ( mTexture == null )
77
+ if ( _texture == null )
76
78
{
77
79
return ;
78
80
}
79
81
80
- float texw = mTexture . Width ;
81
- float texh = mTexture . Height ;
82
+ float texw = _texture . Width ;
83
+ float texh = _texture . Height ;
82
84
83
85
//x -= 1.0f;
84
86
//y -= 1.0f;
85
87
86
- mRects [ num ] . Uv [ 0 ] = x / texw ;
87
- mRects [ num ] . Uv [ 1 ] = y / texh ;
88
+ _subRects [ num ] . Uv [ 0 ] = x / texw ;
89
+ _subRects [ num ] . Uv [ 1 ] = y / texh ;
88
90
89
- mRects [ num ] . Uv [ 2 ] = ( x + w ) / texw ;
90
- mRects [ num ] . Uv [ 3 ] = ( y + h ) / texh ;
91
+ _subRects [ num ] . Uv [ 2 ] = ( x + w ) / texw ;
92
+ _subRects [ num ] . Uv [ 3 ] = ( y + h ) / texh ;
91
93
92
94
// rects[num].uv[0] += 1.0f / m_Texture->width;
93
95
// rects[num].uv[1] += 1.0f / m_Texture->width;
@@ -103,31 +105,31 @@ private void Init(
103
105
float drawMarginScale = 1.0f
104
106
)
105
107
{
106
- mTexture = texture ;
108
+ _texture = texture ;
107
109
108
- mMargin = inMargin ;
110
+ _margin = inMargin ;
109
111
110
- SetRect ( 0 , x , y , mMargin . Left , mMargin . Top ) ;
111
- SetRect ( 1 , x + mMargin . Left , y , w - mMargin . Left - mMargin . Right , mMargin . Top ) ;
112
- SetRect ( 2 , x + w - mMargin . Right , y , mMargin . Right , mMargin . Top ) ;
112
+ SetRect ( 0 , x , y , _margin . Left , _margin . Top ) ;
113
+ SetRect ( 1 , x + _margin . Left , y , w - _margin . Left - _margin . Right , _margin . Top ) ;
114
+ SetRect ( 2 , x + w - _margin . Right , y , _margin . Right , _margin . Top ) ;
113
115
114
- SetRect ( 3 , x , y + mMargin . Top , mMargin . Left , h - mMargin . Top - mMargin . Bottom ) ;
116
+ SetRect ( 3 , x , y + _margin . Top , _margin . Left , h - _margin . Top - _margin . Bottom ) ;
115
117
SetRect (
116
118
4 ,
117
- x + mMargin . Left ,
118
- y + mMargin . Top ,
119
- w - mMargin . Left - mMargin . Right ,
120
- h - mMargin . Top - mMargin . Bottom
119
+ x + _margin . Left ,
120
+ y + _margin . Top ,
121
+ w - _margin . Left - _margin . Right ,
122
+ h - _margin . Top - _margin . Bottom
121
123
) ;
122
124
123
- SetRect ( 5 , x + w - mMargin . Right , y + mMargin . Top , mMargin . Right , h - mMargin . Top - mMargin . Bottom ) ;
125
+ SetRect ( 5 , x + w - _margin . Right , y + _margin . Top , _margin . Right , h - _margin . Top - _margin . Bottom ) ;
124
126
125
- SetRect ( 6 , x , y + h - mMargin . Bottom , mMargin . Left , mMargin . Bottom ) ;
126
- SetRect ( 7 , x + mMargin . Left , y + h - mMargin . Bottom , w - mMargin . Left - mMargin . Right , mMargin . Bottom ) ;
127
- SetRect ( 8 , x + w - mMargin . Right , y + h - mMargin . Bottom , mMargin . Right , mMargin . Bottom ) ;
127
+ SetRect ( 6 , x , y + h - _margin . Bottom , _margin . Left , _margin . Bottom ) ;
128
+ SetRect ( 7 , x + _margin . Left , y + h - _margin . Bottom , w - _margin . Left - _margin . Right , _margin . Bottom ) ;
129
+ SetRect ( 8 , x + w - _margin . Right , y + h - _margin . Bottom , _margin . Right , _margin . Bottom ) ;
128
130
129
- mWidth = w ;
130
- mHeight = h ;
131
+ _width = w ;
132
+ _height = h ;
131
133
}
132
134
133
135
// can't have this as default param
@@ -138,52 +140,52 @@ private void Init(
138
140
139
141
public void Draw ( Renderer . Base render , Rectangle r , Color col )
140
142
{
141
- if ( mTexture == null )
143
+ if ( _texture == null )
142
144
{
143
145
return ;
144
146
}
145
147
146
148
render . DrawColor = col ;
147
149
148
- if ( r . Width < mWidth && r . Height < mHeight )
150
+ if ( r . Width < _width && r . Height < _height )
149
151
{
150
152
render . DrawTexturedRect (
151
- mTexture , r , col , mRects [ 0 ] . Uv [ 0 ] , mRects [ 0 ] . Uv [ 1 ] , mRects [ 8 ] . Uv [ 2 ] , mRects [ 8 ] . Uv [ 3 ]
153
+ _texture , r , col , _subRects [ 0 ] . Uv [ 0 ] , _subRects [ 0 ] . Uv [ 1 ] , _subRects [ 8 ] . Uv [ 2 ] , _subRects [ 8 ] . Uv [ 3 ]
152
154
) ;
153
155
154
156
return ;
155
157
}
156
158
157
- DrawRect ( render , 0 , r . X , r . Y , mMargin . Left , mMargin . Top , col ) ;
158
- DrawRect ( render , 1 , r . X + mMargin . Left , r . Y , r . Width - mMargin . Left - mMargin . Right , mMargin . Top , col ) ;
159
- DrawRect ( render , 2 , r . X + r . Width - mMargin . Right , r . Y , mMargin . Right , mMargin . Top , col ) ;
159
+ DrawRect ( render , 0 , r . X , r . Y , _margin . Left , _margin . Top , col ) ;
160
+ DrawRect ( render , 1 , r . X + _margin . Left , r . Y , r . Width - _margin . Left - _margin . Right , _margin . Top , col ) ;
161
+ DrawRect ( render , 2 , r . X + r . Width - _margin . Right , r . Y , _margin . Right , _margin . Top , col ) ;
160
162
161
- DrawRect ( render , 3 , r . X , r . Y + mMargin . Top , mMargin . Left , r . Height - mMargin . Top - mMargin . Bottom , col ) ;
163
+ DrawRect ( render , 3 , r . X , r . Y + _margin . Top , _margin . Left , r . Height - _margin . Top - _margin . Bottom , col ) ;
162
164
DrawRect (
163
- render , 4 , r . X + mMargin . Left , r . Y + mMargin . Top , r . Width - mMargin . Left - mMargin . Right ,
164
- r . Height - mMargin . Top - mMargin . Bottom , col
165
+ render , 4 , r . X + _margin . Left , r . Y + _margin . Top , r . Width - _margin . Left - _margin . Right ,
166
+ r . Height - _margin . Top - _margin . Bottom , col
165
167
) ;
166
168
167
169
DrawRect (
168
- render , 5 , r . X + r . Width - mMargin . Right , r . Y + mMargin . Top , mMargin . Right ,
169
- r . Height - mMargin . Top - mMargin . Bottom , col
170
+ render , 5 , r . X + r . Width - _margin . Right , r . Y + _margin . Top , _margin . Right ,
171
+ r . Height - _margin . Top - _margin . Bottom , col
170
172
) ;
171
173
172
- DrawRect ( render , 6 , r . X , r . Y + r . Height - mMargin . Bottom , mMargin . Left , mMargin . Bottom , col ) ;
174
+ DrawRect ( render , 6 , r . X , r . Y + r . Height - _margin . Bottom , _margin . Left , _margin . Bottom , col ) ;
173
175
DrawRect (
174
- render , 7 , r . X + mMargin . Left , r . Y + r . Height - mMargin . Bottom , r . Width - mMargin . Left - mMargin . Right ,
175
- mMargin . Bottom , col
176
+ render , 7 , r . X + _margin . Left , r . Y + r . Height - _margin . Bottom , r . Width - _margin . Left - _margin . Right ,
177
+ _margin . Bottom , col
176
178
) ;
177
179
178
180
DrawRect (
179
- render , 8 , r . X + r . Width - mMargin . Right , r . Y + r . Height - mMargin . Bottom , mMargin . Right ,
180
- mMargin . Bottom , col
181
+ render , 8 , r . X + r . Width - _margin . Right , r . Y + r . Height - _margin . Bottom , _margin . Right ,
182
+ _margin . Bottom , col
181
183
) ;
182
184
}
183
185
184
186
public bool Equals ( Bordered other )
185
187
{
186
- return mTexture . Equals ( other . mTexture ) && mRects . Equals ( other . mRects ) && mMargin . Equals ( other . mMargin ) && mWidth . Equals ( other . mWidth ) && mHeight . Equals ( other . mHeight ) ;
188
+ return _texture . Equals ( other . _texture ) && _subRects . Equals ( other . _subRects ) && _margin . Equals ( other . _margin ) && _width . Equals ( other . _width ) && _height . Equals ( other . _height ) ;
187
189
}
188
190
189
191
public override bool Equals ( object ? obj )
@@ -193,7 +195,7 @@ public override bool Equals(object? obj)
193
195
194
196
public override int GetHashCode ( )
195
197
{
196
- return HashCode . Combine ( mTexture , mRects , mMargin , mWidth , mHeight ) ;
198
+ return HashCode . Combine ( _texture , _subRects , _margin , _width , _height ) ;
197
199
}
198
200
199
201
public static bool operator == ( Bordered lhs , Bordered rhs ) => lhs . Equals ( rhs ) ;
0 commit comments