diff options
author | Max Horn | 2002-07-12 16:24:11 +0000 |
---|---|---|
committer | Max Horn | 2002-07-12 16:24:11 +0000 |
commit | e34571dca90689bd7367697c842927994a38d62d (patch) | |
tree | 017bb4761fc65a9b517c2f08a45d17a20bd6a813 /newgui.cpp | |
parent | c99d9a57c0e6d3d24c3f6c51c50612a228f17158 (diff) | |
download | scummvm-rg350-e34571dca90689bd7367697c842927994a38d62d.tar.gz scummvm-rg350-e34571dca90689bd7367697c842927994a38d62d.tar.bz2 scummvm-rg350-e34571dca90689bd7367697c842927994a38d62d.zip |
Countless changes to the New GUI; some hightligths: new ScrollBarWidget class; ListWidget is usable (demo shows it off); added custom String/StringList classes
svn-id: r4521
Diffstat (limited to 'newgui.cpp')
-rw-r--r-- | newgui.cpp | 72 |
1 files changed, 16 insertions, 56 deletions
diff --git a/newgui.cpp b/newgui.cpp index 199fb720ff..33f515592d 100644 --- a/newgui.cpp +++ b/newgui.cpp @@ -23,65 +23,10 @@ #include "newgui.h" #include "guimaps.h" #include "gui/dialog.h" - -// 8-bit alpha blending routines -int BlendCache[256][256]; - -int RGBMatch(byte *palette, int r, int g, int b) { - int i, bestidx = 0, besterr = 0xFFFFFF; - int error = 0; - - for (i = 0;i < 256;i++) { - byte *pal = palette + (i * 3); - int r_diff = r - (int)*pal++; - int g_diff = g - (int)*pal++; - int b_diff = b - (int)*pal++; - r_diff *= r_diff; g_diff *= g_diff; b_diff *= b_diff; - - error = r_diff + g_diff + b_diff; - if (error < besterr) { - besterr = error; - bestidx = i; - } - } - return bestidx; -} - -int Blend(int src, int dst, byte *palette) { - int r, g, b; - int alpha = 128; // Level of transparency [0-256] - byte *srcpal = palette + (dst * 3); - byte *dstpal = palette + (src * 3); - - if (BlendCache[dst][src] > -1) - return BlendCache[dst][src]; - - r = (*srcpal++ * alpha); - r += (*dstpal++ * (256-alpha)); - r /= 256; - - g = (*srcpal++ * alpha); - g += (*dstpal++ * (256-alpha)); - g /= 256; - - b = (*srcpal++ * alpha); - b += (*dstpal++ * (256-alpha)); - b /= 256; - - return (BlendCache[dst][src] = RGBMatch(palette, r , g , b )); -} - -void ClearBlendCache(byte *palette, int weight) { - for (int i = 0; i < 256; i++) - for (int j = 0 ; j < 256 ; j++) -// BlendCache[i][j] = i; // No alphablending -// BlendCache[i][j] = j; // 100% translucent - BlendCache[i][j] = -1; // Enable alphablending -} +#include "gui/util.h" /* * TODO list - * - keep a copy of the original game background, for alpha/moving * - implement the missing / incomplete dialogs * - add more widgets * - add support for right/center aligned text @@ -357,6 +302,21 @@ void NewGui::fillRect(int x, int y, int w, int h, byte color) } } +void NewGui::checkerRect(int x, int y, int w, int h, byte color) +{ + byte *ptr = getBasePtr(x, y); + if (ptr == NULL) + return; + + while (h--) { + for (int i = 0; i < w; i++) { + if ((h ^ i) & 1) + ptr[i] = color; + } + ptr += 320; + } +} + void NewGui::frameRect(int x, int y, int w, int h, byte color) { int i; |