Skip to content

Commit df2cf66

Browse files
Release/1.0.0 rc6 (#18)
* Modifies helper app to only bring main OBS window to foreground. * Adds update check and dialog. * Disables logout button while products are loading, to prevent null pointer issues. * Backs up current scene collection json file before switching to new scene collection. * Updates menu items names. * Misc UI updates.
1 parent 320ef77 commit df2cf66

14 files changed

+274
-21
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ target_sources(
7575
src/elgato-cloud-config.hpp
7676
src/elgato-cloud-window.cpp
7777
src/elgato-cloud-window.hpp
78+
src/elgato-update-modal.cpp
79+
src/elgato-update-modal.hpp
7880
src/elgato-widgets.cpp
7981
src/elgato-widgets.hpp)
8082

buildspec.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
"versionMajor": 1,
4242
"versionMinor": 0,
4343
"versionPatch": 0,
44-
"buildNumber": 123,
45-
"releaseType": "rc5",
44+
"buildNumber": 0,
45+
"releaseType": "rc6",
4646
"author": "Elgato",
4747
"website": "https://elgato.com",
4848
"email": "support@elgato.com",

data/locale/en-US.ini

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ ExportWizard.RequiredPlugins.Title="Add required plugins"
4343
ExportWizard.RequiredPlugins.Text="Select any plugins needed to run this asset"
4444
ExportWizard.RequiredPlugins.NoPluginsFound="No installed plugins found."
4545
ExportWizard.ExportComplete.Title="Export complete"
46-
ExportWizard.ExportComplete.Text="Bundle successfully exported. Click 'Done' below to close this window."
46+
ExportWizard.ExportComplete.Text="Your scene collection is now ready to test or upload to Marketplace."
4747
ExportWizard.Exporting.Title="Exporting Bundle..."
4848
ExportWizard.Exporting.Text="Note: this can take a few minutes for scene collections with large files."
4949
SetupWizard.WindowTitle="Install Scene Collection"
5050
SetupWizard.NextButton="Continue"
5151
SetupWizard.BackButton="Back"
52-
SetupWizard.StartInstall.Title="Start install"
52+
SetupWizard.GetStartedButton="Get started"
53+
SetupWizard.StartInstall.Title="Just a few quick steps and\nyour setup is ready to use"
5354
SetupWizard.MissingPlugins.Title="You're missing something"
5455
SetupWizard.MissingPlugins.Text="To continue, download the following free plugins, then restart OBS and try again"
5556
SetupWizard.MissingPlugins.DownloadButton="Get"
@@ -64,4 +65,10 @@ SetupWizard.AudioSetup.Device.Text="Select a microphone"
6465
SetupWizard.Loading.Title="Loading Collection..."
6566
SetupWizard.Loading.Text="Note: this can take some time for scene collections with large files."
6667
SetupWizard.IncompatibleFile.Title="Incompatible file"
67-
SetupWizard.IncompatibleFile.Text="Error: This download did not contain a valid bundleInfo.json file and cannot be installed. (note: this is a problem with the submitted scene collection file on the server)"
68+
SetupWizard.IncompatibleFile.Text="Error: This download did not contain a valid bundleInfo.json file and cannot be installed. (note: this is a problem with the submitted scene collection file on the server)"
69+
70+
UpdateModal.Title="Update available"
71+
UpdateModal.SkipVersionButton="Skip this verison"
72+
UpdateModal.LaterButton="Remind me later"
73+
UpdateModal.DownloadUpdateButton="Download Update"
74+
UpdateModal.Description="A new version of the Marketplace Direct to OBS is available to download, please download to maintain functionality!

loader/main.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
#include <tlhelp32.h>
44
#include <algorithm>
55

6-
#define BUFFER_SIZE 8000
6+
#include <iostream>
77

8+
#define BUFFER_SIZE 8000
89

910
void ToLowerCase(std::wstring& str) {
1011
std::transform(str.begin(), str.end(), str.begin(), ::towlower);
@@ -17,22 +18,22 @@ bool IsObs64Running() {
1718
return false; // Failed to take snapshot
1819
}
1920

20-
PROCESSENTRY32 pe32;
21-
pe32.dwSize = sizeof(PROCESSENTRY32);
21+
PROCESSENTRY32 processEntry;
22+
processEntry.dwSize = sizeof(PROCESSENTRY32);
2223

2324
// Start iterating through processes
24-
if (Process32First(hProcessSnap, &pe32)) {
25+
if (Process32First(hProcessSnap, &processEntry)) {
2526
do {
2627
// Convert the process name to lowercase for comparison
27-
std::wstring processName(pe32.szExeFile);
28+
std::wstring processName(processEntry.szExeFile);
2829
ToLowerCase(processName);
2930

3031
// Compare process name to "obs64.exe" in lowercase
3132
if (processName == L"obs64.exe") {
3233
CloseHandle(hProcessSnap);
3334
return true; // obs64.exe is running
3435
}
35-
} while (Process32Next(hProcessSnap, &pe32)); // Move to next process
36+
} while (Process32Next(hProcessSnap, &processEntry)); // Move to next process
3637
}
3738

3839
CloseHandle(hProcessSnap);
@@ -71,10 +72,15 @@ BOOL CALLBACK WindowToForeground(HWND hwnd, LPARAM lParam) {
7172
GetWindowThreadProcessId(hwnd, &processId);
7273

7374
if (processId == lParam) {
75+
wchar_t windowTitle[256];
76+
int titleLength = GetWindowTextW(hwnd, windowTitle, sizeof(windowTitle) / sizeof(wchar_t));
77+
std::wstring title = windowTitle;
7478
// Bring the window to the foreground
75-
SetForegroundWindow(hwnd);
76-
ShowWindow(hwnd, SW_RESTORE); // Restore if minimized
77-
return FALSE; // Stop enumerating windows (we found the window)
79+
if (title.rfind(L"OBS ", 0) == 0) { // the main OBS window title starts with 'OBS '
80+
SetForegroundWindow(hwnd);
81+
ShowWindow(hwnd, SW_RESTORE);
82+
return FALSE; // Stop enumerating windows (we found the window)
83+
}
7884
}
7985
return TRUE; // Continue enumerating windows
8086
}

src/elgato-cloud-data.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ with this program. If not, see <https://www.gnu.org/licenses/>
2929
#include <QThread>
3030
#include <QMetaObject>
3131
#include <QDir>
32+
#include <QVersionNumber>
3233

3334
#include <plugin-support.h>
3435
#include "elgato-cloud-window.hpp"
3536
#include "elgato-cloud-data.hpp"
37+
#include "elgato-update-modal.hpp"
3638
#include "platform.h"
3739
#include "util.h"
3840
#include "api.hpp"
@@ -284,6 +286,44 @@ void ElgatoCloud::LogOut()
284286
}
285287
}
286288

289+
void ElgatoCloud::CheckUpdates(bool forceCheck)
290+
{
291+
try {
292+
std::string updateUrl = "https://gc-updates.elgato.com/windows/marketplace-plugin-for-obs/final/app-version-check.json.php";
293+
auto response = fetch_string_from_get(updateUrl, "");
294+
blog(LOG_INFO, response.c_str());
295+
auto responseJson = nlohmann::json::parse(response);
296+
if (responseJson.contains("Automatic")) {
297+
auto details = responseJson["Automatic"];
298+
std::string version = details["Version"];
299+
std::string downloadUrl = details["downloadURL"];
300+
auto updateVersion = QVersionNumber::fromString(version);
301+
auto currentVersion = QVersionNumber::fromString(PLUGIN_VERSION);
302+
std::string skip = _skipUpdate == "" ? "0.0.0" : _skipUpdate;
303+
blog(LOG_INFO, "update: %s, current: %s, skip: %s", version.c_str(), PLUGIN_VERSION, skip.c_str());
304+
auto skipVersion = QVersionNumber::fromString(skip);
305+
if ((forceCheck || skipVersion != updateVersion) && updateVersion > currentVersion) {
306+
// Reset the "skip this update" flag because we now have a
307+
// new update.
308+
_skipUpdate = !forceCheck ? "" : _skipUpdate;
309+
blog(LOG_INFO, "UPDATE FOUND.");
310+
openUpdateModal(version, downloadUrl);
311+
}
312+
} else {
313+
throw("Error");
314+
}
315+
}
316+
catch (...) {
317+
blog(LOG_INFO, "Unable to contact update server.");
318+
}
319+
}
320+
321+
void ElgatoCloud::SetSkipVersion(std::string version)
322+
{
323+
_skipUpdate = version;
324+
_SaveState();
325+
}
326+
287327
void ElgatoCloud::LoadPurchasedProducts()
288328
{
289329
if (!loggedIn) {
@@ -441,6 +481,7 @@ void ElgatoCloud::_SaveState()
441481
_accessTokenExpiration);
442482
obs_data_set_int(_config, "RefreshTokenExpiration",
443483
_refreshTokenExpiration);
484+
obs_data_set_string(_config, "SkipUpdate", _skipUpdate.c_str());
444485
SaveConfig();
445486
}
446487

@@ -452,6 +493,7 @@ void ElgatoCloud::_GetSavedState()
452493
obs_data_get_int(_config, "AccessTokenExpiration");
453494
_refreshTokenExpiration =
454495
obs_data_get_int(_config, "RefreshTokenExpiration");
496+
_skipUpdate = obs_data_get_string(_config, "SkipUpdate");
455497
}
456498

457499
} // namespace elgatocloud

src/elgato-cloud-data.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ class ElgatoCloud {
5252
void StartLogin();
5353
void LogOut();
5454
void LoadPurchasedProducts();
55+
void CheckUpdates(bool forceCheck);
5556
obs_data_t *GetConfig();
57+
void SetSkipVersion(std::string version);
5658
void SaveConfig();
5759
nlohmann::json GetPurchaseDownloadLink(std::string variantId);
5860

@@ -87,6 +89,7 @@ class ElgatoCloud {
8789
std::string _refreshToken;
8890
int64_t _accessTokenExpiration;
8991
int64_t _refreshTokenExpiration;
92+
std::string _skipUpdate;
9093
obs_data_t *_config;
9194
bool _makerToolsOnStart;
9295
};

src/elgato-cloud-window.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ WindowToolBar::WindowToolBar(QWidget *parent) : QWidget(parent)
226226
imageBaseDir += "/images/";
227227

228228
auto api = MarketplaceApi::getInstance();
229-
std::string storeUrl = api->storeUrl() + "/graphics/scene-collections";
229+
std::string storeUrl = api->storeUrl() + "/obs/scene-collections?utm_source=mp_connect";
230230

231231
QPalette pal = QPalette();
232232
pal.setColor(QPalette::Window, "#151515");
@@ -306,6 +306,11 @@ WindowToolBar::WindowToolBar(QWidget *parent) : QWidget(parent)
306306

307307
WindowToolBar::~WindowToolBar() {}
308308

309+
void WindowToolBar::disableLogout(bool disabled)
310+
{
311+
_logOutButton->setDisabled(disabled);
312+
}
313+
309314
void WindowToolBar::updateState()
310315
{
311316
_logInButton->setHidden(elgatoCloud->loggedIn);
@@ -523,6 +528,7 @@ void ElgatoCloudWindow::initialize()
523528

524529
void ElgatoCloudWindow::setLoading()
525530
{
531+
_toolbar->disableLogout(true);
526532
_stackedContent->setCurrentIndex(3);
527533
}
528534

@@ -538,13 +544,15 @@ void ElgatoCloudWindow::on_logOutButton_clicked()
538544

539545
void ElgatoCloudWindow::setLoggedIn()
540546
{
547+
_toolbar->disableLogout(false);
541548
if (elgatoCloud->connectionError) {
542549
_stackedContent->setCurrentIndex(2);
543550
} else if (elgatoCloud->loginError) {
544551
_stackedContent->setCurrentIndex(4);
545552
} else if (!elgatoCloud->loggedIn) {
546553
_stackedContent->setCurrentIndex(1);
547554
} else if (elgatoCloud->loading) {
555+
_toolbar->disableLogout(true);
548556
_stackedContent->setCurrentIndex(3);
549557
} else {
550558
_stackedContent->setCurrentIndex(0);
@@ -844,8 +852,9 @@ extern void InitElgatoCloud(obs_module_t *module)
844852
{
845853
elgatoCloud = new ElgatoCloud(module);
846854
QAction *action = (QAction *)obs_frontend_add_tools_menu_qaction(
847-
"Elgato Marketplace");
855+
"Elgato Marketplace Connect");
848856
action->connect(action, &QAction::triggered, OpenElgatoCloudWindow);
857+
obs_frontend_add_event_callback(CheckForUpdatesOnLaunch, nullptr);
849858
}
850859

851860
extern void ShutDown()
@@ -861,4 +870,20 @@ extern obs_data_t *GetElgatoCloudConfig()
861870
return nullptr;
862871
}
863872

873+
extern void CheckForUpdates(bool forceCheck)
874+
{
875+
if (!elgatoCloud) {
876+
return;
877+
}
878+
elgatoCloud->CheckUpdates(forceCheck);
879+
}
880+
881+
extern void CheckForUpdatesOnLaunch(enum obs_frontend_event event, void* private_data)
882+
{
883+
if (event == OBS_FRONTEND_EVENT_FINISHED_LOADING) {
884+
obs_frontend_remove_event_callback(CheckForUpdatesOnLaunch, nullptr);
885+
CheckForUpdates(false);
886+
}
887+
}
888+
864889
} // namespace elgatocloud

src/elgato-cloud-window.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class WindowToolBar : public QWidget {
116116
WindowToolBar(QWidget *parent);
117117
~WindowToolBar();
118118
void updateState();
119+
void disableLogout(bool disabled);
119120

120121
private:
121122
QHBoxLayout *_layout;
@@ -234,5 +235,7 @@ void OpenElgatoCloudWindow();
234235
void CloseElgatoCloudWindow();
235236
ElgatoCloudWindow *GetElgatoCloudWindow();
236237
void ElgatoCloudWindowSetEnabled(bool enable);
238+
void CheckForUpdates(bool forceCheck);
239+
void CheckForUpdatesOnLaunch(enum obs_frontend_event event, void* private_data);
237240

238241
} // namespace elgatocloud

0 commit comments

Comments
 (0)