Hirato's patch for enhanced texture browser

Started by vampirefrog, May 30, 2009, 06:45:57 PM

Previous topic - Next topic

vampirefrog

Here's a patch that improves the texture browser by adding some extra info at the bottom:


Index: octaedit.cpp
===================================================================
--- octaedit.cpp (revision 954)
+++ octaedit.cpp (working copy)
-1664,13 +1664,16 @@

COMMAND(editmat, "ss");

-#define TEXGUI_WIDTH 10
-#define TEXGUI_HEIGHT 7
+//originally 10, increased for "convenience"
+#define TEXGUI_WIDTH 12
+//originally 7, reduced to host improvement test
+#define TEXGUI_HEIGHT 5
extern int menudistance, menuautoclose;

VARP(thumbtime, 0, 50, 1000);

static int lastthumbnail = 0;
+static int texhoveridx = 0;

VARP(texgui2d, 0, 1, 1);

-1691,6 +1694,8 @@
         {
             g.tab(!i ? "Textures" : NULL, 0xAAFFAA);
             if(i+1 != origtab) continue; //don't load textures on non-visible tabs!
+
+ Texture *prevtex = notexture, *prevglowtex = NULL, *prevlayertex = NULL;
             loopj(TEXGUI_HEIGHT)
             {
                 g.pushlist();
-1714,15 +1719,59 @@
                         }
                         else if(slot.thumbnail) tex = slot.thumbnail;
                         else if(totalmillis-lastthumbnail>=thumbtime) { tex = loadthumbnail(slot); lastthumbnail = totalmillis; }
-                        if(g.texture(tex, 1.0, slot.rotation, slot.xoffset, slot.yoffset, glowtex, slot.glowcolor, layertex)&G3D_UP && (slot.loaded || tex!=notexture))
+
+ int test = g.texture(tex, 1.0, slot.rotation, slot.xoffset, slot.yoffset, glowtex, slot.glowcolor, layertex);
+                        if(test&G3D_UP && (slot.loaded || tex!=notexture))
                             edittex(ti);
+ if(test&G3D_ROLLOVER)
+ {
+ texhoveridx = ti;
+ prevtex = tex;
+ prevglowtex = glowtex;
+ prevlayertex = layertex;
                     }
+                    }
                     else
                         g.texture(notexture, 1.0); //create an empty space
                 }
                 g.poplist();
             }
+
+     Slot &prev = lookuptexture(texhoveridx, false);
+ if(!prev.loaded && !prev.thumbnail) prevtex = loadthumbnail(prev); //load thumbnail if not loaded
+
+ g.pushlist();
+ g.texture(prevtex, 2.0, prev.rotation, prev.xoffset, prev.yoffset, prevglowtex, prev.glowcolor, prevlayertex);
+
+ extern int guitextcolour;
+ g.pushlist();
+ defformatstring(ds)("Texture: %s", prev.sts[0].name);
+ if(ds[45]) //shorten strings, to avoid a jittery interface
+ {
+ ds[45] = '\0';
+ ds[44] = ds[43] = ds[42] = '.';
         }
+ g.text(ds, guitextcolour, "info");
+
+ formatstring(ds)("layer: %i\tShader: %s", prev.layer, prev.shader->name);
+ if(ds[45])
+ {
+ ds[45] = '\0';
+ ds[44] = ds[43] = ds[42] = '.';
+ }
+ g.text(ds, guitextcolour, "info");
+
+ formatstring(ds)("Size: %ix%i\tScale: %.2f (%ix%i)",
+ prevtex->xs, prevtex->ys, prev.scale, (int) (prevtex->xs * prev.scale), (int) (prevtex->ys * prev.scale)); //w and h corresponds to the current scale
+ g.text(ds, guitextcolour, "info");
+
+ formatstring(ds)("Scroll: %.2f %.2f\toffset %i(%i%%) %i(%i%%)", prev.scrollS * 1000.0f, prev.scrollT * 1000.0f,
+ prev.xoffset, abs(100*prev.xoffset/prevtex->xs)%100, prev.yoffset, abs(100*prev.yoffset/prevtex->ys)%100);
+ g.text(ds, guitextcolour, "info");
+
+ g.poplist();
+ g.poplist();
+        }
         g.end();
     }



Apply with:
patch -p1 -u < diff

Suicizer