-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
158 lines (132 loc) · 4.03 KB
/
main.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
#include "mainwindow.h"
#include <QApplication>
#include <iostream>
#include "spanshapi.h"
#include "spansh_route.h"
#include "spansh_sysname.h"
#include "singleapp/singleapplication.h"
#include "edsmapiv1.h"
#include "edsmv1_nearest.h"
#include "edsmv1_sysinfo.h"
#include <QDebug>
#include "stringsfilecache.h"
#include "edsmwrapper.h"
#include "dump_help.h"
#include "salesman/LittleAlgorithm.h"
#include "execonmainthread.h"
#ifdef OCR_ADDED
#include "eliteocr.h"
#endif
void test_ocr()
{
#ifdef SRC_PATH
const static QString tests[] =
{
// PHROI PRI NX-A D1-785
"EliteDangerousCLIENT_1581844531372_47099.png",
//HYPOE FLYI QB-N C23-3651 1 (planet)
"EliteDangerousCLIENT_1581953981012_111958.png",
//HYPOE FLYI QB-N C23-3651 2 A (planet)
"EliteDangerousCLIENT_1581953984790_111968.png",
//HYPOE FLYI QB-N C23-3651 4 E (planet)
"EliteDangerousCLIENT_1581953988331_111976.png",
//those 2 below has many stars on BG
//HYPOE FLYI LA-P C22-1092
"EliteDangerousCLIENT_1581954014555_111994.png",
//HYPOE FLYI FN-H D11-1555
"EliteDangerousCLIENT_1581954025449_112006.png",
};
#ifdef OCR_ADDED
EliteOCR ocr;
const static auto p = QStringLiteral("%1/test_ocr_screens/").arg(SRC_PATH);
for (const auto& s : tests)
{
QImage img;
if (img.load(p + s))
std::cout << "OCR: " << EliteOCR::tryDetectStarFromMapPopup(ocr.recognize(img)).toStdString() << std::endl;
}
exit(0);
#endif
#endif
}
void dotest()
{
#ifdef SRC_PATH
// SpanshApi test {3};
// SpanshRoute r{70, 70, "Sol", "Colonia"};
// SpanshSysName sys{"eu"};
EdsmApiV1 test{3};
EDSMV1NearerstSystem r("Borann", 20, false);
EDSMV1SysInfo sys("Maia");
const auto static testr = [](auto err, auto js)
{
if (!err.empty())
std::cerr << err << std::endl;
else
{
std::cout << js.dump(4) << std::endl;
StringsFileCache::get().addData("test", QString::fromStdString(js.dump()));
}
};
test.executeRequest(r, testr);
test.executeRequest(sys, testr);
test.threads.stop(true);
exit(0);
#endif
}
void test_wrapper()
{
#ifdef SRC_PATH
auto list = EDSMWrapper::requestManySysInfoInRadius("Borann", 30, [](auto a, auto b)
{
if (a % 10 == 0)
std::cout << a << " out of " << b << std::endl;
return false;
});
dump_helper::dumpContainer(list);
std::cout << EDSMWrapper::tooltipWithSysInfo("Brigh").toStdString() << std::endl;
exit(0);
#endif
}
void test_body_info()
{
#ifdef SRC_PATH
// auto list = EDSMWrapper::requestManyBodiesInfoInRadius("Borann", 10, [](auto a, auto b)
// {
// if (a % 10 == 0)
// std::cout << a << " out of " << b << std::endl;
// return false;
// });
// dump_helper::dumpContainer(list);
// exit(0);
auto i = EDSMWrapper::requestBodiesInfo("Borann");
std::cout << dump_helper::toStdStr(i) << std::endl;
exit(0);
#endif
}
int main(int argc, char *argv[])
{
SingleApplication a(argc, argv, false, SingleApplication::Mode::SecondaryNotification | SingleApplication::Mode::User);
a.setApplicationName("ED:HighWay");
a.setApplicationVersion("0.14");
a.setApplicationDisplayName("ED:HighWay");
a.setOrganizationDomain("pasteover.net");
a.setOrganizationName("pasteover.net");
StringsFileCache::get(); //init cache
ExecOnMainThread::get();//creating object from inside gui thread for the 1st time
//test_body_info();
//test_wrapper();
//LittleAlgorithm::selfTest3();
//exit(0);
MainWindow w;
QObject::connect(&a, &SingleApplication::instanceStarted, [&w, &a]()
{
//actual popup of window will be dependent on desktop settings, for example in kde it is something like "bring to front demanding attention"
if (a.activeWindow())
a.activeWindow()->raise();
else
w.raise();
});
w.show();
return a.exec();
}