mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-23 07:57:51 -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");
|
||||
|
||||
std::stringstream ss;
|
||||
crashlog::printMods(ss);
|
||||
log::debug("Test {}", ss.str());
|
||||
|
||||
// add geode button
|
||||
if (!m_fields->m_menuDisabled) {
|
||||
m_fields->m_geodeButton = CircleButtonSprite::createWithSpriteFrameName(
|
||||
|
|
|
@ -41,7 +41,11 @@ void crashlog::printMods(std::stringstream& stream) {
|
|||
using namespace std::string_view_literals;
|
||||
for (auto& mod : mods) {
|
||||
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()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -246,6 +246,14 @@ void Loader::Impl::updateModResources(Mod* mod) {
|
|||
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
|
||||
|
||||
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());
|
||||
if (!res) {
|
||||
m_problems.push_back({
|
||||
this->addProblem({
|
||||
LoadProblem::Type::InvalidFile,
|
||||
entry.path(),
|
||||
res.unwrapErr()
|
||||
|
@ -280,7 +288,7 @@ void Loader::Impl::queueMods(std::vector<ModMetadata>& modQueue) {
|
|||
if (std::find_if(modQueue.begin(), modQueue.end(), [&](auto& item) {
|
||||
return modMetadata.getID() == item.getID();
|
||||
}) != modQueue.end()) {
|
||||
m_problems.push_back({
|
||||
this->addProblem({
|
||||
LoadProblem::Type::Duplicate,
|
||||
modMetadata,
|
||||
"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();
|
||||
if (!res) {
|
||||
m_problems.push_back({
|
||||
this->addProblem({
|
||||
LoadProblem::Type::SetupFailed,
|
||||
mod,
|
||||
res.unwrapErr()
|
||||
|
@ -406,7 +414,7 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
|
|||
log::debug("Load");
|
||||
auto res = node->m_impl->loadBinary();
|
||||
if (!res) {
|
||||
m_problems.push_back({
|
||||
this->addProblem({
|
||||
LoadProblem::Type::LoadFailed,
|
||||
node,
|
||||
res.unwrapErr()
|
||||
|
@ -427,7 +435,7 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
|
|||
{ // version checking
|
||||
auto res = node->getMetadata().checkGameVersion();
|
||||
if (!res) {
|
||||
m_problems.push_back({
|
||||
this->addProblem({
|
||||
LoadProblem::Type::UnsupportedVersion,
|
||||
node,
|
||||
res.unwrapErr()
|
||||
|
@ -439,7 +447,7 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
|
|||
}
|
||||
|
||||
if (!this->isModVersionSupported(node->getMetadata().getGeodeVersion())) {
|
||||
m_problems.push_back({
|
||||
this->addProblem({
|
||||
LoadProblem::Type::UnsupportedGeodeVersion,
|
||||
node,
|
||||
fmt::format(
|
||||
|
@ -458,7 +466,7 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
|
|||
if (early) {
|
||||
auto res = unzipFunction();
|
||||
if (!res) {
|
||||
m_problems.push_back({
|
||||
this->addProblem({
|
||||
LoadProblem::Type::UnzipFailed,
|
||||
node,
|
||||
res.unwrapErr()
|
||||
|
@ -480,7 +488,7 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
|
|||
auto prevNest = log::saveNest();
|
||||
log::loadNest(nest);
|
||||
if (!res) {
|
||||
m_problems.push_back({
|
||||
this->addProblem({
|
||||
LoadProblem::Type::UnzipFailed,
|
||||
node,
|
||||
res.unwrapErr()
|
||||
|
@ -512,7 +520,7 @@ void Loader::Impl::findProblems() {
|
|||
continue;
|
||||
switch(dep.importance) {
|
||||
case ModMetadata::Dependency::Importance::Suggested:
|
||||
m_problems.push_back({
|
||||
this->addProblem({
|
||||
LoadProblem::Type::Suggestion,
|
||||
mod,
|
||||
fmt::format("{} {}", dep.id, dep.version.toString())
|
||||
|
@ -520,7 +528,7 @@ void Loader::Impl::findProblems() {
|
|||
log::info("{} suggests {} {}", id, dep.id, dep.version);
|
||||
break;
|
||||
case ModMetadata::Dependency::Importance::Recommended:
|
||||
m_problems.push_back({
|
||||
this->addProblem({
|
||||
LoadProblem::Type::Recommendation,
|
||||
mod,
|
||||
fmt::format("{} {}", dep.id, dep.version.toString())
|
||||
|
@ -528,7 +536,7 @@ void Loader::Impl::findProblems() {
|
|||
log::warn("{} recommends {} {}", id, dep.id, dep.version);
|
||||
break;
|
||||
case ModMetadata::Dependency::Importance::Required:
|
||||
m_problems.push_back({
|
||||
this->addProblem({
|
||||
LoadProblem::Type::MissingDependency,
|
||||
mod,
|
||||
fmt::format("{} {}", dep.id, dep.version.toString())
|
||||
|
@ -543,7 +551,7 @@ void Loader::Impl::findProblems() {
|
|||
continue;
|
||||
switch(dep.importance) {
|
||||
case ModMetadata::Incompatibility::Importance::Conflicting:
|
||||
m_problems.push_back({
|
||||
this->addProblem({
|
||||
LoadProblem::Type::Conflict,
|
||||
mod,
|
||||
fmt::format("{} {}", dep.id, dep.version.toString())
|
||||
|
@ -551,7 +559,7 @@ void Loader::Impl::findProblems() {
|
|||
log::warn("{} conflicts with {} {}", id, dep.id, dep.version);
|
||||
break;
|
||||
case ModMetadata::Incompatibility::Importance::Breaking:
|
||||
m_problems.push_back({
|
||||
this->addProblem({
|
||||
LoadProblem::Type::PresentIncompatibility,
|
||||
mod,
|
||||
fmt::format("{} {}", dep.id, dep.version.toString())
|
||||
|
@ -571,7 +579,7 @@ void Loader::Impl::findProblems() {
|
|||
std::holds_alternative<Mod*>(item.cause) &&
|
||||
std::get<Mod*>(item.cause) == myEpicMod;
|
||||
})) {
|
||||
m_problems.push_back({
|
||||
this->addProblem({
|
||||
LoadProblem::Type::Unknown,
|
||||
mod,
|
||||
""
|
||||
|
|
|
@ -133,6 +133,8 @@ namespace geode {
|
|||
Result<> setupInternalMod();
|
||||
|
||||
bool userTriedToLoadDLLs() const;
|
||||
|
||||
void addProblem(LoadProblem const& problem);
|
||||
};
|
||||
|
||||
class LoaderImpl : public Loader::Impl {
|
||||
|
|
|
@ -746,6 +746,19 @@ bool Mod::Impl::isCurrentlyLoading() const {
|
|||
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() {
|
||||
std::string error;
|
||||
auto res = matjson::parse(LOADER_MOD_JSON, error);
|
||||
|
|
|
@ -68,6 +68,8 @@ namespace geode {
|
|||
|
||||
ModRequestedAction m_requestedAction = ModRequestedAction::None;
|
||||
|
||||
std::vector<LoadProblem> m_problems;
|
||||
|
||||
Impl(Mod* self, ModMetadata const& metadata);
|
||||
~Impl();
|
||||
|
||||
|
@ -150,6 +152,9 @@ namespace geode {
|
|||
bool isLoggingEnabled() const;
|
||||
void setLoggingEnabled(bool enabled);
|
||||
|
||||
std::vector<LoadProblem> getProblems() const;
|
||||
|
||||
bool hasProblems() const;
|
||||
bool shouldLoad() const;
|
||||
bool isCurrentlyLoading() const;
|
||||
};
|
||||
|
|
|
@ -274,15 +274,7 @@ void ModCell::updateState() {
|
|||
m_enableToggle->m_onButton->setOpacity(!toggleable ? 100 : 255);
|
||||
m_enableToggle->m_onButton->setColor(!toggleable ? cc3x(155) : cc3x(255));
|
||||
}
|
||||
bool hasProblems = false;
|
||||
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;
|
||||
}
|
||||
bool hasProblems = ModImpl::getImpl(m_mod)->hasProblems();
|
||||
m_unresolvedExMark->setVisible(hasProblems);
|
||||
|
||||
this->updateCellLayout();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "ProblemsListPopup.hpp"
|
||||
#include "ProblemsListCell.hpp"
|
||||
|
||||
#include "../../../loader/ModImpl.hpp"
|
||||
#include <utility>
|
||||
#include <queue>
|
||||
|
||||
|
@ -39,7 +39,7 @@ CCArray* ProblemsListPopup::createCells(Mod* scrollTo, float& scrollValue) {
|
|||
std::vector<ProblemsListCell*> middle;
|
||||
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) {
|
||||
case geode::LoadProblem::Type::Suggestion:
|
||||
bottom.push_back(ProblemsListCell::create(problem, this, this->getCellSize()));
|
||||
|
|
Loading…
Reference in a new issue