Compare commits

..

1 commit

Author SHA1 Message Date
Justin
b6220eeed4
Merge 4a40835f71 into 5592ef68c3 2024-11-15 13:05:29 -05:00
9 changed files with 160 additions and 156 deletions

View file

@ -1,25 +1,15 @@
# Geode Changelog
## v4.0.0-beta.1
## v4.0.0-alpha.2
* Button to manually install mods from files (e881dc5)
* Add `ModRequestedAction::Update` (e881dc5)
* Add `ModMetadata::checkGeodeVersion` and `ModMetadata::checkTargetVersions` (e881dc5)
* Add `geode::createModLogo` for creating a logo from a `.geode` package (e881dc5)
* Tags now use names provided by the server (893b03e)
* Add web support for multiple request headers with same name (#1150)
* Fix `Task::chain` using the wrong type in the impl (22a11b9)
* Fix installing mods not checking the current version (#1148)
* Fix searching for mods ignoring geode and gd version (#1153)
* Fix crash when checking tags (01807fe)
* Fix 'Outdated' label being visible while updating (6679a69)
* Fix log nesting issue (0e8d4c6)
* Remove forward compat message box as it confuses users (5592ef6)
* Fix crash on opening mod changelogs (9834cb2)
* Make `ColorPickPopup` pimpl (1a201e1)
* Fix lag issue in `ColorPickPopup` (3081164)
* Change return type of `ModSettingsManager::save` (da92090)
* Fix every misspelling of successfully (#1151)
* Allow building geode itself in debug mode (5645399)
## v4.0.0-alpha.1
* Support for the 2.2074 update

View file

@ -1 +1 @@
4.0.0-beta.1
4.0.0-alpha.1

View file

@ -72,27 +72,18 @@ elseif (GEODE_TARGET_PLATFORM STREQUAL "Win64")
target_link_libraries(${PROJECT_NAME} INTERFACE
${GEODE_LOADER_PATH}/include/link/win64/libcocos2d.lib
${GEODE_LOADER_PATH}/include/link/win64/libExtensions.lib
${GEODE_LOADER_PATH}/include/link/win64/ssl.lib
${GEODE_LOADER_PATH}/include/link/win64/crypto.lib
${GEODE_LOADER_PATH}/include/link/win64/nghttp2.lib
${GEODE_LOADER_PATH}/include/link/win64/ngtcp2.lib
${GEODE_LOADER_PATH}/include/link/win64/nghttp3.lib
${GEODE_LOADER_PATH}/include/link/win64/ngtcp2_crypto_boringssl.lib
${GEODE_LOADER_PATH}/include/link/win64/libcurl.lib
${GEODE_LOADER_PATH}/include/link/win64/glew32.lib
${GEODE_LOADER_PATH}/include/link/win64/fmod.lib
opengl32
)
if (PROJECT_IS_TOP_LEVEL AND CMAKE_BUILD_TYPE STREQUAL "Debug")
target_link_libraries(${PROJECT_NAME} INTERFACE
${GEODE_LOADER_PATH}/include/link/win64/gd-libcurl.lib
)
else()
target_link_libraries(${PROJECT_NAME} INTERFACE
${GEODE_LOADER_PATH}/include/link/win64/ssl.lib
${GEODE_LOADER_PATH}/include/link/win64/crypto.lib
${GEODE_LOADER_PATH}/include/link/win64/nghttp2.lib
${GEODE_LOADER_PATH}/include/link/win64/ngtcp2.lib
${GEODE_LOADER_PATH}/include/link/win64/nghttp3.lib
${GEODE_LOADER_PATH}/include/link/win64/ngtcp2_crypto_boringssl.lib
${GEODE_LOADER_PATH}/include/link/win64/libcurl.lib
)
endif()
# Windows links against .lib and not .dll
set(GEODE_OUTPUT_NAME "Geode")
set(GEODE_PLATFORM_BINARY "Geode.lib")

View file

@ -11,8 +11,6 @@
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) || defined(WIN64) || defined(_WIN64) || defined(__WIN64) && !defined(__CYGWIN__)
#define GEODE_WINDOWS(...) __VA_ARGS__
#define GEODE_DESKTOP(...) __VA_ARGS__
#define GEODE_MOBILE(...)
#define GEODE_IS_WINDOWS
#define GEODE_IS_DESKTOP
#define GEODE_PLATFORM_NAME "Windows"
@ -45,8 +43,6 @@
#define GEODE_INTEL_MAC(...)
#define GEODE_ARM_MAC(...)
#define GEODE_IOS(...) __VA_ARGS__
#define GEODE_DESKTOP(...)
#define GEODE_MOBILE(...) __VA_ARGS__
#define GEODE_IS_IOS
#define GEODE_IS_MOBILE
#define GEODE_PLATFORM_NAME "iOS"
@ -57,8 +53,6 @@
#else
#define GEODE_IOS(...)
#define GEODE_MACOS(...) __VA_ARGS__
#define GEODE_DESKTOP(...) __VA_ARGS__
#define GEODE_MOBILE(...)
#define GEODE_IS_MACOS
#define GEODE_IS_DESKTOP
#define GEODE_PLATFORM_EXTENSION ".dylib"
@ -90,8 +84,6 @@
// Android
#if defined(__ANDROID__)
#define GEODE_ANDROID(...) __VA_ARGS__
#define GEODE_MOBILE(...) __VA_ARGS__
#define GEODE_DESKTOP(...)
#define GEODE_IS_ANDROID
#define GEODE_IS_MOBILE
#define GEODE_CALL

View file

@ -13,7 +13,7 @@ namespace geode {
virtual void updateColor(cocos2d::ccColor4B const& color) {}
};
// todo in v4: maybe use events over the delegate?
// todo in v4: make this pimpl and 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
@ -24,8 +24,18 @@ namespace geode {
public cocos2d::extension::ColorPickerDelegate,
public TextInputDelegate {
protected:
class Impl;
std::unique_ptr<Impl> m_impl;
cocos2d::ccColor4B m_color;
cocos2d::ccColor4B m_originalColor;
cocos2d::extension::CCControlColourPicker* m_picker;
Slider* m_opacitySlider = nullptr;
TextInput* m_rInput;
TextInput* m_gInput;
TextInput* m_bInput;
TextInput* m_hexInput;
TextInput* m_opacityInput = nullptr;
ColorPickPopupDelegate* m_delegate = nullptr;
cocos2d::CCSprite* m_newColorSpr;
CCMenuItemSpriteExtra* m_resetBtn;
static constexpr auto TAG_OPACITY_INPUT = 0;
static constexpr auto TAG_R_INPUT = 1;
@ -33,13 +43,10 @@ namespace geode {
static constexpr auto TAG_B_INPUT = 3;
static constexpr auto TAG_HEX_INPUT = 4;
ColorPickPopup();
~ColorPickPopup();
bool setup(cocos2d::ccColor4B const& color, bool isRGBA) override;
void onOpacitySlider(cocos2d::CCObject* sender);
void onReset(cocos2d::CCObject* sender);
void onClose(cocos2d::CCObject* sender) override;
void textChanged(CCTextInputNode* input) override;
void colorValueChanged(cocos2d::ccColor3B color) override;

View file

@ -266,6 +266,6 @@ struct matjson::Serialize<V> {
}
static Value toJson(V const& value) {
return Value(value.toNonVString());
return Value(value.toString());
}
};

View file

@ -5,6 +5,7 @@
#include "../DefaultInclude.hpp"
#include <chrono>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <filesystem>
@ -63,7 +64,9 @@ namespace geode {
template <typename T>
std::string intToHex(T i) {
return fmt::format("{:#x}", i);
std::stringstream stream;
stream << std::showbase << std::setbase(16) << (uint64_t)i;
return stream.str();
}
/**
@ -72,16 +75,15 @@ namespace geode {
* @param num Number to convert to string
* @param precision Precision of the converted number
* @returns Number as string
* @note Precision has no effect on integers
*/
template <class Num>
std::string numToString(Num num, size_t precision = 0) {
if constexpr (std::is_floating_point_v<Num>) {
if (precision) {
return fmt::format("{:.{}f}", num, precision);
}
std::stringstream ss;
if (precision) {
ss << std::fixed << std::setprecision(precision);
}
return fmt::to_string(num);
ss << num;
return ss.str();
}
/**

View file

@ -10,33 +10,59 @@
using namespace geode::prelude;
class ColorPickPopup::Impl final {
public:
cocos2d::ccColor4B m_color;
cocos2d::ccColor4B m_originalColor;
cocos2d::extension::CCControlColourPicker* m_picker;
Slider* m_opacitySlider = nullptr;
TextInput* m_rInput;
TextInput* m_gInput;
TextInput* m_bInput;
TextInput* m_hexInput;
TextInput* m_opacityInput = nullptr;
ColorPickPopupDelegate* m_delegate = nullptr;
cocos2d::CCSprite* m_newColorSpr;
CCMenuItemSpriteExtra* m_resetBtn;
};
// class ColorPickPopupEvent::Impl final {
// public:
// ColorPickPopup* popup;
// ccColor4B color;
// bool closed = false;
// };
ColorPickPopup::ColorPickPopup() {
m_impl = std::make_unique<Impl>();
}
// ColorPickPopupEvent::ColorPickPopupEvent(ColorPickPopup* popup, ccColor4B const& color)
// : m_impl(std::make_shared<Impl>())
// {
// m_impl->popup = popup;
// m_impl->color = color;
// }
// ColorPickPopupEvent::~ColorPickPopupEvent() = default;
ColorPickPopup::~ColorPickPopup() {}
// ColorPickPopup* ColorPickPopupEvent::getPopup() const {
// return m_impl->popup;
// }
// ccColor4B ColorPickPopupEvent::getColor() const {
// return m_impl->color;
// }
// bool ColorPickPopupEvent::isPopupClosed() const {
// return m_impl->closed;
// }
// class ColorPickPopupEventFilter::Impl final {
// public:
// ColorPickPopup* popup;
// };
// ListenerResult ColorPickPopupEventFilter::handle(std::function<Callback> fn, ColorPickPopupEvent* event) {
// if (event->getPopup() == m_impl->popup) {
// if (event->isPopupClosed()) {
// m_impl->popup = nullptr;
// }
// else {
// fn(event);
// }
// }
// return ListenerResult::Propagate;
// }
// ColorPickPopupEventFilter::ColorPickPopupEventFilter() : ColorPickPopupEventFilter(nullptr) {}
// ColorPickPopupEventFilter::ColorPickPopupEventFilter(ColorPickPopup* popup)
// : m_impl(std::make_shared<Impl>())
// {
// m_impl->popup = popup;
// }
// ColorPickPopupEventFilter::~ColorPickPopupEventFilter() = default;
bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
m_noElasticity = true;
m_impl->m_color = color;
m_impl->m_originalColor = color;
m_color = color;
m_originalColor = color;
auto winSize = CCDirector::sharedDirector()->getWinSize();
@ -89,25 +115,25 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
// picker
m_impl->m_picker = CCControlColourPicker::colourPicker();
m_impl->m_picker->setDelegate(this);
m_impl->m_picker->setID("color-picker");
m_picker = CCControlColourPicker::colourPicker();
m_picker->setDelegate(this);
m_picker->setID("color-picker");
auto pickerWrapper = CCNode::create();
pickerWrapper->setContentSize(m_impl->m_picker->getContentSize());
pickerWrapper->setContentSize(m_picker->getContentSize());
pickerWrapper->setID("picker-wrapper");
pickerWrapper->addChildAtPosition(m_impl->m_picker, Anchor::Center, ccp(0, 0));
pickerWrapper->addChildAtPosition(m_picker, Anchor::Center, ccp(0, 0));
pickerRow->addChild(pickerWrapper);
auto oldColorSpr = CCSprite::createWithSpriteFrameName("whiteSquare60_001.png");
oldColorSpr->setColor(to3B(m_impl->m_color));
oldColorSpr->setColor(to3B(m_color));
oldColorSpr->setID("old-color-spr");
colorMenu->addChild(oldColorSpr);
m_impl->m_newColorSpr = CCSprite::createWithSpriteFrameName("whiteSquare60_001.png");
m_impl->m_newColorSpr->setColor(to3B(m_impl->m_color));
m_impl->m_newColorSpr->setID("new-color-spr");
colorMenu->addChild(m_impl->m_newColorSpr);
m_newColorSpr = CCSprite::createWithSpriteFrameName("whiteSquare60_001.png");
m_newColorSpr->setColor(to3B(m_color));
m_newColorSpr->setID("new-color-spr");
colorMenu->addChild(m_newColorSpr);
auto resetBtnSpr = ButtonSprite::create(
CCSprite::createWithSpriteFrameName("reset-gold.png"_spr), 0x20, true, 0.f,
@ -115,16 +141,16 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
);
resetBtnSpr->setScale(.6f);
m_impl->m_resetBtn =
m_resetBtn =
CCMenuItemSpriteExtra::create(resetBtnSpr, this, menu_selector(ColorPickPopup::onReset));
m_impl->m_resetBtn->setPosition({ -165.f, -50.f });
m_impl->m_resetBtn->setLayoutOptions(
m_resetBtn->setPosition({ -165.f, -50.f });
m_resetBtn->setLayoutOptions(
AxisLayoutOptions::create()
->setPrevGap(10.f)
->setNextGap(10.f)
);
m_impl->m_resetBtn->setID("reset-btn");
colorMenu->addChild(m_impl->m_resetBtn);
m_resetBtn->setID("reset-btn");
colorMenu->addChild(m_resetBtn);
@ -168,11 +194,11 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
rText->setID("r-text");
rColumn->addChild(rText);
m_impl->m_rInput = TextInput::create(50.f, "R");
m_impl->m_rInput->setScale(.7f);
m_impl->m_rInput->setDelegate(this, TAG_R_INPUT);
m_impl->m_rInput->setID("r-input");
rColumn->addChild(m_impl->m_rInput);
m_rInput = TextInput::create(50.f, "R");
m_rInput->setScale(.7f);
m_rInput->setDelegate(this, TAG_R_INPUT);
m_rInput->setID("r-input");
rColumn->addChild(m_rInput);
rColumn->updateLayout();
auto rRect = calculateChildCoverage(rColumn);
@ -197,11 +223,11 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
gText->setID("g-text");
gColumn->addChild(gText);
m_impl->m_gInput = TextInput::create(50.f, "G");
m_impl->m_gInput->setScale(.7f);
m_impl->m_gInput->setDelegate(this, TAG_G_INPUT);
m_impl->m_gInput->setID("g-input");
gColumn->addChild(m_impl->m_gInput);
m_gInput = TextInput::create(50.f, "G");
m_gInput->setScale(.7f);
m_gInput->setDelegate(this, TAG_G_INPUT);
m_gInput->setID("g-input");
gColumn->addChild(m_gInput);
gColumn->updateLayout();
auto gRect = calculateChildCoverage(gColumn);
@ -226,11 +252,11 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
bText->setID("b-text");
bColumn->addChild(bText);
m_impl->m_bInput = TextInput::create(50.f, "B");
m_impl->m_bInput->setScale(.7f);
m_impl->m_bInput->setDelegate(this, TAG_B_INPUT);
m_impl->m_bInput->setID("b-input");
bColumn->addChild(m_impl->m_bInput);
m_bInput = TextInput::create(50.f, "B");
m_bInput->setScale(.7f);
m_bInput->setDelegate(this, TAG_B_INPUT);
m_bInput->setID("b-input");
bColumn->addChild(m_bInput);
bColumn->updateLayout();
auto bRect = calculateChildCoverage(bColumn);
@ -255,11 +281,11 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
hexText->setID("hex-text");
hexColumn->addChild(hexText);
m_impl->m_hexInput = TextInput::create(165.f, "Hex");
m_impl->m_hexInput->setScale(.7f);
m_impl->m_hexInput->setDelegate(this, TAG_HEX_INPUT);
m_impl->m_hexInput->setID("hex-input");
hexColumn->addChild(m_impl->m_hexInput);
m_hexInput = TextInput::create(165.f, "Hex");
m_hexInput->setScale(.7f);
m_hexInput->setDelegate(this, TAG_HEX_INPUT);
m_hexInput->setID("hex-input");
hexColumn->addChild(m_hexInput);
hexColumn->updateLayout();
rgbRow->updateLayout();
@ -298,22 +324,22 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
opacityText->setID("opacity-text");
sliderColumn->addChild(opacityText);
m_impl->m_opacitySlider =
m_opacitySlider =
Slider::create(this, menu_selector(ColorPickPopup::onOpacitySlider), .75f);
m_impl->m_opacitySlider->setValue(color.a / 255.f);
m_impl->m_opacitySlider->setID("opacity-slider");
m_opacitySlider->setValue(color.a / 255.f);
m_opacitySlider->setID("opacity-slider");
auto sliderWrapper = CCNode::create();
sliderWrapper->setContentSize(ccp(m_impl->m_opacitySlider->m_width, m_impl->m_opacitySlider->m_height) * .75f);
sliderWrapper->setContentSize(ccp(m_opacitySlider->m_width, m_opacitySlider->m_height) * .75f);
sliderWrapper->setID("slider-wrapper");
sliderWrapper->addChildAtPosition(m_impl->m_opacitySlider, Anchor::Center, ccp(0, 0));
sliderWrapper->addChildAtPosition(m_opacitySlider, Anchor::Center, ccp(0, 0));
sliderColumn->addChild(sliderWrapper);
m_impl->m_opacityInput = TextInput::create(60.f, "Opacity");
m_impl->m_opacityInput->setScale(.7f);
m_impl->m_opacityInput->setDelegate(this, TAG_OPACITY_INPUT);
m_impl->m_opacityInput->setID("opacity-input");
opacitySection->addChild(m_impl->m_opacityInput);
m_opacityInput = TextInput::create(60.f, "Opacity");
m_opacityInput->setScale(.7f);
m_opacityInput->setDelegate(this, TAG_OPACITY_INPUT);
m_opacityInput->setID("opacity-input");
opacitySection->addChild(m_opacityInput);
sliderColumn->updateLayout();
opacitySection->updateLayout();
@ -335,79 +361,75 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
}
void ColorPickPopup::updateState(CCNode* except) {
#define IF_NOT_EXCEPT(inp, value) \
if (inp->getInputNode() != except) { \
inp->setString(value, false); \
}
#define IF_NOT_EXCEPT(inp, value) \
if (inp->getInputNode() != except) { \
inp->setString(value, false); \
}
IF_NOT_EXCEPT(m_impl->m_rInput, numToString<int>(m_impl->m_color.r));
IF_NOT_EXCEPT(m_impl->m_gInput, numToString<int>(m_impl->m_color.g));
IF_NOT_EXCEPT(m_impl->m_bInput, numToString<int>(m_impl->m_color.b));
IF_NOT_EXCEPT(m_impl->m_hexInput, cc3bToHexString(to3B(m_impl->m_color)));
if (m_impl->m_opacityInput) {
IF_NOT_EXCEPT(m_impl->m_opacityInput, numToString(m_impl->m_color.a / 255.f, 2));
IF_NOT_EXCEPT(m_rInput, numToString<int>(m_color.r));
IF_NOT_EXCEPT(m_gInput, numToString<int>(m_color.g));
IF_NOT_EXCEPT(m_bInput, numToString<int>(m_color.b));
IF_NOT_EXCEPT(m_hexInput, cc3bToHexString(to3B(m_color)));
if (m_opacityInput) {
IF_NOT_EXCEPT(m_opacityInput, numToString(m_color.a / 255.f, 2));
}
if (m_impl->m_opacitySlider) {
m_impl->m_opacitySlider->setValue(m_impl->m_color.a / 255.f);
if (m_opacitySlider) {
m_opacitySlider->setValue(m_color.a / 255.f);
}
if (m_impl->m_picker != except) {
m_impl->m_picker->setDelegate(nullptr);
m_impl->m_picker->setColorValue(to3B(m_impl->m_color));
m_impl->m_picker->setDelegate(this);
if (m_picker != except) {
m_picker->setDelegate(nullptr);
m_picker->setColorValue(to3B(m_color));
m_picker->setDelegate(this);
}
m_resetBtn->setVisible(m_originalColor != m_color);
m_newColorSpr->setColor(to3B(m_color));
if (m_delegate) {
m_delegate->updateColor(m_color);
}
m_impl->m_resetBtn->setVisible(m_impl->m_originalColor != m_impl->m_color);
m_impl->m_newColorSpr->setColor(to3B(m_impl->m_color));
}
void ColorPickPopup::onOpacitySlider(CCObject* sender) {
m_impl->m_color.a = static_cast<GLubyte>(static_cast<SliderThumb*>(sender)->getValue() * 255.f);
m_color.a = static_cast<GLubyte>(static_cast<SliderThumb*>(sender)->getValue() * 255.f);
this->updateState();
}
void ColorPickPopup::onReset(CCObject*) {
m_impl->m_color = m_impl->m_originalColor;
m_color = m_originalColor;
this->updateState();
}
void ColorPickPopup::onClose(CCObject* sender) {
if (m_impl->m_delegate) {
m_impl->m_delegate->updateColor(m_impl->m_color);
}
Popup::onClose(sender);
}
void ColorPickPopup::textChanged(CCTextInputNode* input) {
if (input->getString().size()) {
switch (input->getTag()) {
case TAG_HEX_INPUT:
{
if (auto color = cc3bFromHexString(input->getString(), true)) {
m_impl->m_color.r = color.unwrap().r;
m_impl->m_color.g = color.unwrap().g;
m_impl->m_color.b = color.unwrap().b;
m_color.r = color.unwrap().r;
m_color.g = color.unwrap().g;
m_color.b = color.unwrap().b;
}
}
break;
case TAG_OPACITY_INPUT: {
auto res = numFromString<float>(input->getString().c_str());
if (res) m_impl->m_color.a = std::clamp(static_cast<int>(res.unwrap() * 255.f), 0, 255);
if (res) m_color.a = std::clamp(static_cast<int>(res.unwrap() * 255.f), 0, 255);
break;
}
case TAG_R_INPUT: {
auto res = numFromString<uint32_t>(input->getString().c_str());
if (res) m_impl->m_color.r = std::clamp(res.unwrap(), 0u, 255u);
if (res) m_color.r = std::clamp(res.unwrap(), 0u, 255u);
break;
}
case TAG_G_INPUT: {
auto res = numFromString<uint32_t>(input->getString().c_str());
if (res) m_impl->m_color.g = std::clamp(res.unwrap(), 0u, 255u);
if (res) m_color.g = std::clamp(res.unwrap(), 0u, 255u);
break;
}
case TAG_B_INPUT: {
auto res = numFromString<uint32_t>(input->getString().c_str());
if (res) m_impl->m_color.b = std::clamp(res.unwrap(), 0u, 255u);
if (res) m_color.b = std::clamp(res.unwrap(), 0u, 255u);
break;
}
@ -418,18 +440,18 @@ void ColorPickPopup::textChanged(CCTextInputNode* input) {
}
void ColorPickPopup::colorValueChanged(ccColor3B color) {
m_impl->m_color.r = color.r;
m_impl->m_color.g = color.g;
m_impl->m_color.b = color.b;
this->updateState(m_impl->m_picker);
m_color.r = color.r;
m_color.g = color.g;
m_color.b = color.b;
this->updateState(m_picker);
}
void ColorPickPopup::setDelegate(ColorPickPopupDelegate* delegate) {
m_impl->m_delegate = delegate;
m_delegate = delegate;
}
void ColorPickPopup::setColorTarget(cocos2d::CCSprite* spr) {
m_impl->m_picker->setColorTarget(spr);
m_picker->setColorTarget(spr);
}
ColorPickPopup* ColorPickPopup::create(ccColor4B const& color, bool isRGBA) {