Merge branch 'main' of https://github.com/geode-sdk/geode into main

This commit is contained in:
camila314 2022-11-27 16:53:24 -06:00
commit b85a8e8cd7
36 changed files with 592 additions and 165 deletions

View file

@ -110,6 +110,12 @@ jobs:
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- name: Get version
uses: juliangruber/read-file-action@v1.1.6
with:
path: ${{ github.workspace }}/VERSION
id: version
- uses: actions/download-artifact@v3
with:
@ -117,23 +123,18 @@ jobs:
- uses: vimtor/action-zip@v1
with:
files: macOS
dest: macOS.zip
files: geode-v${{ steps.version.outputs.content }}-mac/Geode.dylib geode-v${{ steps.version.outputs.content }}-mac/GeodeBootstrapper.dylib
dest: geode-nightly-mac.zip
- uses: vimtor/action-zip@v1
with:
files: Windows
dest: Windows.zip
- uses: vimtor/action-zip@v1
with:
files: loader/include
dest: Headers.zip
files: geode-v${{ steps.version.outputs.content }}-win/Geode.dll geode-v${{ steps.version.outputs.content }}-win/GeodeBootstrapper.dll geode-v${{ steps.version.outputs.content }}-win/Geode.lib
dest: geode-nightly-win.zip
- name: Update release
uses: IsaacShelton/update-existing-release@v1.3.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: ./macOS.zip ./Windows.zip ./Headers.zip
files: ./geode-nightly-mac.zip ./geode-nightly-win.zip
release: Nightly
prerelease: true

View file

@ -79,6 +79,8 @@ target_include_directories(${PROJECT_NAME} INTERFACE
)
target_link_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/loader/include/link)
add_definitions(-DFMT_CONSTEVAL=)
add_subdirectory(filesystem)
add_subdirectory(fmt)

View file

@ -833,6 +833,7 @@ class cocos2d::CCString {
virtual auto isEqual(cocos2d::CCObject const*) = mac 0x44c8f0, ios 0x1a1e6c;
virtual auto acceptVisitor(cocos2d::CCDataVisitor&) = mac 0x44ccb0, ios 0x1a2168;
virtual cocos2d::CCObject* copyWithZone(cocos2d::CCZone*) = mac 0x44c870, ios 0x1a1e14;
static cocos2d::CCString* createWithData(unsigned char const*, unsigned long) = mac 0x44c9d0;
// cocos2d::CCString::create(gd::string const&) = mac 0x44c960;
// CCString(gd::string const&) = mac 0x44c310;
auto boolValue() const = mac 0x44c810, ios 0x1a1d88;

View file

@ -2,7 +2,6 @@
// clang-format off
class GDString {
void winDtor() = win 0xf6e0;
char const* winCStr() = win 0xf710;
GDString& winAssign(GDString const&, size_t, size_t) = win 0xf720;
GDString& winAssign(char const*) = win 0xf680;
GDString& winAssign(char const*, size_t) = win 0xf840;
@ -1181,7 +1180,7 @@ class EditorUI : cocos2d::CCLayer, FLAlertLayerProtocol, ColorSelectDelegate, GJ
CreateMenuItem* menuItemFromObjectString(gd::string, int) = mac 0x1e130, win 0x84d00;
void moveObject(GameObject*, cocos2d::CCPoint) = mac 0x24b10, win 0x8ddb0;
void onDuplicate(cocos2d::CCObject*) = mac 0x18ba0, win 0x87d20;
void onCreate() = mac 0x1b960, win 0x85680;
bool onCreate() = mac 0x1b960, win 0x85680;
void onCreateObject(int) = mac 0x200d0, win 0x85750;
cocos2d::CCArray* pasteObjects(gd::string) = mac 0x232d0, win 0x88240;
void playerTouchBegan(cocos2d::CCTouch*, cocos2d::CCEvent*) = mac 0x2ebf0, win 0x90680;
@ -1205,7 +1204,7 @@ class EditorUI : cocos2d::CCLayer, FLAlertLayerProtocol, ColorSelectDelegate, GJ
cocos2d::CCPoint getTouchPoint(cocos2d::CCTouch* touch, cocos2d::CCEvent* event) = win 0x90620;
void onSelectBuildTab(cocos2d::CCObject* sender) = win 0x887f0;
void onCreateButton(cocos2d::CCObject* sender) = win 0x854f0;
CCMenuItemSpriteExtra* getSpriteButton(const char* sprite, cocos2d::SEL_MenuHandler callback, cocos2d::CCMenu* menu, float scale) = win 0x78bf0;
CCMenuItemSpriteExtra* getSpriteButton(const char* sprite, cocos2d::SEL_MenuHandler callback, cocos2d::CCMenu* menu, float scale) = mac 0xb500, win 0x78bf0;
cocos2d::CCPoint offsetForKey(int objID) = win 0x92310;
void updateDeleteMenu() = win 0x7c5d0;
void updateCreateMenu(bool updateTab) = mac 0x1e960, win 0x85530;
@ -1258,6 +1257,7 @@ class EditorUI : cocos2d::CCLayer, FLAlertLayerProtocol, ColorSelectDelegate, GJ
void editColor(cocos2d::CCObject* sender) = mac 0x19190, win 0x8d3c0;
void alignObjects(cocos2d::CCArray* objs, bool alignY) = mac 0x2cea0, win 0x8f320;
virtual void scrollWheel(float vertical, float horizontal) = win 0x921d0, mac 0x31370, ios 0x2c4884;
void createMoveMenu() = mac 0x275e0, win 0x8c0d0;
EditButtonBar* m_buttonBar;
PAD = mac 0x8, win 0x4;
@ -1515,9 +1515,9 @@ class FLAlertLayer : cocos2d::CCLayerColor {
bool scrollable,
float height
) = mac 0x25e1b0, win 0x228e0;
static FLAlertLayer* create(FLAlertLayerProtocol*, char const*, gd::string, char const*, char const*) = mac 0x25de00, win 0x22680;
static FLAlertLayer* create(FLAlertLayerProtocol*, char const*, gd::string, char const*, char const*, float) = mac 0x25e0e0, win 0x22730, ios 0x1fe374;
static FLAlertLayer* create(FLAlertLayerProtocol*, char const*, gd::string, char const*, char const*, float, bool, float) = mac 0x25dec0, win 0x227e0;
static FLAlertLayer* create(FLAlertLayerProtocol* protocol, char const* title, gd::string content, char const* btn1, char const* btn2) = mac 0x25de00, win 0x22680;
static FLAlertLayer* create(FLAlertLayerProtocol* protocol, char const* title, gd::string content, char const* btn1, char const* btn2, float width) = mac 0x25e0e0, win 0x22730, ios 0x1fe374;
static FLAlertLayer* create(FLAlertLayerProtocol* protocol, char const* title, gd::string content, char const* btn1, char const* btn2, float width, bool scrollable, float height) = mac 0x25dec0, win 0x227e0;
void onBtn1(cocos2d::CCObject*) = mac 0x25ec20, win 0x23340;
void onBtn2(cocos2d::CCObject*) = mac 0x25ec80, win 0x23380;
@ -2026,7 +2026,9 @@ class GJEffectManager : cocos2d::CCNode {
void stopActionsForTrigger(EffectGameObject*) = mac 0x183150;
void stopMoveActionsForGroup(int) = mac 0x1830e0;
void storeTriggeredID(int) = mac 0x185380;
void toggleGroup(int, bool) = mac 0x182c80;
void toggleGroup(int item, bool value) { // mac 0x182c80;
m_groupToggled[item] = value;
}
void traverseInheritanceChain(InheritanceNode*) = mac 0x181850, win 0x11caf0;
void updateActiveOpacityEffects() = mac 0x1847e0;
void updateColorAction(ColorAction*) = mac 0x184560;
@ -5060,6 +5062,7 @@ class SetupTouchTogglePopup : FLAlertLayer {
}
class SimplePlayer : cocos2d::CCSprite {
SimplePlayer() {}
void setSecondColor(const cocos2d::ccColor3B& color) {
m_secondLayer->setColor(color);

View file

@ -0,0 +1,303 @@
# When configuring CMake with a toolchain file against a top-level CMakeLists.txt,
# it will actually run CMake many times, once for each small test program used to
# determine what features a compiler supports. Unfortunately, none of these
# invocations share a CMakeCache.txt with the top-level invocation, meaning they
# won't see the value of any arguments the user passed via -D. Since these are
# necessary to properly configure MSVC in both the top-level configuration as well as
# all feature-test invocations, we set environment variables with the values so that
# these environments get inherited by child invocations.
function(init_user_prop prop)
if(${prop})
set(ENV{_${prop}} "${${prop}}")
else()
set(${prop} "$ENV{_${prop}}" PARENT_SCOPE)
endif()
endfunction()
macro(cmake_getconf VAR)
if(NOT ${VAR})
set(${VAR} "$ENV{${VAR}}")
if(${VAR})
set(${VAR} "${${VAR}}" CACHE STRING "${VAR}")
message(STATUS "Found ${VAR}: ${${VAR}}")
else()
message(FATAL_ERROR "Cannot determine \"${VAR}\"")
endif()
else()
set(ENV{${VAR}} "${${VAR}}")
endif()
endmacro()
function(generate_winsdk_vfs_overlay winsdk_include_dir output_path)
set(include_dirs)
file(GLOB_RECURSE entries LIST_DIRECTORIES true "${winsdk_include_dir}/*")
foreach(entry ${entries})
if(IS_DIRECTORY "${entry}")
list(APPEND include_dirs "${entry}")
endif()
endforeach()
file(WRITE "${output_path}" "version: 0\n")
file(APPEND "${output_path}" "case-sensitive: false\n")
file(APPEND "${output_path}" "roots:\n")
foreach(dir ${include_dirs})
file(GLOB headers RELATIVE "${dir}" "${dir}/*.h")
if(NOT headers)
continue()
endif()
file(APPEND "${output_path}" " - name: \"${dir}\"\n")
file(APPEND "${output_path}" " type: directory\n")
file(APPEND "${output_path}" " contents:\n")
foreach(header ${headers})
file(APPEND "${output_path}" " - name: \"${header}\"\n")
file(APPEND "${output_path}" " type: file\n")
file(APPEND "${output_path}" " external-contents: \"${dir}/${header}\"\n")
endforeach()
endforeach()
endfunction()
function(generate_winsdk_lib_symlinks winsdk_um_lib_dir output_dir)
execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${output_dir}")
file(GLOB libraries RELATIVE "${winsdk_um_lib_dir}" "${winsdk_um_lib_dir}/*")
foreach(library ${libraries})
string(TOLOWER "${library}" symlink_name)
execute_process(COMMAND "${CMAKE_COMMAND}"
-E create_symlink
"${winsdk_um_lib_dir}/${library}"
"${output_dir}/${symlink_name}")
endforeach()
endfunction()
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_VERSION 10.0)
set(CMAKE_SYSTEM_PROCESSOR AMD64)
cmake_getconf(HOST_ARCH)
cmake_getconf(MSVC_BASE)
cmake_getconf(WINSDK_BASE)
cmake_getconf(WINSDK_VER)
cmake_getconf(LLVM_VER)
cmake_getconf(CLANG_VER)
cmake_getconf(LLVM_PATH)
if(LLVM_VER STREQUAL "")
set(LLVM_VER 11)
message(STATUS "LLVM_VER not set assuming version ${LLVM_VER}")
endif()
if(CLANG_VER STREQUAL "")
set(CLANG_VER 11)
message(STATUS "CLANG_VER not set assuming version ${CLANG_VER}")
endif()
if(NOT HOST_ARCH)
set(HOST_ARCH x86_64)
endif()
if(HOST_ARCH STREQUAL "aarch64" OR HOST_ARCH STREQUAL "arm64")
set(TRIPLE_ARCH "aarch64")
set(WINSDK_ARCH "arm64")
elseif(HOST_ARCH STREQUAL "armv7" OR HOST_ARCH STREQUAL "arm")
set(TRIPLE_ARCH "armv7")
set(WINSDK_ARCH "arm")
elseif(HOST_ARCH STREQUAL "i686" OR HOST_ARCH STREQUAL "x86")
set(TRIPLE_ARCH "i686")
set(WINSDK_ARCH "x86")
elseif(HOST_ARCH STREQUAL "x86_64" OR HOST_ARCH STREQUAL "x64")
set(TRIPLE_ARCH "x86_64")
set(WINSDK_ARCH "x64")
else()
message(SEND_ERROR "Unknown host architecture ${HOST_ARCH}. Must be aarch64 (or arm64), armv7 (or arm), i686 (or x86), or x86_64 (or x64).")
endif()
set(MSVC_INCLUDE "${MSVC_BASE}/include")
set(MSVC_LIB "${MSVC_BASE}/lib")
set(WINSDK_INCLUDE "${WINSDK_BASE}/Include/${WINSDK_VER}")
set(WINSDK_LIB "${WINSDK_BASE}/Lib/${WINSDK_VER}")
if(NOT EXISTS "${MSVC_BASE}" OR
NOT EXISTS "${MSVC_INCLUDE}" OR
NOT EXISTS "${MSVC_LIB}")
message(SEND_ERROR
"CMake variable MSVC_BASE must point to a folder containing MSVC "
"system headers and libraries")
endif()
if(NOT EXISTS "${WINSDK_BASE}" OR
NOT EXISTS "${WINSDK_INCLUDE}" OR
NOT EXISTS "${WINSDK_LIB}")
message(SEND_ERROR
"CMake variable WINSDK_BASE and WINSDK_VER must resolve to a valid "
"Windows SDK installation")
endif()
if(NOT EXISTS "${WINSDK_INCLUDE}/um/Windows.h")
message(SEND_ERROR "Cannot find Windows.h")
endif()
if(NOT EXISTS "${WINSDK_INCLUDE}/um/WINDOWS.H")
set(case_sensitive_filesystem TRUE)
endif()
# Attempt to find the clang-cl binary
find_program(CLANG_CL_PATH NAMES clang-cl-${CLANG_VER} clang-cl PATHS ${LLVM_PATH})
if(${CLANG_CL_PATH} STREQUAL "CLANG_CL_PATH-NOTFOUND")
message(SEND_ERROR "Unable to find clang-cl-${CLANG_VER}")
endif()
# Attempt to find the llvm-link binary
find_program(LLD_LINK_PATH NAMES lld-link-${LLVM_VER} lld-link PATHS ${LLVM_PATH})
if(${LLD_LINK_PATH} STREQUAL "LLD_LINK_PATH-NOTFOUND")
message(SEND_ERROR "Unable to find lld-link-${LLVM_VER}")
endif()
# Attempt to find the lld-lib binary
find_program(LLVM_LIB_PATH NAMES llvm-lib-${LLVM_VER} llvm-lib PATHS ${LLVM_PATH})
if(${LLVM_LIB_PATH} STREQUAL "LLVM_LIB_PATH-NOTFOUND")
message(SEND_ERROR "Unable to find llvm-lib-${LLVM_VER}")
endif()
# Attempt to find the llvm-nm binary
find_program(LLVM_NM_PATH NAMES llvm-nm-${LLVM_VER} llvm-nm PATHS ${LLVM_PATH})
if(${LLVM_NM_PATH} STREQUAL "LLVM_NM_PATH-NOTFOUND")
message(SEND_ERROR "Unable to find llvm-nm-${LLVM_VER}")
endif()
# Attempt to find the llvm-mt binary
find_program(LLVM_MT_PATH NAMES llvm-mt-${LLVM_VER} llvm-mt PATHS ${LLVM_PATH})
#set(LLVM_MT_PATH "${CMAKE_CURRENT_LIST_DIR}/llvm-mt-wrapper")
if(${LLVM_MT_PATH} STREQUAL "LLVM_MT_PATH-NOTFOUND")
message(SEND_ERROR "Unable to find llvm-mt-${LLVM_VER}")
endif()
# Attempt to find the native clang binary
find_program(CLANG_C_PATH NAMES clang-${CLANG_VER} clang PATHS ${LLVM_PATH})
if(${CLANG_C_PATH} STREQUAL "CLANG_C_PATH-NOTFOUND")
message(SEND_ERROR "Unable to find clang-${CLANG_VER}")
endif()
# Attempt to find the native clang++ binary
find_program(CLANG_CXX_PATH NAMES clang++-${CLANG_VER} clang++ PATHS ${LLVM_PATH})
if(${CLANG_CXX_PATH} STREQUAL "CLANG_CXX_PATH-NOTFOUND")
message(SEND_ERROR "Unable to find clang++-${CLANG_VER}")
endif()
# Attempt to find the llvm-rc binary
find_program(LLVM_RC_PATH NAMES llvm-rc-${LLVM_VER} llvm-rc PATHS ${LLVM_PATH})
if(${LLVM_RC_PATH} STREQUAL "LLVM_RC_PATH-NOTFOUND")
message(SEND_ERROR "Unable to find rc")
endif()
set(CMAKE_C_COMPILER "${CLANG_CL_PATH}" CACHE FILEPATH "")
set(CMAKE_CXX_COMPILER "${CLANG_CL_PATH}" CACHE FILEPATH "")
set(CMAKE_RC_COMPILER "${LLVM_RC_PATH}" CACHE FILEPATH "")
set(CMAKE_LINKER "${LLD_LINK_PATH}" CACHE FILEPATH "")
set(CMAKE_AR "${LLVM_LIB_PATH}" CACHE FILEPATH "")
set(CMAKE_NM "${LLVM_NM_PATH}" CACHE FILEPATH "")
set(CMAKE_MT "${LLVM_MT_PATH}" CACHE FILEPATH "")
# Even though we're cross-compiling, we need some native tools (e.g. llvm-tblgen), and those
# native tools have to be built before we can start doing the cross-build. LLVM supports
# a CROSS_TOOLCHAIN_FLAGS_NATIVE argument which consists of a list of flags to pass to CMake
# when configuring the NATIVE portion of the cross-build. By default we construct this so
# that it points to the tools in the same location as the native clang-cl that we're using.
list(APPEND _CTF_NATIVE_DEFAULT "-DCMAKE_ASM_COMPILER=${CLANG_C_PATH}")
list(APPEND _CTF_NATIVE_DEFAULT "-DCMAKE_C_COMPILER=${CLANG_C_PATH}")
list(APPEND _CTF_NATIVE_DEFAULT "-DCMAKE_CXX_COMPILER=${CLANG_CXX_PATH}")
set(CROSS_TOOLCHAIN_FLAGS_NATIVE "${_CTF_NATIVE_DEFAULT}" CACHE STRING "")
set(COMPILE_FLAGS
-Xclang -fexceptions -Xclang -fcxx-exceptions -Xclang
-D_CRT_SECURE_NO_WARNINGS
--target=${TRIPLE_ARCH}-windows-msvc
-fms-compatibility-version=19.11
-Wno-unused-command-line-argument # Needed to accept projects pushing both -Werror and /MP
-imsvc "${MSVC_INCLUDE}"
-imsvc "${WINSDK_INCLUDE}/ucrt"
-imsvc "${WINSDK_INCLUDE}/shared"
-imsvc "${WINSDK_INCLUDE}/um"
-imsvc "${WINSDK_INCLUDE}/winrt")
link_libraries(user32 kernel32 shell32 ole32)
if(case_sensitive_filesystem)
# Ensure all sub-configures use the top-level VFS overlay instead of generating their own.
init_user_prop(winsdk_vfs_overlay_path)
if(NOT winsdk_vfs_overlay_path)
set(winsdk_vfs_overlay_path "${CMAKE_BINARY_DIR}/winsdk_vfs_overlay.yaml")
generate_winsdk_vfs_overlay("${WINSDK_BASE}/Include/${WINSDK_VER}" "${winsdk_vfs_overlay_path}")
init_user_prop(winsdk_vfs_overlay_path)
endif()
list(APPEND COMPILE_FLAGS
-Xclang -ivfsoverlay -Xclang "${winsdk_vfs_overlay_path}")
set(CMAKE_CLANG_VFS_OVERLAY "${winsdk_vfs_overlay_path}")
endif()
string(REPLACE ";" " " COMPILE_FLAGS "${COMPILE_FLAGS}")
# We need to preserve any flags that were passed in by the user. However, we
# can't append to CMAKE_C_FLAGS and friends directly, because toolchain files
# will be re-invoked on each reconfigure and therefore need to be idempotent.
# The assignments to the _INITIAL cache variables don't use FORCE, so they'll
# only be populated on the initial configure, and their values won't change
# afterward.
set(_CMAKE_RC_FLAGS_INITIAL -I "${MSVC_INCLUDE}"
-I "${WINSDK_INCLUDE}/ucrt"
-I "${WINSDK_INCLUDE}/shared"
-I "${WINSDK_INCLUDE}/um"
-I "${WINSDK_INCLUDE}/winrt")
string(REPLACE ";" " " _CMAKE_RC_FLAGS_INITIAL "${_CMAKE_RC_FLAGS_INITIAL}")
set(CMAKE_RC_FLAGS "${_CMAKE_RC_FLAGS_INITIAL}" CACHE STRING "" FORCE)
set(_CMAKE_C_FLAGS_INITIAL "${CMAKE_C_FLAGS}" CACHE STRING "")
set(CMAKE_C_FLAGS "${_CMAKE_C_FLAGS_INITIAL} ${COMPILE_FLAGS}" CACHE STRING "" FORCE)
set(_CMAKE_CXX_FLAGS_INITIAL "${CMAKE_CXX_FLAGS}" CACHE STRING "")
set(CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS_INITIAL} ${COMPILE_FLAGS}" CACHE STRING "" FORCE)
set(LINK_FLAGS
# Prevent CMake from attempting to invoke mt.exe. It only recognizes the slashed form and not the dashed form.
#/manifest:no
-libpath:"${MSVC_LIB}/${WINSDK_ARCH}"
-libpath:"${WINSDK_LIB}/ucrt/${WINSDK_ARCH}"
-libpath:"${WINSDK_LIB}/um/${WINSDK_ARCH}")
if(case_sensitive_filesystem)
# Ensure all sub-configures use the top-level symlinks dir instead of generating their own.
init_user_prop(winsdk_lib_symlinks_dir)
if(NOT winsdk_lib_symlinks_dir)
set(winsdk_lib_symlinks_dir "${CMAKE_BINARY_DIR}/winsdk_lib_symlinks")
generate_winsdk_lib_symlinks("${WINSDK_BASE}/Lib/${WINSDK_VER}/um/${WINSDK_ARCH}" "${winsdk_lib_symlinks_dir}")
init_user_prop(winsdk_lib_symlinks_dir)
endif()
list(APPEND LINK_FLAGS
-libpath:"${winsdk_lib_symlinks_dir}")
endif()
string(REPLACE ";" " " LINK_FLAGS "${LINK_FLAGS}")
# See explanation for compiler flags above for the _INITIAL variables.
set(_CMAKE_EXE_LINKER_FLAGS_INITIAL "${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "")
set(CMAKE_EXE_LINKER_FLAGS "${_CMAKE_EXE_LINKER_FLAGS_INITIAL} ${LINK_FLAGS}" CACHE STRING "" FORCE)
set(_CMAKE_MODULE_LINKER_FLAGS_INITIAL "${CMAKE_MODULE_LINKER_FLAGS}" CACHE STRING "")
set(CMAKE_MODULE_LINKER_FLAGS "${_CMAKE_MODULE_LINKER_FLAGS_INITIAL} ${LINK_FLAGS}" CACHE STRING "" FORCE)
set(_CMAKE_SHARED_LINKER_FLAGS_INITIAL "${CMAKE_SHARED_LINKER_FLAGS}" CACHE STRING "")
set(CMAKE_SHARED_LINKER_FLAGS "${_CMAKE_SHARED_LINKER_FLAGS_INITIAL} ${LINK_FLAGS}" CACHE STRING "" FORCE)
# CMake populates these with a bunch of unnecessary libraries, which requires
# extra case-correcting symlinks and what not. Instead, let projects explicitly
# control which libraries they require.
set(CMAKE_C_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
if(NOT $ENV{VCPKG_TOOLCHAIN} STREQUAL "")
message(STATUS "Included VCPKG: $ENV{VCPKG_TOOLCHAIN}")
include($ENV{VCPKG_TOOLCHAIN})
endif()

View file

@ -64,6 +64,7 @@ elseif (GEODE_TARGET_PLATFORM STREQUAL "Win32")
${GEODE_LOADER_PATH}/include/link/libcocos2d.lib
${GEODE_LOADER_PATH}/include/link/libExtensions.lib
${GEODE_LOADER_PATH}/include/link/libcurl.lib
${GEODE_LOADER_PATH}/include/link/gdstring.lib
)
# Windows links against .lib and not .dll

View file

@ -8,12 +8,18 @@ namespace { namespace format_strings {
)GEN";
char const* class_includes = R"GEN(#pragma once
#include <Geode/platform/platform.hpp>
#include <Geode/c++stl/gdstdlib.hpp>
#include <cocos2d.h>
#include <cocos-ext.h>
#include <Geode/GeneratedPredeclare.hpp>
#include <Geode/Enums.hpp>
)GEN";
char const* class_no_includes = R"GEN(#pragma once
#include <Geode/platform/platform.hpp>
)GEN";
char const* class_include_prereq = R"GEN(#include "{file_name}"
@ -76,7 +82,11 @@ std::string generateBindingHeader(Root& root, ghc::filesystem::path const& singl
);
std::string single_output;
single_output += format_strings::class_includes;
if (cls.name != "GDString") {
single_output += format_strings::class_includes;
} else {
single_output += format_strings::class_no_includes;
}
for (auto dep : cls.depends) {
if (can_find(dep, "cocos2d::")) continue;

View file

@ -1,10 +1,9 @@
// included by default in every geode project
#include <Geode/Loader.hpp>
GEODE_API bool GEODE_CALL geode_implicit_load(geode::Mod* m) {
geode::Mod::setSharedMod(m);
geode::log::releaseSchedules(m);
geode::Loader::get()->releaseScheduledFunctions(m);
return true;
geode::Mod::setSharedMod(m);
geode::log::releaseSchedules(m);
geode::Loader::get()->releaseScheduledFunctions(m);
return true;
}

View file

@ -1,2 +1,9 @@
#pragma once
#include <Geode/platform/platform.hpp>
#if defined(GEODE_IS_WINDOWS)
#include "msvcstl.hpp"
#else
#include "gnustl.hpp"
// #include "msvcstl.hpp"
#endif

View file

@ -1,14 +1,10 @@
#pragma once
#include <Geode/platform/platform.hpp>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
// #include <Geode/binding/GDString.hpp>
//#include "../utils/platform.hpp"
#include <Geode/binding/GDString.hpp>
namespace geode::base {
uintptr_t get();
@ -452,12 +448,12 @@ namespace gd {
}
}
operator std::vector<bool>() {
std::vector<bool> out;
for (auto i = m_start; i != m_end; ++i) {
out.push_back(*i);
}
return out;
vector(vector<bool> const& lol) : vector(std::vector<bool>(lol)) {}
vector() : vector(std::vector<bool>()) {}
~vector() {
delete[] m_start.m_bitptr;
}
operator std::vector<bool>() const {
@ -468,12 +464,14 @@ namespace gd {
return out;
}
vector(vector<bool> const& lol) : vector(std::vector<bool>(lol)) {}
_bit_reference operator[](size_t index) {
const auto real_index = index / sizeof(uintptr_t);
const auto offset = index % sizeof(uintptr_t);
return _bit_reference(&m_start.m_bitptr[real_index], 1UL << offset);
}
vector() : vector(std::vector<bool>()) {}
~vector() {
delete[] m_start.m_bitptr;
bool operator[](size_t index) const {
return const_cast<vector&>(*this)[index];
}
};
};
@ -526,6 +524,10 @@ namespace gd {
operator std::vector<T>() {
return m_internal;
}
void clear() {
m_internal.clear();
}
operator std::vector<T>() const {
return m_internal;
@ -570,6 +572,4 @@ namespace gd {
~map() {}
};
}
#else
namespace gd = std;
#endif

View file

@ -1,14 +1,11 @@
#pragma once
#include <Geode/platform/platform.hpp>
#include <algorithm>
#include <functional>
#include <map>
#include <Geode/binding/GDString.hpp>
#include <string>
#include <stdexcept>
#include <utility>
#include <map>
#include <vector>
// #include <Geode/binding/GDString.hpp>
#if defined(GEODE_IS_WINDOWS)
namespace gd {
struct InternalString {
@ -21,10 +18,20 @@ namespace gd {
size_t m_capacity;
};
class GEODE_DLL string : protected GDString {
class string : GDString {
private:
InternalString m_data;
char* get_data() {
if (m_data.m_capacity < 16) return m_data.m_storage;
return m_data.m_pointer;
}
const char* get_data() const {
if (m_data.m_capacity < 16) return m_data.m_storage;
return m_data.m_pointer;
}
public:
template <class... Params>
string(Params&&... params) {
@ -36,62 +43,60 @@ namespace gd {
(void)this->winAssign(val.c_str(), val.size());
}
template <class Param>
string& operator=(Param&& param) {
std::string val;
val = std::forward<Param>(param);
(void)this->winAssign(val.c_str(), val.size());
return *this;
}
~string() {
(void)this->winDtor();
}
/*template <class... Params>
decltype(auto) operator=(Params&&... params) ->
decltype(this->operator=(std::forward<Params>(params)...)) { auto val =
std::string(this->winCStr(), m_data.m_length);
val.operator=(std::forward<Params>(params)...);
(void)this->winAssign(val.c_str(), val.size());
}*/
template <class... Params>
string& operator=(Params&&... params) {
auto val = std::string(this->winCStr(), m_data.m_length);
val.operator=(std::forward<Params>(params)...);
(void)this->winAssign(val.c_str(), val.size());
return *this;
}
template <class... Params>
string& assign(Params&&... params) {
auto val = std::string(this->winCStr(), m_data.m_length);
val.assign(std::forward<Params>(params)...);
(void)this->winAssign(val.c_str(), val.size());
return *this;
}
char& at(size_t pos) {
if (pos >= m_data.m_length) throw std::out_of_range("gd::string::at");
return (*this)[pos];
}
char const& at(size_t pos) const {
if (pos >= m_data.m_length) throw std::out_of_range("gd::string::at");
return (*this)[pos];
}
char& operator[](size_t pos) {
return this->winCStr()[pos];
return this->get_data()[pos];
}
char const& operator[](size_t pos) const {
return this->winCStr()[pos];
return this->get_data()[pos];
}
char* data() {
return this->winCStr();
return this->get_data();
}
char const* data() const {
return this->winCStr();
return this->get_data();
}
char const* c_str() const {
return this->winCStr();
return this->get_data();
}
size_t size() const {
return m_data.m_length;
}
operator std::string() const {
return std::string(this->c_str(), this->size());
}
};
}
#endif
template <class T>
using vector = std::vector<T>;
template <class K, class V>
using map = std::map<K, V>;
}

View file

@ -113,10 +113,9 @@ public:
* @return A CCString pointer which is an autorelease object pointer,
* it means that you needn't do a release operation unless you retain it.
*/
static inline CCString* create(const gd::string& str) {
CCString* pRet = new CCString(str);
pRet->autorelease();
return pRet;
// Geode change: this is kind of a hack but i think it will work
static inline CCString* create(std::string const& str) {
return CCString::createWithData(reinterpret_cast<unsigned char const*>(str.c_str()), str.size());
}
/** create a string with format, it's similar with the c function 'sprintf', the default buffer size is (1024*100) bytes,

View file

@ -96,7 +96,7 @@ typedef FMOD_RESULT (F_CALL *FMOD_DSP_SYSTEM_MIX_CALLBACK) (FMOD_
typedef void * (F_CALL *FMOD_DSP_ALLOC_FUNC) (unsigned int size, FMOD_MEMORY_TYPE type, const char *sourcestr);
typedef void * (F_CALL *FMOD_DSP_REALLOC_FUNC) (void *ptr, unsigned int size, FMOD_MEMORY_TYPE type, const char *sourcestr);
typedef void (F_CALL *FMOD_DSP_FREE_FUNC) (void *ptr, FMOD_MEMORY_TYPE type, const char *sourcestr);
typedef void (F_CALL *FMOD_DSP_LOG_FUNC) (FMOD_DEBUG_FLAGS level, const char *file, int line, const char *function, const char *string, ...);
typedef void (F_CALL *FMOD_DSP_LOG_FUNC) (FMOD_DEBUG_FLAGS level, const char *file, int line, const char *function, const char *string);
typedef FMOD_RESULT (F_CALL *FMOD_DSP_GETSAMPLERATE_FUNC) (FMOD_DSP_STATE *dsp_state, int *rate);
typedef FMOD_RESULT (F_CALL *FMOD_DSP_GETBLOCKSIZE_FUNC) (FMOD_DSP_STATE *dsp_state, unsigned int *blocksize);
typedef FMOD_RESULT (F_CALL *FMOD_DSP_GETSPEAKERMODE_FUNC) (FMOD_DSP_STATE *dsp_state, FMOD_SPEAKERMODE *speakermode_mixer, FMOD_SPEAKERMODE *speakermode_output);

View file

@ -57,7 +57,7 @@ typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_COPYPORT_FUNC) (FMOD_OUTPUT
typedef FMOD_RESULT (F_CALL *FMOD_OUTPUT_REQUESTRESET_FUNC) (FMOD_OUTPUT_STATE *output_state);
typedef void * (F_CALL *FMOD_OUTPUT_ALLOC_FUNC) (unsigned int size, unsigned int align, const char *file, int line);
typedef void (F_CALL *FMOD_OUTPUT_FREE_FUNC) (void *ptr, const char *file, int line);
typedef void (F_CALL *FMOD_OUTPUT_LOG_FUNC) (FMOD_DEBUG_FLAGS level, const char *file, int line, const char *function, const char *string, ...);
typedef void (F_CALL *FMOD_OUTPUT_LOG_FUNC) (FMOD_DEBUG_FLAGS level, const char *file, int line, const char *function, const char *string);
/*
Output structures

View file

@ -35,7 +35,7 @@ namespace geode::core {
}
template <template <class, class...> class Conv, auto& Det, class Ret, class... Args>
static constexpr inline auto handler =
static inline auto handler =
Conv<Ret, Args...>::template get_wrapper<&impl::handler<Det, Ret, Args...>>();
template <template <class, class...> class Conv, auto& Det, class Ret, class... Args>

View file

@ -79,8 +79,6 @@ namespace geode {
void updateAllDependencies();
void releaseScheduledFunctions(Mod* mod);
friend class Mod;
friend class CustomLoader;
friend struct ModInfo;
@ -93,6 +91,9 @@ namespace geode {
void updateResourcePaths();
void updateModResources(Mod* mod);
// used internally in geode_implicit_load
void releaseScheduledFunctions(Mod* mod);
friend bool GEODE_CALL ::geode_implicit_load(Mod*);
public:

View file

@ -331,6 +331,7 @@ namespace geode {
template <class = void>
static inline GEODE_HIDDEN Mod* sharedMod = nullptr;
// used internally in geode_implicit_load
template <class = void>
static inline GEODE_HIDDEN void setSharedMod(Mod* mod) {
sharedMod<> = mod;

View file

@ -45,7 +45,7 @@ namespace geode {
* for things like storing the default value, broadcasting value change
* events, making the setting node etc.
*/
class GEODE_DLL Setting : public std::enable_shared_from_this<Setting> {
class Setting : public std::enable_shared_from_this<Setting> {
protected:
std::string m_key;
std::string m_modID;
@ -57,10 +57,12 @@ namespace geode {
);
public:
virtual ~Setting() = default;
GEODE_DLL virtual ~Setting() = default;
// Load from mod.json
static Result<std::shared_ptr<Setting>> parse(std::string const& key, ModJson const& json);
GEODE_DLL static Result<std::shared_ptr<Setting>> parse(
std::string const& key, ModJson const& json
);
// Load value from saved settings
virtual bool load(nlohmann::json const& json) = 0;
// Save setting value
@ -68,9 +70,9 @@ namespace geode {
virtual SettingNode* createNode(float width) = 0;
void valueChanged();
GEODE_DLL void valueChanged();
std::string getKey() const;
GEODE_DLL std::string getKey() const;
virtual SettingType getType() const = 0;
};
@ -314,9 +316,7 @@ namespace geode {
obj.has(json).into(m_##name); \
return Ok(); \
} \
bool has##Name() const { \
return m_##name; \
} \
bool has##Name() const { return m_##name; } \
}
class ICArrows {
@ -405,12 +405,12 @@ namespace geode {
GEODE_INT_DECL_SETTING_CONTROL(Input, hasInput, true, "input");
}
class GEODE_DLL BoolSetting : public GeodeSetting<BoolSetting, bool, SettingType::Bool> {
class BoolSetting : public GeodeSetting<BoolSetting, bool, SettingType::Bool> {
public:
SettingNode* createNode(float width) override;
GEODE_DLL SettingNode* createNode(float width) override;
};
class GEODE_DLL IntSetting :
class IntSetting :
public GeodeSetting<IntSetting, int64_t, SettingType::Int>,
public IOneOf<IntSetting, int64_t>,
public IMinMax<int64_t>,
@ -418,10 +418,10 @@ namespace geode {
public ICSlider<int64_t>,
public ICInput {
public:
SettingNode* createNode(float width) override;
GEODE_DLL SettingNode* createNode(float width) override;
};
class GEODE_DLL FloatSetting :
class FloatSetting :
public GeodeSetting<FloatSetting, double, SettingType::Float>,
public IOneOf<FloatSetting, double>,
public IMinMax<double>,
@ -429,34 +429,33 @@ namespace geode {
public ICSlider<double>,
public ICInput {
public:
SettingNode* createNode(float width) override;
GEODE_DLL SettingNode* createNode(float width) override;
};
class GEODE_DLL StringSetting :
class StringSetting :
public GeodeSetting<StringSetting, std::string, SettingType::String>,
public IOneOf<StringSetting, std::string>,
public IMatch<StringSetting, std::string> {
public:
SettingNode* createNode(float width) override;
GEODE_DLL SettingNode* createNode(float width) override;
};
class GEODE_DLL FileSetting :
class FileSetting :
public GeodeSetting<FileSetting, ghc::filesystem::path, SettingType::File>,
public ICFileFilters {
public:
SettingNode* createNode(float width) override;
GEODE_DLL SettingNode* createNode(float width) override;
};
class GEODE_DLL ColorSetting :
public GeodeSetting<ColorSetting, cocos2d::ccColor3B, SettingType::Color> {
class ColorSetting : public GeodeSetting<ColorSetting, cocos2d::ccColor3B, SettingType::Color> {
public:
SettingNode* createNode(float width) override;
GEODE_DLL SettingNode* createNode(float width) override;
};
class GEODE_DLL ColorAlphaSetting :
class ColorAlphaSetting :
public GeodeSetting<ColorAlphaSetting, cocos2d::ccColor4B, SettingType::ColorAlpha> {
public:
SettingNode* createNode(float width) override;
GEODE_DLL SettingNode* createNode(float width) override;
};
// these can't be member functions because C++ is single-pass >:(
@ -498,6 +497,7 @@ namespace geode {
static_assert(!std::is_same_v<T, T>, "Unsupported type for getting setting value!");
}
}
// clang-format on
}

View file

@ -10,24 +10,24 @@ namespace geode {
class GEODE_DLL SettingChangedEvent : public Event {
protected:
std::string m_modID;
std::shared_ptr<Setting> m_setting;
Setting* m_setting;
public:
SettingChangedEvent(std::string const& modID, std::shared_ptr<Setting> setting);
SettingChangedEvent(std::string const& modID, Setting* setting);
std::string getModID() const;
std::shared_ptr<Setting> getSetting() const;
Setting* getSetting() const;
};
template <typename T = Setting, typename = std::enable_if_t<std::is_base_of_v<Setting, T>>>
class SettingChangedFilter : public EventFilter<SettingChangedEvent> {
public:
using Callback = void(std::shared_ptr<T>);
using Callback = void(T*);
using Event = SettingChangedEvent;
ListenerResult handle(std::function<Callback> fn, SettingChangedEvent* event) {
if (m_modID == event->getModID() &&
(!m_targetKey || m_targetKey.value() == event->getSetting()->getKey())) {
fn(std::static_pointer_cast<T>(event->getSetting()));
fn(static_cast<T*>(event->getSetting()));
}
return ListenerResult::Propagate;
}
@ -54,7 +54,7 @@ namespace geode {
template <class T>
requires std::is_base_of_v<Setting, T> std::monostate listenForSettingChanges(
std::string const& settingID, void (*callback)(std::shared_ptr<T>)
std::string const& settingID, void (*callback)(T*)
) {
Loader::get()->scheduleOnModLoad(getMod(), [=]() {
static auto _ = EventListener(callback, SettingChangedFilter<T>(getMod()->getID(), settingID));
@ -62,7 +62,7 @@ namespace geode {
return std::monostate();
}
static std::monostate listenForAllSettingChanges(void (*callback)(std::shared_ptr<Setting>)) {
static std::monostate listenForAllSettingChanges(void (*callback)(Setting*)) {
Loader::get()->scheduleOnModLoad(getMod(), [=]() {
static auto _ = EventListener(callback, SettingChangedFilter(getMod()->getID()));
});

View file

@ -17,8 +17,8 @@ namespace geode::core::meta::x86 {
}
template <Ret (*detour)(Args...)>
static constexpr decltype(auto) get_wrapper() {
return &wrapper<detour>;
static auto get_wrapper() {
return reinterpret_cast<void*>(&wrapper<detour>);
}
};
}

View file

@ -11,8 +11,8 @@ namespace geode::core::meta {
}
template <Ret (*detour)(Args...)>
static constexpr decltype(auto) get_wrapper() {
return detour;
static auto get_wrapper() {
return reinterpret_cast<void*>(detour);
}
};
}

View file

@ -6,13 +6,20 @@
#include "x86.hpp"
namespace geode::core::meta::x86 {
template <class T>
concept MembercallStructReturn = std::is_class_v<T> && sizeof(T) > 8;
template <class Ret, class... Args>
class Membercall : public CallConv<Ret, Args...> {
private:
class Membercall {};
template <class Ret, class... Args>
requires (!MembercallStructReturn<Ret>)
class Membercall<Ret, Args...> : public CallConv<Ret, Args...> {
protected:
// Metaprogramming / typedefs we need for the rest of the class.
using MyConv = CallConv<Ret, Args...>;
private:
public:
class Sequences {
private:
// These are required for proper reordering.
@ -131,7 +138,7 @@ namespace geode::core::meta::x86 {
using from = typename MyConv::template arr_to_seq<from_arr>;
};
private:
protected:
// Where all the logic is actually implemented.
template <class Class, class>
class Impl {
@ -163,7 +170,7 @@ namespace geode::core::meta::x86 {
}
};
private:
protected:
// Putting it all together: instantiating Impl with our filters.
using MyImpl = Impl<typename Sequences::to, typename Sequences::from>;
@ -179,8 +186,64 @@ namespace geode::core::meta::x86 {
}
template <Ret (*detour)(Args...)>
static constexpr decltype(auto) get_wrapper() {
return &MyImpl::template wrapper<detour>;
static auto get_wrapper() {
return reinterpret_cast<void*>(&MyImpl::template wrapper<detour>);
}
};
template <class Ret, class Class, class... Args>
requires (MembercallStructReturn<Ret>)
class Membercall<Ret, Class, Args...> {
protected:
using Sequences = Membercall<Ret*, Class, Ret*, Args...>::Sequences;
// Where all the logic is actually implemented.
template <class Class, class>
class Impl {
static_assert(
always_false<Class>,
"Please report a bug to the Geode developers! This should never be reached.\n"
"SFINAE didn't reach the right overload!"
);
};
template <size_t... to, size_t... from>
class Impl<std::index_sequence<to...>, std::index_sequence<from...>> {
public:
static Ret* invoke(void* address, Tuple<Class, Ret*, Args..., float, int> const& all) {
return reinterpret_cast<Ret*(__vectorcall*)(
typename Tuple<Class, Ret*, Args..., float, int>::template type_at<to>...
)>(address)(all.template at<to>()...);
}
template <Ret (*detour)(Class, Args...)>
static Ret* __vectorcall wrapper(
/* It's wrapped to stop MSVC from giving me error messages with internal compiler
* info. WTF.
*/
typename Tuple<Class, Ret*, Args..., float, int>::template type_at_wrap<to>... raw
) {
auto all = Tuple<>::make(raw...);
return reinterpret_cast<Ret*(*)(Class, Ret*, Args...)>(detour)(all.template at<from>()...);
}
};
protected:
// Putting it all together: instantiating Impl with our filters.
using MyImpl = Impl<typename Sequences::to, typename Sequences::from>;
public:
static Ret invoke(void* address, Class inst, Args... all) {
Ret ret;
(void)MyImpl::invoke(address, { inst, &ret, all..., 314.0f, 314 });
return ret;
}
template <Ret (*detour)(Class, Args...)>
static auto get_wrapper() {
return reinterpret_cast<void*>(&MyImpl::template wrapper<detour>);
}
};
}

View file

@ -239,8 +239,8 @@ namespace geode::core::meta::x86 {
}
template <Ret (*detour)(Args...)>
static constexpr decltype(auto) get_wrapper() {
return &MyImpl::template wrapper<detour>;
static auto get_wrapper() {
return reinterpret_cast<void*>(&MyImpl::template wrapper<detour>);
}
};

View file

@ -17,8 +17,8 @@ namespace geode::core::meta::x86 {
}
template <Ret (*detour)(Args...)>
static constexpr decltype(auto) get_wrapper() {
return &wrapper<detour>;
static auto get_wrapper() {
return reinterpret_cast<void*>(&wrapper<detour>);
}
};
}

View file

@ -67,4 +67,5 @@
template <class> \
void _##Line_##Function()
#define $execute GEODE_EXECUTE_FUNC(__LINE__)
#define GEODE_EXECUTE_FUNC1(Line_) GEODE_EXECUTE_FUNC(Line_)
#define $execute GEODE_EXECUTE_FUNC1(__LINE__)

Binary file not shown.

View file

@ -59,7 +59,7 @@ static void updateIndexProgress(UpdateStatus status, std::string const& info, ui
template <class T = CCNode>
requires std::is_base_of_v<CCNode, T>
requires std::is_base_of_v<CCNode, T>
T* setIDSafe(CCNode* node, int index, char const* id) {
if constexpr (std::is_same_v<CCNode, T>) {
if (auto child = getChild(node, index)) {
@ -86,7 +86,6 @@ struct CustomMenuLayer : Modify<CustomMenuLayer, MenuLayer> {
bool init() {
if (!MenuLayer::init()) return false;
// set IDs to everything
this->setID("main-menu-layer");
setIDSafe(this, 0, "main-menu-bg");

View file

@ -126,6 +126,11 @@ void Index::updateIndex(IndexUpdateCallback callback, bool force) {
// gee i sure hope no one does 60 commits to the mod index an hour and download every
// single one of them
if (upcomingCommitSHA == "") {
auto err = this->updateIndexFromLocalCache();
if (!err) {
RETURN_ERROR(err.error());
}
m_upToDate = true;
m_updating = false;

View file

@ -42,6 +42,7 @@ static ModInfo getInternalModInfo() {
InternalMod::InternalMod() : Mod(getInternalModInfo()) {
m_saveDirPath = Loader::get()->getGeodeSaveDirectory() / GEODE_MOD_DIRECTORY / m_info.m_id;
ghc::filesystem::create_directories(m_saveDirPath);
// make sure spritesheets get added

View file

@ -37,9 +37,9 @@ void Loader::createDirectories() {
auto tempDir = this->getGeodeDirectory() / GEODE_TEMP_DIRECTORY;
auto confDir = this->getGeodeDirectory() / GEODE_CONFIG_DIRECTORY;
#ifdef GEODE_IS_MACOS
#ifdef GEODE_IS_MACOS
ghc::filesystem::create_directory(this->getSaveDirectory());
#endif
#endif
ghc::filesystem::create_directories(resDir);
ghc::filesystem::create_directory(confDir);
@ -426,13 +426,22 @@ ghc::filesystem::path Loader::getGameDirectory() const {
return ghc::filesystem::path(CCFileUtils::sharedFileUtils()->getWritablePath2().c_str());
}
#ifdef GEODE_IS_WINDOWS
#include <filesystem>
#endif
ghc::filesystem::path Loader::getSaveDirectory() const {
// not using ~/Library/Caches
#ifdef GEODE_IS_MACOS
// not using ~/Library/Caches
#ifdef GEODE_IS_MACOS
return ghc::filesystem::path("/Users/Shared/Geode");
#else
#elif defined(GEODE_IS_WINDOWS)
return ghc::filesystem::path(
std::filesystem::weakly_canonical(CCFileUtils::sharedFileUtils()->getWritablePath().c_str())
.string()
);
#else
return ghc::filesystem::path(CCFileUtils::sharedFileUtils()->getWritablePath().c_str());
#endif
#endif
}
ghc::filesystem::path Loader::getGeodeDirectory() const {

View file

@ -51,7 +51,7 @@ Result<std::shared_ptr<Setting>> Setting::parse(std::string const& key, ModJson
}
void Setting::valueChanged() {
SettingChangedEvent(m_modID, shared_from_this()).post();
SettingChangedEvent(m_modID, this).post();
}
SettingNode* BoolSetting::createNode(float width) {
@ -95,7 +95,7 @@ SettingNode* ColorAlphaSetting::createNode(float width) {
}
SettingChangedEvent::SettingChangedEvent(
std::string const& modID, std::shared_ptr<Setting> setting
std::string const& modID, Setting* setting
) :
m_modID(modID),
m_setting(setting) {}
@ -104,6 +104,6 @@ std::string SettingChangedEvent::getModID() const {
return m_modID;
}
std::shared_ptr<Setting> SettingChangedEvent::getSetting() const {
Setting* SettingChangedEvent::getSetting() const {
return m_setting;
}

View file

@ -96,9 +96,9 @@ BOOL WINAPI DllMain(HINSTANCE lib, DWORD reason, LPVOID) {
}
#endif
static auto _ = listenForSettingChanges(
static auto _ = listenForSettingChanges<BoolSetting>(
"show-platform-console",
+[](std::shared_ptr<BoolSetting> setting) {
[](BoolSetting* setting) {
if (setting->getValue()) {
Loader::get()->openPlatformConsole();
}
@ -118,6 +118,7 @@ int geodeEntry(void* platformData) {
"internal tools and Geode can not be loaded. "
"(InternalLoader::get returned nullptr)"
);
return 1;
}
if (!geode::core::hook::initialize()) {
@ -127,6 +128,7 @@ int geodeEntry(void* platformData) {
"internal tools and Geode can not be loaded. "
"(Unable to set up hook manager)"
);
return 1;
}
geode_implicit_load(InternalMod::get());

View file

@ -143,8 +143,7 @@ bool ModInfoLayer::init(ModObject* obj, ModListView* list) {
nameLabel->limitLabelWidth(200.f, .7f, .1f);
m_mainLayer->addChild(nameLabel, 2);
auto logoSpr = this->createLogoSpr(obj);
logoSpr->setScale(logoSize / logoSpr->getContentSize().width);
auto logoSpr = this->createLogoSpr(obj, { logoSize, logoSize });
m_mainLayer->addChild(logoSpr);
auto developerStr = "by " + m_info.m_developer;
@ -693,23 +692,25 @@ ModInfoLayer* ModInfoLayer::create(ModObject* obj, ModListView* list) {
return nullptr;
}
CCNode* ModInfoLayer::createLogoSpr(ModObject* modObj) {
CCNode* ModInfoLayer::createLogoSpr(ModObject* modObj, CCSize const& size) {
switch (modObj->m_type) {
case ModObjectType::Mod:
{
return ModInfoLayer::createLogoSpr(modObj->m_mod);
return ModInfoLayer::createLogoSpr(modObj->m_mod, size);
}
break;
case ModObjectType::Index:
{
return ModInfoLayer::createLogoSpr(modObj->m_index);
return ModInfoLayer::createLogoSpr(modObj->m_index, size);
}
break;
default:
{
auto spr = CCSprite::createWithSpriteFrameName("no-logo.png"_spr);
spr->setScaleX(size.width / spr->getContentSize().width);
spr->setScaleY(size.height / spr->getContentSize().height);
if (!spr) {
return CCLabelBMFont::create("OwO", "goldFont.fnt");
}
@ -719,7 +720,7 @@ CCNode* ModInfoLayer::createLogoSpr(ModObject* modObj) {
}
}
CCNode* ModInfoLayer::createLogoSpr(Mod* mod) {
CCNode* ModInfoLayer::createLogoSpr(Mod* mod, CCSize const& size) {
CCNode* spr = nullptr;
if (mod == Loader::getInternalMod()) {
spr = CCSprite::createWithSpriteFrameName("geode-logo.png"_spr);
@ -731,10 +732,12 @@ CCNode* ModInfoLayer::createLogoSpr(Mod* mod) {
}
if (!spr) spr = CCSprite::createWithSpriteFrameName("no-logo.png"_spr);
if (!spr) spr = CCLabelBMFont::create("OwO", "goldFont.fnt");
spr->setScaleX(size.width / spr->getContentSize().width);
spr->setScaleY(size.height / spr->getContentSize().height);
return spr;
}
CCNode* ModInfoLayer::createLogoSpr(IndexItem const& item) {
CCNode* ModInfoLayer::createLogoSpr(IndexItem const& item, CCSize const& size) {
CCNode* spr = nullptr;
auto logoPath = ghc::filesystem::absolute(item.m_path / "logo.png");
spr = CCSprite::create(logoPath.string().c_str());
@ -746,14 +749,26 @@ CCNode* ModInfoLayer::createLogoSpr(IndexItem const& item) {
}
if (Index::get()->isFeaturedItem(item.m_info.m_id)) {
auto glowSize = size + CCSize(4.f, 4.f);
auto logoGlow = CCSprite::createWithSpriteFrameName("logo-glow.png"_spr);
logoGlow->setScaleX(glowSize.width / logoGlow->getContentSize().width);
logoGlow->setScaleY(glowSize.height / logoGlow->getContentSize().height);
// i dont know why + 1 is needed and its too late for me to figure out why
spr->setPosition(
logoGlow->getContentSize().width / 2, logoGlow->getContentSize().height / 2
);
logoGlow->setContentSize(spr->getContentSize());
// scary mathematics
spr->setScaleX(size.width / spr->getContentSize().width / logoGlow->getScaleX());
spr->setScaleY(size.height / spr->getContentSize().height / logoGlow->getScaleY());
logoGlow->addChild(spr);
spr = logoGlow;
}
else {
spr->setScaleX(size.width / spr->getContentSize().width);
spr->setScaleY(size.height / spr->getContentSize().height);
}
return spr;
}

View file

@ -75,7 +75,7 @@ public:
static void showIssueReportPopup(ModInfo const& info);
static CCNode* createLogoSpr(ModObject* modObj);
static CCNode* createLogoSpr(Mod* mod);
static CCNode* createLogoSpr(IndexItem const& item);
static CCNode* createLogoSpr(ModObject* modObj, CCSize const& size);
static CCNode* createLogoSpr(Mod* mod, CCSize const& size);
static CCNode* createLogoSpr(IndexItem const& item, CCSize const& size);
};

View file

@ -164,9 +164,8 @@ void ModCell::loadFromObject(ModObject* modobj) {
auto logoSize = m_height / 1.5f;
auto logoSpr = ModInfoLayer::createLogoSpr(modobj);
auto logoSpr = ModInfoLayer::createLogoSpr(modobj, { logoSize, logoSize });
logoSpr->setPosition({ logoSize / 2 + 12.f, m_height / 2 });
logoSpr->setScale(logoSize / logoSpr->getContentSize().width);
m_mainLayer->addChild(logoSpr);
bool hasCategories = false;

View file

@ -68,9 +68,9 @@ static bool addFiltersToDialog(
std::vector<COMDLG_FILTERSPEC> specList {};
specList.reserve(filters.size() + 1);
for (auto& filter : wfilters) {
specList.emplace_back(
filter.first.c_str(),
filter.second.c_str()
specList.push_back(
{filter.first.c_str(),
filter.second.c_str()}
);
}
return SUCCEEDED(