-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.cpp
89 lines (81 loc) · 3.08 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
#include "Dialog/DoorConfigDialog.h"
#include "Dialog/RoomConfigDialog.h"
#include "Dialog/PatchEditDialog.h"
#include "Dialog/CreditsEditDialog.h"
#include "DockWidget/CameraControlDockWidget.h"
#include "Dialog/GraphicManagerDialog.h"
#include "Dialog/SpritesEditorDialog.h"
#include "WL4EditorWindow.h"
#include "SettingsUtils.h"
#include <QApplication>
/// <summary>
/// Perform all static class initializations.
/// </summary>
static void StaticInitialization_BeforeROMLoading()
{
ROMUtils::StaticInitialization();
RoomConfigDialog::StaticComboBoxesInitialization();
DoorConfigDialog::StaticInitialization();
CameraControlDockWidget::StaticInitialization();
CreditsEditDialog::StaticInitialization();
PatchEditDialog::StaticComboBoxesInitialization();
GraphicManagerDialog::StaticInitialization();
SpritesEditorDialog::StaticInitialization();
}
/// <summary>
/// Perform static initializations, and then create the main window for the application.
/// </summary>
/// <param name="argc">
/// Number of command line arguments.
/// </param>
/// <param name="argv">
/// Array of command line arguments.
/// </param>
int main(int argc, char *argv[])
{
StaticInitialization_BeforeROMLoading();
// High DPI support in Qt6 will cause problems in position calculation without using devicePixelRatio
// use this to deal with the problems
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor);
QApplication application(argc, argv);
SettingsUtils::InitProgramSetupPath(application);
application.setWindowIcon(QIcon("./images/icon.ico"));
WL4EditorWindow window;
window.show();
// Quickly test or debug by automatically loading the ROM without UI used by GSB
// comment by ssp: a real man will never use this code (doge)
//-------------------------------------------------------------------
//#ifdef _WIN32 // Windows
// QString restoreFilePath = "C:\\Users\\Andrew\\Desktop\\WL4 PW 2.gba";
// QString filePath = "C:\\Users\\Andrew\\Desktop\\WL4 PW.gba";
//#else // Linux
// QString restoreFilePath = "/home/andrew/Desktop/WL4 2.gba";
// QString filePath = "/home/andrew/Desktop/WL4.gba";
//#endif
// QFile restoreFile(restoreFilePath);
// QFile testFile(filePath);
// testFile.remove();
// restoreFile.copy(filePath);
// if(testFile.exists())
// {
// window.LoadROMDataFromFile(filePath);
// }
// testFile.close();
//-------------------------------------------------------------------
// load the ROM file from argv if exists
if (argc > 1)
{
QString filePath(argv[1]);
ROMUtils::FormatPathSeperators(filePath);
if(QFile::exists(filePath) && filePath.endsWith(".gba", Qt::CaseInsensitive))
{
window.LoadROMDataFromFile(filePath);
}
else
{
QMessageBox::critical(&window, "WL4Editor", QObject::tr("Wrong command line parameter:\n"
"it needs to be a valid gba file path."));
}
}
return application.exec();
}