Skip to content

Commit

Permalink
v 0.5.1
Browse files Browse the repository at this point in the history
- Fix for db not saved on hard exit the app
- ShaderMania useless but fun with shaders
- Custom Sub Font Size
- Show File selection during playback with - button
- Volume Up/Down with rstick
  • Loading branch information
proconsule committed Nov 21, 2021
1 parent eaaa0d7 commit 7f14165
Show file tree
Hide file tree
Showing 18 changed files with 446 additions and 41 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ include $(DEVKITPRO)/libnx/switch_rules
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := libs/imgui libs/imgui/misc/freetype source source/eqpreset source/database source/UI source/remotefs/Enigma2 source/localfs source/localfs/usb source/remotefs/ftplib source/remotefs/HTTPDir
SOURCES := libs/imgui libs/imgui/misc/freetype source source/shadermania source/eqpreset source/database source/UI source/remotefs/Enigma2 source/localfs source/localfs/usb source/remotefs/ftplib source/remotefs/HTTPDir
DATA := data
INCLUDES := libs/simpleini libs/imgui include source/eqpreset source/database source/remotefs/Enigma2 source/localfs source/localfs/usb source/remotefs/ftplib source/remotefs/HTTPDir
INCLUDES := libs/simpleini libs/imgui include source/shadermania source/eqpreset source/database source/remotefs/Enigma2 source/localfs source/localfs/usb source/remotefs/ftplib source/remotefs/HTTPDir
ROMFS := romfs

VERSION_MAJOR := 0
VERSION_MINOR := 5
VERSION_MICRO := 0
VERSION_MICRO := 1

APP_TITLE := NXMP
APP_AUTHOR := proconsule
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ Buttons Mapping
- R Stick Button Toggle Masterlock (during playback, only A button will work)
- Dpad Right (during playback show/hide right menu)
- Dpad Down (during playback show/hide player UI)
- R Stick Up/Down Fast Scroll on file list
- R Stick Up/Down Fast Scroll on file list (Volume Control During Playback)
- \- Show file selection during playback


FAQ
-----
Expand All @@ -57,6 +59,10 @@ FAQ

**A:** Enigma2 is an application used in Linux-based Digital Video Broadcasting (DVB-S, DVB-C, DVB-T) receivers or TV set-top boxes and Internet Protocol television receivers.

**Q:** What is ShaderMania?

**A:** ShaderMania is an useless but fun feature of NXMP, it uses the ability of MPV to load custom shader into the video output chain. I adopt some shaders from https://www.shadertoy.com/ to make shaders effects to the video. Some like grayscale may be usefull for someone others (like the sea shaders) is only for fun. Users can also make their custom shaders and place in mpv/shaders directory.

Thanks to
-----
- Cpasjuste for pPlay https://github.com/Cpasjuste/pplay some code was taken here (mpv part)
Expand Down
8 changes: 8 additions & 0 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class Config{
int getAlang(bool tmpvalue);
void setAlang(int lang);

int getSubFontSize(bool tmpvalue);
void setSubFontSize(int val);

int getDeinterlace(bool tmpvalue);
void setDeinterlace(int value);

Expand Down Expand Up @@ -57,10 +60,15 @@ class Config{
int tmpalang;
int alang;

int tmpsubfontsize;
int subfontsize;

int tmpdeint;
int deint;




int tmpstartresumeperc;
int tmpstopresumeperc;
int startresumeperc;
Expand Down
8 changes: 8 additions & 0 deletions include/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "HTTPDir.h"
#include "FTPDir.h"

#include "shaderMania.h"


enum MENU_STATES {
MENU_STATE_HOME,
Expand Down Expand Up @@ -66,6 +68,7 @@ enum PLAYER_RIGHT_MENU_STATES {
PLAYER_RIGHT_MENU_IMAGE,
PLAYER_RIGHT_MENU_AUDIO,
PLAYER_RIGHT_MENU_SUB,
PLAYER_RIGHT_MENU_SHADERMANIA,
PLAYER_AUDIOEQ,
PLAYER_SUPERAUDIOEQ
};
Expand Down Expand Up @@ -103,6 +106,9 @@ typedef struct {
bool rightmenu_first_item;
bool rightmenu_focus;

bool showVolume = false;
float VolumeHide = 0.0;


} MenuItem;

Expand Down Expand Up @@ -167,6 +173,8 @@ extern Tex NoLoopIcon;

extern ImFont* fontSmall;

extern shaderMania* shadermania;


namespace GUI {

Expand Down
5 changes: 5 additions & 0 deletions include/libmpv.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class libMpv{
void setRotate(int value, bool osd);

void setVolume(int value,bool osd);
int getVolume();

bool getMute();
void toggleMute();
Expand All @@ -84,6 +85,8 @@ class libMpv{

void getfileInfo();

void setShader(std::string _filename);
void clearShader();


mpv_handle *getHandle();
Expand All @@ -96,6 +99,8 @@ class libMpv{

private:


void resetFileInfo();
mpv_handle *handle = nullptr;
mpv_render_context *context = nullptr;
std::vector<decoderlist_struct> decoderlist;
Expand Down
24 changes: 24 additions & 0 deletions include/playerwindows.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ namespace playerWindows{
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0,0.0,0.0,0.5));
}

inline void SetupVolumeWindow(void){
ImGui::SetNextWindowPos(ImVec2(10.0f, 10.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(200.0f, 50.0f), ImGuiCond_Once);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.f);
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0,0.0,0.0,0.5));
}

static float rightmenuposX = 1280.0f;
inline void SetupRightWindow(void) {
ImGui::SetNextWindowPos(ImVec2(rightmenuposX, 0.0f), ImGuiCond_Always);
Expand Down Expand Up @@ -42,6 +50,7 @@ namespace playerWindows{
ImGui::SetNextWindowPos(ImVec2(0.0f, 620.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f, 720.0f), ImGuiCond_Once);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.f);
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0,0.0,0.0,0.5));
};

Expand All @@ -51,6 +60,18 @@ namespace playerWindows{
ImGui::PopStyleColor();
};

inline void ExitVolumeWindow(void) {
ImGui::End();
ImGui::PopStyleVar(2);
ImGui::PopStyleColor();
};

inline void ExitControlsWindow(void) {
ImGui::End();
ImGui::PopStyleVar(2);
ImGui::PopStyleColor();
};

void RightHomeWindow(bool *focus, bool *first_item);
void RightTrackWindow(bool *focus, bool *first_item);
void RightChapterWindow(bool *focus, bool *first_item);
Expand All @@ -72,6 +93,9 @@ namespace playerWindows{

void playerControls();

void RightHomeShaderMania();
void VolumeWindow();

}

#endif
2 changes: 1 addition & 1 deletion source/UI/enigmaui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace Windows {
std::string itemid = "##" + std::to_string(n);
float currstartpos = ImGui::GetCursorPosX();
if (ImGui::Selectable(itemid.c_str(), selected == n, 0, ImVec2(0, 70))){
item.laststate = item.state;
libmpv->loadFileLive(enigma2->e2currbouqet[n].url,enigma2->e2currbouqet[n].name);


Expand Down
1 change: 1 addition & 0 deletions source/UI/filebrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ namespace Windows {
localdir->DirList(thislist[n].path,true,Utility::getMediaExtensions());
}
else{
item.laststate = item.state;
libmpv->loadFile(thislist[n].path);
if(configini->getDbActive(true)){
libmpv->getFileInfo()->resume = sqlitedb->getResume(thislist[n].path);
Expand Down
2 changes: 2 additions & 0 deletions source/UI/networkBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace Windows {
}else if (thislist[n].type == FS::FileEntryType::File){

std::string openurl = thisurl.scheme + std::string("://") + thisurl.user + std::string(":") + thisurl.pass + std::string("@") + thisurl.server + std::string("/") + thislist[n].path + thislist[n].name;
item.laststate = item.state;
libmpv->loadFile(openurl);
if(configini->getDbActive(true)){
libmpv->getFileInfo()->resume = sqlitedb->getResume(openurl);
Expand Down Expand Up @@ -118,6 +119,7 @@ namespace Windows {

urlschema thisurl = Utility::parseUrl(httpdir->getUrl());
std::string openurl = thisurl.scheme + std::string("://") + thisurl.server + std::string("/") + httpdir->getCurrPath() + thislist[n].name;
item.laststate = item.state;
libmpv->loadFile(openurl);
libmpv->getFileInfo()->resume = sqlitedb->getResume(openurl);
if(libmpv->getFileInfo()->resume>0){
Expand Down
77 changes: 71 additions & 6 deletions source/UI/playerWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace playerWindows{
static int drag_gamma = 0;
static int drag_hue = 0;
static int rotateidx = 0;
static int shaderidx = 0;



Expand All @@ -40,7 +41,7 @@ namespace playerWindows{
rightmenuposX = item.rightmenu_startpos;
if(item.rightmenu_startpos>1080)item.rightmenu_startpos-=10;
playerWindows::SetupRightWindow();
std::vector<std::string> topmenu = {"Tracks","Chapters","Aspect Ratio","Image","Audio","Subtitle"};
std::vector<std::string> topmenu = {"Tracks","Chapters","Aspect Ratio","Image","Audio","Subtitle","ShaderMania"};
if (ImGui::Begin("Right Menu Home", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::SetNextWindowFocus();
if (ImGui::BeginListBox("Right Menu Home List",ImVec2(1280.0f, 720.0f))){
Expand All @@ -65,6 +66,9 @@ namespace playerWindows{
if(topmenu[n] == "Subtitle"){
item.rightmenustate = PLAYER_RIGHT_MENU_SUB;
}
if(topmenu[n] == "ShaderMania"){
item.rightmenustate = PLAYER_RIGHT_MENU_SHADERMANIA;
}
}
}
if (*first_item) {
Expand Down Expand Up @@ -419,6 +423,7 @@ namespace playerWindows{
auto windowWidth = ImGui::GetWindowSize().x;
ImGui::SetCursorPosX((windowWidth - ImGui::CalcTextSize("Volume", NULL, true).x) * 0.5f);
ImGui::Text("Volume");
drag_volume = libmpv->getVolume();
if(ImGui::DragInt("Volume", &drag_volume, 0.5f, 0, 200, "%d", ImGuiSliderFlags_NoInput)){
libmpv->setVolume(drag_volume,item.playershowcontrols);
}
Expand Down Expand Up @@ -460,21 +465,21 @@ namespace playerWindows{
if(ImGui::DragInt("Sub Position", &drag_subpos, 0.5f, 0, 100, "%d", ImGuiSliderFlags_NoInput)){
libmpv->setSubPos(drag_subpos,item.playershowcontrols);
}
ImGui::BeginDisabled();
//ImGui::BeginDisabled();
ImGui::SetCursorPosX((windowWidth - ImGui::CalcTextSize("Sub Font Size", NULL, true).x) * 0.5f);
ImGui::Text("Sub Font Size");
if(ImGui::DragInt("Sub Font Size", &drag_subfontsize, 0.5f, 1, 70, "%d", ImGuiSliderFlags_NoInput)){
if(ImGui::DragInt("Sub Font Size", &drag_subfontsize, 0.5f, 1, 120, "%d", ImGuiSliderFlags_NoInput)){
libmpv->setSubFontSize(drag_subfontsize,item.playershowcontrols);
}
ImGui::EndDisabled();
//ImGui::EndDisabled();
ImGui::SetCursorPosY(ImGui::GetWindowSize().y -50);
if(ImGui::Button("Reset to Default")){
drag_subpos = 100;
drag_subdelay = 0.0f;
drag_subfontsize = 55;
drag_subfontsize = configini->getSubFontSize(false);
libmpv->setSubPos(drag_subpos,false);
libmpv->setSubDelay(drag_subdelay,false);
libmpv->setSubFontSize(drag_subdelay,false);
libmpv->setSubFontSize(drag_subfontsize,false);
}
}
playerWindows::ExitWindow();
Expand Down Expand Up @@ -713,7 +718,67 @@ namespace playerWindows{


}
playerWindows::ExitControlsWindow();
}

void RightHomeShaderMania(){
playerWindows::SetupRightWindow();
std::vector<std::string> topmenu = {"Default","16:9","16:10","4:3","Custom Ratio"};
if (ImGui::Begin("Shader Mania", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::PushItemWidth(200-10);
ImGui::Text("Shaders");
if (ImGui::BeginCombo("Shaders Combo", shadermania->getCurrList()[shaderidx].name.c_str(), 0))
{
for (int n = 0; n < shadermania->getCurrList().size(); n++)
{
const bool is_selected = (shaderidx == n);
std::string itemid = "##" + std::to_string(n);
if (ImGui::Selectable(itemid.c_str(), is_selected)){

if(n == 0){
libmpv->clearShader();
}else{
printf("PATH: %s\n",shadermania->getCurrList()[n].path.c_str());
libmpv->setShader(shadermania->getCurrList()[n].path);
}
shaderidx = n;
}
ImGui::SameLine();
ImGui::Text("%s",shadermania->getCurrList()[n].name.c_str());



if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
ImGui::PopItemWidth();
}
}

playerWindows::ExitWindow();
}

void VolumeWindow(){
playerWindows::SetupVolumeWindow();
if (ImGui::Begin("Volume Window", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {

ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(1.0,1.0,1.0,0.2));
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, ImVec4(1.0,1.0,1.0,1.0));
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 12.0f);
ImGui::ProgressBar(libmpv->getVolume()/100.0, ImVec2(150.0, 25.0f),"");
ImGui::PopStyleColor(2);
ImGui::PopStyleVar();
ImGui::SameLine();
ImGui::Image((void*)(intptr_t)VolumeIcon.id, ImVec2(25,25));
ImGuiContext& g = *GImGui;
if(item.VolumeHide +2 < g.Time){
item.showVolume = false;
}

}

playerWindows::ExitVolumeWindow();
}

}
18 changes: 18 additions & 0 deletions source/UI/settingsMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@ namespace Windows {
ImGui::EndDisabled();
}

ImGui::Text("Sub Font Size");
ImGui::SameLine(220,spacing);
ImGui::PushButtonRepeat(true);
if (ImGui::ArrowButton("##subsizeleft", ImGuiDir_Left)) {
if(configini->getSubFontSize(true)-1 >0){
configini->setSubFontSize(configini->getSubFontSize(true)-1);
}
}
ImGui::SameLine(0.0f, spacing);
if (ImGui::ArrowButton("##subsizeright", ImGuiDir_Right)) {
if(configini->getSubFontSize(true)+1 <120){
configini->setSubFontSize(configini->getSubFontSize(true)+1);
}
}
ImGui::PopButtonRepeat();
ImGui::SameLine();
ImGui::Text("%d", configini->getSubFontSize(true));

std::vector<std::string> deintmenu = {"No","Yes","Auto"};
const char* combo_deintpreview_value = deintmenu[configini->getDeinterlace(true)].c_str();
ImGui::PushItemWidth(300);
Expand Down
2 changes: 1 addition & 1 deletion source/UI/usbBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace Windows {
item.usbfileentries = FS::getDirList(item.usbpath.c_str(),true,Utility::getMediaExtensions());
triggerselect = true;
}else if(thislist[n].type == FS::FileEntryType::File){

item.laststate = item.state;
libmpv->loadFile(thislist[n].path);
if(configini->getDbActive(true)){
libmpv->getFileInfo()->resume = sqlitedb->getResume(thislist[n].path);
Expand Down
Loading

0 comments on commit 7f14165

Please sign in to comment.