gui: Display text icon for config, log and text files

This commit is contained in:
Joel16 2020-08-04 20:39:03 -04:00
parent cb00f6a20f
commit 74bea573fa
5 changed files with 45 additions and 25 deletions

View File

@ -10,7 +10,7 @@ typedef struct {
int height = 0;
} Tex;
extern Tex folder_texture, file_texture, archive_texture, audio_texture, image_texture, check_texture, uncheck_texture;
extern Tex folder_icon, file_icon, archive_icon, audio_icon, image_icon, text_icon, check_icon, uncheck_icon;
namespace Textures {
bool LoadImageFile(const std::string &path, Tex *texture);

BIN
romfs/text.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

@ -60,6 +60,8 @@ namespace FS {
else if ((!ext.compare(".BMP")) || (!ext.compare(".GIF")) || (!ext.compare(".JPG")) || (!ext.compare(".JPEG")) || (!ext.compare(".PGM"))
|| (!ext.compare(".PPM")) || (!ext.compare(".PNG")) || (!ext.compare(".PSD")) || (!ext.compare(".TGA")))
return FileTypeImage;
else if ((!ext.compare(".JSON")) || (!ext.compare(".LOG")) || (!ext.compare(".TXT")) || (!ext.compare(".CFG")) || (!ext.compare(".INI")))
return FileTypeText;
return FileTypeNone;
}

View File

@ -396,24 +396,36 @@ namespace GUI {
std::string filename = item.entries[i].name;
if ((item.checked.at(i)) && (!item.checked_cwd.compare(config.cwd)))
ImGui::Image((void *)(intptr_t)check_texture.id, ImVec2(check_texture.width, check_texture.height));
ImGui::Image((void *)(intptr_t)check_icon.id, ImVec2(check_icon.width, check_icon.height));
else
ImGui::Image((void *)(intptr_t)uncheck_texture.id, ImVec2(uncheck_texture.width, uncheck_texture.height));
ImGui::Image((void *)(intptr_t)uncheck_icon.id, ImVec2(uncheck_icon.width, uncheck_icon.height));
ImGui::SameLine();
if (item.entries[i].type == FsDirEntryType_Dir)
ImGui::Image((void *)(intptr_t)folder_texture.id, ImVec2(folder_texture.width, folder_texture.height));
ImGui::Image((void *)(intptr_t)folder_icon.id, ImVec2(folder_icon.width, folder_icon.height));
else {
FileType file_type = FS::GetFileType(filename);
switch(file_type) {
case FileTypeArchive:
ImGui::Image((void *)(intptr_t)archive_icon.id, ImVec2(archive_icon.width, archive_icon.height));
break;
if (file_type == FileTypeArchive)
ImGui::Image((void *)(intptr_t)archive_texture.id, ImVec2(archive_texture.width, archive_texture.height));
else if (file_type == FileTypeAudio)
ImGui::Image((void *)(intptr_t)audio_texture.id, ImVec2(audio_texture.width, audio_texture.height));
else if (file_type == FileTypeImage)
ImGui::Image((void *)(intptr_t)image_texture.id, ImVec2(image_texture.width, image_texture.height));
else
ImGui::Image((void *)(intptr_t)file_texture.id, ImVec2(file_texture.width, file_texture.height));
case FileTypeAudio:
ImGui::Image((void *)(intptr_t)audio_icon.id, ImVec2(audio_icon.width, audio_icon.height));
break;
case FileTypeImage:
ImGui::Image((void *)(intptr_t)image_icon.id, ImVec2(image_icon.width, image_icon.height));
break;
case FileTypeText:
ImGui::Image((void *)(intptr_t)text_icon.id, ImVec2(text_icon.width, text_icon.height));
break;
default:
ImGui::Image((void *)(intptr_t)file_icon.id, ImVec2(file_icon.width, file_icon.height));
break;
}
}
ImGui::SameLine();

View File

@ -19,7 +19,7 @@
#include "imgui.h"
#include "textures.h"
Tex folder_texture, file_texture, archive_texture, audio_texture, image_texture, check_texture, uncheck_texture;
Tex folder_icon, file_icon, archive_icon, audio_icon, image_icon, text_icon, check_icon, uncheck_icon;
namespace Textures {
static bool LoadImage(unsigned char *data, int *width, int *height, GLint format, Tex *texture, void (*free_func)(void *)) {
@ -54,25 +54,28 @@ namespace Textures {
}
void Init(void) {
bool image_ret = Textures::LoadImageFile("romfs:/archive.png", &archive_texture);
bool image_ret = Textures::LoadImageFile("romfs:/archive.png", &archive_icon);
IM_ASSERT(image_ret);
image_ret = Textures::LoadImageFile("romfs:/audio.png", &audio_texture);
image_ret = Textures::LoadImageFile("romfs:/audio.png", &audio_icon);
IM_ASSERT(image_ret);
image_ret = Textures::LoadImageFile("romfs:/file.png", &file_texture);
image_ret = Textures::LoadImageFile("romfs:/file.png", &file_icon);
IM_ASSERT(image_ret);
image_ret = Textures::LoadImageFile("romfs:/folder.png", &folder_texture);
image_ret = Textures::LoadImageFile("romfs:/folder.png", &folder_icon);
IM_ASSERT(image_ret);
image_ret = Textures::LoadImageFile("romfs:/image.png", &image_texture);
image_ret = Textures::LoadImageFile("romfs:/image.png", &image_icon);
IM_ASSERT(image_ret);
image_ret = Textures::LoadImageFile("romfs:/check.png", &check_texture);
image_ret = Textures::LoadImageFile("romfs:/text.png", &text_icon);
IM_ASSERT(image_ret);
image_ret = Textures::LoadImageFile("romfs:/uncheck.png", &uncheck_texture);
image_ret = Textures::LoadImageFile("romfs:/check.png", &check_icon);
IM_ASSERT(image_ret);
image_ret = Textures::LoadImageFile("romfs:/uncheck.png", &uncheck_icon);
IM_ASSERT(image_ret);
}
@ -81,10 +84,13 @@ namespace Textures {
}
void Exit(void) {
glDeleteTextures(1, &image_texture.id);
glDeleteTextures(1, &folder_texture.id);
glDeleteTextures(1, &file_texture.id);
glDeleteTextures(1, &audio_texture.id);
glDeleteTextures(1, &archive_texture.id);
glDeleteTextures(1, &uncheck_icon.id);
glDeleteTextures(1, &check_icon.id);
glDeleteTextures(1, &text_icon.id);
glDeleteTextures(1, &image_icon.id);
glDeleteTextures(1, &folder_icon.id);
glDeleteTextures(1, &file_icon.id);
glDeleteTextures(1, &audio_icon.id);
glDeleteTextures(1, &archive_icon.id);
}
}