@@ -22,25 +22,27 @@ public partial struct Bordered : IEquatable<Bordered>, IAtlasDrawable
2222 public static implicit operator FivePatch ( Bordered bordered )
2323 {
2424 return new FivePatch (
25- bordered . mTexture ,
25+ bordered . _texture ,
2626 ( int ) bordered . mX ,
2727 ( 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 ,
3131 default
3232 ) ;
3333 }
3434
35- private IGameTexture mTexture ;
35+ private IGameTexture _texture ;
3636
37- private readonly SubRect [ ] mRects ;
37+ private readonly SubRect [ ] _subRects ;
3838
39- private Margin mMargin ;
39+ private Margin _margin ;
4040
41- private float mWidth ;
41+ private float _width ;
4242
43- private float mHeight ;
43+ private float _height ;
44+
45+ public Margin Margin => _margin ;
4446
4547 public Bordered (
4648 IGameTexture texture ,
@@ -53,10 +55,10 @@ Margin inMargin
5355 {
5456 mX = x ;
5557 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 ++ )
5860 {
59- mRects [ i ] . Uv = new float [ 4 ] ;
61+ _subRects [ i ] . Uv = new float [ 4 ] ;
6062 }
6163
6264 Init ( texture , x , y , w , h , inMargin ) ;
@@ -65,29 +67,29 @@ Margin inMargin
6567 void DrawRect ( Renderer . Base render , int i , int x , int y , int w , int h , Color clr )
6668 {
6769 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 ]
7072 ) ;
7173 }
7274
7375 void SetRect ( int num , float x , float y , float w , float h )
7476 {
75- if ( mTexture == null )
77+ if ( _texture == null )
7678 {
7779 return ;
7880 }
7981
80- float texw = mTexture . Width ;
81- float texh = mTexture . Height ;
82+ float texw = _texture . Width ;
83+ float texh = _texture . Height ;
8284
8385 //x -= 1.0f;
8486 //y -= 1.0f;
8587
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 ;
8890
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 ;
9193
9294 // rects[num].uv[0] += 1.0f / m_Texture->width;
9395 // rects[num].uv[1] += 1.0f / m_Texture->width;
@@ -103,31 +105,31 @@ private void Init(
103105 float drawMarginScale = 1.0f
104106 )
105107 {
106- mTexture = texture ;
108+ _texture = texture ;
107109
108- mMargin = inMargin ;
110+ _margin = inMargin ;
109111
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 ) ;
113115
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 ) ;
115117 SetRect (
116118 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
121123 ) ;
122124
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 ) ;
124126
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 ) ;
128130
129- mWidth = w ;
130- mHeight = h ;
131+ _width = w ;
132+ _height = h ;
131133 }
132134
133135 // can't have this as default param
@@ -138,52 +140,52 @@ private void Init(
138140
139141 public void Draw ( Renderer . Base render , Rectangle r , Color col )
140142 {
141- if ( mTexture == null )
143+ if ( _texture == null )
142144 {
143145 return ;
144146 }
145147
146148 render . DrawColor = col ;
147149
148- if ( r . Width < mWidth && r . Height < mHeight )
150+ if ( r . Width < _width && r . Height < _height )
149151 {
150152 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 ]
152154 ) ;
153155
154156 return ;
155157 }
156158
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 ) ;
160162
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 ) ;
162164 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
165167 ) ;
166168
167169 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
170172 ) ;
171173
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 ) ;
173175 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
176178 ) ;
177179
178180 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
181183 ) ;
182184 }
183185
184186 public bool Equals ( Bordered other )
185187 {
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 ) ;
187189 }
188190
189191 public override bool Equals ( object ? obj )
@@ -193,7 +195,7 @@ public override bool Equals(object? obj)
193195
194196 public override int GetHashCode ( )
195197 {
196- return HashCode . Combine ( mTexture , mRects , mMargin , mWidth , mHeight ) ;
198+ return HashCode . Combine ( _texture , _subRects , _margin , _width , _height ) ;
197199 }
198200
199201 public static bool operator == ( Bordered lhs , Bordered rhs ) => lhs . Equals ( rhs ) ;
0 commit comments