From 86fa5603f9c3f904f6521b7c0c90e437f479e0f3 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Sun, 22 Aug 2021 13:38:22 -0500 Subject: [PATCH] Improved makefile --- Makefile | 64 +----- src/moon/config/saves/saves.cpp | 4 - src/moon/ui/screens/store/store-view.cpp | 238 ----------------------- src/moon/ui/screens/store/store-view.h | 16 -- 4 files changed, 2 insertions(+), 320 deletions(-) delete mode 100644 src/moon/ui/screens/store/store-view.cpp delete mode 100644 src/moon/ui/screens/store/store-view.h diff --git a/Makefile b/Makefile index 7f77b6c3..5ba0bd0c 100644 --- a/Makefile +++ b/Makefile @@ -258,68 +258,8 @@ endif # Moon64 Source Code # ################################ -# Moon64 SRC [Main] -SRC_DIRS += src/moon src/moon/texts src/moon/utils src/moon/network - -# Moon64 SRC [View] -SRC_DIRS += src/moon/ui src/moon/ui/interfaces src/moon/ui/screens src/moon/ui/screens/options src/moon/ui/screens/options/categories src/moon/ui/utils src/moon/ui/widgets src/moon/ui/screens/addons - -# Moon64 SRC [View - Animations] -SRC_DIRS += src/moon/ui/animation - -# Moon64 SRC [View - Achievements] -SRC_DIRS += src/moon/ui/screens/achievements - -# Moon64 SRC [IO] -SRC_DIRS += src/moon/io src/moon/io/modules - -# Moon64 SRC [Entity] -SRC_DIRS += src/moon/entity src/moon/entity/interfaces - -# Moon64 SRC [Mod-Engine] -SRC_DIRS += src/moon/mod-engine src/moon/mod-engine/modules - -# Moon64 SRC [Mod-Engine - Texture Module] -SRC_DIRS += src/moon/mod-engine/textures src/moon/mod-engine/textures/assets src/moon/mod-engine/textures/modifiers - -# Moon64 SRC [Mod-Engine - Audio Module] -SRC_DIRS += src/moon/mod-engine/audio - -# Moon64 SRC [Mod-Engine - Hook Module] -SRC_DIRS += src/moon/mod-engine/hooks - -# Moon64 SRC [Mod-Engine - Shaders Module] -SRC_DIRS += src/moon/mod-engine/shaders - -# Moon64 SRC [Mod-Engine - Models Module] -SRC_DIRS += src/moon/mod-engine/models - -# Moon64 SRC [Achievements] -SRC_DIRS += src/moon/achievements - -# Moon64 SRC [Config / Saves] -SRC_DIRS += src/moon/config src/moon/config/moon src/moon/config/saves - -# Moon64 SRC [Renderer / ImGui] -SRC_DIRS += src/moon/imgui - -# Moon64 LIB [RapidJSON] -SRC_DIRS += src/moon/libs/rapidjson src/moon/libs/rapidjson/error src/moon/libs/rapidjson/internal src/moon/libs/rapidjson/msinttypes - -# Moon64 LIB [Lua] -SRC_DIRS += src/moon/libs/lua - -# Moon64 LIB [Miniz] -SRC_DIRS += src/moon/libs/miniz - -# Moon64 LIB [nlohmann json] -SRC_DIRS += src/moon/libs/nlohmann - -# Moon64 LIB [MoonFS API] -SRC_DIRS += src/moon/fs - -# Moon64 LIB [ImGui] -SRC_DIRS += src/moon/libs/imgui +MOON_SRC := $(shell find src/moon/ -type d) +SRC_DIRS += $(MOON_SRC) ################################ diff --git a/src/moon/config/saves/saves.cpp b/src/moon/config/saves/saves.cpp index 49612411..73658f67 100644 --- a/src/moon/config/saves/saves.cpp +++ b/src/moon/config/saves/saves.cpp @@ -131,8 +131,6 @@ namespace MoonInternal { obtainedAchievements.push_back(rAchievements->achievement->id); } - if(cheatsGotEnabled) obtainedAchievements.clear(); - cfg->setArray("game.achievements", obtainedAchievements); cfg->setBool("game.updated", cheatsGotEnabled); #endif @@ -196,8 +194,6 @@ namespace MoonInternal { entry->dead = true; entries[fileIndex].push_back(entry); } - - if(cheatsGotEnabled) entries[fileIndex].clear(); #endif gSaveBuffer.files[fileIndex][0].flags |= (1 << 0); diff --git a/src/moon/ui/screens/store/store-view.cpp b/src/moon/ui/screens/store/store-view.cpp deleted file mode 100644 index 5957d5c4..00000000 --- a/src/moon/ui/screens/store/store-view.cpp +++ /dev/null @@ -1,238 +0,0 @@ -#include "store-view.h" -#include -#include "moon/ui/utils/moon-draw-utils.h" -#include "moon/ui/moon-ui-manager.h" -#include "moon/mod-engine/engine.h" -#include "moon/mod-engine/textures/mod-texture.h" -#include - -using namespace std; - -extern "C" { -#include "sm64.h" -#include "gfx_dimensions.h" -#include "pc/configfile.h" -} - -BitModule* currentPack; -vector texturePackList; - -int scrollModifier = 0; - -int currentSubItem = 0; -int focusFlag; -int focusRange = 80; -float focusAnim = focusRange / 2; - -enum ItemButtons{ - UP, - DOWN, - TOGGLE -}; - -void MoonStoreScreen::Init(){ - if(texturePackList.empty()){ - texturePackList.clear(); - copy(Moon::addons.begin(), Moon::addons.end(), back_inserter(texturePackList)); - reverse(texturePackList.begin(), texturePackList.end()); - } - this->scrollIndex = 0; - scrollModifier = 0; - currentPack = NULL; -} - -void MoonStoreScreen::Mount(){ - -} - -bool dispatched; - -void rebuildTextureCache(){ - vector order; - for(auto &addon : texturePackList){ - vector::iterator itr = find(Moon::addons.begin(), Moon::addons.end(), addon); - order.push_back(distance(Moon::addons.begin(), itr)); - } - reverse(order.begin(), order.end()); - MoonInternal::buildTextureCache(order); -} - -void MoonStoreScreen::changeScroll(int idx){ - if(idx < 0){ - if(this->scrollIndex > 0){ - if(scrollModifier > 0 && this->scrollIndex == scrollModifier) - scrollModifier--; - this->scrollIndex--; - return; - } - this->scrollIndex = texturePackList.size() - 1; - scrollModifier = this->scrollIndex - 4; - return; - } - if(this->scrollIndex < texturePackList.size() - 1){ - if(this->scrollIndex > 3 && !((this->scrollIndex - scrollModifier) % 4)) scrollModifier++; - this->scrollIndex++; - return; - } - this->scrollIndex = 0; - scrollModifier = 0; -} - -void MoonStoreScreen::Update(){ - float yStick = GetStickValue(MoonButtons::U_STICK, false); - if(yStick > 5) { - if(dispatched) return; - if(currentPack != NULL){ - if(currentSubItem > 0) - currentSubItem--; - else - currentSubItem = 2; - dispatched = true; - return; - } - MoonStoreScreen::changeScroll(-1); - dispatched = true; - } - if(yStick < -5) { - if(dispatched) return; - if(currentPack != NULL){ - if(currentSubItem < 2) - currentSubItem++; - else - currentSubItem = 0; - dispatched = true; - return; - } - MoonStoreScreen::changeScroll(1); - dispatched = true; - } - if(!yStick) - dispatched = false; - - if(IsBtnPressed(MoonButtons::A_BTN)) { - if(currentPack != NULL){ - switch(currentSubItem){ - case ItemButtons::UP: - if(this->scrollIndex > 0){ - std::swap(texturePackList[this->scrollIndex], texturePackList[this->scrollIndex - 1]); - MoonStoreScreen::changeScroll(-1); - currentPack = texturePackList[this->scrollIndex]; - rebuildTextureCache(); - } - break; - case ItemButtons::DOWN: - if(this->scrollIndex < texturePackList.size() - 1){ - std::swap(texturePackList[this->scrollIndex], texturePackList[this->scrollIndex + 1]); - MoonStoreScreen::changeScroll(1); - currentPack = texturePackList[this->scrollIndex]; - rebuildTextureCache(); - } - break; - case ItemButtons::TOGGLE: - break; - } - return; - } - currentPack = texturePackList[this->scrollIndex]; - currentSubItem = 0; - } - if(IsBtnPressed(MoonButtons::B_BTN)) { - if(currentPack != NULL){ - currentPack = NULL; - return; - } - MoonChangeUI(0); - } - MoonScreen::Update(); -} - -static std::string cropTxt(string txt, int length){ - int currLngt = min((int) txt.length(), length); - string desc = txt.substr(0, currLngt); - desc.erase(find_if(desc.rbegin(), desc.rend(), std::not1(std::ptr_fun(std::isspace))).base(), desc.end()); - return currLngt >= length ? desc + " ..." : desc; -} - -char *strdup(const char *src_str) noexcept { - char *new_str = new char[std::strlen(src_str) + 1]; - std::strcpy(new_str, src_str); - return new_str; -} - -void MoonStoreScreen::Draw(){ - string curTitle = "Addons"; - float step = 1.5; - - if(focusAnim >= focusRange) - focusFlag = 1; - else if (focusAnim <= focusRange / 2) - focusFlag = 0; - - focusAnim += step * (focusFlag ? -1 : 1); - - int boxWidth = SCREEN_WIDTH - 50; - int boxHeight = GetScreenHeight() * 0.8; - - float txtWidth = MoonGetTextWidth(curTitle, 1.0, true); - - MoonDrawRectangle(0, 0, GetScreenWidth(false), GetScreenHeight(), {0, 0, 0, 100}, false); - MoonDrawColoredText(SCREEN_WIDTH / 2 - txtWidth / 2, 10, curTitle, 1.0, {255, 255, 255, 255}, true, true); - MoonDrawRectangle(25, 35, boxWidth, boxHeight, {0, 0, 0, 100}, true); - - Color focusColor = {255, 255, 255, 40 + focusAnim}; - - int packAmount = texturePackList.size(); - int maxPacks = 5; - int iMod = scrollModifier; - - for(int i = 0; i < min(packAmount, maxPacks); i++){ - int index = i + iMod; - - if(index > packAmount - 1){ - this->scrollIndex = 0; - scrollModifier = 0; - cout << "Triggered overflow, coming back to 0" << endl; - return; - } - - auto &addon = texturePackList[index]; - - if(addon == NULL) return; - - bool selected = (i + iMod) == this->scrollIndex && currentPack != NULL; - int itemWidth = boxWidth - (selected ? 15 : 0); - - MoonDrawRectangle(35, 45 + (i * 35), itemWidth - 20, 31, (i + iMod) == this->scrollIndex && !selected ? focusColor : (Color){0, 0, 0, 100}, true); - string pathPrefix = "mod-icons://"; - string iconPath = pathPrefix.append(addon->name); - char* parsed = strdup(iconPath.c_str()); - if(parsed != nullptr) - MoonDrawTexture(35, 45 + (i * 35), 30, 30, parsed); - MoonDrawText(35 + 26, 46 + (i * 35), to_string(i + iMod + 1), 0.5, {255, 255, 255, 255}, true, true); - - MoonDrawText(70, 45 + (i * 35) + 3, cropTxt(addon->name, 37), 0.8, {255, 255, 255, 255}, true, true); - - int maxDesc = 37; - int currLngt = min((int) addon->description.length(), maxDesc); - MoonDrawText(70, 45 + (i * 35) + 16, cropTxt(addon->description, 37), 0.8, {255, 255, 255, 255}, true, true); - - string rawVer = to_string(addon->version); - string version = "v"+rawVer.substr(0, rawVer.find(".")+2); - - MoonDrawText(itemWidth + 13 - MoonGetTextWidth(version, 0.5, false), 45 + (i * 35) + 2, version, 0.5, {255, 255, 255, 255}, true, true); - MoonDrawText(itemWidth + 13 - MoonGetTextWidth(addon->authors[0], 0.5, false), 45 + (i * 35) + 22, addon->authors[0], 0.5, {255, 255, 255, 255}, true, true); - - if(selected){ - MoonDrawRectangle(itemWidth + 16, 45 + (i * 35), 13, 9.3, currentSubItem == ItemButtons::UP ? focusColor : (Color){0, 0, 0, 100}, true); - MoonDrawTexture (itemWidth + 18, 45 + (i * 35), 8, 8, "textures/special/up.rgba16"); - - MoonDrawRectangle(itemWidth + 16, 45 + (i * 35) + 10.9, 13, 9.3, currentSubItem == ItemButtons::DOWN ? focusColor : (Color){0, 0, 0, 100}, true); - MoonDrawTexture (itemWidth + 18, 46 + (i * 35) + 10.9, 8, 8, "textures/special/down.rgba16"); - - MoonDrawRectangle(itemWidth + 16, 45 + (i * 35) + 21.7, 13, 9.3, currentSubItem == ItemButtons::TOGGLE ? focusColor : (Color){0, 0, 0, 100}, true); - MoonDrawTexture (itemWidth + 18, 46 + (i * 35) + 21.7, 8, 8, "textures/special/remove.rgba16"); - } - } - - MoonScreen::Draw(); -} \ No newline at end of file diff --git a/src/moon/ui/screens/store/store-view.h b/src/moon/ui/screens/store/store-view.h deleted file mode 100644 index 007c6c03..00000000 --- a/src/moon/ui/screens/store/store-view.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef MoonScreenStore -#define MoonScreenStore -#include "moon/ui/interfaces/moon-screen.h" - -class MoonStoreScreen : public MoonScreen { -public: - void Init(); - void Update(); - void Draw(); - void Mount(); -private: - void changeScroll(int idx); -}; - - -#endif \ No newline at end of file