Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added code to display the sizes of homebrew. #73

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Views/HomebrewView/homebrewView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include <psp2/io/fcntl.h>
#include <psp2/io/stat.h>
#include <vitaPackage.h>
#include <sstream>
#include <cmath>



extern unsigned char _binary_assets_spr_img_preview_infobg_png_start;
extern unsigned char _binary_assets_spr_img_preview_btn_download_png_start;
Expand Down Expand Up @@ -207,6 +211,16 @@ void HomebrewView::startYoutube() const
0x20000, (std::string("webmodal: https://www.youtube.com/embed/") + hb_.trailer + "?autoplay=1").c_str());
}

std::string HomebrewView::sizeRoundAndString(int sizeinbytes){
double i = 0.000001*sizeinbytes;
i = round( i * 100.0 ) / 100.0;
std::string sizevalueinmb;
std::stringstream ss;
ss << i;
sizevalueinmb = ss.str() + "MB";
return sizevalueinmb;
}

int HomebrewView::Display()
{
bg.Display();
Expand All @@ -217,7 +231,7 @@ int HomebrewView::Display()
font_40.Draw(Point(HB_X + 225, HB_Y + 88), hb_.name, COLOR_WHITE);
font_25.Draw(Point(HB_X + 225, HB_Y + 115), hb_.author, COLOR_AQUA);
font_25.Draw(Point(HB_X + 225, HB_Y + 144), hb_.version, COLOR_WHITE);
// font_20.Draw(Point(HB_X + 100, HB_Y + 189), std::string("0 Kb"), COLOR_WHITE);
font_20.Draw(Point(HB_X + 100, HB_Y + 200), sizeRoundAndString(hb_.size+hb_.datasize), COLOR_WHITE);
// font_20.Draw(Point(HB_X + 850, HB_Y + 503), hb_.date.str, COLOR_WHITE);

font_25.Draw(Point(HB_X + 40, HB_Y + 362), description);
Expand Down
1 change: 1 addition & 0 deletions src/Views/HomebrewView/homebrewView.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ class HomebrewView : public View
void checkInstalled();
void homebrewInstall();
void startYoutube() const;
std::string sizeRoundAndString(int);
};
3 changes: 2 additions & 1 deletion src/homebrew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ namespace YAML
hb.url = node["url"].as<std::string>();
if (node["data"])
hb.data = node["data"].as<std::string>();

hb.size = node["size"].as<int>();
hb.datasize = node["data_size"].as<int>();
return true;
}
}; // namespace YAML
2 changes: 2 additions & 0 deletions src/homebrew.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class Homebrew {
std::vector<std::string> screenshots;
std::string url;
std::string data;
int size;
int datasize;

bool IsInstalled();
};
Expand Down