Check-in [1c929c032c]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Version bump. Code rewrite for improved UI and error checking. Added options for about and preset locations.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | v0.5 | release
Files: files | file ages | folders
SHA1: 1c929c032cc4246040e005e064e2031126733f3d
User & Date: tion 2018-10-08 03:37:06
References
2019-02-16
03:19 Wiki page release_notes artifact: cf2f198ba2 user: tion
Context
2018-10-08
03:40
release_notes: update 0.5 link check-in: c326837822 user: tion tags: trunk, v0.5
03:37
Version bump. Code rewrite for improved UI and error checking. Added options for about and preset locations. check-in: 1c929c032c user: tion tags: trunk, v0.5, release
2018-09-09
19:17
README: minor text changes to download instructions check-in: 7b77bd3649 user: tion tags: trunk, 0.4
Changes

Changes to README.

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
# nmspd - No Man's Sky Portal Decoder #
A Qt-based off-line No Man's Sky Portal Decoder, written in C++.









This program has been tested only on Linux kernel 4.14.55-lts with Qt v5.11.1. Please let me know if it works on other operating systems/configurations.

## Requirements ##
  * Qt5, Qt5base-devel (Lower versions are untested)

  * CC compiler (gcc, clang, etc)
  * [Fossil](https://fossil-scm.org) (if cloning repo)

### Download and Compile ###
Download the tarball from:<br />

  * [download page](/download)
  * current check-in page within the 'Timeline' tab above

or



Clone this repo:<br />
<code><pre>$ fossil clone https://chiselapp.com/user/tion/repository/nmspd nmspd.fossil
$ fossil open nmspd.fossil</pre></code>

Now that you have the source code...<br />

Build it:<br />
<code><pre>$ qmake -o Makefile nmspd.pro
$ make</pre></code>

Run it:<br />

<code><pre>$ ./nmspd
$ ./nmspd -style "Windows"</pre></code>






## Usage ##
![nmspd screen](/raw/db870102a540d151bd6101ab83a4a99575aa7570?m=image/jpeg)

Enter the coordinates. This can be obtained by building a signal booster in-game on any planet/moon. Look for the alphanumeric sequence in the lower left corner of the form: XXXX:12AB:34CD:EF56:7890. The actual values will differ. Only the last 16 digits are important and are what you enter into the program. So in this example, the coordinates you enter would be 12AB:34CD:EF56:7890, ignoring the XXXX that preceeds it.


Optionally select a portal number. If you are unsure what this should be, then leave it at 1.

Click 'convert to glyph' to obtain a glyph code and appropriate portal glyphs.


Alternatively, enter a glyph code and click 'convert to coordinates'. Glyph codes are 12-digit hexadecimal values.


## Credits ##
I am not and will never be smart enough to decode star system coordinates and portal sequences 
on my own. What others have discovered and shared I have merely adapted to the C++ language.

  * [conversion formula](https://www.reddit.com/r/NMSCoordinateExchange/wiki/tutorials/convert_portal_coordinates) posted on reddit
  * [pilgrim star path](https://pahefu.github.io/pilgrimstarpath/) - the great original
  * [inspiration](https://nmsportals.github.io) taken from the awesome NMS Portals site

|
>
>
>

>
>
>
>
>
|


<
>
|
|


<
<
<
<
<
<
<
>
>
|
|
|



|
|
|

<
>
|
<
>
>
>
>
>




|

>
|

<
<
>
|
>



|

|

|
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
# nmspd - No Man's Sky Portal Decoder #
This is a Qt/C++ program created for the common issue of lacking reliable internet connectivity 
to convert coordinates to portal addresses, and vice versa. There are several websites out there 
that will do this conversion for you. This program is for the people that do not always have 
that option.

This program has been tested on:<br />

  * Linux kernel: 4.14.55-lts, 4.18
  * Qt: 5.9, 5.11.1

Please let me know if it works on other operating systems/configurations.

## Requirements ##

  * Dependencies: Qt (qt5)
  * Make dependencies: CC compiler (gcc, clang, etc), Qt headers (qt5-devel)
  * Optional: [Fossil](https://fossil-scm.org) to clone this repo

### Download and Compile ###







Download the [latest release](/wiki/release_notes) and then extract the tarball.<br /><br />
or<br /><br />
Clone this repo:
<pre>$ fossil clone https://chiselapp.com/user/tion/repository/nmspd nmspd.fossil
$ fossil open nmspd.fossil</pre>

Now that you have the source code...<br />

Build it:
<pre>$ qmake -o Makefile nmspd.pro
$ make</pre>


Run the GUI:
<pre>$ nmspd</pre>

If you prefer to use a specific style already installed on your system:<br />
<pre>$ nmspd -style "NAME-OF-STYLE"</pre>

For information about the CLI:
<pre>$ nmspd -h</pre>

## Usage ##
![nmspd screen](/raw/db870102a540d151bd6101ab83a4a99575aa7570?m=image/jpeg)

It is fairly self-explanatory.

Enter the coordinates or glyph code into the appropriate field, then click the button to either 
convert to a glyph code or to a coordinate respectively. Optionally select a portal number when converting a coordinate. If you are unsure what this should be, then leave it at 1.



You can obtain coordinates from other players or in-game. Coordinates can be obtained in-game by building a signal booster on any planet or moon. Interact with the signal booster and look for an alphanumeric sequence in the lower left corner of the form:<br >
<blockquote>XXXX:12AB:34CD:EF56:7890</blockquote>
The actual values will differ. Only the last 16 digits are important and are what you enter into the program. In this example, the coordinates you enter would be 12AB:34CD:EF56:7890, ignoring the XXXX that preceeds it.

## Credits ##
I am not and will never be smart enough to decode star system coordinates and portal sequences 
on my own. What others have discovered and shared I have merely adapted to for use offline.

  * [conversion formula](https://www.reddit.com/r/NMSCoordinateExchange/wiki/tutorials/convert_portal_coordinates) - on reddit
  * [pilgrim star path](https://pahefu.github.io/pilgrimstarpath/) - the great original
  * [inspiration](https://nmsportals.github.io) taken from this awesome NMS Portals site

Changes to nmspd.pro.

1
2
3
4
5
6
7
8
9
10





11
12
13
TEMPLATE = app
TARGET = nmspd
QT = core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
DEFINES += QT_DEPRECATED_WARNINGS

# Inputs
HEADERS += src/toglyph.h
SOURCES += src/glyph.cpp src/toglyph.cpp





RESOURCES += src/toglyph.qrc

VERSION=0.4



<
|



|
|
>
>
>
>
>
|

|
1
2
3

4
5
6
7
8
9
10
11
12
13
14
15
16
17
TEMPLATE = app
TARGET = nmspd
QT = core gui

QT += widgets
DEFINES += QT_DEPRECATED_WARNINGS

# Inputs
HEADERS += src/nmsDecoder.h src/nmsDecoderMainWindow.h \
			src/nmsDecoderUtility.h \
			src/PortalAddressWindow.h
SOURCES += src/nmsDecoderMain.cpp src/nmsDecoder.cpp \
			src/nmsDecoderMainWindow.cpp \
		  	src/PortalAddressWindow.cpp \
          	src/nmsDecoderUtility.cpp
RESOURCES += src/nmsDecoderResources.qrc

VERSION=0.5

Added src/PortalAddressWindow.cpp.





































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
//==================================================================
#include "PortalAddressWindow.h"
#include "nmsDecoderUtility.h"
//==================================================================
///////////////////
// CLASS: Glyphs //
///////////////////
//==================================================================
Glyphs::Glyphs()
{
   initialize_glyphs();
   set_glyphs (QString());
   run_gui();
}
//------------------------------------------------------------------
Glyphs::Glyphs (const QString &_code)
{
   initialize_glyphs();
   set_glyphs (_code);
   run_gui();
}
//------------------------------------------------------------------
void Glyphs::initialize_glyphs ()
{
   for (int i = 0; i < 12; i++)
      glyph[i] = new QPushButton;
}
//------------------------------------------------------------------
void Glyphs::set_glyphs (const QString &_code)
{
   QStringList ignoreThis;

   // Do not change glyph symbols if provided code is the same as 
   // what we already have; just redraw it. Also must be a valid 
   // glyph code.
   if ( glyph_code.toLower() != _code.toLower() &&
        (is_valid_glyph_code (_code, ignoreThis) == true) )
      glyph_code = _code;

   for (int i = 0; i < 12; i++)
   {
      // Using aliases from qrc
      if ( _code.isEmpty() == false )
         glyph[i] -> setIcon (QIcon (QString(":" + QString(glyph_code.at(
                                                i).toUpper()) + ".jpg")));
      else
         glyph[i] -> setIcon (QIcon (QString(":empty.png")));

      glyph[i] -> setIconSize (QSize(40, 40));		// (60,60) is nice, too
      glyph[i] -> setAutoFillBackground (true);
      glyph[i] -> setText (QString());
      glyph[i] -> setCheckable (false);
      glyph[i] -> setFlat (false);
   }
}
//------------------------------------------------------------------
void Glyphs::clear_values()
{
   glyph_code.clear();
   for (int i = 0; i < 12; i++)
      glyph[i] -> setIcon (QIcon (":empty.png"));
}
//------------------------------------------------------------------
void Glyphs::run_gui()
{
   /*
   QPushButton *go_back = new QPushButton;
   go_back -> setText (tr ("Hide"));
   go_back -> setToolTip (tr ("Hide portal address window"));
   go_back -> setCheckable (false);

   QPushButton *exit = new QPushButton;
   exit -> setText (tr ("Quit"));
   exit -> setToolTip (tr ("Exit the application"));
   exit -> setCheckable (false);
   */
   /*
      Create horizontal layout.

      the_glyphs:
       +--------+--------+-----+---------+
       | glyph1 | glyph2 | ... | glyph12 |
       +--------+--------+-----+---------+
   */
   QGroupBox *the_glyphs = new QGroupBox (tr ("Portal Address"));
   QHBoxLayout *sequence = new QHBoxLayout;

   for (int i = 0; i < 12; i++)
      sequence -> addWidget (glyph[i]);

   the_glyphs -> setLayout (sequence);

   /*
      Create vertical layout.

      the_buttons:
       +---------+
       | go_back |
       +---------+
       |   exit  |
       +---------+
   */
   //QGroupBox *the_buttons = new QGroupBox;
   //QVBoxLayout *_buttons = new QVBoxLayout;
   //_buttons -> addWidget (go_back);
   //_buttons -> addWidget (exit);
   //the_buttons -> setLayout (_buttons);

   /*
      Create grid layout for the program.

      _layout:
       +----------------------------+
       | the_buttons |  the_glyphs  |
       +---------+------------------+
   */
   QGridLayout *_layout = new QGridLayout;
   _layout -> addWidget (the_glyphs, 0, 1, 1, 1);
   //_layout -> addWidget (the_buttons, 0, 0, 2, 1);
   setLayout (_layout);

   // Handle button signals (events)
   // Note: Using hide() rather than close() seems to keep memory
   // usage more consistent while application is open.
   //QObject::connect (go_back, SIGNAL (clicked(bool)),
   //                  this, SLOT (hide()));
   //QObject::connect (exit, SIGNAL (clicked(bool)),
   //                  QApplication::instance(), SLOT (quit()));
}
//==================================================================

Added src/PortalAddressWindow.h.





















































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
//==================================================================
#ifndef __NMS_GLYPHS_H__
#define __NMS_GLYPHS_H__
//==================================================================
#include <QtWidgets>
//==================================================================
class Glyphs : public QWidget
{
   // Macro to allow for custom slots and signals
   Q_OBJECT

   public:
      //////////////////
      // CONSTRUCTORS //
      //////////////////
      Glyphs();
      Glyphs(const QString &);

      // Initialize the GUI elements
      void run_gui();

      ////////////////////////////////
      // ACCESSING MEMBER FUNCTIONS //
      ////////////////////////////////
      void set_glyphs(const QString &);
      void clear_values();

   signals:

   public slots:
      void show_glyphs() { set_glyphs (glyph_code); }
      void show_glyphs(const QString &_code) { set_glyphs(_code); }

   private:
      QString glyph_code;
      QPushButton *glyph[12];

      void initialize_glyphs();
};
//==================================================================
#endif	// __NMS_GLYPHS_H__
//==================================================================

Name change from src/toglyph.cpp to src/nmsDecoder.cpp.

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
597
598
599
600
601
602
603
604
605
606
607

608
609
610

611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626

627
628
629
630
631
632
633


634
635
636


637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663

664
665
666
//==================================================================
#include <QtWidgets>
#include <sstream>          // std::stringstream
#include <iomanip>          // std::hex, std::oct, std::dec

#include "toglyph.h"

//==================================================================

Window::Window()



{
   /*
       QGroupBox to handle the display of widgets
   */
   star_group = new QGroupBox (tr ("Coordinates"));
   convert_group = new QGroupBox (tr ("Glyph Code"));
   the_glyphs = new QGroupBox (tr ("Portal Address"));
   to_convert_buttons = new QGroupBox;
   from_convert_buttons = new QGroupBox;
   other_buttons_group = new QGroupBox;

   /*
      QLabel to handle descriptors of information
   */
   QLabel *coordinatesLabel = new QLabel;
   coordinatesLabel -> setText (tr ("System address:"));

   QLabel *portalnumberLabel = new QLabel;
   portalnumberLabel -> setText (tr ("Portal Number:"));

   /*
      QLineEdit to accept coordinate data
   */
   coordinates_input = new QLineEdit;
   QValidator *validator = new QRegExpValidator (
      QRegExp("[0-9A-Fa-f]{4}:[0-9A-Fa-f]{4}:[0-9A-Fa-f]{4}:[0-9A-Fa-f]{4}"),
      this);
   coordinates_input -> setValidator (validator);
   coordinates_input -> setPlaceholderText ("12AB:34CD:56EF:7890");
   coordinates_input -> setCursorMoveStyle(Qt::VisualMoveStyle);
   coordinates_input -> setFocus();
   coordinates_input -> setMaxLength (19);

   /*
      SpinBox to store portal number
   */
   portal_number = new QSpinBox;
   portal_number -> setRange (1, 16);
   portal_number -> setSingleStep (1);
   portal_number -> setValue (1);

   /*
      QLineEdit to store glyph code
   */
   glyph_sequence = new QLineEdit;
   glyph_sequence -> setMaxLength (12);

   /*
      QPushButton to handle convert operations
   */
   convert_to_glyph_button = new QPushButton;
   convert_to_glyph_button -> setText (tr ("Convert to glyphs"));
   convert_to_glyph_button -> setToolTip (
      tr ("Convert from coordinates to glyph sequence"));
   convert_to_glyph_button -> setCheckable (false);
   convert_from_glyph_button = new QPushButton;
   convert_from_glyph_button -> setText (tr ("Convert to coordinates"));
   convert_from_glyph_button -> setToolTip (
      tr ("Convert from glyph sequence to coordinates"));
   convert_from_glyph_button -> setCheckable (false);

   /*
      QPushButton to handle clearing out data from screen
   */
   clear_button = new QPushButton;
   clear_button -> setText (tr ("Clear"));
   clear_button -> setToolTip (tr ("Clear out coordinates and glyphs"));
   clear_button -> setCheckable (false);

   /*
      QPushButton to handle exiting the application
   */
   exit_button = new QPushButton;
   exit_button -> setText (tr ("Quit"));
   exit_button -> setIcon (QIcon());
   exit_button -> setIconSize (QSize(40, 40));
   exit_button -> setCheckable (false);
   exit_button -> setToolTip (tr ("Exit the application"));

   // Create/allocate widgets and their data
   initialize_coordinates();
   initialize_glyphs();


   /*
      Create horizontal layout (convert_buttons)
      Format:
       +---------------------------------+
       | convert_to_glyph_button | clear |
       +---------------------------------+
   */
   QHBoxLayout *convert_to_buttons = new QHBoxLayout;
   convert_to_buttons -> addWidget (convert_to_glyph_button);
   to_convert_buttons -> setLayout (convert_to_buttons);


   QHBoxLayout *convert_from_buttons = new QHBoxLayout;
   convert_from_buttons -> addWidget (convert_from_glyph_button);
   from_convert_buttons -> setLayout (convert_from_buttons);


   /*
      Create layouts

       star_group:
       +-------------------+

       | coordinates_input |
       +-------------------+
       | portalnumberLabel |
       +-------------------+
       | portal_number     |
       +-------------------+



       other_buttons_group:
       +----------------------------+
       | clear_button | exit_button |
       +----------------------------+

       convert_group:
       +---------------------------+
       | convert_to_glyph_button   |
       +---------------------------+
       |        glyph_sequnce      |
       +---------------------------+
       | convert_from_glyph_button |
       +---------------------------+
   */
   QVBoxLayout *the_layout = new QVBoxLayout;
   the_layout -> addWidget (coordinates_input);
   the_layout -> addWidget (portalnumberLabel);
   the_layout -> addWidget (portal_number);
   star_group -> setLayout (the_layout);

   QHBoxLayout *other_buttons_layout = new QHBoxLayout;
   other_buttons_layout -> addWidget (clear_button);
   other_buttons_layout -> addWidget (exit_button);
   other_buttons_group -> setLayout (other_buttons_layout);

   QVBoxLayout *glyphcode_layout = new QVBoxLayout;
   glyphcode_layout -> addWidget (convert_to_glyph_button);
   glyphcode_layout -> addWidget (glyph_sequence);
   glyphcode_layout -> addWidget (convert_from_glyph_button);
   convert_group -> setLayout (glyphcode_layout);

   /*
      Create horizontal layout
      the_glyphs:
       +--------------------------+
       | Glyph1 Glyph2 .. Glyph12 |
       +--------------------------+
   */
   QHBoxLayout *seq_layout = new QHBoxLayout;

   for (int i = 0; i < 12; i++)
   {
      seq_layout -> addWidget (glyph[i]);
   }

   the_glyphs -> setLayout (seq_layout);

   /*
      Create grid layout
      _layout:
       +----------------------------------------+
       |   star_group   |  other_buttons_group  |
       +----------------------------------------+
       |  convert_group |    the_glyphs         |
       +----------------------------------------+

                    or essentially:

       +------------------------------------------------------------+
       |  coordinates_input |                    |                  |
       |  portalnumberLabel |    clear_button    |   exit_button    |
       |      portal_number |                    |                  |
       +------------------------------------------------------------+
       |   convert_to_glyph |                                       |
       |     glyph_sequence |             Portal Address            |
       | convert_from_glyph |                                       |
       +------------------------------------------------------------+
   */
   QGridLayout *_layout = new QGridLayout;
   _layout -> addWidget (star_group, 0, 0, 2, 1);
   _layout -> addWidget (other_buttons_group, 0, 1, 1, 1);
   _layout -> addWidget (the_glyphs, 2, 1, 2, 1);
   _layout -> addWidget (convert_group, 2, 0, 3, 1);
   setLayout (_layout);

   /*
      Handle custom slots/signals (events)
   */
   QObject::connect (convert_to_glyph_button, SIGNAL (clicked(bool)),
                     this, SLOT (convert_to_glyph_sequence()));
   QObject::connect (convert_from_glyph_button, SIGNAL (clicked(bool)),
                     this, SLOT (convert_from_glyph_sequence()));
   QObject::connect (clear_button, SIGNAL (clicked(bool)),
                     this, SLOT (clear_values()));
   QObject::connect (exit_button, SIGNAL (clicked(bool)),
                     QApplication::instance(), SLOT (quit()));
}
//------------------------------------------------------------------
void Window::initialize_coordinates()
{
   // Zero star coordinates
   star_coordinates.clear();
   coordinates_input -> clear();
   portal_number -> setValue (1);


}
//------------------------------------------------------------------
void Window::initialize_glyphs()

{
   // Zero glyph values and icons
   glyph_sequence -> clear();




   for (int i = 0; i < 12; i++)


   {
      glyph[i] = new QPushButton;
      glyph[i] -> setIcon(QIcon(":../images/empty.png"));
      glyph[i] -> setIconSize (QSize(40, 40));
      glyph[i] -> setText (QString());
      glyph[i] -> setAutoFillBackground (true);
      glyph[i] -> setCheckable (false);
      glyph[i] -> setFlat (true);

   }
}
//------------------------------------------------------------------
void Window::clear_values()

{
   initialize_coordinates();
   clear_glyphs();




}
//------------------------------------------------------------------
void Window::clear_glyphs()
{
   glyph_sequence -> clear();

   // Set a null icon
   for (int i = 0; i < 12; i++)
   {
      glyph[i] -> setIcon(QIcon(":empty.png"));
      glyph[i] -> setIconSize (QSize(40, 40));
      glyph[i] -> setText (QString());
      glyph[i] -> setAutoFillBackground (true);
      glyph[i] -> setCheckable (false);
      glyph[i] -> setFlat (true);
   }
}
//------------------------------------------------------------------
void Window::convert_from_glyph_sequence ()
{
   // Verify glyph code is valid hexadecimal
   QValidator *glyph_validator = new QRegExpValidator (
      QRegExp("[0-9A-Fa-f]{12}"),
      this);
   glyph_sequence -> setValidator (glyph_validator);

   // TODO: Add check that glyph code is within valid range.
   if ( glyph_sequence -> hasAcceptableInput() == false )
   {

      clear_glyphs();
      glyph_sequence -> setMaxLength (30);
      glyph_sequence -> setText ("Invalid glyph code entered !");

   }
   else

   {
      /*
         Parse through the glyph code

          => Glyph #1: Portal number (1-16)
          => Glyph #2-4: Star class (coordinate_star)
          => Glyph #5-6: coordinate_y - 0x801
          => Glyph #7-9: coordinate_z - 0x81
          => Glyph #10-12: coordinate_x - 0x801
      */
      QStringList them_glyphs = glyph_sequence -> text().split("");
      QString coordinate_star, coordinate_x, coordinate_y, coordinate_z,
              temp_str, _glyph;
      int temp_value, offset = 0, temp_convert;


      // Iterate over the "strings" in _glyph, each of which is
      // a digit in the glyph code
      _glyph.clear();

      for (int i = 0; i < them_glyphs.size(); i++)
      {
         _glyph += them_glyphs.at(i).toLocal8Bit().constData();
      }

      /*
          Star Class is taken directly from the glyph code.

          Adding zero-padding if necessary to fill up to 4 digits.
      */

      coordinate_star = QString(_glyph[1]) + QString(_glyph[2]) + QString(
                           _glyph[3]);

      // Pad with zeros on the left
      for (int i = coordinate_star.size(); i < 4 ; i++)
      {
         coordinate_star.insert(0, '0');
      }

      /*
          Coordinate-Y

          Adding zero-padding if necessary to fill up to 2 digits.
      */
      temp_str = QString(_glyph[4]) + QString(_glyph[5]);
      temp_convert = convert_hex_to_integer (temp_str);

      // Add leading digit if glyph code required truncate.
      // This is required for situations where removal of a leading
      // digit during coordinate -> glyph code.
      if ( temp_convert < 129 )
      {
         offset = 256;
      }
      else
      {
         offset = 0;
      }

      temp_value = (temp_convert + offset) - 129;
      coordinate_y = convert_integer_to_hex (temp_value);

      // Pad with zeros on the left
      for (int i = coordinate_y.size(); i < 4; i++)
      {
         coordinate_y.insert(0, '0');
      }


      /*
          Coordinate-Z

          Adding zero-padding if necessary to fill up to 4 digits.
      */
      temp_str = QString(_glyph[6]) + QString(_glyph[7]) + QString(
                    _glyph[8]);
      temp_convert = convert_hex_to_integer (temp_str);

      // Add leading digit(s) if glyph code required truncate.
      // This is required for situations where removal of leading
      // digits during coordinate -> glyph code.
      if ( temp_convert < 2049 )
      {
         offset = 4096;
      }
      else
      {
         offset = 0;
      }

      temp_value = (temp_convert + offset) - 2049;
      coordinate_z = convert_integer_to_hex (temp_value);

      // Pad with zeros on the left
      for (int i = coordinate_z.size(); i < 4; i++)
      {
         coordinate_z.insert(0, '0');
      }


      /*
          Coordinate-X

          Adding zero-padding if necessary to fill up to 4 digits.
      */
      temp_str = QString(_glyph[9]) + QString(_glyph[10]) + QString(
                    _glyph[11]);
      temp_convert = convert_hex_to_integer (temp_str);

      // Add leading digits if glyph code required truncate.
      // This is required for situations where removal of leading
      // digits during coordinate -> glyph code.
      if ( temp_convert < 2049 )
      {
         offset = 4096;
      }
      else
      {
         offset = 0;
      }

      temp_value = (temp_convert + offset) - 2049;
      coordinate_x = convert_integer_to_hex (temp_value);



      // Pad with zeros on the left
      for (int i = coordinate_x.size(); i < 4; i++)
      {
         coordinate_x.insert(0, '0');
      }

      // Set coordinate data
      portal_number -> setValue (convert_hex_to_integer(QString(_glyph[0])) + 1);
      temp_str = coordinate_x + ":" + coordinate_y + ":" + coordinate_z +
                 ":" +
                 coordinate_star;
      coordinates_input -> setText (temp_str);

      // Set glyphs
      display_glyph();






   }



   glyph_sequence -> setValidator (0);

}

//------------------------------------------------------------------
void Window::convert_to_glyph_sequence ()
{
   if ( coordinates_input -> hasAcceptableInput() )




   {
      std::stringstream flex_string;
      std::string _astring;


      QString coordinate_star, coordinate_x, coordinate_y, coordinate_z,
              result;

      // Parse through the colons
      coordinate_x = coordinates_input -> text().section(':', 0,
                     0).toUpper();
      coordinate_y = coordinates_input -> text().section(':', 1,
                     1).toUpper();
      coordinate_z = coordinates_input -> text().section(':', 2,
                     2).toUpper();
      coordinate_star = coordinates_input -> text().section(':', 3,
                        3).toUpper();
      /*
         Valid coordinates:
         0001:0001:0001:0001 ... 0FFF:00FF:0FFF:02FF
      */
      int int_of_x = convert_hex_to_integer (coordinate_x);
      int int_of_y = convert_hex_to_integer (coordinate_y);
      int int_of_z = convert_hex_to_integer (coordinate_z);
      int int_of_star = convert_hex_to_integer (coordinate_star);

      // Invalid coordinate address. DO NOT CONVERT to glyphs.
      if ( int_of_x < 1 || int_of_x > 4095)
      {
         clear_glyphs();
         glyph_sequence -> setMaxLength(20);
         glyph_sequence -> setText ("\"" + coordinate_x + "\" invalid");
      }
      else if ( int_of_y < 1 || int_of_y > 255 )
      {
         clear_glyphs();
         glyph_sequence -> setMaxLength(20);
         glyph_sequence -> setText ("\"" + coordinate_y + "\" invalid");
      }
      else if ( int_of_z < 1 || int_of_z > 4095 )
      {
         clear_glyphs();
         glyph_sequence -> setMaxLength(20);
         glyph_sequence -> setText ("\"" + coordinate_z + "\" invalid");
      }
      else if ( int_of_star < 1 || int_of_star > 767 )
      {
         clear_glyphs();
         glyph_sequence -> setMaxLength(20);
         glyph_sequence -> setText ("\"" + coordinate_star + "\" invalid");
      }
      else
      {
         int temp = 0, padding = 0;
         flex_string.str ( std::string() );
         flex_string.clear();

         /*
            Glyph of star index/class
            The last 3 digits of the star index -> x:y:0SSS

            The zero is usually reserved for the portal number: 1-16
            Using the entire star index/class assumes portal number 1.
            So if wanting a specific portal number, use:

             => ((portal number - 1) * (4096)) + (decimal of star index/class)

         */
         temp = (((portal_number -> value() - 1) * 4096) + int_of_star);

         // Pad with zeros if necessary
         if ( temp < 4096 )
         {
            padding = 2;
         }
         else
         {
            padding = 1;
         }

         flex_string << std::setfill ('0') << std::setw(padding * 2) <<
                     std::hex << temp;
         _astring = flex_string.str();
         result = QString::fromStdString(_astring).toUpper();

         const QString starIndex_glyph = result;

         /*
            Glyph of y-axis of star system coordinates

             => (decimal of y) + 129
             => y + (0x81)

            Y-coordinate must be 2-bytes or no greater than 0xFF (255)
         */
         temp = (int_of_y + 129);

         if ( temp > 255 )
         {
            // Removing leading digit

            temp -= 256;
         }

         // Pad with zeros if necessary
         flex_string.str ( std::string() );
         flex_string.clear();

         if ( temp < 10 )
         {
            padding = 1;
         }
         else
         {
            padding = 0;
         }

         flex_string << std::setfill ('0') << std::setw(padding * 2) <<
                     std::hex << temp;
         _astring = flex_string.str();
         result = QString::fromStdString(_astring).toUpper();

         const QString glyph_of_y = result;

         /*
            Glyph of z-axis of star system coordinates

             => (decimal of z) + 2049
             => z + (0x801)

             Z-coordinate must be 3-bytes or no greater than 0xFFF (4095)
         */
         temp = (int_of_z + 2049);

         if ( temp > 4095 )
         {
            // Remove leading digit

            temp -= 4096;
         }

         // Pad with zeros if necessary
         flex_string.str ( std::string() );
         flex_string.clear();

         if ( temp < 10 )
         {
            padding = 1;
         }
         else if ( temp < 100 )
         {
            padding = 1;
         }
         else
         {
            padding = 0;
         }

         flex_string << std::setfill ('0') << std::setw(padding) << std::hex <<
                     temp;
         _astring = flex_string.str();
         result = QString::fromStdString(_astring).toUpper();

         const QString glyph_of_z = result;

         /*
            Glyph of x-axis of star system coordinates

             => (decimal of x) + 2049
             => x + (0x801)

            X-coordinate must be 3-bytes or no greater than 0xFFF (4095)
         */
         temp = (int_of_x + 2049);

         if ( temp > 4095 )
         {
            // Remove leading digit

            temp -= 4096;
         }

         flex_string.str ( std::string() );
         flex_string.clear();

         if ( temp < 10 )
         {
            padding = 1;
         }
         else if ( temp < 100 )
         {
            padding = 1;
         }
         else
         {
            padding = 0;
         }

         flex_string << std::setfill ('0') << std::setw(padding) << std::hex <<
                     temp;
         _astring = flex_string.str();
         result = QString::fromStdString(_astring).toUpper();

         const QString glyph_of_x = result;

         glyph_sequence -> setMaxLength(12);

         glyph_sequence -> setText (starIndex_glyph + glyph_of_y + glyph_of_z +
                                    glyph_of_x);
         display_glyph();
      }
   }
   else
   {
      // Invalid coordinates entered, DO NO COMPUTE glyph sequence
      clear_glyphs();
      glyph_sequence -> setMaxLength(30);
      glyph_sequence ->
      setText ("Invalid address: out of galaxy boundaries");
   }
}
//------------------------------------------------------------------
int Window::convert_hex_to_integer (const QString &coordinate)

{
   std::stringstream flex_string;
   flex_string << std::dec << coordinate.toUtf8().constData();
   std::string something (flex_string.str());
   QString result = QString::fromStdString(something);
   bool ok;
   return (result.toInt(&ok, 16));


}
//------------------------------------------------------------------
QString Window::convert_integer_to_hex (const int &number)


{
   std::stringstream flex_string;
   flex_string << std::setfill ('0') << std::setw(2) << std::hex <<
               number;
   std::string _astring (flex_string.str());
   QString result = QString::fromStdString(_astring).toUpper();
   return (result);
}
//------------------------------------------------------------------
void Window::display_glyph()
{
   QPushButton current_glyph;
   QString fileName, temp;
   // const QString part = "../images/";
   const QString part = ":";            // Using alias from .qrc
   const QString ext = ".jpg";
   temp = glyph_sequence -> text().toUpper();

   for (int i = 0; i < 12; i++)
   {
      fileName = part + temp[i] + ext;
      glyph[i] -> setIcon (QIcon(fileName));
      glyph[i] -> setIconSize (QSize(40, 40));
      glyph[i] -> setFlat (false);
      glyph[i] -> setAutoFillBackground (true);
      glyph[i] -> setText (QString());
      glyph[i] -> setCheckable (false);

   }
}
//------------------------------------------------------------------


<
<

|
>

>
|
>
>
>

<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


>
|
<
<
<
|
<
<
<
<
<
<
>
|
<
<
<
>

<
<
<
<
<
>
|
<
<
<
<
<
>
>
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<

<
|
<
<
>
>


<
>

<
<
>
>
>

<
>
>
|
<
<
<
<
<
<
<
>
|
<

<
>

<
<
>
>
>
>


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|

|
<
<
<
<
<
<
<
<
>
|
<
<
>
|
<
>





|
|
|
|

<



<
>


|


<

<



<
|

>
|
|
<
<
<
<
<
<



<
|





|
|

<

<

<

|
<

|
<
<
<
<
<
<
>



<
|






|
|

<

<

<

|
<

|
<
<
<
<
<
<
<
>


<
|






|
|

<

<

<

|
<

<
>
>

<
<
<
<
<
<

|



|
|
|
<
>
>
>
>
>
>
|
>
>

<
>
|
>

|

<
>
>
>
>
|
<
<
>
>

|


|
|
|
|
|
|
|
|
<
<
<
<




<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<

|
|
|

|
|
|

|

|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>
|

|
|

|
|

|
|
|

<
<
|
>
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>
|

|
|

|
|

|
|
|

<
<
|
>
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>
|

|
|

|
|

|
|
|

<
<
|
>
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>
|

<
>
|
|
<
|
<



<
<
<
<
<
<
<
<
>
|
<
<
<
<
<
<
>
>
|
<
<
>
>
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>



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
//==================================================================
#include <QtWidgets>



#include "nmsDecoder.h"
#include "nmsDecoderUtility.h"
//==================================================================
////////////////////
// CLASS: Console //
////////////////////
//==================================================================
Console::Console()
{



   portal = 1;











































































   initialize_coordinates();
   initialize_glyphs();
   clear_info();
}



//------------------------------------------------------------------






Console::Console (QString _code, bool isCoordinate)
{



   portal = 1;






   if ( isCoordinate == true )
      coordinates = _code;





   else
      glyph_code = _code;
}


























































//------------------------------------------------------------------
























void Console::clear_values()





{

   initialize_coordinates();


   initialize_glyphs();
   clear_info();
}
//------------------------------------------------------------------

QString Console::show_info()
{


   // Ideally this function should never be called unless
   // there is something to display from info -- coordinate errors
   QString result = QString();


   if ( info.isEmpty() == false )
      result.append( QString("[" + get_info().join("] [") + "]") );








   return (result);
}

//------------------------------------------------------------------

void Console::set_portal (const int _number)
{


   if ( is_valid_portal(_number) == true )
      portal = (_number);
   else
      portal = 1;
}
//------------------------------------------------------------------
















void Console::convert_from_glyph_sequence ()
{
   // Verify glyph code is valid hexadecimal and is valid








   // glyph code sequence.
   clear_info();


   QStringList temp_info = QStringList();


   if ( is_valid_glyph_code(glyph_code, temp_info) == true )
   {
      /*
         Parse through the glyph code

          => Glyph #1: Portal number (1-16)
          => Glyph #2, #3, #4: Star class (coordinate_star)
          => Glyph #5, #6: (coordinate_y - 0x801)
          => Glyph #7, #8, #9: (coordinate_z - 0x81)
          => Glyph #10, #11, #12: (coordinate_x - 0x801)
      */

      QString coordinate_star, coordinate_x, coordinate_y, coordinate_z,
              temp_str, _glyph;
      int temp_value, offset = 0, temp_convert;

      _glyph.clear();
      // Iterate over the "strings" in _glyph, each of which is
      // a digit in the glyph code
      QStringList them_glyphs = glyph_code.split("");

      for (int i = 0; i < them_glyphs.size(); i++)

         _glyph += them_glyphs.at(i).toLocal8Bit().constData();


      /*
          Star Class is taken directly from the glyph code.

          Add zero-padding to fill up to 4 digits.
      */
      coordinate_star = pad_with_zeros((QString(_glyph[1]) + QString(
                                           _glyph[2]) + QString(
                                           _glyph[3]).toUpper()), 4);







      /*
          Coordinate-Y

          Add zero-padding to fill up to 2 digits.
      */
      temp_str = QString(_glyph[4]) + QString(_glyph[5]);
      temp_convert = convert_hex_to_integer (temp_str);

      // Add leading digit if glyph code required truncate.
      // This step is required for situations where removal
      // of a leading digit during coordinate -> glyph code.
      if ( temp_convert < 129 )

         offset = 256;

      else

         offset = 0;


      temp_value = (temp_convert + offset) - 129;
      coordinate_y = pad_with_zeros((convert_integer_to_hex (temp_value)),






                                    4);

      /*
          Coordinate-Z

          Add zero-padding to fill up to 4 digits.
      */
      temp_str = QString(_glyph[6]) + QString(_glyph[7]) + QString(
                    _glyph[8]);
      temp_convert = convert_hex_to_integer (temp_str);

      // Add leading digit(s) if glyph code required truncate.
      // This step is required for situations where removal of
      // leading digits during coordinate -> glyph code.
      if ( temp_convert < 2049 )

         offset = 4096;

      else

         offset = 0;


      temp_value = (temp_convert + offset) - 2049;
      coordinate_z = pad_with_zeros((convert_integer_to_hex (temp_value)),







                                    4);
      /*
          Coordinate-X

          Add zero-padding to fill up to 4 digits.
      */
      temp_str = QString(_glyph[9]) + QString(_glyph[10]) + QString(
                    _glyph[11]);
      temp_convert = convert_hex_to_integer (temp_str);

      // Add leading digits if glyph code required truncate.
      // This step is required for situations where removal of
      // leading digits during coordinate -> glyph code.
      if ( temp_convert < 2049 )

         offset = 4096;

      else

         offset = 0;


      temp_value = (temp_convert + offset) - 2049;

      coordinate_x = pad_with_zeros((convert_integer_to_hex(temp_value)),
                                    4);







      // Set coordinate data
      portal = (convert_hex_to_integer(QString(_glyph[0])) + 1);
      temp_str = coordinate_x + ":" + coordinate_y + ":" + coordinate_z +
                 ":" +
                 coordinate_star;
      coordinates = (QString(temp_str).toUpper());
   }
   else

   {
      // Add invalid code segments to element info
      if ( temp_info.isEmpty() == false )
      {
         for (int i = 0; i < temp_info.size(); i++)
            add_to_info(QString(temp_info.at(i)));
      }
      else
         add_to_info(glyph_code);


      clear_glyphs();
   }
}
//------------------------------------------------------------------
void Console::convert_to_glyph_sequence ()
{

   // Verify coordinates are valid hexadecimal and
   // within the known boundaries of the galaxy.
   clear_info();
   QStringList verb = QStringList();



   if ( is_valid_coordinate(coordinates, verb) == true )
   {
      QString coordinate_star, coordinate_x, coordinate_y, coordinate_z,
              result = QString();

      // Parse through the colons
      coordinate_x = coordinates.section(':', 0,
                                         0).toUpper();
      coordinate_y = coordinates.section(':', 1,
                                         1).toUpper();
      coordinate_z = coordinates.section(':', 2,
                                         2).toUpper();
      coordinate_star = coordinates.section(':', 3,
                                            3).toUpper();




      int int_of_x = convert_hex_to_integer (coordinate_x);
      int int_of_y = convert_hex_to_integer (coordinate_y);
      int int_of_z = convert_hex_to_integer (coordinate_z);
      int int_of_star = convert_hex_to_integer (coordinate_star);




























      int temp = 0;



      /*
         Glyph of star index/class
         The last 3 digits of the star index -> x:y:0SSS

         The zero is usually reserved for the portal number: 1-16
         Using the entire star index/class assumes portal number 1.
         So if wanting a specific portal number, use:

          => ((portal number - 1) * (4096)) + (decimal of star index/class)

      */
      temp = (((portal - 1) * 4096) + int_of_star);















      result = (convert_integer_to_hex(temp).toUpper());
      const QString starIndex_glyph = pad_with_zeros(result, 4);

      /*
         Glyph of y-axis of star system coordinates

          => (decimal of y) + 129
          => y + (0x81)

         Y-coordinate must be 2-bytes or no greater than 0xFF (255)
      */
      temp = (int_of_y + 129);



      // Removing leading digit
      if ( temp > 255 )
         temp -= 256;



















      result = (convert_integer_to_hex(temp).toUpper());
      const QString glyph_of_y = pad_with_zeros(result, 2);

      /*
         Glyph of z-axis of star system coordinates

          => (decimal of z) + 2049
          => z + (0x801)

          Z-coordinate must be 3-bytes or no greater than 0xFFF (4095)
      */
      temp = (int_of_z + 2049);



      // Remove leading digit
      if ( temp > 4095 )
         temp -= 4096;























      result = (convert_integer_to_hex(temp).toUpper());
      const QString glyph_of_z = pad_with_zeros(result, 3);

      /*
         Glyph of x-axis of star system coordinates

          => (decimal of x) + 2049
          => x + (0x801)

         X-coordinate must be 3-bytes or no greater than 0xFFF (4095)
      */
      temp = (int_of_x + 2049);



      // Remove leading digit
      if ( temp > 4095 )
         temp -= 4096;






















      result = (convert_integer_to_hex(temp).toUpper());
      const QString glyph_of_x = pad_with_zeros(result, 3);


      // Set glyph code
      glyph_code = (QString (starIndex_glyph + glyph_of_y + glyph_of_z +
                             glyph_of_x).toUpper());

   }

   else
   {
      // Invalid coordinates entered, DO NO COMPUTE glyph sequence








      if ( verb.isEmpty() == false )
      {






         for (int i = 0; i < verb.size(); i++)
            add_to_info ( QString(verb.at(i)) );
      }


      else
         add_to_info (coordinates);



























      //coordinates.clear();
   }
}
//------------------------------------------------------------------

Name change from src/toglyph.h to src/nmsDecoder.h.

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
/**
    File: toglyph.h
    Creation Date: 2018-08-23
    Author: tion <tion7680@protonmail.com>
    Description: Handles converting a star system coordinates to
     a glyph sequence.
    License: GPL-3.0 or later
**/
//==================================================================
#ifndef _GLYPHCONVERT_H_
#define _GLYPHCONVERT_H_
//==================================================================
#include <QtWidgets>
//==================================================================
class Window : public QWidget

{
      // Macro to allow for custom slots and signals
      Q_OBJECT

   public:

      // CONSTRUCTOR










      Window();


   signals:








   public slots:

      void convert_to_glyph_sequence();
      void convert_from_glyph_sequence();
      void display_glyph();














      void clear_values();
      void clear_glyphs();


   private:
      void initialize_glyphs();
      void initialize_coordinates();











      int convert_hex_to_integer (const QString &);
      QString convert_integer_to_hex (const int &);

      QLineEdit *coordinates_input;
      QLineEdit *glyph_sequence;
      QSpinBox *portal_number;
      QGroupBox *star_group;
      QGroupBox *convert_group;
      QGroupBox *the_glyphs;
      QGroupBox *to_convert_buttons;
      QGroupBox *from_convert_buttons;
      QGroupBox *other_buttons_group;
      QPushButton *exit_button;
      QPushButton *convert_to_glyph_button;
      QPushButton *convert_from_glyph_button;
      QPushButton *clear_button;
      QPushButton *glyph[12];
      QList<QString> star_coordinates;
};




































//------------------------------------------------------------------
#endif  // _GLYPHCONVERT_H_
//------------------------------------------------------------------
<
<
<
<
<
<
<
<

|
|

|

<
>

<
<
<

>
|
>
>
>
>
>
>
>
>
>
>
|
>

<
>
>
>
>
>
>
>

<
>
|
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|
>


|
|
>
>
>
>
>
>
>
>
>
>
>
|
|

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|









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








//==================================================================
#ifndef __NMS_DECODER_H__
#define __NMS_DECODER_H__
//==================================================================
#include <QtCore>
//==================================================================

class Console : public QObject
{



   public:
      //////////////////
      // CONSTRUCTORS //
      //////////////////
      Console();
      Console(QString _code, bool isCoordinate = true);

      ////////////////////////////////
      // ACCESSING MEMBER FUNCTIONS //
      ////////////////////////////////
      QString get_glyph_sequence() { return (glyph_code); }
      QString get_coordinate() { return (coordinates); }
      QStringList get_info() { return (info); }
      QString show_info();
      int get_portal() { return (portal); }


      ////////////////////////////////
      // MODIFYING MEMBER FUNCTIONS //
      ////////////////////////////////
      void set_coordinate (const QString _code) { coordinates = (_code); }
      void set_portal (const int);
      void set_glyph_code (const QString _code) { glyph_code = (_code); }
      void add_to_info (const QString x) { if (x.size() > 0) info += x; }


      /*
        void convert_to_glyph_sequence()
        void convert_from_glyph_sequence()


        Handles conversion and variable re-assignment of valid
        coordinates/glyph codes. Makes calls to is_valid_coordinate()
        and is_valid_glyph_code() to determine if conversion should
        take place.
      */
      void convert_to_glyph_sequence();
      void convert_from_glyph_sequence();

      /*
        Reset variable values. clear_values() resets values of all
        private variables. clear_glyphs() is meant specifically
        for resetting the glyph code.
      */
      void clear_values();
      void clear_glyphs() { glyph_code.clear(); }
      void clear_info() { info.clear(); }

   private:
      void initialize_glyphs() { glyph_code.clear(); }
      void initialize_coordinates() { coordinates.clear(); portal = 1; }

      QString coordinates;
      QString glyph_code;
      QStringList info;
      int portal;
};
//------------------------------------------------------------------
////////////////////////////////
// NON-CLASS HELPER FUNCTIONS //
////////////////////////////////
//------------------------------------------------------------------
int convert_hex_to_integer (const QString);
QString convert_integer_to_hex (const int);

















/*
   QString pad_with_zeros (const QString, const int)

   Returns the QString parameter pre-pended with zeros to 
   fill its size to the int parameter, which must be a value 
   between 1 and 4.
*/
QString pad_with_zeros (const QString, const int);

/*
  bool is_valid_coordinate(const QString)

  Coordinate is 16 hex characters long, with 3 semicolons to
  separate the different axis (x,y,z,star class). QStringList 
  parameter will hold invalid segments found within the 
  provided _code.
*/
bool is_valid_coordinate(const QString _code, QStringList &);

/*
  bool is_valid_glyph_code(const QString)

  Glyph code is 12 hex characters long. Must also be between
  a lower and upper limit: 000182802802 .. F2FF80800800. 
  QStringList parameter will hold invalid segements found 
  within the provided _code.
*/
bool is_valid_glyph_code(const QString _code, QStringList &);

/*
  bool is_valid_portal (int)

  Returns true if parameter is a decimal number between 
  1 and 16.
*/
bool is_valid_portal(int _code);
//------------------------------------------------------------------
#endif  // __NMS_DECODER_H__
//------------------------------------------------------------------

Added src/nmsDecoderMain.cpp.





























































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
//==================================================================
#include <QCommandLineParser>
#include <QApplication>
#include <QTextStream>          // output text to screen/stdout
#include <QStyleFactory>

#include "nmsDecoder.h"
#include "nmsDecoderMainWindow.h"
#include "PortalAddressWindow.h"
//==================================================================
void to_glyphs (const QString code, const bool valid,
                QTextStream &outs, const bool verbosity)
{
   Console *window = new Console(code, valid);
   window -> convert_to_glyph_sequence();

   if ( window -> get_glyph_sequence() != QString() )
      outs << window -> get_glyph_sequence();
   else
   {
      if ( verbosity == true )
         outs << "invalid code: " << window -> show_info();
   }
}
//------------------------------------------------------------------
void to_coords (const QString code, const bool valid,
                QTextStream &outs, const bool verbosity)
{
   Console *guess = new Console (code, valid);
   guess -> convert_from_glyph_sequence();

   if ( guess -> get_coordinate() != QString() )
      outs << guess -> get_coordinate() << ", portal #" << guess ->
           get_portal();
   else
   {
      if ( verbosity == true )
         outs << "invalid code: " << guess -> show_info();
   }
}
//------------------------------------------------------------------
int main (int argc, char *argv[])
{
   /*
     Use console-only if more than one (1) argument is given, or
     if the style option is not supplied (which is for GUI anyway)
   */
   if ( argc > 1 && argv[1] != QString("-style") )
   {
      // Use console/non-gui
      QCoreApplication app (argc, argv);
      QCoreApplication::setApplicationName ("nmspd");
      QCoreApplication::setApplicationVersion ("0.5");
      QCommandLineParser parser;
      parser.setApplicationDescription ("Converts coordinates to a portal glyph address, and vice versa. The GUI can be used instead when no options or arguments are specified.");
      parser.addHelpOption();
      parser.addVersionOption();
      parser.addPositionalArgument ("code",
                                    QCoreApplication::translate ("main",
                                          "Coordinate or glyph code sequence to convert."));

      // Boolean option with multiple names (-V, --verbose)
      QCommandLineOption verboseOption (QStringList() << "V" << "verbose",
                                        QCoreApplication::translate ("main",
                                              "Be more verbose with errors."));
      parser.addOption (verboseOption);

      // Boolean option with multiple names (-c, --coordinate)
      QCommandLineOption coordinateOption (QStringList() << "c" <<
                                           "coordinate",
                                           QCoreApplication::translate ("main",
                                                 "Convert from a star system coordinate. Must be in the form HHHH:HHHH:HHHH:HHHH (16 hex digits)"));
      parser.addOption (coordinateOption);

      // Boolean option with multiple names (-g, --glyphcode)
      QCommandLineOption glyphOption (QStringList() << "g" << "glyphcode",
                                      QCoreApplication::translate ("main",
                                            "Convert from a glyph code sequence. Must be in the form HHHHHHHHHHHH (12 hex digits)."));
      parser.addOption (glyphOption);

      // Process the actual command line arguments given by the user
      parser.process (app);

      // All arguments are lumped together...
      const QStringList args = parser.positionalArguments();

      bool coord = parser.isSet (coordinateOption);
      bool glyph = parser.isSet (glyphOption);
      bool verb = parser.isSet (verboseOption);
      QTextStream outs (stdout);

      if ( coord == true && glyph == false )
      {
         // convert coordinates -> glyph
         for (int i = 0; i < args.size(); i++)
         {
            to_glyphs (args.at(i), bool(true), outs, verb);
            outs << "\n";
         }
      }
      else if ( glyph == true && coord == false )
      {
         // convert glyph -> coordinates
         for (int i = 0; i < args.size(); i++)
         {
            to_coords (args.at(i), bool(false), outs, verb);
            outs << "\n";
         }
      }
      else
      {
         if ( args.size() == 0 )
         {
            outs << "Did you want to run the gui? ";
            outs << "Try again without any options.";
         }
         else
         {
            // Options are mixed so best guess the inputs
            for (int i = 0; i < args.size(); i++)
            {
               if ( args.at(i).size() == 12 )
               {
                  // Assume is glyph code
                  to_coords (args.at(i), bool(false), outs, verb);
                  outs << "\n";
               }
               else if ( args.at(i).size() == 19 )
               {
                  // Assume is coordinate
                  to_glyphs (args.at(i), bool(true), outs, verb);
                  outs << "\n";
               }
               else { }
            }
         }
      }

      // Exit properly rather than keep waiting for input.
      app.quit();
   }
   else
   {
      QApplication app (argc, argv);

      // Set GUI style
      QString gui_look = "Fusion", used;

      if ( argc >= 1 && argv[2] != QString() )
      {
         const QString temp_string = argv[2];

         if ( temp_string.size() < 15 )
            gui_look = QString(argv[2]);	// Get GUI-style to use
      }

      QApplication::setStyle(QStyleFactory::create(gui_look));
      used = QApplication::style() -> objectName();

      if ( gui_look.toLower() != used.toLower() )
      {
         qDebug() << gui_look << "cannot be used. Defaulting to" <<
                  used;
         qDebug() << "Available options for \'-style\':" <<
                  QStyleFactory::keys().join(", ");
      }

      Window window;
      window.show();
      return app.exec ();
   }

   return (0);
}

Added src/nmsDecoderMainWindow.cpp.



















































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
//==================================================================
#include <QtWidgets>
#include <QRegularExpressionMatch>

#include "PortalAddressWindow.h"
#include "nmsDecoderMainWindow.h"
//==================================================================
///////////////////
// CLASS: Window //
///////////////////
//==================================================================
Window::Window()
{
   blackbox = new Console;
   glyph_window = new Glyphs;
   coordinates_input = new QLineEdit;
   portal_number = new QSpinBox;
   glyph_sequence = new QLineEdit;
   invalid_messages = new QMessageBox;
   run_gui();
}
//------------------------------------------------------------------
Window::Window (QString _code, bool isCoordinate)
{
   blackbox = new Console(_code, isCoordinate);
   glyph_window = new Glyphs;
   coordinates_input = new QLineEdit;
   glyph_sequence = new QLineEdit;
   portal_number = new QSpinBox;
   invalid_messages = new QMessageBox;
   run_gui();

   if ( isCoordinate == false )
      glyph_sequence -> setText (_code);
   else
      coordinates_input -> setText (_code);
}
//------------------------------------------------------------------
void Window::run_gui()
{
   // Set minimum size of window
   setMinimumSize(415, 50);
   
   // QGroupBox to store the display of widgets
   star_group = new QGroupBox (tr ("Coordinates"));
   convert_group = new QGroupBox (tr ("Glyph Code"));
   other_buttons_group = new QGroupBox;
   QGroupBox *preset_group = new QGroupBox (tr ("Presets"));

   // QLabel to store information descriptors
   QLabel *coordinatesLabel = new QLabel;
   coordinatesLabel -> setText (tr ("System address:"));
   QLabel *portalnumberLabel = new QLabel;
   portalnumberLabel -> setText (tr ("Portal Number:"));

   // QSpinBox to store portal number
   portal_number = new QSpinBox;
   portal_number -> setRange (1, 16);
   portal_number -> setSingleStep (1);
   portal_number -> setValue (1);
   portal_number -> setAlignment (Qt::AlignRight);

   // QLineEdit to store glyph code sequence
   glyph_sequence = new QLineEdit;
   glyph_sequence -> setMaxLength (12);
   glyph_sequence -> setClearButtonEnabled (true);

   /*
      QLineEdit to store coordinate data
       Using inputMask rather than validator to allow for easier  
       user edits of this input field. With validator, the user will 
       have to either delete the whole line and retype, or 
       backspace/delete from the end of the line until where they 
       want to modify the coordinate value.
   */
   coordinates_input = new QLineEdit;
   coordinates_input -> setInputMask ("HHHH:HHHH:HHHH:HHHH");
   coordinates_input -> setPlaceholderText ("0FFF:00FF:0FFF:02FF");
   coordinates_input -> setCursorMoveStyle (Qt::VisualMoveStyle);
   coordinates_input -> setClearButtonEnabled (true);

   // QPushButton to activate converting TO a glyph code
   convert_to_glyph_button = new QPushButton;
   convert_to_glyph_button -> setText (tr ("Convert to glyphs"));
   convert_to_glyph_button -> setToolTip (
      tr ("Convert from coordinates to glyph sequence"));
   convert_to_glyph_button -> setCheckable (false);

   // QPushButton to activate converting FROM a glyph code
   convert_from_glyph_button = new QPushButton;
   convert_from_glyph_button -> setText (tr ("Convert to coordinates"));
   convert_from_glyph_button -> setToolTip (
      tr ("Convert from glyph sequence to corodinate"));
   convert_from_glyph_button -> setCheckable (false);

   // QPushButton to activate clearing ALL data fields
   clear_button = new QPushButton;
   clear_button -> setText (tr ("Clear"));
   clear_button -> setToolTip (tr ("Reset coordinates and glyphs"));
   clear_button -> setCheckable (false);

   // QPushButton to activate shutdown of application
   exit_button = new QPushButton;
   exit_button = new QPushButton;
   exit_button -> setText (tr ("Quit"));
   exit_button -> setToolTip (tr ("Exit the application"));
   exit_button -> setCheckable (false);

   // QPushButton to provide some information about the application
   about_button = new QPushButton;
   about_button -> setText (tr ("About"));
   about_button -> setToolTip (tr ("About this application"));
   about_button -> setCheckable (false);

   show_portal_button = new QPushButton;
   show_portal_button -> setText (tr ("Portal"));
   show_portal_button -> setToolTip (tr ("Show portal address window"));
   show_portal_button -> setCheckable (true);

   // QPushButton for presets
   QPushButton *hub_button = new QPushButton;
   hub_button -> setText ("&HUB");
   hub_button -> setToolTip (tr ("The Galactic Hub"));
   hub_button -> setCheckable (false);
   QPushButton *amino_button = new QPushButton;
   amino_button -> setText ("&Amino");
   amino_button -> setToolTip (tr ("The Amino Hub"));
   amino_button -> setCheckable (false);
   QPushButton *dtt_button = new QPushButton;
   dtt_button -> setText ("&DTT");
   dtt_button -> setToolTip (tr ("Deep Thought Collective"));
   dtt_button -> setCheckable (false);
   QPushButton *hova_button = new QPushButton;
   hova_button -> setText ("H&OVA");
   hova_button -> setToolTip (tr ("Galactic Empire of HOVA"));
   hova_button -> setCheckable (false);

   initialize_coordinates();
   initialize_glyphs();

   /*
      Create layout for user input fields

      star_group:
       +-------------------+
       | coordinates_input |
       +-------------------+
       | portalnumberLabel |
       +-------------------+
       | portal_number     |
       +-------------------+
   */
   QVBoxLayout *the_layout = new QVBoxLayout;
   the_layout -> addWidget (coordinates_input);
   the_layout -> addWidget (portalnumberLabel);
   the_layout -> addWidget (portal_number);
   the_layout -> addWidget (convert_to_glyph_button);
   star_group -> setLayout (the_layout);

   /*
      Create layout for user input fields

      other_buttons_group:
       +----------------------------+
       | clear_button | exit_button |
       +----------------------------+
   */
   QGridLayout *other_buttons_layout = new QGridLayout;
   other_buttons_layout -> addWidget (clear_button, 0, 0, 1, 1);
   other_buttons_layout -> addWidget (exit_button, 1, 1, 1, 1);
   other_buttons_layout -> addWidget (about_button, 1, 0, 1, 1);
   other_buttons_layout -> addWidget (show_portal_button, 0, 1, 1, 1);
   other_buttons_group -> setLayout (other_buttons_layout);

   /*
      Create grid layout.

      preset_group:
       +------------+--------------+
       | hub_button | amino_button |
       +------------+--------------+
       | dtt_button | hova_button  |
       +------------+--------------+
   */
   QGridLayout *preset_buttons_layout = new QGridLayout;
   preset_buttons_layout -> addWidget (hub_button, 0, 0, 1, 1);
   preset_buttons_layout -> addWidget (amino_button, 0, 1, 1, 1);
   preset_buttons_layout -> addWidget (dtt_button, 1, 0, 1, 1);
   preset_buttons_layout -> addWidget (hova_button, 1, 1, 1, 1);
   preset_group -> setLayout (preset_buttons_layout);
   
   /*
      Create layout for user input fields

      convert_group:
       +---------------------------+
       |      glyph_sequence       |
       +---------------------------+
       | convert_from_glyph_button |
       +---------------------------+
   */
   QVBoxLayout *glyphcode_layout = new QVBoxLayout;
   glyphcode_layout -> addWidget (glyph_sequence);
   glyphcode_layout -> addWidget (convert_from_glyph_button);
   convert_group -> setLayout (glyphcode_layout);

   /*
      Create grid layout for all the data

      _layout:
       +-----------------------------------------+
       |    star_group   |      preset_group     |
       +-----------------------------------------+
       |  convert_group  |  other_buttons_group  |
       +-----------------------------------------+

                or essentially:

       +------------------------------------------------------------+
       | coordinates_input  |     hub_button     |   amino_button   |
       | portalnumberLabel  +--------------------+------------------+
       |    portal_number   |     dtt_button     |   hova_button    |
       |  convert_to_glyph  |                    |                  |
       +------------------------------------------------------------+
       |    glyph_sequence  |    clear_button    | show_portal_btn  |
       | convert_from_glyph |    about_button    |    exit_button   |
       +------------------------------------------------------------+
   */
   QGridLayout *_layout = new QGridLayout;
   _layout -> addWidget (star_group, 0, 0, 2, 1);
   _layout -> addWidget (other_buttons_group, 2, 1, 1, 1);
   _layout -> addWidget (preset_group, 0, 1, 1, 1);
   _layout -> addWidget (convert_group, 2, 0, 2, 1);
   setLayout (_layout);

   // Handle custom slots and signals (events)

   // Conversion
   QObject::connect (convert_to_glyph_button, SIGNAL (clicked(bool)),
                     this, SLOT (GUI_convert_to_glyph_sequence()));
   QObject::connect (coordinates_input, SIGNAL (returnPressed()),
   					 this, SLOT (GUI_convert_to_glyph_sequence()));
   QObject::connect (convert_from_glyph_button, SIGNAL (clicked(bool)),
                     this, SLOT (GUI_convert_from_glyph_sequence()));
   QObject::connect (glyph_sequence, SIGNAL (returnPressed()),
   					 this, SLOT (GUI_convert_from_glyph_sequence()));
   QObject::connect (this, SIGNAL (have_errors()),
                     this, SLOT (show_messages()));

   // Presets
   QObject::connect (hub_button, SIGNAL (clicked(bool)),
   					 this, SLOT (preset_hub()));
   QObject::connect (amino_button, SIGNAL (clicked(bool)),
   					 this, SLOT (preset_amino()));
   QObject::connect (dtt_button, SIGNAL (clicked(bool)),
   					 this, SLOT (preset_dtt()));
   QObject::connect (hova_button, SIGNAL (clicked(bool)),
   					 this, SLOT (preset_hova()));

   // Control buttons
   QObject::connect (show_portal_button, SIGNAL (toggled(bool)),
   					 this, SLOT (show_glyphs(bool)));
   QObject::connect (clear_button, SIGNAL (clicked(bool)),
                     this, SLOT (clear_values()));
   QObject::connect (about_button, SIGNAL (clicked(bool)),
   					this, SLOT (about()));
   QObject::connect (exit_button, SIGNAL (clicked(bool)),
                     QApplication::instance(), SLOT (quit()));
}
//------------------------------------------------------------------
void Window::about()
{
	// Set up and display QMessageBox::about
	QMessageBox::about (this, tr ("About nmspd"),
					tr ("<center><h2>nmspd</h2>v0.5.beta1<br><br><br>" 
					"Created by: "
					"tion<br>Contact: " 
					"tion7680@protonmail.com</center>"
					"<hr />"
					"<p>"
					"The glyph symbols used in this program are slightly modified "
					"from images on "
					"<a href=\"https://nomanssky.gamepedia.com/Glyph\">"
					"https://nomanssky.gamepedia.com</a>. These images are "
					"property of Hello Games. The use of "
					"these images is for educational purposes only.</p><hr /><p>"
					"This program is free software: you can redistribute it "
					"and/or modify it under the terms of the GNU General "
					"Public License as published by the Free Software "
					"Foundation, either version 3 of the License, or (at your option) "
					"any later version.</p><p>"
					"This program is distributed in the hope that it will be useful, but "
					"WITHOUT ANY WARRANTY; without even implied warranty of MERCHANTABILITY "
					"or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License "
					"for more details.</p><p>"
					"You should have received a copy of the GNU General Public License along "
					"with this program. If not, see &lt;"
					"<a href=\"http://www.gnu.org/licenses/\" target=\"_blank\">"
					"http//www.gnu.org/licenses/</a>&gt;.</p>"));
}
//------------------------------------------------------------------
void Window::show_messages()
{
   // Set up QMessageBox::warning
   QString text = QString();
   text += QString(tr ("Problematic section: "));
   text += blackbox -> show_info();
   text += "\n\n";
   text += QString(tr ("Please adjust."));
   invalid_messages -> setText ( QString("<center> " +
                                         tr("INVALID CODE") + " </center") );
   invalid_messages -> setDetailedText (text);
   invalid_messages -> setTextFormat (Qt::RichText);
   invalid_messages -> setInformativeText ( QString("- " +
         tr("Coordinates must be 16-digit hex") + "<br>- " +
         tr("Glyph codes must be 12-digit hex") + "<br><br>" +
         tr("Please check your inputs and try again.") ));
   invalid_messages -> setIcon (QMessageBox::Warning);
   invalid_messages -> setStandardButtons (QMessageBox::Ok);
   invalid_messages -> setDefaultButton (QMessageBox::Ok);

   // Show QMessageBox
   invalid_messages -> exec();
}
//------------------------------------------------------------------
void Window::set_coordinate_preset (const QString &_code, const int &_portal)
{
   coordinates_input -> setText (_code);
   portal_number -> setValue (_portal);
}
//------------------------------------------------------------------
void Window::set_glyph_code_preset (const QString &_code)
{
   glyph_sequence -> setText (_code);
}
//------------------------------------------------------------------
void Window::preset_hub()
{
   const QString the_hub = "042F:0078:0D55:0021";
   set_coordinate_preset(the_hub, 1);
   GUI_convert_to_glyph_sequence();
}
//------------------------------------------------------------------
void Window::preset_amino()
{
   const QString the_amino = "064A:0082:01B9:0022";
   set_coordinate_preset (the_amino, 2);
   GUI_convert_to_glyph_sequence();
}
//------------------------------------------------------------------
void Window::preset_dtt()
{
   set_coordinate_preset ("0803:00A2:075D:00A8", 1);
   GUI_convert_to_glyph_sequence();
}
//------------------------------------------------------------------
void Window::preset_hova()
{
   set_coordinate_preset ("0467:0081:0D71:00AD", 1);
   GUI_convert_to_glyph_sequence();
}
//------------------------------------------------------------------
void Window::initialize_coordinates()
{
   coordinates_input -> clear();
   portal_number -> setValue (1);
}
//------------------------------------------------------------------
void Window::clear_values()
{
   blackbox -> clear_values();
   glyph_window -> clear_values();
   initialize_coordinates();
   clear_glyphs();
}
//------------------------------------------------------------------
void Window::show_glyphs (bool is_checked)
{
   if ( is_checked == true ) {
      show_portal_button -> setToolTip ("Hide portal address window");
      glyph_window -> show();
   }
   else {
      show_portal_button -> setToolTip ("Show portal address window");
      glyph_window -> hide();
   }
}
//------------------------------------------------------------------
void Window::GUI_convert_from_glyph_sequence()
{
   if ( glyph_sequence -> text().isEmpty() == false )
   {
      // Move user input into blackbox for conversion
      blackbox -> set_glyph_code (glyph_sequence -> text());
      // Perform conversion: glyph code -> coordinates
      blackbox -> convert_from_glyph_sequence();

      if ( blackbox -> get_glyph_sequence().size() == 12 )
      {
         // Move successful/valid conversion results to GUI
         coordinates_input -> setText (blackbox -> get_coordinate());
         glyph_sequence -> setText (blackbox -> get_glyph_sequence());
         portal_number -> setValue (blackbox -> get_portal());
         glyph_window -> set_glyphs(blackbox -> get_glyph_sequence());
         
         // Show glyph sequence pop-up
         show_portal_button -> setChecked (true);
         show_glyphs(true);
      }
      else
         emit have_errors();
   }
}
//------------------------------------------------------------------
void Window::GUI_convert_to_glyph_sequence()
{
   if ( coordinates_input -> text().isEmpty() == false )
   {
      // Move user inputs to blackbox for conversion
      blackbox -> set_portal (portal_number -> value());
      blackbox -> set_coordinate (coordinates_input -> text());
      // Perform conversion: coordinates -> glyph code
      blackbox -> convert_to_glyph_sequence();

      if ( blackbox -> get_glyph_sequence().size() == 12 )
      {
         // Move successful/valid conversion results to GUI
         glyph_sequence -> setText (blackbox -> get_glyph_sequence());
         coordinates_input -> setText (blackbox -> get_coordinate());
         portal_number -> setValue (blackbox -> get_portal());
         glyph_window -> set_glyphs(blackbox -> get_glyph_sequence());
         
         // Show glyph sequence pop-up
         show_portal_button -> setChecked (true);
         show_glyphs(true);
      }
      else
         emit have_errors();
   }
}
//------------------------------------------------------------------

Added src/nmsDecoderMainWindow.h.















































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
//==================================================================
#ifndef __NMS_CONVERT_GUI_H__
#define __NMS_CONVERT_GUI_H__
//==================================================================
#include <QtWidgets>

#include "nmsDecoder.h"
#include "PortalAddressWindow.h"
//==================================================================
class Window : public QWidget
{
      // Macro to allow for custom slots and signals
      Q_OBJECT

   public:
      //////////////////
      // CONSTRUCTORS //
      //////////////////
      Window();
      Window(QString _code, bool isCoordinate = true);

      ////////////////////////////////
      // ACCESSING MEMBER FUNCTIONS //
      ////////////////////////////////
      // Initialize GUI objects/elements
      void run_gui();

      // For location preset. Has no error-checking
      void set_coordinate_preset(const QString &_code, const int &_portal = 1);
      void set_glyph_code_preset(const QString &);

   signals:
      void have_errors();

   public slots:
      void GUI_convert_to_glyph_sequence();
      void GUI_convert_from_glyph_sequence();
      void about();

      // Show portal address window
      void show_glyphs(bool);
      void hide_glyphs() { glyph_window -> hide(); }

      // Show errors in provided code to convert
      void show_messages();

      // Show coordinates/portal address for location preset
      void preset_hub();
      void preset_amino();
      void preset_dtt();
      void preset_hova();

      /*
        Reset variable values. clear_values() resets values of
        private variables. clear_glyphs() is meant specifically
        for resetting the glyph images.
      */
      void clear_values(); 
      void clear_glyphs() { glyph_sequence -> clear(); }
      void clear_messages() { blackbox -> clear_info(); }

   private:
      void initialize_glyphs() { glyph_sequence -> clear(); }
      void initialize_coordinates();

      Console *blackbox;

      // GUI-specific objects
      QLineEdit *coordinates_input;
      QLineEdit *glyph_sequence;
      QSpinBox *portal_number;
      QGroupBox *star_group;
      QGroupBox *convert_group;
      QGroupBox *other_buttons_group;
      QPushButton *exit_button;
      QPushButton *about_button;
      QPushButton *convert_to_glyph_button;
      QPushButton *convert_from_glyph_button;
      QPushButton *clear_button;
      QPushButton *show_portal_button;
      QMessageBox *invalid_messages;
      Glyphs *glyph_window;
      
};
//------------------------------------------------------------------
#endif  // __NMS_CONVERT_H__
//==================================================================

Name change from src/toglyph.qrc to src/nmsDecoderResources.qrc.

1
2
3
4
5
6
7
8

9
10
11
12
13
14
15
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
    <file alias="empty.jpg">../images/empty.png</file>

    <!-- 
        These are copyrighted images from the game No Man's Sky and are 
        registered trademarks of Hello Games. They are used without 
        permission and not for profit.

    -->
    <file alias="0.jpg">../images/0.jpg</file>
    <file alias="1.jpg">../images/1.jpg</file>
    <file alias="2.jpg">../images/2.jpg</file>
    <file alias="3.jpg">../images/3.jpg</file>
    <file alias="4.jpg">../images/4.jpg</file>
    <file alias="5.jpg">../images/5.jpg</file>







|
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
    <file alias="empty.jpg">../images/empty.png</file>

    <!-- 
        These are copyrighted images from the game No Man's Sky and are 
        registered trademarks of Hello Games. They are used without 
        permission and not for profit. They are used for educational 
        purposes
    -->
    <file alias="0.jpg">../images/0.jpg</file>
    <file alias="1.jpg">../images/1.jpg</file>
    <file alias="2.jpg">../images/2.jpg</file>
    <file alias="3.jpg">../images/3.jpg</file>
    <file alias="4.jpg">../images/4.jpg</file>
    <file alias="5.jpg">../images/5.jpg</file>

Added src/nmsDecoderUtility.cpp.



































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
//==================================================================
#include <QRegularExpressionMatch>
#include <sstream>          // std::stringstream
#include <iomanip>          // std::hex, std::oct, std::dec

#include "nmsDecoderUtility.h"
//==================================================================
//////////////////////
// HELPER FUNCTIONS //
//////////////////////
//==================================================================
//------------------------------------------------------------------
int convert_hex_to_integer (const QString coordinate)
{
   std::stringstream flex_string;
   flex_string << std::dec << coordinate.toUtf8().constData();
   std::string something (flex_string.str());
   QString result = QString::fromStdString(something);
   bool ok;
   return (result.toInt(&ok, 16));
}
//------------------------------------------------------------------
QString convert_integer_to_hex (const int number)
{
   std::stringstream flex_string;
   flex_string << std::setfill ('0') << std::setw(2) << std::hex <<
               number;
   std::string _astring (flex_string.str());
   QString result = QString::fromStdString(_astring).toUpper();
   return (result);
}
//------------------------------------------------------------------
bool is_valid_coordinate (const QString _code, QStringList &errors)
{
   bool result = true;
   QString __code = _code.toUpper();
   QRegularExpression
   lookingForA ("[0-9A-F]{4}:[0-9A-F]{4}:[0-9A-F]{4}:[0-9A-F]{4}");
   QRegularExpressionMatch validCoordinate = lookingForA.match (__code);

   /*
      Valid coordinates:
      0001:0001:0001:0001 ... 0FFF:00FF:0FFF:02FF
       => 1:1:1:1 ... 4095:255:4095:767
   */
   if ( validCoordinate.hasMatch() == true || __code.size() == 19 )
   {
      QString coord = QString();
      int int_of_coord = 0;
      const QRegularExpression validHex ("[0-9A-F]{4}");
      QRegularExpressionMatch testHex;

      for (int i = 0; i < 4; i++)
      {
         coord = QString(__code.section(':', i, i));
         testHex = validHex.match (coord);

         if ( testHex.hasMatch() == true )
         {
            int_of_coord = convert_hex_to_integer (coord);

            if ( i == 1 )
            {
               // Coordinate-Y
               if ( int_of_coord < 1 || int_of_coord > 255 )
               {
                  result = false;
                  errors.append (pad_with_zeros (coord, 4));
               }
            }
            else if ( i == 3 )
            {
               // Coordinate-Star
               if ( int_of_coord < 1 || int_of_coord > 767 )
               {
                  result = false;
                  errors.append (pad_with_zeros (coord, 4));
               }
            }
            else
            {
               // Coordinate-X and Coordinate-Z
               if ( int_of_coord < 1 || int_of_coord > 4095 )
               {
                  result = false;
                  errors.append (pad_with_zeros(coord, 4));
               }
            }
         }
         else
         {
            result = false;
            errors.append (pad_with_zeros(coord, 4));
         }
      }
   }
   else
      result = false;

   return (result);
}
//------------------------------------------------------------------
bool is_valid_glyph_code (const QString _code, QStringList &error)
{
   bool result = true;
   QString __glyph = _code.toUpper();
   const QRegularExpression lookingFor ("[0-9A-F]{12}");
   const QRegularExpression lookingForA ("[0-9A-F]");
   QRegularExpressionMatch validGlyph = lookingFor.match (__glyph);

   /*
      Valid glyph codes:
      000180800800 ... F2FF82802802
       => any value of the form HHHH81801801 is invalid
   */
   if ( validGlyph.hasMatch() == true || __glyph.size() == 12 )
   {
      const int temp_star = convert_hex_to_integer(QString(__glyph.at(
                               1)) + QString(__glyph.at(2)) + QString(__glyph.at(3)));
      const int temp_y = convert_hex_to_integer(QString(__glyph.at(
                            4)) + QString(__glyph.at(5)));
      const int temp_z = convert_hex_to_integer(QString(__glyph.at(
                            6)) + QString(__glyph.at(7)) + QString(__glyph.at(8)));
      const int temp_x = convert_hex_to_integer(QString(__glyph.at(
                            9)) + QString(__glyph.at(10)) + QString(__glyph.at(11)));
      QRegularExpressionMatch validPortal = lookingForA.match (__glyph.at(
            0));
      const QRegularExpression segment ("[0-9A-F]{3}");
      const QRegularExpression segment_y ("[0-9A-F]{2}");
      QRegularExpressionMatch validHex;

      // Portal number: 1-digit
      // Min: 1 [0x1]
      // Max: 16 [0xF]
      if ( validPortal.hasMatch() == false )
      {
         result = false;
         error.append( QString(__glyph.at(0)) );
      }

      // Star Class: 3-digits
      // Min: 1 [0x001]
      // Max: 767 [0x2FF]
      validHex = segment.match ( QString(__glyph.at(1)) + QString(
                                    __glyph.at(2)) + QString(__glyph.at(3)) );

      if ( validHex.hasMatch() == true )
      {
         if ( temp_star < 1 || temp_star > 767 )
         {
            result = false;
            error.append(pad_with_zeros(convert_integer_to_hex(temp_star), 3));
         }
      }
      else
      {
         result = false;
         error.append(QString(__glyph.at(1)) + QString(__glyph.at(
                         2)) + QString(__glyph.at(3)));
      }

      // Coordinate-Y: 2-digits
      // Min: 1 [0x1]
      // Max: mod 130 [0x82]
      validHex = segment_y.match ( QString(__glyph.at(4)) + QString(
                                      __glyph.at(5)) );

      if ( validHex.hasMatch() == true )
      {
         if ( (temp_y % 130) == 129 || temp_y < 1 )
         {
            result = false;
            error.append(pad_with_zeros(convert_integer_to_hex(temp_y), 2));
         }
      }
      else
      {
         result = false;
         error.append(QString(__glyph.at(4)) + QString(__glyph.at(5)));
      }

      // Coordinate-Z: 3-digits
      // Min: 1 [0x1]
      // Max: 2048 [0xFFF]
      validHex = segment.match (QString(__glyph.at(6)) + QString(__glyph.at(
                                   7)) + QString(__glyph.at(8)) );

      if ( validHex.hasMatch() == true )
      {
         if ( (temp_z % 2050) == 2049 || temp_z < 1 )
         {
            result = false;
            error.append(pad_with_zeros(convert_integer_to_hex(temp_z), 3));
         }
      }
      else
      {
         result = false;
         error.append(QString(__glyph.at(6)) + QString(__glyph.at(
                         7)) + QString(__glyph.at(8)));
      }

      // Coordinate-X: 3-digits
      // Min: 1 [0x1]
      // Max: 2048 [0xFFF]
      validHex = segment.match ( QString(__glyph.at(9)) + QString(
                                    __glyph.at(10)) + QString(__glyph.at(11)) );

      if ( validHex.hasMatch() == true )
      {
         if ( (temp_x % 2050) == 2049 || temp_x < 1 )
         {
            result = false;
            error.append(pad_with_zeros(convert_integer_to_hex(temp_x), 3));
         }
      }
      else
      {
         result = false;
         error.append(QString(__glyph.at(9)) + QString(__glyph.at(
                         10)) + QString(__glyph.at(11)));
      }
   }
   else
   {
      // The whole thing is invalid
      result = false;
      error.append(__glyph);
   }

   return (result);
}
//------------------------------------------------------------------
bool is_valid_portal (int _code)
{
   bool result;

   if ( _code >= 1 && _code <= 16 )
      result = true;
   else
      result = false;

   return (result);
}
//------------------------------------------------------------------
QString pad_with_zeros (const QString code, const int padding)
{
   QString result = code;

   if ( padding <= 4 && padding > 0 )
   {
      for (int i = code.size(); i < padding; i++)
         result.insert(0, '0');
   }

   return (result);
}

Added src/nmsDecoderUtility.h.







































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#ifndef __NMS_DECODER_UTILITY_H__
#define __NMS_DECODER_UTILITY_H__
//==================================================================
#include <QtCore>
//==================================================================
//////////////////////
// HELPER FUNCTIONS //
//////////////////////
//------------------------------------------------------------------
int convert_hex_to_integer (const QString);
QString convert_integer_to_hex (const int);

/*
   QString pad_with_zeros (const QString, const int)

   Returns the QString parameter pre-pended with zeros to 
   fill its size to the int parameter, which must be a value 
   between 1 and 4.
*/
QString pad_with_zeros (const QString, const int);

/*
  bool is_valid_coordinate(const QString)

  Coordinate is 16 hex characters long, with 3 semicolons to
  separate the different axis (x,y,z,star class). QStringList 
  parameter will hold invalid segments found within the 
  provided _code.
*/
bool is_valid_coordinate(const QString _code, QStringList &);

/*
  bool is_valid_glyph_code(const QString)

  Glyph code is 12 hex characters long. Must also be between
  a lower and upper limit: 000182802802 .. F2FF80800800. 
  QStringList parameter will hold invalid segements found 
  within the provided _code.
*/
bool is_valid_glyph_code(const QString _code, QStringList &);

/*
  bool is_valid_portal (int)

  Returns true if parameter is a decimal number between 
  1 and 16.
*/
bool is_valid_portal(int _code);
//------------------------------------------------------------------
#endif  // __NMS_DECODER_UTILITY_H__
//------------------------------------------------------------------