mirror of
https://github.com/XorTroll/hb-appstore.git
synced 2024-11-27 04:00:58 +00:00
switch: fix romfs, fix all gamepad events coming in as A button
This commit is contained in:
parent
99c5e107de
commit
aa38536d96
@ -42,7 +42,7 @@ EXEFS_SRC := exefs_src
|
||||
|
||||
APP_TITLE := hb App Store
|
||||
APP_AUTHOR := vgmoose
|
||||
APP_VERSION := 1.1
|
||||
APP_VERSION := 2.0
|
||||
ICON := res/icon.jpg
|
||||
#APP_TITLEID := is the titleID of the app stored in the .nacp file (Optional)
|
||||
|
||||
|
@ -59,7 +59,7 @@ void AppCard::update()
|
||||
this->elements.push_back(author);
|
||||
|
||||
// download status icon
|
||||
ImageElement* statusicon = new ImageElement(("res/" + std::string(package->statusString()) + ".png").c_str());
|
||||
ImageElement* statusicon = new ImageElement((ROMFS "res/" + std::string(package->statusString()) + ".png").c_str());
|
||||
statusicon->position(this->x + 4, this->y + icon->height + 10);
|
||||
statusicon->resize(30, 30);
|
||||
this->elements.push_back(statusicon);
|
||||
|
@ -12,10 +12,6 @@ Button::Button(const char* message, int button, bool dark, int size, int width)
|
||||
|
||||
this->dark = dark;
|
||||
|
||||
// ImageElement* icon = new ImageElement((std::string("res/")+inverse+"button-"+button+outline+".png").c_str());
|
||||
// icon->position(PADDING, PADDING);
|
||||
// this->elements.push_back(icon);
|
||||
|
||||
const char* unicode;
|
||||
|
||||
switch (button)
|
||||
|
@ -9,6 +9,12 @@
|
||||
#define HIGHLIGHT 100
|
||||
#define NO_HIGHLIGHT 0
|
||||
|
||||
#if defined(SWITCH)
|
||||
#define ROMFS "romfs:/"
|
||||
#else
|
||||
#define ROMFS ""
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
class Element
|
||||
|
@ -4,8 +4,6 @@
|
||||
#include "../libs/get/src/libs/rapidjson/include/rapidjson/writer.h"
|
||||
#include "../libs/get/src/libs/rapidjson/include/rapidjson/stringbuffer.h"
|
||||
|
||||
|
||||
|
||||
#include <fstream>
|
||||
|
||||
std::unordered_map<std::string, SDL_Texture*> ImageCache::cache;
|
||||
|
@ -2,15 +2,11 @@
|
||||
#include <SDL2/SDL2_rotozoom.h>
|
||||
#include <string.h>
|
||||
|
||||
ImageElement::ImageElement(const char* path)
|
||||
ImageElement::ImageElement(const char* incoming)
|
||||
{
|
||||
std::string key = std::string(path);
|
||||
this->path = path;
|
||||
#if defined(SWITCH)
|
||||
// if the image path we want to load starts with 'res', prepend romfs for switch
|
||||
if (strncmp(this->path, "res/", 4) == 0)
|
||||
this->path = (std::string("romfs:/") + path).c_str();
|
||||
#endif
|
||||
this->path = incoming;
|
||||
|
||||
std::string key = std::string(this->path);
|
||||
|
||||
// try to find it in the cache first
|
||||
if (ImageCache::cache.count(key))
|
||||
|
@ -19,7 +19,7 @@ bool InputEvents::update()
|
||||
|
||||
// update our variables
|
||||
this->type = event.type;
|
||||
this->keyCode = 0;
|
||||
this->keyCode = -1;
|
||||
this->noop = false;
|
||||
|
||||
#ifdef PC
|
||||
@ -32,7 +32,7 @@ bool InputEvents::update()
|
||||
}
|
||||
else if (this->type == SDL_JOYBUTTONDOWN || this->type == SDL_JOYBUTTONUP)
|
||||
{
|
||||
this->keyCode = event.jbutton.which;
|
||||
this->keyCode = event.jbutton.button;
|
||||
}
|
||||
else if (this->type == SDL_JOYAXISMOTION)
|
||||
{
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
bool isKeyDown();
|
||||
bool isKeyUp();
|
||||
|
||||
SDL_Keycode keyCode;
|
||||
SDL_Keycode keyCode = -1;
|
||||
|
||||
int yPos = 0, xPos = 0;
|
||||
bool noop = false;
|
||||
|
@ -83,7 +83,7 @@ MainDisplay::MainDisplay(Get* get)
|
||||
// this->elements.push_back(pbar_text);
|
||||
|
||||
// create the first two elements (icon and app title)
|
||||
ImageElement* icon = new ImageElement("res/icon.png");
|
||||
ImageElement* icon = new ImageElement(ROMFS "res/icon.png");
|
||||
icon->position(330 + this->error*140, 255 - this->error*230);
|
||||
icon->resize(70 - this->error*35, 70 - this->error*35);
|
||||
this->elements.push_back(icon);
|
||||
@ -147,12 +147,12 @@ bool MainDisplay::process(InputEvents* event)
|
||||
|
||||
bool success = downloadFileToDisk(*(current->repoUrl) + "/packages/" + current->pkg_name + "/icon.png", key_path + "/icon.png");
|
||||
if (!success) // manually add defualt icon to cache if downloading failed
|
||||
cp("res/default.png", (key_path + "/icon.png").c_str());
|
||||
cp(ROMFS "res/default.png", (key_path + "/icon.png").c_str());
|
||||
// TODO: generate a custom icon for this version with a color and name
|
||||
|
||||
success = downloadFileToDisk(*(current->repoUrl) + "/packages/" + current->pkg_name + "/screen.png", key_path + "/screen.png");
|
||||
if (!success)
|
||||
cp("res/noscreen.png", (key_path + "/screen.png").c_str());
|
||||
cp(ROMFS "res/noscreen.png", (key_path + "/screen.png").c_str());
|
||||
|
||||
// add these versions to the version map
|
||||
this->imageCache->version_cache[current->pkg_name] = current->version;
|
||||
|
@ -12,7 +12,7 @@ Sidebar::Sidebar()
|
||||
// there's no back color to the sidebar, as the background is already the right color
|
||||
|
||||
// create image in top left
|
||||
ImageElement* logo = new ImageElement("res/icon.png");
|
||||
ImageElement* logo = new ImageElement(ROMFS "res/icon.png");
|
||||
logo->resize(40, 40);
|
||||
logo->position(30, 50);
|
||||
this->elements.push_back(logo);
|
||||
@ -29,7 +29,7 @@ Sidebar::Sidebar()
|
||||
// for every entry in cat names, create a text element
|
||||
for (int x=0; x<TOTAL_CATS; x++)
|
||||
{
|
||||
ImageElement* icon = new ImageElement((std::string("res/") + cat_value[x] + ".png").c_str());
|
||||
ImageElement* icon = new ImageElement((std::string(ROMFS "res/") + cat_value[x] + ".png").c_str());
|
||||
icon->resize(40, 40);
|
||||
icon->position(30, 150+x*70 - 5);
|
||||
this->elements.push_back(icon);
|
||||
@ -40,7 +40,7 @@ Sidebar::Sidebar()
|
||||
}
|
||||
|
||||
// small indicator to switch to advanced view using L
|
||||
ImageElement* hider = new ImageElement("res/button-l-outline.png");
|
||||
ImageElement* hider = new ImageElement(ROMFS "res/button-l-outline.png");
|
||||
hider->resize(20, 20);
|
||||
hider->position(270, 685);
|
||||
this->elements.push_back(hider);
|
||||
|
@ -50,11 +50,11 @@ SDL_Texture* TextElement::renderText(std::string& message, int size, int font_ty
|
||||
TTF_Font* font;
|
||||
|
||||
if (font_type == MONOSPACED)
|
||||
font = TTF_OpenFont("./res/mono.ttf", size);
|
||||
font = TTF_OpenFont(ROMFS "./res/mono.ttf", size);
|
||||
else if (font_type == ICON)
|
||||
font = TTF_OpenFont("./res/nxicons.ttf", size);
|
||||
font = TTF_OpenFont(ROMFS "./res/nxicons.ttf", size);
|
||||
else
|
||||
font = TTF_OpenFont("./res/opensans.ttf", size);
|
||||
font = TTF_OpenFont(ROMFS "./res/opensans.ttf", size);
|
||||
|
||||
// font couldn't load, don't render anything
|
||||
if (!font)
|
||||
|
Loading…
Reference in New Issue
Block a user