Skip to content

Commit

Permalink
NXMP Docked Mode (1080p)
Browse files Browse the repository at this point in the history
Work in progress
  • Loading branch information
darkxex committed Feb 9, 2022
1 parent f39800c commit 4c7faae
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 29 deletions.
7 changes: 6 additions & 1 deletion include/apppopups.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@

#include "imgui.h"

extern int newResW;
extern int newResH;
extern float multiplyRes;
extern bool isHandheld;

namespace Popups {
inline void SetupPopup(const char *id) {
ImGui::OpenPopup(id);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(15, 15));
ImGui::SetNextWindowPos(ImVec2(640.0f, 360.0f), ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
ImGui::SetNextWindowPos(ImVec2(640.0f*multiplyRes, 360.0f*multiplyRes), ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
};

inline void ExitPopup(void) {
Expand Down
8 changes: 6 additions & 2 deletions include/appwindows.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@
#include "imgui.h"
#include "platforms.h"

extern int newResW;
extern int newResH;
extern float multiplyRes;
extern bool isHandheld;
namespace Windows {

inline void SetupMainWindow(void) {
ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f, 720.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f*multiplyRes, 720.0f*multiplyRes), ImGuiCond_Once);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
};


inline void SetupWindow(void) {
ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f, 720.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f*multiplyRes, 720.0f*multiplyRes), ImGuiCond_Once);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
};

Expand Down
5 changes: 4 additions & 1 deletion include/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ extern USBMounter *usbmounter;
#ifdef NXMP_ENIGMASUPPORT
extern Enigma2 *enigma2;
#endif
extern bool isHandheld;

extern uint32_t wakeup_on_mpv_render_update;
extern uint32_t wakeup_on_mpv_events;
Expand All @@ -240,6 +239,10 @@ extern Playlist *playlist;

extern SysIcons nxmpicons;

extern int newResW;
extern int newResH;
extern float multiplyRes;
extern bool isHandheld;
/*
extern Tex SdCardTexture;
extern Tex UsbTexture;
Expand Down
24 changes: 15 additions & 9 deletions include/playerwindows.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,34 @@
#include "imgui.h"
#include "gui.h"


extern int newResW;
extern int newResH;
extern float multiplyRes;
extern bool isHandheld;
namespace playerWindows{

inline void SetupCacheWindow(void){
ImGui::SetNextWindowPos(ImVec2(10.0f, 600.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(250.0f, 80.0f), ImGuiCond_Once);
ImGui::SetNextWindowPos(ImVec2(10.0f*multiplyRes, 600.0f*multiplyRes), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(250.0f*multiplyRes, 80.0f*multiplyRes), ImGuiCond_Once);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
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::SetNextWindowPos(ImVec2(10.0f*multiplyRes, 10.0f*multiplyRes), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(200.0f*multiplyRes, 50.0f*multiplyRes), 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) {
if(isHandheld == true)
ImGui::SetNextWindowPos(ImVec2(rightmenuposX, 0.0f), ImGuiCond_Always);
ImGui::SetNextWindowSize(ImVec2(200.0f, 720.0f), ImGuiCond_Once);
else
ImGui::SetNextWindowPos(ImVec2((rightmenuposX*multiplyRes)+100, 0.0f), ImGuiCond_Always);
ImGui::SetNextWindowSize(ImVec2(200.0f, 720.0f*multiplyRes), ImGuiCond_Once);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0,0.0,0.0,0.5));

Expand All @@ -41,14 +47,14 @@ namespace playerWindows{

inline void SetupAudioPlayerWindow(void) {
ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f, 720.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f*multiplyRes, 720.0f*multiplyRes), ImGuiCond_Once);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0,0.0,0.0,0.5));
};

inline void SetupPlayerControlsWindow(void) {
ImGui::SetNextWindowPos(ImVec2(0.0f, 620.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f, 720.0f), ImGuiCond_Once);
ImGui::SetNextWindowPos(ImVec2(0.0f, 620.0f*multiplyRes), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f*multiplyRes, 720.0f*multiplyRes), 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 Down
14 changes: 7 additions & 7 deletions source/UI/playerWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace playerWindows{
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))){
if (ImGui::BeginListBox("Right Menu Home List",ImVec2(1280.0f*multiplyRes, 720.0f*multiplyRes))){
for (unsigned int n = 0; n < topmenu.size(); n++){
static int selected = -1;
if (ImGui::Selectable(topmenu[n].c_str(), selected == n)){
Expand Down Expand Up @@ -103,7 +103,7 @@ namespace playerWindows{
std::vector<std::string> topmenu = {"Video","Audio","Sub"};
if (ImGui::Begin("Right Menu Tracks", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::SetNextWindowFocus();
if (ImGui::BeginListBox("Tracks Menu",ImVec2(1280.0f, 720.0f))){
if (ImGui::BeginListBox("Tracks Menu",ImVec2(1280.0f*multiplyRes, 720.0f*multiplyRes))){
for (unsigned int n = 0; n < topmenu.size(); n++){
static int selected = -1;
if (ImGui::Selectable(topmenu[n].c_str(), selected == n)){
Expand Down Expand Up @@ -132,7 +132,7 @@ namespace playerWindows{
playerWindows::SetupRightWindow();
if (ImGui::Begin("Right Menu Tracks Video", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::SetNextWindowFocus();
if (ImGui::BeginListBox("Video Tracks Menu",ImVec2(1280.0f, 720.0f))){
if (ImGui::BeginListBox("Video Tracks Menu",ImVec2(1280.0f*multiplyRes, 720.0f*multiplyRes))){
if(libmpv->getFileInfo() != nullptr){
for (unsigned int n = 0; n < libmpv->getFileInfo()->videos.size(); n++){
static int selected = -1;
Expand Down Expand Up @@ -160,7 +160,7 @@ namespace playerWindows{
playerWindows::SetupRightWindow();
if (ImGui::Begin("Right Menu Tracks Audio", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::SetNextWindowFocus();
if (ImGui::BeginListBox("Audio Tracks Menu",ImVec2(200.0f, 720.0f))){
if (ImGui::BeginListBox("Audio Tracks Menu",ImVec2(200.0f, 720.0f*multiplyRes))){
if(libmpv->getFileInfo() != nullptr){
for (unsigned int n = 0; n < libmpv->getFileInfo()->audios.size(); n++){
std::string itemid = "##" + std::to_string(n);
Expand Down Expand Up @@ -195,7 +195,7 @@ namespace playerWindows{
playerWindows::SetupRightWindow();
if (ImGui::Begin("Right Menu Tracks Subs", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::SetNextWindowFocus();
if (ImGui::BeginListBox("Sub Tracks Menu",ImVec2(200.0f, 720.0f))){
if (ImGui::BeginListBox("Sub Tracks Menu",ImVec2(200.0f, 720.0f*multiplyRes))){
if(libmpv->getFileInfo() != nullptr){
for (unsigned int n = 0; n < libmpv->getFileInfo()->subtitles.size(); n++){
static int selected = -1;
Expand Down Expand Up @@ -231,7 +231,7 @@ namespace playerWindows{
std::vector<std::string> topmenu = {"Video","Audio","Sub"};
if (ImGui::Begin("Right Menu Chapters", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::SetNextWindowFocus();
if (ImGui::BeginListBox("Chapter Menu",ImVec2(200.0f, 720.0f))){
if (ImGui::BeginListBox("Chapter Menu",ImVec2(200.0f, 720.0f*multiplyRes))){
if(libmpv->getFileInfo() != nullptr){
for (unsigned int n = 0; n < libmpv->getFileInfo()->chapters.size(); n++){
static int selected = -1;
Expand Down Expand Up @@ -333,7 +333,7 @@ namespace playerWindows{
std::vector<std::string> topmenu = {"Default","16:9","16:10","4:3","Custom Ratio"};
if (ImGui::Begin("Right Menu ARatio", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::SetNextWindowFocus();
if (ImGui::BeginListBox("Aspect Ratio",ImVec2(200.0f, 720.0f))){
if (ImGui::BeginListBox("Aspect Ratio",ImVec2(200.0f, 720.0f*multiplyRes))){
for (unsigned int n = 0; n < topmenu.size(); n++){
static int selected = -1;
if (ImGui::Selectable(topmenu[n].c_str(), selected == n)){
Expand Down
10 changes: 8 additions & 2 deletions source/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,14 +1000,20 @@ namespace GUI {
if (isHandheld == false)
{isHandheld=true;
printf("changed to Handheld Mode.\n");
SDL_SetWindowSize(window, handheldWidth, handheldHeight);
newResW = handheldWidth;
newResH = handheldHeight;
multiplyRes = 1.0f;
SDL_SetWindowSize(window, newResW, newResH);
}
}
if (stus == AppletOperationMode_Console)
{ if (isHandheld == true)
{isHandheld=false;
printf("changed to Docked Mode.\n");
SDL_SetWindowSize(window, dockedWidth, dockedHeight);
newResW = dockedWidth;
newResH = dockedHeight;
multiplyRes = 1.5f;
SDL_SetWindowSize(window, newResW, newResH);
}
}
#endif
Expand Down
22 changes: 15 additions & 7 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ float themefontsmall;
ImFont* fontSmall;

bool isHandheld=true;

int newResW = 1280;
int newResH = 720;
float multiplyRes = 1.0f;
shaderMania* shadermania = nullptr;

GLuint WIDTH = handheldWidth, HEIGHT = handheldWidth;
Expand Down Expand Up @@ -149,10 +151,18 @@ static bool init() {
AppletOperationMode stus=appletGetOperationMode();
if (stus == AppletOperationMode_Handheld)
{printf("Handheld Mode\n");
isHandheld=true;}
isHandheld=true;
newResW = handheldWidth;
newResH = handheldHeight;
multiplyRes = 1.0f;
}
if (stus == AppletOperationMode_Console)
{printf("Docked Mode\n");
isHandheld=false;}
isHandheld=false;
newResW = dockedWidth;
newResH = dockedHeight;
multiplyRes = 1.5f;
}
#endif


Expand All @@ -168,10 +178,8 @@ static bool init() {
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
if (isHandheld == true)
{WIDTH = handheldWidth; HEIGHT = handheldHeight;}
else
{WIDTH = dockedWidth; HEIGHT = dockedHeight;}

WIDTH = newResW; HEIGHT = newResH;
window = SDL_CreateWindow(
"[glad] GL with SDL",
SDL_WINDOWPOS_CENTERED,
Expand Down

0 comments on commit 4c7faae

Please sign in to comment.