-
Notifications
You must be signed in to change notification settings - Fork 22
(DRAFT) Add theme support #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // | ||
| // Created by kosmas on 28/7/21. | ||
| // | ||
|
|
||
| #include "findThemes.h" | ||
| #include "outputLine.h" | ||
| #ifdef NXDK | ||
| #include <windows.h> | ||
| #endif | ||
|
|
||
| void findThemes(std::string const& path, MenuThemes *list) { | ||
| std::string workPath = path; | ||
| if (workPath.back() != '\\') { | ||
| workPath += '\\'; | ||
| } | ||
| std::string searchMask = workPath + "*"; | ||
|
|
||
| WIN32_FIND_DATA findFileData; | ||
| HANDLE hFind; | ||
| std::string tmp; | ||
|
|
||
| hFind = FindFirstFile(searchMask.c_str(), &findFileData); | ||
| if (hFind == INVALID_HANDLE_VALUE) { | ||
| outputLine("FindFirstHandle() failed!\n"); | ||
| } | ||
|
|
||
| do { | ||
| if (!(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { | ||
| std::string type = path.substr(path.find(".") + 1); | ||
| if (type == "nevoxtheme") { | ||
| tmp = path + findFileData.cFileName; | ||
| list->addNode(std::make_shared<MenuLaunch>(findFileData.cFileName, tmp)); | ||
| } | ||
| } | ||
| } while (FindNextFile(hFind, &findFileData) != 0); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // | ||
| // Created by kosmas on 28/7/21. | ||
| // | ||
|
|
||
| #ifndef NEVOLUTIONX_FINDTHEMES_H | ||
| #define NEVOLUTIONX_FINDTHEMES_H | ||
|
|
||
| #include "menu.hpp" | ||
|
|
||
| void findThemes(std::string const& path, MenuThemes *list); | ||
|
|
||
| #endif //NEVOLUTIONX_FINDTHEMES_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
|
|
||
| #include "outputLine.h" | ||
| #include "findXBE.h" | ||
| #include "findThemes.h" | ||
| #include "settingsMenu.hpp" | ||
| #ifdef NXDK | ||
| #include <hal/xbox.h> | ||
|
|
@@ -130,6 +131,31 @@ void MenuXbe::execute(Menu *menu) { | |
| } | ||
| } | ||
|
|
||
| /****************************************************************************************** | ||
| MenuThemes | ||
| ******************************************************************************************/ | ||
|
|
||
| MenuThemes::MenuThemes(MenuNode *parent, std::string const& label, std::string const& path) : | ||
| MenuNode(parent, label), path(path) { | ||
| findThemes(path, this); | ||
|
|
||
| } | ||
|
|
||
| MenuThemes::~MenuThemes() { | ||
|
|
||
| } | ||
|
|
||
| void MenuThemes::execute(Menu *menu) { | ||
| if (menu->getCurrentMenu() != this) { | ||
| menu->setCurrentMenu(this); | ||
| } | ||
| else { | ||
| if (childNodes.size() > selected) { | ||
| this->childNodes.at(selected)->execute(menu); | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+148
to
+157
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't do anything different from I'd wager you want |
||
|
|
||
| /****************************************************************************************** | ||
| MenuLaunch | ||
| ******************************************************************************************/ | ||
|
|
@@ -189,6 +215,10 @@ Menu::Menu(const Config &config, Renderer &renderer) : renderer(renderer), rootN | |
| std::shared_ptr<MenuNode> newNode = std::make_shared<settingsMenu>(currentMenu, e["label"]); | ||
| this->rootNode.addNode(newNode); | ||
| } | ||
| else if (!static_cast<std::string>(e["type"]).compare("themes")) { | ||
| std::shared_ptr<MenuThemes> newNode = std::make_shared<MenuThemes>(currentMenu, e["label"], e["path"]); | ||
| this->rootNode.addNode(newNode); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,6 +54,15 @@ class MenuXbe : public MenuNode { | |
| std::string path; | ||
| }; | ||
|
|
||
| class MenuThemes : public MenuNode { | ||
| public: | ||
| MenuThemes(MenuNode *parent, std::string const& label, std::string const& path); | ||
| ~MenuThemes(); | ||
| void execute(Menu *menu); | ||
| protected: | ||
| std::string path; | ||
| }; | ||
|
|
||
|
Comment on lines
+57
to
+65
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Worthy of its own file, no? |
||
| class MenuLaunch : public MenuItem { | ||
| public: | ||
| MenuLaunch(std::string const& label, std::string const& path); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not as part of
MenuThemes::?