Skip to content

Commit a3e8145

Browse files
committed
fully functioning, technically
very slow, needs caching and features
1 parent 0bd0a56 commit a3e8145

File tree

6 files changed

+101
-37
lines changed

6 files changed

+101
-37
lines changed

hbas.elf

2.31 KB
Binary file not shown.

hbas_dbg.elf

2.38 KB
Binary file not shown.

src/Application.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#include "video/CVideo.h"
2222
#include "system/CThread.h"
2323

24+
#define repoUrl "http://wiiubru.com/appstore"
25+
//#define repoUrl "192.168.1.104:8000"
26+
2427
class Application : public CThread
2528
{
2629
public:

src/menu/HomebrewLaunchWindow.cpp

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ HomebrewLaunchWindow::HomebrewLaunchWindow(homebrewButton & thisButton, Homebrew
6262

6363
HomebrewXML metaXml;
6464
bool xmlReadSuccess = metaXml.LoadHomebrewXMLData((homebrewPath + "/meta.xml").c_str());
65+
66+
// if GET or UDPATE, fetch xml from server
67+
// if (selectedButton->status == GET || selectedButton->status == UPDATE)
68+
// {
69+
// std::string xmlFetchData;
70+
// FileDownloader::getFile(std::string(repoUrl)+"/apps/"+selectedButton->shortname+"/meta.xml", xmlFetchData);
71+
// xmlReadSuccess = metaXml.LoadHomebrewXMLData(xmlFetchData.c_str());
72+
// }
6573

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

115-
scaleFactor = 1.0f;
116-
loadImg.setScale(scaleFactor);
117-
loadBtn.setSize(scaleFactor * loadImg.getWidth(), scaleFactor * loadImg.getHeight());
118-
loadBtn.setImage(&loadImg);
119-
loadBtn.setLabel(&loadBtnLabel);
120-
loadBtn.setAlignment(ALIGN_CENTER | ALIGN_MIDDLE);
121-
loadBtn.setPosition(-600, -310);
122-
loadBtn.setTrigger(&touchTrigger);
123-
loadBtn.setTrigger(&wpadTouchTrigger);
124-
loadBtn.setEffectGrow();
125-
loadBtn.setSoundClick(buttonClickSound);
126-
loadBtn.clicked.connect(this, &HomebrewLaunchWindow::OnLoadButtonClick);
127-
append(&loadBtn);
128-
129-
delImg.setScale(scaleFactor);
130-
delBtn.setSize(scaleFactor * loadImg.getWidth(), scaleFactor * delImg.getHeight());
131-
delBtn.setImage(&delImg);
132-
delBtn.setLabel(&delBtnLabel);
133-
delBtn.setAlignment(ALIGN_CENTER | ALIGN_MIDDLE);
134-
delBtn.setPosition(-200, -310);
135-
delBtn.setTrigger(&touchTrigger);
136-
delBtn.setTrigger(&wpadTouchTrigger);
137-
delBtn.setEffectGrow();
138-
delBtn.setSoundClick(buttonClickSound);
139-
delBtn.clicked.connect(this, &HomebrewLaunchWindow::OnDeleteButtonClick);
140-
append(&delBtn);
123+
if (thisButton.status == GET || thisButton.status == UPDATE)
124+
{
125+
scaleFactor = 1.0f;
126+
loadImg.setScale(scaleFactor);
127+
loadBtn.setSize(scaleFactor * loadImg.getWidth(), scaleFactor * loadImg.getHeight());
128+
loadBtn.setImage(&loadImg);
129+
loadBtn.setLabel(&loadBtnLabel);
130+
loadBtn.setAlignment(ALIGN_CENTER | ALIGN_MIDDLE);
131+
loadBtn.setPosition(-300, -310);
132+
loadBtn.setTrigger(&touchTrigger);
133+
loadBtn.setTrigger(&wpadTouchTrigger);
134+
loadBtn.setEffectGrow();
135+
loadBtn.setSoundClick(buttonClickSound);
136+
loadBtn.clicked.connect(this, &HomebrewLaunchWindow::OnLoadButtonClick);
137+
append(&loadBtn);
138+
}
139+
if (thisButton.status != GET)
140+
{
141+
delImg.setScale(scaleFactor);
142+
delBtn.setSize(scaleFactor * loadImg.getWidth(), scaleFactor * delImg.getHeight());
143+
delBtn.setImage(&delImg);
144+
delBtn.setLabel(&delBtnLabel);
145+
delBtn.setAlignment(ALIGN_CENTER | ALIGN_MIDDLE);
146+
delBtn.setPosition(0, -310);
147+
delBtn.setTrigger(&touchTrigger);
148+
delBtn.setTrigger(&wpadTouchTrigger);
149+
delBtn.setEffectGrow();
150+
delBtn.setSoundClick(buttonClickSound);
151+
delBtn.clicked.connect(this, &HomebrewLaunchWindow::OnDeleteButtonClick);
152+
append(&delBtn);
153+
}
141154

142155
backImg.setScale(scaleFactor);
143156
backBtn.setSize(scaleFactor * backImg.getWidth(), scaleFactor * backImg.getHeight());
144157
backBtn.setImage(&backImg);
145158
backBtn.setLabel(&backBtnLabel);
146159
backBtn.setAlignment(ALIGN_CENTER | ALIGN_MIDDLE);
147-
backBtn.setPosition(200, -310);
160+
backBtn.setPosition(300, -310);
148161
backBtn.setTrigger(&touchTrigger);
149162
backBtn.setTrigger(&wpadTouchTrigger);
150163
backBtn.setEffectGrow();
@@ -225,7 +238,7 @@ void HomebrewLaunchWindow::OnLoadButtonClick(GuiButton *button, const GuiControl
225238
std::string path = "/apps/"+selectedButton->shortname;
226239
std::string sdPath = "sd:/wiiu"+path;
227240
CreateSubfolder(sdPath.c_str());
228-
std::string repoUrl = "http://192.168.1.104:8000";
241+
// std::string repoUrl = "http://192.168.1.104:8000";
229242
FileDownloader::getFile(repoUrl+path+"/"+selectedButton->binary, sdPath+"/"+selectedButton->binary, 0);
230243
FileDownloader::getFile(repoUrl+path+"/meta.xml", sdPath+"/meta.xml", 0);
231244
FileDownloader::getFile(repoUrl+path+"/icon.png", sdPath+"/icon.png", 0);

src/menu/HomebrewWindow.cpp

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@
3030

3131
#define MAX_BUTTONS_ON_PAGE 4
3232

33-
#define LOCAL 0
34-
#define UPDATE 1
35-
#define INSTALLED 2
36-
#define GET 3
37-
3833
void HomebrewWindow::positionHomebrewButton(homebrewButton* button, int index)
3934
{
4035
const float cfImageScale = 0.8f;
@@ -69,6 +64,27 @@ void HomebrewWindow::positionHomebrewButton(homebrewButton* button, int index)
6964
button->button->clicked.connect(this, &HomebrewWindow::OnHomebrewButtonClick);
7065
}
7166

67+
int HomebrewWindow::checkIfUpdateOrInstalled(std::string name, std::string version, int totalLocalApps)
68+
{
69+
for (int x=0; x<totalLocalApps; x++)
70+
{
71+
// if shortname matches
72+
if (!name.compare(homebrewButtons[x].shortname))
73+
{
74+
homebrewButtons[x].status = INSTALLED;
75+
if (version.compare(homebrewButtons[x].version))
76+
{
77+
// if version doesn't match
78+
homebrewButtons[x].status = UPDATE;
79+
}
80+
removeE(homebrewButtons[x].button);
81+
82+
return x;
83+
}
84+
}
85+
return -1;
86+
}
87+
7288
void HomebrewWindow::refreshHomebrewApps()
7389
{
7490
GuiImageData* appButtonImages[4] = { localButtonImgData, updateButtonImgData, installedButtonImgData, getButtonImgData };
@@ -83,6 +99,7 @@ void HomebrewWindow::refreshHomebrewApps()
8399
homebrewButtons.clear();
84100
dirList.SortList();
85101

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

93110
int idx = homebrewButtons.size();
94111
homebrewButtons.resize(homebrewButtons.size() + 1);
95-
112+
96113
// file path
97114
homebrewButtons[idx].execPath = dirList.GetFilepath(i);
98115
homebrewButtons[idx].iconImgData = NULL;
@@ -107,6 +124,9 @@ void HomebrewWindow::refreshHomebrewApps()
107124

108125
homebrewButtons[idx].dirPath = homebrewPath;
109126

127+
// assume that the first part of homebrewPath is "sd:/wiiu/apps/"
128+
homebrewButtons[idx].shortname = homebrewPath.substr(14);
129+
110130
// since we got this app from the sd card, mark it local for now.
111131
// if we see it later on the server, update its status appropriately to
112132
// update or installed
@@ -135,16 +155,19 @@ void HomebrewWindow::refreshHomebrewApps()
135155
homebrewButtons[idx].descriptionLabel = new GuiText(metaXml.GetCoder(), 28, glm::vec4(0, 0, 0, 1));
136156
homebrewButtons[idx].button = new GuiButton(installedButtonImgData->getWidth(), installedButtonImgData->getHeight());
137157
homebrewButtons[idx].image = new GuiImage(appButtonImages[homebrewButtons[idx].status]);
158+
homebrewButtons[idx].version = metaXml.GetVersion();
138159

139160
positionHomebrewButton(&homebrewButtons[idx], idx);
140161

141162
append(homebrewButtons[idx].button);
142163
}
164+
165+
totalLocalApps = homebrewButtons.size();
143166

144167
// download app list from the repo
145168
std::string fileContents;
146-
std::string repoUrl = "http://192.168.1.104:8000";
147-
std::string targetUrl = std::string(repoUrl+"/directory.yaml");
169+
// std::string repoUrl = "http://192.168.1.104:8000";
170+
std::string targetUrl = std::string(repoUrl)+"/directory.yaml";
148171
FileDownloader::getFile(targetUrl, fileContents);
149172
std::istringstream f(fileContents);
150173

@@ -166,6 +189,9 @@ void HomebrewWindow::refreshHomebrewApps()
166189
std::string binary;
167190
std::getline(f, binary);
168191
binary = binary.substr(2);
192+
std::string version;
193+
std::getline(f, version);
194+
version = version.substr(2);
169195

170196
int idx = homebrewButtons.size();
171197
homebrewButtons.resize(homebrewButtons.size() + 1);
@@ -188,10 +214,24 @@ void HomebrewWindow::refreshHomebrewApps()
188214
homebrewButtons[idx].status = GET;
189215
homebrewButtons[idx].shortname = shortname;
190216
homebrewButtons[idx].binary = binary;
217+
homebrewButtons[idx].version = version;
218+
219+
// update status if already a local app
220+
int addedIndex = checkIfUpdateOrInstalled(homebrewButtons[idx].shortname, homebrewButtons[idx].version, totalLocalApps);
221+
222+
if (addedIndex >= 0)
223+
{
224+
homebrewButtons.pop_back();
225+
homebrewButtons[addedIndex].button = new GuiButton(installedButtonImgData->getWidth(), installedButtonImgData->getHeight());
226+
homebrewButtons[addedIndex].image = new GuiImage(appButtonImages[homebrewButtons[addedIndex].status]);
227+
append(homebrewButtons[addedIndex].button);
228+
positionHomebrewButton(&homebrewButtons[addedIndex], addedIndex);
229+
continue;
230+
}
191231

192232
// download app icon
193233
std::string targetIcon;
194-
std::string targetIconUrl = std::string(repoUrl+"/apps/" + shortname + "/icon.png");
234+
std::string targetIconUrl = std::string(repoUrl)+"/apps/" + shortname + "/icon.png";
195235
FileDownloader::getFile(targetIconUrl, targetIcon);
196236

197237
homebrewButtons[idx].iconImgData = new GuiImageData((u8*)targetIcon.c_str(), targetIcon.size());

src/menu/HomebrewWindow.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
#include "gui/Gui.h"
2121
#include "gui/GuiFrame.h"
2222

23+
24+
#define LOCAL 0
25+
#define UPDATE 1
26+
#define INSTALLED 2
27+
#define GET 3
28+
2329
typedef struct
2430
{
2531
std::string execPath;
@@ -33,6 +39,7 @@ typedef struct
3339
int status;
3440
std::string dirPath;
3541
std::string binary;
42+
std::string version;
3643
} homebrewButton;
3744

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

5057
void positionHomebrewButton(homebrewButton*, int);
5158
void refreshHomebrewApps();
59+
int checkIfUpdateOrInstalled(std::string name, std::string version, int totalLocalApps);
5260

5361
private:
5462
void OnOpenEffectFinish(GuiElement *element);

0 commit comments

Comments
 (0)