2019-09-01 21:40:08 +00:00
|
|
|
extern "C" {
|
|
|
|
#include "menu_book_reader.h"
|
2019-09-02 20:24:09 +00:00
|
|
|
#include "MenuChooser.h"
|
2019-09-01 21:40:08 +00:00
|
|
|
#include "common.h"
|
2019-09-20 00:12:38 +00:00
|
|
|
#include "config.h"
|
|
|
|
#include "SDL_helper.h"
|
2019-09-01 21:40:08 +00:00
|
|
|
}
|
|
|
|
|
2019-09-03 22:17:53 +00:00
|
|
|
#include <iostream>
|
2019-09-01 21:40:08 +00:00
|
|
|
#include "BookReader.hpp"
|
|
|
|
|
|
|
|
void Menu_OpenBook(char *path) {
|
2019-10-30 16:56:10 +00:00
|
|
|
BookReader *reader = NULL;
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
reader = new BookReader(path, &result);
|
|
|
|
|
|
|
|
if(result < 0){
|
|
|
|
std::cout << "Menu_OpenBook: document not loaded" << std::endl;
|
|
|
|
}
|
2019-09-01 21:40:08 +00:00
|
|
|
|
|
|
|
/*TouchInfo touchInfo;
|
|
|
|
Touch_Init(&touchInfo);*/
|
|
|
|
|
2019-09-20 00:12:38 +00:00
|
|
|
bool helpMenu = false;
|
|
|
|
|
2021-07-13 06:25:32 +00:00
|
|
|
// Configure our supported input layout: a single player with standard controller syles
|
|
|
|
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
|
|
|
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
|
|
|
PadState pad;
|
|
|
|
padInitializeDefault(&pad);
|
|
|
|
//Touch_Process(&touchInfo);
|
|
|
|
|
2019-10-30 16:56:10 +00:00
|
|
|
while(result >= 0 && appletMainLoop()) {
|
2019-09-20 00:12:38 +00:00
|
|
|
reader->draw(helpMenu);
|
2019-09-01 21:40:08 +00:00
|
|
|
|
2021-07-13 06:25:32 +00:00
|
|
|
//hidScanInput();
|
|
|
|
|
|
|
|
//u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
|
|
|
//u64 kHeld = hidKeysHeld(CONTROLLER_P1_AUTO);
|
|
|
|
|
|
|
|
padUpdate(&pad);
|
2019-09-01 21:40:08 +00:00
|
|
|
|
2021-07-13 06:25:32 +00:00
|
|
|
u64 kDown = padGetButtonsDown(&pad);
|
|
|
|
u64 kHeld = padGetButtons(&pad);
|
|
|
|
u64 kUp = padGetButtonsUp(&pad);
|
2019-09-01 21:40:08 +00:00
|
|
|
|
2021-07-13 06:25:32 +00:00
|
|
|
if (!helpMenu && kDown & HidNpadButton_Left) {
|
|
|
|
if (reader->currentPageLayout() == BookPageLayoutPortrait ) {
|
2019-09-01 21:40:08 +00:00
|
|
|
reader->previous_page(1);
|
2021-07-13 06:25:32 +00:00
|
|
|
} else if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) {
|
2019-09-01 21:40:08 +00:00
|
|
|
reader->zoom_out();
|
2019-09-20 00:12:38 +00:00
|
|
|
}
|
2021-07-13 06:25:32 +00:00
|
|
|
} else if (!helpMenu && kDown & HidNpadButton_Right) {
|
|
|
|
if (reader->currentPageLayout() == BookPageLayoutPortrait ) {
|
2019-09-01 21:40:08 +00:00
|
|
|
reader->next_page(1);
|
2021-07-13 06:25:32 +00:00
|
|
|
} else if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) {
|
2019-09-01 21:40:08 +00:00
|
|
|
reader->zoom_in();
|
2019-09-20 00:12:38 +00:00
|
|
|
}
|
2019-09-01 21:40:08 +00:00
|
|
|
}
|
|
|
|
|
2021-07-13 06:25:32 +00:00
|
|
|
if (!helpMenu && kDown & HidNpadButton_R) {
|
2019-09-01 21:40:08 +00:00
|
|
|
reader->next_page(10);
|
2021-07-13 06:25:32 +00:00
|
|
|
} else if (!helpMenu && kDown & HidNpadButton_L) {
|
2019-09-01 21:40:08 +00:00
|
|
|
reader->previous_page(10);
|
|
|
|
}
|
|
|
|
|
2021-07-13 06:25:32 +00:00
|
|
|
if (!helpMenu && ((kDown & HidNpadButton_Up) || (kHeld & HidNpadButton_StickRUp))) {
|
|
|
|
if (reader->currentPageLayout() == BookPageLayoutPortrait ) {
|
2019-09-01 21:40:08 +00:00
|
|
|
reader->zoom_in();
|
2021-07-13 06:25:32 +00:00
|
|
|
} else if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) {
|
2019-09-01 21:40:08 +00:00
|
|
|
reader->previous_page(1);
|
|
|
|
}
|
2021-07-13 06:25:32 +00:00
|
|
|
} else if (!helpMenu && ((kDown & HidNpadButton_Down) || (kHeld & HidNpadButton_StickRDown))) {
|
|
|
|
if (reader->currentPageLayout() == BookPageLayoutPortrait ) {
|
2019-09-01 21:40:08 +00:00
|
|
|
reader->zoom_out();
|
2021-07-13 06:25:32 +00:00
|
|
|
} else if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) {
|
2019-09-01 21:40:08 +00:00
|
|
|
reader->next_page(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-13 06:25:32 +00:00
|
|
|
if (!helpMenu && kHeld & HidNpadButton_StickLUp) {
|
|
|
|
if (reader->currentPageLayout() == BookPageLayoutPortrait ) {
|
2019-09-01 21:40:08 +00:00
|
|
|
reader->move_page_up();
|
2021-07-13 06:25:32 +00:00
|
|
|
} else if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) {
|
2019-09-01 21:40:08 +00:00
|
|
|
reader->move_page_left();
|
|
|
|
}
|
2021-07-13 06:25:32 +00:00
|
|
|
} else if (!helpMenu && kHeld & HidNpadButton_StickLDown) {
|
|
|
|
if (reader->currentPageLayout() == BookPageLayoutPortrait ) {
|
2019-09-01 21:40:08 +00:00
|
|
|
reader->move_page_down();
|
2021-07-13 06:25:32 +00:00
|
|
|
} else if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) {
|
2019-09-01 21:40:08 +00:00
|
|
|
reader->move_page_right();
|
|
|
|
}
|
2021-07-13 06:25:32 +00:00
|
|
|
} else if (!helpMenu && kHeld & HidNpadButton_StickLRight) {
|
|
|
|
if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) {
|
2019-09-20 00:12:38 +00:00
|
|
|
//reader->move_page_up();
|
2019-09-01 21:40:08 +00:00
|
|
|
reader->move_page_down();
|
|
|
|
}
|
2021-07-13 06:25:32 +00:00
|
|
|
} else if (!helpMenu && kHeld & HidNpadButton_StickLLeft) {
|
|
|
|
if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) {
|
2019-09-20 00:12:38 +00:00
|
|
|
//reader->move_page_down();
|
|
|
|
reader->move_page_up();
|
|
|
|
}
|
2019-09-01 21:40:08 +00:00
|
|
|
}
|
|
|
|
|
2021-07-13 06:25:32 +00:00
|
|
|
if (kDown & HidNpadButton_B) {
|
2019-09-20 00:12:38 +00:00
|
|
|
if (helpMenu) {
|
|
|
|
helpMenu = !helpMenu;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
2019-09-01 21:40:08 +00:00
|
|
|
}
|
2019-09-03 22:17:53 +00:00
|
|
|
|
2021-07-13 06:25:32 +00:00
|
|
|
if (!helpMenu && kDown & HidNpadButton_X) {
|
2019-09-03 22:17:53 +00:00
|
|
|
reader->permStatusBar = !reader->permStatusBar;
|
|
|
|
}
|
2019-09-01 21:40:08 +00:00
|
|
|
|
2021-07-13 06:25:32 +00:00
|
|
|
if (!helpMenu && kDown & HidNpadButton_StickL || kDown & HidNpadButton_StickR) {
|
2019-09-01 21:40:08 +00:00
|
|
|
reader->reset_page();
|
|
|
|
}
|
|
|
|
|
2021-07-13 06:25:32 +00:00
|
|
|
if (!helpMenu && kDown & HidNpadButton_Y) {
|
2019-09-01 21:40:08 +00:00
|
|
|
reader->switch_page_layout();
|
|
|
|
}
|
2019-09-20 00:12:38 +00:00
|
|
|
|
2021-07-13 06:25:32 +00:00
|
|
|
if (!helpMenu && kUp & HidNpadButton_Minus) {
|
2019-09-20 00:12:38 +00:00
|
|
|
configDarkMode = !configDarkMode;
|
|
|
|
reader->previous_page(0);
|
|
|
|
}
|
|
|
|
|
2021-07-13 06:25:32 +00:00
|
|
|
if (kDown & HidNpadButton_Plus) {
|
2019-09-20 00:12:38 +00:00
|
|
|
helpMenu = !helpMenu;
|
|
|
|
}
|
2021-07-13 06:25:32 +00:00
|
|
|
|
2019-09-03 22:17:53 +00:00
|
|
|
/*if (touchInfo.state == TouchEnded && touchInfo.tapType != TapNone) {
|
2019-09-01 21:40:08 +00:00
|
|
|
float tapRegion = 120;
|
|
|
|
|
2019-09-03 22:17:53 +00:00
|
|
|
switch (reader->currentPageLayout()) {
|
2019-09-01 21:40:08 +00:00
|
|
|
case BookPageLayoutPortrait:
|
|
|
|
if (tapped_inside(touchInfo, 0, 0, tapRegion, 720))
|
|
|
|
reader->previous_page(1);
|
|
|
|
else if (tapped_inside(touchInfo, 1280 - tapRegion, 0, 1280, 720))
|
|
|
|
reader->next_page(1);
|
|
|
|
break;
|
|
|
|
case BookPageLayoutLandscape:
|
|
|
|
if (tapped_inside(touchInfo, 0, 0, 1280, tapRegion))
|
|
|
|
reader->previous_page(1);
|
|
|
|
else if (tapped_inside(touchInfo, 0, 720 - tapRegion, 1280, 720))
|
|
|
|
reader->next_page(1);
|
|
|
|
reader->reset_page();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
|
2019-09-03 22:17:53 +00:00
|
|
|
std::cout << "Exiting reader" << std::endl;
|
|
|
|
std::cout << "Opening chooser" << std::endl;
|
|
|
|
Menu_StartChoosing();
|
2019-09-01 21:40:08 +00:00
|
|
|
delete reader;
|
|
|
|
}
|