mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-30 03:15:38 -05:00
Compare commits
5 commits
c0514b1915
...
dd95b87353
Author | SHA1 | Date | |
---|---|---|---|
|
dd95b87353 | ||
|
f90461fbb7 | ||
|
555ebe3eb3 | ||
|
07d92a34ad | ||
|
61b80a0114 |
10 changed files with 63 additions and 33 deletions
|
@ -114,7 +114,6 @@
|
|||
namespace geode {
|
||||
class PlatformID {
|
||||
public:
|
||||
// todo in v4: make these flags and add archless Mac and Android as well as Desktop and Mobile and remove Linux
|
||||
enum {
|
||||
Unknown = 0b000000,
|
||||
Windows = 0b000001,
|
||||
|
@ -184,11 +183,11 @@ namespace geode {
|
|||
/**
|
||||
* Returns the list of platforms covered by this string name. For
|
||||
* example, "android" would return both Android32 and Android64
|
||||
* todo in v4: deprecate this as the flagged version deals with this
|
||||
* todo in v5: deprecate this as the flagged version deals with this
|
||||
*/
|
||||
static GEODE_DLL std::vector<PlatformID> getCovered(std::string_view str);
|
||||
|
||||
// todo in v4: this does not need to be constexpr in the header. dllexport it
|
||||
// todo in v5: this does not need to be constexpr in the header. dllexport it
|
||||
static constexpr char const* toString(Type lp) {
|
||||
switch (lp) {
|
||||
case Unknown: return "Unknown";
|
||||
|
@ -203,7 +202,7 @@ namespace geode {
|
|||
return "Undefined";
|
||||
}
|
||||
|
||||
// todo in v4: this does not need to be constexpr in the header. dllexport it
|
||||
// todo in v5: this does not need to be constexpr in the header. dllexport it
|
||||
static constexpr char const* toShortString(Type lp, bool ignoreArch = false) {
|
||||
switch (lp) {
|
||||
case Unknown: return "unknown";
|
||||
|
|
|
@ -13,12 +13,6 @@ namespace geode {
|
|||
virtual void updateColor(cocos2d::ccColor4B const& color) {}
|
||||
};
|
||||
|
||||
// todo in v4: maybe use events over the delegate?
|
||||
// thing with events is that if you just filter via ColorPickPopup* it
|
||||
// won't work unless you automatically detach the filter when closing the
|
||||
// popup (otherwise opening another popup really quickly will just be
|
||||
// allocated into the same memory and now the old filter is catching the
|
||||
// new popup too)
|
||||
class GEODE_DLL ColorPickPopup :
|
||||
public Popup<cocos2d::ccColor4B const&, bool>,
|
||||
public cocos2d::extension::ColorPickerDelegate,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "CopyButtonSetting.hpp"
|
||||
#include <Geode/loader/Mod.hpp>
|
||||
#include <Geode/ui/Notification.hpp>
|
||||
|
||||
$on_mod(Loaded) {
|
||||
(void)Mod::get()->registerCustomSettingType("copy-mods", &CopyButtonSetting::parse);
|
||||
|
|
|
@ -172,16 +172,6 @@ ModSettingsManager::ModSettingsManager(ModMetadata const& metadata)
|
|||
auto root = checkJson(json, "setting");
|
||||
root.needs("type").into(setting.type);
|
||||
if (root) {
|
||||
if (setting.type == "custom") {
|
||||
log::warn(
|
||||
"Setting \"{}\" in mod {} has the old \"custom\" type - "
|
||||
"this type has been deprecated and will be removed in Geode v4.0.0. "
|
||||
"Use the new \"custom:type-name-here\" syntax for defining custom "
|
||||
"setting types - see more in "
|
||||
"https://docs.geode-sdk.org/mods/settings/#custom-settings",
|
||||
key, m_impl->modID
|
||||
);
|
||||
}
|
||||
m_impl->settings.emplace(key, setting);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
#include "ui/mods/sources/ModListSource.hpp"
|
||||
#include <loader/LoaderImpl.hpp>
|
||||
|
||||
static ModListDisplay MOD_LIST_DISPLAY = ModListDisplay::SmallList;
|
||||
|
||||
bool ModsStatusNode::init() {
|
||||
if (!CCNode::init())
|
||||
return false;
|
||||
|
@ -355,6 +353,8 @@ bool ModsLayer::init() {
|
|||
}
|
||||
}
|
||||
|
||||
m_modListDisplay = Mod::get()->getSavedValue<ModListDisplay>("mod-list-display-type");
|
||||
|
||||
auto backMenu = CCMenu::create();
|
||||
backMenu->setID("back-menu");
|
||||
backMenu->setContentWidth(100.f);
|
||||
|
@ -651,7 +651,7 @@ void ModsLayer::gotoTab(ModListSource* src) {
|
|||
m_currentSource = src;
|
||||
|
||||
// Update the state of the current list
|
||||
m_lists.at(m_currentSource)->updateDisplay(MOD_LIST_DISPLAY);
|
||||
m_lists.at(m_currentSource)->updateDisplay(m_modListDisplay);
|
||||
m_lists.at(m_currentSource)->activateSearch(m_showSearch);
|
||||
m_lists.at(m_currentSource)->updateState();
|
||||
}
|
||||
|
@ -713,7 +713,7 @@ void ModsLayer::updateState() {
|
|||
// Update display button
|
||||
for (auto btn : m_displayBtns) {
|
||||
static_cast<GeodeSquareSprite*>(btn->getNormalImage())->setState(
|
||||
static_cast<ModListDisplay>(btn->getTag()) == MOD_LIST_DISPLAY
|
||||
static_cast<ModListDisplay>(btn->getTag()) == m_modListDisplay
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -746,10 +746,12 @@ void ModsLayer::onGoToPage(CCObject*) {
|
|||
popup->show();
|
||||
}
|
||||
void ModsLayer::onDisplay(CCObject* sender) {
|
||||
MOD_LIST_DISPLAY = static_cast<ModListDisplay>(sender->getTag());
|
||||
m_modListDisplay = static_cast<ModListDisplay>(sender->getTag());
|
||||
Mod::get()->setSavedValue("mod-list-display-type", m_modListDisplay);
|
||||
|
||||
// Make sure to avoid a crash
|
||||
if (m_currentSource) {
|
||||
m_lists.at(m_currentSource)->updateDisplay(MOD_LIST_DISPLAY);
|
||||
m_lists.at(m_currentSource)->updateDisplay(m_modListDisplay);
|
||||
m_lists.at(m_currentSource)->reloadPage();
|
||||
}
|
||||
this->updateState();
|
||||
|
|
|
@ -67,6 +67,7 @@ protected:
|
|||
EventListener<UpdateModListStateFilter> m_updateStateListener;
|
||||
bool m_showSearch = true;
|
||||
std::vector<CCMenuItemSpriteExtra*> m_displayBtns;
|
||||
ModListDisplay m_modListDisplay;
|
||||
|
||||
bool init();
|
||||
|
||||
|
|
|
@ -18,6 +18,39 @@ enum class ModListDisplay {
|
|||
Grid,
|
||||
};
|
||||
|
||||
// i made it this way just in case someone wanted to add to the enum in the future
|
||||
// mat is allowed to judge
|
||||
template<>
|
||||
struct matjson::Serialize<ModListDisplay> {
|
||||
static Result<ModListDisplay> fromJson(matjson::Value const& value) {
|
||||
auto saved = GEODE_UNWRAP(value.asString());
|
||||
if (saved == "small-list") {
|
||||
return Ok(ModListDisplay::SmallList);
|
||||
} else if (saved == "big-list") {
|
||||
return Ok(ModListDisplay::BigList);
|
||||
} else if (saved == "grid") {
|
||||
return Ok(ModListDisplay::Grid);
|
||||
}
|
||||
|
||||
return Err("unknown display type");
|
||||
}
|
||||
|
||||
static matjson::Value toJson(ModListDisplay const& value) {
|
||||
switch (value) {
|
||||
default:
|
||||
case ModListDisplay::SmallList:
|
||||
return "small-list";
|
||||
break;
|
||||
case ModListDisplay::BigList:
|
||||
return "big-list";
|
||||
break;
|
||||
case ModListDisplay::Grid:
|
||||
return "grid";
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class ModItem : public CCNode {
|
||||
protected:
|
||||
ModSource m_source;
|
||||
|
|
|
@ -15,9 +15,9 @@ static size_t getDisplayPageSize(ModListSource* src, ModListDisplay display) {
|
|||
|
||||
$execute {
|
||||
listenForSettingChanges("infinite-local-mods-list", [](bool value) {
|
||||
InstalledModListSource::get(InstalledModListType::All)->reset();
|
||||
InstalledModListSource::get(InstalledModListType::OnlyErrors)->reset();
|
||||
InstalledModListSource::get(InstalledModListType::OnlyOutdated)->reset();
|
||||
InstalledModListSource::get(InstalledModListType::All)->clearCache();
|
||||
InstalledModListSource::get(InstalledModListType::OnlyErrors)->clearCache();
|
||||
InstalledModListSource::get(InstalledModListType::OnlyOutdated)->clearCache();
|
||||
// Updates is technically a server mod list :-) So I left it out here
|
||||
});
|
||||
}
|
||||
|
@ -601,6 +601,16 @@ void ModList::updateDisplay(ModListDisplay display) {
|
|||
);
|
||||
}
|
||||
|
||||
// Make sure list isn't too small
|
||||
// NOTE: Do NOT call `updateLayout` on m_list, it'll undo this!
|
||||
if (m_list->m_contentLayer->getContentHeight() < m_list->getContentHeight()) {
|
||||
auto diff = m_list->getContentHeight() - m_list->m_contentLayer->getContentHeight();
|
||||
m_list->m_contentLayer->setContentHeight(m_list->getContentHeight());
|
||||
for (auto child : CCArrayExt<CCNode*>(m_list->m_contentLayer->getChildren())) {
|
||||
child->setPositionY(child->getPositionY() + diff);
|
||||
}
|
||||
}
|
||||
|
||||
// Preserve relative scroll position
|
||||
m_list->m_contentLayer->setPositionY((
|
||||
m_list->m_contentLayer->getContentHeight() - m_list->getContentHeight()
|
||||
|
|
|
@ -64,7 +64,7 @@ std::optional<size_t> ModListSource::getItemCount() const {
|
|||
void ModListSource::setPageSize(size_t size) {
|
||||
if (m_pageSize != size) {
|
||||
m_pageSize = size;
|
||||
this->reset();
|
||||
this->clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
using namespace geode::prelude;
|
||||
|
||||
PlatformID PlatformID::from(const char* str) {
|
||||
// todo in v4: this should just be
|
||||
// todo in v5: this should just be
|
||||
// "win" -> Windows
|
||||
// "mac", "mac-intel", "mac-arm" -> Mac
|
||||
// "ios" -> iOS
|
||||
|
@ -38,7 +38,7 @@ PlatformID PlatformID::from(const char* str) {
|
|||
}
|
||||
|
||||
bool PlatformID::coveredBy(const char* str, PlatformID t) {
|
||||
// todo in v4: this is ridiculously inefficient currently - in v4 just use a flag check!
|
||||
// todo in v5: this is ridiculously inefficient currently - in v5 just use a flag check!
|
||||
return ranges::contains(getCovered(str), t);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue