mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-27 01:45:35 -05:00
some problems rework
This commit is contained in:
parent
a79592ace2
commit
5c457251d4
8 changed files with 54 additions and 26 deletions
|
@ -65,6 +65,10 @@ struct CustomMenuLayer : Modify<CustomMenuLayer, MenuLayer> {
|
||||||
|
|
||||||
m_fields->m_menuDisabled = Loader::get()->getLaunchFlag("disable-custom-menu");
|
m_fields->m_menuDisabled = Loader::get()->getLaunchFlag("disable-custom-menu");
|
||||||
|
|
||||||
|
std::stringstream ss;
|
||||||
|
crashlog::printMods(ss);
|
||||||
|
log::debug("Test {}", ss.str());
|
||||||
|
|
||||||
// add geode button
|
// add geode button
|
||||||
if (!m_fields->m_menuDisabled) {
|
if (!m_fields->m_menuDisabled) {
|
||||||
m_fields->m_geodeButton = CircleButtonSprite::createWithSpriteFrameName(
|
m_fields->m_geodeButton = CircleButtonSprite::createWithSpriteFrameName(
|
||||||
|
|
|
@ -41,7 +41,11 @@ void crashlog::printMods(std::stringstream& stream) {
|
||||||
using namespace std::string_view_literals;
|
using namespace std::string_view_literals;
|
||||||
for (auto& mod : mods) {
|
for (auto& mod : mods) {
|
||||||
stream << fmt::format("{} | [{}] {}\n",
|
stream << fmt::format("{} | [{}] {}\n",
|
||||||
mod->isEnabled() ? "x"sv : mod->shouldLoad() ? "~"sv : ModImpl::getImpl(mod)->isCurrentlyLoading() ? "o"sv : " "sv,
|
mod->isEnabled() ? "x"sv :
|
||||||
|
ModImpl::getImpl(mod)->hasProblems() ? "!"sv : // thank you for this bug report
|
||||||
|
mod->shouldLoad() ? "~"sv :
|
||||||
|
ModImpl::getImpl(mod)->isCurrentlyLoading() ? "o"sv :
|
||||||
|
" "sv,
|
||||||
mod->getVersion().toString(), mod->getID()
|
mod->getVersion().toString(), mod->getID()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,6 +246,14 @@ void Loader::Impl::updateModResources(Mod* mod) {
|
||||||
log::popNest();
|
log::popNest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Loader::Impl::addProblem(LoadProblem const& problem) {
|
||||||
|
if (std::holds_alternative<Mod*>(problem.cause)) {
|
||||||
|
auto mod = std::get<Mod*>(problem.cause);
|
||||||
|
ModImpl::getImpl(mod)->m_problems.push_back(problem);
|
||||||
|
}
|
||||||
|
m_problems.push_back(problem);
|
||||||
|
}
|
||||||
|
|
||||||
// Dependencies and refreshing
|
// Dependencies and refreshing
|
||||||
|
|
||||||
void Loader::Impl::queueMods(std::vector<ModMetadata>& modQueue) {
|
void Loader::Impl::queueMods(std::vector<ModMetadata>& modQueue) {
|
||||||
|
@ -262,7 +270,7 @@ void Loader::Impl::queueMods(std::vector<ModMetadata>& modQueue) {
|
||||||
|
|
||||||
auto res = ModMetadata::createFromGeodeFile(entry.path());
|
auto res = ModMetadata::createFromGeodeFile(entry.path());
|
||||||
if (!res) {
|
if (!res) {
|
||||||
m_problems.push_back({
|
this->addProblem({
|
||||||
LoadProblem::Type::InvalidFile,
|
LoadProblem::Type::InvalidFile,
|
||||||
entry.path(),
|
entry.path(),
|
||||||
res.unwrapErr()
|
res.unwrapErr()
|
||||||
|
@ -280,7 +288,7 @@ void Loader::Impl::queueMods(std::vector<ModMetadata>& modQueue) {
|
||||||
if (std::find_if(modQueue.begin(), modQueue.end(), [&](auto& item) {
|
if (std::find_if(modQueue.begin(), modQueue.end(), [&](auto& item) {
|
||||||
return modMetadata.getID() == item.getID();
|
return modMetadata.getID() == item.getID();
|
||||||
}) != modQueue.end()) {
|
}) != modQueue.end()) {
|
||||||
m_problems.push_back({
|
this->addProblem({
|
||||||
LoadProblem::Type::Duplicate,
|
LoadProblem::Type::Duplicate,
|
||||||
modMetadata,
|
modMetadata,
|
||||||
"A mod with the same ID is already present."
|
"A mod with the same ID is already present."
|
||||||
|
@ -317,7 +325,7 @@ void Loader::Impl::populateModList(std::vector<ModMetadata>& modQueue) {
|
||||||
|
|
||||||
auto res = mod->m_impl->setup();
|
auto res = mod->m_impl->setup();
|
||||||
if (!res) {
|
if (!res) {
|
||||||
m_problems.push_back({
|
this->addProblem({
|
||||||
LoadProblem::Type::SetupFailed,
|
LoadProblem::Type::SetupFailed,
|
||||||
mod,
|
mod,
|
||||||
res.unwrapErr()
|
res.unwrapErr()
|
||||||
|
@ -406,7 +414,7 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
|
||||||
log::debug("Load");
|
log::debug("Load");
|
||||||
auto res = node->m_impl->loadBinary();
|
auto res = node->m_impl->loadBinary();
|
||||||
if (!res) {
|
if (!res) {
|
||||||
m_problems.push_back({
|
this->addProblem({
|
||||||
LoadProblem::Type::LoadFailed,
|
LoadProblem::Type::LoadFailed,
|
||||||
node,
|
node,
|
||||||
res.unwrapErr()
|
res.unwrapErr()
|
||||||
|
@ -427,7 +435,7 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
|
||||||
{ // version checking
|
{ // version checking
|
||||||
auto res = node->getMetadata().checkGameVersion();
|
auto res = node->getMetadata().checkGameVersion();
|
||||||
if (!res) {
|
if (!res) {
|
||||||
m_problems.push_back({
|
this->addProblem({
|
||||||
LoadProblem::Type::UnsupportedVersion,
|
LoadProblem::Type::UnsupportedVersion,
|
||||||
node,
|
node,
|
||||||
res.unwrapErr()
|
res.unwrapErr()
|
||||||
|
@ -439,7 +447,7 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->isModVersionSupported(node->getMetadata().getGeodeVersion())) {
|
if (!this->isModVersionSupported(node->getMetadata().getGeodeVersion())) {
|
||||||
m_problems.push_back({
|
this->addProblem({
|
||||||
LoadProblem::Type::UnsupportedGeodeVersion,
|
LoadProblem::Type::UnsupportedGeodeVersion,
|
||||||
node,
|
node,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
|
@ -458,7 +466,7 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
|
||||||
if (early) {
|
if (early) {
|
||||||
auto res = unzipFunction();
|
auto res = unzipFunction();
|
||||||
if (!res) {
|
if (!res) {
|
||||||
m_problems.push_back({
|
this->addProblem({
|
||||||
LoadProblem::Type::UnzipFailed,
|
LoadProblem::Type::UnzipFailed,
|
||||||
node,
|
node,
|
||||||
res.unwrapErr()
|
res.unwrapErr()
|
||||||
|
@ -480,7 +488,7 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
|
||||||
auto prevNest = log::saveNest();
|
auto prevNest = log::saveNest();
|
||||||
log::loadNest(nest);
|
log::loadNest(nest);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
m_problems.push_back({
|
this->addProblem({
|
||||||
LoadProblem::Type::UnzipFailed,
|
LoadProblem::Type::UnzipFailed,
|
||||||
node,
|
node,
|
||||||
res.unwrapErr()
|
res.unwrapErr()
|
||||||
|
@ -512,7 +520,7 @@ void Loader::Impl::findProblems() {
|
||||||
continue;
|
continue;
|
||||||
switch(dep.importance) {
|
switch(dep.importance) {
|
||||||
case ModMetadata::Dependency::Importance::Suggested:
|
case ModMetadata::Dependency::Importance::Suggested:
|
||||||
m_problems.push_back({
|
this->addProblem({
|
||||||
LoadProblem::Type::Suggestion,
|
LoadProblem::Type::Suggestion,
|
||||||
mod,
|
mod,
|
||||||
fmt::format("{} {}", dep.id, dep.version.toString())
|
fmt::format("{} {}", dep.id, dep.version.toString())
|
||||||
|
@ -520,7 +528,7 @@ void Loader::Impl::findProblems() {
|
||||||
log::info("{} suggests {} {}", id, dep.id, dep.version);
|
log::info("{} suggests {} {}", id, dep.id, dep.version);
|
||||||
break;
|
break;
|
||||||
case ModMetadata::Dependency::Importance::Recommended:
|
case ModMetadata::Dependency::Importance::Recommended:
|
||||||
m_problems.push_back({
|
this->addProblem({
|
||||||
LoadProblem::Type::Recommendation,
|
LoadProblem::Type::Recommendation,
|
||||||
mod,
|
mod,
|
||||||
fmt::format("{} {}", dep.id, dep.version.toString())
|
fmt::format("{} {}", dep.id, dep.version.toString())
|
||||||
|
@ -528,7 +536,7 @@ void Loader::Impl::findProblems() {
|
||||||
log::warn("{} recommends {} {}", id, dep.id, dep.version);
|
log::warn("{} recommends {} {}", id, dep.id, dep.version);
|
||||||
break;
|
break;
|
||||||
case ModMetadata::Dependency::Importance::Required:
|
case ModMetadata::Dependency::Importance::Required:
|
||||||
m_problems.push_back({
|
this->addProblem({
|
||||||
LoadProblem::Type::MissingDependency,
|
LoadProblem::Type::MissingDependency,
|
||||||
mod,
|
mod,
|
||||||
fmt::format("{} {}", dep.id, dep.version.toString())
|
fmt::format("{} {}", dep.id, dep.version.toString())
|
||||||
|
@ -543,7 +551,7 @@ void Loader::Impl::findProblems() {
|
||||||
continue;
|
continue;
|
||||||
switch(dep.importance) {
|
switch(dep.importance) {
|
||||||
case ModMetadata::Incompatibility::Importance::Conflicting:
|
case ModMetadata::Incompatibility::Importance::Conflicting:
|
||||||
m_problems.push_back({
|
this->addProblem({
|
||||||
LoadProblem::Type::Conflict,
|
LoadProblem::Type::Conflict,
|
||||||
mod,
|
mod,
|
||||||
fmt::format("{} {}", dep.id, dep.version.toString())
|
fmt::format("{} {}", dep.id, dep.version.toString())
|
||||||
|
@ -551,7 +559,7 @@ void Loader::Impl::findProblems() {
|
||||||
log::warn("{} conflicts with {} {}", id, dep.id, dep.version);
|
log::warn("{} conflicts with {} {}", id, dep.id, dep.version);
|
||||||
break;
|
break;
|
||||||
case ModMetadata::Incompatibility::Importance::Breaking:
|
case ModMetadata::Incompatibility::Importance::Breaking:
|
||||||
m_problems.push_back({
|
this->addProblem({
|
||||||
LoadProblem::Type::PresentIncompatibility,
|
LoadProblem::Type::PresentIncompatibility,
|
||||||
mod,
|
mod,
|
||||||
fmt::format("{} {}", dep.id, dep.version.toString())
|
fmt::format("{} {}", dep.id, dep.version.toString())
|
||||||
|
@ -571,7 +579,7 @@ void Loader::Impl::findProblems() {
|
||||||
std::holds_alternative<Mod*>(item.cause) &&
|
std::holds_alternative<Mod*>(item.cause) &&
|
||||||
std::get<Mod*>(item.cause) == myEpicMod;
|
std::get<Mod*>(item.cause) == myEpicMod;
|
||||||
})) {
|
})) {
|
||||||
m_problems.push_back({
|
this->addProblem({
|
||||||
LoadProblem::Type::Unknown,
|
LoadProblem::Type::Unknown,
|
||||||
mod,
|
mod,
|
||||||
""
|
""
|
||||||
|
|
|
@ -133,6 +133,8 @@ namespace geode {
|
||||||
Result<> setupInternalMod();
|
Result<> setupInternalMod();
|
||||||
|
|
||||||
bool userTriedToLoadDLLs() const;
|
bool userTriedToLoadDLLs() const;
|
||||||
|
|
||||||
|
void addProblem(LoadProblem const& problem);
|
||||||
};
|
};
|
||||||
|
|
||||||
class LoaderImpl : public Loader::Impl {
|
class LoaderImpl : public Loader::Impl {
|
||||||
|
|
|
@ -746,6 +746,19 @@ bool Mod::Impl::isCurrentlyLoading() const {
|
||||||
return m_isCurrentlyLoading;
|
return m_isCurrentlyLoading;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Mod::Impl::hasProblems() const {
|
||||||
|
for (auto const& item : m_problems) {
|
||||||
|
if (item.type <= LoadProblem::Type::Recommendation)
|
||||||
|
continue;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<LoadProblem> Mod::Impl::getProblems() const {
|
||||||
|
return m_problems;
|
||||||
|
}
|
||||||
|
|
||||||
static Result<ModMetadata> getModImplInfo() {
|
static Result<ModMetadata> getModImplInfo() {
|
||||||
std::string error;
|
std::string error;
|
||||||
auto res = matjson::parse(LOADER_MOD_JSON, error);
|
auto res = matjson::parse(LOADER_MOD_JSON, error);
|
||||||
|
|
|
@ -68,6 +68,8 @@ namespace geode {
|
||||||
|
|
||||||
ModRequestedAction m_requestedAction = ModRequestedAction::None;
|
ModRequestedAction m_requestedAction = ModRequestedAction::None;
|
||||||
|
|
||||||
|
std::vector<LoadProblem> m_problems;
|
||||||
|
|
||||||
Impl(Mod* self, ModMetadata const& metadata);
|
Impl(Mod* self, ModMetadata const& metadata);
|
||||||
~Impl();
|
~Impl();
|
||||||
|
|
||||||
|
@ -150,6 +152,9 @@ namespace geode {
|
||||||
bool isLoggingEnabled() const;
|
bool isLoggingEnabled() const;
|
||||||
void setLoggingEnabled(bool enabled);
|
void setLoggingEnabled(bool enabled);
|
||||||
|
|
||||||
|
std::vector<LoadProblem> getProblems() const;
|
||||||
|
|
||||||
|
bool hasProblems() const;
|
||||||
bool shouldLoad() const;
|
bool shouldLoad() const;
|
||||||
bool isCurrentlyLoading() const;
|
bool isCurrentlyLoading() const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -274,15 +274,7 @@ void ModCell::updateState() {
|
||||||
m_enableToggle->m_onButton->setOpacity(!toggleable ? 100 : 255);
|
m_enableToggle->m_onButton->setOpacity(!toggleable ? 100 : 255);
|
||||||
m_enableToggle->m_onButton->setColor(!toggleable ? cc3x(155) : cc3x(255));
|
m_enableToggle->m_onButton->setColor(!toggleable ? cc3x(155) : cc3x(255));
|
||||||
}
|
}
|
||||||
bool hasProblems = false;
|
bool hasProblems = ModImpl::getImpl(m_mod)->hasProblems();
|
||||||
for (auto const& item : Loader::get()->getProblems()) {
|
|
||||||
if (!std::holds_alternative<Mod*>(item.cause) ||
|
|
||||||
std::get<Mod*>(item.cause) != m_mod ||
|
|
||||||
item.type <= LoadProblem::Type::Recommendation)
|
|
||||||
continue;
|
|
||||||
hasProblems = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
m_unresolvedExMark->setVisible(hasProblems);
|
m_unresolvedExMark->setVisible(hasProblems);
|
||||||
|
|
||||||
this->updateCellLayout();
|
this->updateCellLayout();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "ProblemsListPopup.hpp"
|
#include "ProblemsListPopup.hpp"
|
||||||
#include "ProblemsListCell.hpp"
|
#include "ProblemsListCell.hpp"
|
||||||
|
#include "../../../loader/ModImpl.hpp"
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ CCArray* ProblemsListPopup::createCells(Mod* scrollTo, float& scrollValue) {
|
||||||
std::vector<ProblemsListCell*> middle;
|
std::vector<ProblemsListCell*> middle;
|
||||||
std::vector<ProblemsListCell*> bottom;
|
std::vector<ProblemsListCell*> bottom;
|
||||||
|
|
||||||
for (auto const& problem : Loader::get()->getProblems()) {
|
for (auto const& problem : scrollTo ? ModImpl::getImpl(scrollTo)->getProblems() : Loader::get()->getProblems()) {
|
||||||
switch (problem.type) {
|
switch (problem.type) {
|
||||||
case geode::LoadProblem::Type::Suggestion:
|
case geode::LoadProblem::Type::Suggestion:
|
||||||
bottom.push_back(ProblemsListCell::create(problem, this, this->getCellSize()));
|
bottom.push_back(ProblemsListCell::create(problem, this, this->getCellSize()));
|
||||||
|
|
Loading…
Reference in a new issue