Skip to content

Commit d6f0339

Browse files
committed
download icon and xml as well
initial file deletion code
1 parent 9e1708d commit d6f0339

File tree

6 files changed

+56
-21
lines changed

6 files changed

+56
-21
lines changed

hbas.elf

4.81 KB
Binary file not shown.

hbas_dbg.elf

5.05 KB
Binary file not shown.

src/menu/HomebrewLaunchWindow.cpp

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

26-
HomebrewLaunchWindow::HomebrewLaunchWindow(const std::string & launchPath, GuiImageData * iconImgData, std::string & shortname)
26+
HomebrewLaunchWindow::HomebrewLaunchWindow(homebrewButton & thisButton)
2727
: GuiFrame(0, 0)
2828
, buttonClickSound(Resources::GetSound("button_click.mp3"))
2929
, backgroundImgData(Resources::GetImageData("launchMenuBox.png"))
3030
, backgroundImg(backgroundImgData)
3131
, buttonImgData(Resources::GetImageData("button.png"))
32-
, iconImage(iconImgData)
32+
, iconImage(thisButton.iconImgData)
3333
, titleText((char*)NULL, 42, glm::vec4(0,0,0, 1))
3434
, versionText("Version:", 32, glm::vec4(0,0,0, 1))
3535
, versionValueText((char*)NULL, 32, glm::vec4(0,0,0, 1))
3636
, authorText("Author:", 32, glm::vec4(0,0,0, 1))
3737
, authorValueText((char*)NULL, 32, glm::vec4(0,0,0, 1))
3838
, descriptionText((char*)NULL, 28, glm::vec4(0,0,0, 1))
3939
, loadBtnLabel("Download", 32, glm::vec4(1.0f))
40+
, delBtnLabel("Delete", 32, glm::vec4(1.0f))
4041
, loadImg(buttonImgData)
42+
, delImg(buttonImgData)
4143
, loadBtn(loadImg.getWidth(), loadImg.getHeight())
44+
, delBtn(loadImg.getWidth(), loadImg.getHeight())
4245
, backBtnLabel("Close", 32, glm::vec4(1.0f))
4346
, backImg(buttonImgData)
4447
, backBtn(backImg.getWidth(), backImg.getHeight())
4548
, touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH)
4649
, wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A)
47-
, homebrewLaunchPath(launchPath)
48-
, homebrewLaunchName(shortname)
50+
, selectedButton(thisButton)
4951
{
5052
width = backgroundImg.getWidth();
5153
height = backgroundImg.getHeight();
5254
append(&backgroundImg);
5355

56+
std::string launchPath = selectedButton.execPath;
5457
std::string homebrewPath = launchPath;
5558
size_t slashPos = homebrewPath.rfind('/');
5659
if(slashPos != std::string::npos)
@@ -121,6 +124,19 @@ HomebrewLaunchWindow::HomebrewLaunchWindow(const std::string & launchPath, GuiIm
121124
loadBtn.setSoundClick(buttonClickSound);
122125
loadBtn.clicked.connect(this, &HomebrewLaunchWindow::OnLoadButtonClick);
123126
append(&loadBtn);
127+
128+
delImg.setScale(scaleFactor);
129+
delBtn.setSize(scaleFactor * loadImg.getWidth(), scaleFactor * delImg.getHeight());
130+
delBtn.setImage(&delImg);
131+
delBtn.setLabel(&delBtnLabel);
132+
delBtn.setAlignment(ALIGN_CENTER | ALIGN_MIDDLE);
133+
delBtn.setPosition(-200, -310);
134+
delBtn.setTrigger(&touchTrigger);
135+
delBtn.setTrigger(&wpadTouchTrigger);
136+
delBtn.setEffectGrow();
137+
delBtn.setSoundClick(buttonClickSound);
138+
delBtn.clicked.connect(this, &HomebrewLaunchWindow::OnDeleteButtonClick);
139+
// append(&delBtn);
124140

125141
backImg.setScale(scaleFactor);
126142
backBtn.setSize(scaleFactor * backImg.getWidth(), scaleFactor * backImg.getHeight());
@@ -177,13 +193,25 @@ void HomebrewLaunchWindow::OnFileLoadFinish(GuiElement *element, const std::stri
177193
}
178194
}
179195

196+
void HomebrewLaunchWindow::OnDeleteButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger)
197+
{
198+
std::string path = "/apps/"+selectedButton.shortname+"/"+selectedButton.binary;
199+
std::string sdPath = "sd:/wiiu"+path;
200+
rename("sdPath", "sd:/.Trashes/oiuwroiuewr");
201+
}
180202

181203
void HomebrewLaunchWindow::OnLoadButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger)
182204
{
183-
backBtn.setState(GuiElement::STATE_DISABLED);
205+
// backBtn.setState(GuiElement::STATE_DISABLED);
206+
delBtn.setState(GuiElement::STATE_DISABLED);
184207
loadBtn.setState(GuiElement::STATE_DISABLED);
185208

186-
FileDownloader::getFile("http://wiiubru.com/appstore/apps/"+homebrewLaunchName+"/boot.elf", "sd:/wiiu/apps/"+homebrewLaunchName+"/boot.elf", 0);
209+
std::string path = "/apps/"+selectedButton.shortname;
210+
std::string sdPath = "sd:/wiiu"+path;
211+
CreateSubfolder(sdPath.c_str());
212+
FileDownloader::getFile("http://wiiubru.com/appstore"+path+"/"+selectedButton.binary, sdPath+"/"+selectedButton.binary, 0);
213+
FileDownloader::getFile("http://wiiubru.com/appstore"+path+"/meta.xml", sdPath+"/meta.xml", 0);
214+
FileDownloader::getFile("http://wiiubru.com/appstore"+path+"/icon.png", sdPath+"/icon.png", 0);
187215

188216

189217
// struct SYSBrowserArgsIn args = {};

src/menu/HomebrewLaunchWindow.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919

2020
#include "gui/Gui.h"
2121
#include "gui/GuiFrame.h"
22+
#include "menu/HomebrewWindow.h"
2223

2324
class HomebrewLaunchWindow : public GuiFrame, public sigslot::has_slots<>
2425
{
2526
public:
26-
HomebrewLaunchWindow(const std::string & launchPath, GuiImageData * iconImgData, std::string & shortname);
27+
HomebrewLaunchWindow(homebrewButton & thisButton);
2728
virtual ~HomebrewLaunchWindow();
2829

2930

@@ -35,6 +36,7 @@ class HomebrewLaunchWindow : public GuiFrame, public sigslot::has_slots<>
3536
}
3637

3738
void OnLoadButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
39+
void OnDeleteButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
3840

3941
void OnFileLoadFinish(GuiElement *element, const std::string & filepath, int result);
4042
void OnOpenEffectFinish(GuiElement *element);
@@ -55,8 +57,11 @@ class HomebrewLaunchWindow : public GuiFrame, public sigslot::has_slots<>
5557
GuiText descriptionText;
5658

5759
GuiText loadBtnLabel;
60+
GuiText delBtnLabel;
61+
GuiImage delImg;
5862
GuiImage loadImg;
5963
GuiButton loadBtn;
64+
GuiButton delBtn;
6065

6166
GuiText backBtnLabel;
6267
GuiImage backImg;
@@ -65,8 +70,7 @@ class HomebrewLaunchWindow : public GuiFrame, public sigslot::has_slots<>
6570
GuiTrigger touchTrigger;
6671
GuiTrigger wpadTouchTrigger;
6772

68-
const std::string homebrewLaunchPath;
69-
const std::string homebrewLaunchName;
73+
homebrewButton selectedButton;
7074
};
7175

7276
#endif //_HOMEBREW_LAUNCHER_WINDOW_H_

src/menu/HomebrewWindow.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ HomebrewWindow::HomebrewWindow(int w, int h)
218218
// update or installed
219219
homebrewButtons[idx].status = GET;
220220
homebrewButtons[idx].shortname = shortname;
221+
homebrewButtons[idx].binary = binary;
221222
// download app list from wiiubru
222223
std::string targetIcon;
223224
std::string targetIconUrl = std::string("http://wiiubru.com/appstore/apps/" + shortname + "/icon.png");
@@ -370,7 +371,7 @@ void HomebrewWindow::OnHomebrewButtonClick(GuiButton *button, const GuiControlle
370371
{
371372
if(button == homebrewButtons[i].button)
372373
{
373-
HomebrewLaunchWindow * launchBox = new HomebrewLaunchWindow(homebrewButtons[i].execPath, homebrewButtons[i].iconImgData, homebrewButtons[i].shortname);
374+
HomebrewLaunchWindow * launchBox = new HomebrewLaunchWindow(homebrewButtons[i]);
374375
launchBox->setEffect(EFFECT_FADE, 10, 255);
375376
launchBox->setState(GuiElement::STATE_DISABLED);
376377
launchBox->setPosition(0.0f, 30.0f);

src/menu/HomebrewWindow.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,7 @@
2020
#include "gui/Gui.h"
2121
#include "gui/GuiFrame.h"
2222

23-
class HomebrewWindow : public GuiFrame, public sigslot::has_slots<>
24-
{
25-
public:
26-
HomebrewWindow(int w, int h);
27-
virtual ~HomebrewWindow();
28-
static void do_download(CThread *thread, void *arg);
29-
30-
void draw(CVideo *pVideo);
31-
float scrollOffY = 0;
32-
float lastScrollOffY = 0;
33-
typedef struct
23+
typedef struct
3424
{
3525
std::string execPath;
3626
GuiImage *image;
@@ -42,7 +32,19 @@ class HomebrewWindow : public GuiFrame, public sigslot::has_slots<>
4232
std::string shortname;
4333
int status;
4434
std::string dirPath;
35+
std::string binary;
4536
} homebrewButton;
37+
38+
class HomebrewWindow : public GuiFrame, public sigslot::has_slots<>
39+
{
40+
public:
41+
HomebrewWindow(int w, int h);
42+
virtual ~HomebrewWindow();
43+
static void do_download(CThread *thread, void *arg);
44+
45+
void draw(CVideo *pVideo);
46+
float scrollOffY = 0;
47+
float lastScrollOffY = 0;
4648
std::vector<homebrewButton> homebrewButtons;
4749

4850
private:

0 commit comments

Comments
 (0)