mirror of
https://github.com/geode-sdk/geode.git
synced 2025-02-17 00:30:26 -05:00
always open up installed version of mod popup if possible
This commit is contained in:
parent
560b42c8de
commit
e13091115b
3 changed files with 20 additions and 1 deletions
|
@ -231,7 +231,8 @@ ModItem* ModItem::create(ModSource&& source) {
|
|||
}
|
||||
|
||||
void ModItem::onView(CCObject*) {
|
||||
auto popup = ModPopup::create(ModSource(m_source));
|
||||
// Always open up the popup for the installed mod page if that is possible
|
||||
auto popup = ModPopup::create(m_source.tryConvertToMod());
|
||||
popup->onUpdateParentState([this]() {
|
||||
this->updateState();
|
||||
});
|
||||
|
|
|
@ -59,6 +59,20 @@ bool ModSource::wantsRestart() const {
|
|||
}, m_value);
|
||||
}
|
||||
|
||||
ModSource ModSource::tryConvertToMod() const {
|
||||
return std::visit(makeVisitor {
|
||||
[](Mod* mod) {
|
||||
return ModSource(mod);
|
||||
},
|
||||
[](server::ServerModMetadata const& metadata) {
|
||||
if (auto mod = Loader::get()->getInstalledMod(metadata.id)) {
|
||||
return ModSource(mod);
|
||||
}
|
||||
return ModSource(server::ServerModMetadata(metadata));
|
||||
}
|
||||
}, m_value);
|
||||
}
|
||||
|
||||
Mod* ModSource::asMod() const {
|
||||
auto mod = std::get_if<Mod*>(&m_value);
|
||||
return mod ? *mod : nullptr;
|
||||
|
|
|
@ -24,6 +24,10 @@ public:
|
|||
return std::visit(func, m_value);
|
||||
}
|
||||
|
||||
// Returns a new ModSource that is either a copy of the current source or
|
||||
// an installed version of a server mod
|
||||
ModSource tryConvertToMod() const;
|
||||
|
||||
Mod* asMod() const;
|
||||
server::ServerModMetadata const* asServer() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue