Skip to content

Commit

Permalink
fully functioning, technically
Browse files Browse the repository at this point in the history
very slow, needs caching and features
  • Loading branch information
vgmoose committed Jun 13, 2016
1 parent 0bd0a56 commit a3e8145
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 37 deletions.
Binary file modified hbas.elf
Binary file not shown.
Binary file modified hbas_dbg.elf
Binary file not shown.
3 changes: 3 additions & 0 deletions src/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#include "video/CVideo.h"
#include "system/CThread.h"

#define repoUrl "http://wiiubru.com/appstore"
//#define repoUrl "192.168.1.104:8000"

class Application : public CThread
{
public:
Expand Down
69 changes: 41 additions & 28 deletions src/menu/HomebrewLaunchWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ HomebrewLaunchWindow::HomebrewLaunchWindow(homebrewButton & thisButton, Homebrew

HomebrewXML metaXml;
bool xmlReadSuccess = metaXml.LoadHomebrewXMLData((homebrewPath + "/meta.xml").c_str());

// if GET or UDPATE, fetch xml from server
// if (selectedButton->status == GET || selectedButton->status == UPDATE)
// {
// std::string xmlFetchData;
// FileDownloader::getFile(std::string(repoUrl)+"/apps/"+selectedButton->shortname+"/meta.xml", xmlFetchData);
// xmlReadSuccess = metaXml.LoadHomebrewXMLData(xmlFetchData.c_str());
// }

int xOffset = 500;
int yOffset = height * 0.5f - 75.0f;
Expand Down Expand Up @@ -112,39 +120,44 @@ HomebrewLaunchWindow::HomebrewLaunchWindow(homebrewButton & thisButton, Homebrew
descriptionText.setMaxWidth(width - 200, GuiText::WRAP);
append(&descriptionText);

scaleFactor = 1.0f;
loadImg.setScale(scaleFactor);
loadBtn.setSize(scaleFactor * loadImg.getWidth(), scaleFactor * loadImg.getHeight());
loadBtn.setImage(&loadImg);
loadBtn.setLabel(&loadBtnLabel);
loadBtn.setAlignment(ALIGN_CENTER | ALIGN_MIDDLE);
loadBtn.setPosition(-600, -310);
loadBtn.setTrigger(&touchTrigger);
loadBtn.setTrigger(&wpadTouchTrigger);
loadBtn.setEffectGrow();
loadBtn.setSoundClick(buttonClickSound);
loadBtn.clicked.connect(this, &HomebrewLaunchWindow::OnLoadButtonClick);
append(&loadBtn);

delImg.setScale(scaleFactor);
delBtn.setSize(scaleFactor * loadImg.getWidth(), scaleFactor * delImg.getHeight());
delBtn.setImage(&delImg);
delBtn.setLabel(&delBtnLabel);
delBtn.setAlignment(ALIGN_CENTER | ALIGN_MIDDLE);
delBtn.setPosition(-200, -310);
delBtn.setTrigger(&touchTrigger);
delBtn.setTrigger(&wpadTouchTrigger);
delBtn.setEffectGrow();
delBtn.setSoundClick(buttonClickSound);
delBtn.clicked.connect(this, &HomebrewLaunchWindow::OnDeleteButtonClick);
append(&delBtn);
if (thisButton.status == GET || thisButton.status == UPDATE)
{
scaleFactor = 1.0f;
loadImg.setScale(scaleFactor);
loadBtn.setSize(scaleFactor * loadImg.getWidth(), scaleFactor * loadImg.getHeight());
loadBtn.setImage(&loadImg);
loadBtn.setLabel(&loadBtnLabel);
loadBtn.setAlignment(ALIGN_CENTER | ALIGN_MIDDLE);
loadBtn.setPosition(-300, -310);
loadBtn.setTrigger(&touchTrigger);
loadBtn.setTrigger(&wpadTouchTrigger);
loadBtn.setEffectGrow();
loadBtn.setSoundClick(buttonClickSound);
loadBtn.clicked.connect(this, &HomebrewLaunchWindow::OnLoadButtonClick);
append(&loadBtn);
}
if (thisButton.status != GET)
{
delImg.setScale(scaleFactor);
delBtn.setSize(scaleFactor * loadImg.getWidth(), scaleFactor * delImg.getHeight());
delBtn.setImage(&delImg);
delBtn.setLabel(&delBtnLabel);
delBtn.setAlignment(ALIGN_CENTER | ALIGN_MIDDLE);
delBtn.setPosition(0, -310);
delBtn.setTrigger(&touchTrigger);
delBtn.setTrigger(&wpadTouchTrigger);
delBtn.setEffectGrow();
delBtn.setSoundClick(buttonClickSound);
delBtn.clicked.connect(this, &HomebrewLaunchWindow::OnDeleteButtonClick);
append(&delBtn);
}

backImg.setScale(scaleFactor);
backBtn.setSize(scaleFactor * backImg.getWidth(), scaleFactor * backImg.getHeight());
backBtn.setImage(&backImg);
backBtn.setLabel(&backBtnLabel);
backBtn.setAlignment(ALIGN_CENTER | ALIGN_MIDDLE);
backBtn.setPosition(200, -310);
backBtn.setPosition(300, -310);
backBtn.setTrigger(&touchTrigger);
backBtn.setTrigger(&wpadTouchTrigger);
backBtn.setEffectGrow();
Expand Down Expand Up @@ -225,7 +238,7 @@ void HomebrewLaunchWindow::OnLoadButtonClick(GuiButton *button, const GuiControl
std::string path = "/apps/"+selectedButton->shortname;
std::string sdPath = "sd:/wiiu"+path;
CreateSubfolder(sdPath.c_str());
std::string repoUrl = "http://192.168.1.104:8000";
// std::string repoUrl = "http://192.168.1.104:8000";
FileDownloader::getFile(repoUrl+path+"/"+selectedButton->binary, sdPath+"/"+selectedButton->binary, 0);
FileDownloader::getFile(repoUrl+path+"/meta.xml", sdPath+"/meta.xml", 0);
FileDownloader::getFile(repoUrl+path+"/icon.png", sdPath+"/icon.png", 0);
Expand Down
58 changes: 49 additions & 9 deletions src/menu/HomebrewWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@

#define MAX_BUTTONS_ON_PAGE 4

#define LOCAL 0
#define UPDATE 1
#define INSTALLED 2
#define GET 3

void HomebrewWindow::positionHomebrewButton(homebrewButton* button, int index)
{
const float cfImageScale = 0.8f;
Expand Down Expand Up @@ -69,6 +64,27 @@ void HomebrewWindow::positionHomebrewButton(homebrewButton* button, int index)
button->button->clicked.connect(this, &HomebrewWindow::OnHomebrewButtonClick);
}

int HomebrewWindow::checkIfUpdateOrInstalled(std::string name, std::string version, int totalLocalApps)
{
for (int x=0; x<totalLocalApps; x++)
{
// if shortname matches
if (!name.compare(homebrewButtons[x].shortname))
{
homebrewButtons[x].status = INSTALLED;
if (version.compare(homebrewButtons[x].version))
{
// if version doesn't match
homebrewButtons[x].status = UPDATE;
}
removeE(homebrewButtons[x].button);

return x;
}
}
return -1;
}

void HomebrewWindow::refreshHomebrewApps()
{
GuiImageData* appButtonImages[4] = { localButtonImgData, updateButtonImgData, installedButtonImgData, getButtonImgData };
Expand All @@ -83,6 +99,7 @@ void HomebrewWindow::refreshHomebrewApps()
homebrewButtons.clear();
dirList.SortList();

int totalLocalApps = 0;
// load up local apps
for(int i = 0; i < dirList.GetFilecount(); i++)
{
Expand All @@ -92,7 +109,7 @@ void HomebrewWindow::refreshHomebrewApps()

int idx = homebrewButtons.size();
homebrewButtons.resize(homebrewButtons.size() + 1);

// file path
homebrewButtons[idx].execPath = dirList.GetFilepath(i);
homebrewButtons[idx].iconImgData = NULL;
Expand All @@ -107,6 +124,9 @@ void HomebrewWindow::refreshHomebrewApps()

homebrewButtons[idx].dirPath = homebrewPath;

// assume that the first part of homebrewPath is "sd:/wiiu/apps/"
homebrewButtons[idx].shortname = homebrewPath.substr(14);

// since we got this app from the sd card, mark it local for now.
// if we see it later on the server, update its status appropriately to
// update or installed
Expand Down Expand Up @@ -135,16 +155,19 @@ void HomebrewWindow::refreshHomebrewApps()
homebrewButtons[idx].descriptionLabel = new GuiText(metaXml.GetCoder(), 28, glm::vec4(0, 0, 0, 1));
homebrewButtons[idx].button = new GuiButton(installedButtonImgData->getWidth(), installedButtonImgData->getHeight());
homebrewButtons[idx].image = new GuiImage(appButtonImages[homebrewButtons[idx].status]);
homebrewButtons[idx].version = metaXml.GetVersion();

positionHomebrewButton(&homebrewButtons[idx], idx);

append(homebrewButtons[idx].button);
}

totalLocalApps = homebrewButtons.size();

// download app list from the repo
std::string fileContents;
std::string repoUrl = "http://192.168.1.104:8000";
std::string targetUrl = std::string(repoUrl+"/directory.yaml");
// std::string repoUrl = "http://192.168.1.104:8000";
std::string targetUrl = std::string(repoUrl)+"/directory.yaml";
FileDownloader::getFile(targetUrl, fileContents);
std::istringstream f(fileContents);

Expand All @@ -166,6 +189,9 @@ void HomebrewWindow::refreshHomebrewApps()
std::string binary;
std::getline(f, binary);
binary = binary.substr(2);
std::string version;
std::getline(f, version);
version = version.substr(2);

int idx = homebrewButtons.size();
homebrewButtons.resize(homebrewButtons.size() + 1);
Expand All @@ -188,10 +214,24 @@ void HomebrewWindow::refreshHomebrewApps()
homebrewButtons[idx].status = GET;
homebrewButtons[idx].shortname = shortname;
homebrewButtons[idx].binary = binary;
homebrewButtons[idx].version = version;

// update status if already a local app
int addedIndex = checkIfUpdateOrInstalled(homebrewButtons[idx].shortname, homebrewButtons[idx].version, totalLocalApps);

if (addedIndex >= 0)
{
homebrewButtons.pop_back();
homebrewButtons[addedIndex].button = new GuiButton(installedButtonImgData->getWidth(), installedButtonImgData->getHeight());
homebrewButtons[addedIndex].image = new GuiImage(appButtonImages[homebrewButtons[addedIndex].status]);
append(homebrewButtons[addedIndex].button);
positionHomebrewButton(&homebrewButtons[addedIndex], addedIndex);
continue;
}

// download app icon
std::string targetIcon;
std::string targetIconUrl = std::string(repoUrl+"/apps/" + shortname + "/icon.png");
std::string targetIconUrl = std::string(repoUrl)+"/apps/" + shortname + "/icon.png";
FileDownloader::getFile(targetIconUrl, targetIcon);

homebrewButtons[idx].iconImgData = new GuiImageData((u8*)targetIcon.c_str(), targetIcon.size());
Expand Down
8 changes: 8 additions & 0 deletions src/menu/HomebrewWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
#include "gui/Gui.h"
#include "gui/GuiFrame.h"


#define LOCAL 0
#define UPDATE 1
#define INSTALLED 2
#define GET 3

typedef struct
{
std::string execPath;
Expand All @@ -33,6 +39,7 @@ typedef struct
int status;
std::string dirPath;
std::string binary;
std::string version;
} homebrewButton;

class HomebrewWindow : public GuiFrame, public sigslot::has_slots<>
Expand All @@ -49,6 +56,7 @@ class HomebrewWindow : public GuiFrame, public sigslot::has_slots<>

void positionHomebrewButton(homebrewButton*, int);
void refreshHomebrewApps();
int checkIfUpdateOrInstalled(std::string name, std::string version, int totalLocalApps);

private:
void OnOpenEffectFinish(GuiElement *element);
Expand Down

0 comments on commit a3e8145

Please sign in to comment.