]> Chaos Git - vn/vndc.git/commitdiff
Making changes. There's some rather terrible and buggy behavior that needs severe...
authorchaoskagami <chaos.kagami@gmail.com>
Mon, 29 Sep 2014 16:26:54 +0000 (12:26 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Mon, 29 Sep 2014 16:26:54 +0000 (12:26 -0400)
external/zero/include/UDisplayable.hpp
external/zero/src/UDisplayable.cpp
vndc/include/Data.hpp
vndc/include/gitrev.hpp
vndc/src/Data.cpp
vndc/src/Loop.cpp
vndc/src/VNDC.cpp
vndc/src/op_cleartext.cpp

index 1d1c70187678ab0caf03910be7625843022ae96b..b733d64551ec31a5702d9a815db857b05b7c6aab 100644 (file)
@@ -17,6 +17,7 @@ typedef enum {
                        UDisplayable(ContextManager* ctx, char* fname); // Sets up in normal mode.
                        UDisplayable(ContextManager* ctx, UDisplayableMode mode, char* fname); // Sets up in specified mode; params not set
                        UDisplayable(ContextManager* ctx, UDisplayableMode mode, void* memory, int mSize); // Sets up from memory block in mode
+                       UDisplayable(ContextManager* cx, UDisplayableMode mode, SDL_Surface* bitmap_tmp);  // Loads from SDL_surface
 
                        // All modes can use the following.
                        void SetXY(double x, double y);
@@ -40,6 +41,7 @@ typedef enum {
                        // Only specific modes can use these. Otherwise, they nop.
                        void SetHitbox(int x, int y, int w, int h);
                        void SetDock(int x, int y, int w, int h);
+                       void SetOverlay(bool state);
 
                        // Only animated Displayables can use these.
                        void SetFrameWidth(int frameW);
@@ -56,6 +58,7 @@ typedef enum {
                        void* bitmap; // Will contain either a SDL_Surface or SDL_Texture
                        SDL_Rect loc, clip;
                        ContextManager* ctx;
+                       bool over;
 
                        int bmp_w, bmp_h;
 
index 2a0d801a2397a82352854e8096cc0a58e452f237..e50496d98350bcd3fde79e65d7fa9198b23faebc 100644 (file)
                }
        }
 
+       // From SDL_Surface.
+       UDisplayable::UDisplayable(ContextManager* cx, UDisplayableMode mode, SDL_Surface* bitmap_tmp) {
+               this->x = 0;
+               this->y = 0;
+               this->loc.x = 0;
+               this->loc.y = 0;
+               this->ctx = cx;
+               this->frameWidth = bitmap_tmp->w;
+               this->bmp_w = bitmap_tmp->w;
+               this->bmp_h = bitmap_tmp->h;
+
+               // We still allocate the two arrays, regardless.
+
+               // These values are unused, but we'll default them so it will operate normally.
+               hitbox = (int*)calloc(sizeof(int), 4);
+
+               // By default, it will fill this with 0, 0, W, H.
+               // This will behave identically to a displayable.
+               hitbox[0] = 0;
+               hitbox[1] = 0;
+               hitbox[2] = bitmap_tmp->w;
+               hitbox[3] = bitmap_tmp->h;
+
+               this->loc.w = bitmap_tmp->w;
+               this->loc.h = bitmap_tmp->w;
+
+               frame = (int*)calloc(sizeof(int), 4);
+
+               frame[0] = 0;
+               frame[1] = 0;
+               frame[2] = cx->GetWidth();
+               frame[3] = cx->GetHeight();
+
+               // Determine if we're on an accelerated context. If so, we create a texture out of the bitmap.
+               // Then we store what we'll use to the void* bitmap, either Tex or Surf.
+
+               if(cx->Accelerated()) {
+                       this->bitmap = cx->AccelImage(bitmap_tmp);
+               }
+               else {
+                       this->bitmap = cx->GLTexImage(bitmap_tmp);
+               }
+       }
+
        // Sets the position on screen.
 
        void UDisplayable::SetXY(double x, double y) {
                src.h = bmp_h;
 
                if (frameIndex == -1) {
-                       ctx->Blit(bitmap, &src, &loc_adj, NULL);
+                       if(over)
+                               ctx->OverlayBlit(bitmap, &src, &loc_adj, NULL);
+                       else
+                               ctx->Blit(bitmap, &src, &loc_adj, NULL);
                        return;
                }
 
                        image_rect.x = 0;
                        image_rect.w = bmp_w;
                        image_rect.h = bmp_h;
+                       if(over)
+                               ctx->OverlayBlit(bitmap, &frameClip, &loc_adj, &image_rect); // GL needs data that isn't inside of bitmap.
+                       else
+                               ctx->Blit(bitmap, &frameClip, &loc_adj, &image_rect); // GL needs data that isn't inside of bitmap.
 
-                       ctx->Blit(bitmap, &frameClip, &loc_adj, &image_rect); // GL needs data that isn't inside of bitmap.
                }
                else {
-                       ctx->Blit(bitmap, &frameClip, &loc_adj, NULL);
+                       if(over)
+                               ctx->OverlayBlit(bitmap, &frameClip, &loc_adj, NULL);
+                       else
+                               ctx->Blit(bitmap, &frameClip, &loc_adj, NULL);
                }
        }
 
                return rect;
        }
 
+       // Surface is on overlay, not background.
+       void UDisplayable::SetOverlay(bool state) {
+               over = state;
+       }
+
        // Destroy bitmap.
 
        UDisplayable::~UDisplayable() {
index 7bf4fab386517546ea96b660272ac3e8601374ea..41105c65f9be1eabd2c1e55755fefd9d3070eb24 100644 (file)
@@ -43,10 +43,12 @@ class DataContainer {
                char* window_name;
                char* next_line; // Used for voice-detect.
                                        // It's impossible to parse without lookahead.
+               UDisplayable* text_box_base;
 };
 
 DataContainer* GetData();
-void CreateDataContainer();
+void Data_PreInit();
+void Data_PostInit();
 void DumpSave(char* fname);
 
 #endif
index d15b922545d181c8e02bdfdc12e660f1992399c8..2745b8b0fe030c95a6e7783c72b88a9d64a1a5cd 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef GIT_REV_HDR
 #define GIT_REV_HDR
-#define GIT_REV "600f8372132a379e10f46584bba06b5013e8bf05"
+#define GIT_REV "2aefc48e99ae39a5427858ce44bfb625c51ac8db"
 
 #endif
index 71b1dc90cd99626f9f5311945511bdbad9357253..8c8ca872565461b1a14e8408ccec0ed7e64ec73a 100644 (file)
@@ -44,16 +44,28 @@ DataContainer::DataContainer() {
                                // It's impossible to parse without lookahead.
 }
 
-void CreateDataContainer() {
+void Data_PreInit() {
        data = new DataContainer();
 
-
-
+       /* Storage of values for saves */
        GetData()->main_scr = (char**)calloc(sizeof(char*), 1);
        GetData()->main_scr[0] = (char*)calloc(sizeof(char), 400);
        strncpy(GetData()->main_scr[0], loadup, 400);
 }
 
+void Data_PostInit() {
+       /* Generate the surface for use with cleartext. */
+       int width_dr = (GetData()->render_x2 - GetData()->render_x1 + 20);
+       int height_dr = (GetData()->render_y2 - GetData()->render_y1 + 20);
+
+       SDL_Surface* pass_sfc = SDL_CreateRGBSurface(0, width_dr, height_dr, 32, RED_MASK, GREEN_MASK, BLUE_MASK, ALPHA_MASK);
+       SDL_FillRect(pass_sfc, NULL, SDL_MapRGBA(pass_sfc->format, 0, 0, 0, 100));
+
+       GetData()->text_box_base = new UDisplayable(GetData()->ctx, Normal, pass_sfc);
+       GetData()->text_box_base->SetOverlay(true);
+       // GetData()->text_box_base->SetXY(GetData()->render_x1, GetData()->render_y1);
+}
+
 DataContainer* GetData() {
        return &data[0];
 }
index 87544f676e2c52c8b8a203d6c2a071ca91ef3526..f4625e4e0cbc1d8d1e1e4f34f598bcaf51f0d3da 100644 (file)
@@ -61,5 +61,7 @@ void Setup() {
        GetData()->ctx->Text()->Outline(1);
        GetData()->ctx->Text()->SetColor(255,255,255,255);
 
+       Data_PostInit();
+
        op_cleartext();
 }
index 57d23a1c342b04266615fdda862bef581819e07c..4f502a421be701f5b1c040aaafc9d2cbdd6800d0 100644 (file)
@@ -102,7 +102,7 @@ int main(int argc, char** argv) {
                }
        }
 
-       CreateDataContainer();
+       Data_PreInit();
 
        GetData()->ctx = new ContextManager();
 
index 2b6c71147b68fa5f6b3ba6452741e5653a63194d..1763ceb15d32662bb3ea5791b254fb87bb75d3f9 100644 (file)
@@ -2,46 +2,6 @@
 
 #include "Funcs.hpp"
 
-void ct_transwindow() {
-
-       int width_dr = (GetData()->render_x2 - GetData()->render_x1 + 20);
-       int height_dr = (GetData()->render_y2 - GetData()->render_y1 + 30 + 20);
-
-       // if(! GetData()->ctx->Accelerated()) return;
-       SDL_Surface* sfc = SDL_CreateRGBSurface(0, width_dr, height_dr, 32, RED_MASK, GREEN_MASK, BLUE_MASK, ALPHA_MASK);
-       SDL_FillRect(sfc, NULL, SDL_MapRGBA(sfc->format, 0, 0, 0, 100));
-       if(!GetData()->ctx->Accelerated()) {
-       }
-
-       SDL_Rect src;
-       src.x = 0;
-       src.y = 0;
-       src.w = sfc->w;
-       src.h = sfc->h;
-
-       SDL_Rect dst;
-       dst.x = GetData()->render_x1 - 10;
-       dst.y = GetData()->render_y1 - 10;
-       dst.w = src.w;
-       dst.h = src.h;
-
-       if(GetData()->ctx->Accelerated()) {
-               SDL_Texture* dim = SDL_CreateTextureFromSurface(GetData()->ctx->Renderer(), sfc);
-               //SDL_SetTextureBlendMode(dim, SDL_BLENDMODE_BLEND);
-               //SDL_SetTextureAlphaMod(dim, 128);
-
-               GetData()->ctx->OverlayBlit(dim, &src, &dst, NULL);
-
-               SDL_DestroyTexture(dim);
-       }
-       else {
-               GetData()->ctx->OverlayBlit(sfc, &src, &dst, NULL);             
-       }
-
-       SDL_FreeSurface(sfc);
-
-}
-
 /*
  * Implements cleartext vnds function.
  * cleartext mod
@@ -57,5 +17,5 @@ void op_cleartext() {
        GetData()->ctx->ClearOverlay();
 
        // Dim transparent overlay
-       ct_transwindow();
+       GetData()->text_box_base->Blit();
 }