diff --git a/config/menus/editing.cfg b/config/menus/editing.cfg index 6c8f1be31..2231f6bc4 100644 --- a/config/menus/editing.cfg +++ b/config/menus/editing.cfg @@ -10,7 +10,7 @@ // ui_center [ui_edit_button2 [toggle edit mode] [edittoggle]] ui_center [ui_button "map info" [show_ui mapinfo]] ui_center [ui_button "geometry and texturing" [show_ui geometry]] - ui_center [ui_button (format "texture list %1" (dobindsearch showtexgui edit)) [clear_ui ; showtexgui ]] + ui_center [ui_button (format "texture list %1" (dobindsearch [show_ui texture_list] edit)) [show_ui texture_list]] ui_center [ui_button "editing options" [show_ui editoptions]] ui_center [ui_button "environment settings" [show_ui world]] ui_center [ui_button "texture variations" [show_ui textures]] @@ -25,7 +25,7 @@ //compass "^fs^fcQ^fSuit editing" Q [edittoggle] compass "m^fs^fca^fSp info" A [show_ui mapinfo] compass "^fs^fcg^fSeometry and texturing" G [show_ui geometry] - compass "^fs^fct^fSexture list" T [showtexgui] + compass "^fs^fct^fSexture list" T [show_ui texture_list] compass "e^fs^fcd^fSiting options" D [show_ui editoptions] compass "^fs^fcw^fSorld variables" W [show_ui world] compass "texture ^fs^fcv^fSariations" V [show_ui textures] @@ -446,8 +446,8 @@ ui_button "view the texture list" ui_strut 1 ui_spring 1 - ui_button (dobindsearch showtexgui edit) - ] [clear_ui ; showtexgui ] [saycommand /showtexgui] [ui_tooltip showtexgui] + ui_button (dobindsearch [show_ui texture_list] edit) + ] [clear_ui ; show_ui texture_list ] [saycommand /show_ui texture_list] [ui_tooltip "show_ui texture_list"] ui_edit_button "^fdcycle textures via mouse wheel" [domodifier 6] ui_edit_button "grab texture from selected face" gettex ui_edit_button "repeat last texture change across the entire map" [allfaces 0; replace] @@ -1291,7 +1291,7 @@ ui_center [ui_text "a blendmap creates smooth transitions on two-layer textures"] ui_strut 1 ui_list [ - ui_button "first look up a texture index in the texture list: #" [clear_ui; showtexgui] + ui_button "first look up a texture index in the texture list: #" [show_ui texture_list] ui_strut 1 ui_textfield slotnum 4 ] @@ -2130,3 +2130,11 @@ ] ] + new_ui texture_list [ + ui_header "Select Texture" + ui_texture_list + ] [ + if (= $guipasses 0) [ + ui_texture_list_init + ] + ] diff --git a/config/menus/options.cfg b/config/menus/options.cfg index c05e3e996..69b5e081b 100644 --- a/config/menus/options.cfg +++ b/config/menus/options.cfg @@ -1008,7 +1008,7 @@ waitbindtitles = [ ] editbindactions = [ - "showtexgui" edittoggle "show_ui edit" "remip" "fullbright 0; patchlight" + "show_ui texture_list" edittoggle "show_ui edit" "remip" "fullbright 0; patchlight" "fullbright 0; quicklight" "fullbright 0; calclight 1" savemap "changeoutline 1" [showcompass editing] [show_ui materials] [if $blendpaintmode paintblendmap editdrag] [if $blendpaintmode rotateblendbrush editextend] selcorners "universaldelta 1" "universaldelta -1" diff --git a/config/setup.cfg b/config/setup.cfg index a7202fc10..7bd7da93e 100644 --- a/config/setup.cfg +++ b/config/setup.cfg @@ -182,7 +182,7 @@ bind F12 [ screenshot ] bind COMMA [ show_ui profile 2 ] bind PERIOD [ show_ui team ] -editbind F1 [ showtexgui ] +editbind F1 [ show_ui texture_list ] editbind F2 [ edittoggle ] editbind F3 [ show_ui edit ] editbind F4 [ remip ] diff --git a/src/engine/engine.h b/src/engine/engine.h index 1dafc6a6a..a399e8615 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -688,7 +688,6 @@ extern char *ui_skin_texture, *ui_skin_border_texture, *ui_overlay_texture, *ui_ extern void menu_progress(); extern void menu_main(); -extern void menu_texture(); extern bool menuactive(); extern int cleargui(int n = 0, bool skip = true); diff --git a/src/engine/menus.cpp b/src/engine/menus.cpp index faa3f08e9..bd383c1a8 100644 --- a/src/engine/menus.cpp +++ b/src/engine/menus.cpp @@ -192,10 +192,8 @@ bool showgui(const char *name, int tab, bool *keep) return true; } -extern bool closetexgui(); int cleargui(int n, bool skip) { - if(closetexgui()) n--; int clear = menustack.length(); if(n>0) clear = min(clear, n); loopi(clear) if(!pop_ui(skip)) break; @@ -975,3 +973,18 @@ void ui_console(int width, int height, const char *init) } } ICOMMAND(0, consolegui, "iis", (int *w, int *h, char *i), ui_console(*w, *h, i)); + +void ui_texture_list() +{ + if(!cgui) return; + void ui_texture_list_(guient &); + ui_texture_list_(*cgui); +} +COMMAND(0, ui_texture_list, ""); + +void ui_texture_list_init() +{ + void ui_texture_list_init_(); + ui_texture_list_init_(); +} +COMMAND(0, ui_texture_list_init, ""); diff --git a/src/engine/octaedit.cpp b/src/engine/octaedit.cpp index e084818ad..a4abd2994 100644 --- a/src/engine/octaedit.cpp +++ b/src/engine/octaedit.cpp @@ -2809,160 +2809,133 @@ FVAR(IDF_PERSIST, thumbsize, 0, 2, 25); static int lastthumbnail = 0; static const char *rotations[6] = { "none", "90 degrees", "180 degrees", "270 degrees", "flip x", "flip y" }; -struct texturegui : guicb -{ - bool menuon; - int menustart, menupage, menutex, rolltex; - - texturegui() : menustart(-1), menutex(-1), rolltex(-1) {} - - void gui(guient &g, bool firstpass) - { - extern VSlot dummyvslot; - int curtex = menutex, numpages = max((texmru.length() + thumbwidth*thumbheight - 1)/(thumbwidth*thumbheight), 1)-1; - if(autopreviewtexgui && texmru.inrange(rolltex)) curtex = rolltex; - if(menupage > numpages) menupage = numpages; - else if(menupage < 0) menupage = 0; - g.start(menustart, NULL, true); +static int menupage, menutex = -1, rolltex = -1; + +void ui_texture_list_(guient &g) +{ + bool menuon = true; + extern VSlot dummyvslot; + int curtex = menutex, numpages = max((texmru.length() + thumbwidth*thumbheight - 1)/(thumbwidth*thumbheight), 1)-1; + if(autopreviewtexgui && texmru.inrange(rolltex)) curtex = rolltex; + if(menupage > numpages) menupage = numpages; + else if(menupage < 0) menupage = 0; + + uilist(g, { + g.space(2); + if(g.button("\fgauto apply", 0xFFFFFF, "checkbox", 0xFFFFFF, -1, true, autoapplytexgui ? "checkboxon" : NULL, ui_color_checkbox) & GUI_UP) + autoapplytexgui = autoapplytexgui ? 0 : 1; + g.space(2); + if(g.button("\fgauto preview", 0xFFFFFF, "checkbox", 0xFFFFFF, -1, true, autopreviewtexgui ? "checkboxon" : NULL, ui_color_checkbox) & GUI_UP) + autopreviewtexgui = autopreviewtexgui ? 0 : 1; + g.space(2); + if(g.button("\fgauto close", 0xFFFFFF, "checkbox", 0xFFFFFF, -1, true, autoclosetexgui ? "checkboxon" : NULL, autoclosetexgui > 1 ? ui_color_checkbox_two : ui_color_checkbox) & GUI_UP) + autoclosetexgui = autoclosetexgui ? (autoclosetexgui > 1 ? 0 : 2) : 1; + g.space(2); + if(g.button("\foreset order", 0xFFFFFF, NULL)&GUI_UP) + { + int old = texmru.inrange(menutex) ? texmru[menutex] : -1; + resettexmru(); + curtex = menutex = rolltex = texmru.find(old); + } + }); + g.space(1); + uilist(g, { uilist(g, { - g.space(2); - if(g.button("\fgauto apply", 0xFFFFFF, "checkbox", 0xFFFFFF, -1, true, autoapplytexgui ? "checkboxon" : NULL, ui_color_checkbox) & GUI_UP) - autoapplytexgui = autoapplytexgui ? 0 : 1; - g.space(2); - if(g.button("\fgauto preview", 0xFFFFFF, "checkbox", 0xFFFFFF, -1, true, autopreviewtexgui ? "checkboxon" : NULL, ui_color_checkbox) & GUI_UP) - autopreviewtexgui = autopreviewtexgui ? 0 : 1; - g.space(2); - if(g.button("\fgauto close", 0xFFFFFF, "checkbox", 0xFFFFFF, -1, true, autoclosetexgui ? "checkboxon" : NULL, autoclosetexgui > 1 ? ui_color_checkbox_two : ui_color_checkbox) & GUI_UP) - autoclosetexgui = autoclosetexgui ? (autoclosetexgui > 1 ? 0 : 2) : 1; - g.space(2); - if(g.button("\foreset order", 0xFFFFFF, NULL)&GUI_UP) + if(texmru.inrange(curtex)) { - int old = texmru.inrange(menutex) ? texmru[menutex] : -1; - resettexmru(); - curtex = menutex = rolltex = texmru.find(old); + VSlot &v = lookupvslot(texmru[curtex], false); + g.strut(60); + if(v.slot->sts.empty()) g.texture(dummyvslot, thumbheight*thumbsize/2, false); + else if(!v.slot->loaded && !v.slot->thumbnail) + { + if(totalmillis-lastthumbnailsts.empty() ? "" : v.slot->sts[0].name); + g.textf(" - scale: \fa%f", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.scale); + g.textf(" - rotation: \fa%d (%s)", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.rotation, rotations[clamp(v.rotation, 0, 5)]); + g.textf(" - offset: \fa%d %d", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.offset.x, v.offset.y); + g.textf(" - scroll: \fa%f %f", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.scroll.x, v.scroll.y); + g.textf(" - alpha: \fa%f \fAfront \fa%f \fAback", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.alphafront, v.alphaback); + g.textf(" - colour: \fr%f \fg%f \fb%f", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.colorscale[0], v.colorscale[1], v.colorscale[2]); + g.textf(" - palette: \fa%d %d", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.palette, v.palindex); + g.textf(" - coast: \fa%f", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.coastscale); + VSlot &vl = lookupvslot(v.layer); + g.textf(" - layer: \fa%03d (%s)", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.layer, vl.slot->sts.empty() ? "" : vl.slot->sts[0].name); + loopv(v.params) + { + SlotShaderParam &p = v.params[i]; + g.textf(" - shader: \fa%s %f %f %f %f %d %d", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, p.name, p.val[0], p.val[1], p.val[2], p.val[3], v.palette, v.palindex); + } } + else g.image(textureload(nothumbtex, 3), thumbheight*thumbsize/2, true); }); g.space(1); - uilist(g, { - uilist(g, { - if(texmru.inrange(curtex)) - { - VSlot &v = lookupvslot(texmru[curtex], false); - g.strut(60); - if(v.slot->sts.empty()) g.texture(dummyvslot, thumbheight*thumbsize/2, false); - else if(!v.slot->loaded && !v.slot->thumbnail) - { - if(totalmillis-lastthumbnailsts.empty() ? "" : v.slot->sts[0].name); - g.textf(" - scale: \fa%f", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.scale); - g.textf(" - rotation: \fa%d (%s)", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.rotation, rotations[clamp(v.rotation, 0, 5)]); - g.textf(" - offset: \fa%d %d", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.offset.x, v.offset.y); - g.textf(" - scroll: \fa%f %f", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.scroll.x, v.scroll.y); - g.textf(" - alpha: \fa%f \fAfront \fa%f \fAback", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.alphafront, v.alphaback); - g.textf(" - colour: \fr%f \fg%f \fb%f", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.colorscale[0], v.colorscale[1], v.colorscale[2]); - g.textf(" - palette: \fa%d %d", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.palette, v.palindex); - g.textf(" - coast: \fa%f", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.coastscale); - VSlot &vl = lookupvslot(v.layer); - g.textf(" - layer: \fa%03d (%s)", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, v.layer, vl.slot->sts.empty() ? "" : vl.slot->sts[0].name); - loopv(v.params) - { - SlotShaderParam &p = v.params[i]; - g.textf(" - shader: \fa%s %f %f %f %f %d %d", 0xFFFFFF, NULL, 0, -1, false, NULL, 0xFFFFFF, p.name, p.val[0], p.val[1], p.val[2], p.val[3], v.palette, v.palindex); - } - } - else g.image(textureload(nothumbtex, 3), thumbheight*thumbsize/2, true); - }); - g.space(1); - uilistv(g, 2, { - uilist(g, loop(h, thumbheight) + uilistv(g, 2, { + uilist(g, loop(h, thumbheight) + { + uilist(g, loop(w, thumbwidth) { - uilist(g, loop(w, thumbwidth) + int ti = (menupage*thumbheight+h)*thumbwidth+w; + if(tists.empty()) continue; + else if(!v.slot->loaded && !v.slot->thumbnail) { - VSlot &v = lookupvslot(texmru[ti], false); - if(v.slot->sts.empty()) continue; - else if(!v.slot->loaded && !v.slot->thumbnail) + if(totalmillis-lastthumbnailloaded || v.slot->thumbnail!=notexture)) { - if(autoapplytexgui && (v.slot->loaded || v.slot->thumbnail!=notexture)) - { - menutex = ti; - edittex(texmru[ti]); - hudshader->set(); - if(autoclosetexgui > 1) menuon = false; - } + menutex = ti; + edittex(texmru[ti]); + hudshader->set(); + if(autoclosetexgui > 1) menuon = false; } - else if(ret&GUI_ROLLOVER) rolltex = ti; } - else g.texture(dummyvslot, thumbsize, false); //create an empty space - }); + else if(ret&GUI_ROLLOVER) rolltex = ti; + } + else g.texture(dummyvslot, thumbsize, false); //create an empty space }); - g.slider(menupage, 0, numpages, 0xFFFFFF, NULL, true, true); }); + g.slider(menupage, 0, numpages, 0xFFFFFF, NULL, true, true); }); - g.end(); - } + }); - void showtextures(bool on) - { - if(on != menuon && (menuon = on)) - { - menustart = starttime(); - cube &c = lookupcube(sel.o, -sel.grid); - rolltex = -1; - if(texmru.length() > 0) - { - if(!texmru.inrange(menutex = !isempty(c) ? texmru.find(c.texture[sel.orient]) : texmru.find(lasttex))) - menutex = 0; - menupage = clamp(menutex, 0, texmru.length()-1)/(thumbwidth*thumbheight); - } - else menutex = menupage = 0; - } - } + if(!menuon) cleargui(1); +} - void show() +void ui_texture_list_init_() +{ + cube &c = lookupcube(sel.o, -sel.grid); + rolltex = -1; + if(texmru.length() > 0) { - if(!menuon) return; - filltexlist(); - if(!editmode) menuon = false; - else UI::addcb(this); + if(!texmru.inrange(menutex = !isempty(c) ? texmru.find(c.texture[sel.orient]) : texmru.find(lasttex))) + menutex = 0; + menupage = clamp(menutex, 0, texmru.length()-1)/(thumbwidth*thumbheight); } -} gui; - -void menu_texture() { gui.show(); } -bool closetexgui() { if(gui.menuon) { gui.menuon = false; return true; } return false; } - -void showtexgui(int *n) -{ - if(!editmode) { conoutf("\froperation only allowed in edit mode"); return; } - gui.showtextures(*n==0 ? !gui.menuon : *n==1); + else menutex = menupage = 0; } -COMMAND(0, showtexgui, "i"); // 0/noargs = toggle, 1 = on, other = off - will autoclose when exiting editmode - void rendertexturepanel(int w, int h) { if((texpaneltimer -= curtime)>0 && editmode) diff --git a/src/engine/ui.cpp b/src/engine/ui.cpp index 03408ea62..3af9ef4e2 100644 --- a/src/engine/ui.cpp +++ b/src/engine/ui.cpp @@ -1408,7 +1408,6 @@ namespace UI if(progressing) menu_progress(); else { - menu_texture(); hud::gamemenus(); menu_main(); }