mirror of
https://github.com/geode-sdk/geode.git
synced 2024-12-02 04:06:58 -05:00
Compare commits
10 commits
b6220eeed4
...
c33f54bbb2
Author | SHA1 | Date | |
---|---|---|---|
|
c33f54bbb2 | ||
|
d6f0c597f1 | ||
|
f6c23220d8 | ||
|
9fe3d133e9 | ||
|
3081164600 | ||
|
bebc7b4074 | ||
|
5645399a9f | ||
|
1a201e1d65 | ||
|
4a40835f71 | ||
|
74d0924bcb |
10 changed files with 177 additions and 161 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -1,15 +1,25 @@
|
||||||
# Geode Changelog
|
# Geode Changelog
|
||||||
|
|
||||||
## v4.0.0-alpha.2
|
## v4.0.0-beta.1
|
||||||
* Button to manually install mods from files (e881dc5)
|
* Button to manually install mods from files (e881dc5)
|
||||||
* Add `ModRequestedAction::Update` (e881dc5)
|
* Add `ModRequestedAction::Update` (e881dc5)
|
||||||
* Add `ModMetadata::checkGeodeVersion` and `ModMetadata::checkTargetVersions` (e881dc5)
|
* Add `ModMetadata::checkGeodeVersion` and `ModMetadata::checkTargetVersions` (e881dc5)
|
||||||
* Add `geode::createModLogo` for creating a logo from a `.geode` package (e881dc5)
|
* Add `geode::createModLogo` for creating a logo from a `.geode` package (e881dc5)
|
||||||
* Tags now use names provided by the server (893b03e)
|
* 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 `Task::chain` using the wrong type in the impl (22a11b9)
|
||||||
* Fix installing mods not checking the current version (#1148)
|
* 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 crash when checking tags (01807fe)
|
||||||
* Fix 'Outdated' label being visible while updating (6679a69)
|
* 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
|
## v4.0.0-alpha.1
|
||||||
* Support for the 2.2074 update
|
* Support for the 2.2074 update
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
4.0.0-alpha.1
|
4.0.0-beta.1
|
||||||
|
|
|
@ -164,7 +164,27 @@ function(setup_geode_mod proname)
|
||||||
set(HAS_HEADERS Off)
|
set(HAS_HEADERS Off)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (HAS_HEADERS AND WIN32)
|
if (GEODE_BUNDLE_PDB AND WIN32 AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
|
||||||
|
if (HAS_HEADERS)
|
||||||
|
add_custom_target(${proname}_PACKAGE ALL
|
||||||
|
DEPENDS ${proname} ${CMAKE_CURRENT_SOURCE_DIR}/mod.json
|
||||||
|
COMMAND ${GEODE_CLI} package new ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
--binary $<TARGET_FILE:${proname}> $<TARGET_LINKER_FILE:${proname}> $<TARGET_PDB_FILE:${proname}>
|
||||||
|
--output ${CMAKE_CURRENT_BINARY_DIR}/${MOD_ID}.geode
|
||||||
|
${INSTALL_ARG} ${PDB_ARG}
|
||||||
|
VERBATIM USES_TERMINAL
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
add_custom_target(${proname}_PACKAGE ALL
|
||||||
|
DEPENDS ${proname} ${CMAKE_CURRENT_SOURCE_DIR}/mod.json
|
||||||
|
COMMAND ${GEODE_CLI} package new ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
--binary $<TARGET_FILE:${proname}> $<TARGET_PDB_FILE:${proname}>
|
||||||
|
--output ${CMAKE_CURRENT_BINARY_DIR}/${MOD_ID}.geode
|
||||||
|
${INSTALL_ARG} ${PDB_ARG}
|
||||||
|
VERBATIM USES_TERMINAL
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
elseif (HAS_HEADERS AND WIN32)
|
||||||
# this adds the .lib file on windows, which is needed for linking with the headers
|
# this adds the .lib file on windows, which is needed for linking with the headers
|
||||||
add_custom_target(${proname}_PACKAGE ALL
|
add_custom_target(${proname}_PACKAGE ALL
|
||||||
DEPENDS ${proname} ${CMAKE_CURRENT_SOURCE_DIR}/mod.json
|
DEPENDS ${proname} ${CMAKE_CURRENT_SOURCE_DIR}/mod.json
|
||||||
|
|
|
@ -72,6 +72,17 @@ elseif (GEODE_TARGET_PLATFORM STREQUAL "Win64")
|
||||||
target_link_libraries(${PROJECT_NAME} INTERFACE
|
target_link_libraries(${PROJECT_NAME} INTERFACE
|
||||||
${GEODE_LOADER_PATH}/include/link/win64/libcocos2d.lib
|
${GEODE_LOADER_PATH}/include/link/win64/libcocos2d.lib
|
||||||
${GEODE_LOADER_PATH}/include/link/win64/libExtensions.lib
|
${GEODE_LOADER_PATH}/include/link/win64/libExtensions.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/ssl.lib
|
||||||
${GEODE_LOADER_PATH}/include/link/win64/crypto.lib
|
${GEODE_LOADER_PATH}/include/link/win64/crypto.lib
|
||||||
${GEODE_LOADER_PATH}/include/link/win64/nghttp2.lib
|
${GEODE_LOADER_PATH}/include/link/win64/nghttp2.lib
|
||||||
|
@ -79,10 +90,8 @@ elseif (GEODE_TARGET_PLATFORM STREQUAL "Win64")
|
||||||
${GEODE_LOADER_PATH}/include/link/win64/nghttp3.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/ngtcp2_crypto_boringssl.lib
|
||||||
${GEODE_LOADER_PATH}/include/link/win64/libcurl.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
|
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Windows links against .lib and not .dll
|
# Windows links against .lib and not .dll
|
||||||
set(GEODE_OUTPUT_NAME "Geode")
|
set(GEODE_OUTPUT_NAME "Geode")
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) || defined(WIN64) || defined(_WIN64) || defined(__WIN64) && !defined(__CYGWIN__)
|
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) || defined(WIN64) || defined(_WIN64) || defined(__WIN64) && !defined(__CYGWIN__)
|
||||||
#define GEODE_WINDOWS(...) __VA_ARGS__
|
#define GEODE_WINDOWS(...) __VA_ARGS__
|
||||||
|
#define GEODE_DESKTOP(...) __VA_ARGS__
|
||||||
|
#define GEODE_MOBILE(...)
|
||||||
#define GEODE_IS_WINDOWS
|
#define GEODE_IS_WINDOWS
|
||||||
#define GEODE_IS_DESKTOP
|
#define GEODE_IS_DESKTOP
|
||||||
#define GEODE_PLATFORM_NAME "Windows"
|
#define GEODE_PLATFORM_NAME "Windows"
|
||||||
|
@ -43,6 +45,8 @@
|
||||||
#define GEODE_INTEL_MAC(...)
|
#define GEODE_INTEL_MAC(...)
|
||||||
#define GEODE_ARM_MAC(...)
|
#define GEODE_ARM_MAC(...)
|
||||||
#define GEODE_IOS(...) __VA_ARGS__
|
#define GEODE_IOS(...) __VA_ARGS__
|
||||||
|
#define GEODE_DESKTOP(...)
|
||||||
|
#define GEODE_MOBILE(...) __VA_ARGS__
|
||||||
#define GEODE_IS_IOS
|
#define GEODE_IS_IOS
|
||||||
#define GEODE_IS_MOBILE
|
#define GEODE_IS_MOBILE
|
||||||
#define GEODE_PLATFORM_NAME "iOS"
|
#define GEODE_PLATFORM_NAME "iOS"
|
||||||
|
@ -53,6 +57,8 @@
|
||||||
#else
|
#else
|
||||||
#define GEODE_IOS(...)
|
#define GEODE_IOS(...)
|
||||||
#define GEODE_MACOS(...) __VA_ARGS__
|
#define GEODE_MACOS(...) __VA_ARGS__
|
||||||
|
#define GEODE_DESKTOP(...) __VA_ARGS__
|
||||||
|
#define GEODE_MOBILE(...)
|
||||||
#define GEODE_IS_MACOS
|
#define GEODE_IS_MACOS
|
||||||
#define GEODE_IS_DESKTOP
|
#define GEODE_IS_DESKTOP
|
||||||
#define GEODE_PLATFORM_EXTENSION ".dylib"
|
#define GEODE_PLATFORM_EXTENSION ".dylib"
|
||||||
|
@ -84,6 +90,8 @@
|
||||||
// Android
|
// Android
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
#define GEODE_ANDROID(...) __VA_ARGS__
|
#define GEODE_ANDROID(...) __VA_ARGS__
|
||||||
|
#define GEODE_MOBILE(...) __VA_ARGS__
|
||||||
|
#define GEODE_DESKTOP(...)
|
||||||
#define GEODE_IS_ANDROID
|
#define GEODE_IS_ANDROID
|
||||||
#define GEODE_IS_MOBILE
|
#define GEODE_IS_MOBILE
|
||||||
#define GEODE_CALL
|
#define GEODE_CALL
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace geode {
|
||||||
virtual void updateColor(cocos2d::ccColor4B const& color) {}
|
virtual void updateColor(cocos2d::ccColor4B const& color) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// todo in v4: make this pimpl and maybe use events over the delegate?
|
// todo in v4: maybe use events over the delegate?
|
||||||
// thing with events is that if you just filter via ColorPickPopup* it
|
// thing with events is that if you just filter via ColorPickPopup* it
|
||||||
// won't work unless you automatically detach the filter when closing the
|
// won't work unless you automatically detach the filter when closing the
|
||||||
// popup (otherwise opening another popup really quickly will just be
|
// popup (otherwise opening another popup really quickly will just be
|
||||||
|
@ -24,18 +24,8 @@ namespace geode {
|
||||||
public cocos2d::extension::ColorPickerDelegate,
|
public cocos2d::extension::ColorPickerDelegate,
|
||||||
public TextInputDelegate {
|
public TextInputDelegate {
|
||||||
protected:
|
protected:
|
||||||
cocos2d::ccColor4B m_color;
|
class Impl;
|
||||||
cocos2d::ccColor4B m_originalColor;
|
std::unique_ptr<Impl> m_impl;
|
||||||
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_OPACITY_INPUT = 0;
|
||||||
static constexpr auto TAG_R_INPUT = 1;
|
static constexpr auto TAG_R_INPUT = 1;
|
||||||
|
@ -43,10 +33,13 @@ namespace geode {
|
||||||
static constexpr auto TAG_B_INPUT = 3;
|
static constexpr auto TAG_B_INPUT = 3;
|
||||||
static constexpr auto TAG_HEX_INPUT = 4;
|
static constexpr auto TAG_HEX_INPUT = 4;
|
||||||
|
|
||||||
|
ColorPickPopup();
|
||||||
|
~ColorPickPopup();
|
||||||
bool setup(cocos2d::ccColor4B const& color, bool isRGBA) override;
|
bool setup(cocos2d::ccColor4B const& color, bool isRGBA) override;
|
||||||
|
|
||||||
void onOpacitySlider(cocos2d::CCObject* sender);
|
void onOpacitySlider(cocos2d::CCObject* sender);
|
||||||
void onReset(cocos2d::CCObject* sender);
|
void onReset(cocos2d::CCObject* sender);
|
||||||
|
void onClose(cocos2d::CCObject* sender) override;
|
||||||
|
|
||||||
void textChanged(CCTextInputNode* input) override;
|
void textChanged(CCTextInputNode* input) override;
|
||||||
void colorValueChanged(cocos2d::ccColor3B color) override;
|
void colorValueChanged(cocos2d::ccColor3B color) override;
|
||||||
|
|
|
@ -266,6 +266,6 @@ struct matjson::Serialize<V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Value toJson(V const& value) {
|
static Value toJson(V const& value) {
|
||||||
return Value(value.toString());
|
return Value(value.toNonVString());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include "../DefaultInclude.hpp"
|
#include "../DefaultInclude.hpp"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
@ -64,9 +63,7 @@ namespace geode {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::string intToHex(T i) {
|
std::string intToHex(T i) {
|
||||||
std::stringstream stream;
|
return fmt::format("{:#x}", i);
|
||||||
stream << std::showbase << std::setbase(16) << (uint64_t)i;
|
|
||||||
return stream.str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,15 +72,16 @@ namespace geode {
|
||||||
* @param num Number to convert to string
|
* @param num Number to convert to string
|
||||||
* @param precision Precision of the converted number
|
* @param precision Precision of the converted number
|
||||||
* @returns Number as string
|
* @returns Number as string
|
||||||
|
* @note Precision has no effect on integers
|
||||||
*/
|
*/
|
||||||
template <class Num>
|
template <class Num>
|
||||||
std::string numToString(Num num, size_t precision = 0) {
|
std::string numToString(Num num, size_t precision = 0) {
|
||||||
std::stringstream ss;
|
if constexpr (std::is_floating_point_v<Num>) {
|
||||||
if (precision) {
|
if (precision) {
|
||||||
ss << std::fixed << std::setprecision(precision);
|
return fmt::format("{:.{}f}", num, precision);
|
||||||
}
|
}
|
||||||
ss << num;
|
}
|
||||||
return ss.str();
|
return fmt::to_string(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
BIN
loader/include/link/win64/gd-libcurl.lib
Normal file
BIN
loader/include/link/win64/gd-libcurl.lib
Normal file
Binary file not shown.
|
@ -10,59 +10,33 @@
|
||||||
|
|
||||||
using namespace geode::prelude;
|
using namespace geode::prelude;
|
||||||
|
|
||||||
// class ColorPickPopupEvent::Impl final {
|
class ColorPickPopup::Impl final {
|
||||||
// public:
|
public:
|
||||||
// ColorPickPopup* popup;
|
cocos2d::ccColor4B m_color;
|
||||||
// ccColor4B color;
|
cocos2d::ccColor4B m_originalColor;
|
||||||
// bool closed = false;
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
// ColorPickPopupEvent::ColorPickPopupEvent(ColorPickPopup* popup, ccColor4B const& color)
|
ColorPickPopup::ColorPickPopup() {
|
||||||
// : m_impl(std::make_shared<Impl>())
|
m_impl = std::make_unique<Impl>();
|
||||||
// {
|
}
|
||||||
// m_impl->popup = popup;
|
|
||||||
// m_impl->color = color;
|
|
||||||
// }
|
|
||||||
// ColorPickPopupEvent::~ColorPickPopupEvent() = default;
|
|
||||||
|
|
||||||
// ColorPickPopup* ColorPickPopupEvent::getPopup() const {
|
ColorPickPopup::~ColorPickPopup() {}
|
||||||
// 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) {
|
bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
|
||||||
m_noElasticity = true;
|
m_noElasticity = true;
|
||||||
m_color = color;
|
m_impl->m_color = color;
|
||||||
m_originalColor = color;
|
m_impl->m_originalColor = color;
|
||||||
|
|
||||||
auto winSize = CCDirector::sharedDirector()->getWinSize();
|
auto winSize = CCDirector::sharedDirector()->getWinSize();
|
||||||
|
|
||||||
|
@ -115,25 +89,25 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
|
||||||
|
|
||||||
// picker
|
// picker
|
||||||
|
|
||||||
m_picker = CCControlColourPicker::colourPicker();
|
m_impl->m_picker = CCControlColourPicker::colourPicker();
|
||||||
m_picker->setDelegate(this);
|
m_impl->m_picker->setDelegate(this);
|
||||||
m_picker->setID("color-picker");
|
m_impl->m_picker->setID("color-picker");
|
||||||
|
|
||||||
auto pickerWrapper = CCNode::create();
|
auto pickerWrapper = CCNode::create();
|
||||||
pickerWrapper->setContentSize(m_picker->getContentSize());
|
pickerWrapper->setContentSize(m_impl->m_picker->getContentSize());
|
||||||
pickerWrapper->setID("picker-wrapper");
|
pickerWrapper->setID("picker-wrapper");
|
||||||
pickerWrapper->addChildAtPosition(m_picker, Anchor::Center, ccp(0, 0));
|
pickerWrapper->addChildAtPosition(m_impl->m_picker, Anchor::Center, ccp(0, 0));
|
||||||
pickerRow->addChild(pickerWrapper);
|
pickerRow->addChild(pickerWrapper);
|
||||||
|
|
||||||
auto oldColorSpr = CCSprite::createWithSpriteFrameName("whiteSquare60_001.png");
|
auto oldColorSpr = CCSprite::createWithSpriteFrameName("whiteSquare60_001.png");
|
||||||
oldColorSpr->setColor(to3B(m_color));
|
oldColorSpr->setColor(to3B(m_impl->m_color));
|
||||||
oldColorSpr->setID("old-color-spr");
|
oldColorSpr->setID("old-color-spr");
|
||||||
colorMenu->addChild(oldColorSpr);
|
colorMenu->addChild(oldColorSpr);
|
||||||
|
|
||||||
m_newColorSpr = CCSprite::createWithSpriteFrameName("whiteSquare60_001.png");
|
m_impl->m_newColorSpr = CCSprite::createWithSpriteFrameName("whiteSquare60_001.png");
|
||||||
m_newColorSpr->setColor(to3B(m_color));
|
m_impl->m_newColorSpr->setColor(to3B(m_impl->m_color));
|
||||||
m_newColorSpr->setID("new-color-spr");
|
m_impl->m_newColorSpr->setID("new-color-spr");
|
||||||
colorMenu->addChild(m_newColorSpr);
|
colorMenu->addChild(m_impl->m_newColorSpr);
|
||||||
|
|
||||||
auto resetBtnSpr = ButtonSprite::create(
|
auto resetBtnSpr = ButtonSprite::create(
|
||||||
CCSprite::createWithSpriteFrameName("reset-gold.png"_spr), 0x20, true, 0.f,
|
CCSprite::createWithSpriteFrameName("reset-gold.png"_spr), 0x20, true, 0.f,
|
||||||
|
@ -141,16 +115,16 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
|
||||||
);
|
);
|
||||||
resetBtnSpr->setScale(.6f);
|
resetBtnSpr->setScale(.6f);
|
||||||
|
|
||||||
m_resetBtn =
|
m_impl->m_resetBtn =
|
||||||
CCMenuItemSpriteExtra::create(resetBtnSpr, this, menu_selector(ColorPickPopup::onReset));
|
CCMenuItemSpriteExtra::create(resetBtnSpr, this, menu_selector(ColorPickPopup::onReset));
|
||||||
m_resetBtn->setPosition({ -165.f, -50.f });
|
m_impl->m_resetBtn->setPosition({ -165.f, -50.f });
|
||||||
m_resetBtn->setLayoutOptions(
|
m_impl->m_resetBtn->setLayoutOptions(
|
||||||
AxisLayoutOptions::create()
|
AxisLayoutOptions::create()
|
||||||
->setPrevGap(10.f)
|
->setPrevGap(10.f)
|
||||||
->setNextGap(10.f)
|
->setNextGap(10.f)
|
||||||
);
|
);
|
||||||
m_resetBtn->setID("reset-btn");
|
m_impl->m_resetBtn->setID("reset-btn");
|
||||||
colorMenu->addChild(m_resetBtn);
|
colorMenu->addChild(m_impl->m_resetBtn);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -194,11 +168,11 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
|
||||||
rText->setID("r-text");
|
rText->setID("r-text");
|
||||||
rColumn->addChild(rText);
|
rColumn->addChild(rText);
|
||||||
|
|
||||||
m_rInput = TextInput::create(50.f, "R");
|
m_impl->m_rInput = TextInput::create(50.f, "R");
|
||||||
m_rInput->setScale(.7f);
|
m_impl->m_rInput->setScale(.7f);
|
||||||
m_rInput->setDelegate(this, TAG_R_INPUT);
|
m_impl->m_rInput->setDelegate(this, TAG_R_INPUT);
|
||||||
m_rInput->setID("r-input");
|
m_impl->m_rInput->setID("r-input");
|
||||||
rColumn->addChild(m_rInput);
|
rColumn->addChild(m_impl->m_rInput);
|
||||||
|
|
||||||
rColumn->updateLayout();
|
rColumn->updateLayout();
|
||||||
auto rRect = calculateChildCoverage(rColumn);
|
auto rRect = calculateChildCoverage(rColumn);
|
||||||
|
@ -223,11 +197,11 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
|
||||||
gText->setID("g-text");
|
gText->setID("g-text");
|
||||||
gColumn->addChild(gText);
|
gColumn->addChild(gText);
|
||||||
|
|
||||||
m_gInput = TextInput::create(50.f, "G");
|
m_impl->m_gInput = TextInput::create(50.f, "G");
|
||||||
m_gInput->setScale(.7f);
|
m_impl->m_gInput->setScale(.7f);
|
||||||
m_gInput->setDelegate(this, TAG_G_INPUT);
|
m_impl->m_gInput->setDelegate(this, TAG_G_INPUT);
|
||||||
m_gInput->setID("g-input");
|
m_impl->m_gInput->setID("g-input");
|
||||||
gColumn->addChild(m_gInput);
|
gColumn->addChild(m_impl->m_gInput);
|
||||||
|
|
||||||
gColumn->updateLayout();
|
gColumn->updateLayout();
|
||||||
auto gRect = calculateChildCoverage(gColumn);
|
auto gRect = calculateChildCoverage(gColumn);
|
||||||
|
@ -252,11 +226,11 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
|
||||||
bText->setID("b-text");
|
bText->setID("b-text");
|
||||||
bColumn->addChild(bText);
|
bColumn->addChild(bText);
|
||||||
|
|
||||||
m_bInput = TextInput::create(50.f, "B");
|
m_impl->m_bInput = TextInput::create(50.f, "B");
|
||||||
m_bInput->setScale(.7f);
|
m_impl->m_bInput->setScale(.7f);
|
||||||
m_bInput->setDelegate(this, TAG_B_INPUT);
|
m_impl->m_bInput->setDelegate(this, TAG_B_INPUT);
|
||||||
m_bInput->setID("b-input");
|
m_impl->m_bInput->setID("b-input");
|
||||||
bColumn->addChild(m_bInput);
|
bColumn->addChild(m_impl->m_bInput);
|
||||||
|
|
||||||
bColumn->updateLayout();
|
bColumn->updateLayout();
|
||||||
auto bRect = calculateChildCoverage(bColumn);
|
auto bRect = calculateChildCoverage(bColumn);
|
||||||
|
@ -281,11 +255,11 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
|
||||||
hexText->setID("hex-text");
|
hexText->setID("hex-text");
|
||||||
hexColumn->addChild(hexText);
|
hexColumn->addChild(hexText);
|
||||||
|
|
||||||
m_hexInput = TextInput::create(165.f, "Hex");
|
m_impl->m_hexInput = TextInput::create(165.f, "Hex");
|
||||||
m_hexInput->setScale(.7f);
|
m_impl->m_hexInput->setScale(.7f);
|
||||||
m_hexInput->setDelegate(this, TAG_HEX_INPUT);
|
m_impl->m_hexInput->setDelegate(this, TAG_HEX_INPUT);
|
||||||
m_hexInput->setID("hex-input");
|
m_impl->m_hexInput->setID("hex-input");
|
||||||
hexColumn->addChild(m_hexInput);
|
hexColumn->addChild(m_impl->m_hexInput);
|
||||||
|
|
||||||
hexColumn->updateLayout();
|
hexColumn->updateLayout();
|
||||||
rgbRow->updateLayout();
|
rgbRow->updateLayout();
|
||||||
|
@ -324,22 +298,22 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
|
||||||
opacityText->setID("opacity-text");
|
opacityText->setID("opacity-text");
|
||||||
sliderColumn->addChild(opacityText);
|
sliderColumn->addChild(opacityText);
|
||||||
|
|
||||||
m_opacitySlider =
|
m_impl->m_opacitySlider =
|
||||||
Slider::create(this, menu_selector(ColorPickPopup::onOpacitySlider), .75f);
|
Slider::create(this, menu_selector(ColorPickPopup::onOpacitySlider), .75f);
|
||||||
m_opacitySlider->setValue(color.a / 255.f);
|
m_impl->m_opacitySlider->setValue(color.a / 255.f);
|
||||||
m_opacitySlider->setID("opacity-slider");
|
m_impl->m_opacitySlider->setID("opacity-slider");
|
||||||
|
|
||||||
auto sliderWrapper = CCNode::create();
|
auto sliderWrapper = CCNode::create();
|
||||||
sliderWrapper->setContentSize(ccp(m_opacitySlider->m_width, m_opacitySlider->m_height) * .75f);
|
sliderWrapper->setContentSize(ccp(m_impl->m_opacitySlider->m_width, m_impl->m_opacitySlider->m_height) * .75f);
|
||||||
sliderWrapper->setID("slider-wrapper");
|
sliderWrapper->setID("slider-wrapper");
|
||||||
sliderWrapper->addChildAtPosition(m_opacitySlider, Anchor::Center, ccp(0, 0));
|
sliderWrapper->addChildAtPosition(m_impl->m_opacitySlider, Anchor::Center, ccp(0, 0));
|
||||||
sliderColumn->addChild(sliderWrapper);
|
sliderColumn->addChild(sliderWrapper);
|
||||||
|
|
||||||
m_opacityInput = TextInput::create(60.f, "Opacity");
|
m_impl->m_opacityInput = TextInput::create(60.f, "Opacity");
|
||||||
m_opacityInput->setScale(.7f);
|
m_impl->m_opacityInput->setScale(.7f);
|
||||||
m_opacityInput->setDelegate(this, TAG_OPACITY_INPUT);
|
m_impl->m_opacityInput->setDelegate(this, TAG_OPACITY_INPUT);
|
||||||
m_opacityInput->setID("opacity-input");
|
m_impl->m_opacityInput->setID("opacity-input");
|
||||||
opacitySection->addChild(m_opacityInput);
|
opacitySection->addChild(m_impl->m_opacityInput);
|
||||||
|
|
||||||
sliderColumn->updateLayout();
|
sliderColumn->updateLayout();
|
||||||
opacitySection->updateLayout();
|
opacitySection->updateLayout();
|
||||||
|
@ -361,75 +335,79 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorPickPopup::updateState(CCNode* except) {
|
void ColorPickPopup::updateState(CCNode* except) {
|
||||||
#define IF_NOT_EXCEPT(inp, value) \
|
#define IF_NOT_EXCEPT(inp, value) \
|
||||||
if (inp->getInputNode() != except) { \
|
if (inp->getInputNode() != except) { \
|
||||||
inp->setString(value, false); \
|
inp->setString(value, false); \
|
||||||
}
|
}
|
||||||
|
|
||||||
IF_NOT_EXCEPT(m_rInput, numToString<int>(m_color.r));
|
IF_NOT_EXCEPT(m_impl->m_rInput, numToString<int>(m_impl->m_color.r));
|
||||||
IF_NOT_EXCEPT(m_gInput, numToString<int>(m_color.g));
|
IF_NOT_EXCEPT(m_impl->m_gInput, numToString<int>(m_impl->m_color.g));
|
||||||
IF_NOT_EXCEPT(m_bInput, numToString<int>(m_color.b));
|
IF_NOT_EXCEPT(m_impl->m_bInput, numToString<int>(m_impl->m_color.b));
|
||||||
IF_NOT_EXCEPT(m_hexInput, cc3bToHexString(to3B(m_color)));
|
IF_NOT_EXCEPT(m_impl->m_hexInput, cc3bToHexString(to3B(m_impl->m_color)));
|
||||||
if (m_opacityInput) {
|
if (m_impl->m_opacityInput) {
|
||||||
IF_NOT_EXCEPT(m_opacityInput, numToString(m_color.a / 255.f, 2));
|
IF_NOT_EXCEPT(m_impl->m_opacityInput, numToString(m_impl->m_color.a / 255.f, 2));
|
||||||
}
|
}
|
||||||
if (m_opacitySlider) {
|
if (m_impl->m_opacitySlider) {
|
||||||
m_opacitySlider->setValue(m_color.a / 255.f);
|
m_impl->m_opacitySlider->setValue(m_impl->m_color.a / 255.f);
|
||||||
}
|
}
|
||||||
if (m_picker != except) {
|
if (m_impl->m_picker != except) {
|
||||||
m_picker->setDelegate(nullptr);
|
m_impl->m_picker->setDelegate(nullptr);
|
||||||
m_picker->setColorValue(to3B(m_color));
|
m_impl->m_picker->setColorValue(to3B(m_impl->m_color));
|
||||||
m_picker->setDelegate(this);
|
m_impl->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) {
|
void ColorPickPopup::onOpacitySlider(CCObject* sender) {
|
||||||
m_color.a = static_cast<GLubyte>(static_cast<SliderThumb*>(sender)->getValue() * 255.f);
|
m_impl->m_color.a = static_cast<GLubyte>(static_cast<SliderThumb*>(sender)->getValue() * 255.f);
|
||||||
this->updateState();
|
this->updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorPickPopup::onReset(CCObject*) {
|
void ColorPickPopup::onReset(CCObject*) {
|
||||||
m_color = m_originalColor;
|
m_impl->m_color = m_impl->m_originalColor;
|
||||||
this->updateState();
|
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) {
|
void ColorPickPopup::textChanged(CCTextInputNode* input) {
|
||||||
if (input->getString().size()) {
|
if (input->getString().size()) {
|
||||||
switch (input->getTag()) {
|
switch (input->getTag()) {
|
||||||
case TAG_HEX_INPUT:
|
case TAG_HEX_INPUT:
|
||||||
{
|
{
|
||||||
if (auto color = cc3bFromHexString(input->getString(), true)) {
|
if (auto color = cc3bFromHexString(input->getString(), true)) {
|
||||||
m_color.r = color.unwrap().r;
|
m_impl->m_color.r = color.unwrap().r;
|
||||||
m_color.g = color.unwrap().g;
|
m_impl->m_color.g = color.unwrap().g;
|
||||||
m_color.b = color.unwrap().b;
|
m_impl->m_color.b = color.unwrap().b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TAG_OPACITY_INPUT: {
|
case TAG_OPACITY_INPUT: {
|
||||||
auto res = numFromString<float>(input->getString().c_str());
|
auto res = numFromString<float>(input->getString().c_str());
|
||||||
if (res) m_color.a = std::clamp(static_cast<int>(res.unwrap() * 255.f), 0, 255);
|
if (res) m_impl->m_color.a = std::clamp(static_cast<int>(res.unwrap() * 255.f), 0, 255);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TAG_R_INPUT: {
|
case TAG_R_INPUT: {
|
||||||
auto res = numFromString<uint32_t>(input->getString().c_str());
|
auto res = numFromString<uint32_t>(input->getString().c_str());
|
||||||
if (res) m_color.r = std::clamp(res.unwrap(), 0u, 255u);
|
if (res) m_impl->m_color.r = std::clamp(res.unwrap(), 0u, 255u);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TAG_G_INPUT: {
|
case TAG_G_INPUT: {
|
||||||
auto res = numFromString<uint32_t>(input->getString().c_str());
|
auto res = numFromString<uint32_t>(input->getString().c_str());
|
||||||
if (res) m_color.g = std::clamp(res.unwrap(), 0u, 255u);
|
if (res) m_impl->m_color.g = std::clamp(res.unwrap(), 0u, 255u);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TAG_B_INPUT: {
|
case TAG_B_INPUT: {
|
||||||
auto res = numFromString<uint32_t>(input->getString().c_str());
|
auto res = numFromString<uint32_t>(input->getString().c_str());
|
||||||
if (res) m_color.b = std::clamp(res.unwrap(), 0u, 255u);
|
if (res) m_impl->m_color.b = std::clamp(res.unwrap(), 0u, 255u);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,18 +418,18 @@ void ColorPickPopup::textChanged(CCTextInputNode* input) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorPickPopup::colorValueChanged(ccColor3B color) {
|
void ColorPickPopup::colorValueChanged(ccColor3B color) {
|
||||||
m_color.r = color.r;
|
m_impl->m_color.r = color.r;
|
||||||
m_color.g = color.g;
|
m_impl->m_color.g = color.g;
|
||||||
m_color.b = color.b;
|
m_impl->m_color.b = color.b;
|
||||||
this->updateState(m_picker);
|
this->updateState(m_impl->m_picker);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorPickPopup::setDelegate(ColorPickPopupDelegate* delegate) {
|
void ColorPickPopup::setDelegate(ColorPickPopupDelegate* delegate) {
|
||||||
m_delegate = delegate;
|
m_impl->m_delegate = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorPickPopup::setColorTarget(cocos2d::CCSprite* spr) {
|
void ColorPickPopup::setColorTarget(cocos2d::CCSprite* spr) {
|
||||||
m_picker->setColorTarget(spr);
|
m_impl->m_picker->setColorTarget(spr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorPickPopup* ColorPickPopup::create(ccColor4B const& color, bool isRGBA) {
|
ColorPickPopup* ColorPickPopup::create(ccColor4B const& color, bool isRGBA) {
|
||||||
|
|
Loading…
Reference in a new issue