diff --git a/source/common.cpp b/source/common.cpp index 376328b..9ddfcbf 100644 --- a/source/common.cpp +++ b/source/common.cpp @@ -318,11 +318,11 @@ void screen_fill(int x, int y, int width, int height, u8 r, u8 g, u8 b) { } } -int screen_get_str_width(std::string str) { +int screen_get_str_width(const std::string str) { return str.length() * 8; } -int screen_get_str_height(std::string str) { +int screen_get_str_height(const std::string str) { return 8; } @@ -342,7 +342,7 @@ void screen_draw_char(char c, int x, int y, u8 r, u8 g, u8 b) { } } -void screen_draw_string(std::string str, int x, int y, u8 r, u8 g, u8 b) { +void screen_draw_string(const std::string str, int x, int y, u8 r, u8 g, u8 b) { if(fb == NULL) { return; } @@ -469,7 +469,7 @@ SelectionResult ui_select(std::vector elements, SelectableEle return APP_CLOSING; } -bool ui_is_directory(std::string path) { +bool ui_is_directory(const std::string path) { DIR *dir = opendir(path.c_str()); if(!dir) { return false; @@ -485,7 +485,7 @@ struct ui_alphabetize { } }; -std::vector ui_get_dir_elements(std::string directory, std::string extension) { +std::vector ui_get_dir_elements(const std::string directory, const std::string extension) { std::vector elements; elements.push_back({".", "."}); elements.push_back({"..", ".."}); @@ -498,8 +498,8 @@ std::vector ui_get_dir_elements(std::string directory, std::s break; } - std::string dirName = std::string(ent->d_name); - std::string path = directory + "/" + dirName; + const std::string dirName = std::string(ent->d_name); + const std::string path = directory + "/" + dirName; if(ui_is_directory(path)) { elements.push_back({path, dirName}); } else { @@ -524,7 +524,7 @@ std::vector ui_get_dir_elements(std::string directory, std::s return elements; } -bool ui_select_file(std::string rootDirectory, std::string extension, std::string* selectedFile, std::function onLoop) { +bool ui_select_file(const std::string rootDirectory, const std::string extension, std::string* selectedFile, std::function onLoop) { std::stack directoryStack; std::string currDirectory = rootDirectory; while(platform_is_running()) { @@ -691,7 +691,7 @@ AppCategory app_category_from_id(u16 id) { return APP; } -std::string app_get_platform_name(AppPlatform platform) { +const std::string app_get_platform_name(AppPlatform platform) { switch(platform) { case WII: return "Wii"; @@ -706,7 +706,7 @@ std::string app_get_platform_name(AppPlatform platform) { } } -std::string app_get_category_name(AppCategory category) { +const std::string app_get_category_name(AppCategory category) { switch(category) { case APP: return "App"; @@ -759,7 +759,7 @@ std::vector app_list(MediaType mediaType) { return titles; } -bool app_install(MediaType mediaType, std::string path, std::function onProgress) { +bool app_install(MediaType mediaType, const std::string path, std::function onProgress) { if(!am_prepare()) { return false; } diff --git a/source/common.hpp b/source/common.hpp index f453f4a..f0a48ca 100644 --- a/source/common.hpp +++ b/source/common.hpp @@ -100,12 +100,12 @@ int screen_get_width(); int screen_get_height(); void screen_draw(int x, int y, u8 r, u8 g, u8 b); void screen_fill(int x, int y, int width, int height, u8 r, u8 g, u8 b); -int screen_get_str_width(std::string str); -int screen_get_str_height(std::string str); -void screen_draw_string(std::string str, int x, int y, u8 r, u8 g, u8 b); +int screen_get_str_width(const std::string str); +int screen_get_str_height(const std::string str); +void screen_draw_string(const std::string str, int x, int y, u8 r, u8 g, u8 b); void screen_clear(u8 r, u8 g, u8 b); -bool ui_select_file(std::string rootDirectory, std::string extension, std::string* selectedFile, std::function onLoop); +bool ui_select_file(const std::string rootDirectory, const std::string extension, std::string* selectedFile, std::function onLoop); bool ui_select_app(MediaType mediaType, App* selectedApp, std::function onLoop); void input_poll(); @@ -114,10 +114,10 @@ bool input_is_pressed(Button button); bool input_is_held(Button button); Touch input_get_touch(); -std::string app_get_platform_name(AppPlatform platform); -std::string app_get_category_name(AppCategory category); +const std::string app_get_platform_name(AppPlatform platform); +const std::string app_get_category_name(AppCategory category); std::vector app_list(MediaType mediaType); -bool app_install(MediaType mediaType, std::string path, std::function onProgress); +bool app_install(MediaType mediaType, const std::string path, std::function onProgress); bool app_delete(App app); bool app_launch(App app);