handle the ui for major and minor versions

This commit is contained in:
altalk23 2023-05-01 18:41:18 +03:00
parent b236a1daac
commit 0f6b173a11
10 changed files with 98 additions and 35 deletions

View file

@ -96,6 +96,7 @@ jobs:
- name: Delete resource cache file - name: Delete resource cache file
run: | run: |
rm ./bin/nightly/resources/.geode_cache rm ./bin/nightly/resources/.geode_cache
rm ./bin/nightly/resources/dont-update.txt
- name: Upload resources - name: Upload resources
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:

1
.gitignore vendored
View file

@ -50,6 +50,7 @@ docs
loader/src/internal/about.hpp loader/src/internal/about.hpp
loader/src/internal/resources.hpp loader/src/internal/resources.hpp
loader/resources/mod.json loader/resources/mod.json
loader/resources/version
loader/resources/blanks/rename.js loader/resources/blanks/rename.js
loader/resources/changelog.md loader/resources/changelog.md
fods-catgirl-hideout.txt fods-catgirl-hideout.txt

View file

@ -1 +1 @@
1.0.0-beta.16 1.0.0-beta.17

View file

@ -29,6 +29,7 @@ execute_process(
# Package info file for internal representation # Package info file for internal representation
configure_file(resources/mod.json.in ${CMAKE_CURRENT_SOURCE_DIR}/resources/mod.json) configure_file(resources/mod.json.in ${CMAKE_CURRENT_SOURCE_DIR}/resources/mod.json)
file(READ resources/mod.json LOADER_MOD_JSON) file(READ resources/mod.json LOADER_MOD_JSON)
configure_file(${GEODE_ROOT_PATH}/VERSION ${CMAKE_CURRENT_SOURCE_DIR}/resources/version COPYONLY)
configure_file(${GEODE_ROOT_PATH}/CHANGELOG.md ${CMAKE_CURRENT_SOURCE_DIR}/resources/changelog.md COPYONLY) configure_file(${GEODE_ROOT_PATH}/CHANGELOG.md ${CMAKE_CURRENT_SOURCE_DIR}/resources/changelog.md COPYONLY)
configure_file(src/internal/about.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/src/internal/about.hpp) configure_file(src/internal/about.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/src/internal/about.hpp)

View file

@ -37,7 +37,8 @@
"about.md", "about.md",
"changelog.md", "changelog.md",
"support.md", "support.md",
"mod.json" "mod.json",
"version"
], ],
"spritesheets": { "spritesheets": {
"LogoSheet": [ "LogoSheet": [

View file

@ -463,8 +463,8 @@ void Index::update(bool force) {
std::vector<IndexItemHandle> Index::getItems() const { std::vector<IndexItemHandle> Index::getItems() const {
std::vector<IndexItemHandle> res; std::vector<IndexItemHandle> res;
for (auto& items : map::values(m_items)) { for (auto& items : map::values(m_items)) {
if (items.size()) { for (auto& item : items) {
res.push_back(items.rbegin()->second); res.push_back(item.second);
} }
} }
return res; return res;
@ -473,9 +473,9 @@ std::vector<IndexItemHandle> Index::getItems() const {
std::vector<IndexItemHandle> Index::getFeaturedItems() const { std::vector<IndexItemHandle> Index::getFeaturedItems() const {
std::vector<IndexItemHandle> res; std::vector<IndexItemHandle> res;
for (auto& items : map::values(m_items)) { for (auto& items : map::values(m_items)) {
if (items.size()) { for (auto& item : items) {
if (items.rbegin()->second->isFeatured) { if (item.second->isFeatured) {
res.push_back(items.rbegin()->second); res.push_back(item.second);
} }
} }
} }
@ -487,9 +487,9 @@ std::vector<IndexItemHandle> Index::getItemsByDeveloper(
) const { ) const {
std::vector<IndexItemHandle> res; std::vector<IndexItemHandle> res;
for (auto& items : map::values(m_items)) { for (auto& items : map::values(m_items)) {
if (items.size()) { for (auto& item : items) {
if (items.rbegin()->second->info.developer() == name) { if (item.second->info.developer() == name) {
res.push_back(items.rbegin()->second); res.push_back(item.second);
} }
} }
} }
@ -503,6 +503,15 @@ bool Index::isKnownItem(
return this->getItem(id, version).get(); return this->getItem(id, version).get();
} }
IndexItemHandle Index::getMajorItem(
std::string const& id
) const {
if (m_items.count(id)) {
return m_items.at(id).rbegin()->second;
}
return nullptr;
}
IndexItemHandle Index::getItem( IndexItemHandle Index::getItem(
std::string const& id, std::string const& id,
std::optional<VersionInfo> version std::optional<VersionInfo> version
@ -558,7 +567,7 @@ bool Index::isUpdateAvailable(IndexItemHandle item) const {
bool Index::areUpdatesAvailable() const { bool Index::areUpdatesAvailable() const {
for (auto& mod : Loader::get()->getAllMods()) { for (auto& mod : Loader::get()->getAllMods()) {
auto item = this->getItem(mod); auto item = this->getMajorItem(mod->getID());
if (item && item->info.version() > mod->getVersion()) { if (item && item->info.version() > mod->getVersion()) {
return true; return true;
} }

View file

@ -624,6 +624,15 @@ bool Loader::Impl::verifyLoaderResources() {
return false; return false;
} }
// TODO: actually have a proper way to disable checking resources
// for development builds
if (ghc::filesystem::exists(resourcesDir / "dont-update.txt")) {
// this is kind of a hack, but it's the easiest way to prevent
// auto update while developing
log::debug("Not updating resources since dont-update.txt exists");
return true;
}
// make sure every file was covered // make sure every file was covered
size_t coverage = 0; size_t coverage = 0;

View file

@ -347,13 +347,12 @@ bool LocalModInfoPopup::init(Mod* mod, ModListLayer* list) {
uninstallBtn->setPosition(-85.f, 75.f); uninstallBtn->setPosition(-85.f, 75.f);
m_buttonMenu->addChild(uninstallBtn); m_buttonMenu->addChild(uninstallBtn);
auto indexItem = Index::get()->getItem( auto latestIndexItem = Index::get()->getMajorItem(
mod->getModInfo().id(), mod->getModInfo().id()
ComparableVersionInfo(mod->getModInfo().version(), VersionCompare::More)
); );
// todo: show update button on loader that invokes the installer // todo: show update button on loader that invokes the installer
if (indexItem && Index::get()->isUpdateAvailable(indexItem)) { if (latestIndexItem && Index::get()->isUpdateAvailable(latestIndexItem)) {
m_installBtnSpr = IconButtonSprite::create( m_installBtnSpr = IconButtonSprite::create(
"GE_button_01.png"_spr, "GE_button_01.png"_spr,
CCSprite::createWithSpriteFrameName("install.png"_spr), CCSprite::createWithSpriteFrameName("install.png"_spr),
@ -371,15 +370,49 @@ bool LocalModInfoPopup::init(Mod* mod, ModListLayer* list) {
m_installStatus->setVisible(false); m_installStatus->setVisible(false);
m_mainLayer->addChild(m_installStatus); m_mainLayer->addChild(m_installStatus);
m_updateVersionLabel = CCLabelBMFont::create( auto minorIndexItem = Index::get()->getItem(
("Available: " + indexItem->info.version().toString()).c_str(), mod->getModInfo().id(),
"bigFont.fnt" ComparableVersionInfo(mod->getModInfo().version(), VersionCompare::MoreEq)
); );
m_updateVersionLabel->setScale(.35f);
m_updateVersionLabel->setAnchorPoint({.0f, .5f}); // TODO: use column layout here?
m_updateVersionLabel->setColor({94, 219, 255});
m_updateVersionLabel->setPosition(winSize.width / 2 + 35.f, winSize.height / 2 + 75.f); if (latestIndexItem->info.version().getMajor() > minorIndexItem->info.version().getMajor()) {
m_mainLayer->addChild(m_updateVersionLabel); // has major update
m_latestVersionLabel = CCLabelBMFont::create(
("Available: " + latestIndexItem->info.version().toString()).c_str(),
"bigFont.fnt"
);
m_latestVersionLabel->setScale(.35f);
m_latestVersionLabel->setAnchorPoint({.0f, .5f});
m_latestVersionLabel->setColor({94, 219, 255});
m_latestVersionLabel->setPosition(winSize.width / 2 + 35.f, winSize.height / 2 + 75.f);
m_mainLayer->addChild(m_latestVersionLabel);
}
if (minorIndexItem->info.version() > mod->getModInfo().version()) {
// has minor update
m_minorVersionLabel = CCLabelBMFont::create(
("Available: " + minorIndexItem->info.version().toString()).c_str(),
"bigFont.fnt"
);
m_minorVersionLabel->setScale(.35f);
m_minorVersionLabel->setAnchorPoint({.0f, .5f});
m_minorVersionLabel->setColor({94, 219, 255});
if (m_latestVersionLabel) {
m_latestVersionLabel->setPosition(
winSize.width / 2 + 35.f, winSize.height / 2 + 81.f
);
m_minorVersionLabel->setPosition(
winSize.width / 2 + 35.f, winSize.height / 2 + 69.f
);
} else {
m_minorVersionLabel->setPosition(
winSize.width / 2 + 35.f, winSize.height / 2 + 75.f
);
}
m_mainLayer->addChild(m_minorVersionLabel);
}
} }
} else { } else {
auto* label = CCLabelBMFont::create(LOADER_COMMIT_HASH, "chatFont.fnt"); auto* label = CCLabelBMFont::create(LOADER_COMMIT_HASH, "chatFont.fnt");
@ -647,8 +680,8 @@ void IndexItemInfoPopup::onCancel(CCObject*) {
} }
void IndexItemInfoPopup::doInstall() { void IndexItemInfoPopup::doInstall() {
if (m_updateVersionLabel) { if (m_latestVersionLabel) {
m_updateVersionLabel->setVisible(false); m_latestVersionLabel->setVisible(false);
} }
this->setInstallStatus(UpdateProgress(0, "Starting install")); this->setInstallStatus(UpdateProgress(0, "Starting install"));

View file

@ -33,7 +33,8 @@ protected:
IconButtonSprite* m_installBtnSpr; IconButtonSprite* m_installBtnSpr;
CCMenuItemSpriteExtra* m_installBtn; CCMenuItemSpriteExtra* m_installBtn;
CCMenuItemSpriteExtra* m_infoBtn; CCMenuItemSpriteExtra* m_infoBtn;
CCLabelBMFont* m_updateVersionLabel = nullptr; CCLabelBMFont* m_latestVersionLabel = nullptr;
CCLabelBMFont* m_minorVersionLabel = nullptr;
MDTextArea* m_detailsArea; MDTextArea* m_detailsArea;
MDTextArea* m_changelogArea = nullptr; MDTextArea* m_changelogArea = nullptr;
Scrollbar* m_scrollbar; Scrollbar* m_scrollbar;

View file

@ -260,19 +260,26 @@ bool ModCell::init(
m_menu->addChild(m_unresolvedExMark); m_menu->addChild(m_unresolvedExMark);
if (m_mod->wasSuccesfullyLoaded()) { if (m_mod->wasSuccesfullyLoaded()) {
auto indexItem = Index::get()->getItem(
mod->getModInfo().id(), auto latestIndexItem = Index::get()->getMajorItem(
ComparableVersionInfo(mod->getModInfo().version(), VersionCompare::More) mod->getModInfo().id()
); );
if (indexItem) { if (latestIndexItem && Index::get()->isUpdateAvailable(latestIndexItem)) {
viewSpr->updateBGImage("GE_button_01.png"_spr); viewSpr->updateBGImage("GE_button_01.png"_spr);
auto updateIcon = CCSprite::createWithSpriteFrameName("updates-available.png"_spr); auto minorIndexItem = Index::get()->getItem(
updateIcon->setPosition(viewSpr->getContentSize() - CCSize { 2.f, 2.f }); mod->getModInfo().id(),
updateIcon->setZOrder(99); ComparableVersionInfo(mod->getModInfo().version(), VersionCompare::MoreEq)
updateIcon->setScale(.5f); );
viewSpr->addChild(updateIcon);
if (latestIndexItem->info.version().getMajor() > minorIndexItem->info.version().getMajor()) {
auto updateIcon = CCSprite::createWithSpriteFrameName("updates-available.png"_spr);
updateIcon->setPosition(viewSpr->getContentSize() - CCSize { 2.f, 2.f });
updateIcon->setZOrder(99);
updateIcon->setScale(.5f);
viewSpr->addChild(updateIcon);
}
} }
} }