Skip to content

Commit

Permalink
2.206
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Jul 3, 2024
1 parent 58be22c commit 80b1437
Show file tree
Hide file tree
Showing 17 changed files with 236 additions and 71 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.21)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_OSX_ARCHITECTURES "x86_64")
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
set(CMAKE_CXX_VISIBILITY_PRESET hidden)

project(BetterEdit VERSION 1.0.0)
Expand Down
12 changes: 9 additions & 3 deletions about.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# BetterEdit 6
# BetterEdit

The ultimate editor improvement mod.
The ultimate editor improvement mod. Adds a ton of <cp>utilities</c> and <cj>improvements</c> to the level editor, such as <cg>redesigned menus</c>, <cp>bug fixes</c>, <ca>keybinds</c>, and more!

## Features
## <cg>Features</c>

* Better color selection menu
* Better font selection menu
Expand All @@ -15,3 +15,9 @@ The ultimate editor improvement mod.
* Custom UI scaling
* Fully customizable editor keybinds
* And lots, lots more!

## <cy>Support</c>

BetterEdit is first and foremost **a passion project**, however it is also being developed by a poor student living on his own. If you would like to support development and help me out, I have a Ko-fi!

[Link to my Ko-fi](https://ko-fi.com/hjfod)
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## v6.5.0
* Add support for <cy>2.206</c>
* Add <cp>Quick Save</c> feature that significantly improves level saving speeds
* Allow <cj>configuring autosave rate</c>
* Fix autosave possibly causing the level to be corrupted if it occurred during playtesting
* <cr>Remove BetterSave dependency</c> as the mod was discontinued

## v6.4.3
* Fix playtest pausing not showing the UI

Expand Down
Binary file removed logo-new.png
Binary file not shown.
Binary file modified logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 34 additions & 17 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"geode": "2.0.0-beta.26",
"version": "6.4.3",
"geode": "3.1.1",
"version": "6.5.0",
"gd": {
"win": "2.204",
"mac": "2.200",
"android": "2.205"
"win": "2.206",
"mac": "2.206",
"android": "2.206"
},
"id": "hjfod.betteredit",
"name": "BetterEdit",
Expand All @@ -19,24 +19,34 @@
"dependencies": [
{
"id": "geode.node-ids",
"version": "1.11.0",
"version": "1.13.0",
"importance": "required"
},
{
"id": "geode.custom-keybinds",
"version": "1.5.0",
"version": "1.6.2",
"importance": "required",
"platforms": ["windows"]
"platforms": ["win"]
},
{
"id": "hjfod.gmd-api",
"version": "1.1.0",
"version": "1.2.1",
"importance": "required"
},
{
"id": "hjfod.bettersave",
"version": "1.2.0",
"id": "cvolton.level-id-api",
"version": "1.0.0",
"importance": "required"
},
{
"id": "hjfod.trashcan",
"version": "1.0.0",
"importance": "recommended"
},
{
"id": "hjfod.backups",
"version": "1.0.0",
"importance": "recommended"
}
],
"resources": {
Expand All @@ -50,18 +60,25 @@
}
},
"settings": {
"auto-save": {
"auto-save-rate": {
"type": "string",
"default": "Every 10 Minutes",
"name": "Auto-save",
"one-of": ["Every 10 Minutes", "Every 20 Minutes", "Every Hour", "Never"],
"description": "Automatically saves the level in the editor at the specified rate, as well as creates a backup. The backups created by autosave get automatically deleted after 3 new ones have been created to avoid using too much disk space"
},
"quick-save": {
"type": "bool",
"default": true,
"name": "Auto-save",
"description": "Automatically saves the level every 5 minutes, as well as creates a backup. The backups created by autosave get automatically deleted after 3 new ones have been created to avoid using too much disk space"
"name": "Quick Save",
"description": "Makes level saving faster by saving to a backup file rather than directly to the save file"
},
"mouse-move-on-zoom": {
"type": "bool",
"default": true,
"name": "Zoom Towards Cursor",
"description": "When enabled and while holding down the CTRL key, zooming in the editor with the scroll wheel will be zoomed toward the cursor and not the center of the screen",
"platforms": ["windows", "macos"]
"platforms": ["win", "macos"]
},
"pinch-to-zoom": {
"type": "bool",
Expand Down Expand Up @@ -139,14 +156,14 @@
"default": true,
"name": "Show Grid Size Controls",
"description": "Shows controls in the UI for adjusting the size of the grid. <cr>Requires re-entering the editor!</c>",
"platforms": ["windows", "android64"]
"platforms": ["win", "android64"]
},
"show-grid-on-size-change": {
"type": "bool",
"default": true,
"name": "Show Grid on Size Change",
"description": "If the grid is currently hidden and you use the controls to change its size, its toggled on",
"platforms": ["windows", "android64"]
"platforms": ["win", "android64"]
}
},
"tags": ["editor", "enhancement", "utility", "customization"]
Expand Down
6 changes: 3 additions & 3 deletions src/features/BetterColorSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class $modify(NewColorSelect, CustomizeObjectLayer) {
auto spr = ColorChannelSprite::create();
spr->setScale(.8f);
// tag gets overwritten by CCMenuItemSpriteExtra :(
spr->setUserData(reinterpret_cast<void*>(channel));
spr->setUserData(reinterpret_cast<void*>(static_cast<intptr_t>(channel)));
spr->setID("channel-sprite"_spr);

if (recent && channel == 0) {
Expand Down Expand Up @@ -378,7 +378,7 @@ class $modify(NewColorSelect, CustomizeObjectLayer) {

void gotoPageWithChannel(int channel) {
if (0 < channel && channel < 1000) {
this->gotoPage((channel - 1) / getChannelsOnPage());
this->gotoPage(static_cast<int>((channel - 1) / getChannelsOnPage()));
}
}

Expand All @@ -388,7 +388,7 @@ class $modify(NewColorSelect, CustomizeObjectLayer) {
if (!m_fields->initDone) {
return;
}
int channelsPerPage = getChannelsOnPage();
int channelsPerPage = static_cast<int>(getChannelsOnPage());
if (page < 0) {
page = 0;
}
Expand Down
7 changes: 3 additions & 4 deletions src/features/BetterFontSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ class SelFont {

class $modify(BetterSelectFontLayer, SelectFontLayer) {
void onSelect(CCObject* sender) {
size_t s = static_cast<CCNode*>(sender)->getTag();

int s = static_cast<CCNode*>(sender)->getTag();
GameManager::get()->m_levelEditorLayer->updateLevelFont(s);

for (size_t i = 0; i < SelFont::buttons.size(); i++) {
if (i != s) {
if (i != static_cast<size_t>(s)) {
SelFont::buttons[i]->toggle(false);
SelFont::buttons[i]->setEnabled(true);
}
Expand Down Expand Up @@ -113,7 +112,7 @@ class $modify(BetterSelectFontLayer, SelectFontLayer) {
menu->addChild(font);

auto btn = CCMenuItemToggler::create(unSel, sel, menu, menu_selector(BetterSelectFontLayer::onSelect));
btn->setTag(i);
btn->setTag(static_cast<int>(i));
btn->setPosition(node->getContentSize().width - 20, 15);
btn->toggle(static_cast<int>(i) == p0->m_levelSettings->m_fontIndex);
btn->setEnabled(!(static_cast<int>(i) == p0->m_levelSettings->m_fontIndex));
Expand Down
7 changes: 4 additions & 3 deletions src/features/Keybinds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <Geode/modify/EditorUI.hpp>
#include <utils/EditCommandExt.hpp>
#include <Geode/binding/EditButtonBar.hpp>
#include <utils/HolyUB.hpp>

using namespace geode::prelude;
using namespace keybinds;
Expand Down Expand Up @@ -38,13 +39,13 @@ struct $modify(EditorUI) {
this->showUI(false);
});
this->defineKeybind("select-all"_spr, [this]() {
this->selectAll();
fakeEditorPauseLayer(m_editorLayer)->onSelectAll(nullptr);
});
this->defineKeybind("select-all-left"_spr, [this]() {
this->selectAllWithDirection(true);
fakeEditorPauseLayer(m_editorLayer)->onSelectAllLeft(nullptr);
});
this->defineKeybind("select-all-right"_spr, [this]() {
this->selectAllWithDirection(false);
fakeEditorPauseLayer(m_editorLayer)->onSelectAllRight(nullptr);
});
this->defineKeybind("move-obj-half-left"_spr, [this] {
this->moveObjectCall(EditCommand::HalfLeft);
Expand Down
78 changes: 78 additions & 0 deletions src/features/QuickSave.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#include <Geode/modify/EditorPauseLayer.hpp>
#include <Geode/modify/GManager.hpp>
#include <Geode/modify/MenuLayer.hpp>
#include <cvolton.level-id-api/include/EditorIDs.hpp>
#include <hjfod.gmd-api/include/GMD.hpp>

using namespace geode::prelude;

static std::filesystem::path getQuickSaveDir() {
return Mod::get()->getSaveDir() / "quicksave";
}
static std::filesystem::path getQuickSaveFile(GJGameLevel* level) {
return getQuickSaveDir() / fmt::format("{}.gmd", EditorIDs::getID(level));
}

static bool SKIP_NEXT_LLM_SAVE = false;
class $modify(GManager) {
$override
void save() {
auto isLLM = static_cast<LocalLevelManager*>(static_cast<GManager*>(this)) == LocalLevelManager::get();
if (isLLM && SKIP_NEXT_LLM_SAVE) {
SKIP_NEXT_LLM_SAVE = false;
return;
}
GManager::save();
// If we have succesfully saved local levels, we can delete the temp quick save directory
if (isLLM) {
std::error_code ec;
std::filesystem::remove_all(getQuickSaveDir(), ec);
}
}
};
class $modify(EditorPauseLayer) {
$override
void saveLevel() {
// If quicksaving is disabled, save normally
// In any case we need to still run the rest of `saveLevel` to have GD
// update the level state but for quicksave we just skip the function
// saving CCLocalLevels
SKIP_NEXT_LLM_SAVE = Mod::get()->template getSettingValue<bool>("quick-save");
EditorPauseLayer::saveLevel();

// Save to individual file regardless as a backup if saving crashes
(void)file::createDirectoryAll(getQuickSaveDir());
auto res = gmd::exportLevelAsGmd(m_editorLayer->m_level, getQuickSaveFile(m_editorLayer->m_level));
if (!res) {
log::error("Unable to quicksave level '{}': {}", m_editorLayer->m_level->m_levelName, res.unwrapErr());
}
}
};
class $modify(MenuLayer) {
bool init() {
if (!MenuLayer::init())
return false;

// Check if there's quicksaved crash data
for (auto file : file::readDirectory(getQuickSaveDir()).unwrapOrDefault()) {
auto data = gmd::importGmdAsLevel(file);
if (!data) continue;
auto imported = *data;

auto num = numFromString<int>(file.stem().string());
if (!num) continue;

// Restore existing level
if (auto level = EditorIDs::getLevelByID(*num)) {
level->m_levelString = imported->m_levelString;
log::info("Restored crash data for {}", level->m_levelName);
}
else {
LocalLevelManager::get()->m_localLevels->insertObject(imported, 0);
log::info("Restored crashed level {}", imported->m_levelName);
}
}

return true;
}
};
18 changes: 12 additions & 6 deletions src/features/ViewTab/ViewTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <Geode/utils/cocos.hpp>
#include <geode.custom-keybinds/include/Keybinds.hpp>
#include <utils/HandleUIHide.hpp>
#include <utils/HolyUB.hpp>

using namespace geode::prelude;
using namespace keybinds;
Expand Down Expand Up @@ -206,9 +207,13 @@ struct $modify(ViewTabUI, EditorUI) {
// for the view toggles was causing super weird crashes, so will have
// to make due with this :/

btns->addObject(this->createViewToggleGV("v_rotate.png"_spr, "0118", [this](bool) {
m_editorLayer->updatePreviewAnim();
}));
btns->addObject(this->createViewToggle(
"v_rotate.png"_spr,
[] { return GameManager::get()->getGameVariable("0118"); },
[this](bool) {
fakeEditorPauseLayer(m_editorLayer)->togglePreviewAnim(nullptr);
}
));
btns->addObject(this->createViewToggleGV("v_particles.png"_spr, "0117", [this](bool) {
m_editorLayer->updatePreviewParticles();
}));
Expand All @@ -221,7 +226,8 @@ struct $modify(ViewTabUI, EditorUI) {
btns->addObject(this->createViewToggleGV("v_prevmode.png"_spr, "0036", [this](bool) {
// Let's not be funny and ruin everyone's levels
if (m_editorLayer->m_playbackMode != PlaybackMode::Not) {
m_editorLayer->resetMovingObjects();
// Why was this being called separately? `onStopPlaytest` already calls it
// m_editorLayer->resetMovingObjects();
this->onStopPlaytest(m_playtestBtn);
}
m_editorLayer->updateEditorMode();
Expand Down Expand Up @@ -288,8 +294,8 @@ struct $modify(ViewTabUI, EditorUI) {
void selectObjects(CCArray* objs, bool ignoreFilters) {
// filter out LDM objects
if (objs) {
size_t objCount = objs->count();
for (size_t i = 0; i < objCount; i++) {
unsigned int objCount = objs->count();
for (unsigned int i = 0; i < objCount; i++) {
auto obj = static_cast<GameObjectExtra*>(objs->objectAtIndex(i));
if (obj->shouldHide()) {
objs->removeObjectAtIndex(i, false);
Expand Down
2 changes: 1 addition & 1 deletion src/features/about/ChangelogPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static std::string parseChangelog(std::optional<VersionInfo> const& since) {
auto ver = parse.unwrap();
if (!since || since.value() < ver) {
validHeader = true;
res += "\n# " + ver.toString() + "\n\n";
res += "\n# " + ver.toNonVString() + "\n\n";
}
else {
validHeader = false;
Expand Down
Loading

0 comments on commit 80b1437

Please sign in to comment.