Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
cgytrus committed Aug 3, 2023
2 parents 0d25fb8 + 29d7df1 commit ebab230
Show file tree
Hide file tree
Showing 10 changed files with 360 additions and 412 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jobs:
draft: false
prerelease: true
body: |
Dev release of Geode. Will not install the resources automatically, so you should use the installers to install them.
Geode dev release for commit ${{ github.sha }}. Since this is not a regular release, Geode will not install the resources automatically, so you should use the installer if you want them.
files: |
./geode-${{ steps.ref.outputs.hash }}-mac.zip
./geode-${{ steps.ref.outputs.hash }}-win.zip
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
* Implement a new updater / bootstrapper for Windows (b47870e)
* Don't download resources if the tag doesn't exist (991e714)
* Fix MacOS wine by using `std::filesystem::weakly_canonical` (46fab0e)
* Make the Index pimpl aswell as remove ability for multiple sources (7a0ade2)
* All mods including disabled ones are now always unzipped in order to load their logos (0a6d31e)
* Add IDs and layouts for `CustomizeObjectLayer` (6d92bb8, 138fdbb, f8da816)
* Add option to disable the Last Crashed popup (e00b3a6)
* Fix `SpacerNode` not actually taking up any space (8ca2b99)

## v1.0.0-beta.18
* Fix pickup bounds checks
Expand Down
2 changes: 1 addition & 1 deletion installer/windows/Language Files/SwedishExtra.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ${LangFileString} GEODE_TEXT_SYSTEM_XINPUT_MISSING "$0 hittades inte på din dat

${LangFileString} GEODE_TEXT_GD_MISSING "$\r$\n$\r$\nDen valda mappen innehåller ingen installation av Geometry Dash."
${LangFileString} GEODE_TEXT_MH_ALREADY_INSTALLED "Den valda mappen innehåller redan Mega Hack v6/v7.$\r$\nGeode är inte kompatibel med MHv6/v7 (MHv8 är den första versionen som är kompatibel med Geode).$\r$\nSe till att avinstallera Mega Hack innan du startar installationen av Geode."
${LangFileString} GEODE_TEXT_MOD_LOADER_ALREADY_INSTALLED "Den valda mappen innehåller redan några andra mods.$\r$\nGeode är inte kompatibel med .DLL-slag mods eller sin mod loaders.$\r$\nSe till att avinstallera .DLL-slag mods och sin mod loaders innan du startar installationen av Geode."
${LangFileString} GEODE_TEXT_MOD_LOADER_ALREADY_INSTALLED "Den valda mappen innehåller redan några andra mod.$\r$\nGeode är inte kompatibel med .DLL-slag mod eller sin mod loader.$\r$\nSe till att avinstallera .DLL-slag mod och sin mod loader innan du startar installationen av Geode."

; uninstaller

Expand Down
138 changes: 84 additions & 54 deletions loader/include/Geode/loader/Index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,63 @@
#include <unordered_set>

namespace geode {
class Index;

/**
* Status signifying an index-related download has been finished
*/
using UpdateFinished = std::monostate;
/**
* Status signifying an index-related download is in progress. First element
* in pair is percentage downloaded, second is status string
*/
using UpdateProgress = std::pair<uint8_t, std::string>;
using UpdateFailed = std::string;
using UpdateStatus = std::variant<UpdateFinished, UpdateProgress, UpdateFailed>;
/**
* Status signifying an index-related download has failed. Consists of the
* error string
*/
using UpdateFailed = std::string;
/**
* Status code for an index-related download
*/
using UpdateStatus = std::variant<UpdateFinished, UpdateProgress, UpdateFailed>;

/**
* Event for when a mod is being installed from the index. Automatically
* broadcast by the mods index; use ModInstallFilter to listen to these
* events
*/
struct GEODE_DLL ModInstallEvent : public Event {
/**
* The ID of the mod being installed
*/
const std::string modID;
/**
* The current status of the installation
*/
const UpdateStatus status;

private:
ModInstallEvent(std::string const& id, const UpdateStatus status);

friend class Index;
};

/**
* Basic filter for listening to mod installation events. Always propagates
* the event down the chain
* @example
* // Install "steve.hotdogs" and listen for its installation progress
*
* // Create a listener that listens for when steve.hotdogs is being installed
* auto listener = EventListener<ModInstallFilter>(+[](ModInstallEvent* ev) {
* // Check the event status using std::visit or other
* }, ModInstallFilter("steve.hotdogs"));
* // Get the latest version of steve.hotdogs from the index and install it
* if (auto mod = Index::get()->getMajorItem("steve.hotdogs")) {
* Index::get()->install(mod);
* }
*/
class GEODE_DLL ModInstallFilter : public EventFilter<ModInstallEvent> {
protected:
std::string m_id;
Expand All @@ -31,11 +77,18 @@ namespace geode {
ModInstallFilter(ModInstallFilter const&) = default;
};

/**
* Event broadcast when the index is being updated
*/
struct GEODE_DLL IndexUpdateEvent : public Event {
const UpdateStatus status;
IndexUpdateEvent(const UpdateStatus status);
};

/**
* Basic filter for listening to index update events. Always propagates
* the event down the chain
*/
class GEODE_DLL IndexUpdateFilter : public EventFilter<IndexUpdateEvent> {
public:
using Callback = void(IndexUpdateEvent*);
Expand All @@ -45,32 +98,24 @@ namespace geode {
IndexUpdateFilter(IndexUpdateFilter const&) = default;
};

struct IndexSourceImpl;
struct GEODE_DLL IndexSourceImplDeleter {
void operator()(IndexSourceImpl* src);
};
struct SourceUpdateEvent;
using IndexSourcePtr = std::unique_ptr<IndexSourceImpl, IndexSourceImplDeleter>;

struct GEODE_DLL IndexItem {
std::string sourceRepository;
ghc::filesystem::path path;
ModInfo info;
struct {
std::string url;
std::string hash;
std::unordered_set<PlatformID> platforms;
} download;
bool isFeatured;
std::unordered_set<std::string> tags;

/**
* Create IndexItem from a directory
*/
static Result<std::shared_ptr<IndexItem>> createFromDir(
std::string const& sourceRepository,
ghc::filesystem::path const& dir
);
class GEODE_DLL IndexItem final {
public:
class Impl;

private:
std::unique_ptr<Impl> m_impl;

public:
ghc::filesystem::path getPath() const;
ModInfo getModInfo() const;
std::string getDownloadURL() const;
std::string getPackageHash() const;
std::unordered_set<PlatformID> getAvailablePlatforms() const;
bool isFeatured() const;
std::unordered_set<std::string> getTags() const;

IndexItem();
~IndexItem();
};
using IndexItemHandle = std::shared_ptr<IndexItem>;

Expand All @@ -85,38 +130,19 @@ namespace geode {
std::vector<IndexItemHandle> list;
};

static constexpr size_t MAX_INDEX_API_VERSION = 0;

class GEODE_DLL Index final {
protected:
// for once, the fact that std::map is ordered is useful (this makes
// getting the latest version of a mod as easy as items.rbegin())
using ItemVersions = std::map<size_t, IndexItemHandle>;

std::vector<IndexSourcePtr> m_sources;
std::unordered_map<std::string, UpdateStatus> m_sourceStatuses;
std::unordered_map<
IndexItemHandle,
utils::web::SentAsyncWebRequestHandle
> m_runningInstallations;
std::atomic<bool> m_triedToUpdate = false;
std::unordered_map<std::string, ItemVersions> m_items;
private:
class Impl;
std::unique_ptr<Impl> m_impl;

Index();

void onSourceUpdate(SourceUpdateEvent* event);
void checkSourceUpdates(IndexSourceImpl* src);
void downloadSource(IndexSourceImpl* src);
void updateSourceFromLocal(IndexSourceImpl* src);
void cleanupItems();

void installNext(size_t index, IndexInstallList const& list);
~Index();

public:
static Index* get();

void addSource(std::string const& repository);
void removeSource(std::string const& repository);
std::vector<std::string> getSources() const;

/**
* Get all tags
*/
Expand Down Expand Up @@ -206,13 +232,17 @@ namespace geode {
Result<IndexInstallList> getInstallList(IndexItemHandle item) const;
/**
* Install an index item. Add an event listener for the ModInstallEvent
* class to track the installation progress
* class to track the installation progress. Automatically also downloads
* all missing dependencies for the item
* @param item Item to install
*/
void install(IndexItemHandle item);
/**
* Install a list of index items. Add an event listener for the
* ModInstallEvent class to track the installation progress
* @warning Does not download any missing dependencies - use the
* `install(IndexItemHandle)` overload if you aren't sure all the
* dependencies are installed!
* @param list List of items to install
*/
void install(IndexInstallList const& list);
Expand Down
Loading

0 comments on commit ebab230

Please sign in to comment.