Merge branch 'main' into layout

This commit is contained in:
HJfod 2022-11-22 17:24:03 +02:00
commit 182ced8e17
29 changed files with 597 additions and 197 deletions

View file

@ -17,7 +17,7 @@ jobs:
os_identifier: "win"
os: windows-2019
prefixes: ''
extra_flags: '-G "Visual Studio 16 2019" -T host=x86 -A win32'
extra_flags: '-G "Visual Studio 16 2019" -T host=x86 -A win32 -DGEODE_DEBUG=On'
out_paths: './bin/nightly/Geode.dll ./bin/nightly/GeodeBootstrapper.dll ./bin/nightly/Geode.lib ./bin/nightly/XInput9_1_0.dll'
cli_cmd: ''
@ -25,7 +25,7 @@ jobs:
os_identifier: "mac"
os: macos-latest
prefixes: 'PATH="/usr/local/opt/ccache/libexec:$PATH"'
extra_flags: "-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++"
extra_flags: "-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug -DGEODE_DEBUG=On"
out_paths: './bin/nightly/Geode.dylib ./bin/nightly/GeodeBootstrapper.dylib ./loader/include/link/libfmod.dylib'
cli_cmd: 'chmod +x $GITHUB_WORKSPACE/cli/geode'
@ -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

@ -8,13 +8,15 @@ project(geode-sdk VERSION ${GEODE_VERSION} LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (PROJECT_IS_TOP_LEVEL AND APPLE)
set(CMAKE_BUILD_TYPE Debug)
endif()
add_library(${PROJECT_NAME} INTERFACE)
if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
if (NOT DEFINED GEODE_DEBUG AND (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo))
set(GEODE_DEBUG ON)
endif()
# define it in command line or your project system
if (GEODE_DEBUG)
target_compile_definitions(${PROJECT_NAME} INTERFACE -DGEODE_DEBUG)
endif()
@ -23,10 +25,6 @@ set_target_properties(${PROJECT_NAME} PROPERTIES CMAKE_CONFIGURE_DEPENDS VERSION
target_compile_definitions(${PROJECT_NAME} INTERFACE -DPROJECT_NAME=${CMAKE_PROJECT_NAME})
if (GEODE_DEBUG)
target_compile_definitions(${PROJECT_NAME} INTERFACE GEODE_DEBUG)
endif()
set(GEODE_CODEGEN_PATH ${CMAKE_CURRENT_BINARY_DIR}/codegenned)
set(GEODE_BIN_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(GEODE_LOADER_PATH ${CMAKE_CURRENT_SOURCE_DIR}/loader)
@ -37,13 +35,20 @@ include(cmake/Platform.cmake)
target_sources(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/entry.cpp)
add_subdirectory(codegen)
include(ExternalProject)
set(GEODE_CODEGEN_BINARY_OUT ${CMAKE_CURRENT_BINARY_DIR}/codegen)
ExternalProject_Add(CodegenProject
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/codegen
CMAKE_CACHE_ARGS "-DCMAKE_INSTALL_PREFIX:STRING=${GEODE_CODEGEN_BINARY_OUT}"
)
add_custom_command(
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bindings/GeometryDash.bro
${CMAKE_CURRENT_SOURCE_DIR}/bindings/Cocos2d.bro
${CMAKE_CURRENT_SOURCE_DIR}/bindings/Entry.bro
COMMAND Codegen ${GEODE_TARGET_PLATFORM} bindings ${GEODE_CODEGEN_PATH}
DEPENDS CodegenProject
COMMAND ${GEODE_CODEGEN_BINARY_OUT}/Codegen ${GEODE_TARGET_PLATFORM} bindings ${GEODE_CODEGEN_PATH}
COMMAND echo codegen > ${GEODE_CODEGEN_PATH}/.stamp
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Run Codegen"
@ -74,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;
@ -831,6 +830,7 @@ class CountTriggerAction : cocos2d::CCNode {
int m_targetCount;
int m_targetID;
bool m_activateGroup;
bool m_multiActivate;
}
class CreateGuidelinesLayer : FLAlertLayer, FLAlertLayerProtocol {
@ -1222,7 +1222,6 @@ class EditorUI : cocos2d::CCLayer, FLAlertLayerProtocol, ColorSelectDelegate, GJ
void editObject2(cocos2d::CCObject* sender) = win 0x8d1b0;
void editGroup(cocos2d::CCObject* sender) = win 0x8d720;
void moveObjectCall(cocos2d::CCObject* sender) = mac 0x29830, win 0x8db30;
void moveObjectCall(EditCommand command) = win 0x8db30;
void transformObjectCall(cocos2d::CCObject* sender) = mac 0x29860, win 0x8def0;
void onDelete(cocos2d::CCObject* sender) = mac 0x1b3d0, win 0x7b8d0;
void onDeleteSelected(cocos2d::CCObject* sender) = mac 0xb990, win 0x7bf50;
@ -4205,7 +4204,7 @@ class PlayLayer : GJBaseGameLayer, CCCircleWaveDelegate, CurrencyRewardDelegate,
return GameManager::sharedState()->getPlayLayer();
}
PlayLayer() = win 0x1FAA90;
PlayLayer() = mac 0x80e20, win 0x1faa90;
void addCircle(CCCircleWave*) = mac 0x7e0f0;
void addObject(GameObject*) = mac 0x70e50, win 0x2017e0;
@ -5315,7 +5314,11 @@ class TextArea : cocos2d::CCSprite {
virtual void draw() {}
virtual void setOpacity(unsigned char) = mac 0x19f760, win 0x33800;
bool init(gd::string str, char const* font, float width, float height, cocos2d::CCPoint anchor, float scale, bool disableColor) = mac 0x19ec70, win 0x33370, ios 0x92444;
<<<<<<< HEAD
static TextArea* create(gd::string str, char const* font, float width, float height, cocos2d::CCPoint anchor, float scale, bool disableColor) = mac 0x19eb40, win 0x33270;
=======
static TextArea* create(gd::string str, char const* font, float scale, float width, cocos2d::CCPoint anchor, float height, bool disableColor) = mac 0x19eb40, win 0x33270;
>>>>>>> main
void colorAllCharactersTo(cocos2d::ccColor3B color) = win 0x33830;
void setString(gd::string str) = mac 0x19eda0, win 0x33480;

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

@ -4,6 +4,8 @@ project(Codegen LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
add_subdirectory(Broma)
add_subdirectory(../fmt ${CMAKE_CURRENT_BINARY_DIR}/fmt)
add_subdirectory(../filesystem ${CMAKE_CURRENT_BINARY_DIR}/fs)
file(GLOB SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
@ -17,4 +19,6 @@ target_include_directories(Codegen PRIVATE
target_precompile_headers(Codegen PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/Shared.hpp
)
)
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})

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,16 +1,16 @@
#pragma once
#include <broma.hpp>
#include <array>
#include <broma.hpp>
#include <fmt/format.h>
#include <fmt/ranges.h>
#include <fstream>
#include <fs/filesystem.hpp> // bruh
#include <fstream>
using std::istreambuf_iterator;
#ifdef _MSC_VER
#pragma warning(disable: 4996)
#pragma warning(disable : 4996)
#endif
#if _WIN32
@ -57,59 +57,57 @@ enum class BindStatus {
Unbindable
};
struct codegen_error : std::runtime_error {
inline codegen_error(char const* msg) : std::runtime_error(msg) {}
};
namespace codegen {
template <typename ...Args>
template <typename... Args>
inline codegen_error error(Args... args) {
return codegen_error(fmt::format(args...).c_str());
}
inline Platform platform;
inline Platform platform;
inline uintptr_t platformNumber(PlatformNumber const& p) {
inline uintptr_t platformNumber(PlatformNumber const& p) {
switch (codegen::platform) {
case Platform::Mac:
return p.mac;
case Platform::Windows:
return p.win;
case Platform::iOS:
return p.ios;
case Platform::Android:
return p.android;
case Platform::Mac: return p.mac;
case Platform::Windows: return p.win;
case Platform::iOS: return p.ios;
case Platform::Android: return p.android;
default: // unreachable
return p.win;
}
}
inline BindStatus getStatus(Field const& field) {
const FunctionBegin* fb;
FunctionBegin const* fb;
if (auto fn = field.get_as<FunctionBindField>()) {
if (platformNumber(fn->binds))
return BindStatus::NeedsBinding;
if (platformNumber(fn->binds)) return BindStatus::NeedsBinding;
fb = &fn->beginning;
} else if (auto fn = field.get_as<OutOfLineField>()) {
}
else if (auto fn = field.get_as<OutOfLineField>()) {
fb = &fn->beginning;
} else return BindStatus::Unbindable;
}
else return BindStatus::Unbindable;
// if (field.parent.rfind("GDString", 0) == 0) return BindStatus::NeedsBinding;
if (platform == Platform::Android) {
for (auto& [type, name] : fb->args) {
if (type.name.find("gd::") != std::string::npos)
return BindStatus::NeedsBinding;
if (type.name.find("gd::") != std::string::npos) return BindStatus::NeedsBinding;
}
if (field.parent.rfind("cocos2d::CCEGLView", 0) == 0) return BindStatus::Unbindable;
return BindStatus::Binded;
}
if (fb->type == FunctionType::Normal) {
if (field.parent.rfind("fmod::", 0) == 0)
return BindStatus::Binded;
if (field.parent.rfind("fmod::", 0) == 0) return BindStatus::Binded;
if (field.parent.rfind("cocos2d::", 0) == 0 && platform == Platform::Windows)
return BindStatus::Binded;
}
@ -148,26 +146,24 @@ namespace codegen {
}
inline std::string getConvention(Field& f) {
if (codegen::platform != Platform::Windows)
return "DefaultConv";
if (codegen::platform != Platform::Windows) return "DefaultConv";
if (auto fn = f.get_fn()) {
auto status = getStatus(f);
if (fn->is_static) {
if (status == BindStatus::Binded)
return "x86::Cdecl";
else
return "x86::Optcall";
} else if (fn->is_virtual) {
return "x86::Thiscall";
} else {
if (status == BindStatus::Binded)
return "x86::Thiscall";
else
return "x86::Membercall";
if (status == BindStatus::Binded) return "x86::Cdecl";
else return "x86::Optcall";
}
} else throw codegen::error("Tried to get convention of non-function");
else if (fn->is_virtual) {
return "x86::Thiscall";
}
else {
if (status == BindStatus::Binded) return "x86::Thiscall";
else return "x86::Membercall";
}
}
else throw codegen::error("Tried to get convention of non-function");
}
inline std::string getUnqualifiedClassName(std::string const& s) {

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();
@ -570,6 +566,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

@ -25,12 +25,12 @@ THE SOFTWARE.
#ifndef __CCMOTION_STREAK_H__
#define __CCMOTION_STREAK_H__
#include "../include/CCProtocols.h"
#include "../textures/CCTexture2D.h"
#include "../include/ccTypes.h"
#include "../base_nodes/CCNode.h"
#include "../include/CCProtocols.h"
#include "../include/ccTypes.h"
#include "../textures/CCTexture2D.h"
#ifdef EMSCRIPTEN
#include "../base_nodes/CCGLBufferedNode.h"
#include "../base_nodes/CCGLBufferedNode.h"
#endif // EMSCRIPTEN
NS_CC_BEGIN
@ -43,11 +43,15 @@ NS_CC_BEGIN
/** MotionStreak.
Creates a trailing path.
*/
class CC_DLL CCMotionStreak : public CCNodeRGBA, public CCTextureProtocol
class CC_DLL CCMotionStreak :
public CCNodeRGBA,
public CCTextureProtocol
#ifdef EMSCRIPTEN
, public CCGLBufferedNode
,
public CCGLBufferedNode
#endif // EMSCRIPTEN
{
public:
/**
* @js ctor
@ -59,15 +63,27 @@ public:
*/
virtual ~CCMotionStreak();
/** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename */
static CCMotionStreak* create(float fade, float minSeg, float stroke, const ccColor3B& color, const char* path);
/** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture */
static CCMotionStreak* create(float fade, float minSeg, float stroke, const ccColor3B& color, CCTexture2D* texture);
/** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's
* width, color, texture filename */
static CCMotionStreak* create(
float fade, float minSeg, float stroke, ccColor3B const& color, char const* path
);
/** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's
* width, color, texture */
static CCMotionStreak* create(
float fade, float minSeg, float stroke, ccColor3B const& color, CCTexture2D* texture
);
/** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture filename */
bool initWithFade(float fade, float minSeg, float stroke, const ccColor3B& color, const char* path);
/** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture */
bool initWithFade(float fade, float minSeg, float stroke, const ccColor3B& color, CCTexture2D* texture);
/** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color
* and texture filename */
bool initWithFade(
float fade, float minSeg, float stroke, ccColor3B const& color, char const* path
);
/** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color
* and texture */
bool initWithFade(
float fade, float minSeg, float stroke, ccColor3B const& color, CCTexture2D* texture
);
/** color used for the tint */
void tintWithColor(ccColor3B colors);
@ -76,13 +92,13 @@ public:
void reset();
/** Override super methods */
virtual void setPosition(const CCPoint& position);
virtual void setPosition(CCPoint const& position);
virtual void draw();
virtual void update(float delta);
/* Implement interfaces */
virtual CCTexture2D* getTexture(void);
virtual void setTexture(CCTexture2D *texture);
virtual void setTexture(CCTexture2D* texture);
/**
* @js NA
*/
@ -96,24 +112,28 @@ public:
virtual void setOpacityModifyRGB(bool bValue);
virtual bool isOpacityModifyRGB(void);
RT_ADD(
void resumeStroke();
void stopStroke();
);
RT_ADD(void resumeStroke(); void stopStroke(););
/** When fast mode is enabled, new points are added faster but with lower precision */
inline bool isFastMode() { return m_bFastMode; }
inline void setFastMode(bool bFastMode) { m_bFastMode = bFastMode; }
inline bool isStartingPositionInitialized() { return m_bStartingPositionInitialized; }
inline void setStartingPositionInitialized(bool bStartingPositionInitialized)
{
m_bStartingPositionInitialized = bStartingPositionInitialized;
inline bool isFastMode() {
return m_bFastMode;
}
inline void setFastMode(bool bFastMode) {
m_bFastMode = bFastMode;
}
inline bool isStartingPositionInitialized() {
return m_bStartingPositionInitialized;
}
inline void setStartingPositionInitialized(bool bStartingPositionInitialized) {
m_bStartingPositionInitialized = bStartingPositionInitialized;
}
protected:
bool m_bFastMode;
bool m_bStartingPositionInitialized;
private:
/** texture used for the motion streak */
CCTexture2D* m_pTexture;
ccBlendFunc m_tBlendFunc;

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

@ -94,8 +94,6 @@ namespace geode {
void updateAllDependencies();
void releaseScheduledFunctions(Mod* mod);
friend class Mod;
friend class CustomLoader;
friend struct ModInfo;
@ -107,6 +105,9 @@ namespace geode {
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

@ -350,6 +350,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(), [=]() {
new EventListener(
@ -64,7 +64,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(), [=]() {
new EventListener(
callback, SettingChangedFilter(getMod()->getID())

View file

@ -1,6 +1,7 @@
#pragma once
#include "Ref.hpp"
#include "casts.hpp"
#include <Geode/DefaultInclude.hpp>
#include <cocos2d.h>
@ -179,6 +180,33 @@ namespace geode::cocos {
*/
GEODE_DLL cocos2d::CCNode* getChildByTagRecursive(cocos2d::CCNode* node, int tag);
/**
* Get first node that conforms to the predicate
* by traversing children recursively
*
* @param node Parent node
* @param predicate Predicate used to evaluate nodes
* @return Child node if one is found, or null if
* there is none
*/
template <class Type = cocos2d::CCNode>
Type* findFirstChildRecursive(cocos2d::CCNode* node, std::function<bool(Type*)> predicate) {
if (cast::safe_cast<Type*>(node) && predicate(static_cast<Type*>(node)))
return static_cast<Type*>(node);
auto children = node->getChildren();
if (!children) return nullptr;
for (int i = 0; i < children->count(); ++i) {
auto newParent = static_cast<cocos2d::CCNode*>(children->objectAtIndex(i));
auto child = findFirstChildRecursive(newParent, predicate);
if (child)
return child;
}
return nullptr;
}
/**
* Checks if a given file exists in CCFileUtils
* search paths.

Binary file not shown.

View file

@ -70,6 +70,11 @@ public:
#include <Geode/modify/CCNode.hpp>
struct ProxyCCNode : Modify<ProxyCCNode, CCNode> {
virtual CCObject* getUserObject() {
if (static_cast<CCObject*>(this) == static_cast<CCObject*>(CCDirector::get())) {
// apparently this function is the same as
// CCDirector::getNextScene so yeah
return m_pUserObject;
}
return GeodeNodeMetadata::set(this)->m_userObject;
}
virtual void setUserObject(CCObject* obj) {

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);
@ -468,13 +468,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

@ -4,11 +4,14 @@
#include <Geode/loader/Log.hpp>
#include <Geode/loader/Mod.hpp>
#include <Geode/loader/SettingEvent.hpp>
#include <Geode/loader/Setting.hpp>
#include <Geode/loader/IPC.hpp>
#include <InternalLoader.hpp>
#include <InternalMod.hpp>
#include <array>
USE_GEODE_NAMESPACE();
int geodeEntry(void* platformData);
// platform-specific entry points
@ -101,7 +104,7 @@ BOOL WINAPI DllMain(HINSTANCE lib, DWORD reason, LPVOID) {
static auto $_ = listenForSettingChanges(
"show-platform-console",
+[](std::shared_ptr<BoolSetting> setting) {
[](BoolSetting* setting) {
if (setting->getValue()) {
Loader::get()->openPlatformConsole();
}
@ -138,6 +141,7 @@ int geodeEntry(void* platformData) {
"internal tools and Geode can not be loaded. "
"(InternalLoader::get returned nullptr)"
);
return 1;
}
if (!geode::core::hook::initialize()) {
@ -147,6 +151,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

@ -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(