-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to 1.2.0. Full changelog in CHANGELOG.md
- Loading branch information
1 parent
9147eb9
commit 3ef4aa8
Showing
25 changed files
with
763 additions
and
422 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# GD-Roulette Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## [1.2.0] - 2023-12-06 | ||
|
||
### Added | ||
- Added a json manager (to save options) | ||
- Added a percentage goal besides the LevelInfoLayer percentage text | ||
- Added a percentage goal in the PauseLayer | ||
|
||
### Changed | ||
|
||
- Separated the layers contained in the RouletteLayer.cpp file into sub-files | ||
|
||
### Fixed | ||
|
||
- Fixed RouletteManager not managing data correctly after JSON saving was added | ||
- Fixed demonDiffArr resetting everything to false when RouletteLayer::onClose is called | ||
|
||
## [1.1.7] - 2023-10-29 | ||
|
||
### Added | ||
- Added a DEV_CONSOLE macro enabled only when compiling RelWithDebInfo | ||
- Added a check for MegaHack v7 to change the roulette button's position | ||
|
||
<!-- maybe add the other versions here too --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "JsonManager.hpp" | ||
#define DECLAREROULETTEMANAGER | ||
#include "../roulette/manager/RouletteManager.hpp" | ||
|
||
nlohmann::ordered_json JsonManager::m_default_savedata; | ||
nlohmann::ordered_json JsonManager::m_savedata; | ||
|
||
// maybe change to saving the std::array instead of its elements individually | ||
|
||
JsonManager::JsonManager() | ||
{ | ||
m_default_savedata["normalList"] = static_cast<bool>(RouletteManager.selectedListArr[0]); | ||
m_default_savedata["demonList"] = static_cast<bool>(RouletteManager.selectedListArr[1]); | ||
m_default_savedata["challengeList"] = static_cast<bool>(RouletteManager.selectedListArr[2]); | ||
m_default_savedata["maxSkips"] = static_cast<int>(RouletteManager.maxSkips); | ||
|
||
if (!std::filesystem::exists(m_savefile)) | ||
{ | ||
if (!std::filesystem::exists(m_savefile_directory)) | ||
std::filesystem::create_directory(m_savefile_directory); | ||
|
||
std::ofstream file(m_savefile, std::ios::out | std::ios::trunc); | ||
file << m_default_savedata.dump(4); | ||
file.close(); | ||
|
||
m_savedata.update(m_default_savedata); | ||
} | ||
|
||
std::ifstream file(m_savefile); | ||
try | ||
{ | ||
file >> m_savedata; | ||
|
||
if (m_savedata["normalList"].get<bool>() == m_savedata["demonList"].get<bool>() == m_savedata["challengeList"].get<bool>() == false) | ||
m_savedata["normalList"] = true; | ||
|
||
RouletteManager.selectedListArr[0].assignNoSave(m_savedata["normalList"]); | ||
RouletteManager.selectedListArr[1].assignNoSave(m_savedata["demonList"]); | ||
RouletteManager.selectedListArr[2].assignNoSave(m_savedata["challengeList"]); | ||
RouletteManager.maxSkips.assignNoSave(m_savedata["maxSkips"]); | ||
} | ||
catch (...) | ||
{ | ||
file.close(); | ||
RouletteManager.isJsonCorrupted = true; | ||
std::ofstream openedFile(m_savefile, std::ios::out | std::ios::trunc); | ||
openedFile << m_default_savedata.dump(4); | ||
openedFile.close(); | ||
} | ||
|
||
file.close(); | ||
} | ||
|
||
void JsonManager::save() | ||
{ | ||
m_savedata["normalList"] = static_cast<bool>(RouletteManager.selectedListArr[0]); | ||
m_savedata["demonList"] = static_cast<bool>(RouletteManager.selectedListArr[1]); | ||
m_savedata["challengeList"] = static_cast<bool>(RouletteManager.selectedListArr[2]); | ||
m_savedata["maxSkips"] = static_cast<int>(RouletteManager.maxSkips); | ||
|
||
std::ofstream file(m_savefile, std::ios::out | std::ios::trunc); | ||
file << m_savedata.dump(4); | ||
file.close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
#include "../pch.hpp" | ||
#include <nlohmann/json.hpp> | ||
|
||
class JsonManager | ||
{ | ||
public: | ||
JsonManager(); | ||
~JsonManager() = default; | ||
|
||
static void save(); | ||
|
||
private: | ||
inline static std::filesystem::path m_savefile_directory = std::filesystem::path(std::getenv("appdata")) / "GD-Roulette"; | ||
inline static std::filesystem::path m_savefile = m_savefile_directory / "options.json"; | ||
|
||
static nlohmann::ordered_json m_default_savedata; | ||
static nlohmann::ordered_json m_savedata; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#pragma once | ||
#include "../pch.hpp" | ||
#include "JsonManager.hpp" | ||
|
||
// this class just writes the savedata after each assignment | ||
// because 1: there is no main loop | ||
// and 2: there aren't that many options to save, so i cba'd to hook the render loop or similar | ||
template<typename T> | ||
class WriteInvoking | ||
{ | ||
public: | ||
WriteInvoking<T>& operator=(const T& t) | ||
{ | ||
m_data = t; | ||
|
||
JsonManager::save(); | ||
|
||
return *this; | ||
} | ||
|
||
constexpr bool operator==(const T t) | ||
{ | ||
return t == m_data; | ||
} | ||
|
||
constexpr operator T() | ||
{ | ||
return m_data; | ||
} | ||
|
||
WriteInvoking(T t) | ||
: m_data(t) {} | ||
|
||
WriteInvoking() | ||
: m_data{} {} | ||
|
||
void assignNoSave(T t) | ||
{ | ||
m_data = t; | ||
} | ||
|
||
private: | ||
T m_data; | ||
}; | ||
|
||
template<typename T, std::size_t S> | ||
class WriteInvoking<std::array<T, S>> : public std::array<WriteInvoking<T>, S> | ||
{}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#include "CustomLayer.hpp" | ||
|
||
bool CustomLayer::createBasics(CCPoint contentSize, SEL_MenuHandler onClose, float closeBtnScale, const ccColor4B& color) | ||
{ | ||
if (!CCLayerColor::initWithColor(color)) return false; | ||
|
||
alertSize = contentSize; | ||
|
||
CCDirector* director = CCDirector::sharedDirector(); | ||
director->getTouchDispatcher()->incrementForcePrio(2); | ||
|
||
setTouchEnabled(true); | ||
setKeypadEnabled(true); | ||
|
||
m_pLayer = CCLayer::create(); | ||
|
||
this->addChild(m_pLayer); | ||
|
||
CCSize winSize = director->getWinSize(); | ||
extension::CCScale9Sprite* bg = extension::CCScale9Sprite::create("GJ_square01.png", { .0f, .0f, 80.0f, 80.0f }); | ||
bg->setContentSize(alertSize); | ||
m_pLayer->addChild(bg, -1); | ||
bg->setPosition({ winSize.width / 2, winSize.height / 2 }); | ||
|
||
m_pButtonMenu = CCMenu::create(); | ||
m_pLayer->addChild(m_pButtonMenu, 10); | ||
|
||
closeBtn = createButton("GJ_closeBtn_001.png", { -((alertSize.x) / 2) + 9.5f, (alertSize.y / 2) - 10 }, onClose, -1, closeBtnScale); | ||
|
||
return true; | ||
} | ||
|
||
void CustomLayer::createTitle(std::string text, float separatorScale, float usernameScale) | ||
{ | ||
auto userName = CCLabelBMFont::create(text.c_str(), "bigFont.fnt"); | ||
userName->setPosition({ 0, (alertSize.y / 2) - 22 }); | ||
userName->setScale(usernameScale); | ||
m_pButtonMenu->addChild(userName); | ||
|
||
auto separator = CCSprite::createWithSpriteFrameName("floorLine_001.png"); | ||
separator->setPosition({ 0, (alertSize.y / 2) - 46 }); | ||
separator->setScaleX(separatorScale); | ||
separator->setOpacity(100); | ||
m_pButtonMenu->addChild(separator); | ||
} | ||
|
||
gd::CCMenuItemSpriteExtra* CustomLayer::createButton(const char* texture, CCPoint position, SEL_MenuHandler callback, int tag, float textureScale, float sizeMult) | ||
{ | ||
auto buttonSprite = CCSprite::createWithSpriteFrameName(texture); | ||
buttonSprite->setScale(textureScale); | ||
auto button = gd::CCMenuItemSpriteExtra::create( | ||
buttonSprite, | ||
this, | ||
callback | ||
); | ||
button->setPosition(position); | ||
button->setSizeMult(sizeMult); | ||
if (tag != -1) | ||
button->setTag(tag); | ||
m_pButtonMenu->addChild(button); | ||
|
||
return button; | ||
} | ||
|
||
// overriden because clicking space crashes the game | ||
void CustomLayer::keyDown(enumKeyCodes key) | ||
{ | ||
if (key == enumKeyCodes::KEY_Escape) | ||
onClose(nullptr); | ||
} | ||
|
||
void CustomLayer::keyBackClicked() | ||
{ | ||
onClose(nullptr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
#include "../pch.hpp" | ||
|
||
class CustomLayer : public gd::FLAlertLayer | ||
{ | ||
public: | ||
CCPoint alertSize{}; | ||
gd::CCMenuItemSpriteExtra* closeBtn{}; | ||
|
||
bool createBasics(CCPoint, SEL_MenuHandler, float = 1, const ccColor4B & = { 0x00, 0x00, 0x00, 0x4B }); | ||
void createTitle(std::string, float = .75f, float = 1); | ||
gd::CCMenuItemSpriteExtra* createButton(const char*, CCPoint, SEL_MenuHandler, int = -1, float = 1.0f, float = 1.2f); | ||
virtual void onClose(CCObject*) = 0; | ||
void keyDown(enumKeyCodes); | ||
void keyBackClicked(); | ||
}; |
Oops, something went wrong.