Skip to content

Commit

Permalink
Merge pull request #230 from geode-sdk/1.3.0-dev
Browse files Browse the repository at this point in the history
1.3.0
  • Loading branch information
altalk23 authored Sep 8, 2023
2 parents 0bfa2d8 + cbd1d04 commit fbce0ea
Show file tree
Hide file tree
Showing 28 changed files with 783 additions and 427 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Geode Changelog

## v1.3.0
* Completely remove runtime enabling & disabling of mods (d817749)
* Patches auto enabling can be disabled (69821f3)
* Move ModEventType::Loaded to after hooks & patches are enabled (23c3095)
* Update index to be able to store multiple versions of the same mod (5572f9c)
* Implement UI for selection of downloading specific mod versions (5d15eb0)
* Change install & uninstall popups to reflect the new changes (d40f467)
* Keep the scroll when enabling, installing etc. a mod (b3d444a)
* Update MacOS crashlog to include base and offset (7816c43)
* Add user agent to AsyncWebRequest (c256207)
* Add post and custom requests to AsyncWebRequest (c256207)

## v1.2.1
* Mods now target macOS 10.13 instead of 10.14 (7cc1cd4)
* Fix CustomizeObjectLayer ids moving around when multiple objects are selected (9ee0994, 87749d4)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.1
1.3.0
33 changes: 21 additions & 12 deletions loader/include/Geode/loader/Hook.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace geode {
class Mod;
class Loader;

class GEODE_DLL Hook {
class GEODE_DLL Hook final {
private:
class Impl;
std::shared_ptr<Impl> m_impl;
Expand Down Expand Up @@ -143,20 +143,23 @@ namespace geode {
void setAutoEnable(bool autoEnable);
};

class GEODE_DLL Patch {
class GEODE_DLL Patch final {
// Change to private in 2.0.0
protected:
Mod* m_owner;
void* m_address;
ByteVector m_original;
ByteVector m_patch;
bool m_applied;
bool m_autoEnable;

// Only allow friend classes to create
// patches. Whatever method created the
// patches should take care of populating
// m_owner, m_address, m_original and
// m_patch.
Patch() : m_applied(false) {}
Patch();
~Patch();

// no copying
Patch(Patch const&) = delete;
Expand All @@ -170,17 +173,13 @@ namespace geode {
* Get the address of the patch.
* @returns Address
*/
uintptr_t getAddress() const {
return reinterpret_cast<uintptr_t>(m_address);
}
uintptr_t getAddress() const;

/**
* Get whether the patch is applied or not.
* @returns True if applied, false if not.
*/
bool isApplied() const {
return m_applied;
}
bool isApplied() const;

bool apply();
bool restore();
Expand All @@ -189,14 +188,24 @@ namespace geode {
* Get the owner of this patch.
* @returns Pointer to the owner's Mod handle.
*/
Mod* getOwner() const {
return m_owner;
}
Mod* getOwner() const;

/**
* Get info about the patch as JSON
* @note For IPC
*/
json::Value getRuntimeInfo() const;

/**
* Get whether the patch should be auto enabled or not.
* @returns Auto enable
*/
bool getAutoEnable() const;

/**
* Set whether the patch should be auto enabled or not.
* @param autoEnable Auto enable
*/
void setAutoEnable(bool autoEnable);
};
}
22 changes: 22 additions & 0 deletions loader/include/Geode/loader/Index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ namespace geode {
std::unique_ptr<Impl> m_impl;

public:
/**
* Returns the path that contains all the versions
*/
ghc::filesystem::path getRootPath() const;

/**
* Returns the path to the specific version
*/
ghc::filesystem::path getPath() const;
[[deprecated("use getMetadata instead")]] ModInfo getModInfo() const;
ModMetadata getMetadata() const;
Expand All @@ -124,10 +132,14 @@ namespace geode {
void setAvailablePlatforms(std::unordered_set<PlatformID> const& value);
void setIsFeatured(bool const& value);
void setTags(std::unordered_set<std::string> const& value);
void setIsInstalled(bool const& value);
#endif

IndexItem();
~IndexItem();

friend class ModMetadata;
friend class Index;
};
using IndexItemHandle = std::shared_ptr<IndexItem>;

Expand Down Expand Up @@ -168,12 +180,22 @@ namespace geode {
* Get all featured index items
*/
std::vector<IndexItemHandle> getFeaturedItems() const;
/**
* Get all latest index items
*/
std::vector<IndexItemHandle> getLatestItems() const;
/**
* Get all index items by a developer
*/
std::vector<IndexItemHandle> getItemsByDeveloper(
std::string const& name
) const;
/**
* Get all index items for a specific mod
*/
std::vector<IndexItemHandle> getItemsByModID(
std::string const& modID
) const;
/**
* Check if an item with this ID is found on the index, and optionally
* provide the version sought after
Expand Down
9 changes: 9 additions & 0 deletions loader/include/Geode/loader/Mod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ namespace geode {
~HandleToSaved();
};

enum class ModRequestedAction {
None,
Enable,
Disable,
Uninstall,
};

GEODE_HIDDEN Mod* takeNextLoaderMod();

class ModImpl;
Expand Down Expand Up @@ -337,6 +344,8 @@ namespace geode {
Result<> uninstall();
bool isUninstalled() const;

ModRequestedAction getRequestedAction() const;

/**
* Check whether or not this Mod
* depends on another mod
Expand Down
1 change: 1 addition & 0 deletions loader/include/Geode/loader/ModMetadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ namespace geode {
friend class Loader;

friend class ModMetadataImpl;
friend class IndexItem;
};
}

Expand Down
41 changes: 40 additions & 1 deletion loader/include/Geode/utils/web.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,39 @@ namespace geode::utils::web {
template <class T>
using DataConverter = Result<T> (*)(ByteVector const&);

// Hack until 2.0.0 to store extra members in AsyncWebRequest
struct AsyncWebRequestData {
std::string m_userAgent;
std::string m_customRequest;
bool m_isPostRequest = false;
std::string m_postFields;
bool m_isJsonRequest = false;
bool m_sent = false;
};

/**
* An asynchronous, thread-safe web request. Downloads data from the
* internet without slowing the main thread. All callbacks are run in the
* GD thread, so interacting with the Cocos2d UI is perfectly safe
*/
class GEODE_DLL AsyncWebRequest {
private:
// i want to cry whose idea was to not make this pimpl
// For 2.0.0: make this pimpl

std::optional<std::string> m_joinID;
std::string m_url;
AsyncThen m_then = nullptr;
AsyncExpectCode m_expect = nullptr;
AsyncProgress m_progress = nullptr;
AsyncCancelled m_cancelled = nullptr;
bool m_sent = false;
mutable AsyncWebRequestData* m_extra = nullptr;
std::variant<std::monostate, std::ostream*, ghc::filesystem::path> m_target;
std::vector<std::string> m_httpHeaders;

AsyncWebRequestData& extra();
AsyncWebRequestData const& extra() const;

template <class T>
friend class AsyncWebResult;
friend class SentAsyncWebRequest;
Expand Down Expand Up @@ -151,6 +167,29 @@ namespace geode::utils::web {
* Can be called more than once.
*/
AsyncWebRequest& header(std::string const& header);
/**
* In order to specify an user agent to the request, give it here.
*/
AsyncWebRequest& userAgent(std::string const& userAgent);
/**
* Specify that the request is a POST request.
*/
AsyncWebRequest& postRequest();
/**
* Specify that the request is a custom request like PUT and DELETE.
*/
AsyncWebRequest& customRequest(std::string const& request);
/**
* Specify the post fields to send with the request. Only valid if
* `postRequest` or `customRequest` was called before.
*/
AsyncWebRequest& postFields(std::string const& fields);
/**
* Specify the post fields to send with the request. Only valid if
* `postRequest` or `customRequest` was called before. Additionally
* sets the content type to application/json.
*/
AsyncWebRequest& postFields(json::Value const& fields);
/**
* URL to fetch from the internet asynchronously
* @param url URL of the data to download. Redirects will be
Expand Down
1 change: 1 addition & 0 deletions loader/src/loader/Hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ using namespace geode::prelude;
Hook::Hook(std::shared_ptr<Impl>&& impl) : m_impl(std::move(impl)) {}
Hook::~Hook() {}

// These classes (Hook and Patch) are nasty using new and delete, change them in 2.0.0
Hook* Hook::create(
Mod* owner,
void* address,
Expand Down
Loading

0 comments on commit fbce0ea

Please sign in to comment.