handmade.network » Forums » Work-in-Progress » UPDATE: ZeroTypes Library (C++) updated after a long hiatus, and now an SFL version!
lost
Lost Astronaut Studios
36 posts / 2 projects

Goodbye Handmade, you make no fucking sense

#15106 UPDATE: ZeroTypes Library (C++) updated after a long hiatus, and now an SFL version!
2 months, 3 weeks ago Edited by Lost Astronaut Studios on May 1, 2018, 5 a.m.

After many many months I have updated ZeroTypes to work with Visual Studio 2017.

The project has improved greatly from its initial release over a year ago. Worth another look, especially the SFL version.

* C++
* POD-non-PODs
* String wrangling
* Comes with examples

Original Handmade project:
zero.handmade.network

Single File Version: (well 2 files really)
http://github.com/h3rb/ZeroTypesSFL

Feel free to ask questions if you're wondering why you would use such a library, how it can be used most effectively, and what makes it great. I'll answer all reasonable queries. Thanks and enjoy!
lost
Lost Astronaut Studios
36 posts / 2 projects

Goodbye Handmade, you make no fucking sense

#15180 UPDATE: ZeroTypes Library (C++) updated after a long hiatus, and now an SFL version!
2 months, 2 weeks ago Edited by Lost Astronaut Studios on May 7, 2018, 8:03 p.m.

Here is an example of a "screen position" wrangling class for handling 2D AA boundaries:

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
/*********************************************************************************************
 *  __    __________________   ________________________________   __________  ________       *
 * /\ \  /\  __ \  ___\__  _\ /\  __ \  ___\__  _\  == \  __ \ "-.\ \  __ \ \/\ \__  _\ (tm) *
 * \ \ \_\_\ \/\ \___  \/\ \/ \ \  __ \___  \/\ \/\  __<\ \/\ \ \-.  \  __ \ \_\ \/\ \/      *
 *  \ \_____\_____\_____\ \_\  \ \_\ \_\_____\ \_\ \_\ \_\_____\_\\"\_\_\ \_\_____\ \_\      *
 *   \/_____/_____/_____/\/_/   \/_/\/_/_____/\/_/\/_/\/_/_____/_/ \/_/_/\/_/_____/\/_/      *
 *    --------------------------------------------------------------------------------       *
 *     Lost Astronaut Game Development Framework (c) 2007-2017 H. Elwood Gilliland III       *
 *********************************************************************************************
 * This software is copyrighted software.  Use of this code is given only with permission to *
 * parties who have been granted such permission by its author, Herbert Elwood Gilliland III *
 *********************************************************************************************/
// Released 5/7/2018 MIT License - H. Elwood Gilliland for Handmade Network
#pragma once
#include "macros.h"
#include "BinaryFile.h"
// Holds all information relevent to an object's screen position in the 2.5D engine

ONE(ScreenPosition,{})
 Zint x,y, w,h, x2,y2, cx,cy, h2,w2;
 Zfloat fx,fy, fw,fh, fx2,fy2, fcx,fcy, fh2,fw2;
 Zdouble dx,dy, dw,dh, dx2,dy2, dcx,dcy, dh2,dw2;
 Zdouble angle; // rotation
 KEYWORDS({
  NUMWORD("x",x)
  else NUMWORD("y",y)
  else NUMWORD("w",w)
  else NUMWORD("h",h)
  else NUMWORD("x2",x2)
  else NUMWORD("y2",y2)
  else NUMWORD("cx",cx)
  else NUMWORD("cx",cy)
  else NUMWORD("h2",h2)
  else NUMWORD("w2",w2)
  else NUMWORD("fx",fx)
  else NUMWORD("fx",fy)
  else NUMWORD("fw",fw)
  else NUMWORD("fh",fh)
  else NUMWORD("fx2",fx2)
  else NUMWORD("fy2",fy2)
  else NUMWORD("fcx",fcx)
  else NUMWORD("fcy",fcy)
  else NUMWORD("fh2",fh2)
  else NUMWORD("fw2",fw2)
  else NUMWORD("dx",dx)
  else NUMWORD("dx",dy)
  else NUMWORD("dw",dw)
  else NUMWORD("dh",dh)
  else NUMWORD("dx2",dx2)
  else NUMWORD("dy2",dy2)
  else NUMWORD("dcx",dcx)
  else NUMWORD("dcy",dcy)
  else NUMWORD("dh2",dh2)
  else NUMWORD("dw2",dw2)
  else NUMWORD("a",angle)
  else BADKEY("ScreenPosition")
 })
 WORDKEYS({
  NUMBKEY("x",x)
  NUMBKEY("y",y)
  NUMBKEY("w",w)
  NUMBKEY("h",h)
  NUMBKEY("x2",x2)
  NUMBKEY("y2",y2)
  NUMBKEY("cx",cx)
  NUMBKEY("cx",cy)
  NUMBKEY("h2",h2)
  NUMBKEY("w2",w2)
  NUMBKEY("fx",fx)
  NUMBKEY("fx",fy)
  NUMBKEY("fw",fw)
  NUMBKEY("fh",fh)
  NUMBKEY("fx2",fx2)
  NUMBKEY("fy2",fy2)
  NUMBKEY("fcx",fcx)
  NUMBKEY("fcy",fcy)
  NUMBKEY("fh2",fh2)
  NUMBKEY("fw2",fw2)
  NUMBKEY("dx",dx)
  NUMBKEY("dx",dy)
  NUMBKEY("dw",dw)
  NUMBKEY("dh",dh)
  NUMBKEY("dx2",dx2)
  NUMBKEY("dy2",dy2)
  NUMBKEY("dcx",dcx)
  NUMBKEY("dcy",dcy)
  NUMBKEY("dh2",dh2)
  NUMBKEY("dw2",dw2)
  NUMBKEY("a",angle)
 })
 CLONE(ScreenPosition,{
  DUPE(x);
  DUPE(y);
  DUPE(x2);
  DUPE(y2);
  DUPE(w);
  DUPE(h);
  DUPE(cx);
  DUPE(cy);
  DUPE(w2);
  DUPE(h2);
  DUPE(fx);
  DUPE(fy);
  DUPE(fx2);
  DUPE(fy2);
  DUPE(fw);
  DUPE(fh);
  DUPE(fcx);
  DUPE(fcy);
  DUPE(fw2);
  DUPE(fh2);
  DUPE(dx);
  DUPE(dy);
  DUPE(dx2);
  DUPE(dy2);
  DUPE(dw);
  DUPE(dh);
  DUPE(dcx);
  DUPE(dcy);
  DUPE(dw2);
  DUPE(dh2);
  DUPE(angle);
 })
 void BinaryRead( BinaryFile *open ) {
  open->read(&x);
  open->read(&y);
  open->read(&w);
  open->read(&h);
  open->read(&x2);
  open->read(&y2);
  open->read(&cx);
  open->read(&cy);
  open->read(&h2);
  open->read(&w2);
  open->read(&fx);
  open->read(&fy);
  open->read(&fw);
  open->read(&fh);
  open->read(&fx2);
  open->read(&fy2);
  open->read(&fcx);
  open->read(&fcy);
  open->read(&fh2);
  open->read(&fw2);
  open->read(&dx);
  open->read(&dy);
  open->read(&dw);
  open->read(&dh);
  open->read(&dx2);
  open->read(&dy2);
  open->read(&dcx);
  open->read(&dcy);
  open->read(&dh2);
  open->read(&dw2);
  open->read(&angle);
 }
 void BinaryWrite( BinaryFile *open ) {
  open->write(&x);
  open->write(&y);
  open->write(&w);
  open->write(&h);
  open->write(&x2);
  open->write(&y2);
  open->write(&cx);
  open->write(&cy);
  open->write(&h2);
  open->write(&w2);
  open->write(&fx);
  open->write(&fy);
  open->write(&fw);
  open->write(&fh);
  open->write(&fx2);
  open->write(&fy2);
  open->write(&fcx);
  open->write(&fcy);
  open->write(&fh2);
  open->write(&fw2);
  open->write(&dx);
  open->write(&dy);
  open->write(&dw);
  open->write(&dh);
  open->write(&dx2);
  open->write(&dy2);
  open->write(&dcx);
  open->write(&dcy);
  open->write(&dh2);
  open->write(&dw2);
  open->write(&angle);
 }
 void Set( ScreenPosition *s ) {
  x=    s->x;
  y=    s->y;
  w=    s->w;
  h=    s->h;
  x2=   s->x2;
  y2=   s->y2;
  cx=   s->cx;
  cy=   s->cy;
  h2=   s->h2;
  w2=   s->w2;
  fx=   s->fx;
  fy=   s->fy;
  fw=   s->fw;
  fh=   s->fh;
  fx2=  s->fx2;
  fy2=  s->fy2;
  fcx=  s->fcx;
  fcy=  s->fcy;
  fh2=  s->fh2;
  fw2=  s->fw2;
  dx=   s->dx;
  dy=   s->dy;
  dw=   s->dw;
  dh=   s->dh;
  dx2=  s->dx2;
  dy2=  s->dy2;
  dcx=  s->dcx;
  dcy=  s->dcy;
  dh2=  s->dh2;
  dw2=  s->dw2;
  angle=s->angle;
 }
 int RandomX() { return x+upto(w); }
 int RandomY() { return y+upto(h); }
 float RandomXf() { return float_range(fx,fx+fw); }
 float RandomYf() { return float_range(fy,fy+fh); }
 double RandomXd() { return double_range(dx,dx+dw); }
 double RandomYd() { return double_range(dy,dy+dh); }
 int RandomW() { return upto(w); }
 int RandomH() { return upto(h); }
 float RandomWf() { return float_range(0.0f,fw); }
 float RandomHf() { return float_range(0.0f,fh); }
 double RandomWd() { return double_range(0.0,dw); }
 double RandomHd() { return double_range(0.0,dh); }
 void X( int x ) { PositionX(x); }
 void X( float x ) { PositionX(x); }
 void X( double x ) { PositionX(x); }
 void PositionX( int X ) {
  x=X;
  fx=(float)X;
  dx=(double)X;
  x2=x+w;
  fx2=fx+fw;
  dx2=dx+dw;
  cx=x+w/2;
  fcx=fx+fw/2.0f;
  dcx=dx+dw/2.0;
 }
 void PositionX( float X ) {
  x=(int)X;
  fx=X;
  dx=(double)X;
  x2=x+w;
  fx2=fx+fw;
  dx2=dx+dw;
  cx=x+w/2;
  fcx=fx+fw/2.0f;
  dcx=dx+dw/2.0;
 }
 void PositionX( double X ) {
  x=(int)X;
  fx=(float)X;
  dx=X;
  x2=x+w;
  fx2=fx+fw;
  dx2=dx+dw;
  cx=x+w/2;
  fcx=fx+fw/2.0f;
  dcx=dx+dw/2.0;
 }
 void Y( int y ) { PositionY(y); }
 void Y( float y ) { PositionY(y); }
 void Y( double y ) { PositionY(y); }
 void PositionY( int Y ) {
  y=Y;
  fy=(float)Y;
  dy=(double)Y;
  y2=y+h;
  fy2=fy+fh;
  dy2=dy+dh;
  cy=y+h/2;
  fcy=fy+fh/2.0f;
  dcy=dy+dh/2.0;
 }
 void PositionY( float Y ) {
  y=(int)Y;
  fy=Y;
  dy=(double)Y;
  y2=y+h;
  fy2=fy+fh;
  dy2=dy+dh;
  cy=y+h/2;
  fcy=fy+fh/2.0f;
  dcy=dy+dh/2.0;
 }
 void PositionY( double Y ) {
  y=(int)Y;
  fy=(float)Y;
  dy=Y;
  y2=y+h;
  fy2=fy+fh;
  dy2=dy+dh;
  cy=y+h/2;
  fcy=fy+fh/2.0f;
  dcy=dy+dh/2.0;
 }
 void W( int w ) { Width(w); }
 void W( float w  ) { Width(w); }
 void W( double w ) { Width(w); }
 void Width( int W ) {
  w=W;
  fw=(float)W;
  dw=(double)W;
  w2=w/2;
  fw2=fw/2.0f;
  dw2=dw/2.0;
  x2=x+w;
  fx2=fx+fw;
  dx2=dx+dw;
  cx=x+w/2;
  fcx=fx+fw/2.0f;
  dcx=dx+dw/2.0;
 }
 void Width( float W ) {
  w=(int)W;
  fw=W;
  dw=(double)W;
  w2=w/2;
  fw2=fw/2.0f;
  dw2=dw/2.0;
  x2=x+w;
  fx2=fx+fw;
  dx2=dx+dw;
  cx=x+w/2;
  fcx=fx+fw/2.0f;
  dcx=dx+dw/2.0;
 }
 void Width( double W ) {
  w=(int)W;
  fw=(float)W;
  dw=W;
  w2=w/2;
  fw2=fw/2.0f;
  dw2=dw/2.0;
  x2=x+w;
  fx2=fx+fw;
  dx2=dx+dw;
  cx=x+w/2;
  fcx=fx+fw/2.0f;
  dcx=dx+dw/2.0;
 }
 void H( int h ) { Height(h); }
 void H( float h ) { Height(h); }
 void H( double h ) { Height(h); }
 void Height( int H ) {
  h=H;
  fh=(float)H;
  dh=(double)H;
  h2=h/2;
  fh2=fh/2.0f;
  dh2=dh/2.0;
  y2=y+h;
  fy2=fy+fh;
  dy2=dy+dh;
  cy=y+h/2;
  fcy=fy+fh/2.0f;
  dcy=dy+dh/2.0;
 }
 void Height( float H ) {
  h=(int)H;
  fh=H;
  dh=(double)H;
  h2=h/2;
  fh2=fh/2.0f;
  dh2=dh/2.0;
  y2=y+h;
  fy2=fy+fh;
  dy2=dy+dh;
  cy=y+h/2;
  fcy=fy+fh/2.0f;
  dcy=dy+dh/2.0;
 }
 void Height( double H ) {
  h=(int)H;
  fh=(float)H;
  dh=H;
  h2=h/2;
  fh2=fh/2.0f;
  dh2=dh/2.0;
  y2=y+h;
  dy2=fy+fh;
  dy2=dy+dh;
  cy=y+h/2;
  fcy=fy+fh/2.0f;
  dcy=dy+dh/2.0;
 }
 void Size( int w, int h ) {
  Height(h);
  Width(w);
 }
 void Size( float w, float h ) {
  Height(h);
  Width(w);
 }
 void Size( double w, double h ) {
  Height(h); 
  Width(w);
 }
 void Size( int wh ) {
  Height(wh);
  Width(wh);
 }
 void Size( float wh ) {
  Height(wh);
  Width(wh);
 }
 void Size( double wh ) {
  Height(wh);
  Width(wh);
 }
 void MoveTo( int X, int Y ) {
  PositionX(X);
  PositionY(Y);
 }
 void MoveTo( float X, float Y ) {
  PositionX(X);
  PositionY(Y);
 }
 void MoveTo( double X, double Y ) {
  PositionX(X);
  PositionY(Y);
 }
 void MoveToCenter( int CX, int CY ) {
  CenterX(CX);
  CenterY(CY);
 }
 void MoveToCenter( float CX, float CY ) {
  CenterX(CX);
  CenterY(CY);
 }
 void MoveToCenter( double CX, double CY ) {
  CenterX(CX);
  CenterY(CY);
 }
 void MoveBy( int X, int Y ) {
  PositionX(this->x+X);
  PositionY(this->y+Y);
 }
 void MoveBy( float X, float Y ) {
  PositionX(this->fx+X);
  PositionY(this->fy+Y);
 }
 void MoveBy( double X, double Y ) {
  PositionX(this->dx+X);
  PositionY(this->dy+Y);
 }
 void Set( int X, int Y ) {
  PositionX(X);
  PositionY(Y);
 }
 void Set( float X, float Y ) {
  PositionX(X);
  PositionY(Y);
 }
 void Set( double X, double Y ) {
  PositionX(X);
  PositionY(Y);
 }
 void Set( int X, int Y, int W, int H ) {
  Width(W);
  Height(H);
  CenterX(X+W/2);
  CenterY(Y+H/2);
 }
 void Set( float X, float Y, float W, float H ) {
  Width(W);
  Height(H);
  CenterX(X+W/2.0f);
  CenterY(Y+H/2.0f);
 }
 void Set( double X, double Y, double W, double H ) {
  Width(W);
  Height(H);  
  CenterX(X+W/2.0);
  CenterY(Y+H/2.0);
 }
 void Corners( int X, int Y, int X2, int Y2 ) {
  int x=X<X2?X:X2;
  int y=Y<Y2?Y:Y2;
  int w=abs(X2-X);
  int h=abs(Y2-Y);
  Set(x,y,w,h);
 }
 void Corners( float X, float Y, float X2, float Y2 ) {
  float x=X<X2?X:X2;
  float y=Y<Y2?Y:Y2;
  float w=abs(X2-X);
  float h=abs(Y2-Y);
  Set(x,y,w,h);
 }
 void Corners( double X, double Y, double X2, double Y2 ) {
  double x=X<X2?X:X2;
  double y=Y<Y2?Y:Y2;
  double w=abs(X2-X);
  double h=abs(Y2-Y);
  Set(x,y,w,h);
 }
 void Center( int cx, int cy ) {
  CenterX(cx);
  CenterY(cy);
 }
 void Center( float cx, float cy ) {
  CenterX(cx);
  CenterY(cy);
 }
 void Center( double cx, double cy ) {
  CenterX(cx);
  CenterY(cy);
 }
 void CenterX( int CX ) { PositionX(CX-w/2); }
 void CenterY( int CY ) { PositionY(CY-h/2); }
 void CenterX( float CX ) { PositionX(CX-fw/2.0f); }
 void CenterY( float CY ) { PositionY(CY-fh/2.0f); }
 void CenterX( double CX ) { PositionX(CX-dw/2.0); }
 void CenterY( double CY ) { PositionY(CY-dh/2.0); }
 void Set( Cartesian *in ) { Set(in->x,in->y,in->w,in->h); }
 void Get( Cartesian *out ) { out->Corners((int)x,(int)y,(int)x2,(int)y2,(int)w,(int)h); }
 void GetNormalizedPosition( double inx, double iny, double *outx, double *outy ) {
  if ( dx < 0 ) {
   if ( inx < dx ) (*outx)=-((inx-dx)/dw);
   else (*outx)=(inx+abs(dx))/dw;
  } else {
   if ( inx < dx ) {
    if ( inx < 0 ) {
     (*outx)=-((abs(inx)+dx)/dh);
    } else (*outx)=-((dx-inx)/dw);
   } else (*outx)=inx/dw;
  }
  if ( dy < 0 ) {
   if ( iny < dy ) (*outy)=-((iny-dy)/dh);
   else (*outy)=(iny+abs(dy))/dh;
  } else {
   if ( iny < dy ) {
    if ( iny < 0 ) {
     (*outy)=-((abs(iny)+dy)/dh);
    } else (*outy)=-((dy-iny)/dh);
   }
   else (*outy)=iny/dh;
  }
 }
 bool OnScreen()  {
  return (dx > -dw && dy > -dh && dx2 < display.wd+dw && dy2 < display.hd+dh );
 }
 bool OnScreeni() {
  return (x > -w && y > -h && x2 < display.w+w && y2 < display.h+h );
 }
 bool OnScreenf() {
  return (fx > -fw && fy > -fh && fx2 < display.wf+fw && fy2 < display.hf+fh );
 }
// void DrawDebug();
 bool within( int mx, int my ) {
  return ( mx >= x && mx <= x2 && my >= y && my <= y2 );
 }
 bool within( float mx, float my ) {
  return ( mx >= fx && mx <= fx2 && my >= fy && my <= fy2 );
 }
 bool within( double mx, double my ) {
  return ( mx >= dx && mx <= dx2 && my >= dy && my <= dy2 );
 }
 bool within( const Zint& mx, const Zint& my ) {
  return ( mx >= x && mx <= x2 && my >= y && my <= y2 );
 }
 bool within( const Zfloat& mx, const Zfloat& my ) {
  return ( mx >= fx && mx <= fx2 && my >= fy && my <= fy2 );
 }
 bool within( const Zdouble& mx, const Zdouble& my ) {
  return ( mx >= dx && mx <= dx2 && my >= dy && my <= dy2 );
 }
 bool within( ScreenPosition *box ) {
  return (
     WITHIN(box->x,box->y,x,y,x2,y2)
  || WITHIN(box->x,box->y2,x,y,x2,y2)
  || WITHIN(box->x2,box->y2,x,y,x2,y2)
  || WITHIN(box->x2,box->y,x,y,x2,y2)
  );
 }
 double Aspect() {
  return dw/dh;
 }
 double AspectInverse() {
  return dh/dw;
 }
MANY(ScreenPosition,ScreenPositionHandle,ScreenPositionHandles,"ScreenPosition",ScreenPositions,{})
 KEYSWORDSGroups("ScreenPosition",ScreenPosition)
 CLONES(ScreenPosition,ScreenPositions)
DONE(ScreenPosition)


This section implements fromString(const char *s):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 KEYWORDS({
  NUMWORD("x",x)
  else NUMWORD("y",y)
  else NUMWORD("w",w)
  else NUMWORD("h",h)
  else NUMWORD("x2",x2)
  else NUMWORD("y2",y2)
  else NUMWORD("cx",cx)
  else NUMWORD("cx",cy)
  else NUMWORD("h2",h2)
  else NUMWORD("w2",w2)
  else NUMWORD("fx",fx)
  else NUMWORD("fx",fy)
  else NUMWORD("fw",fw)
  else NUMWORD("fh",fh)
  else NUMWORD("fx2",fx2)
  else NUMWORD("fy2",fy2)
  else NUMWORD("fcx",fcx)
  else NUMWORD("fcy",fcy)
  else NUMWORD("fh2",fh2)
  else NUMWORD("fw2",fw2)
  else NUMWORD("dx",dx)
  else NUMWORD("dx",dy)
  else NUMWORD("dw",dw)
  else NUMWORD("dh",dh)
  else NUMWORD("dx2",dx2)
  else NUMWORD("dy2",dy2)
  else NUMWORD("dcx",dcx)
  else NUMWORD("dcy",dcy)
  else NUMWORD("dh2",dh2)
  else NUMWORD("dw2",dw2)
  else NUMWORD("a",angle)
  else BADKEY("ScreenPosition")
 })



This section implements std::string toString():

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 WORDKEYS({
  NUMBKEY("x",x)
  NUMBKEY("y",y)
  NUMBKEY("w",w)
  NUMBKEY("h",h)
  NUMBKEY("x2",x2)
  NUMBKEY("y2",y2)
  NUMBKEY("cx",cx)
  NUMBKEY("cx",cy)
  NUMBKEY("h2",h2)
  NUMBKEY("w2",w2)
  NUMBKEY("fx",fx)
  NUMBKEY("fx",fy)
  NUMBKEY("fw",fw)
  NUMBKEY("fh",fh)
  NUMBKEY("fx2",fx2)
  NUMBKEY("fy2",fy2)
  NUMBKEY("fcx",fcx)
  NUMBKEY("fcy",fcy)
  NUMBKEY("fh2",fh2)
  NUMBKEY("fw2",fw2)
  NUMBKEY("dx",dx)
  NUMBKEY("dx",dy)
  NUMBKEY("dw",dw)
  NUMBKEY("dh",dh)
  NUMBKEY("dx2",dx2)
  NUMBKEY("dy2",dy2)
  NUMBKEY("dcx",dcx)
  NUMBKEY("dcy",dcy)
  NUMBKEY("dh2",dh2)
  NUMBKEY("dw2",dw2)
  NUMBKEY("a",angle)
 })



This section implements ->Duplicate() an in-memory cloning:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 CLONE(ScreenPosition,{
  DUPE(x);
  DUPE(y);
  DUPE(x2);
  DUPE(y2);
  DUPE(w);
  DUPE(h);
  DUPE(cx);
  DUPE(cy);
  DUPE(w2);
  DUPE(h2);
  DUPE(fx);
  DUPE(fy);
  DUPE(fx2);
  DUPE(fy2);
  DUPE(fw);
  DUPE(fh);
  DUPE(fcx);
  DUPE(fcy);
  DUPE(fw2);
  DUPE(fh2);
  DUPE(dx);
  DUPE(dy);
  DUPE(dx2);
  DUPE(dy2);
  DUPE(dw);
  DUPE(dh);
  DUPE(dcx);
  DUPE(dcy);
  DUPE(dw2);
  DUPE(dh2);
  DUPE(angle);
 })


This section lets you read and write from a binary file:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 void BinaryRead( BinaryFile *open ) {
  open->read(&x);
  open->read(&y);
  open->read(&w);
  open->read(&h);
  open->read(&x2);
  open->read(&y2);
  open->read(&cx);
  open->read(&cy);
  open->read(&h2);
  open->read(&w2);
  open->read(&fx);
  open->read(&fy);
  open->read(&fw);
  open->read(&fh);
  open->read(&fx2);
  open->read(&fy2);
  open->read(&fcx);
  open->read(&fcy);
  open->read(&fh2);
  open->read(&fw2);
  open->read(&dx);
  open->read(&dy);
  open->read(&dw);
  open->read(&dh);
  open->read(&dx2);
  open->read(&dy2);
  open->read(&dcx);
  open->read(&dcy);
  open->read(&dh2);
  open->read(&dw2);
  open->read(&angle);
 }
 void BinaryWrite( BinaryFile *open ) {
  open->write(&x);
  open->write(&y);
  open->write(&w);
  open->write(&h);
  open->write(&x2);
  open->write(&y2);
  open->write(&cx);
  open->write(&cy);
  open->write(&h2);
  open->write(&w2);
  open->write(&fx);
  open->write(&fy);
  open->write(&fw);
  open->write(&fh);
  open->write(&fx2);
  open->write(&fy2);
  open->write(&fcx);
  open->write(&fcy);
  open->write(&fh2);
  open->write(&fw2);
  open->write(&dx);
  open->write(&dy);
  open->write(&dw);
  open->write(&dh);
  open->write(&dx2);
  open->write(&dy2);
  open->write(&dcx);
  open->write(&dcy);
  open->write(&dh2);
  open->write(&dw2);
  open->write(&angle);
 }