Skip to content

Commit

Permalink
v 0.1.0
Browse files Browse the repository at this point in the history
First public release
  • Loading branch information
proconsule committed Oct 24, 2021
1 parent 5e869b0 commit 341ebb1
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
1 change: 1 addition & 0 deletions include/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions include/windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

Expand Down
Binary file added romfs/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions source/UI/enigmaui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}
Expand All @@ -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) {
Expand Down
7 changes: 3 additions & 4 deletions source/UI/filebrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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;
Expand All @@ -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) {
Expand Down
10 changes: 8 additions & 2 deletions source/UI/mainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Windows {
void MainMenuWindow(bool *focus, bool *first_item) {
Windows::SetupWindow();
std::vector<std::string> topmenu = {"Local Files","Network","Enigma2","Info","Exit"};
std::vector<std::string> 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();
Expand All @@ -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));
}
Expand Down Expand Up @@ -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;
}
}
Expand Down
17 changes: 9 additions & 8 deletions source/UI/networkBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;n<item.networksources.size();n++){
const bool is_selected = (item_current_idx == n);
static int selected = -1;
urlschema thisurl = Utility::parseUrl(item.networksources[n].url);
if(thisurl.scheme == "ftp"){
ImGui::Image((void*)(intptr_t)FTPTexture.id, ImVec2(40,40));
Expand All @@ -31,18 +31,20 @@ namespace Windows {
ImGui::SameLine();
ImGui::SetCursorPos({ImGui::GetCursorPos().x, ImGui::GetCursorPos().y + (40 - ImGui::GetFont()->FontSize) / 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";
Expand All @@ -61,7 +63,7 @@ namespace Windows {
}
}
}
if (is_selected)
if (selected)
ImGui::SetItemDefaultFocus();
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
25 changes: 25 additions & 0 deletions source/UI/settingsMenu.cpp
Original file line number Diff line number Diff line change
@@ -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();
}
}
18 changes: 4 additions & 14 deletions source/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -269,9 +262,6 @@ namespace GUI {


}


//}

}

Expand Down
7 changes: 6 additions & 1 deletion source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Tex SdCardTexture;
Tex NetworkTexture;
Tex Enigma2Texture;
Tex InfoTexture;
Tex SettingsTexture;


Tex FolderTexture;
Tex FileTexture;
Expand Down Expand Up @@ -100,8 +102,9 @@ static bool init() {
int main() {

socketInitializeDefault();
#ifdef NDEBUG
nxlinkStdio();

#endif
printf("Loading Config\n");

configini = new Config("config.ini");
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 1 addition & 6 deletions source/mpv.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#include <SDL2/SDL_video.h>
#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();
Expand Down Expand Up @@ -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);
}
}

Expand Down
1 change: 0 additions & 1 deletion source/remotefs/Enigma2/Enigma2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ vector<EnigmaServices> 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");
}
Expand Down
2 changes: 0 additions & 2 deletions source/remotefs/HTTPDir/HTTPDir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ std::vector<remotefs_entry> 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;
Expand Down
2 changes: 0 additions & 2 deletions source/remotefs/HTTPDir/HTTPDir.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include <curl/curl.h>
#include "remotefs.h"



struct HTTPMemoryStruct {
char *memory;
size_t size;
Expand Down

0 comments on commit 341ebb1

Please sign in to comment.