1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2014-2016 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include <nel/misc/types_nl.h>
18 #include "tool_main.h"
31 #ifdef Q_COMPILER_RVALUE_REFS
32 #undef Q_COMPILER_RVALUE_REFS
35 #include <QApplication>
36 #include <QtCore/QMap>
37 #include <QtCore/qdebug.h>
38 #include <QStyleFactory>
40 #ifdef QT_STATICPLUGIN
44 #if defined(Q_OS_WIN32)
45 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin
)
46 #elif defined(Q_OS_MAC)
47 Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin
)
48 #elif defined(Q_OS_UNIX)
49 Q_IMPORT_PLUGIN(QXcbIntegrationPlugin
)
55 #include <nel/misc/debug.h>
56 #include <nel/misc/common.h>
57 #include <nel/misc/file.h>
58 #include <nel/misc/path.h>
59 #include <nel/misc/command.h>
60 #include <nel/misc/sheet_id.h>
63 #include "../shared_widgets/common.h"
64 #include "tool_config.h"
65 #include "main_window.h"
68 using namespace NLMISC
;
74 CFileDisplayer
*s_FileDisplayer
= NULL
;
76 } /* anonymous namespace */
78 } /* namespace NLTOOLS */
84 qWarning() << "Usage: mainwindow [-SizeHint<color> <width>x<height>] ...";
88 QMap
<QString
, QSize
> parseCustomSizeHints(int argc
, char **argv
)
92 QMap
<QString
, QSize
> result
;
94 for (int i
= 1; i
< argc
; ++i
) {
95 QString arg
= QString::fromLocal8Bit(argv
[i
]);
97 if (arg
.startsWith(QLatin1String("-SizeHint"))) {
98 QString name
= arg
.mid(9);
103 QString sizeStr
= QString::fromLocal8Bit(argv
[i
]);
104 int idx
= sizeStr
.indexOf(QLatin1Char('x'));
108 int w
= sizeStr
.left(idx
).toInt(&ok
);
111 int h
= sizeStr
.mid(idx
+ 1).toInt(&ok
);
114 result
[name
] = QSize(w
, h
);
123 # define tstring wstring
125 # define tstring string
129 sint
main(int argc
, char **argv
)
133 // use log.log if NEL_LOG_IN_FILE and NLTOOLS_USE_LOG_LOG defined as 1
134 createDebug(NULL
, NLTOOLS_USE_LOG_LOG
, false);
137 // create toverhex_client.log
138 // filedisplayer only deletes the 001 etc
139 if (NLTOOLS_ERASE_LOG
&& CFile::isExists(NLTOOLS_LOG_FILE
))
140 CFile::deleteFile(NLTOOLS_LOG_FILE
);
141 // initialize the log file
142 NLTOOLS::s_FileDisplayer
= new CFileDisplayer();
143 NLTOOLS::s_FileDisplayer
->setParam(NLTOOLS_LOG_FILE
, NLTOOLS_ERASE_LOG
);
144 DebugLog
->addDisplayer(NLTOOLS::s_FileDisplayer
);
145 InfoLog
->addDisplayer(NLTOOLS::s_FileDisplayer
);
146 WarningLog
->addDisplayer(NLTOOLS::s_FileDisplayer
);
147 AssertLog
->addDisplayer(NLTOOLS::s_FileDisplayer
);
148 ErrorLog
->addDisplayer(NLTOOLS::s_FileDisplayer
);
151 nlinfo("Welcome to NeL!");
154 // low fragmentation heap (windows)
155 #if NLTOOLS_LOW_FRAGMENTATION_HEAP
156 ULONG heapFragValue
= 2; // enable low fragmentation heap
157 if (HeapSetInformation(GetProcessHeap(),
158 HeapCompatibilityInformation
,
159 &heapFragValue
, sizeof(heapFragValue
)))
161 nlinfo("HeapSetInformation OK!\n");
165 nlwarning("HeapSetInformation FAIL! (%d)\n", GetLastError());
171 hr
= hr
= CoInitializeEx(NULL
, COINIT_MULTITHREADED
);
172 bool coInitOk
= (hr
== S_OK
) || (hr
== S_FALSE
);
175 CSheetId::initWithoutSheet();
177 NLQT::preApplication();
178 QApplication
app(argc
, const_cast<char **>(argv
));
179 NLQT::postApplication();
181 QMap
<QString
, QSize
> customSizeHints
= parseCustomSizeHints(argc
, argv
);
183 NLTOOLS::CMainWindow
mainWin(customSizeHints
);
184 mainWin
.resize(800, 600);
185 mainWin
.show(); // calls isVisible(true)
187 int result
= app
.exec();
190 if (coInitOk
) CoUninitialize();