Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Includes/findThemes.cpp
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) {
Copy link
Owner

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::?

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);
}
12 changes: 12 additions & 0 deletions Includes/findThemes.h
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
30 changes: 30 additions & 0 deletions Includes/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "outputLine.h"
#include "findXBE.h"
#include "findThemes.h"
#include "settingsMenu.hpp"
#ifdef NXDK
#include <hal/xbox.h>
Expand Down Expand Up @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't do anything different from MenuNode, does it?
In that case, this can be removed.

I'd wager you want ThemeItem to perform the actual magic in the end anyways?


/******************************************************************************************
MenuLaunch
******************************************************************************************/
Expand Down Expand Up @@ -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);
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions Includes/menu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The 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);
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ INCDIR = $(CURDIR)/Includes
RESOURCEDIR = $(CURDIR)/Resources

SRCS += $(CURDIR)/main.cpp $(INCDIR)/outputLine.cpp \
$(INCDIR)/subsystems.cpp $(INCDIR)/findXBE.cpp \
$(INCDIR)/subsystems.cpp $(INCDIR)/findXBE.cpp $(INCDIR)/findThemes.cpp \
$(INCDIR)/renderer.cpp $(INCDIR)/font.cpp $(INCDIR)/networking.cpp \
$(INCDIR)/ftpServer.cpp $(INCDIR)/ftpConnection.cpp \
$(INCDIR)/menu.cpp $(INCDIR)/langMenu.cpp $(INCDIR)/timeMenu.cpp \
Expand Down
5 changes: 5 additions & 0 deletions sampleconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
{
"label": "Some stupid submenu",
"type": "submenu"
},
{
"label": "Themes",
"type": "themes",
"path": "F:\\Themes"
}
]
}