Skip to content

Commit

Permalink
Added CFileBrowser class to simplify/unify GUI (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
proconsule committed Sep 6, 2023
1 parent 25cf20d commit f860135
Show file tree
Hide file tree
Showing 9 changed files with 371 additions and 87 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ include $(DEVKITPRO)/libnx/switch_rules
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source/logger source/stats libs/imgui libs/imgui/opengl3 libs/imgui/misc/freetype source source/updater source/curldownloader source/touchcontrols source/playlist source/shadermania source/eqpreset source/database source/UI source/remotefs/UPNP source/remotefs/nfsDir source/remotefs/smb2 source/remotefs/sshDir source/remotefs/Enigma2 source/localfs source/localfs/usb source/remotefs/ftplib source/remotefs/HTTPDir source/themes
SOURCES := source/fileBrowser source/logger source/stats libs/imgui libs/imgui/opengl3 libs/imgui/misc/freetype source source/updater source/curldownloader source/touchcontrols source/playlist source/shadermania source/eqpreset source/database source/UI source/remotefs/UPNP source/remotefs/nfsDir source/remotefs/smb2 source/remotefs/sshDir source/remotefs/Enigma2 source/localfs source/localfs/usb source/remotefs/ftplib source/remotefs/HTTPDir source/themes
DATA := data
INCLUDES := source/logger source/stats libs/simpleini libs/imgui libs/imgui/opengl3 include source/curldownloader source/updater source/touchcontrols source/playlist source/shadermania source/eqpreset source/database source/remotefs/UPNP source/remotefs/nfsDir source/remotefs/smb2 source/remotefs/sshDir source/remotefs/Enigma2 source/localfs source/localfs/usb source/remotefs/ftplib source/remotefs/HTTPDir source/themes
INCLUDES := source/fileBrowser source/logger source/stats libs/simpleini libs/imgui libs/imgui/opengl3 include source/curldownloader source/updater source/touchcontrols source/playlist source/shadermania source/eqpreset source/database source/remotefs/UPNP source/remotefs/nfsDir source/remotefs/smb2 source/remotefs/sshDir source/remotefs/Enigma2 source/localfs source/localfs/usb source/remotefs/ftplib source/remotefs/HTTPDir source/themes
ROMFS := romfs

GITREV:= -D'GITREV="$(shell git rev-parse --short HEAD)"'
Expand Down
7 changes: 7 additions & 0 deletions include/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

#include "Enigma2.h"

#include "fileBrowserClass.h"


#include "HTTPDir.h"
#include "FTPDir.h"
Expand Down Expand Up @@ -209,12 +211,17 @@ extern SDL_Window *window;
extern MenuItem item;

extern libMpv *libmpv;

extern CFileBrowser *filebrowser;

/*
extern localFs *localdir;
extern HTTPDir *httpdir;
extern FTPDir *ftpdir;
extern sshDir *sshdir;
extern sambaDir *sambadir;
extern nfsDir *nfsdir;
*/
extern NXUPnP *nxupnp;
extern USBMounter *usbmounter;
extern Enigma2 *enigma2;
Expand Down
16 changes: 8 additions & 8 deletions source/UI/filebrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ namespace Windows {
}

if (ImGui::BeginMenuBar()) {
ImGui::Text("current path: %s",localdir->getCurrentPath().c_str());
ImGui::Text("current path: %s",filebrowser->getCurrentPath().c_str());
ImGui::EndMenuBar();
}
float total_w = ImGui::GetContentRegionAvail().x;
float total_h = ImGui::GetContentRegionAvail().y;
if (ImGui::BeginListBox("File Browser Menu",ImVec2(total_w, total_h))){

std::vector<FS::FileEntry> thislist = localdir->getCurrList();
std::vector<FS::FileEntry> thislist = filebrowser->getCurrList();
bool triggerselect = false;
for (unsigned int n = 0; n < thislist.size(); n++){

Expand All @@ -43,14 +43,14 @@ namespace Windows {
ImGui::SetCursorPos({ImGui::GetCursorPos().x, ImGui::GetCursorPos().y + (40*multiplyRes - ImGui::GetFont()->FontSize) / 2});
if (ImGui::Selectable(itemid.c_str(), selected == n)){
triggerselect = true;
localdir->DirList(thislist[n].path,configini->getshowHidden(false),Utility::getMediaExtensions());
filebrowser->DirList(thislist[n].path,configini->getshowHidden(false),Utility::getMediaExtensions());
}
}else{
ImGui::SetCursorPos({ImGui::GetCursorPos().x, ImGui::GetCursorPos().y + (40*multiplyRes - ImGui::GetFont()->FontSize - ImGui::GetStyle().FramePadding.y * 2) / 2});
std::string checkitemid = "##check" + std::to_string(n);
if(thislist[n].type != FS::FileEntryType::Directory){
if(ImGui::Checkbox(checkitemid.c_str(), localdir->checked(n))){
if(*localdir->checked(n)){
if(ImGui::Checkbox(checkitemid.c_str(), filebrowser->checked(n))){
if(*filebrowser->checked(n)){
playlist->appendFile(thislist[n].name,thislist[n].path);
} else {
playlist->removeFile(thislist[n].name,thislist[n].path);
Expand All @@ -65,14 +65,14 @@ namespace Windows {
if(item.selectionstate == FILE_SELECTION_NONE){
ImGui::SetCursorPos({ImGui::GetCursorPos().x, ImGui::GetCursorPos().y + (40*multiplyRes - ImGui::GetFont()->FontSize) / 2});
if (ImGui::Selectable(itemid.c_str(), selected == n)){
if(localdir->getCurrList()[n].type == FS::FileEntryType::Directory){
if(filebrowser->getCurrList()[n].type == FS::FileEntryType::Directory){
triggerselect = true;
localdir->DirList(thislist[n].path,configini->getshowHidden(false),Utility::getMediaExtensions());
filebrowser->DirList(thislist[n].path,configini->getshowHidden(false),Utility::getMediaExtensions());
}
else{
item.laststate = item.state;
playlist->clearPlaylist();
localdir->clearChecked();
filebrowser->clearChecked();
libmpv->loadFile(thislist[n].path);
if(configini->getDbActive(true)){
libmpv->getFileInfo()->resume = sqlitedb->getResume(thislist[n].path);
Expand Down
4 changes: 2 additions & 2 deletions source/UI/mainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ namespace Windows {
if (ImGui::Selectable(itemid.c_str(), selected == n)){
if(topmenu[n] == "Local Files"){
item.state = MENU_STATE_FILEBROWSER;
localdir = new localFs(configini->getStartPath(),playlist);
localdir->DirList(configini->getStartPath(),true,Utility::getMediaExtensions());
filebrowser = new CFileBrowser(configini->getStartPath(),playlist);
filebrowser->DirList(configini->getStartPath(),true,Utility::getMediaExtensions());
item.first_item = true;
}
if(topmenu[n] == "USB"){
Expand Down
Loading

0 comments on commit f860135

Please sign in to comment.