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);
// 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);
void* bitmap; // Will contain either a SDL_Surface or SDL_Texture
SDL_Rect loc, clip;
ContextManager* ctx;
+ bool over;
int bmp_w, bmp_h;
}
}
+ // 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() {
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
#ifndef GIT_REV_HDR
#define GIT_REV_HDR
-#define GIT_REV "600f8372132a379e10f46584bba06b5013e8bf05"
+#define GIT_REV "2aefc48e99ae39a5427858ce44bfb625c51ac8db"
#endif
// 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];
}
GetData()->ctx->Text()->Outline(1);
GetData()->ctx->Text()->SetColor(255,255,255,255);
+ Data_PostInit();
+
op_cleartext();
}
}
}
- CreateDataContainer();
+ Data_PreInit();
GetData()->ctx = new ContextManager();
#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
GetData()->ctx->ClearOverlay();
// Dim transparent overlay
- ct_transwindow();
+ GetData()->text_box_base->Blit();
}