mirror of
https://gitlab.com/Theopse/fbi-i18n-zh.git
synced 2025-05-10 01:58:58 +08:00
Use const with strings more often.
This commit is contained in:
parent
c5400874cf
commit
7f5f4d5ef8
@ -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;
|
return str.length() * 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
int screen_get_str_height(std::string str) {
|
int screen_get_str_height(const std::string str) {
|
||||||
return 8;
|
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) {
|
if(fb == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -469,7 +469,7 @@ SelectionResult ui_select(std::vector<SelectableElement> elements, SelectableEle
|
|||||||
return APP_CLOSING;
|
return APP_CLOSING;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ui_is_directory(std::string path) {
|
bool ui_is_directory(const std::string path) {
|
||||||
DIR *dir = opendir(path.c_str());
|
DIR *dir = opendir(path.c_str());
|
||||||
if(!dir) {
|
if(!dir) {
|
||||||
return false;
|
return false;
|
||||||
@ -485,7 +485,7 @@ struct ui_alphabetize {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<SelectableElement> ui_get_dir_elements(std::string directory, std::string extension) {
|
std::vector<SelectableElement> ui_get_dir_elements(const std::string directory, const std::string extension) {
|
||||||
std::vector<SelectableElement> elements;
|
std::vector<SelectableElement> elements;
|
||||||
elements.push_back({".", "."});
|
elements.push_back({".", "."});
|
||||||
elements.push_back({"..", ".."});
|
elements.push_back({"..", ".."});
|
||||||
@ -498,8 +498,8 @@ std::vector<SelectableElement> ui_get_dir_elements(std::string directory, std::s
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string dirName = std::string(ent->d_name);
|
const std::string dirName = std::string(ent->d_name);
|
||||||
std::string path = directory + "/" + dirName;
|
const std::string path = directory + "/" + dirName;
|
||||||
if(ui_is_directory(path)) {
|
if(ui_is_directory(path)) {
|
||||||
elements.push_back({path, dirName});
|
elements.push_back({path, dirName});
|
||||||
} else {
|
} else {
|
||||||
@ -524,7 +524,7 @@ std::vector<SelectableElement> ui_get_dir_elements(std::string directory, std::s
|
|||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ui_select_file(std::string rootDirectory, std::string extension, std::string* selectedFile, std::function<bool()> onLoop) {
|
bool ui_select_file(const std::string rootDirectory, const std::string extension, std::string* selectedFile, std::function<bool()> onLoop) {
|
||||||
std::stack<std::string> directoryStack;
|
std::stack<std::string> directoryStack;
|
||||||
std::string currDirectory = rootDirectory;
|
std::string currDirectory = rootDirectory;
|
||||||
while(platform_is_running()) {
|
while(platform_is_running()) {
|
||||||
@ -691,7 +691,7 @@ AppCategory app_category_from_id(u16 id) {
|
|||||||
return APP;
|
return APP;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string app_get_platform_name(AppPlatform platform) {
|
const std::string app_get_platform_name(AppPlatform platform) {
|
||||||
switch(platform) {
|
switch(platform) {
|
||||||
case WII:
|
case WII:
|
||||||
return "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) {
|
switch(category) {
|
||||||
case APP:
|
case APP:
|
||||||
return "App";
|
return "App";
|
||||||
@ -759,7 +759,7 @@ std::vector<App> app_list(MediaType mediaType) {
|
|||||||
return titles;
|
return titles;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool app_install(MediaType mediaType, std::string path, std::function<bool(int)> onProgress) {
|
bool app_install(MediaType mediaType, const std::string path, std::function<bool(int)> onProgress) {
|
||||||
if(!am_prepare()) {
|
if(!am_prepare()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -100,12 +100,12 @@ int screen_get_width();
|
|||||||
int screen_get_height();
|
int screen_get_height();
|
||||||
void screen_draw(int x, int y, u8 r, u8 g, u8 b);
|
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);
|
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);
|
||||||
int screen_get_str_height(std::string str);
|
int screen_get_str_height(const std::string str);
|
||||||
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);
|
||||||
void screen_clear(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<bool()> onLoop);
|
bool ui_select_file(const std::string rootDirectory, const std::string extension, std::string* selectedFile, std::function<bool()> onLoop);
|
||||||
bool ui_select_app(MediaType mediaType, App* selectedApp, std::function<bool()> onLoop);
|
bool ui_select_app(MediaType mediaType, App* selectedApp, std::function<bool()> onLoop);
|
||||||
|
|
||||||
void input_poll();
|
void input_poll();
|
||||||
@ -114,10 +114,10 @@ bool input_is_pressed(Button button);
|
|||||||
bool input_is_held(Button button);
|
bool input_is_held(Button button);
|
||||||
Touch input_get_touch();
|
Touch input_get_touch();
|
||||||
|
|
||||||
std::string app_get_platform_name(AppPlatform platform);
|
const 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);
|
||||||
std::vector<App> app_list(MediaType mediaType);
|
std::vector<App> app_list(MediaType mediaType);
|
||||||
bool app_install(MediaType mediaType, std::string path, std::function<bool(int)> onProgress);
|
bool app_install(MediaType mediaType, const std::string path, std::function<bool(int)> onProgress);
|
||||||
bool app_delete(App app);
|
bool app_delete(App app);
|
||||||
bool app_launch(App app);
|
bool app_launch(App app);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user