Add Preload Option to the Settings. (#59)

* Add preloading texture option to the Display GUI.
This commit is contained in:
Prince Frizzy 2022-04-09 05:02:42 -04:00 committed by GitHub
parent 8e7f0e2ea9
commit b230d63b25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 17 deletions

View File

@ -2,12 +2,32 @@
#include "src/pc/utils/misc.h"
#include "src/pc/configfile.h"
// The checkbox size is determined by the base size they all have and the amount.
#define CHECKBOXES_SIZE 32 * 6
// The checkbox pad size is determined by half the base size they all have and the amount plus one.
#define CHECKBOXES_PAD_SIZE 16 * 7
// The accumulative size of both the padding size and normal size for the checkboxes.
#define CHECKBOXES_FULL_SIZE CHECKBOXES_SIZE + CHECKBOXES_PAD_SIZE
// The selection box size is determined by the base size they all have and the amount.
#define SELECTION_BOXES_SIZE 32 * 3
// The selection box pad size is determined by half the base size they all have and the amount plus one.
#define SELECTION_BOXES_PAD_SIZE 16 * 4
// The accumulative size of both the padding size and normal size for the selection boxes.
#define SELECTION_BOXES_FULL_SIZE SELECTION_BOXES_SIZE + SELECTION_BOXES_PAD_SIZE
// The button size is determined by the base size they all have and the amount.
#define BUTTON_SIZES 64 * 2
// The full height for the body.
#define BODY_HEIGHT CHECKBOXES_FULL_SIZE + SELECTION_BOXES_FULL_SIZE + BUTTON_SIZES
static void djui_panel_display_apply(UNUSED struct DjuiBase* caller) {
configWindow.settings_changed = true;
}
void djui_panel_display_create(struct DjuiBase* caller) {
f32 bodyHeight = 32 * 8 + 64 * 2 + 16 * 9;
f32 bodyHeight = BODY_HEIGHT;
struct DjuiBase* defaultBase = NULL;
struct DjuiThreePanel* panel = djui_panel_menu_create(bodyHeight, "\\#ff0800\\D\\#1be700\\I\\#00b3ff\\S\\#ffef00\\P\\#ff0800\\L\\#1be700\\A\\#00b3ff\\Y");
@ -25,17 +45,23 @@ void djui_panel_display_create(struct DjuiBase* caller) {
djui_base_set_size(&checkbox2->base, 1.0f, 32);
djui_interactable_hook_value_change(&checkbox2->base, djui_panel_display_apply);
struct DjuiCheckbox* checkbox4 = djui_checkbox_create(&body->base, "HUD", &configHUD);
struct DjuiCheckbox* checkbox3 = djui_checkbox_create(&body->base, "HUD", &configHUD);
djui_base_set_size_type(&checkbox3->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&checkbox3->base, 1.0f, 32);
struct DjuiCheckbox* checkbox4 = djui_checkbox_create(&body->base, "Disable Popups", &configDisablePopups);
djui_base_set_size_type(&checkbox4->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&checkbox4->base, 1.0f, 32);
struct DjuiCheckbox* checkbox5 = djui_checkbox_create(&body->base, "Disable Popups", &configDisablePopups);
struct DjuiCheckbox* checkbox5 = djui_checkbox_create(&body->base, "Disable Downloaded Models", &configDisableDownloadedModels);
djui_base_set_size_type(&checkbox5->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&checkbox5->base, 1.0f, 32);
struct DjuiCheckbox* checkbox6 = djui_checkbox_create(&body->base, "Disable Downloaded Models", &configDisableDownloadedModels);
#ifdef EXTERNAL_DATA
struct DjuiCheckbox* checkbox6 = djui_checkbox_create(&body->base, "Preload Textures", &configPrecacheRes);
djui_base_set_size_type(&checkbox6->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&checkbox6->base, 1.0f, 32);
#endif
char* filterChoices[3] = { "Nearest", "Linear", "Tripoint" };
struct DjuiSelectionbox* selectionbox1 = djui_selectionbox_create(&body->base, "Filtering", filterChoices, 3, &configFiltering);
@ -52,16 +78,16 @@ void djui_panel_display_create(struct DjuiBase* caller) {
djui_base_set_size_type(&selectionbox3->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&selectionbox3->base, 1.0f, 32);
struct DjuiButton* button5 = djui_button_create(&body->base, "DynOS Model Packs");
djui_base_set_size_type(&button5->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button5->base, 1.0f, 64);
djui_interactable_hook_click(&button5->base, djui_panel_dynos_create);
struct DjuiButton* button1 = djui_button_create(&body->base, "DynOS Model Packs");
djui_base_set_size_type(&button1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button1->base, 1.0f, 64);
djui_interactable_hook_click(&button1->base, djui_panel_dynos_create);
struct DjuiButton* button6 = djui_button_create(&body->base, "Back");
djui_base_set_size_type(&button6->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button6->base, 1.0f, 64);
djui_button_set_style(button6, 1);
djui_interactable_hook_click(&button6->base, djui_panel_menu_back);
struct DjuiButton* button2 = djui_button_create(&body->base, "Back");
djui_base_set_size_type(&button2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button2->base, 1.0f, 64);
djui_button_set_style(button2, 1);
djui_interactable_hook_click(&button2->base, djui_panel_menu_back);
}
djui_panel_add(caller, &panel->base, defaultBase);

View File

@ -524,7 +524,7 @@ static inline void load_texture(const char *fullpath) {
}
}
fprintf(stderr, "could not load texture: `%s`\n", fullpath);
fprintf(stderr, "Could not load texture: `%s`\n", fullpath);
// replace with missing texture
gfx_rapi->upload_texture(missing_texture, MISSING_W, MISSING_H);
}
@ -578,7 +578,7 @@ static bool preload_texture(void *user, const char *path) {
// get the format and size from filename
u8 fmt, siz;
if (!texname_to_texformat(texname, &fmt, &siz)) {
fprintf(stderr, "unknown texture format: `%s`, skipping\n", texname);
fprintf(stderr, "Unknown texture format: `%s`, skipping\n", texname);
return true; // just skip it, might be a stray skybox or something
}
@ -590,8 +590,11 @@ static bool preload_texture(void *user, const char *path) {
assert(actualname);
struct TextureHashmapNode *n;
if (!gfx_texture_cache_lookup(0, &n, actualname, fmt, siz))
if (!gfx_texture_cache_lookup(0, &n, actualname, fmt, siz)) {
//fprintf(stdout, "Loading new texture: `%s.`\n", actualname);
load_texture(path); // new texture, load it
}
return true;
}