Added scroll and some fixes to textures screen

This commit is contained in:
KiritoDev 2021-05-15 21:26:03 -05:00
parent 9c654cfe04
commit 4712f3b599
12 changed files with 289 additions and 50 deletions

View File

@ -67,6 +67,20 @@ static struct UnusedHUDStruct sUnusedHUDValues = { 0x00, 0x0A, 0x00 };
static struct CameraHUD sCameraHUD = { CAM_STATUS_NONE };
void render_hud_texture(s32 x, s32 y, u32 w, u32 h, u8 *texture) {
gSPDisplayList(gDisplayListHead++, dl_hud_img_begin);
gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_32b, 0, 0, G_TX_LOADTILE, 0, G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD);
gDPTileSync(gDisplayListHead++);
gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_32b, 2, 0, G_TX_RENDERTILE, 0, G_TX_NOMIRROR, 3, G_TX_NOLOD, G_TX_NOMIRROR, 3, G_TX_NOLOD);
gDPSetTileSize(gDisplayListHead++, G_TX_RENDERTILE, 0, 0, w << G_TEXTURE_IMAGE_FRAC, h << G_TEXTURE_IMAGE_FRAC);
gDPPipeSync(gDisplayListHead++);
gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_32b, 1, texture);
gDPLoadSync(gDisplayListHead++);
gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, w * h - 1, CALC_DXT(w, G_IM_SIZ_32b_BYTES));
gSPTextureRectangle(gDisplayListHead++, x << 2, y << 2, (x + w) << 2, (y + h) << 2, G_TX_RENDERTILE, 0, 0, 4 << 10, 1 << 10);
gSPDisplayList(gDisplayListHead++, dl_hud_img_end);
}
/**
* Renders a rgba16 16x16 glyph texture from a table list.
*/
@ -433,15 +447,15 @@ void render_nx_hud(void){
s16 h = y + 4;
struct Color color;
//color = { .r = 57, .g = 57, .b = 57, .a = 255 }
//moon_draw_rectangle(x - 1, y - 1, w + 1, h + 1, COLOR(57, 57, 57, 255));
//moon_draw_rectangle(x - 1, y - 1, w + 1, h + 1, COLOR(57, 57, 57, 255));
//moon_draw_rectangle(w, y, w + 2, y + 4, color);
//color = { .r = 57, .g = 57, .b = 57, .a = 255 }
//color = { .r = 57, .g = 57, .b = 57, .a = 255 }
//moon_draw_rectangle(x, y, w, h, COLOR(194, 194, 194, 255));
//color = { .r = 57, .g = 57, .b = 57, .a = 255 }
//moon_draw_rectangle(x, y, x + (s16)(12 * getBatteryPercentage()), h, COLOR(78, 235, 52, 255));
x = GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(20);
y = 207;
y = 207;
struct NXController controller;
@ -449,7 +463,7 @@ void render_nx_hud(void){
gSPDisplayList(gDisplayListHead++, dl_hud_img_begin);
render_hud_tex_lut(x, y, controller.icon);
gSPDisplayList(gDisplayListHead++, dl_hud_img_end);
gSPDisplayList(gDisplayListHead++, dl_hud_img_end);
}
#endif
@ -494,14 +508,14 @@ void render_hud(void) {
if (hudDisplayFlags & HUD_DISPLAY_FLAG_TIMER && configHUD) {
render_hud_timer();
}
if( configHUD ) {
#ifdef TARGET_SWITCH
if ( configSwitchHud )
render_nx_hud();
#endif
}
}
}

View File

@ -24,5 +24,6 @@ enum CameraHUDLut {
// Functions
void set_hud_camera_status(s16 status);
void render_hud(void);
void render_hud_texture(s32 x, s32 y, u32 w, u32 h, u8 *texture);
#endif // HUD_H

View File

@ -35,23 +35,20 @@ namespace Moon {
json j = json::parse(tjson);
if(j.contains("bit") && j["bit"].contains("name")){
BitModule* bit = new BitModule();
bit->name = j["bit"]["name"];
BitModule* bit = new BitModule({
.name = j["bit"]["name"],
.description = j["bit"].contains("icon") ? j["bit"]["description"] : "None",
.authors = j["bit"]["authors"],
.version = j["bit"]["version"],
.website = j["bit"].contains("website") ? j["bit"]["website"] : "None",
.icon = j["bit"].contains("icon") ? j["bit"]["icon"] : "None"
});
bit->description = j["bit"].contains("icon") ? j["bit"]["description"] : "None";
bit->author = j["bit"].contains("author") ? j["bit"]["author"] : "None";
bit->website = j["bit"].contains("website") ? j["bit"]["website"] : "None";
bit->icon = j["bit"].contains("icon") ? j["bit"]["icon"] : "None";
bit->main = j["bit"].contains("main") ? j["bit"]["main"] : "None";
bit->version = j["bit"]["version"];
if(j["bit"].contains("main")) bit->main = j["bit"]["main"];
bit->path = addonPath;
bit->readOnly = false;
if(file.exists(bit->main)){
std::cout << file.read(bit->main) << std::endl;
}
if(file.exists(bit->icon)){
vector<string> allowedTextures = {"png", "jpg", "jpeg"};
if(std::count(allowedTextures.begin(), allowedTextures.end(), string(get_filename_ext(bit->icon.c_str())))){

View File

@ -11,11 +11,10 @@ class zip_file;
extern "C" {
#include "pc/gfx/gfx_pc.h"
}
class BitModule{
public:
struct BitModule{
std::string name;
std::string description;
std::string author;
std::vector<std::string> authors;
double version;
std::string website;
std::string icon;

View File

@ -0,0 +1,171 @@
#ifndef Moon64LogoTexture
#define Moon64LogoTexture
static const struct {
unsigned int width;
unsigned int height;
unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
unsigned char pixel_data[32 * 32 * 4 + 1];
} moon64_logo = {
32, 32, 4,
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377*\031\071\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\"\031,\377\023\030."
"\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\"\031,\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377^\251\245\377+Yi\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377+Yi\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\016\020\037\377\016\020\037\377\016\020\037\377\016\020\037\377\016\020\037\377\016\020\037"
"\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\016"
"\020\037\377\371\340P\377\371\340P\377\371\340P\377\371\340P\377\371\340P\377"
"\016\020\037\377\016\020\037\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377*\031\071\377\023\030.\377\023\030.\377\023"
"\030.\377\016\020\037\377\371\340P\377\371\340P\377\371\340P\377\371\340P\377"
"\371\340P\377\371\340P\377\016\020\037\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\016\020\037\377\371\340P\377\371\340P\377\371\340P\377"
"\371\340P\377\371\340P\377\371\340P\377\016\020\037\377\023\030.\377\023\030.\377"
"M-<\377\023\030.\377\023\030.\377\023\030.\377*\071P\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377*\031\071\377"
"[.K\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\016\020\037\377\371\340P\377\371\340P\377\371\340P\377\371\340P"
"\377\371\340P\377\371\340P\377\371\340P\377\016\020\037\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"*\031\071\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\016\020\037\377\371\340P\377\016\020\037\377\371\340"
"P\377\016\020\037\377\371\340P\377\371\340P\377\016\020\037\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\016\020\037\377\371\340P\377\016\020\037\377\371\340"
"P\377\016\020\037\377\371\340P\377\371\340P\377\371\340P\377\016\020\037\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\016\020\037\377\371\340P\377\016\020\037\377\371"
"\340P\377\016\020\037\377\371\340P\377\371\340P\377\371\340P\377\016\020\037\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\016\020\037\377\371\340P\377\371\340P\377\371\340P\377"
"\371\340P\377\371\340P\377\371\340P\377\371\340P\377\371\340P\377\016\020\037"
"\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\016\020\037\377\016\020\037\377\371\340P\377\016\020\037\377\371\340P\377\371"
"\340P\377\371\340P\377\371\340P\377\016\020\037\377\371\340P\377\371\340P\377"
"\016\020\037\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\016\020\037\377\016\020\037"
"\377\016\020\037\377\371\340P\377\371\340P\377\371\340P\377\016\020\037\377\371"
"\340P\377\371\340P\377\371\340P\377\016\020\037\377\371\340P\377\371\340P\377"
"\016\020\037\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377*\071P\377\023\030.\377\016\020\037\377"
"\371\340P\377\371\340P\377\371\340P\377\371\340P\377\371\340P\377\371\340"
"P\377\016\020\037\377\016\020\037\377\016\020\037\377\371\340P\377\371\340P\377\371"
"\340P\377\016\020\037\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\016\020\037\377\371\340P\377\371\340P\377\371\340P\377\371\340P"
"\377\371\340P\377\371\340P\377\371\340P\377\371\340P\377\371\340P\377\371"
"\340P\377\016\020\037\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\016\020\037\377\371\340P\377\371\340P\377"
"\371\340P\377\371\340P\377\371\340P\377\371\340P\377\371\340P\377\371\340"
"P\377\016\020\037\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\016\020\037\377\016\020\037"
"\377\371\340P\377\371\340P\377\371\340P\377\371\340P\377\016\020\037\377\016"
"\020\037\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030."
"\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\016\020\037\377\016\020\037\377\016\020\037\377\016\020\037\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377M-<\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377*\031\071\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377*\031\071\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023"
"\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377"
"\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030.\377\023\030"
".\377\023\030.\377\023\030.\377",
};
#endif

View File

@ -1,6 +1,5 @@
#ifndef MissingTexture
#define MissingTexture
static const struct {
unsigned int width;
unsigned int height;

View File

@ -7,6 +7,7 @@
#include "modifiers/tmod.h"
#include "modifiers/animated.h"
#include "assets/missing.h"
#include "assets/logo.h"
#define STB_IMAGE_IMPLEMENTATION
#include <stb/stb_image.h>
@ -95,6 +96,11 @@ namespace MoonInternal {
int w, h;
u64 imgsize = 0;
if(!strcmp(fullpath, "gfx/mod-icons://Moon64.png")){
gfx_rapi->upload_texture(moon64_logo.pixel_data, moon64_logo.width, moon64_logo.height);
return;
}
TextureFileEntry * imgdata = getTextureData(fullpath);
if (imgdata) {
u8 *data = stbi_load_from_memory(reinterpret_cast<const stbi_uc *>(imgdata->data), imgdata->size, &w, &h, NULL, 4);
@ -109,6 +115,7 @@ namespace MoonInternal {
}
cout << "Failed to load texture" << endl;
cout << fullpath << endl;
gfx_rapi->upload_texture(missing_image.pixel_data, missing_image.width, missing_image.height);
}
@ -137,7 +144,7 @@ namespace MoonInternal {
BitModule* bit = new BitModule();
bit->name = "Moon64";
bit->description = "SM64 Original Textures";
bit->author = "Nintendo";
bit->authors = (vector<string>){ "Nintendo" };
bit->version = 1.0f;
bit->readOnly = true;
bit->textures = baseGameTextures;

View File

@ -6,10 +6,10 @@
class TextureModifier {
public:
virtual void onInit(){}
virtual void onLoad(std::string texture, nlohmann::json data){}
// virtual void onRelease(){}
virtual std::string getKey(){}
virtual void onInit() = 0;
virtual void onLoad(std::string texture, nlohmann::json data) = 0;
// virtual void onRelease() = 0;
virtual std::string getKey() = 0;
};
#endif

View File

@ -17,6 +17,8 @@ extern "C" {
BitModule* currentPack;
vector<BitModule*> texturePackList;
int scrollModifier = 0;
int currentSubItem = 0;
int focusFlag;
int focusRange = 80;
@ -31,6 +33,7 @@ enum ItemButtons{
void MoonAddonsScreen::Init(){
texturePackList.clear();
this->scrollIndex = 0;
scrollModifier = 0;
currentPack = NULL;
copy(Moon::addons.begin(), Moon::addons.end(), back_inserter(texturePackList));
reverse(texturePackList.begin(), texturePackList.end());
@ -52,6 +55,27 @@ void rebuildTextureCache(){
MoonInternal::buildTextureCache(order);
}
void MoonAddonsScreen::changeScroll(int idx){
if(idx < 0){
if(this->scrollIndex > 0){
if(scrollModifier > 0 && this->scrollIndex == scrollModifier)
scrollModifier--;
this->scrollIndex--;
return;
}
this->scrollIndex = texturePackList.size() - 1;
scrollModifier = this->scrollIndex - 4;
return;
}
if(this->scrollIndex < texturePackList.size() - 1){
if(this->scrollIndex > 3 && !((this->scrollIndex - scrollModifier) % 4)) scrollModifier++;
this->scrollIndex++;
return;
}
this->scrollIndex = 0;
scrollModifier = 0;
}
void MoonAddonsScreen::Update(){
float yStick = GetStickValue(MoonButtons::U_STICK, false);
if(yStick > 0) {
@ -64,10 +88,7 @@ void MoonAddonsScreen::Update(){
dispatched = true;
return;
}
if(this->scrollIndex > 0)
this->scrollIndex--;
else
this->scrollIndex = texturePackList.size() - 1;
MoonAddonsScreen::changeScroll(-1);
dispatched = true;
}
if(yStick < 0) {
@ -80,10 +101,7 @@ void MoonAddonsScreen::Update(){
dispatched = true;
return;
}
if(this->scrollIndex < texturePackList.size() - 1)
this->scrollIndex++;
else
this->scrollIndex = 0;
MoonAddonsScreen::changeScroll(1);
dispatched = true;
}
if(!yStick)
@ -95,14 +113,16 @@ void MoonAddonsScreen::Update(){
case ItemButtons::UP:
if(this->scrollIndex > 0){
std::swap(texturePackList[this->scrollIndex], texturePackList[this->scrollIndex - 1]);
currentPack = texturePackList[this->scrollIndex--];
MoonAddonsScreen::changeScroll(-1);
currentPack = texturePackList[this->scrollIndex];
rebuildTextureCache();
}
break;
case ItemButtons::DOWN:
if(this->scrollIndex < texturePackList.size() - 1){
std::swap(texturePackList[this->scrollIndex], texturePackList[this->scrollIndex + 1]);
currentPack = texturePackList[this->scrollIndex++];
MoonAddonsScreen::changeScroll(1);
currentPack = texturePackList[this->scrollIndex];
rebuildTextureCache();
}
break;
@ -124,6 +144,13 @@ void MoonAddonsScreen::Update(){
MoonScreen::Update();
}
static std::string cropTxt(string txt, int length){
int currLngt = min((int) txt.length(), length);
string desc = txt.substr(0, currLngt);
desc.erase(find_if(desc.rbegin(), desc.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), desc.end());
return currLngt >= length ? desc + " ..." : desc;
}
char *strdup(const char *src_str) noexcept {
char *new_str = new char[std::strlen(src_str) + 1];
std::strcpy(new_str, src_str);
@ -132,7 +159,6 @@ char *strdup(const char *src_str) noexcept {
void MoonAddonsScreen::Draw(){
string curTitle = "Texture packs";
float step = 1.5;
if(focusAnim >= focusRange)
@ -153,22 +179,46 @@ void MoonAddonsScreen::Draw(){
Color focusColor = {255, 255, 255, 40 + focusAnim};
int i = 0;
for(auto &addon : texturePackList){
bool selected = i == this->scrollIndex && currentPack != NULL;
int packAmount = texturePackList.size();
int maxPacks = 5;
int iMod = scrollModifier;
for(int i = 0; i < min(packAmount, maxPacks); i++){
int index = i + iMod;
if(index > packAmount - 1){
this->scrollIndex = 0;
scrollModifier = 0;
cout << "Triggered overflow, coming back to 0" << endl;
return;
}
auto &addon = texturePackList[index];
if(addon == NULL) return;
bool selected = (i + iMod) == this->scrollIndex && currentPack != NULL;
int itemWidth = boxWidth - (selected ? 15 : 0);
MoonDrawRectangle(35, 45 + (i * 35), itemWidth - 20, 31, i == this->scrollIndex && !selected ? focusColor : (Color){0, 0, 0, 100}, true);
string iconPath = "mod-icons://"+addon->name;
MoonDrawTexture(35, 45 + (i * 35), 30, 30, strdup(iconPath.c_str()));
MoonDrawText(70, 45 + (i * 35) + 3, addon->name, 0.8, {255, 255, 255, 255}, true, true);
MoonDrawText(70, 45 + (i * 35) + 16, addon->description, 0.8, {255, 255, 255, 255}, true, true);
MoonDrawRectangle(35, 45 + (i * 35), itemWidth - 20, 31, (i + iMod) == this->scrollIndex && !selected ? focusColor : (Color){0, 0, 0, 100}, true);
string pathPrefix = "mod-icons://";
string iconPath = pathPrefix.append(addon->name);
char* parsed = strdup(iconPath.c_str());
if(parsed != nullptr)
MoonDrawTexture(35, 45 + (i * 35), 30, 30, parsed);
MoonDrawText(35 + 26, 46 + (i * 35), to_string(i + iMod), 0.5, {255, 255, 255, 255}, true, true);
MoonDrawText(70, 45 + (i * 35) + 3, cropTxt(addon->name, 37), 0.8, {255, 255, 255, 255}, true, true);
int maxDesc = 37;
int currLngt = min((int) addon->description.length(), maxDesc);
MoonDrawText(70, 45 + (i * 35) + 16, cropTxt(addon->description, 37), 0.8, {255, 255, 255, 255}, true, true);
string rawVer = to_string(addon->version);
string version = "v"+rawVer.substr(0, rawVer.find(".")+2);
MoonDrawText(itemWidth + 13 - MoonGetTextWidth(version, 0.5, false), 45 + (i * 35) + 2, version, 0.5, {255, 255, 255, 255}, true, true);
MoonDrawText(itemWidth + 13 - MoonGetTextWidth(addon->author, 0.5, false), 45 + (i * 35) + 22, addon->author, 0.5, {255, 255, 255, 255}, true, true);
MoonDrawText(itemWidth + 13 - MoonGetTextWidth(addon->authors[0], 0.5, false), 45 + (i * 35) + 22, addon->authors[0], 0.5, {255, 255, 255, 255}, true, true);
if(selected){
MoonDrawRectangle(itemWidth + 16, 45 + (i * 35), 13, 9.3, currentSubItem == ItemButtons::UP ? focusColor : (Color){0, 0, 0, 100}, true);
@ -180,7 +230,6 @@ void MoonAddonsScreen::Draw(){
MoonDrawRectangle(itemWidth + 16, 45 + (i * 35) + 21.7, 13, 9.3, currentSubItem == ItemButtons::TOGGLE ? focusColor : (Color){0, 0, 0, 100}, true);
MoonDrawTexture (itemWidth + 18, 46 + (i * 35) + 21.7, 8, 8, "textures/special/remove.rgba16");
}
i++;
}
MoonScreen::Draw();

View File

@ -8,6 +8,8 @@ public:
void Update();
void Draw();
void Mount();
private:
void changeScroll(int idx);
};

View File

@ -115,7 +115,7 @@ Vtx *make_rect_verts(float w, float h) {
return verts;
}
void moon_draw_texture(s32 x, s32 y, u32 w, u32 h, u8 *texture) {
void moon_draw_texture(s32 x, s32 y, u32 w, u32 h, char *texture) {
gSPDisplayList(gDisplayListHead++, dl_hud_img_begin);
gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_32b, 0, 0, G_TX_LOADTILE, 0, G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD);
gDPTileSync(gDisplayListHead++);

View File

@ -14,6 +14,6 @@ f32 moon_get_text_width(u8* text, float scale, u8 colored);
void moon_draw_colored_text(f32 x, f32 y, const u8 *str, float scale, struct Color c);
void moon_draw_text(f32 x, f32 y, const u8 *str, float scale);
void moon_draw_rectangle(f32 x, f32 y, f32 w, f32 h, struct Color c, u8 u4_3);
void moon_draw_texture(s32 x, s32 y, u32 w, u32 h, u8 *texture);
void moon_draw_texture(s32 x, s32 y, u32 w, u32 h, char *texture);
#endif