Skip to content

Commit

Permalink
fix font cache and switch to libcurl
Browse files Browse the repository at this point in the history
  • Loading branch information
vgmoose committed Aug 28, 2018
1 parent f8ee414 commit 023373a
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -3,7 +3,7 @@ sudo: required
matrix:
include:
- os: linux
dist: trusty
dist: xenial
addons:
apt:
packages:
Expand All @@ -12,5 +12,5 @@ addons:
- libsdl2-gfx-dev
- libsdl2-ttf-dev
- zlib1g-dev

script: make -f Makefile.pc
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -55,7 +55,7 @@ CFLAGS := -g -Wall -O2 \
-ffast-math \
$(ARCH) $(DEFINES)

CFLAGS += $(INCLUDE) -DSWITCH -D__LIBNX__ -DNOSTYLUS -DUSE_FILE32API -DNOCURL
CFLAGS += $(INCLUDE) -DSWITCH -D__LIBNX__ -DNOSTYLUS -DUSE_FILE32API


CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
Expand Down
4 changes: 2 additions & 2 deletions Makefile.pc
Expand Up @@ -6,11 +6,11 @@ MINIZIP_O := zip.o ioapi.o unzip.o

all:
gcc -c $(MINIZIP)/*.c
g++ -g -std=gnu++11 *.cpp ./console/*.cpp ./gui/*.cpp -lSDL2 -lSDL2main -lSDL2_image -lSDL2_ttf -lSDL2_gfx ./libs/get/src/*.cpp $(MINIZIP_O) -I $(RAPIDJSON) -I $(MINIZIP) -I /usr/local/include -lz -o appstore.bin -fstack-protector-all -DNOCURL
g++ -g -std=gnu++11 *.cpp ./console/*.cpp ./gui/*.cpp -lSDL2 -lSDL2main -lSDL2_image -lSDL2_ttf -lSDL2_gfx ./libs/get/src/*.cpp $(MINIZIP_O) -I $(RAPIDJSON) -I $(MINIZIP) -I /usr/local/include -lz -o appstore.bin -fstack-protector-all

macos:
gcc -c $(MINIZIP)/*.c
g++ -g -std=gnu++11 *.cpp -lSDL2 -lSDL2main -lSDL2_gfx -lSDL2_image -lSDL2_ttf -framework Cocoa ./console/*.cpp ./gui/*.cpp ./libs/get/src/*.cpp $(MINIZIP_O) -I $(RAPIDJSON) -I $(MINIZIP) -I /usr/local/include -lcurl -lz -o appstore.exe -fstack-protector-all -DNOCURL
g++ -g -std=gnu++11 *.cpp -lSDL2 -lSDL2main -lSDL2_gfx -lSDL2_image -lSDL2_ttf -framework Cocoa ./console/*.cpp ./gui/*.cpp ./libs/get/src/*.cpp $(MINIZIP_O) -I $(RAPIDJSON) -I $(MINIZIP) -I /usr/local/include -lcurl -lz -o appstore.exe -fstack-protector-all

clean:
rm *.o *.bin
8 changes: 7 additions & 1 deletion gui/AppPopup.cpp
Expand Up @@ -229,9 +229,13 @@ void AppPopup::render(Element* parent)
this->subscreen->render(this);
}

void AppPopup::updateCurrentlyDisplayedPopup(float amount)
int AppPopup::updateCurrentlyDisplayedPopup(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
{
AppPopup* popup = AppPopup::frontmostPopup;

if (dltotal == 0) dltotal = 1;

double amount = dlnow / dltotal;

// update the amount
if (popup != NULL)
Expand All @@ -254,4 +258,6 @@ void AppPopup::updateCurrentlyDisplayedPopup(float amount)
}

}

return 0;
}
2 changes: 1 addition & 1 deletion gui/AppPopup.hpp
Expand Up @@ -22,7 +22,7 @@ class AppPopup : public Element
DetailsPopup* subscreen = NULL;

// the callback method to update the currently displayed pop up (and variables it needs)
static void updateCurrentlyDisplayedPopup(float amount);
static int updateCurrentlyDisplayedPopup(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
static AppPopup* frontmostPopup;
};

Expand Down
15 changes: 8 additions & 7 deletions gui/TextElement.cpp
Expand Up @@ -11,6 +11,11 @@ TextElement::TextElement(const char* text, int size, SDL_Color* color, bool mono
this->color = *color;

this->textSurface = this->renderText(*(this->text), size, monospaced, wrapped_width);

int w, h;
SDL_QueryTexture(this->textSurface, NULL, NULL, &w, &h);
this->width = w;
this->height = h;
}

void TextElement::render(Element* parent)
Expand All @@ -37,9 +42,8 @@ SDL_Texture* TextElement::renderText(std::string& message, int size, bool monosp
std::string key = message + std::to_string(size);

// try to find it in the cache first
// TODO: fix cache?
// if (ImageCache::cache.count(key))
// return ImageCache::cache[key];
if (ImageCache::cache.count(key))
return ImageCache::cache[key];

// not found, make/render it

Expand All @@ -61,10 +65,7 @@ SDL_Texture* TextElement::renderText(std::string& message, int size, bool monosp
surf = TTF_RenderText_Blended_Wrapped(font, message.c_str(), this->color, wrapped_width);

SDL_Texture* texture = SDL_CreateTextureFromSurface(MainDisplay::mainRenderer, surf);

this->width = surf->w;
this->height = surf->h;
SDL_FreeSurface(surf);
SDL_FreeSurface(surf);

// SDL_FreeSurface(surf);
TTF_CloseFont(font);
Expand Down
2 changes: 1 addition & 1 deletion libs/get
Submodule get updated from 4bec7d to 2338da

0 comments on commit 023373a

Please sign in to comment.