some minor changes

- add Mod::getPackagePath as a replacement for Mod::getPath
 - add new geode/config directory for mods' config files
 - add Mod::getConfigDir for getting the mod's config directory
 - add libfmod.dylib and auto-move it in actions
 - add open save directory button to mod settings popup
This commit is contained in:
HJfod 2022-10-23 15:23:55 +03:00
parent 42d51e3cdc
commit 0a0a34eb5c
8 changed files with 50 additions and 9 deletions
.github/workflows
loader

View file

@ -26,7 +26,7 @@ jobs:
os: macos-latest
prefixes: 'PATH="/usr/local/opt/ccache/libexec:$PATH"'
extra_flags: "-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++"
out_paths: './bin/nightly/Geode.dylib ./bin/nightly/GeodeBootstrapper.dylib'
out_paths: './bin/nightly/Geode.dylib ./bin/nightly/GeodeBootstrapper.dylib ./loader/include/link/libfmod.dylib'
cli_cmd: 'chmod +x $GITHUB_WORKSPACE/cli/geode'
name: ${{ matrix.config.name }}
@ -65,13 +65,16 @@ jobs:
run: |
${{ matrix.config.cli_cmd }}
echo "${{ github.workspace }}/cli" >> $GITHUB_PATH
- name: Configure CMake
run: |
${{ matrix.config.prefixes }} cmake -B ${{ github.workspace }}/build ${{ matrix.config.extra_flags }} -DGEODE_DISABLE_CLI_CALLS=ON -DCLI_PATH="${{ github.workspace }}/cli"
- name: Build
run: |
cd build
cmake --build . --config RelWithDebInfo
- name: Move to output folder
shell: bash
working-directory: ${{ github.workspace }}
@ -133,4 +136,4 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
files: ./macOS.zip ./Windows.zip ./Headers.zip
release: Nightly
prerelease: true
prerelease: true

View file

@ -19,6 +19,7 @@ namespace geode {
static constexpr std::string_view GEODE_MOD_DIRECTORY = "mods";
static constexpr std::string_view GEODE_LOG_DIRECTORY = "log";
static constexpr std::string_view GEODE_RESOURCE_DIRECTORY = "resources";
static constexpr std::string_view GEODE_CONFIG_DIRECTORY = "config";
static constexpr std::string_view GEODE_TEMP_DIRECTORY = "temp";
static constexpr std::string_view GEODE_MOD_EXTENSION = ".geode";
@ -65,7 +66,6 @@ namespace geode {
std::vector<FailedModInfo> m_erroredMods;
std::vector<ghc::filesystem::path> m_texturePaths;
LoaderSettings m_loadedSettings;
bool m_isSetup = false;
static bool s_unloading;

View file

@ -344,7 +344,9 @@ namespace geode {
std::string getDeveloper() const;
std::optional<std::string> getDescription() const;
std::optional<std::string> getDetails() const;
[[deprecated("Use Mod::getPackagePath instead")]]
std::string getPath() const;
ghc::filesystem::path getPackagePath() const;
VersionInfo getVersion() const;
bool isEnabled() const;
bool isLoaded() const;
@ -355,6 +357,14 @@ namespace geode {
ModInfo getModInfo() const;
ghc::filesystem::path getTempDir() const;
ghc::filesystem::path getBinaryPath() const;
/**
* Get the mod's save directory path
*/
ghc::filesystem::path getSaveDir() const;
/**
* Get the mod's config directory path
*/
ghc::filesystem::path getConfigDir() const;
bool hasSettings() const;
decltype(ModInfo::m_settings) getSettings() const;
@ -506,12 +516,6 @@ namespace geode {
*/
Result<> uninstall();
bool isUninstalled() const;
/**
* Get the mod's save directory
* path
*/
ghc::filesystem::path getSaveDir() const;
/**
* Return the data store object

Binary file not shown.

View file

@ -35,8 +35,10 @@ void Loader::createDirectories() {
auto logDir = this->getGeodeDirectory() / GEODE_LOG_DIRECTORY;
auto resDir = this->getGeodeDirectory() / GEODE_RESOURCE_DIRECTORY;
auto tempDir = this->getGeodeDirectory() / GEODE_TEMP_DIRECTORY;
auto confDir = this->getGeodeDirectory() / GEODE_CONFIG_DIRECTORY;
ghc::filesystem::create_directories(resDir);
ghc::filesystem::create_directory(confDir);
ghc::filesystem::create_directory(modDir);
ghc::filesystem::create_directory(logDir);
ghc::filesystem::create_directory(tempDir);

View file

@ -491,6 +491,18 @@ std::string Mod::getPath() const {
return m_info.m_path.string();
}
ghc::filesystem::path Mod::getPackagePath() const {
return m_info.m_path;
}
ghc::filesystem::path Mod::getConfigDir() const {
auto dir = Loader::get()->getGeodeDirectory() / GEODE_CONFIG_DIRECTORY / m_info.m_id;
if (!ghc::filesystem::exists(dir)) {
ghc::filesystem::create_directories(dir);
}
return dir;
}
VersionInfo Mod::getVersion() const {
return m_info.m_version;
}

View file

@ -4,6 +4,7 @@
#include <Geode/utils/cocos.hpp>
#include <Geode/utils/convert.hpp>
#include <Geode/binding/ButtonSprite.hpp>
#include <Geode/loader/Mod.hpp>
bool ModSettingsPopup::setup(Mod* mod) {
m_noElasticity = true;
@ -143,6 +144,20 @@ bool ModSettingsPopup::setup(Mod* mod) {
resetBtn->setPosition(-m_size.width / 2 + 45.f, -m_size.height / 2 + 20.f);
m_buttonMenu->addChild(resetBtn);
auto openDirBtnSpr = ButtonSprite::create(
"Open Folder",
"goldFont.fnt",
"GJ_button_05.png",
.7f
);
openDirBtnSpr->setScale(.7f);
auto openDirBtn = CCMenuItemSpriteExtra::create(
openDirBtnSpr, this, menu_selector(ModSettingsPopup::onOpenSaveDirectory)
);
openDirBtn->setPosition(m_size.width / 2 - 45.f, -m_size.height / 2 + 20.f);
m_buttonMenu->addChild(openDirBtn);
this->settingValueChanged(nullptr);
return true;
@ -216,6 +231,10 @@ void ModSettingsPopup::onClose(CCObject* sender) {
Popup<Mod*>::onClose(sender);
}
void ModSettingsPopup::onOpenSaveDirectory(CCObject*) {
file::openFolder(m_mod->getSaveDir());
}
ModSettingsPopup* ModSettingsPopup::create(Mod* mod) {
auto ret = new ModSettingsPopup();
if (ret && ret->init(440.f, 290.f, mod)) {

View file

@ -20,6 +20,7 @@ protected:
void onClose(CCObject*) override;
void onApply(CCObject*);
void onResetAll(CCObject*);
void onOpenSaveDirectory(CCObject*);
public:
static ModSettingsPopup* create(Mod* mod);