forked from tiltedphoques/TiltedEvolution
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
84 lines (63 loc) · 3.01 KB
/
Copy pathmain.cpp
File metadata and controls
84 lines (63 loc) · 3.01 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 <TiltedOnlineApp.h>
#include <TiltedOnlinePCH.h>
#include <ScriptExtender.h>
#include <Commctrl.h>
#include <Windows.h>
#include <base/dialogues/win/TaskDialog.h>
// 1 - Steam, 2 - GOG
inline constexpr std::string_view kSupportedGameVersions[2] = {"1.6.1170.0", "1.6.1179.0"};
std::unique_ptr<TiltedOnlineApp> g_appInstance{nullptr};
extern HICON g_SharedWindowIcon;
static void ShowAddressLibraryError(const wchar_t* apGamePath)
{
auto errorDetail = fmt::format(L"Looking for it here: {}\\Data\\SKSE\\Plugins", apGamePath);
Base::TaskDialog dia(g_SharedWindowIcon, L"Error", L"Failed to load Skyrim Address Library", L"Make sure to use \"All in one\"", errorDetail.c_str());
dia.AppendButton(0xBEED, L"Visit troubleshooting page on wiki.tiltedphoques.com");
dia.AppendButton(0xBEEF, L"Visit Address Library modpage on nexusmods.com");
const int result = dia.Show();
if (result == 0xBEEF)
{
ShellExecuteW(nullptr, L"open", LR"(https://www.nexusmods.com/skyrimspecialedition/mods/32444?tab=files)", nullptr, nullptr, SW_SHOWNORMAL);
}
else if (result == 0xBEED)
{
ShellExecuteW(nullptr, L"open", LR"(https://wiki.tiltedphoques.com/tilted-online/guides/troubleshooting/address-library-error)", nullptr, nullptr, SW_SHOWNORMAL);
}
exit(4);
}
static void ShowIncompatibleVersionError(const char* apDetectedGameVersion, const wchar_t* apGamePath)
{
constexpr wchar_t kModPageUrl[] = LR"(https://www.nexusmods.com/skyrimspecialedition/mods/69993?tab=files)";
const auto [steamVer, gogVer] = kSupportedGameVersions;
std::string supportedVersions = steamVer != gogVer ? fmt::format("{} (or {} if GOG)", steamVer, gogVer) : std::string{steamVer};
std::string message = fmt::format("Skyrim Together {} requires Skyrim SE {}, but your installed version is {}\n\nUpdate or downgrade to match, then relaunch", BUILD_COMMIT + 1, supportedVersions, apDetectedGameVersion);
std::wstring wideMessage(message.begin(), message.end());
const auto optionalDetails = fmt::format(L"Installed here: {}", apGamePath);
Base::TaskDialog dia(g_SharedWindowIcon, L"Error", L"Incompatible game version", wideMessage.c_str(), optionalDetails.c_str());
dia.AppendButton(0xBEEF, L"Visit Skyrim Together mod page on nexusmods.com");
if (dia.Show() == 0xBEEF)
{
ShellExecuteW(nullptr, L"open", kModPageUrl, nullptr, nullptr, SW_SHOWNORMAL);
}
exit(4);
}
void RunTiltedInit(const std::filesystem::path& acGamePath, const String& aExeVersion)
{
if (!VersionDb::Get().Load(acGamePath, aExeVersion))
{
ShowAddressLibraryError(acGamePath.c_str());
}
auto [steamVer, gogVer] = kSupportedGameVersions;
if (aExeVersion != steamVer && aExeVersion != gogVer)
{
ShowIncompatibleVersionError(aExeVersion.c_str(), acGamePath.c_str());
}
g_appInstance = std::make_unique<TiltedOnlineApp>();
TiltedOnlineApp::InstallHooks2();
TP_HOOK_COMMIT;
LoadScriptExtender();
}
void RunTiltedApp()
{
g_appInstance->BeginMain();
}