|
26 | 26 | #include <thread> |
27 | 27 | #include <sstream> |
28 | 28 |
|
29 | | - |
30 | | - |
31 | 29 | #define DEFAULT_WIILOAD_PORT 4299 |
32 | 30 |
|
33 | 31 | #define MAX_BUTTONS_ON_PAGE 4 |
@@ -71,36 +69,18 @@ void HomebrewWindow::positionHomebrewButton(homebrewButton* button, int index) |
71 | 69 | button->button->clicked.connect(this, &HomebrewWindow::OnHomebrewButtonClick); |
72 | 70 | } |
73 | 71 |
|
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() |
92 | 73 | { |
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 | | - |
100 | 74 | GuiImageData* appButtonImages[4] = { localButtonImgData, updateButtonImgData, installedButtonImgData, getButtonImgData }; |
101 | 75 |
|
102 | 76 | DirList dirList("sd:/wiiu/apps", ".elf", DirList::Files | DirList::CheckSubfolders); |
103 | 77 |
|
| 78 | + for (int x=0; x<homebrewButtons.size(); x++) |
| 79 | + { |
| 80 | + removeE(homebrewButtons[x].button); |
| 81 | + } |
| 82 | + |
| 83 | + homebrewButtons.clear(); |
104 | 84 | dirList.SortList(); |
105 | 85 |
|
106 | 86 | // load up local apps |
@@ -161,78 +141,106 @@ HomebrewWindow::HomebrewWindow(int w, int h) |
161 | 141 | append(homebrewButtons[idx].button); |
162 | 142 | } |
163 | 143 |
|
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); |
234 | 169 |
|
| 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; |
235 | 184 |
|
| 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 | + |
236 | 244 | hblVersionText.setAlignment(ALIGN_BOTTOM | ALIGN_RIGHT); |
237 | 245 | hblVersionText.setPosition(0, 0); |
238 | 246 | append(&hblVersionText); |
@@ -294,7 +302,7 @@ void HomebrewWindow::OnHomebrewButtonClick(GuiButton *button, const GuiControlle |
294 | 302 | { |
295 | 303 | if(button == homebrewButtons[i].button) |
296 | 304 | { |
297 | | - HomebrewLaunchWindow * launchBox = new HomebrewLaunchWindow(homebrewButtons[i]); |
| 305 | + HomebrewLaunchWindow * launchBox = new HomebrewLaunchWindow(homebrewButtons[i], this); |
298 | 306 | launchBox->setEffect(EFFECT_FADE, 10, 255); |
299 | 307 | launchBox->setState(GuiElement::STATE_DISABLED); |
300 | 308 | launchBox->setPosition(0.0f, 30.0f); |
|
0 commit comments