commit b8e7c4dd3836ebe18fd13831addb0c2b760abe0f
parent 4810df67ee37fb0d77c3bf0699222ec74f5b4d7c
Author: cfillion <cfillion@users.noreply.github.com>
Date: Sun, 1 May 2016 13:57:29 -0700
show a message box if critical api functions cannot be imported
Diffstat:
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/main.cpp b/src/main.cpp
@@ -42,25 +42,34 @@ static bool loadAPI(void *(*getFunc)(const char *))
REQUIRED_API(GetAppVersion),
REQUIRED_API(GetMainHwnd),
REQUIRED_API(GetResourcePath),
- REQUIRED_API(GetUserFileNameForRead), // v3.21
REQUIRED_API(NamedCommandLookup), // v3.1415
REQUIRED_API(plugin_register),
REQUIRED_API(RecursiveCreateDirectory), // v4.60
- REQUIRED_API(ReverseNamedCommandLookup), // v4.7
REQUIRED_API(ShowMessageBox),
REQUIRED_API(Splash_GetWnd), // v4.7
OPTIONAL_API(AddRemoveReaScript), // v5.12
};
- bool ok = true;
-
for(const ApiFunc &func : funcs) {
*func.ptr = getFunc(func.name);
- ok = ok && (*func.ptr || !func.required);
+
+ if(func.required && *func.ptr == nullptr) {
+ auto_char msg[1024] = {};
+ auto_snprintf(msg, auto_size(msg),
+ AUTO_STR("ReaPack v%s is incompatible with this version of REAPER.\r\n\r\n")
+ AUTO_STR("(Unable to import the following API function: %s)"),
+ make_autostring(ReaPack::VERSION).c_str(),
+ make_autostring(func.name).c_str());
+
+ MessageBox(Splash_GetWnd ? Splash_GetWnd() : nullptr,
+ msg, AUTO_STR("ReaPack: Fatal Error"), MB_OK);
+
+ return false;
+ }
}
- return ok;
+ return true;
}
#undef REQUIRED_API