-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
84 lines (67 loc) · 2.65 KB
/
Copy pathmain.cpp
File metadata and controls
84 lines (67 loc) · 2.65 KB
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
#include "lexicon.h"
#include "pathing.h"
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickStyle>
#include <QQmlContext>
#include <QDir>
#include <QQuickWindow>
#include <QFontDatabase>
#include <spdlog/spdlog.h>
#include <spdlog/sinks/basic_file_sink.h>
#include <spdlog/sinks/msvc_sink.h>
#include <vector>
#include <memory>
#include <iostream>
void static setupSpdlog() {
try {
QString logDir = Pathing::getInstance()->paths().appData;
QString logPath = logDir + "/lexicon.log";
QDir dir(logDir);
if (!dir.exists()) {
if (!dir.mkpath(".")) {
std::cerr << "Failed to create log directory: " << logDir.toStdString() << std::endl;
return;
}
}
// Two sinks for output to file and visual studio output console
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(logPath.toStdString(), true);
auto msvc_sink = std::make_shared<spdlog::sinks::msvc_sink_mt>();
file_sink->set_pattern("[%Y-%m-%d %H:%M:%S.%f] [%l] [%t] %v");
msvc_sink->set_pattern("[%H:%M:%S.%f] [%l] %v");
std::vector<spdlog::sink_ptr> sinks;
sinks.push_back(file_sink);
sinks.push_back(msvc_sink);
auto logger = std::make_shared<spdlog::logger>("multi_sink_logger", sinks.begin(), sinks.end());
spdlog::set_default_logger(logger);
spdlog::set_level(spdlog::level::debug);
spdlog::flush_on(spdlog::level::info);
spdlog::info("Spdlog initialized successfully. Log file: {}", logPath.toStdString());
} catch (const spdlog::spdlog_ex& ex) {
std::cout << "Spdlog initialization failed: " << ex.what() << std::endl;
}
}
int main(int argc, char *argv[])
{
qputenv("QSG_BATCH_RENDER_THRESHOLD", "64");
qputenv("QSG_BATCH_ALLOCATOR_CHUNK_SIZE", "262144");
//qputenv("QSG_RENDER_LOOP", "basic");
qputenv("QSG_RHI_BACKEND", "d3d11");
QGuiApplication app(argc, argv);
app.setApplicationName("ModdingLexicon");
app.setApplicationVersion("1.4");
setupSpdlog();
QFontDatabase::addApplicationFont(":/fonts/Roboto-Regular.ttf");
app.setFont(QFont("Segoe UI", 10));
QQmlApplicationEngine engine;
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [](QObject* obj, const QUrl& objUrl) {
if (!obj) {
spdlog::error("Failed to load QML component from: {}", objUrl.toString().toStdString());
QCoreApplication::exit(-1);
return;
}
}, Qt::QueuedConnection);
engine.loadFromModule("ModdingLexicon", "Main");
return app.exec();
}