Skip to content

Commit

Permalink
Awful first implementation of in app configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
oreo639 committed Oct 27, 2019
1 parent 9e6f71a commit 537d1e3
Show file tree
Hide file tree
Showing 18 changed files with 219 additions and 68 deletions.
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ UNIQUE_ID := 0xEDA06
PRODUCT_CODE := CTR-P-LIME
ICON_FLAGS := nosavebackups,visible

NODEBUG := 0

VERSION_MAJOR := 0
VERSION_MINOR := 0
VERSION_BUILD := 8
Expand All @@ -90,16 +92,17 @@ CFLAGS := -Wall -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(ARCH)

CFLAGS += $(INCLUDE) -DARM11 -D_3DS `arm-none-eabi-pkg-config opusfile --cflags` \
-DLIMEPLAYER_VERSION="$(VERSION_ALL)" \
$(CUSTOMFLAGS)

ifdef RELEASE
CFLAGS += -O3 -g
else
CFLAGS += -Og -ggdb
endif

CFLAGS += $(INCLUDE) -DARM11 -D_3DS `arm-none-eabi-pkg-config opusfile --cflags` \
-DLIMEPLAYER_VERSION=$(VERSION_ALL) \
-DNODEBUG=${NODEBUG} \
${CUSTOMFLAGS}

CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17

ASFLAGS := -g $(ARCH)
Expand Down Expand Up @@ -225,6 +228,7 @@ ifeq ($(suffix $(BANNER_AUDIO)),.cwav)
else
BANNER_AUDIO_ARG := -a
endif

#---------------------------------------------------------------------------------
all: 3dsx
#---------------------------------------------------------------------------------
Expand Down
Binary file added gfx/menu_copyright_colored.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gfx/menu_copyright_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions gfx/sprites.t3s
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ menu_radio.png
menu_globe.png
menu_document.png
menu_copyright.png
menu_copyright_colored.png
1 change: 0 additions & 1 deletion src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <sys/stat.h>
#include <stdio.h>

#include "app.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <stdbool.h>
#include <stdarg.h>

#ifndef NODEBUG
#if !NODEBUG
#include "debug.hpp"
#include "file.hpp"

Expand Down
4 changes: 2 additions & 2 deletions src/debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef __LP_DEBUG_H__
#define __LP_DEBUG_H__

#ifndef NODEBUG
#if !NODEBUG
#define DEBUG(...) debug_perform("[" __FILE__ "] " STRINGIFY(__LINE__) ": " __VA_ARGS__)

void debug_init(bool use_file);
Expand All @@ -23,5 +23,5 @@ static void debug_exit(void) {};

static void debug_perform(const char* fmt, ...) {};

#endif // ifndef NODEBUG
#endif // if !NODEBUG
#endif // ifndef __LP_DEBUG_H__
2 changes: 1 addition & 1 deletion src/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void Error::Add(int err) {
}
}

void Error::Add(int err, std::string& extraInfo) {
void Error::Add(int err, const std::string& extraInfo) {
// Error codes of 0 are not allowed
if (err != 0) {
LimeError_t tmperr;
Expand Down
13 changes: 7 additions & 6 deletions src/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
#define __LIME_ERROR_H__

/* Errors that can't be explained with errno */
#define NDSP_INIT_FAIL 1000
#define DECODER_INIT_FAIL 1001
#define FILE_NOT_SUPPORTED 1002
#define DECODER_INIT_TIMEOUT 1003
#define UNSUPPORTED_CHANNELS 1004
#define ERRORH_GENERIC 1000
#define NDSP_INIT_FAIL 1001
#define DECODER_INIT_FAIL 1002
#define FILE_NOT_SUPPORTED 1003
#define DECODER_INIT_TIMEOUT 1004
#define UNSUPPORTED_CHANNELS 1005

#include <vector>
#include <string>
Expand All @@ -20,7 +21,7 @@ typedef struct {
namespace Error {
void Add(int err);

void Add(int err, std::string& extraInfo);
void Add(int err, const std::string& extraInfo);

void Remove(void);

Expand Down
13 changes: 10 additions & 3 deletions src/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ void Gui::Update(playbackInfo_t* playbackInfo)
C3D_FrameEnd(0);
C2D_TextBufClear(g_dynamicBuf);

if (Error::IsQuered()) {
if (kDown)
Error::Remove();
return;
}

touchPosition touch;
hidTouchRead(&touch);
menus.top()->doUpdate(&touch);
Expand Down Expand Up @@ -147,21 +153,21 @@ C2D_Text Gui::StaticTextGen(std::string str) {
return tmpStaticText;
}

void Gui::PrintColor(const char* text, float xloc, float yloc, float scaleX, float scaleY, u32 color)
void Gui::PrintColor(const std::string& text, float xloc, float yloc, float scaleX, float scaleY, u32 color)
{
// Clear the dynamic text buffer
C2D_TextBufClear(g_dynamicBuf);

// Generate and draw dynamic text
C2D_Text dynText;
C2D_TextParse(&dynText, g_dynamicBuf, text);
C2D_TextParse(&dynText, g_dynamicBuf, text.c_str());
C2D_TextOptimize(&dynText);
C2D_DrawText(&dynText, C2D_WithColor, xloc, yloc, 0.5f, scaleX, scaleY, color);
}

void Gui::Print(const std::string& text, float xloc, float yloc, float scaleX, float scaleY)
{
Gui::PrintColor(text.c_str(), xloc, yloc, scaleX, scaleY, 0xFFFFFFFF);
Gui::PrintColor(text, xloc, yloc, scaleX, scaleY, 0xFFFFFFFF);
}

void Gui::PrintStatic(const std::string &ident, float xloc, float yloc, float scaleX, float scaleY)
Expand Down Expand Up @@ -259,6 +265,7 @@ void Gui::DrawError(void) {
else if (errorcode == DECODER_INIT_FAIL){
Gui::Print("ERR: Failed to initalize decoder.", 20.0f, 40.0f, 0.5f, 0.5f);
}
else if (errorcode == ERRORH_GENERIC);
else {
char errstr[30];
snprintf(errstr, 30, "ERR: Undefined error.");
Expand Down
2 changes: 1 addition & 1 deletion src/gui/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace Gui {

void DrawSolidRectangle(float x, float y, float w, float h, u32 color);

void PrintColor(const char* text, float xloc, float yloc, float scaleX, float scaleY, u32 color);
void PrintColor(const std::string& text, float xloc, float yloc, float scaleX, float scaleY, u32 color);

void DrawBaseGui(void);

Expand Down
35 changes: 35 additions & 0 deletions src/gui/menus/AboutMenu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "AboutMenu.hpp"
#include "gui.hpp"

#include "SelectFileMenu.hpp"
#include "app.hpp"

AboutMenu::AboutMenu()
{

}

void AboutMenu::drawTop() const
{
std::string currentversion = "LimePlayer3DS version ";
currentversion.append(STRINGIFY(LIMEPLAYER_VERSION));
Gui::Print("About:", 20.0f, 20.0f, 0.5f, 0.5f);
Gui::Print(currentversion, 40.0f, 40.0f, 0.5f, 0.5f);
Gui::Print("This application is licensed under GPL3.0-or-later.", 40.0f, 60.0f, 0.5f, 0.5f);
}

void AboutMenu::drawBottom() const
{

}

void AboutMenu::update(touchPosition* touch)
{
u32 kDown = hidKeysDown();

if (kDown & KEY_B)
{
Gui::BackMenu();
return;
}
}
17 changes: 17 additions & 0 deletions src/gui/menus/AboutMenu.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef __LP_ABOUTMENU_HPP__
#define __LP_ABOUTMENU_HPP__

#include "menu.hpp"
#include <memory>
#include <vector>

class AboutMenu : public Menu
{
public:
AboutMenu();
void drawTop() const override;
void drawBottom() const override;
void update(touchPosition* touch) override;
};

#endif
66 changes: 29 additions & 37 deletions src/gui/menus/PlayerMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,53 +170,45 @@ void PlayerMenu::update(touchPosition* touch)
u32 kDown = hidKeysDown();
u32 kHeld = hidKeysHeld();

if (Error::IsQuered()) {
if (kDown & KEY_A) {
Error::Remove();
kDown = 0;
}
if (kDown & KEY_SELECT) {
addOverlay<QuickSetOverlay>();
}
else {
if (kDown & KEY_SELECT) {
addOverlay<QuickSetOverlay>();
}

if (kHeld & KEY_X) {
if (kDown & (KEY_R | KEY_UP)) {
if(PlayerInterface::IsPlaying())
PlayerInterface::TogglePlayback();
}

if (kDown & KEY_RIGHT) {
if(PlayerInterface::IsPlaying())
PlayerInterface::SeekSectionTime(PlayerInterface::GetCurrentTime()+15);
}
if (kHeld & KEY_X) {
if (kDown & (KEY_R | KEY_UP)) {
if(PlayerInterface::IsPlaying())
PlayerInterface::TogglePlayback();
}

if (kDown & KEY_LEFT) {
if(PlayerInterface::IsPlaying())
PlayerInterface::SeekSectionTime(PlayerInterface::GetCurrentTime()-15);
}
if (kDown & KEY_RIGHT) {
if(PlayerInterface::IsPlaying())
PlayerInterface::SeekSectionTime(PlayerInterface::GetCurrentTime()+15);
}

if(kDown & KEY_A) {
exitPlayback();
}
if (kDown & KEY_LEFT) {
if(PlayerInterface::IsPlaying())
PlayerInterface::SeekSectionTime(PlayerInterface::GetCurrentTime()-15);
}

if(kDown & KEY_Y) {
PlayerInterface::SkipPlayback();
}
if(kDown & KEY_A) {
exitPlayback();
}

return;
if(kDown & KEY_Y) {
PlayerInterface::SkipPlayback();
}

if (kDown & KEY_R && window < WINDOW_MAX-1)
window++;
return;
}

if (kDown & KEY_L && window > WINDOW_MIN)
window--;
if (kDown & KEY_R && window < WINDOW_MAX-1)
window++;

if (window == WINDOW_BROWSER)
PlayerMenu::BrowserControls(touch);
}
if (kDown & KEY_L && window > WINDOW_MIN)
window--;

if (window == WINDOW_BROWSER)
PlayerMenu::BrowserControls(touch);
}

void PlayerMenu::BrowserControls(touchPosition* touch) {
Expand Down
8 changes: 6 additions & 2 deletions src/gui/menus/SelectFileMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SelectFileMenu::SelectFileMenu(std::string* path) : filepath(path)
}
}

static void List(const char* text, int row)
static void displayDirName(const char* text, int row)
{
Gui::PrintColor(text, 8.0f, row*12, 0.4f, 0.4f, 0xFF000000);
}
Expand Down Expand Up @@ -53,13 +53,14 @@ static void menuList(int cur, int from, float startpoint, float size, int rows)
void SelectFileMenu::drawTop() const
{
Gui::Print("Select a config file.", 20.0f, 40.0f, 0.5f, 0.5f);
Gui::Print("Press <X> to exit.", 20.0f, 60.0f, 0.5f, 0.5f);
}

void SelectFileMenu::drawBottom() const
{
menuList(cursor, seloffs, 15, 15, expInst->Size());
C2D_DrawRectSolid(0, 0, 0.5f, SCREEN_WIDTH, 15, C2D_Color32(119, 131, 147, 255));
List(expInst->GetCurrentDir().c_str(), 0);
displayDirName(expInst->GetCurrentDir().c_str(), 0);
fblist(expInst->Size(), 15, 15);
}

Expand All @@ -69,6 +70,9 @@ void SelectFileMenu::update(touchPosition* touch)
u32 kHeld = hidKeysHeld();
static u64 mill = 0;

if (kDown & KEY_X)
Gui::BackMenu();

if (kDown & KEY_A) {
DirEntry_t dent = expInst->GetEntry(cursor);
if (dent.directory) {
Expand Down
Loading

0 comments on commit 537d1e3

Please sign in to comment.