Remove subscription levels; license valid = subscribed

This commit is contained in:
NeilClack
2026-08-15 00:54:24 -05:00
parent 8ca60de647
commit f14bf3e29a
19 changed files with 136 additions and 1534 deletions
+5 -53
View File
@@ -1,6 +1,5 @@
#include "proclamation_options_page.h"
#include "app_state.h"
#include "network/license_service.h"
#include "network/proclamation_sync.h"
#include <SDL3/SDL.h>
#include <algorithm>
@@ -9,8 +8,6 @@
namespace {
constexpr uint64_t kFlashDurationMs = 700;
// Case-insensitive word-prefix match: true when any word in `text` (split on
// non-alphanumeric boundaries) starts with `query`. Both must already be
// lowercase. Mirrors the old Go browser's matching behavior.
@@ -45,9 +42,6 @@ void ProclamationOptionsPage::onPush(AppState& state)
createFonts();
SDL_StartTextInput(state.window);
int level = radiantwave::license::getStoredSubscriptionLevelId(state.db);
subscriptionLevelId_ = level > 0 ? level : 1;
// TODO(portal #4/#5): once the portal exposes color palettes, sync them
// alongside proclamations here (sync::syncColorPalettesFromApi after this
// succeeds) so palette updates reach the scroller on every manual refresh.
@@ -83,9 +77,6 @@ void ProclamationOptionsPage::onResume(AppState& state)
createFonts();
SDL_StartTextInput(state.window);
int level = radiantwave::license::getStoredSubscriptionLevelId(state.db);
subscriptionLevelId_ = level > 0 ? level : 1;
loadFromDb();
rebuildItems();
rebuildVisible();
@@ -302,27 +293,6 @@ void ProclamationOptionsPage::toggleItem()
return;
}
// Selecting a proclamation whose required subscription level is above the
// one attached to the stored license key is rejected: the name flashes red
// and a hint is shown up top.
if (!item.selected) {
int requiredLevel = 1;
for (const auto& p : proclamations_) {
if (p.id == item.id) {
requiredLevel = p.required_level_id;
break;
}
}
if (requiredLevel > subscriptionLevelId_) {
flashItemIndex_ = static_cast<int>(visible_[highlightIndex_]);
flashUntilMs_ = SDL_GetTicks() + kFlashDurationMs;
statusMessage_ = "This proclamation is available on " +
radiantwave::license::subscriptionLevelName(requiredLevel) +
" systems";
return;
}
}
item.selected = !item.selected;
for (auto& p : proclamations_) {
if (p.id == item.id) {
@@ -390,9 +360,9 @@ int ProclamationOptionsPage::activeListSize() const
}
// Toggles the highlighted search result. Selection rules mirror toggleItem():
// the always-on top-level proclamation is not togglable, and locked
// proclamations flash red. Selection state is synced back into items_ so the
// browse tree stays consistent when search mode ends.
// the always-on top-level proclamation is not togglable. Selection state is
// synced back into items_ so the browse tree stays consistent when search mode
// ends.
void ProclamationOptionsPage::toggleSearchItem()
{
if (searchResults_.empty()) return;
@@ -403,17 +373,6 @@ void ProclamationOptionsPage::toggleSearchItem()
return;
}
if (!p.selected) {
if (p.required_level_id > subscriptionLevelId_) {
flashItemIndex_ = static_cast<int>(searchResults_[highlightIndex_]);
flashUntilMs_ = SDL_GetTicks() + kFlashDurationMs;
statusMessage_ = "This proclamation is available on " +
radiantwave::license::subscriptionLevelName(p.required_level_id) +
" systems";
return;
}
}
p.selected = !p.selected;
for (auto& item : items_) {
if (item.type == FlatItem::Type::Proclamation && item.id == p.id) {
@@ -609,9 +568,6 @@ void ProclamationOptionsPage::render(SDL_Renderer* renderer)
SDL_Color gray = {170, 170, 170, 255};
SDL_Color categoryBlue = {100, 180, 255, 255};
SDL_Color selectedOrange = {255, 170, 60, 255};
SDL_Color lockedRed = {235, 70, 70, 255};
bool flashing = SDL_GetTicks() < flashUntilMs_;
float titleY = 50.0f;
float titleH = 0.0f;
@@ -718,9 +674,7 @@ void ProclamationOptionsPage::render(SDL_Renderer* renderer)
float y = listTop + rowIndex * rowPitch;
SDL_Color color = white;
if (flashing && searchResults_[i] == static_cast<size_t>(flashItemIndex_)) {
color = lockedRed;
} else if (p.selected) {
if (p.selected) {
color = selectedOrange;
}
@@ -771,9 +725,7 @@ void ProclamationOptionsPage::render(SDL_Renderer* renderer)
}
SDL_Color color = white;
if (flashing && static_cast<int>(visible_[i]) == flashItemIndex_) {
color = lockedRed;
} else if (item.type == FlatItem::Type::RootCategory || item.type == FlatItem::Type::SubCategory) {
if (item.type == FlatItem::Type::RootCategory || item.type == FlatItem::Type::SubCategory) {
color = categoryBlue;
} else if (item.selected || item.isDefault) {
color = selectedOrange;