diff --git a/Makefile b/Makefile index 6401316..9f2ca5a 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,7 @@ APP_VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO} #--------------------------------------------------------------------------------- ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE -CFLAGS := -g -Wall -O2 -ffunction-sections \ +CFLAGS := -g -Wall -Wno-sign-compare -O2 -ffunction-sections \ $(ARCH) $(DEFINES) CFLAGS += `sdl2-config --cflags` `freetype-config --cflags` diff --git a/include/gui.h b/include/gui.h index 44f73be..3a2b4bd 100644 --- a/include/gui.h +++ b/include/gui.h @@ -77,6 +77,7 @@ extern Tex SdCardTexture; extern Tex NetworkTexture; extern Tex Enigma2Texture; extern Tex InfoTexture; +extern Tex SettingsTexture; extern Tex FolderTexture; extern Tex FileTexture; diff --git a/include/windows.h b/include/windows.h index 475fa97..cb50701 100644 --- a/include/windows.h +++ b/include/windows.h @@ -21,6 +21,7 @@ namespace Windows { void NetworkWindow(bool *focus, bool *first_item); void InfoMenuWindow(bool *focus, bool *first_item); void VideoWindow(bool *focus, bool *first_item); + void SettingsMenuWindow(bool *focus, bool *first_item); } diff --git a/romfs/settings.png b/romfs/settings.png new file mode 100644 index 0000000..2a8be21 Binary files /dev/null and b/romfs/settings.png differ diff --git a/source/UI/enigmaui.cpp b/source/UI/enigmaui.cpp index f5dea18..3a94468 100644 --- a/source/UI/enigmaui.cpp +++ b/source/UI/enigmaui.cpp @@ -18,13 +18,13 @@ namespace Windows { if (ImGui::BeginListBox("Enigma2 Browser Menu",ImVec2(1280.0f, 720.0f))){ if(item.enigma2bouquet == ""){ for (unsigned int n = 0; n < enigma2->e2services.size(); n++){ - const bool is_selected = (item_current_idx == n); - if (ImGui::Selectable(enigma2->e2services[n].name.c_str(), is_selected)){ + static int selected = -1; + if (ImGui::Selectable(enigma2->e2services[n].name.c_str(), selected == n)){ enigma2->m3uParser((char *)enigma2->e2services[n].bouquetref.c_str()); item.enigma2bouquet = enigma2->e2services[n].bouquetref; } - if (is_selected) + if (selected) ImGui::SetItemDefaultFocus(); } @@ -34,14 +34,14 @@ namespace Windows { } }else if(item.enigma2bouquet != ""){ for (unsigned int n = 0; n < enigma2->e2currbouqet.size(); n++){ - const bool is_selected = (item_current_idx == n); + static int selected = -1; std::string channame = std::to_string(n) + std::string(". ") +enigma2->e2currbouqet[n].name; - if (ImGui::Selectable(channame.c_str(), is_selected)){ + if (ImGui::Selectable(channame.c_str(), selected == n)){ const char *cmd[] = {"loadfile", enigma2->e2currbouqet[n].url.c_str(), NULL}; mpv_command_async(mpv->getHandle(), 0, cmd); } - if (is_selected) + if (selected) ImGui::SetItemDefaultFocus(); } if (*first_item) { diff --git a/source/UI/filebrowser.cpp b/source/UI/filebrowser.cpp index c527c41..945d3cb 100644 --- a/source/UI/filebrowser.cpp +++ b/source/UI/filebrowser.cpp @@ -23,9 +23,8 @@ namespace Windows { } if (ImGui::BeginListBox("File Browser Menu",ImVec2(1280.0f, 720.0f))){ int total_w = ImGui::GetContentRegionAvail().x; - //ImGui::Text("current path: %s",item.localpath.c_str()); for (unsigned int n = 0; n < item.localfileentries.size(); n++){ - const bool is_selected = (item_current_idx == n); + static int selected = -1; if(item.localfileentries[n].type == FsDirEntryType_Dir || FS::GetFileType(item.localfileentries[n].name) != FileTypeNone){ if(item.localfileentries[n].type == FsDirEntryType_Dir){ ImGui::Image((void*)(intptr_t)FolderTexture.id, ImVec2(40,40)); @@ -34,7 +33,7 @@ namespace Windows { } ImGui::SameLine(); ImGui::SetCursorPos({ImGui::GetCursorPos().x, ImGui::GetCursorPos().y + (40 - ImGui::GetFont()->FontSize) / 2}); - if (ImGui::Selectable(item.localfileentries[n].name, is_selected)){ + if (ImGui::Selectable(item.localfileentries[n].name, selected == n)){ if(item.localfileentries[n].type == FsDirEntryType_Dir){ item.first_item = true; item_current_idx = 0; @@ -57,7 +56,7 @@ namespace Windows { ImGui::Text("%s",Utility::humanSize(item.localfileentries[n].file_size).c_str()); } } - if (is_selected) + if (selected) ImGui::SetItemDefaultFocus(); } if (*first_item) { diff --git a/source/UI/mainMenu.cpp b/source/UI/mainMenu.cpp index 202778a..662af0c 100644 --- a/source/UI/mainMenu.cpp +++ b/source/UI/mainMenu.cpp @@ -10,7 +10,7 @@ namespace Windows { void MainMenuWindow(bool *focus, bool *first_item) { Windows::SetupWindow(); - std::vector topmenu = {"Local Files","Network","Enigma2","Info","Exit"}; + std::vector topmenu = {"Local Files","Network","Enigma2","Settings","Info","Exit"}; if (ImGui::Begin(nxmpTitle.c_str(), nullptr, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse)) { ImGui::SetNextWindowFocus(); @@ -30,6 +30,9 @@ namespace Windows { else if(topmenu[n] == "Info"){ ImGui::Image((void*)(intptr_t)InfoTexture.id, ImVec2(40,40)); } + else if(topmenu[n] == "Settings"){ + ImGui::Image((void*)(intptr_t)SettingsTexture.id, ImVec2(40,40)); + } else if(topmenu[n] == "Exit"){ ImGui::Image((void*)(intptr_t)ExitTexture.id, ImVec2(40,40)); } @@ -66,9 +69,12 @@ namespace Windows { } } if(n==3){ - item.state = MENU_STATE_INFO; + item.state = MENU_STATE_SETTINGS; } if(n==4){ + item.state = MENU_STATE_INFO; + } + if(n==5){ renderloopdone = true; } } diff --git a/source/UI/networkBrowser.cpp b/source/UI/networkBrowser.cpp index aed6bca..c404ad2 100644 --- a/source/UI/networkBrowser.cpp +++ b/source/UI/networkBrowser.cpp @@ -20,7 +20,7 @@ namespace Windows { if(item.networkselect){ if (ImGui::BeginListBox("Network Source Menu",ImVec2(1280.0f, 720.0f))){ for(unsigned int n=0;nFontSize) / 2}); - if (ImGui::Selectable(item.networksources[n].name.c_str(), is_selected)){ + if (ImGui::Selectable(item.networksources[n].name.c_str(), selected == n)){ item.first_item = true; item.networkselect = false; item.networkurl = item.networksources[n].url; - item.networklastpath = thisurl.path; + if(thisurl.scheme == "http" || thisurl.scheme == "https"){ + item.networklastpath = ""; item_current_idx = 0; httpdir->setUrl(item.networkurl = item.networksources[n].url); item.networkentries = httpdir->dirList(""); std::sort(item.networkentries.begin(),item.networkentries.end(),Utility::compare); } if(thisurl.scheme == "ftp"){ + item.networklastpath = thisurl.path; netbuf *ftp_con = nullptr; printf("FTP CONNECT %s\n",thisurl.server.c_str()); if(thisurl.port == "")thisurl.port = "21"; @@ -61,7 +63,7 @@ namespace Windows { } } } - if (is_selected) + if (selected) ImGui::SetItemDefaultFocus(); } @@ -92,8 +94,8 @@ namespace Windows { ImGui::SetCursorPos({ImGui::GetCursorPos().x, ImGui::GetCursorPos().y + (40 - ImGui::GetFont()->FontSize) / 2}); urlschema thisurl = Utility::parseUrl(item.networkurl); - const bool is_selected = (item_current_idx == n); - if (ImGui::Selectable(item.networkentries[n].name.c_str(), is_selected)){ + static int selected = -1; + if (ImGui::Selectable(item.networkentries[n].name.c_str(), selected == n)){ if(item.networkentries[n].isDir){ item.first_item = true; @@ -138,8 +140,7 @@ namespace Windows { } } } - if (is_selected) - ImGui::SetItemDefaultFocus(); + if(!item.networkentries[n].isDir && thisurl.scheme != "http"){ ImGui::SameLine(total_w-150); ImGui::Text("%s",Utility::humanSize(item.networkentries[n].size).c_str()); diff --git a/source/UI/settingsMenu.cpp b/source/UI/settingsMenu.cpp new file mode 100644 index 0000000..c7212f1 --- /dev/null +++ b/source/UI/settingsMenu.cpp @@ -0,0 +1,25 @@ +#include "gui.h" +#include "imgui.h" +#include "imgui_internal.h" +#include "windows.h" +#include "utils.h" +#include "localfiles.h" +#include "Enigma2.h" + + +namespace Windows { + void SettingsMenuWindow(bool *focus, bool *first_item) { + Windows::SetupWindow(); + if (ImGui::Begin("Settings Window", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse)) { + if (!*focus) { + ImGui::SetNextWindowFocus(); + *focus = true; + } + auto windowWidth = ImGui::GetWindowSize().x; + ImGui::SetCursorPosX((windowWidth - ImGui::CalcTextSize("No Settings right now", NULL, true).x) * 0.5f); + ImGui::Text("No Settings right now"); + + } + Windows::ExitWindow(); + } +} \ No newline at end of file diff --git a/source/gui.cpp b/source/gui.cpp index 2c8d728..3380161 100644 --- a/source/gui.cpp +++ b/source/gui.cpp @@ -30,9 +30,7 @@ namespace GUI { wakeup_on_mpv_events = SDL_RegisterEvents(1); mpv_set_wakeup_callback(mpv->getHandle(), [](void *) -> void {SDL_Event event = {.type = wakeup_on_mpv_events}; SDL_PushEvent(&event);}, NULL); mpv_render_context_set_update_callback(mpv->getContext(), [](void *) -> void { SDL_Event event = {.type = wakeup_on_mpv_render_update}; SDL_PushEvent(&event); }, NULL); - - - + } void toggleStats(){ @@ -229,22 +227,14 @@ namespace GUI { count --; printf("event: %s\n", mpv_event_name(mp_event->event_id)); } - - } - - } - } void HandleLayers(){ - //bool focus = false, first_item = true; ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplSDL2_NewFrame(window); ImGui::NewFrame(); - //if(mpv->isStopped()){ - //GUI switch (item.state) { case MENU_STATE_HOME: Windows::MainMenuWindow(&item.focus, &item.first_item); @@ -258,6 +248,9 @@ namespace GUI { case MENU_STATE_ENIGMABROWSER: Windows::EnigmaWindow(&item.focus, &item.first_item); break; + case MENU_STATE_SETTINGS: + Windows::SettingsMenuWindow(&item.focus, &item.first_item); + break; case MENU_STATE_INFO: Windows::InfoMenuWindow(&item.focus, &item.first_item); break; @@ -269,9 +262,6 @@ namespace GUI { } - - - //} } diff --git a/source/main.cpp b/source/main.cpp index 697a46e..b3138ef 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -38,6 +38,8 @@ Tex SdCardTexture; Tex NetworkTexture; Tex Enigma2Texture; Tex InfoTexture; +Tex SettingsTexture; + Tex FolderTexture; Tex FileTexture; @@ -100,8 +102,9 @@ static bool init() { int main() { socketInitializeDefault(); +#ifdef NDEBUG nxlinkStdio(); - +#endif printf("Loading Config\n"); configini = new Config("config.ini"); @@ -233,6 +236,8 @@ int main() { Utility::TxtLoadPNGFromFile("romfs:/folder.png",&FolderTexture.id,&FolderTexture.width,&FolderTexture.height); Utility::TxtLoadPNGFromFile("romfs:/file.png",&FileTexture.id,&FileTexture.width,&FileTexture.height); Utility::TxtLoadPNGFromFile("romfs:/info.png",&InfoTexture.id,&InfoTexture.width,&InfoTexture.height); + Utility::TxtLoadPNGFromFile("romfs:/settings.png",&SettingsTexture.id,&SettingsTexture.width,&SettingsTexture.height); + Utility::TxtLoadPNGFromFile("romfs:/ffmpeg.png",&FFMPEGTexture.id,&FFMPEGTexture.width,&FFMPEGTexture.height); Utility::TxtLoadPNGFromFile("romfs:/http.png",&HTTPTexture.id,&HTTPTexture.width,&HTTPTexture.height); Utility::TxtLoadPNGFromFile("romfs:/ftp.png",&FTPTexture.id,&FTPTexture.width,&FTPTexture.height); diff --git a/source/mpv.cpp b/source/mpv.cpp index 2fa7afa..aa30daa 100644 --- a/source/mpv.cpp +++ b/source/mpv.cpp @@ -1,10 +1,6 @@ #include #include "mpv.h" -static void *get_proc_address_mpv(void *unused, const char *name) { - return SDL_GL_GetProcAddress(name); -} - Mpv::Mpv(const std::string &configPath, bool initRender) { handle = mpv_create(); @@ -74,8 +70,7 @@ Mpv::~Mpv() { mpv_render_context_free(context); } if (handle) { - //mpv_terminate_destroy(handle); - mpv_detach_destroy(handle); + mpv_terminate_destroy(handle); } } diff --git a/source/remotefs/Enigma2/Enigma2.cpp b/source/remotefs/Enigma2/Enigma2.cpp index 5f3a83e..e3225bb 100644 --- a/source/remotefs/Enigma2/Enigma2.cpp +++ b/source/remotefs/Enigma2/Enigma2.cpp @@ -88,7 +88,6 @@ vector Enigma2::parseBouquet(char * data){ XMLElement * pe2serviceRef = pe2service->FirstChildElement("e2servicereference"); tmpele.name = pe2serviceName->GetText(); tmpele.bouquetref = pe2serviceRef->GetText(); - printf("%s\n",tmpele.name.c_str()); tmpret.push_back(tmpele); pe2service = pe2service->NextSiblingElement("e2service"); } diff --git a/source/remotefs/HTTPDir/HTTPDir.cpp b/source/remotefs/HTTPDir/HTTPDir.cpp index 67b2c76..2c41b4a 100644 --- a/source/remotefs/HTTPDir/HTTPDir.cpp +++ b/source/remotefs/HTTPDir/HTTPDir.cpp @@ -54,8 +54,6 @@ std::vector HTTPDir::dirList(std::string path){ std::string geturl = url + currentrelpath + path; HTTPMemoryStruct *chunk = (HTTPMemoryStruct *)malloc(sizeof(HTTPMemoryStruct)); curlDownload((char *)geturl.c_str(),chunk); - //printf("%s\n",chunk->memory); - std::string s = chunk->memory; std::smatch sm; currentrelpath = currentrelpath+path; diff --git a/source/remotefs/HTTPDir/HTTPDir.h b/source/remotefs/HTTPDir/HTTPDir.h index e8f620a..f854783 100644 --- a/source/remotefs/HTTPDir/HTTPDir.h +++ b/source/remotefs/HTTPDir/HTTPDir.h @@ -10,8 +10,6 @@ #include #include "remotefs.h" - - struct HTTPMemoryStruct { char *memory; size_t size;