summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9e2ffed)
raw | patch | inline | side by side (parent: 9e2ffed)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Thu, 28 Dec 2017 23:46:02 +0000 (01:46 +0200) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Thu, 28 Dec 2017 23:46:53 +0000 (01:46 +0200) |
src/game/g_game.pas | patch | blob | history | |
src/game/g_textures.pas | patch | blob | history |
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 78c8dba234975e1ead9c75585d60eedb1171eced..7e20f0962af8e18c463e556ec3a9443ba9d9a668 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
sfs, wadreader, g_holmes;
+var
+ hasPBarGfx: Boolean = false;
+
+
// ////////////////////////////////////////////////////////////////////////// //
function gPause (): Boolean; inline; begin result := gPauseMain or gPauseHolmes; end;
ShowCount: Integer;
Msgs: Array of String;
NextMsg: Word;
+ PBarWasHere: Boolean; // did we draw a progress bar for this message?
end;
TParamStrValue = record
end;
procedure g_Game_LoadData();
+var
+ wl, hl: Integer;
+ wr, hr: Integer;
+ wb, hb: Integer;
+ wm, hm: Integer;
begin
if DataLoaded then Exit;
g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD+':TEXTURES\FLAGHUD_B_DROP');
g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD+':TEXTURES\TALKBUBBLE');
g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD+':TEXTURES\PENTA');
+
+ hasPBarGfx := true;
+ if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD+':TEXTURES\LLEFT') then hasPBarGfx := false;
+ if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD+':TEXTURES\LMARKER') then hasPBarGfx := false;
+ if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD+':TEXTURES\LMIDDLE') then hasPBarGfx := false;
+ if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD+':TEXTURES\LRIGHT') then hasPBarGfx := false;
+
+ if hasPBarGfx then
+ begin
+ g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl, hl);
+ g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr, hr);
+ g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb, hb);
+ g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm, hm);
+ if (wl > 0) and (hl > 0) and (wr > 0) and (hr = hl) and (wb > 0) and (hb = hl) and (wm > 0) and (hm > 0) and (hm <= hl) then
+ begin
+ // yay!
+ end
+ else
+ begin
+ hasPBarGfx := false;
+ end;
+ end;
+
g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD+':TEXTURES\TELEPORT', 64, 64, 10, False);
g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD+':SOUNDS\TELEPORT');
g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD+':SOUNDS\NOTELEPORT');
glEnd();
end;
- procedure drawPBar (cur, total: Integer);
+ function drawPBar (cur, total: Integer; washere: Boolean): Boolean;
var
rectW, rectH: Integer;
x0, y0: Integer;
wdt: Integer;
- begin
+ wl, hl: Integer;
+ wr, hr: Integer;
+ wb, hb: Integer;
+ wm, hm: Integer;
+ idl, idr, idb, idm: LongWord;
+ f, my: Integer;
+ begin
+ result := false;
if (total < 1) then exit;
if (cur < 1) then exit; // don't blink
- if (cur >= total) then exit; // don't blink
+ if (not washere) and (cur >= total) then exit; // don't blink
//if (cur < 0) then cur := 0;
//if (cur > total) then cur := total;
+ result := true;
- rectW := gScreenWidth-64;
- rectH := 16;
+ if (hasPBarGfx) then
+ begin
+ g_Texture_Get('UI_GFX_PBAR_LEFT', idl);
+ g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl, hl);
+ g_Texture_Get('UI_GFX_PBAR_RIGHT', idr);
+ g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr, hr);
+ g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb);
+ g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb, hb);
+ g_Texture_Get('UI_GFX_PBAR_MARKER', idm);
+ g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm, hm);
- x0 := (gScreenWidth-rectW) div 2;
- y0 := gScreenHeight-rectH-64;
- if (y0 < 2) then y0 := 2;
+ rectW := gScreenWidth-64;
+ rectH := hl;
- glDisable(GL_BLEND);
- glDisable(GL_TEXTURE_2D);
+ x0 := (gScreenWidth-rectW) div 2;
+ y0 := gScreenHeight-rectH-64;
+ if (y0 < 2) then y0 := 2;
- //glClearColor(0, 0, 0, 0);
- //glClear(GL_COLOR_BUFFER_BIT);
+ glEnable(GL_SCISSOR_TEST);
- glColor4ub(127, 127, 127, 255);
- drawRect(x0-2, y0-2, rectW+4, rectH+4);
+ // left and right
+ glScissor(x0, gScreenHeight-y0-rectH, rectW, rectH);
+ e_DrawSize(idl, x0, y0, 0, true, false, wl, hl);
+ e_DrawSize(idr, x0+rectW-wr, y0, 0, true, false, wr, hr);
- glColor4ub(0, 0, 0, 255);
- drawRect(x0-1, y0-1, rectW+2, rectH+2);
+ // body
+ glScissor(x0+wl, gScreenHeight-y0-rectH, rectW-wl-wr, rectH);
+ f := x0+wl;
+ while (f < x0+rectW) do
+ begin
+ e_DrawSize(idb, f, y0, 0, true, false, wb, hb);
+ f += wb;
+ end;
- glColor4ub(127, 127, 127, 255);
- wdt := rectW*cur div total;
- if (wdt > rectW) then wdt := rectW;
- drawRect(x0, y0, wdt, rectH);
+ // filled part
+ wdt := (rectW-wl-wr)*cur div total;
+ if (wdt > rectW-wl-wr) then wdt := rectW-wr-wr;
+ if (wdt > 0) then
+ begin
+ my := y0+(rectH-wm) div 2;
+ glScissor(x0+wl, gScreenHeight-my-rectH, wdt, hm);
+ f := x0+wl;
+ while (wdt > 0) do
+ begin
+ e_DrawSize(idm, f, y0, 0, true, false, wm, hm);
+ f += wm;
+ wdt -= wm;
+ end;
+ end;
+
+ glScissor(0, 0, gScreenWidth, gScreenHeight);
+
+{
+procedure e_DrawSize(ID: DWORD; X, Y: Integer; Alpha: Byte; AlphaChannel: Boolean;
+ Blending: Boolean; Width, Height: Word; Mirror: TMirrorType = TMirrorType.None);
+ if g_Texture_Get('MENU_BACKGROUND', ID) then e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight)
+ else e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0);
+}
+ end
+ else
+ begin
+ rectW := gScreenWidth-64;
+ rectH := 16;
+
+ x0 := (gScreenWidth-rectW) div 2;
+ y0 := gScreenHeight-rectH-64;
+ if (y0 < 2) then y0 := 2;
+
+ glDisable(GL_BLEND);
+ glDisable(GL_TEXTURE_2D);
+
+ //glClearColor(0, 0, 0, 0);
+ //glClear(GL_COLOR_BUFFER_BIT);
+
+ glColor4ub(127, 127, 127, 255);
+ drawRect(x0-2, y0-2, rectW+4, rectH+4);
+
+ glColor4ub(0, 0, 0, 255);
+ drawRect(x0-1, y0-1, rectW+2, rectH+2);
+
+ glColor4ub(127, 127, 127, 255);
+ wdt := rectW*cur div total;
+ if (wdt > rectW) then wdt := rectW;
+ drawRect(x0, y0, wdt, rectH);
+ end;
end;
var
e_CharFont_PrintEx(gMenuSmallFont, xx, yy, s, _RGB(255, 0, 0));
yy := yy + LOADING_INTERLINE;
- drawPBar(CurValue, MaxValue);
+ PBarWasHere := drawPBar(CurValue, MaxValue, PBarWasHere);
end;
end;
end;
CurValue := 0;
MaxValue := Max;
ShowCount := 0;
+ PBarWasHere := false;
end;
g_ActiveWindow := nil;
for len := Low(Msgs) to High(Msgs) do
Msgs[len] := '';
NextMsg := 0;
+ PBarWasHere := false;
end;
end;
index 1e66c8ee1556ee8634b813ff8d075667b857cb65..26a06f9a2a89067c31cd9df5574ea03481ed446d 100644 (file)
--- a/src/game/g_textures.pas
+++ b/src/game/g_textures.pas
function g_Texture_CreateWADEx (const textureName, Resource: AnsiString): Boolean;
function g_Texture_CreateFileEx (const textureName, FileName: AnsiString): Boolean;
function g_Texture_Get (const textureName: AnsiString; var ID: LongWord): Boolean;
+function g_Texture_GetSize (const textureName: AnsiString; var w, h: Integer): Boolean; overload;
+function g_Texture_GetSize (ID: LongWord; var w, h: Integer): Boolean; overload;
procedure g_Texture_Delete (const textureName: AnsiString);
procedure g_Texture_DeleteAll ();
end;
+function g_Texture_GetSize (const textureName: AnsiString; var w, h: Integer): Boolean; overload;
+var
+ a: Integer;
+begin
+ result := false;
+ w := 0;
+ h := 0;
+ if (Length(texturesArray) = 0) or (Length(textureName) = 0) then exit;
+ for a := 0 to High(texturesArray) do
+ begin
+ if (StrEquCI1251(texturesArray[a].name, textureName)) then
+ begin
+ w := texturesArray[a].width;
+ h := texturesArray[a].height;
+ result := true;
+ break;
+ end;
+ end;
+end;
+
+
+function g_Texture_GetSize (ID: LongWord; var w, h: Integer): Boolean; overload;
+var
+ a: Integer;
+begin
+ result := false;
+ w := 0;
+ h := 0;
+ if (Length(texturesArray) = 0) then exit;
+ for a := 0 to High(texturesArray) do
+ begin
+ if (texturesArray[a].id = ID) then
+ begin
+ w := texturesArray[a].width;
+ h := texturesArray[a].height;
+ result := true;
+ break;
+ end;
+ end;
+end;
+
+
procedure g_Texture_Delete (const textureName: AnsiString);
var
a: Integer;