Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
push:
branches:
- main
- '**'
jobs:
build:
strategy:
Expand Down Expand Up @@ -33,6 +33,10 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Update Submodule
run: |
git submodule update --init --recursive

- name: Build the mod
uses: geode-sdk/build-geode-mod@main
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "libs/socket.io-client-cpp"]
path = libs/socket.io-client-cpp
url = https://github.com/socketio/socket.io-client-cpp
[submodule "libs/pl_mpeg"]
path = libs/pl_mpeg
url = https://github.com/phoboslab/pl_mpeg
Expand Down
41 changes: 35 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
include(cmake/CPM.cmake)

if(NOT DEFINED GEODE_TARGET_PLATFORM)
set(GEODE_TARGET_PLATFORM "Win64")
Expand Down Expand Up @@ -41,12 +42,42 @@ file(GLOB SOURCES
# Set up the mod binary
add_library(${PROJECT_NAME} SHARED ${SOURCES})

set(PAHO_BUILD_SHARED OFF CACHE INTERNAL "")
set(PAHO_BUILD_STATIC ON CACHE INTERNAL "")
set(PAHO_ENABLE_TESTING OFF CACHE INTERNAL "")
set(PAHO_BUILD_TESTS OFF CACHE INTERNAL "")
set(PAHO_WITH_MQTT_C ON CACHE INTERNAL "")
set(PAHO_WITH_SSL OFF CACHE INTERNAL "")

FetchContent_Declare(
paho-mqttpp3-static
GIT_REPOSITORY https://github.com/eclipse-paho/paho.mqtt.cpp.git
GIT_TAG 71f78aafc3246c05d624098b8438129f5e0a70e5
)

#FetchContent_MakeAvailable(paho-mqttpp3-static)
FetchContent_GetProperties(paho-mqttpp3-static)
# patch it because apparently stl doesnt like basic_string
if(NOT paho-mqttpp3-static_POPULATED)
FetchContent_Populate(paho-mqttpp3-static)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/patch/ssl_options.h
${paho-mqttpp3-static_SOURCE_DIR}/include/mqtt/ssl_options.h
COPYONLY
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/patch/ssl_options.cpp
${paho-mqttpp3-static_SOURCE_DIR}/src/ssl_options.cpp
COPYONLY
)
add_subdirectory(${paho-mqttpp3-static_SOURCE_DIR} ${paho-mqttpp3-static_BINARY_DIR})
endif()

target_include_directories(${PROJECT_NAME} PRIVATE
libs/socket.io-client-cpp
libs/filesystem
libs/pl_mpeg/
libs/glew/
libs/socket.io-client-cpp/src
${paho-mqttpp3-static_SOURCE_DIR}/src
)

if (NOT DEFINED ENV{GEODE_SDK})
Expand All @@ -57,12 +88,10 @@ endif()

add_subdirectory($ENV{GEODE_SDK} ${CMAKE_CURRENT_BINARY_DIR}/geode)

add_subdirectory(libs/socket.io-client-cpp EXCLUDE_FROM_ALL)
add_dependencies(${PROJECT_NAME} sioclient)
if (APPLE) # AND NOT (${GEODE_TARGET_PLATFORM} STREQUAL "iOS" OR IOS)
target_link_libraries(${PROJECT_NAME} sioclient "-framework OpenGL")
target_link_libraries(${PROJECT_NAME} paho-mqttpp3-static "-framework OpenGL")
else()
target_link_libraries(${PROJECT_NAME} sioclient)
target_link_libraries(${PROJECT_NAME} paho-mqttpp3-static)
endif()
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND WIN32)
message("compiling on linux!!")
Expand Down
24 changes: 24 additions & 0 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: MIT
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors

set(CPM_DOWNLOAD_VERSION 0.38.7)
set(CPM_HASH_SUM "83e5eb71b2bbb8b1f2ad38f1950287a057624e385c238f6087f94cdfc44af9c5")

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)

file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)

include(${CPM_DOWNLOAD_LOCATION})
97 changes: 87 additions & 10 deletions include/Types.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma once

#include <Geode/Geode.hpp>
enum EventType {
Rate,
Expand All @@ -13,17 +12,95 @@ enum EventType {
};

struct EventData {
bool demon;
uint8_t starsum;
uint8_t stars;
uint8_t rate;
EventType type;
bool demon = false;
uint16_t starsum = 0;
uint16_t stars = 0;
uint16_t rate = 0;
EventType type = EventType::Rate;
std::string title;
std::string sprite;
std::string sprite = "GJ_square01.png";
std::string level_name;
std::string level_creator;
uint8_t coins;
bool verified_coins;
bool platformer;
uint8_t coins = 0;
uint8_t verified_coins = 0;
bool platformer = false;
int level_id = -1;
std::string levels_list;
int maxToCompleteList = 0;
};

template<>
struct matjson::Serialize<EventData> {
static geode::Result<EventData> fromJson(matjson::Value const& value) {
EventData data;
if (value.contains("demon")) {
if (value["demon"].asUInt().isErr()) {
GEODE_UNWRAP_INTO(data.demon, value["demon"].asBool());
} else {
GEODE_UNWRAP_INTO(auto demon, value["demon"].asUInt());
data.demon = demon == 1;
}
}
GEODE_UNWRAP_INTO(data.starsum, value["starsum"].asUInt());
GEODE_UNWRAP_INTO(data.stars, value["stars"].asUInt());
GEODE_UNWRAP_INTO(data.rate, value["rate"].asUInt());
GEODE_UNWRAP_INTO(auto type, value["type"].asUInt());
// yeahhhh im getting linker errors ok
switch (type) {
default:
data.type = EventType::NA;
break;
case 0: // Rate
data.type = EventType::Rate;
break;
case 1: // Daily
data.type = EventType::Daily;
break;
case 2: // Weekly
data.type = EventType::Weekly;
break;
case 3: // Small chest
data.type = EventType::smallChest;
break;
case 4: // Large chest
data.type = EventType::largeChest;
break;
case 5: // List
data.type = EventType::List;
break;
case 6: // Event
data.type = EventType::Event;
break;
}
GEODE_UNWRAP_INTO(data.title, value["title"].asString());
GEODE_UNWRAP_INTO(data.sprite, value["sprite"].asString());
GEODE_UNWRAP_INTO(data.level_name, value["level_name"].asString());
GEODE_UNWRAP_INTO(data.level_creator, value["level_creator"].asString());
GEODE_UNWRAP_INTO(data.rate, value["rate"].asUInt());
GEODE_UNWRAP_INTO(data.coins, value["coins"].asUInt());
GEODE_UNWRAP_INTO(data.verified_coins, value["verified_coins"].asUInt());
if (value.contains("platformer")) {
if (value["platformer"].asUInt().isErr()) {
GEODE_UNWRAP_INTO(data.platformer, value["platformer"].asBool());
} else {
GEODE_UNWRAP_INTO(auto platformer, value["platformer"].asUInt());
data.platformer = platformer == 1;
}
}
if (value.contains("level_id")) {
if (value["level_id"].asString().isErr()) {
GEODE_UNWRAP_INTO(data.level_id, value["level_id"].asInt());
} else {
GEODE_UNWRAP_INTO(auto level_id, value["level_id"].asString());
data.level_id = geode::utils::numFromString<int>(level_id).unwrapOrDefault();
}
}
if (value.contains("levels_list")) {
GEODE_UNWRAP_INTO(data.levels_list, value["levels_list"].asString());
}
if (value.contains("maxToCompleteList")) {
GEODE_UNWRAP_INTO(data.maxToCompleteList, value["maxToCompleteList"].asInt());
}
return geode::Ok(data);
}
};
1 change: 0 additions & 1 deletion libs/socket.io-client-cpp
Submodule socket.io-client-cpp deleted from 676adf
Loading