Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.
C++ 3d3d-sculptingcppdear-imguidigital-sculptingfbxgame-developmentgaussian-splattinggltfimage-to-3dmcpopenglopenusdsculptingtext-to-3dunreal-engine
Merge feat/one-click-update 07e9fda6 (startMemberSignIn(onDone)); the membership card uses its callback
islandmed3558a3452e79
diff --cc src/app/App.hindex 8a2a54b8,674f2db6..7fdc4b57--- a/src/app/App.h+++ b/src/app/App.h@@@ -462,23 -465,6 +462,23 @@@ privatebool supportCardEvent(const SDL_Event& e); // input while it's open goes to it, not the canvas or shortcutsvoid drawSupportCard();void drawSupportPrefs(); // Preferences > Support+ // The small card at good moments.+ int64_t memberClock() const; // seconds since 1970 (UI tests: their own clock)+ int64_t memberClockOffset_ = 0; // UI tests: `member_card days=N`+ void memberMoment(MemberMoment m); // a good moment happened: the card follows if it may (Support.h)+ void tickMemberCard(float dt); // the sculpting time, and the card once the frame is calm+ void drawMemberCard();+ void memberCardChoice(MemberCardChoice c);+ void verifyMember(); // "I'm already a member": the member builds' GitHub sign-in- void memberSignInFinished(bool ok); // (PanelUpdate.cpp, when a sign-in ends)++ void memberSignInFinished(bool member); // the card's sign-in ended (startMemberSignIn's onDone)+ bool memberSignedIn() const { return memberBuilds_; }+ double sessionSculptSeconds_ = 0.0; // stroke time in this session+ bool sculptMomentDone_ = false; // the sculpting moment came this session+ MemberMoment memberMomentPending_ = MemberMoment::None; // allowed, waiting for a calm frame+ MemberMoment memberCard_ = MemberMoment::None; // the small card showing+ bool memberVerifying_ = false; // the card's sign-in runs (shown in the card)+ bool updatedThisStart_ = false; // this start runs a newer version than the last (the update moment)+ std::string challengeTitle_; // the monthly challenge whose results came (latest.json)// Show SculptForge on Discord (PanelIntegrations.cpp, core/DiscordPresence.h): off by default, project.json.struct DiscordPresencePrefs {bool enabled = false, showChallenge = false, showFileName = false;@@@ -1339,8 -1324,10 +1339,11 @@@// (from the keychain, refreshed when it has run out; false and `signedOut` when the sign-in is gone).static void checkMemberBuilds(MemberAuth& auth, UpdateJob& job);static bool memberAccessToken(MemberAuth& auth, std::string& token, std::string& error, bool& signedOut);- void startMemberSignIn();+ // The one member sign-in (GitHub device flow; Preferences > Updates and the membership card's "I'm already a+ // member" both use it): `onDone(member)` runs on the main thread when it ends: true = signed in with an account+ // that can see member builds (memberBuilds_ is then true); false = not a member, declined, failed or cancelled.+ void startMemberSignIn(std::function<void(bool member)> onDone = {});+ void finishMemberSignInForTest(bool ok); // UI tests' member_sign_in: the running sign-in ends (GitHub never reached)void memberSignOut();std::shared_ptr<MemberAuth> memberAuth_;std::shared_ptr<MemberSignIn> memberSignIn_;diff --cc src/app/PanelSupportCard.cppindex d9a73201,da3337eb..dc0c843d--- a/src/app/PanelSupportCard.cpp+++ b/src/app/PanelSupportCard.cpp@@@ -513,151 -549,16 +513,151 @@@ void App::drawSupportCard()}void App::drawSupportPrefs() {- if (ImGui::Checkbox("Show the support card at launch", &supportCardPrefs_.enabled)) saveProjectPrefs();- ui::HelpText("Show the support card at launch", nullptr,- "A card with the SculptForge memberships, shown while it starts: the first time, after "- "each update, and at most once a week otherwise; Maybe later hides it for 30 days. Never while you work.",- "Preferences > Support");- if (ImGui::Checkbox("I'm a supporter", &supportCardPrefs_.supporter)) saveProjectPrefs();- ui::HelpText("I'm a supporter", nullptr,- "Thank you! The support card never shows. Kept on this computer only: SculptForge has no accounts.",- "Preferences > Support");- if (ImGui::Button("Show the support card", ImVec2(-1, 0))) showSupportCard(SupportCardReason::Weekly);+ if (supportCardPrefs_.supporter || memberSignedIn()) {+ ImGui::TextWrapped("%s", "Thank you for being a member! No membership cards show.");+ } else {+ ImGui::TextWrapped("%s", "A small membership card shows at most once a week, at a good moment (never mid-stroke), "+ "until you become a member.");+ if (ImGui::Button("I'm already a member##prefs.member_verify", ImVec2(-1, 0))) verifyMember();+ ui::HelpText("I'm already a member", nullptr,+ "Signs in with GitHub, as member builds do (Preferences > Updates): no more membership cards, "+ "and the member builds are on.",+ "Preferences > Support");+ }+ if (ImGui::Button("Show the memberships", ImVec2(-1, 0))) showSupportCard(SupportCardReason::Manual);+}++// --- The small card at good moments ---++int64_t App::memberClock() const { return int64_t(std::time(nullptr)) + memberClockOffset_; }++void App::memberMoment(MemberMoment m) {+ const bool testMode = supportCardTestMode() && !memberCardTestMode_;+ if (m == MemberMoment::None || memberCard_ != MemberMoment::None || memberVerifying_) return;+ if (!memberMomentAllowed(supportCardPrefs_, memberSignedIn(), memberClock(), testMode)) return;+ memberMomentPending_ = m; // (the latest moment's words)+ redrawIn(0.0);+}++void App::tickMemberCard(float dt) {+ const bool stroking = doc_.sculptor.strokeActive();+ if (stroking) sessionSculptSeconds_ = addSculptTime(sessionSculptSeconds_, double(dt));+ if (sculptMomentDue(sessionSculptSeconds_, sculptMomentDone_)) {+ sculptMomentDone_ = true;+ memberMoment(MemberMoment::Sculpted);+ }+ if (memberMomentPending_ == MemberMoment::None) return;+ const bool otherCard = supportCard_ || showWelcome_ || quickTourOpen_ || whatsNew_ || showWhatsNew_ ||+ ImGui::GetTopMostPopupModal() != nullptr;+ if (!memberCardMayOpen(stroking, backgroundBusy(), otherCard)) return; // (it waits)+ memberCard_ = std::exchange(memberMomentPending_, MemberMoment::None);+ supportCardPrefs_.shownAt = memberClock();+ saveProjectPrefs(); // (recorded as it shows: a crash can't bring it back at once)+ redrawIn(0.0);+}++void App::memberCardChoice(MemberCardChoice c) {+ applyMemberCardChoice(supportCardPrefs_, c, memberClock());+ if (c == MemberCardChoice::SignedIn) status_ = "Thank you for being a member! No more membership cards.";+ if (c == MemberCardChoice::NoSignIn)+ status_ = "No member sign-in: no membership cards for three months (Preferences > Support signs in later).";+ memberCard_ = MemberMoment::None;+ saveProjectPrefs();+}++void App::verifyMember() {+ if (memberSignedIn()) { // (already signed in for member builds)+ memberCardChoice(MemberCardChoice::SignedIn);+ return;+ }+ memberVerifying_ = true;+ memberMomentPending_ = MemberMoment::None;- startMemberSignIn(); // (PanelUpdate.cpp; a sign-in already running is kept)++ startMemberSignIn([this](bool member) { memberSignInFinished(member); }); // (PanelUpdate.cpp: the one sign-in)+ redrawIn(0.0);+}+- void App::memberSignInFinished(bool ok) {- if (ok) memberCardChoice(MemberCardChoice::SignedIn); // gone for good (and member builds are on)- else if (memberVerifying_) memberCardChoice(MemberCardChoice::NoSignIn);++void App::memberSignInFinished(bool member) {+ memberVerifying_ = false;++ // A member: gone for good (and member builds are on). Not signed in (cancelled, declined, no access): 3 months.++ memberCardChoice(member ? MemberCardChoice::SignedIn : MemberCardChoice::NoSignIn);+}++void App::drawMemberCard() {+ if (memberCard_ == MemberMoment::None && !memberVerifying_) return;+ const float s = uiScale_;+ const CanvasRect c = canvasRect();+ ImGui::SetNextWindowPos(ImVec2(c.x + c.w * 0.5f, c.y + c.h - 16.0f * s), ImGuiCond_Always, ImVec2(0.5f, 1.0f));+ ImGui::SetNextWindowSize(ImVec2(std::min(560.0f * s, c.w - 32.0f * s), 0.0f), ImGuiCond_Always);+ ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(18.0f * s, 14.0f * s));+ ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 12.0f * s);+ ImGui::PushStyleColor(ImGuiCol_Border, theme::accent);+ const ImGuiWindowFlags flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings |+ ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoMove;+ const bool began = ImGui::Begin("##member_card", nullptr, flags);+ ImGui::PopStyleColor();+ ImGui::PopStyleVar(2);+ if (began) {+ ImFont* bold = boldFont();+ if (memberVerifying_) {+ if (bold) ImGui::PushFont(bold);+ ImGui::TextWrapped("%s", "Sign in with the GitHub account that has the members' invitation.");+ if (bold) ImGui::PopFont();+ ImGui::TextDisabled("%s", "It can only read the member builds; Preferences > Updates signs out.");+ ImGui::Spacing();+ if (memberSignIn_) drawMemberSignInSteps(); // (PanelUpdate.cpp)- else memberSignInFinished(memberSignedIn()); // (a sign-in that ended before it drew)++ else memberSignInFinished(memberSignedIn()); // (gone without an answer: Sign out in Preferences meanwhile)+ } else {+ std::string line;+ switch (memberCard_) {+ case MemberMoment::Sculpted: line = "Twenty minutes of sculpting. Members keep SculptForge free and moving."; break;+ case MemberMoment::SavedRender: line = "Nice render. Members keep SculptForge free and moving."; break;+ case MemberMoment::Updated:+ line = std::string("SculptForge ") + appVersionLabel() + " is here. Members get new versions early, as betas.";+ break;+ case MemberMoment::Challenge:+ line = challengeTitle_.empty() ? std::string("The monthly challenge results are in, on Discord.")+ : "The " + challengeTitle_ + " challenge results are in, on Discord.";+ break;+ case MemberMoment::None: break;+ }+ if (bold) ImGui::PushFont(bold);+ ImGui::TextWrapped("%s", line.c_str());+ if (bold) ImGui::PopFont();+ ImGui::PushStyleColor(ImGuiCol_Text, theme::textDim);+ ImGui::TextWrapped("%s", "$5 a month or $48 a year: betas early, the feature vote, Member Requests and your "+ "name in the credits. Nothing in the app is ever paywalled.");+ ImGui::PopStyleColor();+ const FoundingMembers& founding = foundingMembers();+ if (founding.open()) {+ ImGui::PushStyleColor(ImGuiCol_Text, theme::accentHover);+ ImGui::TextWrapped("The first %d members are Founding Members: a badge, their name in the credits and "+ "their price locked for good.", founding.limit);+ ImGui::PopStyleColor();+ }+ ImGui::Spacing();+ ImGui::PushStyleColor(ImGuiCol_Button, theme::accent);+ ImGui::PushStyleColor(ImGuiCol_ButtonHovered, theme::accentHover);+ ImGui::PushStyleColor(ImGuiCol_Text, theme::textOnAccent);+ const bool become = ImGui::Button("Become a member##member_card.become");+ ImGui::PopStyleColor(3);+ ImGui::SameLine();+ const bool notNow = ImGui::Button("Not now##member_card.not_now");+ if (ImGui::IsItemHovered()) ImGui::SetTooltip("Nothing about memberships for a week.");+ ImGui::SameLine();+ const bool already = ImGui::Button("I'm already a member##member_card.already");+ if (ImGui::IsItemHovered()) ImGui::SetTooltip("Sign in with GitHub (the member builds' sign-in): no more cards.");+ if (become) {+ openSupportPage(); // both choices (monthly, yearly) on the membership page+ memberCardChoice(MemberCardChoice::Become);+ } else if (notNow) {+ memberCardChoice(MemberCardChoice::NotNow);+ } else if (already) {+ memberCard_ = MemberMoment::None;+ verifyMember();+ }+ }+ }+ ImGui::End();}} // namespace sf