|
@@ -541,9 +541,6 @@ struct EngineButton : MenuButton { |
|
|
//////////////////// |
|
|
//////////////////// |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool isLoggingIn = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct AccountPasswordField : ui::PasswordField { |
|
|
struct AccountPasswordField : ui::PasswordField { |
|
|
ui::MenuItem* logInItem; |
|
|
ui::MenuItem* logInItem; |
|
|
void onAction(const ActionEvent& e) override { |
|
|
void onAction(const ActionEvent& e) override { |
|
@@ -557,19 +554,17 @@ struct LogInItem : ui::MenuItem { |
|
|
ui::TextField* passwordField; |
|
|
ui::TextField* passwordField; |
|
|
|
|
|
|
|
|
void onAction(const ActionEvent& e) override { |
|
|
void onAction(const ActionEvent& e) override { |
|
|
isLoggingIn = true; |
|
|
|
|
|
std::string email = emailField->text; |
|
|
std::string email = emailField->text; |
|
|
std::string password = passwordField->text; |
|
|
std::string password = passwordField->text; |
|
|
std::thread t([=] { |
|
|
std::thread t([=] { |
|
|
library::logIn(email, password); |
|
|
library::logIn(email, password); |
|
|
isLoggingIn = false; |
|
|
|
|
|
|
|
|
library::checkUpdates(); |
|
|
}); |
|
|
}); |
|
|
t.detach(); |
|
|
t.detach(); |
|
|
e.unconsume(); |
|
|
e.unconsume(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void step() override { |
|
|
void step() override { |
|
|
disabled = isLoggingIn; |
|
|
|
|
|
text = "Log in"; |
|
|
text = "Log in"; |
|
|
rightText = library::loginStatus; |
|
|
rightText = library::loginStatus; |
|
|
MenuItem::step(); |
|
|
MenuItem::step(); |
|
@@ -677,16 +672,16 @@ struct SyncUpdateItem : ui::MenuItem { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct LibraryMenu : ui::Menu { |
|
|
struct LibraryMenu : ui::Menu { |
|
|
bool loggedIn = false; |
|
|
|
|
|
|
|
|
|
|
|
LibraryMenu() { |
|
|
LibraryMenu() { |
|
|
refresh(); |
|
|
refresh(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void step() override { |
|
|
void step() override { |
|
|
// Refresh menu when appropriate |
|
|
// Refresh menu when appropriate |
|
|
if (!loggedIn && library::isLoggedIn()) |
|
|
|
|
|
|
|
|
if (library::refreshRequested) { |
|
|
|
|
|
library::refreshRequested = false; |
|
|
refresh(); |
|
|
refresh(); |
|
|
|
|
|
} |
|
|
Menu::step(); |
|
|
Menu::step(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -721,8 +716,6 @@ struct LibraryMenu : ui::Menu { |
|
|
addChild(logInItem); |
|
|
addChild(logInItem); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
loggedIn = true; |
|
|
|
|
|
|
|
|
|
|
|
addChild(createMenuItem("Log out", "", [=]() { |
|
|
addChild(createMenuItem("Log out", "", [=]() { |
|
|
library::logOut(); |
|
|
library::logOut(); |
|
|
})); |
|
|
})); |
|
@@ -737,10 +730,7 @@ struct LibraryMenu : ui::Menu { |
|
|
|
|
|
|
|
|
if (!library::updateInfos.empty()) { |
|
|
if (!library::updateInfos.empty()) { |
|
|
addChild(new ui::MenuSeparator); |
|
|
addChild(new ui::MenuSeparator); |
|
|
|
|
|
|
|
|
ui::MenuLabel* updatesLabel = new ui::MenuLabel; |
|
|
|
|
|
updatesLabel->text = "Updates"; |
|
|
|
|
|
addChild(updatesLabel); |
|
|
|
|
|
|
|
|
addChild(createMenuLabel("Updates")); |
|
|
|
|
|
|
|
|
for (auto& pair : library::updateInfos) { |
|
|
for (auto& pair : library::updateInfos) { |
|
|
SyncUpdateItem* updateItem = new SyncUpdateItem; |
|
|
SyncUpdateItem* updateItem = new SyncUpdateItem; |
|
@@ -748,19 +738,6 @@ struct LibraryMenu : ui::Menu { |
|
|
addChild(updateItem); |
|
|
addChild(updateItem); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if (!settings::autoCheckUpdates) { |
|
|
|
|
|
struct CheckUpdatesItem : ui::MenuItem { |
|
|
|
|
|
void onAction(const ActionEvent& e) override { |
|
|
|
|
|
std::thread t([&] { |
|
|
|
|
|
library::checkUpdates(); |
|
|
|
|
|
}); |
|
|
|
|
|
t.detach(); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
CheckUpdatesItem* checkUpdatesItem = new CheckUpdatesItem; |
|
|
|
|
|
checkUpdatesItem->text = "Check for updates"; |
|
|
|
|
|
addChild(checkUpdatesItem); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
@@ -778,6 +755,12 @@ struct LibraryButton : MenuButton { |
|
|
ui::Menu* menu = createMenu<LibraryMenu>(); |
|
|
ui::Menu* menu = createMenu<LibraryMenu>(); |
|
|
menu->cornerFlags = BND_CORNER_TOP; |
|
|
menu->cornerFlags = BND_CORNER_TOP; |
|
|
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); |
|
|
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); |
|
|
|
|
|
// Check for updates when menu is opened |
|
|
|
|
|
std::thread t([&]() { |
|
|
|
|
|
system::setThreadName("Library"); |
|
|
|
|
|
library::checkUpdates(); |
|
|
|
|
|
}); |
|
|
|
|
|
t.detach(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void step() override { |
|
|
void step() override { |
|
|