Skip to content

Commit 0bd0a56

Browse files
committed
refresh app list after download/delete
1 parent 5ae6366 commit 0bd0a56

File tree

6 files changed

+123
-106
lines changed

6 files changed

+123
-106
lines changed

hbas.elf

-416 Bytes
Binary file not shown.

hbas_dbg.elf

-403 Bytes
Binary file not shown.

src/menu/HomebrewLaunchWindow.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
#include "dynamic_libs/sys_functions.h"
2424
#include "network/FileDownloader.h"
2525

26-
HomebrewLaunchWindow::HomebrewLaunchWindow(homebrewButton & thisButton)
26+
HomebrewLaunchWindow::HomebrewLaunchWindow(homebrewButton & thisButton, HomebrewWindow * window)
2727
: GuiFrame(0, 0)
28+
, homebrewWindow(window)
2829
, buttonClickSound(Resources::GetSound("button_click.mp3"))
2930
, backgroundImgData(Resources::GetImageData("launchMenuBox.png"))
3031
, backgroundImg(backgroundImgData)
@@ -47,13 +48,13 @@ HomebrewLaunchWindow::HomebrewLaunchWindow(homebrewButton & thisButton)
4748
, backBtn(backImg.getWidth(), backImg.getHeight())
4849
, touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH)
4950
, wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A)
50-
, selectedButton(thisButton)
51+
, selectedButton(&thisButton)
5152
{
5253
width = backgroundImg.getWidth();
5354
height = backgroundImg.getHeight();
5455
append(&backgroundImg);
5556

56-
std::string launchPath = selectedButton.execPath;
57+
std::string launchPath = selectedButton->execPath;
5758
std::string homebrewPath = launchPath;
5859
size_t slashPos = homebrewPath.rfind('/');
5960
if(slashPos != std::string::npos)
@@ -195,7 +196,7 @@ void HomebrewLaunchWindow::OnFileLoadFinish(GuiElement *element, const std::stri
195196

196197
void HomebrewLaunchWindow::OnDeleteButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger)
197198
{
198-
std::string removePath = selectedButton.dirPath;
199+
std::string removePath = selectedButton->dirPath;
199200
// if the remove path is the whole directory, stop!
200201
if (!removePath.compare(std::string("sd:/wiiu/apps")) || !removePath.compare(std::string("sd:/wiiu/apps/")))
201202
return;
@@ -210,6 +211,9 @@ void HomebrewLaunchWindow::OnDeleteButtonClick(GuiButton *button, const GuiContr
210211

211212
// close the window
212213
OnBackButtonClick(button, controller, trigger);
214+
215+
// refresh
216+
homebrewWindow->refreshHomebrewApps();
213217
}
214218

215219
void HomebrewLaunchWindow::OnLoadButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger)
@@ -218,16 +222,19 @@ void HomebrewLaunchWindow::OnLoadButtonClick(GuiButton *button, const GuiControl
218222
delBtn.setState(GuiElement::STATE_DISABLED);
219223
loadBtn.setState(GuiElement::STATE_DISABLED);
220224

221-
std::string path = "/apps/"+selectedButton.shortname;
225+
std::string path = "/apps/"+selectedButton->shortname;
222226
std::string sdPath = "sd:/wiiu"+path;
223227
CreateSubfolder(sdPath.c_str());
224228
std::string repoUrl = "http://192.168.1.104:8000";
225-
FileDownloader::getFile(repoUrl+path+"/"+selectedButton.binary, sdPath+"/"+selectedButton.binary, 0);
229+
FileDownloader::getFile(repoUrl+path+"/"+selectedButton->binary, sdPath+"/"+selectedButton->binary, 0);
226230
FileDownloader::getFile(repoUrl+path+"/meta.xml", sdPath+"/meta.xml", 0);
227231
FileDownloader::getFile(repoUrl+path+"/icon.png", sdPath+"/icon.png", 0);
228232

229233
// close the window
230234
OnBackButtonClick(button, controller, trigger);
235+
236+
// refresh
237+
homebrewWindow->refreshHomebrewApps();
231238

232239
// struct SYSBrowserArgsIn args = {};
233240
// std::string url = "http://vgmoose.com";

src/menu/HomebrewLaunchWindow.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
class HomebrewLaunchWindow : public GuiFrame, public sigslot::has_slots<>
2525
{
2626
public:
27-
HomebrewLaunchWindow(homebrewButton & thisButton);
27+
HomebrewLaunchWindow(homebrewButton & thisButton, HomebrewWindow* window);
2828
virtual ~HomebrewLaunchWindow();
2929

3030

@@ -70,7 +70,8 @@ class HomebrewLaunchWindow : public GuiFrame, public sigslot::has_slots<>
7070
GuiTrigger touchTrigger;
7171
GuiTrigger wpadTouchTrigger;
7272

73-
homebrewButton selectedButton;
73+
homebrewButton * selectedButton;
74+
HomebrewWindow * homebrewWindow;
7475
};
7576

7677
#endif //_HOMEBREW_LAUNCHER_WINDOW_H_

src/menu/HomebrewWindow.cpp

Lines changed: 106 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
#include <thread>
2727
#include <sstream>
2828

29-
30-
3129
#define DEFAULT_WIILOAD_PORT 4299
3230

3331
#define MAX_BUTTONS_ON_PAGE 4
@@ -71,36 +69,18 @@ void HomebrewWindow::positionHomebrewButton(homebrewButton* button, int index)
7169
button->button->clicked.connect(this, &HomebrewWindow::OnHomebrewButtonClick);
7270
}
7371

74-
HomebrewWindow::HomebrewWindow(int w, int h)
75-
: GuiFrame(w, h)
76-
, buttonClickSound(Resources::GetSound("button_click.mp3"))
77-
, installedButtonImgData(Resources::GetImageData("INSTALLED.png"))
78-
, getButtonImgData(Resources::GetImageData("GET.png"))
79-
, updateButtonImgData(Resources::GetImageData("UPDATE.png"))
80-
, localButtonImgData(Resources::GetImageData("LOCAL.png"))
81-
, arrowRightImageData(Resources::GetImageData("rightArrow.png"))
82-
, arrowLeftImageData(Resources::GetImageData("leftArrow.png"))
83-
, arrowRightImage(arrowRightImageData)
84-
, arrowLeftImage(arrowLeftImageData)
85-
, arrowRightButton(arrowRightImage.getWidth(), arrowRightImage.getHeight())
86-
, arrowLeftButton(arrowLeftImage.getWidth(), arrowLeftImage.getHeight())
87-
, hblVersionText("Homebrew App Store by VGMoose, Music by (T-T)b (google t tb bandcamp)", 32, glm::vec4(1.0f))
88-
, touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH)
89-
, wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A)
90-
, buttonLTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_L | GuiTrigger::BUTTON_LEFT, true)
91-
, buttonRTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_R | GuiTrigger::BUTTON_RIGHT, true)
72+
void HomebrewWindow::refreshHomebrewApps()
9273
{
93-
// tcpReceiver.serverReceiveStart.connect(this, &HomebrewWindow::OnTcpReceiveStart);
94-
// tcpReceiver.serverReceiveFinished.connect(this, &HomebrewWindow::OnTcpReceiveFinish);
95-
96-
targetLeftPosition = 0;
97-
currentLeftPosition = 0;
98-
listOffset = 0;
99-
10074
GuiImageData* appButtonImages[4] = { localButtonImgData, updateButtonImgData, installedButtonImgData, getButtonImgData };
10175

10276
DirList dirList("sd:/wiiu/apps", ".elf", DirList::Files | DirList::CheckSubfolders);
10377

78+
for (int x=0; x<homebrewButtons.size(); x++)
79+
{
80+
removeE(homebrewButtons[x].button);
81+
}
82+
83+
homebrewButtons.clear();
10484
dirList.SortList();
10585

10686
// load up local apps
@@ -161,78 +141,106 @@ HomebrewWindow::HomebrewWindow(int w, int h)
161141
append(homebrewButtons[idx].button);
162142
}
163143

164-
// download app list from the repo
165-
std::string fileContents;
166-
std::string repoUrl = "http://192.168.1.104:8000";
167-
std::string targetUrl = std::string(repoUrl+"/directory.yaml");
168-
FileDownloader::getFile(targetUrl, fileContents);
169-
std::istringstream f(fileContents);
170-
171-
while (true)
172-
{
173-
std::string shortname;
174-
175-
if (!std::getline(f, shortname)) break;
176-
shortname = shortname.substr(5);
177-
std::string name;
178-
std::getline(f, name);
179-
name = name.substr(2);
180-
std::string author;
181-
std::getline(f, author);
182-
author = author.substr(2);
183-
std::string desc;
184-
std::getline(f, desc);
185-
desc = desc.substr(2);
186-
std::string binary;
187-
std::getline(f, binary);
188-
binary = binary.substr(2);
189-
190-
int idx = homebrewButtons.size();
191-
homebrewButtons.resize(homebrewButtons.size() + 1);
192-
193-
// file path
194-
homebrewButtons[idx].execPath = "";
195-
homebrewButtons[idx].iconImgData = NULL;
196-
197-
std::string homebrewPath = homebrewButtons[idx].execPath;
198-
size_t slashPos = homebrewPath.rfind('/');
199-
if(slashPos != std::string::npos)
200-
homebrewPath.erase(slashPos);
201-
202-
u8 * iconData = NULL;
203-
u32 iconDataSize = 0;
204-
205-
homebrewButtons[idx].dirPath = homebrewPath;
206-
207-
// since we got this app from the net, mark it as a GET
208-
homebrewButtons[idx].status = GET;
209-
homebrewButtons[idx].shortname = shortname;
210-
homebrewButtons[idx].binary = binary;
211-
212-
// download app icon
213-
std::string targetIcon;
214-
std::string targetIconUrl = std::string(repoUrl+"/apps/" + shortname + "/icon.png");
215-
FileDownloader::getFile(targetIconUrl, targetIcon);
216-
217-
homebrewButtons[idx].iconImgData = new GuiImageData((u8*)targetIcon.c_str(), targetIcon.size());
218-
219-
const char *cpName = name.c_str();
220-
const char *cpDescription = desc.c_str();
221-
222-
if(strncmp(cpName, "sd:/wiiu/apps/", strlen("sd:/wiiu/apps/")) == 0)
223-
cpName += strlen("sd:/wiiu/apps/");
224-
225-
homebrewButtons[idx].nameLabel = new GuiText(cpName, 28, glm::vec4(0, 0, 0, 1));
226-
homebrewButtons[idx].descriptionLabel = new GuiText(author.c_str(), 28, glm::vec4(0, 0, 0, 1));
227-
homebrewButtons[idx].button = new GuiButton(installedButtonImgData->getWidth(), installedButtonImgData->getHeight());
228-
homebrewButtons[idx].image = new GuiImage(appButtonImages[homebrewButtons[idx].status]);
229-
230-
positionHomebrewButton(&homebrewButtons[idx], idx);
231-
232-
append(homebrewButtons[idx].button);
233-
}
144+
// download app list from the repo
145+
std::string fileContents;
146+
std::string repoUrl = "http://192.168.1.104:8000";
147+
std::string targetUrl = std::string(repoUrl+"/directory.yaml");
148+
FileDownloader::getFile(targetUrl, fileContents);
149+
std::istringstream f(fileContents);
150+
151+
while (true)
152+
{
153+
std::string shortname;
154+
155+
if (!std::getline(f, shortname)) break;
156+
shortname = shortname.substr(5);
157+
std::string name;
158+
std::getline(f, name);
159+
name = name.substr(2);
160+
std::string author;
161+
std::getline(f, author);
162+
author = author.substr(2);
163+
std::string desc;
164+
std::getline(f, desc);
165+
desc = desc.substr(2);
166+
std::string binary;
167+
std::getline(f, binary);
168+
binary = binary.substr(2);
234169

170+
int idx = homebrewButtons.size();
171+
homebrewButtons.resize(homebrewButtons.size() + 1);
172+
173+
// file path
174+
homebrewButtons[idx].execPath = "";
175+
homebrewButtons[idx].iconImgData = NULL;
176+
177+
std::string homebrewPath = homebrewButtons[idx].execPath;
178+
size_t slashPos = homebrewPath.rfind('/');
179+
if(slashPos != std::string::npos)
180+
homebrewPath.erase(slashPos);
181+
182+
u8 * iconData = NULL;
183+
u32 iconDataSize = 0;
235184

185+
homebrewButtons[idx].dirPath = homebrewPath;
186+
187+
// since we got this app from the net, mark it as a GET
188+
homebrewButtons[idx].status = GET;
189+
homebrewButtons[idx].shortname = shortname;
190+
homebrewButtons[idx].binary = binary;
191+
192+
// download app icon
193+
std::string targetIcon;
194+
std::string targetIconUrl = std::string(repoUrl+"/apps/" + shortname + "/icon.png");
195+
FileDownloader::getFile(targetIconUrl, targetIcon);
196+
197+
homebrewButtons[idx].iconImgData = new GuiImageData((u8*)targetIcon.c_str(), targetIcon.size());
198+
199+
const char *cpName = name.c_str();
200+
const char *cpDescription = desc.c_str();
201+
202+
if(strncmp(cpName, "sd:/wiiu/apps/", strlen("sd:/wiiu/apps/")) == 0)
203+
cpName += strlen("sd:/wiiu/apps/");
204+
205+
homebrewButtons[idx].nameLabel = new GuiText(cpName, 28, glm::vec4(0, 0, 0, 1));
206+
homebrewButtons[idx].descriptionLabel = new GuiText(author.c_str(), 28, glm::vec4(0, 0, 0, 1));
207+
homebrewButtons[idx].button = new GuiButton(installedButtonImgData->getWidth(), installedButtonImgData->getHeight());
208+
homebrewButtons[idx].image = new GuiImage(appButtonImages[homebrewButtons[idx].status]);
209+
210+
positionHomebrewButton(&homebrewButtons[idx], idx);
211+
212+
append(homebrewButtons[idx].button);
213+
}
214+
}
215+
216+
HomebrewWindow::HomebrewWindow(int w, int h)
217+
: GuiFrame(w, h)
218+
, buttonClickSound(Resources::GetSound("button_click.mp3"))
219+
, installedButtonImgData(Resources::GetImageData("INSTALLED.png"))
220+
, getButtonImgData(Resources::GetImageData("GET.png"))
221+
, updateButtonImgData(Resources::GetImageData("UPDATE.png"))
222+
, localButtonImgData(Resources::GetImageData("LOCAL.png"))
223+
, arrowRightImageData(Resources::GetImageData("rightArrow.png"))
224+
, arrowLeftImageData(Resources::GetImageData("leftArrow.png"))
225+
, arrowRightImage(arrowRightImageData)
226+
, arrowLeftImage(arrowLeftImageData)
227+
, arrowRightButton(arrowRightImage.getWidth(), arrowRightImage.getHeight())
228+
, arrowLeftButton(arrowLeftImage.getWidth(), arrowLeftImage.getHeight())
229+
, hblVersionText("Homebrew App Store by VGMoose, Music by (T-T)b (google t tb bandcamp)", 32, glm::vec4(1.0f))
230+
, touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH)
231+
, wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A)
232+
, buttonLTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_L | GuiTrigger::BUTTON_LEFT, true)
233+
, buttonRTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_R | GuiTrigger::BUTTON_RIGHT, true)
234+
{
235+
// tcpReceiver.serverReceiveStart.connect(this, &HomebrewWindow::OnTcpReceiveStart);
236+
// tcpReceiver.serverReceiveFinished.connect(this, &HomebrewWindow::OnTcpReceiveFinish);
237+
238+
targetLeftPosition = 0;
239+
currentLeftPosition = 0;
240+
listOffset = 0;
241+
242+
refreshHomebrewApps();
243+
236244
hblVersionText.setAlignment(ALIGN_BOTTOM | ALIGN_RIGHT);
237245
hblVersionText.setPosition(0, 0);
238246
append(&hblVersionText);
@@ -294,7 +302,7 @@ void HomebrewWindow::OnHomebrewButtonClick(GuiButton *button, const GuiControlle
294302
{
295303
if(button == homebrewButtons[i].button)
296304
{
297-
HomebrewLaunchWindow * launchBox = new HomebrewLaunchWindow(homebrewButtons[i]);
305+
HomebrewLaunchWindow * launchBox = new HomebrewLaunchWindow(homebrewButtons[i], this);
298306
launchBox->setEffect(EFFECT_FADE, 10, 255);
299307
launchBox->setState(GuiElement::STATE_DISABLED);
300308
launchBox->setPosition(0.0f, 30.0f);

src/menu/HomebrewWindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class HomebrewWindow : public GuiFrame, public sigslot::has_slots<>
4848
std::vector<homebrewButton> homebrewButtons;
4949

5050
void positionHomebrewButton(homebrewButton*, int);
51+
void refreshHomebrewApps();
5152

5253
private:
5354
void OnOpenEffectFinish(GuiElement *element);

0 commit comments

Comments
 (0)