Skip to content

Commit

Permalink
v 0.2.1
Browse files Browse the repository at this point in the history
- fixed FTP navigation
- Network/Enigma are not shown if no source provided
- Enigma2 preliminary EPG support
- USB should not crash anymore
  • Loading branch information
proconsule committed Oct 28, 2021
1 parent 5db1e51 commit 54640f2
Show file tree
Hide file tree
Showing 27 changed files with 484 additions and 284 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build/
build-win32/
nxmp.*
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ROMFS := romfs

VERSION_MAJOR := 0
VERSION_MINOR := 2
VERSION_MICRO := 0
VERSION_MICRO := 1

APP_TITLE := NXMP
APP_AUTHOR := proconsule
Expand Down
73 changes: 73 additions & 0 deletions Makefile.win32
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
CC=gcc
CPP=g++

TOPDIR ?= $(CURDIR)
BUILD := build-win32

TARGET := $(notdir $(CURDIR))

VERSION_MAJOR := 0
VERSION_MINOR := 2
VERSION_MICRO := 1

CFLAGS := -g -Wall -Wno-sign-compare -O2 -ffunction-sections
CFLAGS += `sdl2-config --cflags` `freetype-config --cflags`
CFLAGS += $(INCLUDE) -D_WIN32 -DWIN32_LEAN_AND_MEAN

CFLAGS += -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_MICRO=$(VERSION_MICRO) -gdwarf-2 -gstrict-dwarf

CXXFLAGS := $(CFLAGS) -fno-rtti -fexceptions -DIMGUI_IMPL_OPENGL_LOADER_GLAD \
-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_ENABLE_FREETYPE -fpermissive


LIBS := $(shell pkgconf mpv --libs --static) $(shell pkgconf libavcodec --libs --static) -lmpv `curl-config --libs` `sdl2-config --static-libs` `freetype-config --libs` -lswscale -lswresample -lavformat -lavfilter -lavcodec -lavutil -lfreetype -lfribidi -lpng -lbz2 -ltinyxml2 -llua5.1 -ldwmapi -llcms2 -lglfw3 -lopengl32 -lmingw32 -lSDLmain -lSDL2 -mwindows -liconv -lm -luser32 -lgdi32 -lwinmm -ldxguid -lws2_32 -lavrt -lz


SOURCES := libs/glad/src/ libs/imgui libs/imgui/misc/freetype source source/UI source/remotefs/Enigma2 source/remotefs/ftplib source/remotefs/HTTPDir
INCLUDES := /mingw64/include/ libs/glad/include libs/simpleini libs/imgui include source/remotefs/Enigma2 source/remotefs/ftplib source/remotefs/HTTPDir


ifneq ($(BUILD),$(notdir $(CURDIR)))

export OUTPUT := $(CURDIR)/$(TARGET)

export TOPDIR := $(CURDIR)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)

export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))

CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))

export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SRC)

.PHONY: $(BUILD) clean all


all: $(BUILD)

$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) -C $(BUILD) -f ../Makefile.win32

clean:
@echo clean ...
@rm -fr $(BUILD) imgui-test.exe


else


all: $(OUTPUT).exe

%.o: %.cpp
$(CPP) $(CXXFLAGS) $(INCLUDE) -c $< -o $@

$(OUTPUT).exe: $(OFILES)
$(CPP) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@

endif
File renamed without changes.
1 change: 1 addition & 0 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Config{
std::string getEnigma();
std::string getStartPath();

std::vector<std::string> topmenu;
CSimpleIniA *ini;
};

Expand Down
9 changes: 6 additions & 3 deletions include/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
#include <vector>
#include <string>
#include <SDL.h>
#ifdef __SWITCH__
#include <switch.h>
#endif
#include <glad/glad.h>
#include "windows.h"
#include "appwindows.h"
#include "libmpv.h"
#include "config.h"
#include "remotefs.h"
Expand Down Expand Up @@ -41,7 +43,6 @@ typedef struct {
std::string usbpath = "";
std::string usbbasepath = "";
std::vector<FS::FileEntry> usbfileentries;
std::string enigma2bouquet = "";
std::vector<networkSource> networksources;
std::string networkurl;
std::string networklastpath;
Expand All @@ -65,7 +66,9 @@ extern MenuItem item;
extern libMpv *libmpv;
extern HTTPDir *httpdir;
extern FTPDir *ftpdir;
#ifdef __SWITCH__
extern USBMounter *usbmounter;
#endif
extern uint32_t wakeup_on_mpv_render_update;
extern uint32_t wakeup_on_mpv_events;

Expand Down Expand Up @@ -101,7 +104,7 @@ extern Tex MPVTexture;
extern Tex NXMPBannerTexture;
extern Tex ExitTexture;


extern ImFont* fontSmall;



Expand Down
2 changes: 2 additions & 0 deletions include/usbfs.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef __SWITCH__
#ifndef NXMP_USBFS_H
#define NXMP_USBFS_H

Expand Down Expand Up @@ -33,3 +34,4 @@ class USBMounter{
void usbInit();

#endif
#endif
6 changes: 2 additions & 4 deletions include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
#include <remotefs.h>

#include <glad/glad.h>
#include <turbojpeg.h>
#include <png.h>


typedef struct {
GLuint id = 0;
Expand All @@ -37,8 +36,7 @@ namespace Utility{
std::string formatTimeShort(double seconds);
urlschema parseUrl(std::string url);
bool compare(const remotefs_entry &a, const remotefs_entry &b);
bool TxtLoadJPGFromFile(std::string filename, GLuint* out_texture, int* out_width, int* out_height);
bool TxtLoadPNGFromFile(std::string filename, GLuint* out_texture, int* out_width, int* out_height);
bool TxtLoadFromFile(std::string filename, GLuint* out_texture, int* out_width, int* out_height);
std::string toLower(const std::string &str);
std::string toUpper(const std::string &str);
bool endsWith(const std::string &value, const std::string &ending, bool sensitive);
Expand Down
Binary file modified romfs/exit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 30 additions & 10 deletions source/UI/enigmaui.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "gui.h"
#include "imgui.h"
#include "imgui_internal.h"
#include "windows.h"
#include "appwindows.h"
#include "utils.h"
#include "localfiles.h"
#include "Enigma2.h"
Expand All @@ -10,19 +10,23 @@
namespace Windows {
void EnigmaWindow(bool *focus, bool *first_item) {
Windows::SetupWindow();
static unsigned int item_current_idx = 0;
std::vector<std::string> topmenu = {"Local Files","Network","Enigma2"};
std::vector<std::string> topmenu = {"Local Files","Network","Enigma2"};

if (ImGui::Begin("Enigma2", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_MenuBar)) {
ImGui::SetNextWindowFocus();
if (ImGui::BeginMenuBar()) {
ImGui::Text("%s",enigma2->getCurrBouquet().name.c_str());
ImGui::EndMenuBar();
}
if (ImGui::BeginListBox("Enigma2 Browser Menu",ImVec2(1280.0f, 720.0f))){
if(item.enigma2bouquet == ""){
if(enigma2->getCurrBouquet().bouquetref == ""){
for (unsigned int n = 0; n < enigma2->e2services.size(); n++){
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;
enigma2->setCurrBouquet(enigma2->e2services[n]);
}
if (selected)
ImGui::SetItemDefaultFocus();
Expand All @@ -32,21 +36,37 @@ namespace Windows {
ImGui::SetFocusID(ImGui::GetID(enigma2->e2services[0].name.c_str()), ImGui::GetCurrentWindow());
*first_item = false;
}
}else if(item.enigma2bouquet != ""){
}else if(enigma2->getCurrBouquet().bouquetref != ""){
for (unsigned int n = 0; n < enigma2->e2currbouqet.size(); n++){
static int selected = -1;
std::string channame = std::to_string(n) + std::string(". ") +enigma2->e2currbouqet[n].name;
if (ImGui::Selectable(channame.c_str(), selected == n)){
std::string itemid = "##" + std::to_string(n);
float currstartpos = ImGui::GetCursorPosX();
if (ImGui::Selectable(itemid.c_str(), selected == n, 0, ImVec2(0, 70))){

const char *cmd[] = {"loadfile", enigma2->e2currbouqet[n].url.c_str(), NULL};
mpv_command_async(libmpv->getHandle(), 0, cmd);
}
ImGui::SameLine();
ImGui::SetCursorPosX(currstartpos);
ImGui::Text("%s",enigma2->e2currbouqet[n].name.c_str());
ImGui::SetCursorPosY(ImGui::GetCursorPosY()-40.0f);
ImGui::PushFont(fontSmall);
ImGui::Text(u8"%s",enigma2->e2currbouqet[n].epg.title.c_str());
ImGui::PopFont();
float progressval = (float)(enigma2->e2currbouqet[n].epg.currTime-enigma2->e2currbouqet[n].epg.startTime)/(float)enigma2->e2currbouqet[n].epg.duration;
std::string progressid = std::string("progress") + itemid;
if(enigma2->e2currbouqet[n].epg.title == "")progressval=0.0f;
ImGui::PushStyleColor(ImGuiCol_PlotHistogram,ImVec4(1.0f,1.0f,1.0f,0.6f));
ImGui::ProgressBar(progressval,ImVec2(-1.0f,15),"");
ImGui::PopStyleColor(1);
ImGui::Separator();
if (selected)
ImGui::SetItemDefaultFocus();

}
if (*first_item) {
std::string channame = std::to_string(0) + std::string(". ") +enigma2->e2currbouqet[0].name;
ImGui::SetFocusID(ImGui::GetID(channame.c_str()), ImGui::GetCurrentWindow());
std::string itemid = "##" + std::to_string(0);
ImGui::SetFocusID(ImGui::GetID(itemid.c_str()), ImGui::GetCurrentWindow());
*first_item = false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/UI/filebrowser.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "gui.h"
#include "imgui.h"
#include "imgui_internal.h"
#include "windows.h"
#include "appwindows.h"
#include "utils.h"
#include "localfiles.h"
#include "Enigma2.h"
Expand Down
2 changes: 1 addition & 1 deletion source/UI/infoMenu.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "gui.h"
#include "imgui.h"
#include "imgui_internal.h"
#include "windows.h"
#include "appwindows.h"
#include "utils.h"
#include "localfiles.h"
#include "Enigma2.h"
Expand Down
8 changes: 6 additions & 2 deletions source/UI/mainMenu.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "gui.h"
#include "imgui.h"
#include "imgui_internal.h"
#include "windows.h"
#include "appwindows.h"
#include "utils.h"
#include "localfiles.h"
#include "Enigma2.h"
Expand All @@ -10,7 +10,8 @@
namespace Windows {
void MainMenuWindow(bool *focus, bool *first_item) {
Windows::SetupWindow();
std::vector<std::string> topmenu = {"Local Files","USB","Network","Enigma2","Settings","Info","Exit"};
//std::vector<std::string> topmenu = {"Local Files","USB","Network","Enigma2","Settings","Info","Exit"};
std::vector<std::string> topmenu = configini->topmenu;

if (ImGui::Begin(nxmpTitle.c_str(), nullptr, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse)) {
ImGui::SetNextWindowFocus();
Expand Down Expand Up @@ -51,10 +52,12 @@ namespace Windows {
item.first_item = true;
}
if(topmenu[n] == "USB"){
#ifdef __SWITCH__
usbInit();
item.state = MENU_STATE_USB;
usbmounter = new USBMounter();
item.first_item = true;
#endif
}
if(topmenu[n] == "Network"){
item.networksources.clear();
Expand All @@ -66,6 +69,7 @@ namespace Windows {

}
if(topmenu[n] == "Enigma2"){
enigma2 = new Enigma2();
item.first_item = true;
std::string e2uri = configini->getEnigma();
if(e2uri == ""){
Expand Down
4 changes: 2 additions & 2 deletions source/UI/networkBrowser.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "gui.h"
#include "imgui.h"
#include "imgui_internal.h"
#include "windows.h"
#include "appwindows.h"
#include "utils.h"
#include "localfiles.h"
#include "Enigma2.h"
Expand All @@ -12,7 +12,7 @@ namespace Windows {
Windows::SetupWindow();
std::vector<std::string> topmenu = {"Local Files","Network","Enigma2"};

if (ImGui::Begin("Network Browser", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_MenuBar)) {
if (ImGui::Begin("Network Source Selection", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_MenuBar)) {

ImGui::SetNextWindowFocus();

Expand Down
2 changes: 1 addition & 1 deletion source/UI/settingsMenu.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "gui.h"
#include "imgui.h"
#include "imgui_internal.h"
#include "windows.h"
#include "appwindows.h"
#include "utils.h"
#include "localfiles.h"
#include "Enigma2.h"
Expand Down
Loading

0 comments on commit 54640f2

Please sign in to comment.