summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fa53806)
raw | patch | inline | side by side (parent: fa53806)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 13 Feb 2023 14:12:10 +0000 (17:12 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 9 Jun 2023 09:12:03 +0000 (12:12 +0300) |
20 files changed:
diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr
index f0c3a90a2bc108c090755d66697d701e8cce893b..33a069dc79288ea61dd312f8b0742dd285afe121 100644 (file)
--- a/src/game/Doom2DF.lpr
+++ b/src/game/Doom2DF.lpr
{$ENDIF}
{$IFDEF ENABLE_RENDER}
- {$IF DEFINED(USE_OPENGL) OR DEFINED(USE_GLES1) OR DEFINED(USE_GLSTUB)}
- {$I ../shared/vampimg.inc}
- r_animations in 'opengl/r_animations.pas',
- r_console in 'opengl/r_console.pas',
- r_game in 'opengl/r_game.pas',
- {$IFDEF ENABLE_GFX}
- r_gfx in 'opengl/r_gfx.pas',
- {$ENDIF}
- r_graphics in 'opengl/r_graphics.pas',
- r_items in 'opengl/r_items.pas',
- r_map in 'opengl/r_map.pas',
- r_monsters in 'opengl/r_monsters.pas',
- r_netmaster in 'opengl/r_netmaster.pas',
- r_player in 'opengl/r_player.pas',
- r_playermodel in 'opengl/r_playermodel.pas',
- r_render in 'opengl/r_render.pas',
- r_texture in 'opengl/r_texture.pas',
- r_textures in 'opengl/r_textures.pas',
- r_weapons in 'opengl/r_weapons.pas',
- r_window in 'opengl/r_window.pas',
- {$IFDEF ENABLE_TOUCH}
- r_touch in 'opengl/r_touch.pas',
- {$ENDIF}
- {$IFDEF ENABLE_MENU}
- r_gui in 'opengl/r_gui.pas',
- {$ENDIF}
- {$ELSEIF DEFINED(USE_STUBRENDER)}
+ {$IF DEFINED(USE_STUBRENDER)}
r_render in 'renders/stub/r_render.pas',
- {$ELSEIF DEFINED(USE_NEWGL)}
+ {$ELSEIF DEFINED(USE_OPENGL) OR DEFINED(USE_GLES1) OR DEFINED(USE_GLSTUB) OR DEFINED(USE_NEWGL)}
{$I ../shared/vampimg.inc}
r_render in 'renders/opengl/r_render.pas',
r_atlas in 'renders/opengl/r_atlas.pas',
diff --git a/src/game/opengl/r_animations.pas b/src/game/opengl/r_animations.pas
+++ /dev/null
@@ -1,407 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_animations;
-
-interface
-
- uses g_base, g_animations, MAPDEF, Imaging; // TMirrorType, TAnimationState, TDFPoint, TDynImageDataArray
-
- procedure r_AnimState_Draw (FID: DWORD; const t: TAnimState; x, y: Integer; alpha: Byte; mirror: TMirrorType; blending: Boolean);
- procedure r_AnimState_DrawEx (FID: DWORD; const t: TAnimState; x, y: Integer; alpha: Byte; mirror: TMirrorType; blending: Boolean; rpoint: TDFPoint; angle: SmallInt);
-
- function g_CreateFramesImg (ia: TDynImageDataArray; ID: PDWORD; const Name: AnsiString; BackAnimation: Boolean = false): Boolean;
-
- function g_Frames_CreateWAD (ID: PDWORD; const Name, Resource: AnsiString; mWidth, mHeight, mCount: Word; BackAnimation: Boolean=false): Boolean;
- function g_Frames_CreateFile (ID: PDWORD; const Name, FileName: AnsiString; mWidth, mHeight, mCount: Word; BackAnimation: Boolean = false): Boolean;
- function g_Frames_CreateMemory (ID: PDWORD; const Name: AnsiString; pData: Pointer; dataSize: LongInt; mWidth, mHeight, mCount: Word; BackAnimation: Boolean=false): Boolean;
- function g_Frames_Dup (const NewName, OldName: AnsiString): Boolean;
- function g_Frames_Get (out ID: LongWord; const FramesName: AnsiString): Boolean;
- function g_Frames_GetTexture (out ID: LongWord; const FramesName: AnsiString; Frame: Word): Boolean;
- procedure g_Frames_GetFrameSize (ID: DWORD; out w, h: Integer);
- function g_Frames_Exists (const FramesName: AnsiString): Boolean;
- procedure g_Frames_DeleteByName (const FramesName: AnsiString);
- procedure g_Frames_DeleteByID (ID: LongWord);
- procedure g_Frames_DeleteAll;
-
- type
- TFrames = record
- texturesID: array of LongWord;
- name: AnsiString;
- frameWidth, frameHeight: Word;
- used: Boolean;
- end;
-
- var
- framesArray: array of TFrames = nil;
-
-implementation
-
- uses
- SysUtils, Classes, Math,
- WadReader, utils,
- e_log,
- r_graphics,
- g_language, g_game
- ;
-
- procedure g_Frames_GetFrameSize (ID: DWORD; out w, h: Integer);
- begin
- w := 0;
- h := 0;
- if framesArray <> nil then
- begin
- w := framesArray[ID].frameWidth;
- h := framesArray[ID].frameHeight;
- end
- end;
-
- procedure r_AnimState_Draw (FID: DWORD; const t: TAnimState; x, y: Integer; alpha: Byte; mirror: TMirrorType; blending: Boolean);
- begin
- if t.enabled then
- e_DrawAdv(framesArray[FID].TexturesID[t.currentFrame], x, y, alpha, true, blending, 0, nil, mirror)
- end;
-
- procedure r_AnimState_DrawEx (FID: DWORD; const t: TAnimState; x, y: Integer; alpha: Byte; mirror: TMirrorType; blending: Boolean; rpoint: TDFPoint; angle: SmallInt);
- begin
- if t.enabled then
- e_DrawAdv(framesArray[FID].TexturesID[t.currentFrame], x, y, alpha, true, blending, angle, @rpoint, mirror)
- end;
-
-function allocFrameSlot (): LongWord;
-var
- f: integer;
-begin
- for f := 0 to High(framesArray) do
- begin
- if (not framesArray[f].used) then
- begin
- result := f;
- exit;
- end;
- end;
-
- result := Length(framesArray);
- SetLength(framesArray, result+64);
- for f := result to High(framesArray) do
- begin
- with framesArray[f] do
- begin
- texturesID := nil;
- name := '';
- frameWidth := 0;
- frameHeight := 0;
- used := false;
- end;
- end;
-end;
-
-function g_Frames_CreateFile (ID: PDWORD; const Name, FileName: AnsiString;
- mWidth, mHeight, mCount: Word; BackAnimation: Boolean = false): Boolean;
-var
- a: Integer;
- find_id: LongWord;
-begin
- result := false;
-
- find_id := allocFrameSlot();
-
- if (mCount <= 2) then BackAnimation := false;
-
- if BackAnimation then SetLength(framesArray[find_id].TexturesID, mCount+mCount-2)
- else SetLength(framesArray[find_id].TexturesID, mCount);
-
- for a := 0 to mCount-1 do
- begin
- if not e_CreateTextureEx(FileName, framesArray[find_id].TexturesID[a], a*mWidth, 0, mWidth, mHeight) then exit;
- end;
-
- if BackAnimation then
- begin
- for a := 1 to mCount-2 do framesArray[find_id].TexturesID[mCount+mCount-2-a] := framesArray[find_id].TexturesID[a];
- end;
-
- framesArray[find_id].used := true;
- framesArray[find_id].FrameWidth := mWidth;
- framesArray[find_id].FrameHeight := mHeight;
- if (Name <> '') then framesArray[find_id].Name := Name else framesArray[find_id].Name := '<noname>';
-
- if (ID <> nil) then ID^ := find_id;
-
- result := true;
-end;
-
-function CreateFramesMem (pData: Pointer; dataSize: LongInt; ID: PDWORD; Name: AnsiString;
- mWidth, mHeight, mCount: Word; BackAnimation: Boolean = false): Boolean;
-var
- find_id: LongWord;
- a: Integer;
-begin
- result := false;
-
- find_id := allocFrameSlot();
-
- if (mCount <= 2) then BackAnimation := false;
-
- if BackAnimation then SetLength(framesArray[find_id].TexturesID, mCount+mCount-2)
- else SetLength(framesArray[find_id].TexturesID, mCount);
-
- for a := 0 to mCount-1 do
- if not e_CreateTextureMemEx(pData, dataSize, framesArray[find_id].TexturesID[a], a*mWidth, 0, mWidth, mHeight) then
- begin
- //!!!FreeMem(pData);
- exit;
- end;
-
- if BackAnimation then
- begin
- for a := 1 to mCount-2 do framesArray[find_id].TexturesID[mCount+mCount-2-a] := framesArray[find_id].TexturesID[a];
- end;
-
- framesArray[find_id].used := true;
- framesArray[find_id].FrameWidth := mWidth;
- framesArray[find_id].FrameHeight := mHeight;
- if (Name <> '') then framesArray[find_id].Name := Name else framesArray[find_id].Name := '<noname>';
-
- if (ID <> nil) then ID^ := find_id;
-
- result := true;
-end;
-
-function g_CreateFramesImg (ia: TDynImageDataArray; ID: PDWORD; const Name: AnsiString; BackAnimation: Boolean = false): Boolean;
-var
- find_id: LongWord;
- a, mCount: Integer;
-begin
- result := false;
- find_id := allocFrameSlot();
-
- mCount := Length(ia);
-
- //e_WriteLog(Format('+++ creating %d frames [%s]', [FCount, Name]), MSG_NOTIFY);
-
- if (mCount < 1) then exit;
- if (mCount <= 2) then BackAnimation := false;
-
- if BackAnimation then SetLength(framesArray[find_id].TexturesID, mCount+mCount-2)
- else SetLength(framesArray[find_id].TexturesID, mCount);
-
- //e_WriteLog(Format('+++ creating %d frames, %dx%d', [FCount, ia[0].width, ia[0].height]), MSG_NOTIFY);
-
- for a := 0 to mCount-1 do
- begin
- if not e_CreateTextureImg(ia[a], framesArray[find_id].TexturesID[a]) then exit;
- //e_WriteLog(Format('+++ frame %d, %dx%d', [a, ia[a].width, ia[a].height]), MSG_NOTIFY);
- end;
-
- if BackAnimation then
- begin
- for a := 1 to mCount-2 do framesArray[find_id].TexturesID[mCount+mCount-2-a] := framesArray[find_id].TexturesID[a];
- end;
-
- framesArray[find_id].used := true;
- framesArray[find_id].FrameWidth := ia[0].width;
- framesArray[find_id].FrameHeight := ia[0].height;
- if (Name <> '') then framesArray[find_id].Name := Name else framesArray[find_id].Name := '<noname>';
-
- if (ID <> nil) then ID^ := find_id;
-
- result := true;
-end;
-
-function g_Frames_CreateWAD (ID: PDWORD; const Name, Resource: AnsiString;
- mWidth, mHeight, mCount: Word; BackAnimation: Boolean=false): Boolean;
-var
- WAD: TWADFile;
- FileName: AnsiString;
- TextureData: Pointer;
- ResourceLength: Integer;
-begin
- result := false;
-
- // models without "advanced" animations asks for "nothing" like this; don't spam log
- if (Length(Resource) > 0) and ((Resource[Length(Resource)] = '/') or (Resource[Length(Resource)] = '\')) then exit;
-
- FileName := g_ExtractWadName(Resource);
-
- WAD := TWADFile.Create();
- WAD.ReadFile(FileName);
-
- if not WAD.GetResource(g_ExtractFilePathName(Resource), TextureData, ResourceLength) then
- begin
- WAD.Free();
- e_WriteLog(Format('Error loading texture %s', [Resource]), TMsgType.Warning);
- //e_WriteLog(Format('WAD Reader error: %s', [WAD.GetLastErrorStr]), MSG_WARNING);
- exit;
- end;
-
- if not CreateFramesMem(TextureData, ResourceLength, ID, Name, mWidth, mHeight, mCount, BackAnimation) then
- begin
- FreeMem(TextureData);
- WAD.Free();
- exit;
- end;
-
- FreeMem(TextureData);
- WAD.Free();
-
- result := true;
-end;
-
-function g_Frames_CreateMemory (ID: PDWORD; const Name: AnsiString; pData: Pointer; dataSize: LongInt;
- mWidth, mHeight, mCount: Word; BackAnimation: Boolean = false): Boolean;
-begin
- result := CreateFramesMem(pData, dataSize, ID, Name, mWidth, mHeight, mCount, BackAnimation);
-end;
-
-function g_Frames_Dup (const NewName, OldName: AnsiString): Boolean;
-var
- find_id, b: LongWord;
- a, c: Integer;
-begin
- result := false;
-
- if not g_Frames_Get(b, OldName) then exit;
-
- find_id := allocFrameSlot();
-
- framesArray[find_id].used := true;
- framesArray[find_id].Name := NewName;
- framesArray[find_id].FrameWidth := framesArray[b].FrameWidth;
- framesArray[find_id].FrameHeight := framesArray[b].FrameHeight;
-
- c := High(framesArray[b].TexturesID);
- SetLength(framesArray[find_id].TexturesID, c+1);
-
- for a := 0 to c do framesArray[find_id].TexturesID[a] := framesArray[b].TexturesID[a];
-
- result := true;
-end;
-
-
-procedure g_Frames_DeleteByName (const FramesName: AnsiString);
-var
- a, b: Integer;
-begin
- if (Length(framesArray) = 0) then exit;
- for a := 0 to High(framesArray) do
- begin
- if (StrEquCI1251(framesArray[a].Name, FramesName)) then
- begin
- if framesArray[a].TexturesID <> nil then
- begin
- for b := 0 to High(framesArray[a].TexturesID) do e_DeleteTexture(framesArray[a].TexturesID[b]);
- end;
- framesArray[a].used := false;
- framesArray[a].TexturesID := nil;
- framesArray[a].Name := '';
- framesArray[a].FrameWidth := 0;
- framesArray[a].FrameHeight := 0;
- end;
- end;
-end;
-
-procedure g_Frames_DeleteByID (ID: LongWord);
-var
- b: Integer;
-begin
- if (Length(framesArray) = 0) then exit;
- if (framesArray[ID].TexturesID <> nil) then
- begin
- for b := 0 to High(framesArray[ID].TexturesID) do e_DeleteTexture(framesArray[ID].TexturesID[b]);
- end;
- framesArray[ID].used := false;
- framesArray[ID].TexturesID := nil;
- framesArray[ID].Name := '';
- framesArray[ID].FrameWidth := 0;
- framesArray[ID].FrameHeight := 0;
-end;
-
-procedure g_Frames_DeleteAll ();
-var
- a, b: Integer;
-begin
- for a := 0 to High(framesArray) do
- begin
- if (framesArray[a].used) then
- begin
- for b := 0 to High(framesArray[a].TexturesID) do e_DeleteTexture(framesArray[a].TexturesID[b]);
- end;
- framesArray[a].used := false;
- framesArray[a].TexturesID := nil;
- framesArray[a].Name := '';
- framesArray[a].FrameWidth := 0;
- framesArray[a].FrameHeight := 0;
- end;
- framesArray := nil;
-end;
-
-
-function g_Frames_Get (out ID: LongWord; const FramesName: AnsiString): Boolean;
-var
- a: Integer;
-begin
- result := false;
- if (Length(framesArray) = 0) then exit;
- for a := 0 to High(framesArray) do
- begin
- if (StrEquCI1251(framesArray[a].Name, FramesName)) then
- begin
- ID := a;
- result := true;
- break;
- end;
- end;
- if not result then g_FatalError(Format(_lc[I_GAME_ERROR_FRAMES], [FramesName]));
-end;
-
-function g_Frames_GetTexture (out ID: LongWord; const FramesName: AnsiString; Frame: Word): Boolean;
-var
- a: Integer;
-begin
- result := false;
- if (Length(framesArray) = 0) then exit;
- for a := 0 to High(framesArray) do
- begin
- if (StrEquCI1251(framesArray[a].Name, FramesName)) then
- begin
- if (Frame < Length(framesArray[a].TexturesID)) then
- begin
- ID := framesArray[a].TexturesID[Frame];
- result := true;
- break;
- end;
- end;
- end;
- if not result then g_FatalError(Format(_lc[I_GAME_ERROR_FRAMES], [FramesName]));
-end;
-
-function g_Frames_Exists (const FramesName: AnsiString): Boolean;
-var
- a: Integer;
-begin
- result := false;
- if (Length(framesArray) = 0) then exit;
- for a := 0 to High(framesArray) do
- begin
- if (StrEquCI1251(framesArray[a].Name, FramesName)) then
- begin
- result := true;
- exit;
- end;
- end;
-end;
-
-end.
diff --git a/src/game/opengl/r_console.pas b/src/game/opengl/r_console.pas
+++ /dev/null
@@ -1,217 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_console;
-
-interface
-
- procedure r_Console_Init;
- procedure r_Console_Update;
- procedure r_Console_Draw (MessagesOnly: Boolean = False);
-
-implementation
-
- uses
- {$IFDEF ENABLE_MENU}
- g_menu,
- {$ENDIF}
- SysUtils, Classes, Math,
- e_log, r_graphics, g_options, r_textures, r_game,
- conbuf,
- g_base, g_console, g_game
- ;
-
-(* ====== Console ====== *)
-
-const
- DEBUG_STRING = 'DEBUG MODE';
-
-var
- ID: DWORD;
- ConsoleTrans: Single;
- ChatTop: BOOLEAN;
-
- Cons_Y: SmallInt;
- ConsoleHeight: Single;
- ConsoleStep: Single;
- Cons_Shown: Boolean; // draw console
-
-procedure drawConsoleText ();
-var
- CWidth, CHeight: Byte;
- ty: Integer;
- sp, ep: LongWord;
- skip: Integer;
-
- procedure putLine (sp, ep: LongWord);
- var
- p: LongWord;
- wdt, cw: Integer;
- begin
- p := sp;
- wdt := 0;
- while p <> ep do
- begin
- cw := e_TextureFontCharWidth(cbufAt(p), gStdFont);
- if wdt+cw > gScreenWidth-8 then break;
- //e_TextureFontPrintChar(X, Y: Integer; Ch: Char; FontID: DWORD; Shadow: Boolean = False);
- Inc(wdt, cw);
- cbufNext(p);
- end;
- if p <> ep then putLine(p, ep); // do rest of the line first
- // now print our part
- if skip = 0 then
- begin
- ep := p;
- p := sp;
- wdt := 2;
- while p <> ep do
- begin
- cw := e_TextureFontCharWidth(cbufAt(p), gStdFont);
- e_TextureFontPrintCharEx(wdt, ty, cbufAt(p), gStdFont);
- Inc(wdt, cw);
- cbufNext(p);
- end;
- Dec(ty, CHeight);
- end
- else
- begin
- Dec(skip);
- end;
- end;
-
-begin
- e_TextureFontGetSize(gStdFont, CWidth, CHeight);
- ty := Floor(gScreenHeight * ConsoleHeight) - 4 - 2 * CHeight - Abs(Cons_Y);
- skip := conSkipLines;
- cbufLastLine(sp, ep);
- repeat
- putLine(sp, ep);
- if ty+CHeight <= 0 then break;
- until not cbufLineUp(sp, ep);
-end;
-
-procedure r_Console_Draw (MessagesOnly: Boolean = False);
-var
- CWidth, CHeight: Byte;
- mfW, mfH: Word;
- a, b, offset_y: Integer;
-begin
- e_TextureFontGetSize(gStdFont, CWidth, CHeight);
-
- if ChatTop and gChatShow then
- offset_y := CHeight
- else
- offset_y := 0;
-
- for a := 0 to High(MsgArray) do
- if MsgArray[a].Time > 0 then
- e_TextureFontPrintFmt(0, offset_y + CHeight * a, MsgArray[a].Msg, gStdFont, True);
-
- if MessagesOnly then Exit;
-
- if gChatShow then
- begin
- if ChatTop then
- offset_y := 0
- else
- offset_y := gScreenHeight - CHeight - 1;
- if gChatTeam then
- begin
- e_TextureFontPrintEx(0, offset_y, 'say team> ' + Line, gStdFont, 255, 255, 255, 1, True);
- e_TextureFontPrintEx((CPos + 9) * CWidth, offset_y, '_', gStdFont, 255, 255, 255, 1, True);
- end
- else
- begin
- e_TextureFontPrintEx(0, offset_y, 'say> ' + Line, gStdFont, 255, 255, 255, 1, True);
- e_TextureFontPrintEx((CPos + 4) * CWidth, offset_y, '_', gStdFont, 255, 255, 255, 1, True);
- end
- end;
-
- if not Cons_Shown then
- Exit;
-
- if gDebugMode then
- begin
- e_CharFont_GetSize(gMenuFont, DEBUG_STRING, mfW, mfH);
- a := (gScreenWidth - 2*mfW) div 2;
- b := Cons_Y + (Floor(gScreenHeight * ConsoleHeight) - 2 * mfH) div 2;
- e_CharFont_PrintEx(gMenuFont, a div 2, b div 2, DEBUG_STRING,
- _RGB(128, 0, 0), 2.0);
- end;
-
- e_DrawSize(ID, 0, Cons_Y, Round(ConsoleTrans * 255), False, False, gScreenWidth, Floor(gScreenHeight * ConsoleHeight));
- e_TextureFontPrint(0, Cons_Y + Floor(gScreenHeight * ConsoleHeight) - CHeight - 4, '> ' + Line, gStdFont);
-
- drawConsoleText();
- (*
- if ConsoleHistory <> nil then
- begin
- b := 0;
- if CHeight > 0 then
- if Length(ConsoleHistory) > (Floor(gScreenHeight * ConsoleHeight) div CHeight) - 1 then
- b := Length(ConsoleHistory) - (Floor(gScreenHeight * ConsoleHeight) div CHeight) + 1;
-
- b := Max(b-Offset, 0);
- d := Max(High(ConsoleHistory)-Offset, 0);
-
- c := 2;
- for a := d downto b do
- begin
- e_TextureFontPrintFmt(0, Floor(gScreenHeight * ConsoleHeight) - 4 - c * CHeight - Abs(Cons_Y), ConsoleHistory[a], gStdFont, True);
- c := c + 1;
- end;
- end;
- *)
-
- e_TextureFontPrint((CPos + 1) * CWidth, Cons_Y + Floor(gScreenHeight * ConsoleHeight) - 21, '_', gStdFont);
-end;
-
- procedure r_Console_Update;
- var step, miny: Integer;
- begin
- step := Max(1, Round(Floor(gScreenHeight * ConsoleHeight) * ConsoleStep));
- miny := Round(-Floor(gScreenHeight * ConsoleHeight));
- if gConsoleShow then
- Cons_Y := Cons_Y + step
- else
- Cons_Y := Cons_Y - step;
- Cons_Y := Min(Max(Cons_Y, miny), 0);
- Cons_Shown := Cons_Y > miny;
- end;
-
- procedure r_Console_Init;
- var miny: Integer;
- begin
- g_Texture_CreateWAD(ID, GameWAD + ':TEXTURES\CONSOLE');
- miny := Round(-Floor(gScreenHeight * ConsoleHeight));
- Cons_Y := miny;
- end;
-
-initialization
- conRegVar('chat_at_top', @ChatTop, 'draw chat at top border', 'draw chat at top border');
- conRegVar('console_height', @ConsoleHeight, 0.0, 1.0, 'set console size', 'set console size');
- conRegVar('console_step', @ConsoleStep, 0.0, 1.0, 'set console animation speed', 'set console animation speed');
- conRegVar('console_trans', @ConsoleTrans, 0.0, 1.0, 'set console transparency', 'set console transparency');
-{$IFDEF ANDROID}
- ChatTop := True;
- ConsoleHeight := 0.35;
-{$ELSE}
- ChatTop := False;
- ConsoleHeight := 0.5;
-{$ENDIF}
- ConsoleStep := 0.07;
- ConsoleTrans := 0.1;
-end.
diff --git a/src/game/opengl/r_game.pas b/src/game/opengl/r_game.pas
+++ /dev/null
@@ -1,2206 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_game;
-
-interface
-
- procedure r_Game_Load;
- procedure r_Game_Free;
-
- procedure r_Game_LoadTextures;
- procedure r_Game_FreeTextures;
-
- procedure r_Game_Draw;
- procedure r_Game_DrawLoadingStat;
- procedure r_Game_DrawMenuBackground (tex: AnsiString);
-
- procedure r_Game_SetupScreenSize;
-
- var
- gStdFont: DWORD;
- gMenuFont: DWORD;
- gMenuSmallFont: DWORD;
-
-implementation
-
- uses
- {$INCLUDE ../nogl/noGLuses.inc}
- {$IFDEF ENABLE_HOLMES}
- g_holmes,
- {$ENDIF}
- {$IFDEF ENABLE_MENU}
- g_gui, g_menu, r_gui,
- {$ENDIF}
- {$IFDEF ENABLE_GFX}
- g_gfx, r_gfx,
- {$ENDIF}
- {$IFDEF ENABLE_CORPSES}
- g_corpses,
- {$ENDIF}
- {$IFDEF ENABLE_SYSTEM}
- g_system,
- {$ENDIF}
- SysUtils, Classes, Math,
- g_base, g_basic, r_graphics,
- MAPDEF, xprofiler, utils, wadreader, CONFIG,
- e_input, e_sound,
- g_language, g_console, g_triggers, g_player, g_options, g_monsters, g_map, g_panel,
- g_items, g_weapons, g_phys, g_net, g_netmaster,
- g_game, r_console, r_items, r_map, r_monsters, r_weapons, r_netmaster, r_player, r_textures,
- r_playermodel
- ;
-
- var
- profileFrameDraw: TProfiler = nil;
-
- FPS: Word;
- FPSCounter: Word;
- FPSTime: LongWord;
- hasPBarGfx: Boolean;
-
- BackID: DWORD = DWORD(-1);
- gBackSize: TDFPoint;
-
-procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
-var
- cwdt, chgt: Byte;
- spc: ShortInt;
- ID: DWORD;
- wad: TWADFile;
- cfgdata: Pointer;
- cfglen: Integer;
- config: TConfig;
-begin
- cfglen := 0;
-
- wad := TWADFile.Create;
- if wad.ReadFile(GameWAD) then
- wad.GetResource('FONTS/'+cfgres, cfgdata, cfglen);
- wad.Free();
-
- if cfglen <> 0 then
- begin
- g_Texture_CreateWADEx('FONT_STD', GameWAD+':FONTS\'+texture);
-
- config := TConfig.CreateMem(cfgdata, cfglen);
- cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
- chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
- spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
-
- if g_Texture_Get('FONT_STD', ID) then
- e_TextureFontBuild(ID, FontID, cwdt, chgt, spc);
-
- config.Free();
- end;
-
- if cfglen <> 0 then FreeMem(cfgdata);
-end;
-
-procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
-var
- cwdt, chgt: Byte;
- spc: ShortInt;
- CharID: DWORD;
- wad: TWADFile;
- cfgdata, fntdata: Pointer;
- cfglen, fntlen: Integer;
- config: TConfig;
- chrwidth: Integer;
- a: Byte;
-begin
- cfglen := 0;
- fntlen := 0;
-
- wad := TWADFile.Create;
- if wad.ReadFile(GameWAD) then
- begin
- wad.GetResource('FONTS/'+txtres, cfgdata, cfglen);
- wad.GetResource('FONTS/'+fntres, fntdata, fntlen);
- end;
- wad.Free();
-
- if cfglen <> 0 then
- begin
- config := TConfig.CreateMem(cfgdata, cfglen);
- cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
- chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
-
- spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
- FontID := e_CharFont_Create(spc);
-
- for a := 0 to 255 do
- begin
- chrwidth := config.ReadInt(IntToStr(a), 'Width', 0);
- if chrwidth = 0 then Continue;
-
- if e_CreateTextureMemEx(fntdata, fntlen, CharID, cwdt*(a mod 16), chgt*(a div 16),
- cwdt, chgt) then
- e_CharFont_AddChar(FontID, CharID, Chr(a), chrwidth);
- end;
-
- config.Free();
- end;
-
- if cfglen <> 0 then FreeMem(cfgdata);
- if fntlen <> 0 then FreeMem(fntdata);
-end;
-
- procedure r_Game_Load;
- var
- wl, hl: Integer;
- wr, hr: Integer;
- wb, hb: Integer;
- wm, hm: Integer;
- begin
- // early load
- g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD + ':TEXTURES\TITLE', gTextureFilter);
- g_Texture_CreateWADEx('INTER', GameWAD + ':TEXTURES\INTER', gTextureFilter);
- g_Texture_CreateWADEx('ENDGAME_EN', GameWAD + ':TEXTURES\ENDGAME_EN', gTextureFilter);
- g_Texture_CreateWADEx('ENDGAME_RU', GameWAD + ':TEXTURES\ENDGAME_RU', gTextureFilter);
- LoadStdFont('STDTXT', 'STDFONT', gStdFont);
- LoadFont('MENUTXT', 'MENUFONT', gMenuFont);
- LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont);
- // game data
- g_Texture_CreateWADEx('NOTEXTURE', GameWAD + ':TEXTURES\NOTEXTURE');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD + ':TEXTURES\HUD');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD + ':TEXTURES\AIRBAR');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD + ':TEXTURES\JETBAR');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD + ':TEXTURES\HUDBG');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD + ':TEXTURES\ARMORHUD');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD + ':TEXTURES\FLAGHUD_R_BASE');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD + ':TEXTURES\FLAGHUD_R_STOLEN');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD + ':TEXTURES\FLAGHUD_R_DROP');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD + ':TEXTURES\FLAGHUD_B_BASE');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD + ':TEXTURES\FLAGHUD_B_STOLEN');
- 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');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD + ':TEXTURES\PLRIND');
- // bar
- 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
- hasPBarGfx := false;
- end;
- end;
-
- procedure r_Game_Free;
- begin
- e_CharFont_Remove(gMenuFont);
- e_CharFont_Remove(gMenuSmallFont);
- g_Texture_Delete('NOTEXTURE');
- g_Texture_Delete('TEXTURE_PLAYER_HUD');
- g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
- g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
- g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
- g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
- g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
- g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
- g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
- g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
- g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
- g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
- end;
-
-procedure r_Game_SetupScreenSize;
-const
- RES_FACTOR = 4.0 / 3.0;
-var
- s: Single;
- rf: Single;
- bw, bh: Word;
-begin
-// Размер экранов игроков:
- gPlayerScreenSize.X := gScreenWidth-196;
- if (gPlayer1 <> nil) and (gPlayer2 <> nil) then
- gPlayerScreenSize.Y := gScreenHeight div 2
- else
- gPlayerScreenSize.Y := gScreenHeight;
-
-// Размер заднего плана:
- if BackID <> DWORD(-1) then
- begin
- s := SKY_STRETCH;
- if (gScreenWidth*s > gMapInfo.Width) or
- (gScreenHeight*s > gMapInfo.Height) then
- begin
- gBackSize.X := gScreenWidth;
- gBackSize.Y := gScreenHeight;
- end
- else
- begin
- e_GetTextureSize(BackID, @bw, @bh);
- rf := Single(bw) / Single(bh);
- if (rf > RES_FACTOR) then bw := Round(Single(bh) * RES_FACTOR)
- else if (rf < RES_FACTOR) then bh := Round(Single(bw) / RES_FACTOR);
- s := Max(gScreenWidth / bw, gScreenHeight / bh);
- if (s < 1.0) then s := 1.0;
- gBackSize.X := Round(bw*s);
- gBackSize.Y := Round(bh*s);
- end;
- end;
-end;
-
- procedure r_Game_LoadTextures;
- begin
- g_Texture_CreateWADEx('TEXTURE_endpic', EndPicPath, gTextureFilter);
- if gMapInfo.SkyFullName <> '' then
- g_Texture_CreateWAD(BackID, gMapInfo.SkyFullName, gTextureFilter);
- r_Game_SetupScreenSize;
- end;
-
- procedure r_Game_FreeTextures;
- begin
- g_Texture_Delete('TEXTURE_endpic');
- if BackID <> DWORD(-1) then
- begin
- gBackSize.X := 0;
- gBackSize.Y := 0;
- e_DeleteTexture(BackID);
- BackID := DWORD(-1);
- end
- end;
-
-procedure r_Map_DrawBack(dx, dy: Integer);
-begin
- if gDrawBackGround and (BackID <> DWORD(-1)) then
- e_DrawSize(BackID, dx, dy, 0, False, False, gBackSize.X, gBackSize.Y)
- else
- e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0);
-end;
-
-function GetActivePlayer_ByID(ID: Integer): TPlayer;
-var
- a: Integer;
-begin
- Result := nil;
- if ID < 0 then
- Exit;
- if gPlayers = nil then
- Exit;
- for a := Low(gPlayers) to High(gPlayers) do
- if IsActivePlayer(gPlayers[a]) then
- begin
- if gPlayers[a].UID <> ID then
- continue;
- Result := gPlayers[a];
- break;
- end;
-end;
-
-function calcProfilesHeight (prof: TProfiler): Integer;
-begin
- result := 0;
- if (prof = nil) then exit;
- if (length(prof.bars) = 0) then exit;
- result := length(prof.bars)*(16+2);
-end;
-
-// returns width
-function drawProfiles (x, y: Integer; prof: TProfiler): Integer;
-var
- wdt, hgt: Integer;
- yy: Integer;
- ii: Integer;
-begin
- result := 0;
- if (prof = nil) then exit;
- // gScreenWidth
- if (length(prof.bars) = 0) then exit;
- wdt := 192;
- hgt := calcProfilesHeight(prof);
- if (x < 0) then x := gScreenWidth-(wdt-1)+x;
- if (y < 0) then y := gScreenHeight-(hgt-1)+y;
- // background
- //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
- //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
- e_DarkenQuadWH(x, y, wdt, hgt, 150);
- // title
- yy := y+2;
- for ii := 0 to High(prof.bars) do
- begin
- e_TextureFontPrintEx(x+2+4*prof.bars[ii].level, yy, Format('%s: %d', [prof.bars[ii].name, prof.bars[ii].value]), gStdFont, 255, 255, 0, 1, false);
- Inc(yy, 16+2);
- end;
- result := wdt;
-end;
-
-procedure drawTime(X, Y: Integer); inline;
-begin
- e_TextureFontPrint(x, y, Format('%d:%.2d:%.2d', [gTime div 1000 div 3600, (gTime div 1000 div 60) mod 60, gTime div 1000 mod 60]), gStdFont);
-end;
-
-procedure DrawStat();
-var
- pc, x, y, w, h: Integer;
- w1, w2, w3, w4: Integer;
- a, aa: Integer;
- cw, ch, r, g, b, rr, gg, bb: Byte;
- s1, s2, s3: String;
- _y: Integer;
- stat: TPlayerStatArray;
- wad, map: string;
- mapstr: string;
- namestr: string;
-begin
- s1 := '';
- s2 := '';
- s3 := '';
- pc := g_Player_GetCount;
- e_TextureFontGetSize(gStdFont, cw, ch);
-
- w := gScreenWidth-(gScreenWidth div 5);
- if gGameSettings.GameMode in [GM_TDM, GM_CTF] then
- h := 32+ch*(11+pc)
- else
- h := 40+ch*5+(ch+8)*pc;
- x := (gScreenWidth div 2)-(w div 2);
- y := (gScreenHeight div 2)-(h div 2);
-
- e_DrawFillQuad(x, y, x+w-1, y+h-1, 64, 64, 64, 32);
- e_DrawQuad(x, y, x+w-1, y+h-1, 255, 127, 0);
-
- drawTime(x+w-78, y+8);
-
- wad := g_ExtractWadNameNoPath(gMapInfo.Map);
- map := g_ExtractFileName(gMapInfo.Map);
- mapstr := wad + ':\' + map + ' - ' + gMapInfo.Name;
-
- case gGameSettings.GameMode of
- GM_DM:
- begin
- if gGameSettings.MaxLives = 0 then
- s1 := _lc[I_GAME_DM]
- else
- s1 := _lc[I_GAME_LMS];
- s2 := Format(_lc[I_GAME_FRAG_LIMIT], [gGameSettings.ScoreLimit]);
- s3 := Format(_lc[I_GAME_TIME_LIMIT], [gGameSettings.TimeLimit div 3600, (gGameSettings.TimeLimit div 60) mod 60, gGameSettings.TimeLimit mod 60]);
- end;
-
- GM_TDM:
- begin
- if gGameSettings.MaxLives = 0 then
- s1 := _lc[I_GAME_TDM]
- else
- s1 := _lc[I_GAME_TLMS];
- s2 := Format(_lc[I_GAME_FRAG_LIMIT], [gGameSettings.ScoreLimit]);
- s3 := Format(_lc[I_GAME_TIME_LIMIT], [gGameSettings.TimeLimit div 3600, (gGameSettings.TimeLimit div 60) mod 60, gGameSettings.TimeLimit mod 60]);
- end;
-
- GM_CTF:
- begin
- s1 := _lc[I_GAME_CTF];
- s2 := Format(_lc[I_GAME_SCORE_LIMIT], [gGameSettings.ScoreLimit]);
- s3 := Format(_lc[I_GAME_TIME_LIMIT], [gGameSettings.TimeLimit div 3600, (gGameSettings.TimeLimit div 60) mod 60, gGameSettings.TimeLimit mod 60]);
- end;
-
- GM_COOP:
- begin
- if gGameSettings.MaxLives = 0 then
- s1 := _lc[I_GAME_COOP]
- else
- s1 := _lc[I_GAME_SURV];
- s2 := _lc[I_GAME_MONSTERS] + ' ' + IntToStr(gCoopMonstersKilled) + '/' + IntToStr(gTotalMonsters);
- s3 := _lc[I_GAME_SECRETS] + ' ' + IntToStr(gCoopSecretsFound) + '/' + IntToStr(gSecretsCount);
- end;
-
- else
- begin
- s1 := '';
- s2 := '';
- end;
- end;
- _y := y+8;
- e_TextureFontPrintEx(x+(w div 2)-(Length(s1)*cw div 2), _y, s1, gStdFont, 255, 255, 255, 1);
- _y := _y+ch+8;
- e_TextureFontPrintEx(x+(w div 2)-(Length(mapstr)*cw div 2), _y, mapstr, gStdFont, 200, 200, 200, 1);
- _y := _y+ch+8;
- e_TextureFontPrintEx(x+16, _y, s2, gStdFont, 200, 200, 200, 1);
-
- e_TextureFontPrintEx(x+w-16-(Length(s3))*cw, _y, s3,
- gStdFont, 200, 200, 200, 1);
-
- if NetMode = NET_SERVER then
- e_TextureFontPrintEx(x+8, y + 8, _lc[I_NET_SERVER], gStdFont, 255, 255, 255, 1)
- else
- if NetMode = NET_CLIENT then
- e_TextureFontPrintEx(x+8, y + 8,
- NetClientIP + ':' + IntToStr(NetClientPort), gStdFont, 255, 255, 255, 1);
-
- if pc = 0 then
- Exit;
- stat := g_Player_GetStats();
- SortGameStat(stat);
-
- w2 := (w-16) div 6 + 48; // ширина 2 столбца
- w3 := (w-16) div 6; // ширина 3 и 4 столбцов
- w4 := w3;
- w1 := w-16-w2-w3-w4; // оставшееся пространство - для цвета и имени игрока
-
- if gGameSettings.GameMode in [GM_TDM, GM_CTF] then
- begin
- _y := _y+ch+ch;
-
- for a := TEAM_RED to TEAM_BLUE do
- begin
- if a = TEAM_RED then
- begin
- s1 := _lc[I_GAME_TEAM_RED];
- r := 255;
- g := 0;
- b := 0;
- end
- else
- begin
- s1 := _lc[I_GAME_TEAM_BLUE];
- r := 0;
- g := 0;
- b := 255;
- end;
-
- e_TextureFontPrintEx(x+16, _y, s1, gStdFont, r, g, b, 1);
- e_TextureFontPrintEx(x+w1+16, _y, IntToStr(gTeamStat[a].Score),
- gStdFont, r, g, b, 1);
-
- _y := _y+ch+(ch div 4);
- e_DrawLine(1, x+16, _y, x+w-16, _y, r, g, b);
- _y := _y+(ch div 4);
-
- for aa := 0 to High(stat) do
- if stat[aa].Team = a then
- with stat[aa] do
- begin
- if Spectator then
- begin
- rr := r div 2;
- gg := g div 2;
- bb := b div 2;
- end
- else
- begin
- rr := r;
- gg := g;
- bb := b;
- end;
- if gShowPIDs then
- namestr := Format('[%5d] %s', [UID, Name])
- else
- namestr := Name;
- // Имя
- e_TextureFontPrintEx(x+16, _y, namestr, gStdFont, rr, gg, bb, 1);
- // Пинг/потери
- e_TextureFontPrintEx(x+w1+16, _y, Format(_lc[I_GAME_PING_MS], [Ping, Loss]), gStdFont, rr, gg, bb, 1);
- // Фраги
- e_TextureFontPrintEx(x+w1+w2+16, _y, IntToStr(Frags), gStdFont, rr, gg, bb, 1);
- // Смерти
- e_TextureFontPrintEx(x+w1+w2+w3+16, _y, IntToStr(Deaths), gStdFont, rr, gg, bb, 1);
- _y := _y+ch;
- end;
-
- _y := _y+ch;
- end;
- end
- else if gGameSettings.GameMode in [GM_DM, GM_COOP] then
- begin
- _y := _y+ch+ch;
- e_TextureFontPrintEx(x+16, _y, _lc[I_GAME_PLAYER_NAME], gStdFont, 255, 127, 0, 1);
- e_TextureFontPrintEx(x+16+w1, _y, _lc[I_GAME_PING], gStdFont, 255, 127, 0, 1);
- e_TextureFontPrintEx(x+16+w1+w2, _y, _lc[I_GAME_FRAGS], gStdFont, 255, 127, 0, 1);
- e_TextureFontPrintEx(x+16+w1+w2+w3, _y, _lc[I_GAME_DEATHS], gStdFont, 255, 127, 0, 1);
-
- _y := _y+ch+8;
- for aa := 0 to High(stat) do
- with stat[aa] do
- begin
- if Spectator then
- begin
- r := 127;
- g := 64;
- end
- else
- begin
- r := 255;
- g := 127;
- end;
- if gShowPIDs then
- namestr := Format('[%5d] %s', [UID, Name])
- else
- namestr := Name;
- // Цвет игрока
- e_DrawFillQuad(x+16, _y+4, x+32-1, _y+16+4-1, Color.R, Color.G, Color.B, 0);
- e_DrawQuad(x+16, _y+4, x+32-1, _y+16+4-1, 192, 192, 192);
- // Имя
- e_TextureFontPrintEx(x+16+16+8, _y+4, namestr, gStdFont, r, g, 0, 1);
- // Пинг/потери
- e_TextureFontPrintEx(x+w1+16, _y+4, Format(_lc[I_GAME_PING_MS], [Ping, Loss]), gStdFont, r, g, 0, 1);
- // Фраги
- e_TextureFontPrintEx(x+w1+w2+16, _y+4, IntToStr(Frags), gStdFont, r, g, 0, 1);
- // Смерти
- e_TextureFontPrintEx(x+w1+w2+w3+16, _y+4, IntToStr(Deaths), gStdFont, r, g, 0, 1);
- _y := _y+ch+8;
- end;
- end
-end;
-
-procedure DrawCustomStat();
-var
- pc, x, y, w, _y,
- w1, w2, w3,
- t, p, m: Integer;
- ww1, hh1: Word;
- ww2, hh2, r, g, b, rr, gg, bb: Byte;
- s1, s2, topstr: String;
-begin
- e_TextureFontGetSize(gStdFont, ww2, hh2);
-
- {$IFDEF ENABLE_SYSTEM}
- sys_HandleInput;
- {$ENDIF}
-
- if g_Console_Action(ACTION_SCORES) then
- begin
- if not gStatsPressed then
- begin
- gStatsOff := not gStatsOff;
- gStatsPressed := True;
- end;
- end
- else
- gStatsPressed := False;
-
- if gStatsOff then
- begin
- s1 := _lc[I_MENU_INTER_NOTICE_TAB];
- w := (Length(s1) * ww2) div 2;
- x := gScreenWidth div 2 - w;
- y := 8;
- e_TextureFontPrint(x, y, s1, gStdFont);
- Exit;
- end;
-
- if (gGameSettings.GameMode = GM_COOP) then
- begin
- if gMissionFailed then
- topstr := _lc[I_MENU_INTER_MISSION_FAIL]
- else
- topstr := _lc[I_MENU_INTER_LEVEL_COMPLETE];
- end
- else
- topstr := _lc[I_MENU_INTER_ROUND_OVER];
-
- e_CharFont_GetSize(gMenuFont, topstr, ww1, hh1);
- e_CharFont_Print(gMenuFont, (gScreenWidth div 2)-(ww1 div 2), 16, topstr);
-
- if g_Game_IsNet then
- begin
- topstr := Format(_lc[I_MENU_INTER_NOTICE_TIME], [gServInterTime]);
- if not gChatShow then
- e_TextureFontPrintEx((gScreenWidth div 2)-(Length(topstr)*ww2 div 2),
- gScreenHeight-(hh2+4)*2, topstr, gStdFont, 255, 255, 255, 1);
- end;
-
- if g_Game_IsClient then
- topstr := _lc[I_MENU_INTER_NOTICE_MAP]
- else
- topstr := _lc[I_MENU_INTER_NOTICE_SPACE];
- if not gChatShow then
- e_TextureFontPrintEx((gScreenWidth div 2)-(Length(topstr)*ww2 div 2),
- gScreenHeight-(hh2+4), topstr, gStdFont, 255, 255, 255, 1);
-
- x := 32;
- y := 16+hh1+16;
-
- w := gScreenWidth-x*2;
-
- w2 := (w-16) div 6;
- w3 := w2;
- w1 := w-16-w2-w3;
-
- e_DrawFillQuad(x, y, gScreenWidth-x-1, gScreenHeight-y-1, 64, 64, 64, 32);
- e_DrawQuad(x, y, gScreenWidth-x-1, gScreenHeight-y-1, 255, 127, 0);
-
- m := Max(Length(_lc[I_MENU_MAP])+1, Length(_lc[I_GAME_GAME_TIME])+1)*ww2;
-
- case CustomStat.GameMode of
- GM_DM:
- begin
- if gGameSettings.MaxLives = 0 then
- s1 := _lc[I_GAME_DM]
- else
- s1 := _lc[I_GAME_LMS];
- end;
- GM_TDM:
- begin
- if gGameSettings.MaxLives = 0 then
- s1 := _lc[I_GAME_TDM]
- else
- s1 := _lc[I_GAME_TLMS];
- end;
- GM_CTF: s1 := _lc[I_GAME_CTF];
- GM_COOP:
- begin
- if gGameSettings.MaxLives = 0 then
- s1 := _lc[I_GAME_COOP]
- else
- s1 := _lc[I_GAME_SURV];
- end;
- else s1 := '';
- end;
-
- _y := y+16;
- e_TextureFontPrintEx(x+(w div 2)-(Length(s1)*ww2 div 2), _y, s1, gStdFont, 255, 255, 255, 1);
- _y := _y+8;
-
- _y := _y+16;
- e_TextureFontPrintEx(x+8, _y, _lc[I_MENU_MAP], gStdFont, 255, 127, 0, 1);
- e_TextureFontPrint(x+8+m, _y, Format('%s - %s', [CustomStat.Map, CustomStat.MapName]), gStdFont);
-
- _y := _y+16;
- e_TextureFontPrintEx(x+8, _y, _lc[I_GAME_GAME_TIME], gStdFont, 255, 127, 0, 1);
- e_TextureFontPrint(x+8+m, _y, Format('%d:%.2d:%.2d', [CustomStat.GameTime div 1000 div 3600,
- (CustomStat.GameTime div 1000 div 60) mod 60,
- CustomStat.GameTime div 1000 mod 60]), gStdFont);
-
- pc := Length(CustomStat.PlayerStat);
- if pc = 0 then Exit;
-
- if CustomStat.GameMode = GM_COOP then
- begin
- m := Max(Length(_lc[I_GAME_MONSTERS])+1, Length(_lc[I_GAME_SECRETS])+1)*ww2;
- _y := _y+32;
- s2 := _lc[I_GAME_MONSTERS];
- e_TextureFontPrintEx(x+8, _y, s2, gStdFont, 255, 127, 0, 1);
- e_TextureFontPrintEx(x+8+m, _y, IntToStr(gCoopMonstersKilled) + '/' + IntToStr(gTotalMonsters), gStdFont, 255, 255, 255, 1);
- _y := _y+16;
- s2 := _lc[I_GAME_SECRETS];
- e_TextureFontPrintEx(x+8, _y, s2, gStdFont, 255, 127, 0, 1);
- e_TextureFontPrintEx(x+8+m, _y, IntToStr(gCoopSecretsFound) + '/' + IntToStr(gSecretsCount), gStdFont, 255, 255, 255, 1);
- if gLastMap then
- begin
- m := Max(Length(_lc[I_GAME_MONSTERS_TOTAL])+1, Length(_lc[I_GAME_SECRETS_TOTAL])+1)*ww2;
- _y := _y-16;
- s2 := _lc[I_GAME_MONSTERS_TOTAL];
- e_TextureFontPrintEx(x+250, _y, s2, gStdFont, 255, 127, 0, 1);
- e_TextureFontPrintEx(x+250+m, _y, IntToStr(gCoopTotalMonstersKilled) + '/' + IntToStr(gCoopTotalMonsters), gStdFont, 255, 255, 255, 1);
- _y := _y+16;
- s2 := _lc[I_GAME_SECRETS_TOTAL];
- e_TextureFontPrintEx(x+250, _y, s2, gStdFont, 255, 127, 0, 1);
- e_TextureFontPrintEx(x+250+m, _y, IntToStr(gCoopTotalSecretsFound) + '/' + IntToStr(gCoopTotalSecrets), gStdFont, 255, 255, 255, 1);
- end;
- end;
-
- if CustomStat.GameMode in [GM_TDM, GM_CTF] then
- begin
- _y := _y+16+16;
-
- with CustomStat do
- if TeamStat[TEAM_RED].Score > TeamStat[TEAM_BLUE].Score then s1 := _lc[I_GAME_WIN_RED]
- else if TeamStat[TEAM_BLUE].Score > TeamStat[TEAM_RED].Score then s1 := _lc[I_GAME_WIN_BLUE]
- else s1 := _lc[I_GAME_WIN_DRAW];
-
- e_TextureFontPrintEx(x+8+(w div 2)-(Length(s1)*ww2 div 2), _y, s1, gStdFont, 255, 255, 255, 1);
- _y := _y+40;
-
- for t := TEAM_RED to TEAM_BLUE do
- begin
- if t = TEAM_RED then
- begin
- e_TextureFontPrintEx(x+8, _y, _lc[I_GAME_TEAM_RED],
- gStdFont, 255, 0, 0, 1);
- e_TextureFontPrintEx(x+w1+8, _y, IntToStr(CustomStat.TeamStat[TEAM_RED].Score),
- gStdFont, 255, 0, 0, 1);
- r := 255;
- g := 0;
- b := 0;
- end
- else
- begin
- e_TextureFontPrintEx(x+8, _y, _lc[I_GAME_TEAM_BLUE],
- gStdFont, 0, 0, 255, 1);
- e_TextureFontPrintEx(x+w1+8, _y, IntToStr(CustomStat.TeamStat[TEAM_BLUE].Score),
- gStdFont, 0, 0, 255, 1);
- r := 0;
- g := 0;
- b := 255;
- end;
-
- e_DrawLine(1, x+8, _y+20, x-8+w, _y+20, r, g, b);
- _y := _y+24;
-
- for p := 0 to High(CustomStat.PlayerStat) do
- if CustomStat.PlayerStat[p].Team = t then
- with CustomStat.PlayerStat[p] do
- begin
- if Spectator then
- begin
- rr := r div 2;
- gg := g div 2;
- bb := b div 2;
- end
- else
- begin
- rr := r;
- gg := g;
- bb := b;
- end;
- if (gPlayers[Num] <> nil) and (gPlayers[Num].FReady) then
- e_TextureFontPrintEx(x+16, _y, Name + ' *', gStdFont, rr, gg, bb, 1)
- else
- e_TextureFontPrintEx(x+16, _y, Name, gStdFont, rr, gg, bb, 1);
- e_TextureFontPrintEx(x+w1+16, _y, IntToStr(Frags), gStdFont, rr, gg, bb, 1);
- e_TextureFontPrintEx(x+w1+w2+16, _y, IntToStr(Deaths), gStdFont, rr, gg, bb, 1);
- _y := _y+24;
- end;
-
- _y := _y+16+16;
- end;
- end
- else if CustomStat.GameMode in [GM_DM, GM_COOP] then
- begin
- _y := _y+40;
- e_TextureFontPrintEx(x+8, _y, _lc[I_GAME_PLAYER_NAME], gStdFont, 255, 127, 0, 1);
- e_TextureFontPrintEx(x+8+w1, _y, _lc[I_GAME_FRAGS], gStdFont, 255, 127, 0, 1);
- e_TextureFontPrintEx(x+8+w1+w2, _y, _lc[I_GAME_DEATHS], gStdFont, 255, 127, 0, 1);
-
- _y := _y+24;
- for p := 0 to High(CustomStat.PlayerStat) do
- with CustomStat.PlayerStat[p] do
- begin
- e_DrawFillQuad(x+8, _y+4, x+24-1, _y+16+4-1, Color.R, Color.G, Color.B, 0);
-
- if Spectator then
- r := 127
- else
- r := 255;
-
- if (gPlayers[Num] <> nil) and (gPlayers[Num].FReady) then
- e_TextureFontPrintEx(x+8+16+8, _y+4, Name + ' *', gStdFont, r, r, r, 1, True)
- else
- e_TextureFontPrintEx(x+8+16+8, _y+4, Name, gStdFont, r, r, r, 1, True);
- e_TextureFontPrintEx(x+w1+8+16+8, _y+4, IntToStr(Frags), gStdFont, r, r, r, 1, True);
- e_TextureFontPrintEx(x+w1+w2+8+16+8, _y+4, IntToStr(Deaths), gStdFont, r, r, r, 1, True);
- _y := _y+24;
- end;
- end;
-
- // HACK: take stats screenshot immediately after the first frame of the stats showing
- if gScreenshotStats and (not StatShotDone) and (Length(CustomStat.PlayerStat) > 1) then
- begin
- g_TakeScreenShot('stats/' + StatFilename);
- StatShotDone := True;
- end;
-end;
-
-procedure DrawSingleStat();
-var
- tm, key_x, val_x, y: Integer;
- w1, w2, h: Word;
- s1, s2: String;
-
- procedure player_stat(n: Integer);
- var
- kpm: Real;
-
- begin
- // "Kills: # / #":
- s1 := Format(' %d ', [SingleStat.PlayerStat[n].Kills]);
- s2 := Format(' %d', [gTotalMonsters]);
-
- e_CharFont_Print(gMenuFont, key_x, y, _lc[I_MENU_INTER_KILLS]);
- e_CharFont_PrintEx(gMenuFont, val_x, y, s1, _RGB(255, 0, 0));
- e_CharFont_GetSize(gMenuFont, s1, w1, h);
- e_CharFont_Print(gMenuFont, val_x+w1, y, '/');
- s1 := s1 + '/';
- e_CharFont_GetSize(gMenuFont, s1, w1, h);
- e_CharFont_PrintEx(gMenuFont, val_x+w1, y, s2, _RGB(255, 0, 0));
-
- // "Kills-per-minute: ##.#":
- s1 := _lc[I_MENU_INTER_KPM];
- if tm > 0 then
- kpm := (SingleStat.PlayerStat[n].Kills / tm) * 60
- else
- kpm := SingleStat.PlayerStat[n].Kills;
- s2 := Format(' %.1f', [kpm]);
-
- e_CharFont_Print(gMenuFont, key_x, y+32, s1);
- e_CharFont_PrintEx(gMenuFont, val_x, y+32, s2, _RGB(255, 0, 0));
-
- // "Secrets found: # / #":
- s1 := Format(' %d ', [SingleStat.PlayerStat[n].Secrets]);
- s2 := Format(' %d', [SingleStat.TotalSecrets]);
-
- e_CharFont_Print(gMenuFont, key_x, y+64, _lc[I_MENU_INTER_SECRETS]);
- e_CharFont_PrintEx(gMenuFont, val_x, y+64, s1, _RGB(255, 0, 0));
- e_CharFont_GetSize(gMenuFont, s1, w1, h);
- e_CharFont_Print(gMenuFont, val_x+w1, y+64, '/');
- s1 := s1 + '/';
- e_CharFont_GetSize(gMenuFont, s1, w1, h);
- e_CharFont_PrintEx(gMenuFont, val_x+w1, y+64, s2, _RGB(255, 0, 0));
- end;
-
-begin
-// "Level Complete":
- e_CharFont_GetSize(gMenuFont, _lc[I_MENU_INTER_LEVEL_COMPLETE], w1, h);
- e_CharFont_Print(gMenuFont, (gScreenWidth-w1) div 2, 32, _lc[I_MENU_INTER_LEVEL_COMPLETE]);
-
-// Определяем координаты выравнивания по самой длинной строке:
- s1 := _lc[I_MENU_INTER_KPM];
- e_CharFont_GetSize(gMenuFont, s1, w1, h);
- Inc(w1, 16);
- s1 := ' 9999.9';
- e_CharFont_GetSize(gMenuFont, s1, w2, h);
-
- key_x := (gScreenWidth-w1-w2) div 2;
- val_x := key_x + w1;
-
-// "Time: #:##:##":
- tm := SingleStat.GameTime div 1000;
- s1 := _lc[I_MENU_INTER_TIME];
- s2 := Format(' %d:%.2d:%.2d', [tm div (60*60), (tm mod (60*60)) div 60, tm mod 60]);
-
- e_CharFont_Print(gMenuFont, key_x, 80, s1);
- e_CharFont_PrintEx(gMenuFont, val_x, 80, s2, _RGB(255, 0, 0));
-
- if SingleStat.TwoPlayers then
- begin
- // "Player 1":
- s1 := _lc[I_MENU_PLAYER_1];
- e_CharFont_GetSize(gMenuFont, s1, w1, h);
- e_CharFont_Print(gMenuFont, (gScreenWidth-w1) div 2, 128, s1);
-
- // Статистика первого игрока:
- y := 176;
- player_stat(0);
-
- // "Player 2":
- s1 := _lc[I_MENU_PLAYER_2];
- e_CharFont_GetSize(gMenuFont, s1, w1, h);
- e_CharFont_Print(gMenuFont, (gScreenWidth-w1) div 2, 288, s1);
-
- // Статистика второго игрока:
- y := 336;
- player_stat(1);
- end
- else
- begin
- // Статистика первого игрока:
- y := 128;
- player_stat(0);
- end;
-end;
-
-procedure r_Game_DrawLoadingStat;
- procedure drawRect (x, y, w, h: Integer);
- begin
- if (w < 1) or (h < 1) then exit;
- glBegin(GL_QUADS);
- glVertex2f(x+0.375, y+0.375);
- glVertex2f(x+w+0.375, y+0.375);
- glVertex2f(x+w+0.375, y+h+0.375);
- glVertex2f(x+0.375, y+h+0.375);
- glEnd();
- end;
-
- function drawPBar (cur, total: Integer; washere: Boolean): Boolean;
- var
- rectW, rectH: Integer;
- x0, y0: Integer;
- wdt: Integer;
- 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 (not washere) and (cur >= total) then exit; // don't blink
- //if (cur < 0) then cur := 0;
- //if (cur > total) then cur := total;
- result := true;
-
- 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);
-
- //rectW := gScreenWidth-360;
- rectW := trunc(624.0*gScreenWidth/1024.0);
- rectH := hl;
-
- x0 := (gScreenWidth-rectW) div 2;
- y0 := gScreenHeight-rectH-64;
- if (y0 < 2) then y0 := 2;
-
- glEnable(GL_SCISSOR_TEST);
-
- // 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);
-
- // 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;
-
- // 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; // don't be so smart, ketmar: +(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);
- 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
- ww, hh: Word;
- xx, yy, i: Integer;
- s: String;
-begin
- if (Length(LoadingStat.Msgs) = 0) then exit;
-
- e_CharFont_GetSize(gMenuFont, _lc[I_MENU_LOADING], ww, hh);
- yy := (gScreenHeight div 3);
- e_CharFont_Print(gMenuFont, (gScreenWidth div 2)-(ww div 2), yy-2*hh, _lc[I_MENU_LOADING]);
- xx := (gScreenWidth div 3);
-
- with LoadingStat do
- begin
- for i := 0 to NextMsg-1 do
- begin
- if (i = (NextMsg-1)) and (MaxValue > 0) then
- s := Format('%s: %d/%d', [Msgs[i], CurValue, MaxValue])
- else
- s := Msgs[i];
-
- e_CharFont_PrintEx(gMenuSmallFont, xx, yy, s, _RGB(255, 0, 0));
- yy := yy + LOADING_INTERLINE;
- PBarWasHere := drawPBar(CurValue, MaxValue, PBarWasHere);
- end;
- end;
-end;
-
-procedure r_Game_DrawMenuBackground (tex: AnsiString);
-var
- w, h: Word;
- ID: DWord;
-
-begin
- if g_Texture_Get(tex, ID) then
- begin
- e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0);
- e_GetTextureSize(ID, @w, @h);
- if w = h then
- w := round(w * 1.333 * (gScreenHeight / h))
- else
- w := trunc(w * (gScreenHeight / h));
- e_DrawSize(ID, (gScreenWidth - w) div 2, 0, 0, False, False, w, gScreenHeight);
- end
- else e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0);
-end;
-
-procedure DrawMinimap(p: TPlayer; RenderRect: TRect);
-var
- a, aX, aY, aX2, aY2, Scale, ScaleSz: Integer;
-
- function monDraw (mon: TMonster): Boolean;
- begin
- result := false; // don't stop
- with mon do
- begin
- if alive then
- begin
- // Левый верхний угол
- aX := Obj.X div ScaleSz + 1;
- aY := Obj.Y div ScaleSz + 1;
- // Размеры
- aX2 := max(Obj.Rect.Width div ScaleSz, 1);
- aY2 := max(Obj.Rect.Height div ScaleSz, 1);
- // Правый нижний угол
- aX2 := aX + aX2 - 1;
- aY2 := aY + aY2 - 1;
- e_DrawFillQuad(aX, aY, aX2, aY2, 255, 255, 0, 0);
- end;
- end;
- end;
-
-begin
- if (gMapInfo.Width > RenderRect.Right - RenderRect.Left) or
- (gMapInfo.Height > RenderRect.Bottom - RenderRect.Top) then
- begin
- Scale := 1;
- // Сколько пикселов карты в 1 пикселе мини-карты:
- ScaleSz := 16 div Scale;
- // Размеры мини-карты:
- aX := max(gMapInfo.Width div ScaleSz, 1);
- aY := max(gMapInfo.Height div ScaleSz, 1);
- // Рамка карты:
- e_DrawFillQuad(0, 0, aX-1, aY-1, 0, 0, 0, 0);
-
- if gWalls <> nil then
- begin
- // Рисуем стены:
- for a := 0 to High(gWalls) do
- with gWalls[a] do
- if PanelType <> 0 then
- begin
- // Левый верхний угол:
- aX := X div ScaleSz;
- aY := Y div ScaleSz;
- // Размеры:
- aX2 := max(Width div ScaleSz, 1);
- aY2 := max(Height div ScaleSz, 1);
- // Правый нижний угол:
- aX2 := aX + aX2 - 1;
- aY2 := aY + aY2 - 1;
-
- case PanelType of
- PANEL_WALL: e_DrawFillQuad(aX, aY, aX2, aY2, 208, 208, 208, 0);
- PANEL_OPENDOOR, PANEL_CLOSEDOOR:
- if Enabled then e_DrawFillQuad(aX, aY, aX2, aY2, 160, 160, 160, 0);
- end;
- end;
- end;
- if gSteps <> nil then
- begin
- // Рисуем ступени:
- for a := 0 to High(gSteps) do
- with gSteps[a] do
- if PanelType <> 0 then
- begin
- // Левый верхний угол:
- aX := X div ScaleSz;
- aY := Y div ScaleSz;
- // Размеры:
- aX2 := max(Width div ScaleSz, 1);
- aY2 := max(Height div ScaleSz, 1);
- // Правый нижний угол:
- aX2 := aX + aX2 - 1;
- aY2 := aY + aY2 - 1;
-
- e_DrawFillQuad(aX, aY, aX2, aY2, 128, 128, 128, 0);
- end;
- end;
- if gLifts <> nil then
- begin
- // Рисуем лифты:
- for a := 0 to High(gLifts) do
- with gLifts[a] do
- if PanelType <> 0 then
- begin
- // Левый верхний угол:
- aX := X div ScaleSz;
- aY := Y div ScaleSz;
- // Размеры:
- aX2 := max(Width div ScaleSz, 1);
- aY2 := max(Height div ScaleSz, 1);
- // Правый нижний угол:
- aX2 := aX + aX2 - 1;
- aY2 := aY + aY2 - 1;
-
- case LiftType of
- LIFTTYPE_UP: e_DrawFillQuad(aX, aY, aX2, aY2, 116, 72, 36, 0);
- LIFTTYPE_DOWN: e_DrawFillQuad(aX, aY, aX2, aY2, 116, 124, 96, 0);
- LIFTTYPE_LEFT: e_DrawFillQuad(aX, aY, aX2, aY2, 200, 80, 4, 0);
- LIFTTYPE_RIGHT: e_DrawFillQuad(aX, aY, aX2, aY2, 252, 140, 56, 0);
- end;
- end;
- end;
- if gWater <> nil then
- begin
- // Рисуем воду:
- for a := 0 to High(gWater) do
- with gWater[a] do
- if PanelType <> 0 then
- begin
- // Левый верхний угол:
- aX := X div ScaleSz;
- aY := Y div ScaleSz;
- // Размеры:
- aX2 := max(Width div ScaleSz, 1);
- aY2 := max(Height div ScaleSz, 1);
- // Правый нижний угол:
- aX2 := aX + aX2 - 1;
- aY2 := aY + aY2 - 1;
-
- e_DrawFillQuad(aX, aY, aX2, aY2, 0, 0, 192, 0);
- end;
- end;
- if gAcid1 <> nil then
- begin
- // Рисуем кислоту 1:
- for a := 0 to High(gAcid1) do
- with gAcid1[a] do
- if PanelType <> 0 then
- begin
- // Левый верхний угол:
- aX := X div ScaleSz;
- aY := Y div ScaleSz;
- // Размеры:
- aX2 := max(Width div ScaleSz, 1);
- aY2 := max(Height div ScaleSz, 1);
- // Правый нижний угол:
- aX2 := aX + aX2 - 1;
- aY2 := aY + aY2 - 1;
-
- e_DrawFillQuad(aX, aY, aX2, aY2, 0, 176, 0, 0);
- end;
- end;
- if gAcid2 <> nil then
- begin
- // Рисуем кислоту 2:
- for a := 0 to High(gAcid2) do
- with gAcid2[a] do
- if PanelType <> 0 then
- begin
- // Левый верхний угол:
- aX := X div ScaleSz;
- aY := Y div ScaleSz;
- // Размеры:
- aX2 := max(Width div ScaleSz, 1);
- aY2 := max(Height div ScaleSz, 1);
- // Правый нижний угол:
- aX2 := aX + aX2 - 1;
- aY2 := aY + aY2 - 1;
-
- e_DrawFillQuad(aX, aY, aX2, aY2, 176, 0, 0, 0);
- end;
- end;
- if gPlayers <> nil then
- begin
- // Рисуем игроков:
- for a := 0 to High(gPlayers) do
- if gPlayers[a] <> nil then with gPlayers[a] do
- if alive then begin
- // Левый верхний угол:
- aX := Obj.X div ScaleSz + 1;
- aY := Obj.Y div ScaleSz + 1;
- // Размеры:
- aX2 := max(Obj.Rect.Width div ScaleSz, 1);
- aY2 := max(Obj.Rect.Height div ScaleSz, 1);
- // Правый нижний угол:
- aX2 := aX + aX2 - 1;
- aY2 := aY + aY2 - 1;
-
- if gPlayers[a] = p then
- e_DrawFillQuad(aX, aY, aX2, aY2, 0, 255, 0, 0)
- else
- case Team of
- TEAM_RED: e_DrawFillQuad(aX, aY, aX2, aY2, 255, 0, 0, 0);
- TEAM_BLUE: e_DrawFillQuad(aX, aY, aX2, aY2, 0, 0, 255, 0);
- else e_DrawFillQuad(aX, aY, aX2, aY2, 255, 128, 0, 0);
- end;
- end;
- end;
- // Рисуем монстров
- g_Mons_ForEach(monDraw);
- end;
-end;
-
-
-procedure renderAmbientQuad (hasAmbient: Boolean; constref ambColor: TDFColor);
-begin
- if not hasAmbient then exit;
- e_AmbientQuad(sX, sY, sWidth, sHeight, ambColor.r, ambColor.g, ambColor.b, ambColor.a);
-end;
-
-// ////////////////////////////////////////////////////////////////////////// //
-var
- ltexid: GLuint = 0;
-
-function g_Texture_Light (): Integer;
-const
- Radius: Integer = 128;
-var
- tex, tpp: PByte;
- x, y, a: Integer;
- dist: Double;
-begin
- if ltexid = 0 then
- begin
- GetMem(tex, (Radius*2)*(Radius*2)*4);
- tpp := tex;
- for y := 0 to Radius*2-1 do
- begin
- for x := 0 to Radius*2-1 do
- begin
- dist := 1.0-sqrt((x-Radius)*(x-Radius)+(y-Radius)*(y-Radius))/Radius;
- if (dist < 0) then
- begin
- tpp^ := 0; Inc(tpp);
- tpp^ := 0; Inc(tpp);
- tpp^ := 0; Inc(tpp);
- tpp^ := 0; Inc(tpp);
- end
- else
- begin
- //tc.setPixel(x, y, Color(cast(int)(dist*255), cast(int)(dist*255), cast(int)(dist*255)));
- if (dist > 0.5) then dist := 0.5;
- a := round(dist*255);
- if (a < 0) then a := 0 else if (a > 255) then a := 255;
- tpp^ := 255; Inc(tpp);
- tpp^ := 255; Inc(tpp);
- tpp^ := 255; Inc(tpp);
- tpp^ := Byte(a); Inc(tpp);
- end;
- end;
- end;
-
- glGenTextures(1, @ltexid);
- //if (tid == 0) assert(0, "VGL: can't create screen texture");
-
- glBindTexture(GL_TEXTURE_2D, ltexid);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- //GLfloat[4] bclr = 0.0;
- //glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bclr.ptr);
-
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Radius*2, Radius*2, 0, GL_RGBA{gltt}, GL_UNSIGNED_BYTE, tex);
- end;
-
- result := ltexid;
-end;
-
-// setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
-//FIXME: broken for splitscreen mode
-procedure renderDynLightsInternal ();
-var
- //hasAmbient: Boolean;
- //ambColor: TDFColor;
- lln: Integer;
- lx, ly, lrad: Integer;
- scxywh: array[0..3] of GLint;
- wassc: Boolean;
-begin
- if e_NoGraphics then exit;
-
- //TODO: lights should be in separate grid, i think
- // but on the other side: grid may be slower for dynlights, as their lifetime is short
- if (not gwin_k8_enable_light_experiments) or (not gwin_has_stencil) or (g_dynLightCount < 1) then exit;
-
- // rendering mode
- //ambColor := gCurrentMap['light_ambient'].rgba;
- //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
-
- { // this will multiply incoming color to alpha from framebuffer
- glEnable(GL_BLEND);
- glBlendFunc(GL_DST_ALPHA, GL_ONE);
- }
-
- (*
- * light rendering: (INVALID!)
- * glStencilFunc(GL_EQUAL, 0, $ff);
- * for each light:
- * glClear(GL_STENCIL_BUFFER_BIT);
- * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
- * draw shadow volume into stencil buffer
- * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
- * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
- * turn off blending
- * draw color-less quad with light alpha (WARNING! don't touch color!)
- * glEnable(GL_BLEND);
- * glBlendFunc(GL_DST_ALPHA, GL_ONE);
- * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
- *)
- wassc := (glIsEnabled(GL_SCISSOR_TEST) <> 0);
- if wassc then glGetIntegerv(GL_SCISSOR_BOX, @scxywh[0]) else glGetIntegerv(GL_VIEWPORT, @scxywh[0]);
-
- // setup OpenGL parameters
- glStencilMask($FFFFFFFF);
- glStencilFunc(GL_ALWAYS, 0, $FFFFFFFF);
- glEnable(GL_STENCIL_TEST);
- glEnable(GL_SCISSOR_TEST);
- glClear(GL_STENCIL_BUFFER_BIT);
- glStencilFunc(GL_EQUAL, 0, $ff);
-
- for lln := 0 to g_dynLightCount-1 do
- begin
- lx := g_dynLights[lln].x;
- ly := g_dynLights[lln].y;
- lrad := g_dynLights[lln].radius;
- if (lrad < 3) then continue;
-
- if (lx-sX+lrad < 0) then continue;
- if (ly-sY+lrad < 0) then continue;
- if (lx-sX-lrad >= gPlayerScreenSize.X) then continue;
- if (ly-sY-lrad >= gPlayerScreenSize.Y) then continue;
-
- // set scissor to optimize drawing
- if (g_dbg_scale = 1.0) then
- begin
- glScissor((lx-sX)-lrad+2, gPlayerScreenSize.Y-(ly-sY)-lrad-1+2, lrad*2-4, lrad*2-4);
- end
- else
- begin
- glScissor(0, 0, gScreenWidth, gScreenHeight);
- end;
- // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
- if (g_dbg_scale <> 1.0) then glClear(GL_STENCIL_BUFFER_BIT);
- glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
- // draw extruded panels
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_BLEND);
- glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // no need to modify color buffer
- if (lrad > 4) then r_Map_DrawPanelShadowVolumes(lx, ly, lrad);
- // render light texture
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
- glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO); // draw light, and clear stencil buffer
- // blend it
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_TEXTURE_2D);
- // color and opacity
- glColor4f(g_dynLights[lln].r, g_dynLights[lln].g, g_dynLights[lln].b, g_dynLights[lln].a);
- glBindTexture(GL_TEXTURE_2D, g_Texture_Light());
- glBegin(GL_QUADS);
- glTexCoord2f(0.0, 0.0); glVertex2i(lx-lrad, ly-lrad); // top-left
- glTexCoord2f(1.0, 0.0); glVertex2i(lx+lrad, ly-lrad); // top-right
- glTexCoord2f(1.0, 1.0); glVertex2i(lx+lrad, ly+lrad); // bottom-right
- glTexCoord2f(0.0, 1.0); glVertex2i(lx-lrad, ly+lrad); // bottom-left
- glEnd();
- end;
-
- // done
- glDisable(GL_STENCIL_TEST);
- glDisable(GL_BLEND);
- glDisable(GL_SCISSOR_TEST);
- //glScissor(0, 0, sWidth, sHeight);
-
- glScissor(scxywh[0], scxywh[1], scxywh[2], scxywh[3]);
- if wassc then glEnable(GL_SCISSOR_TEST) else glDisable(GL_SCISSOR_TEST);
-end;
-
-
-function fixViewportForScale (): Boolean;
-var
- nx0, ny0, nw, nh: Integer;
-begin
- result := false;
- if (g_dbg_scale <> 1.0) then
- begin
- result := true;
- nx0 := round(sX-(gPlayerScreenSize.X-(sWidth*g_dbg_scale))/2/g_dbg_scale);
- ny0 := round(sY-(gPlayerScreenSize.Y-(sHeight*g_dbg_scale))/2/g_dbg_scale);
- nw := round(sWidth/g_dbg_scale);
- nh := round(sHeight/g_dbg_scale);
- sX := nx0;
- sY := ny0;
- sWidth := nw;
- sHeight := nh;
- end;
-end;
-
-
-// setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
-// WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
-procedure renderMapInternal (backXOfs, backYOfs: Integer; setTransMatrix: Boolean);
-type
- TDrawCB = procedure ();
-
-var
- hasAmbient: Boolean;
- ambColor: TDFColor;
- doAmbient: Boolean = false;
-
- procedure drawPanelType (profname: AnsiString; panType: DWord; doDraw: Boolean);
- var
- tagmask: Integer;
- pan: TPanel;
- begin
- if (profileFrameDraw <> nil) then profileFrameDraw.sectionBegin(profname);
- if gdbg_map_use_accel_render then
- begin
- tagmask := panelTypeToTag(panType);
- while (gDrawPanelList.count > 0) do
- begin
- pan := TPanel(gDrawPanelList.front());
- if ((pan.tag and tagmask) = 0) then break;
- if doDraw then r_Panel_Draw(pan, doAmbient, ambColor);
- gDrawPanelList.popFront();
- end;
- end
- else
- begin
- if doDraw then r_Map_DrawPanels(panType, hasAmbient, ambColor);
- end;
- if (profileFrameDraw <> nil) then profileFrameDraw.sectionEnd();
- end;
-
- procedure drawOther (profname: AnsiString; cb: TDrawCB);
- begin
- if (profileFrameDraw <> nil) then profileFrameDraw.sectionBegin(profname);
- if assigned(cb) then cb();
- if (profileFrameDraw <> nil) then profileFrameDraw.sectionEnd();
- end;
-
-begin
- if (profileFrameDraw <> nil) then profileFrameDraw.sectionBegin('total');
-
- // our accelerated renderer will collect all panels to gDrawPanelList
- // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
- if (profileFrameDraw <> nil) then profileFrameDraw.sectionBegin('collect');
- if gdbg_map_use_accel_render then
- begin
- r_Map_CollectDrawPanels(sX, sY, sWidth, sHeight);
- end;
- if (profileFrameDraw <> nil) then profileFrameDraw.sectionEnd();
-
- if (profileFrameDraw <> nil) then profileFrameDraw.sectionBegin('skyback');
- r_Map_DrawBack(backXOfs, backYOfs);
- if (profileFrameDraw <> nil) then profileFrameDraw.sectionEnd();
-
- if setTransMatrix then
- begin
- //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
- glScalef(g_dbg_scale, g_dbg_scale, 1.0);
- glTranslatef(-sX, -sY, 0);
- end;
-
- // rendering mode
- ambColor := gCurrentMap['light_ambient'].rgba;
- hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
-
- {
- if hasAmbient then
- begin
- //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
- glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
- glClear(GL_COLOR_BUFFER_BIT);
- end;
- }
- //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
-
-
- drawPanelType('*back', PANEL_BACK, g_rlayer_back);
- drawPanelType('*step', PANEL_STEP, g_rlayer_step);
- drawOther('items', @r_Items_Draw);
- drawOther('weapons', @r_Weapon_Draw);
- {$IFDEF ENABLE_SHELLS}
- drawOther('shells', @r_Player_DrawShells);
- {$ENDIF}
- drawOther('drawall', @r_Player_DrawAll);
- {$IFDEF ENABLE_GIBS}
- drawOther('gibs', @r_PlayerModel_DrawGibs);
- {$ENDIF}
- {$IFDEF ENABLE_CORPSES}
- drawOther('corpses', @r_Player_DrawCorpses);
- {$ENDIF}
- drawPanelType('*wall', PANEL_WALL, g_rlayer_wall);
- drawOther('monsters', @r_Monsters_Draw);
- drawOther('itemdrop', @r_Items_DrawDrop);
- drawPanelType('*door', PANEL_CLOSEDOOR, g_rlayer_door);
- {$IFDEF ENABLE_GFX}
- drawOther('gfx', @r_GFX_Draw);
- {$ENDIF}
- drawOther('flags', @r_Map_DrawFlags);
- drawPanelType('*acid1', PANEL_ACID1, g_rlayer_acid1);
- drawPanelType('*acid2', PANEL_ACID2, g_rlayer_acid2);
- drawPanelType('*water', PANEL_WATER, g_rlayer_water);
- drawOther('dynlights', @renderDynLightsInternal);
-
- if hasAmbient {and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
- begin
- renderAmbientQuad(hasAmbient, ambColor);
- end;
-
- doAmbient := true;
- drawPanelType('*fore', PANEL_FORE, g_rlayer_fore);
-
-
- if g_debug_HealthBar then
- begin
- r_Monsters_DrawHealth();
- r_Player_DrawHealth();
- end;
-
- if (profileFrameDraw <> nil) then profileFrameDraw.mainEnd(); // map rendering
-end;
-
-
-procedure DrawMapView(x, y, w, h: Integer);
-
-var
- bx, by: Integer;
-begin
- glPushMatrix();
-
- bx := Round(x/(gMapInfo.Width - w)*(gBackSize.X - w));
- by := Round(y/(gMapInfo.Height - h)*(gBackSize.Y - h));
-
- sX := x;
- sY := y;
- sWidth := w;
- sHeight := h;
-
- fixViewportForScale();
- renderMapInternal(-bx, -by, true);
-
- glPopMatrix();
-end;
-
-
-procedure DrawPlayer(p: TPlayer);
-var
- px, py, a, b, c, d, i, fX, fY: Integer;
- camObj: TObj;
- //R: TRect;
-begin
- if (p = nil) or (p.FDummy) then
- begin
- glPushMatrix();
- r_Map_DrawBack(0, 0);
- glPopMatrix();
- Exit;
- end;
-
- if (profileFrameDraw = nil) then profileFrameDraw := TProfiler.Create('RENDER', g_profile_history_size);
- if (profileFrameDraw <> nil) then profileFrameDraw.mainBegin(g_profile_frame_draw);
-
- gPlayerDrawn := p;
-
- glPushMatrix();
-
- {$IFDEF ENABLE_CORPSES}
- camObj := g_Corpses_GetCameraObj(p);
- {$ELSE}
- camObj := p.Obj;
- {$ENDIF}
-
- camObj.lerp(gLerpFactor, fX, fY);
- px := fX + PLAYER_RECT_CX;
- py := fY + PLAYER_RECT_CY+nlerp(p.SlopeOld, camObj.slopeUpLeft, gLerpFactor);
-
- if (g_dbg_scale = 1.0) and (not g_dbg_ignore_bounds) then
- begin
- if (px > (gPlayerScreenSize.X div 2)) then a := -px+(gPlayerScreenSize.X div 2) else a := 0;
- if (py > (gPlayerScreenSize.Y div 2)) then b := -py+(gPlayerScreenSize.Y div 2) else b := 0;
-
- if (px > gMapInfo.Width-(gPlayerScreenSize.X div 2)) then a := -gMapInfo.Width+gPlayerScreenSize.X;
- if (py > gMapInfo.Height-(gPlayerScreenSize.Y div 2)) then b := -gMapInfo.Height+gPlayerScreenSize.Y;
-
- if (gMapInfo.Width = gPlayerScreenSize.X) then a := 0
- else if (gMapInfo.Width < gPlayerScreenSize.X) then
- begin
- // hcenter
- a := (gPlayerScreenSize.X-gMapInfo.Width) div 2;
- end;
-
- if (gMapInfo.Height = gPlayerScreenSize.Y) then b := 0
- else if (gMapInfo.Height < gPlayerScreenSize.Y) then
- begin
- // vcenter
- b := (gPlayerScreenSize.Y-gMapInfo.Height) div 2;
- end;
- end
- else
- begin
- // scaled, ignore level bounds
- a := -px+(gPlayerScreenSize.X div 2);
- b := -py+(gPlayerScreenSize.Y div 2);
- end;
-
- sX := -a;
- sY := -b;
- sWidth := gPlayerScreenSize.X;
- sHeight := gPlayerScreenSize.Y;
- fixViewportForScale();
-
- i := py - (sY + sHeight div 2);
- if (p.IncCam > 0) then
- begin
- // clamp to level bounds
- if (sY - p.IncCam < 0) then
- p.IncCam := nclamp(sY, 0, 120);
- // clamp around player position
- if (i > 0) then
- p.IncCam := nclamp(p.IncCam, 0, max(0, 120 - i));
- end
- else if (p.IncCam < 0) then
- begin
- // clamp to level bounds
- if (sY + sHeight - p.IncCam > gMapInfo.Height) then
- p.IncCam := nclamp(sY + sHeight - gMapInfo.Height, -120, 0);
- // clamp around player position
- if (i < 0) then
- p.IncCam := nclamp(p.IncCam, min(0, -120 - i), 0);
- end;
-
- sY := sY - nlerp(p.IncCamOld, p.IncCam, gLerpFactor);
-
- if (not g_dbg_ignore_bounds) then
- begin
- if (sX+sWidth > gMapInfo.Width) then sX := gMapInfo.Width-sWidth;
- if (sY+sHeight > gMapInfo.Height) then sY := gMapInfo.Height-sHeight;
- if (sX < 0) then sX := 0;
- if (sY < 0) then sY := 0;
- end;
-
- if (gBackSize.X <= gPlayerScreenSize.X) or (gMapInfo.Width <= sWidth) then c := 0 else c := trunc((gBackSize.X-gPlayerScreenSize.X)*sX/(gMapInfo.Width-sWidth));
- if (gBackSize.Y <= gPlayerScreenSize.Y) or (gMapInfo.Height <= sHeight) then d := 0 else d := trunc((gBackSize.Y-gPlayerScreenSize.Y)*sY/(gMapInfo.Height-sHeight));
-
- //r_smallmap_h: 0: left; 1: center; 2: right
- //r_smallmap_v: 0: top; 1: center; 2: bottom
- // horiz small map?
- if (gMapInfo.Width = sWidth) then
- begin
- sX := 0;
- end
- else if (gMapInfo.Width < sWidth) then
- begin
- case r_smallmap_h of
- 1: sX := -((sWidth-gMapInfo.Width) div 2); // center
- 2: sX := -(sWidth-gMapInfo.Width); // right
- else sX := 0; // left
- end;
- end;
- // vert small map?
- if (gMapInfo.Height = sHeight) then
- begin
- sY := 0;
- end
- else if (gMapInfo.Height < sHeight) then
- begin
- case r_smallmap_v of
- 1: sY := -((sHeight-gMapInfo.Height) div 2); // center
- 2: sY := -(sHeight-gMapInfo.Height); // bottom
- else sY := 0; // top
- end;
- end;
-
- p.viewPortX := sX;
- p.viewPortY := sY;
- p.viewPortW := sWidth;
- p.viewPortH := sHeight;
-
-{$IFDEF ENABLE_HOLMES}
- if (p = gPlayer1) then
- begin
- g_Holmes_plrViewPos(sX, sY);
- g_Holmes_plrViewSize(sWidth, sHeight);
- end;
-{$ENDIF}
-
- renderMapInternal(-c, -d, true);
-
- if (gGameSettings.GameMode <> GM_SINGLE) and (gPlayerIndicator > 0) then
- case gPlayerIndicator of
- 1:
- r_Player_DrawIndicator(p, _RGB(255, 255, 255));
-
- 2:
- for i := 0 to High(gPlayers) do
- if gPlayers[i] <> nil then
- if gPlayers[i] = p then
- r_Player_DrawIndicator(p, _RGB(255, 255, 255))
- else if (gPlayers[i].Team = p.Team) and (gPlayers[i].Team <> TEAM_NONE) then
- if gPlayerIndicatorStyle = 1 then
- r_Player_DrawIndicator(gPlayers[i], _RGB(192, 192, 192))
- else
- r_Player_DrawIndicator(gPlayers[i], gPlayers[i].GetColor);
- end;
-
- {
- for a := 0 to High(gCollideMap) do
- for b := 0 to High(gCollideMap[a]) do
- begin
- d := 0;
- if ByteBool(gCollideMap[a, b] and MARK_WALL) then
- d := d + 1;
- if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
- d := d + 2;
-
- case d of
- 1: e_DrawPoint(1, b, a, 200, 200, 200);
- 2: e_DrawPoint(1, b, a, 64, 64, 255);
- 3: e_DrawPoint(1, b, a, 255, 0, 255);
- end;
- end;
- }
-
- glPopMatrix();
-
- r_Player_DrawPain(p);
- r_Player_DrawPickup(p);
- r_Player_DrawRulez(p);
- if gShowMap then DrawMinimap(p, _TRect(0, 0, 128, 128));
- if g_Debug_Player then
- r_Player_DrawDebug(p);
- r_Player_DrawGUI(p);
-end;
-
-procedure drawProfilers ();
-var
- px: Integer = -1;
- py: Integer = -1;
-begin
- if g_profile_frame_draw and (profileFrameDraw <> nil) then px := px-drawProfiles(px, py, profileFrameDraw);
- if g_profile_collision and (profMapCollision <> nil) then begin px := px-drawProfiles(px, py, profMapCollision); py -= calcProfilesHeight(profMonsLOS); end;
- if g_profile_los and (profMonsLOS <> nil) then begin px := px-drawProfiles(px, py, profMonsLOS); py -= calcProfilesHeight(profMonsLOS); end;
-end;
-
-procedure r_Game_Draw();
-var
- ID: DWORD;
- w, h: Word;
- ww, hh: Byte;
- Time: Int64;
- back: string;
- plView1, plView2: TPlayer;
- Split: Boolean;
- MsgLineLength: Integer;
- MsgText: String;
-begin
- if gExit = EXIT_QUIT then Exit;
-
- Time := GetTickCount64() {div 1000};
- FPSCounter := FPSCounter+1;
- if Time - FPSTime >= 1000 then
- begin
- FPS := FPSCounter;
- FPSCounter := 0;
- FPSTime := Time;
- end;
-
- e_SetRendertarget(True);
- e_SetViewPort(0, 0, gScreenWidth, gScreenHeight);
-
- if gGameOn or (gState = STATE_FOLD) then
- begin
- if (gPlayer1 <> nil) and (gPlayer2 <> nil) then
- begin
- gSpectMode := SPECT_NONE;
- if not gRevertPlayers then
- begin
- plView1 := gPlayer1;
- plView2 := gPlayer2;
- end
- else
- begin
- plView1 := gPlayer2;
- plView2 := gPlayer1;
- end;
- end
- else
- if (gPlayer1 <> nil) or (gPlayer2 <> nil) then
- begin
- gSpectMode := SPECT_NONE;
- if gPlayer2 = nil then
- plView1 := gPlayer1
- else
- plView1 := gPlayer2;
- plView2 := nil;
- end
- else
- begin
- plView1 := nil;
- plView2 := nil;
- end;
-
- if (plView1 = nil) and (plView2 = nil) and (gSpectMode = SPECT_NONE) then
- gSpectMode := SPECT_STATS;
-
- if gSpectMode = SPECT_PLAYERS then
- if gPlayers <> nil then
- begin
- plView1 := GetActivePlayer_ByID(gSpectPID1);
- if plView1 = nil then
- begin
- gSpectPID1 := GetActivePlayerID_Next();
- plView1 := GetActivePlayer_ByID(gSpectPID1);
- end;
- if gSpectViewTwo then
- begin
- plView2 := GetActivePlayer_ByID(gSpectPID2);
- if plView2 = nil then
- begin
- gSpectPID2 := GetActivePlayerID_Next();
- plView2 := GetActivePlayer_ByID(gSpectPID2);
- end;
- end;
- end;
-
- if gSpectMode = SPECT_MAPVIEW then
- begin
- // Режим просмотра карты
- Split := False;
- e_SetViewPort(0, 0, gScreenWidth, gScreenHeight);
- DrawMapView(gSpectX, gSpectY, gScreenWidth, gScreenHeight);
- gHearPoint1.Active := True;
- gHearPoint1.Coords.X := gScreenWidth div 2 + gSpectX;
- gHearPoint1.Coords.Y := gScreenHeight div 2 + gSpectY;
- gHearPoint2.Active := False;
- end
- else
- begin
- Split := (plView1 <> nil) and (plView2 <> nil);
-
- // Точки слуха игроков
- if plView1 <> nil then
- begin
- gHearPoint1.Active := True;
- gHearPoint1.Coords.X := plView1.GameX + PLAYER_RECT.Width;
- gHearPoint1.Coords.Y := plView1.GameY + PLAYER_RECT.Height DIV 2;
- end else
- gHearPoint1.Active := False;
- if plView2 <> nil then
- begin
- gHearPoint2.Active := True;
- gHearPoint2.Coords.X := plView2.GameX + PLAYER_RECT.Width;
- gHearPoint2.Coords.Y := plView2.GameY + PLAYER_RECT.Height DIV 2;
- end else
- gHearPoint2.Active := False;
-
- // Размер экранов игроков:
- gPlayerScreenSize.X := gScreenWidth-196;
- if Split then
- begin
- gPlayerScreenSize.Y := gScreenHeight div 2;
- if gScreenHeight mod 2 = 0 then
- Dec(gPlayerScreenSize.Y);
- end
- else
- gPlayerScreenSize.Y := gScreenHeight;
-
- if Split then
- if gScreenHeight mod 2 = 0 then
- e_SetViewPort(0, gPlayerScreenSize.Y+2, gPlayerScreenSize.X+196, gPlayerScreenSize.Y)
- else
- e_SetViewPort(0, gPlayerScreenSize.Y+1, gPlayerScreenSize.X+196, gPlayerScreenSize.Y);
-
- DrawPlayer(plView1);
- gPlayer1ScreenCoord.X := sX;
- gPlayer1ScreenCoord.Y := sY;
-
- if Split then
- begin
- e_SetViewPort(0, 0, gPlayerScreenSize.X+196, gPlayerScreenSize.Y);
-
- DrawPlayer(plView2);
- gPlayer2ScreenCoord.X := sX;
- gPlayer2ScreenCoord.Y := sY;
- end;
-
- e_SetViewPort(0, 0, gScreenWidth, gScreenHeight);
-
- if Split then
- e_DrawLine(2, 0, gScreenHeight div 2, gScreenWidth, gScreenHeight div 2, 0, 0, 0);
- end;
-
-{$IFDEF ENABLE_HOLMES}
- // draw inspector
- if (g_holmes_enabled) then g_Holmes_Draw();
-{$ENDIF}
-
- if MessageText <> '' then
- begin
- w := 0;
- h := 0;
- e_CharFont_GetSizeFmt(gMenuFont, MessageText, w, h);
- MsgLineLength := (gScreenWidth - 204) div e_CharFont_GetMaxWidth(gMenuFont);
- MsgText := b_Text_Wrap(b_Text_Format(MessageText), MsgLineLength);
- if Split then
- e_CharFont_PrintFmt(gMenuFont, (gScreenWidth div 2)-(w div 2),
- (gScreenHeight div 2)-(h div 2), MsgText)
- else
- e_CharFont_PrintFmt(gMenuFont, (gScreenWidth div 2)-(w div 2),
- Round(gScreenHeight / 2.75)-(h div 2), MsgText);
- end;
-
- if IsDrawStat or (gSpectMode = SPECT_STATS) then
- DrawStat();
-
- if gSpectHUD and (not gChatShow) and (gSpectMode <> SPECT_NONE) and (not gSpectAuto) then
- begin
- // Draw spectator GUI
- ww := 0;
- hh := 0;
- e_TextureFontGetSize(gStdFont, ww, hh);
- case gSpectMode of
- SPECT_STATS:
- e_TextureFontPrintEx(0, gScreenHeight - (hh+2)*2, 'MODE: Stats', gStdFont, 255, 255, 255, 1);
- SPECT_MAPVIEW:
- e_TextureFontPrintEx(0, gScreenHeight - (hh+2)*2, 'MODE: Observe Map', gStdFont, 255, 255, 255, 1);
- SPECT_PLAYERS:
- e_TextureFontPrintEx(0, gScreenHeight - (hh+2)*2, 'MODE: Watch Players', gStdFont, 255, 255, 255, 1);
- end;
- e_TextureFontPrintEx(2*ww, gScreenHeight - (hh+2), '< jump >', gStdFont, 255, 255, 255, 1);
- if gSpectMode = SPECT_STATS then
- begin
- e_TextureFontPrintEx(16*ww, gScreenHeight - (hh+2)*2, 'Autoview', gStdFont, 255, 255, 255, 1);
- e_TextureFontPrintEx(16*ww, gScreenHeight - (hh+2), '< fire >', gStdFont, 255, 255, 255, 1);
- end;
- if gSpectMode = SPECT_MAPVIEW then
- begin
- e_TextureFontPrintEx(22*ww, gScreenHeight - (hh+2)*2, '[-]', gStdFont, 255, 255, 255, 1);
- e_TextureFontPrintEx(26*ww, gScreenHeight - (hh+2)*2, 'Step ' + IntToStr(gSpectStep), gStdFont, 255, 255, 255, 1);
- e_TextureFontPrintEx(34*ww, gScreenHeight - (hh+2)*2, '[+]', gStdFont, 255, 255, 255, 1);
- e_TextureFontPrintEx(18*ww, gScreenHeight - (hh+2), '<prev weap>', gStdFont, 255, 255, 255, 1);
- e_TextureFontPrintEx(30*ww, gScreenHeight - (hh+2), '<next weap>', gStdFont, 255, 255, 255, 1);
- end;
- if gSpectMode = SPECT_PLAYERS then
- begin
- e_TextureFontPrintEx(22*ww, gScreenHeight - (hh+2)*2, 'Player 1', gStdFont, 255, 255, 255, 1);
- e_TextureFontPrintEx(20*ww, gScreenHeight - (hh+2), '<left/right>', gStdFont, 255, 255, 255, 1);
- if gSpectViewTwo then
- begin
- e_TextureFontPrintEx(37*ww, gScreenHeight - (hh+2)*2, 'Player 2', gStdFont, 255, 255, 255, 1);
- e_TextureFontPrintEx(34*ww, gScreenHeight - (hh+2), '<prev w/next w>', gStdFont, 255, 255, 255, 1);
- e_TextureFontPrintEx(52*ww, gScreenHeight - (hh+2)*2, '2x View', gStdFont, 255, 255, 255, 1);
- e_TextureFontPrintEx(51*ww, gScreenHeight - (hh+2), '<up/down>', gStdFont, 255, 255, 255, 1);
- end
- else
- begin
- e_TextureFontPrintEx(35*ww, gScreenHeight - (hh+2)*2, '2x View', gStdFont, 255, 255, 255, 1);
- e_TextureFontPrintEx(34*ww, gScreenHeight - (hh+2), '<up/down>', gStdFont, 255, 255, 255, 1);
- end;
- end;
- end;
- end;
-
-{$IFDEF ENABLE_MENU}
- if gPauseMain and gGameOn and (g_ActiveWindow = nil) then
-{$ELSE}
- if gPauseMain and gGameOn then
-{$ENDIF}
- begin
- //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
- e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
-
- e_CharFont_GetSize(gMenuFont, _lc[I_MENU_PAUSE], w, h);
- e_CharFont_Print(gMenuFont, (gScreenWidth div 2)-(w div 2),
- (gScreenHeight div 2)-(h div 2), _lc[I_MENU_PAUSE]);
- end;
-
- if not gGameOn then
- begin
- {$IFDEF ENABLE_MENU}
- if (gState = STATE_MENU) then
- begin
- if (g_ActiveWindow = nil) or (g_ActiveWindow.BackTexture = '') then r_Game_DrawMenuBackground('MENU_BACKGROUND');
- // F3 at menu will show game loading dialog
- if e_KeyPressed(IK_F3) then g_Menu_Show_LoadMenu(true);
- if (g_ActiveWindow <> nil) then
- begin
- //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
- e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
- end
- else
- begin
- // F3 at titlepic will show game loading dialog
- if e_KeyPressed(IK_F3) then
- begin
- g_Menu_Show_LoadMenu(true);
- if (g_ActiveWindow <> nil) then e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
- end;
- end;
- end;
- {$ELSE}
- r_Game_DrawMenuBackground('MENU_BACKGROUND');
- {$ENDIF}
-
- if gState = STATE_FOLD then
- begin
- e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 0, 0, 0, EndingGameCounter);
- end;
-
- if gState = STATE_INTERCUSTOM then
- begin
- if gLastMap and (gGameSettings.GameMode = GM_COOP) then
- begin
- back := 'TEXTURE_endpic';
- if not g_Texture_Get(back, ID) then
- back := _lc[I_TEXTURE_ENDPIC];
- end
- else
- back := 'INTER';
-
- r_Game_DrawMenuBackground(back);
-
- DrawCustomStat();
-
- {$IFDEF ENABLE_MENU}
- if g_ActiveWindow <> nil then
- begin
- //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
- e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
- end;
- {$ENDIF}
- end;
-
- if gState = STATE_INTERSINGLE then
- begin
- if EndingGameCounter > 0 then
- begin
- e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 0, 0, 0, EndingGameCounter);
- end
- else
- begin
- back := 'INTER';
-
- r_Game_DrawMenuBackground(back);
-
- DrawSingleStat();
-
- {$IFDEF ENABLE_MENU}
- if g_ActiveWindow <> nil then
- begin
- //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
- e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
- end;
- {$ENDIF}
- end;
- end;
-
- if gState = STATE_ENDPIC then
- begin
- ID := DWORD(-1);
- if g_Texture_Get('TEXTURE_endpic', ID) then r_Game_DrawMenuBackground('TEXTURE_endpic')
- else r_Game_DrawMenuBackground(_lc[I_TEXTURE_ENDPIC]);
-
- {$IFDEF ENABLE_MENU}
- if g_ActiveWindow <> nil then
- begin
- //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
- e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
- end;
- {$ENDIF}
- end;
-
- if gState = STATE_SLIST then
- begin
-// if g_Texture_Get('MENU_BACKGROUND', ID) then
-// begin
-// e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
-// //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
-// end;
- r_Game_DrawMenuBackground('MENU_BACKGROUND');
- e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
- r_Serverlist_Draw(slCurrent, slTable);
- end;
- end;
-
-{$IFDEF ENABLE_MENU}
- if g_ActiveWindow <> nil then
- begin
- if gGameOn then
- begin
- //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
- e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
- end;
- r_GUI_Draw_Window(g_ActiveWindow);
- end;
-{$ENDIF}
-
- r_Console_Draw();
-
- if g_debug_Sounds and gGameOn then
- begin
- for w := 0 to High(e_SoundsArray) do
- for h := 0 to e_SoundsArray[w].nRefs do
- e_DrawPoint(1, w+100, h+100, 255, 0, 0);
- end;
-
- if gShowFPS then
- begin
- e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS]), gStdFont);
- e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS]), gStdFont);
- end;
-
- if gGameOn and gShowTime then
- drawTime(gScreenWidth-72, gScreenHeight-16);
-
- if gGameOn then drawProfilers();
-
- // TODO: draw this after the FBO and remap mouse click coordinates
-
-{$IFDEF ENABLE_HOLMES}
- g_Holmes_DrawUI();
-{$ENDIF}
-
- // blit framebuffer to screen
-
- e_SetRendertarget(False);
- e_SetViewPort(0, 0, gWinSizeX, gWinSizeY);
- e_BlitFramebuffer(gWinSizeX, gWinSizeY);
-end;
-
-end.
diff --git a/src/game/opengl/r_gfx.pas b/src/game/opengl/r_gfx.pas
+++ /dev/null
@@ -1,244 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_gfx;
-
-interface
-
-{
- const
- R_GFX_FLAME_WIDTH = 32;
- R_GFX_FLAME_HEIGHT = 32;
- R_GFX_SMOKE_WIDTH = 32;
- R_GFX_SMOKE_HEIGHT = 32;
-}
-
- procedure r_GFX_Load;
- procedure r_GFX_Free;
- procedure r_GFX_Draw;
- procedure r_GFX_Update;
-
- procedure r_GFX_OnceAnim (AnimType, X, Y: Integer);
-
-implementation
-
- uses
- {$INCLUDE ../nogl/noGLuses.inc}
- SysUtils, Classes, Math,
- utils,
- g_base, r_graphics, g_options, r_animations,
- g_game, g_animations,
- g_gfx
- ;
-
- type
- TOnceAnim = record
- AnimType: Byte;
- Alpha: Byte;
- x, y: Integer;
- oldX, oldY: Integer;
- Animation: TAnimState;
- end;
-
- var
- OnceAnims: array of TOnceAnim = nil;
- gfxFrames: array [0..R_GFX_LAST] of DWORD;
-
- procedure r_GFX_Load;
- begin
- g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD+':TEXTURES\TELEPORT', 64, 64, 10, False);
- g_Frames_Get(gfxFrames[R_GFX_TELEPORT], 'FRAMES_TELEPORT');
- g_Frames_Get(gfxFrames[R_GFX_FLAME], 'FRAMES_FLAME');
- g_Frames_Get(gfxFrames[R_GFX_EXPLODE_ROCKET], 'FRAMES_EXPLODE_ROCKET');
- g_Frames_Get(gfxFrames[R_GFX_EXPLODE_BFG], 'FRAMES_EXPLODE_BFG');
- g_Frames_Get(gfxFrames[R_GFX_BFG_HIT], 'FRAMES_BFGHIT');
- g_Frames_Get(gfxFrames[R_GFX_FIRE], 'FRAMES_FIRE');
- g_Frames_Get(gfxFrames[R_GFX_ITEM_RESPAWN], 'FRAMES_ITEM_RESPAWN');
- g_Frames_Get(gfxFrames[R_GFX_SMOKE], 'FRAMES_SMOKE');
- g_Frames_Get(gfxFrames[R_GFX_EXPLODE_SKELFIRE], 'FRAMES_EXPLODE_SKELFIRE');
- g_Frames_Get(gfxFrames[R_GFX_EXPLODE_PLASMA], 'FRAMES_EXPLODE_PLASMA');
- g_Frames_Get(gfxFrames[R_GFX_EXPLODE_BSPFIRE], 'FRAMES_EXPLODE_BSPFIRE');
- g_Frames_Get(gfxFrames[R_GFX_EXPLODE_IMPFIRE], 'FRAMES_EXPLODE_IMPFIRE');
- g_Frames_Get(gfxFrames[R_GFX_EXPLODE_CACOFIRE], 'FRAMES_EXPLODE_CACOFIRE');
- g_Frames_Get(gfxFrames[R_GFX_EXPLODE_BARONFIRE], 'FRAMES_EXPLODE_BARONFIRE');
- end;
-
- procedure r_GFX_Free;
- begin
- g_Frames_DeleteByName('FRAMES_TELEPORT');
- OnceAnims := nil;
- end;
-
- function FindOnceAnim (): DWORD;
- var i: Integer;
- begin
- if OnceAnims <> nil then
- for i := 0 to High(OnceAnims) do
- if OnceAnims[i].Animation.IsInvalid() then
- begin
- Result := i;
- Exit;
- end;
- if OnceAnims = nil then
- begin
- SetLength(OnceAnims, 16);
- Result := 0;
- end
- else
- begin
- Result := High(OnceAnims) + 1;
- SetLength(OnceAnims, Length(OnceAnims) + 16);
- end;
- end;
-
- procedure r_GFX_OnceAnim (AnimType, x, y: Integer);
- var find_id: DWORD; a: TAnimState; alpha: Byte;
- begin
- if not gpart_dbg_enabled then exit;
- find_id := FindOnceAnim();
- alpha := 0;
- case AnimType of
- R_GFX_NONE: a := TAnimState.Create(false, 0, 0);
- R_GFX_TELEPORT: a := TAnimState.Create(false, 6, 10);
- R_GFX_TELEPORT_FAST:
- begin
- AnimType := R_GFX_TELEPORT;
- a := TAnimState.Create(false, 3, 10);
- end;
- R_GFX_FLAME: a := TAnimState.Create(false, 3, 11);
- R_GFX_FLAME_RAND:
- begin
- AnimType := R_GFX_FLAME;
- a := TAnimState.Create(false, 2 + Random(2), 10);
- end;
- R_GFX_EXPLODE_ROCKET: a := TAnimState.Create(false, 6, 6);
- R_GFX_EXPLODE_BFG: a := TAnimState.Create(false, 6, 6);
- R_GFX_BFG_HIT: a := TAnimState.Create(false, 4, 4);
- R_GFX_FIRE: a := TAnimState.Create(false, 4, 8); // !!! TODO: random speed
- R_GFX_ITEM_RESPAWN: a := TAnimState.Create(false, 4, 5);
- R_GFX_SMOKE: a := TAnimState.Create(false, 3, 10);
- R_GFX_SMOKE_TRANS:
- begin
- AnimType := R_GFX_SMOKE;
- a := TAnimState.Create(false, 3, 10);
- alpha := 150;
- end;
- R_GFX_EXPLODE_SKELFIRE: a := TAnimState.Create(false, 8, 3);
- R_GFX_EXPLODE_PLASMA: a := TAnimState.Create(false, 3, 4);
- R_GFX_EXPLODE_BSPFIRE: a := TAnimState.Create(false, 3, 5);
- R_GFX_EXPLODE_IMPFIRE: a := TAnimState.Create(false, 6, 3);
- R_GFX_EXPLODE_CACOFIRE: a := TAnimState.Create(false, 6, 3);
- R_GFX_EXPLODE_BARONFIRE: a := TAnimState.Create(false, 6, 3);
- else
- a := TAnimState.Create(false, 0, 0);
- raise Exception.Create('invalid anim type');
- end;
- OnceAnims[find_id].AnimType := AnimType;
- OnceAnims[find_id].Alpha := alpha;
- OnceAnims[find_id].Animation := a;
- OnceAnims[find_id].Animation.Reset();
- OnceAnims[find_id].Animation.Enable();
- OnceAnims[find_id].x := x;
- OnceAnims[find_id].y := y;
- end;
-
- procedure r_GFX_Update;
- var a: Integer;
- begin
- if OnceAnims <> nil then
- begin
- for a := 0 to High(OnceAnims) do
- begin
- if OnceAnims[a].Animation.IsValid() then
- begin
- OnceAnims[a].oldx := OnceAnims[a].x;
- OnceAnims[a].oldy := OnceAnims[a].y;
- case OnceAnims[a].AnimType of
- R_GFX_FLAME, R_GFX_SMOKE: (*ONCEANIM_SMOKE:*)
- begin
- if Random(3) = 0 then
- OnceAnims[a].x := OnceAnims[a].x-1+Random(3);
- if Random(2) = 0 then
- OnceAnims[a].y := OnceAnims[a].y-Random(2);
- end;
- end;
- if OnceAnims[a].Animation.Played then
- OnceAnims[a].Animation.Invalidate()
- else
- OnceAnims[a].Animation.Update();
- end;
- end;
- end;
- end;
-
-procedure r_GFX_Draw;
- var
- a, len, fx, fy: Integer;
-begin
- if not gpart_dbg_enabled then exit;
-
- if (Particles <> nil) then
- begin
- glDisable(GL_TEXTURE_2D);
- if (g_dbg_scale < 0.6) then glPointSize(1)
- else if (g_dbg_scale > 1.3) then glPointSize(g_dbg_scale+1)
- else glPointSize(2);
- glDisable(GL_POINT_SMOOTH);
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- glBegin(GL_POINTS);
-
- len := High(Particles);
- for a := 0 to len do
- begin
- with Particles[a] do
- begin
- if not alive then continue;
- if (x >= sX) and (y >= sY) and (x <= sX+sWidth) and (sY <= sY+sHeight) then
- begin
- fx := nlerp(oldx, x, gLerpFactor);
- fy := nlerp(oldy, y, gLerpFactor);
- glColor4ub(red, green, blue, alpha);
- glVertex2f(fx+0.37, fy+0.37);
- end;
- end;
- end;
-
- glEnd();
-
- glDisable(GL_BLEND);
- end;
-
- if (OnceAnims <> nil) then
- begin
- len := High(OnceAnims);
- for a := 0 to len do
- begin
- if OnceAnims[a].Animation.IsValid() then
- begin
- with OnceAnims[a] do
- begin
- fx := nlerp(oldx, x, gLerpFactor);
- fy := nlerp(oldy, y, gLerpFactor);
- r_AnimState_Draw(gfxFrames[AnimType], Animation, x, y, Alpha, TMirrorType.None, False);
- end;
- end;
- end;
- end;
-end;
-
-end.
diff --git a/src/game/opengl/r_graphics.pas b/src/game/opengl/r_graphics.pas
+++ /dev/null
@@ -1,2068 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_graphics;
-
-interface
-
-uses
- {$INCLUDE ../nogl/noGLuses.inc}
- {$IFDEF USE_SDL2}
- SDL2,
- {$ENDIF}
- SysUtils, Classes, Math, e_log, r_texture, g_base,
- MAPDEF, ImagingTypes, Imaging, ImagingUtility;
-
-type
- PDFPoint = ^TDFPoint;
-
-//------------------------------------------------------------------
-// прототипы функций
-//------------------------------------------------------------------
-procedure e_InitGL();
-procedure e_SetViewPort(X, Y, Width, Height: Word);
-procedure e_ResizeWindow(Width, Height: Integer);
-function e_ResizeFramebuffer(Width, Height: Integer): Boolean;
-procedure e_BlitFramebuffer(WinWidth, WinHeight: Integer);
-procedure e_SetRenderTarget(Framebuffer: Boolean);
-
-procedure e_Draw(ID: DWORD; X, Y: Integer; Alpha: Byte; AlphaChannel: Boolean;
- Blending: Boolean; Mirror: TMirrorType = TMirrorType.None);
-procedure e_DrawAdv(ID: DWORD; X, Y: Integer; Alpha: Byte; AlphaChannel: Boolean;
- Blending: Boolean; Angle: Single; RC: PDFPoint; Mirror: TMirrorType = TMirrorType.None);
-procedure e_DrawSize(ID: DWORD; X, Y: Integer; Alpha: Byte; AlphaChannel: Boolean;
- Blending: Boolean; Width, Height: Word; Mirror: TMirrorType = TMirrorType.None);
-procedure e_DrawSizeMirror(ID: DWORD; X, Y: Integer; Alpha: Byte; AlphaChannel: Boolean;
- Blending: Boolean; Width, Height: Word; Mirror: TMirrorType = TMirrorType.None);
-
-procedure e_DrawFill(ID: DWORD; X, Y: Integer; XCount, YCount: Word; Alpha: Integer;
- AlphaChannel: Boolean; Blending: Boolean; ambientBlendMode: Boolean=false);
-
-procedure e_DrawFillX (id: DWORD; x, y, wdt, hgt: Integer; alpha: Integer; alphachannel: Boolean;
- blending: Boolean; scale: Single; ambientBlendMode: Boolean=false);
-
-procedure e_AmbientQuad (x, y, w, h: Integer; r, g, b, a: Byte);
-
-procedure e_DrawPoint(Size: Byte; X, Y: Integer; Red, Green, Blue: Byte);
-procedure e_DrawLine(Width: Byte; X1, Y1, X2, Y2: Integer; Red, Green, Blue: Byte; Alpha: Byte = 0);
-procedure e_DrawQuad(X1, Y1, X2, Y2: Integer; Red, Green, Blue: Byte; Alpha: Byte = 0);
-procedure e_DrawFillQuad(X1, Y1, X2, Y2: Integer; Red, Green, Blue, Alpha: Byte;
- Blending: TBlending = TBlending.None);
-procedure e_DarkenQuad (x0, y0, x1, y1: Integer; a: Integer);
-procedure e_DarkenQuadWH (x, y, w, h: Integer; a: Integer);
-
-function e_CreateTextureImg (var img: TImageData; var ID: DWORD): Boolean;
-function e_CreateTexture(FileName: string; var ID: DWORD): Boolean;
-function e_CreateTextureEx(FileName: string; var ID: DWORD; fX, fY, fWidth, fHeight: Word): Boolean;
-function e_CreateTextureMem(pData: Pointer; dataSize: LongInt; var ID: DWORD; filter: Boolean = False): Boolean;
-function e_CreateTextureMemEx(pData: Pointer; dataSize: LongInt; var ID: DWORD; fX, fY, fWidth, fHeight: Word; filter: Boolean = False): Boolean;
-procedure e_GetTextureSize(ID: DWORD; Width, Height: PWord);
-procedure e_DeleteTexture(ID: DWORD);
-procedure e_RemoveAllTextures();
-
-// CharFont
-function e_CharFont_Create(sp: ShortInt=0): DWORD;
-procedure e_CharFont_AddChar(FontID: DWORD; Texture: Integer; c: Char; w: Byte);
-procedure e_CharFont_Print(FontID: DWORD; X, Y: Integer; Text: string);
-procedure e_CharFont_PrintEx(FontID: DWORD; X, Y: Integer; Text: string;
- Color: TRGB; Scale: Single = 1.0);
-procedure e_CharFont_PrintFmt(FontID: DWORD; X, Y: Integer; Text: string);
-procedure e_CharFont_GetSize(FontID: DWORD; Text: string; var w, h: Word);
-procedure e_CharFont_GetSizeFmt(FontID: DWORD; Text: string; var w, h: Word);
-function e_CharFont_GetMaxWidth(FontID: DWORD): Word;
-function e_CharFont_GetMaxHeight(FontID: DWORD): Word;
-procedure e_CharFont_Remove(FontID: DWORD);
-procedure e_CharFont_RemoveAll();
-
-// TextureFont
-procedure e_TextureFontBuild(Tex: DWORD; var FontID: DWORD; XCount, YCount: Word;
- Space: ShortInt=0);
-procedure e_TextureFontKill(FontID: DWORD);
-procedure e_TextureFontPrint(X, Y: GLint; Text: string; FontID: DWORD);
-procedure e_TextureFontPrintEx(X, Y: GLint; Text: string; FontID: DWORD; Red, Green,
- Blue: Byte; Scale: Single; Shadow: Boolean = False);
-procedure e_TextureFontPrintFmt(X, Y: GLint; Text: string; FontID: DWORD;
- Shadow: Boolean = False; Newlines: Boolean = False);
-procedure e_TextureFontGetSize(ID: DWORD; out CharWidth, CharHeight: Byte);
-procedure e_RemoveAllTextureFont();
-
-function e_TextureFontCharWidth (ch: Char; FontID: DWORD): Integer;
-procedure e_TextureFontPrintCharEx (X, Y: Integer; Ch: Char; FontID: DWORD; Shadow: Boolean = False);
-
-procedure e_ReleaseEngine();
-procedure e_BeginRender();
-procedure e_Clear(Mask: TGLbitfield; Red, Green, Blue: Single); overload;
-procedure e_Clear(Red, Green, Blue: Single); overload;
-procedure e_Clear(); overload;
-procedure e_EndRender();
-
-{$IFDEF USE_SDL2}
-function e_GetGamma(win: PSDL_Window): Byte;
-procedure e_SetGamma(win: PSDL_Window;Gamma: Byte);
-{$ENDIF}
-
-procedure e_MakeScreenshot(st: TStream; Width, Height: Word);
-
-//function e_getTextGLId (ID: DWORD): GLuint;
-
-var
- e_Colors: TRGB;
-
-implementation
-
-uses
- paszlib, crc, utils, g_options;
-
-type
- TTexture = record
- tx: GLTexture;
- end;
-
- TTextureFont = record
- Texture: DWORD;
- TextureID: DWORD;
- Base: Uint32;
- CharWidth: Byte;
- CharHeight: Byte;
- XC, YC: WORD;
- SPC: ShortInt;
- end;
-
- TCharFont = record
- Chars: array[0..255] of
- record
- TextureID: Integer;
- Width: Byte;
- end;
- Space: ShortInt;
- Height: ShortInt;
- alive: Boolean;
- end;
-
- TSavedTexture = record
- TexID: DWORD;
- OldID: DWORD;
- Pixels: Pointer;
- end;
-
-var
- e_Textures: array of TTexture = nil;
- e_TextureFonts: array of TTextureFont = nil;
- e_CharFonts: array of TCharFont;
- //e_SavedTextures: array of TSavedTexture;
- e_FBO: GLuint = 0;
- e_RBO: GLuint = 0;
- e_RBOSupported: Boolean = True;
- e_Frame: GLuint = 0;
-
-//function e_getTextGLId (ID: DWORD): GLuint; begin result := e_Textures[ID].tx.id; end;
-
-//------------------------------------------------------------------
-// Инициализирует OpenGL
-//------------------------------------------------------------------
-procedure e_InitGL();
-begin
- if e_NoGraphics then
- begin
- e_DummyTextures := True;
- Exit;
- end;
- e_Colors.R := 255;
- e_Colors.G := 255;
- e_Colors.B := 255;
- glDisable(GL_DEPTH_TEST);
- glEnable(GL_SCISSOR_TEST);
- glClearColor(0, 0, 0, 0);
-end;
-
-procedure e_SetViewPort(X, Y, Width, Height: Word);
-var
- mat: Array [0..15] of GLDouble;
-
-begin
- if e_NoGraphics then Exit;
- glLoadIdentity();
- glScissor(X, Y, Width, Height);
- glViewport(X, Y, Width, Height);
- //gluOrtho2D(0, Width, Height, 0);
-
- glMatrixMode(GL_PROJECTION);
-
- mat[ 0] := 2.0 / Width;
- mat[ 1] := 0.0;
- mat[ 2] := 0.0;
- mat[ 3] := 0.0;
-
- mat[ 4] := 0.0;
- mat[ 5] := -2.0 / Height;
- mat[ 6] := 0.0;
- mat[ 7] := 0.0;
-
- mat[ 8] := 0.0;
- mat[ 9] := 0.0;
- mat[10] := 1.0;
- mat[11] := 0.0;
-
- mat[12] := -1.0;
- mat[13] := 1.0;
- mat[14] := 0.0;
- mat[15] := 1.0;
-
- glLoadMatrixd(@mat[0]);
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-end;
-
-//------------------------------------------------------------------
-// Ищет свободный элемент в массиве текстур
-//------------------------------------------------------------------
-function FindTexture(): DWORD;
-var
- i: integer;
-begin
- if e_Textures <> nil then
- for i := 0 to High(e_Textures) do
- if e_Textures[i].tx.Width = 0 then
- begin
- Result := i;
- Exit;
- end;
-
- if e_Textures = nil then
- begin
- SetLength(e_Textures, 32);
- Result := 0;
- end
- else
- begin
- Result := High(e_Textures) + 1;
- SetLength(e_Textures, Length(e_Textures) + 32);
- end;
-end;
-
-//------------------------------------------------------------------
-// Создает текстуру
-//------------------------------------------------------------------
-function e_CreateTexture(FileName: String; var ID: DWORD): Boolean;
-var
- find_id: DWORD;
- fmt: Word;
-begin
- Result := False;
-
- e_WriteLog('Loading texture from '+FileName, TMsgType.Notify);
-
- find_id := FindTexture();
-
- if not LoadTexture(FileName, e_Textures[find_id].tx, e_Textures[find_id].tx.Width,
- e_Textures[find_id].tx.Height, @fmt) then Exit;
-
- ID := find_id;
-
- Result := True;
-end;
-
-function e_CreateTextureEx(FileName: String; var ID: DWORD; fX, fY, fWidth, fHeight: Word): Boolean;
-var
- find_id: DWORD;
- fmt: Word;
-begin
- Result := False;
-
- find_id := FindTexture();
-
- if not LoadTextureEx(FileName, e_Textures[find_id].tx, fX, fY, fWidth, fHeight, @fmt) then exit;
-
- ID := find_id;
-
- Result := True;
-end;
-
-function e_CreateTextureMem(pData: Pointer; dataSize: LongInt; var ID: DWORD; filter: Boolean = False): Boolean;
-var
- find_id: DWORD;
- fmt: Word;
-begin
- Result := False;
-
- find_id := FindTexture;
-
- if not LoadTextureMem(pData, dataSize, e_Textures[find_id].tx, e_Textures[find_id].tx.Width, e_Textures[find_id].tx.Height, @fmt, filter) then exit;
-
- id := find_id;
-
- Result := True;
-end;
-
-function e_CreateTextureMemEx(pData: Pointer; dataSize: LongInt; var ID: DWORD; fX, fY, fWidth, fHeight: Word; filter: Boolean = False): Boolean;
-var
- find_id: DWORD;
- fmt: Word;
-begin
- Result := False;
-
- find_id := FindTexture();
-
- if not LoadTextureMemEx(pData, dataSize, e_Textures[find_id].tx, fX, fY, fWidth, fHeight, @fmt, filter) then exit;
-
- ID := find_id;
-
- Result := True;
-end;
-
-function e_CreateTextureImg (var img: TImageData; var ID: DWORD): Boolean;
-var
- find_id: DWORD;
- fmt, tw, th: Word;
-begin
- result := false;
- find_id := FindTexture();
- if not LoadTextureImg(img, e_Textures[find_id].tx, tw, th, @fmt) then exit;
- ID := find_id;
- result := True;
-end;
-
-procedure e_GetTextureSize(ID: DWORD; Width, Height: PWord);
-begin
- if Width <> nil then Width^ := e_Textures[ID].tx.Width;
- if Height <> nil then Height^ := e_Textures[ID].tx.Height;
-end;
-
-procedure DestroyFramebuffer;
-begin
- glBindTexture(GL_TEXTURE_2D, 0);
- glBindRenderbuffer(GL_RENDERBUFFER, 0);
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
-
- if e_Frame > 0 then
- begin
- glDeleteTextures(1, @e_Frame);
- e_Frame := 0;
- end;
-
- if e_RBO > 0 then
- begin
- glDeleteRenderbuffers(1, @e_RBO);
- e_RBO := 0;
- end;
-
- if e_FBO > 0 then
- begin
- glDeleteFramebuffers(1, @e_FBO);
- e_FBO := 0;
- end;
-end;
-
-function e_ResizeFramebuffer(Width, Height: Integer): Boolean;
-begin
- Result := False;
-
- if e_NoGraphics then Exit;
-
- DestroyFramebuffer;
-
- glGetError();
-
- glGenFramebuffers(1, @e_FBO);
-
- if glGetError() <> GL_NO_ERROR then
- begin
- e_LogWriteln('GL: glGenFramebuffers failed');
- Exit;
- end;
-
- glGenTextures(1, @e_Frame);
- glBindTexture(GL_TEXTURE_2D, e_Frame);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, Width, Height, 0, GL_RGB, GL_UNSIGNED_BYTE, nil);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-
- if glGetError() <> GL_NO_ERROR then
- begin
- e_LogWriteln('GL: can''t create FBO color buffer');
- DestroyFramebuffer;
- Exit;
- end;
-
- glBindFramebuffer(GL_FRAMEBUFFER, e_FBO);
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, e_Frame, 0);
- if glCheckFramebufferStatus(GL_FRAMEBUFFER) <> GL_FRAMEBUFFER_COMPLETE then
- begin
- e_LogWriteln('GL: can''t construct framebuffer with color attachment');
- DestroyFramebuffer;
- Exit;
- end;
-
-{$IFNDEF USE_GLES1}
- if e_RBOSupported then
- begin
- glGenRenderbuffers(1, @e_RBO);
- glBindRenderbuffer(GL_RENDERBUFFER, e_RBO);
- glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, Width, Height);
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, e_RBO);
- if glCheckFramebufferStatus(GL_FRAMEBUFFER) <> GL_FRAMEBUFFER_COMPLETE then
- begin
- e_LogWriteln('GL: can''t construct framebuffer with depth+stencil attachment, trying without');
- e_RBOSupported := False;
- Result := e_ResizeFramebuffer(Width, Height);
- Exit;
- end;
- end;
-{$ENDIF}
-
- Result := True;
-end;
-
-procedure e_ResizeWindow(Width, Height: Integer);
-begin
- if Height = 0 then
- Height := 1;
- e_SetViewPort(0, 0, Width, Height);
-end;
-
-procedure drawTxQuad (x0, y0, w, h, tw, th: Integer; u, v: single; Mirror: TMirrorType);
-var
- x1, y1, tmp: Integer;
-begin
- if (w < 1) or (h < 1) then exit;
- x1 := x0+w;
- y1 := y0+h;
- if Mirror = TMirrorType.Horizontal then begin tmp := x1; x1 := x0; x0 := tmp; end
- else if Mirror = TMirrorType.Vertical then begin tmp := y1; y1 := y0; y0 := tmp; end;
- glTexCoord2f(0, v); glVertex2i(x0, y0);
- glTexCoord2f(0, 0); glVertex2i(x0, y1);
- glTexCoord2f(u, 0); glVertex2i(x1, y1);
- glTexCoord2f(u, v); glVertex2i(x1, y0);
-end;
-
-procedure e_SetRenderTarget(Framebuffer: Boolean);
-begin
- if (e_FBO = 0) or e_NoGraphics then exit;
- if Framebuffer then
- glBindFramebuffer(GL_FRAMEBUFFER, e_FBO)
- else
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
-end;
-
-procedure e_BlitFramebuffer(WinWidth, WinHeight: Integer);
-begin
- if (e_FBO = 0) or (e_Frame = 0) or e_NoGraphics then exit;
-
- glDisable(GL_BLEND);
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, e_Frame);
- glColor4ub(255, 255, 255, 255);
-
- glBegin(GL_QUADS);
- glTexCoord2f(0, 1); glVertex2i( 0, 0);
- glTexCoord2f(0, 0); glVertex2i( 0, WinHeight);
- glTexCoord2f(1, 0); glVertex2i(WinWidth, WinHeight);
- glTexCoord2f(1, 1); glVertex2i(WinWidth, 0);
- glEnd();
-end;
-
-procedure e_Draw(ID: DWORD; X, Y: Integer; Alpha: Byte; AlphaChannel: Boolean;
- Blending: Boolean; Mirror: TMirrorType = TMirrorType.None);
-begin
- if e_NoGraphics then Exit;
- glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
-
- if (Alpha > 0) or (AlphaChannel) or (Blending) then
- glEnable(GL_BLEND)
- else
- glDisable(GL_BLEND);
-
- if (AlphaChannel) or (Alpha > 0) then
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- if Alpha > 0 then
- glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255-Alpha);
-
- if Blending then
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
-
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, e_Textures[ID].tx.id);
- glBegin(GL_QUADS);
-
- drawTxQuad(X, Y, e_Textures[id].tx.width, e_Textures[id].tx.height, e_Textures[id].tx.width, e_Textures[id].tx.height, e_Textures[ID].tx.u, e_Textures[ID].tx.v, Mirror);
-
- //u := e_Textures[ID].tx.u;
- //v := e_Textures[ID].tx.v;
-
- {
- if Mirror = M_NONE then
- begin
- glTexCoord2f(u, 0); glVertex2i(X + e_Textures[id].tx.Width, Y);
- glTexCoord2f(0, 0); glVertex2i(X, Y);
- glTexCoord2f(0, -v); glVertex2i(X, Y + e_Textures[id].tx.Height);
- glTexCoord2f(u, -v); glVertex2i(X + e_Textures[id].tx.Width, Y + e_Textures[id].tx.Height);
- end
- else
- if Mirror = M_HORIZONTAL then
- begin
- glTexCoord2f(u, 0); glVertex2i(X, Y);
- glTexCoord2f(0, 0); glVertex2i(X + e_Textures[id].tx.Width, Y);
- glTexCoord2f(0, -v); glVertex2i(X + e_Textures[id].tx.Width, Y + e_Textures[id].tx.Height);
- glTexCoord2f(u, -v); glVertex2i(X, Y + e_Textures[id].tx.Height);
- end
- else
- if Mirror = M_VERTICAL then
- begin
- glTexCoord2f(u, -v); glVertex2i(X + e_Textures[id].tx.Width, Y);
- glTexCoord2f(0, -v); glVertex2i(X, Y);
- glTexCoord2f(0, 0); glVertex2i(X, Y + e_Textures[id].tx.Height);
- glTexCoord2f(u, 0); glVertex2i(X + e_Textures[id].tx.Width, Y + e_Textures[id].tx.Height);
- end;
- }
-
- glEnd();
-
- glDisable(GL_BLEND);
-end;
-
-procedure e_DrawSize(ID: DWORD; X, Y: Integer; Alpha: Byte; AlphaChannel: Boolean;
- Blending: Boolean; Width, Height: Word; Mirror: TMirrorType = TMirrorType.None);
-var
- u, v: Single;
-begin
- if e_NoGraphics then Exit;
- glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
-
- if (Alpha > 0) or (AlphaChannel) or (Blending) then
- glEnable(GL_BLEND)
- else
- glDisable(GL_BLEND);
-
- if (AlphaChannel) or (Alpha > 0) then
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- if Alpha > 0 then
- glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255-Alpha);
-
- if Blending then
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
-
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, e_Textures[ID].tx.id);
-
- u := e_Textures[ID].tx.u;
- v := e_Textures[ID].tx.v;
-
- glBegin(GL_QUADS);
- glTexCoord2f(0, v); glVertex2i(X, Y);
- glTexCoord2f(u, v); glVertex2i(X + Width, Y);
- glTexCoord2f(u, 0); glVertex2i(X + Width, Y + Height);
- glTexCoord2f(0, 0); glVertex2i(X, Y + Height);
- glEnd();
-
- glDisable(GL_BLEND);
-end;
-
-procedure e_DrawSizeMirror(ID: DWORD; X, Y: Integer; Alpha: Byte; AlphaChannel: Boolean;
- Blending: Boolean; Width, Height: Word; Mirror: TMirrorType = TMirrorType.None);
-begin
- if e_NoGraphics then Exit;
- glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
-
- if (Alpha > 0) or (AlphaChannel) or (Blending) then
- glEnable(GL_BLEND)
- else
- glDisable(GL_BLEND);
-
- if (AlphaChannel) or (Alpha > 0) then
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- if Alpha > 0 then
- glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255-Alpha);
-
- if Blending then
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
-
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, e_Textures[ID].tx.id);
- glBegin(GL_QUADS);
- drawTxQuad(X, Y, Width, Height, e_Textures[id].tx.width, e_Textures[id].tx.height, e_Textures[ID].tx.u, e_Textures[ID].tx.v, Mirror);
- glEnd();
-
- glDisable(GL_BLEND);
-end;
-
-procedure e_DrawFill(ID: DWORD; X, Y: Integer; XCount, YCount: Word; Alpha: Integer;
- AlphaChannel: Boolean; Blending: Boolean; ambientBlendMode: Boolean=false);
-var
- X2, Y2, dx, w, h: Integer;
- u, v: Single;
-begin
- if e_NoGraphics then Exit;
- glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
- ambientBlendMode := false;
-
- if (Alpha > 0) or AlphaChannel or Blending then
- begin
- glEnable(GL_BLEND);
- end
- else
- begin
- if not ambientBlendMode then glDisable(GL_BLEND);
- end;
- if AlphaChannel or (Alpha > 0) then glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- if (Alpha > 0) then glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255-Alpha);
- if Blending then glBlendFunc(GL_SRC_ALPHA, GL_ONE);
-
- if (XCount = 0) then XCount := 1;
- if (YCount = 0) then YCount := 1;
-
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, e_Textures[ID].tx.id);
-
- X2 := X+e_Textures[ID].tx.width*XCount;
- Y2 := Y+e_Textures[ID].tx.height*YCount;
-
- //k8: this SHOULD work... i hope
- if (e_Textures[ID].tx.width = e_Textures[ID].tx.glwidth) and (e_Textures[ID].tx.height = e_Textures[ID].tx.glheight) then
- begin
- glBegin(GL_QUADS);
- glTexCoord2i(0, YCount); glVertex2i(X, Y);
- glTexCoord2i(XCount, YCount); glVertex2i(X2, Y);
- glTexCoord2i(XCount, 0); glVertex2i(X2, Y2);
- glTexCoord2i(0, 0); glVertex2i(X, Y2);
- glEnd();
- end
- else
- begin
- glBegin(GL_QUADS);
- // hard day's night
- u := e_Textures[ID].tx.u;
- v := e_Textures[ID].tx.v;
- w := e_Textures[ID].tx.width;
- h := e_Textures[ID].tx.height;
- while YCount > 0 do
- begin
- dx := XCount;
- x2 := X;
- while dx > 0 do
- begin
- glTexCoord2f(0, v); glVertex2i(X, Y);
- glTexCoord2f(u, v); glVertex2i(X+w, Y);
- glTexCoord2f(u, 0); glVertex2i(X+w, Y+h);
- glTexCoord2f(0, 0); glVertex2i(X, Y+h);
- Inc(X, w);
- Dec(dx);
- end;
- X := x2;
- Inc(Y, h);
- Dec(YCount);
- end;
- glEnd();
- end;
-
- glDisable(GL_BLEND);
-end;
-
-
-//TODO: overflow checks
-function intersectRect (var x0, y0, w0, h0: Integer; const x1, y1, w1, h1: Integer): Boolean;
-var
- ex0, ey0: Integer;
-begin
- result := false;
- if (w0 < 1) or (h0 < 1) or (w1 < 1) or (h1 < 1) then exit;
- // check for intersection
- if (x0+w0 <= x1) or (y0+h0 <= y1) or (x1+w1 <= x0) or (y1+h1 <= y0) then exit;
- if (x0 >= x1+w1) or (y0 >= y1+h1) or (x1 >= x0+h0) or (y1 >= y0+h0) then exit;
- // ok, intersects
- ex0 := x0+w0;
- ey0 := y0+h0;
- if (x0 < x1) then x0 := x1;
- if (y0 < y1) then y0 := y1;
- if (ex0 > x1+w1) then ex0 := x1+w1;
- if (ey0 > y1+h1) then ey0 := y1+h1;
- w0 := ex0-x0;
- h0 := ey0-y0;
- result := (w0 > 0) and (h0 > 0);
-end;
-
-
-procedure e_DrawFillX (id: DWORD; x, y, wdt, hgt: Integer; alpha: Integer; alphachannel: Boolean;
- blending: Boolean; scale: Single; ambientBlendMode: Boolean=false);
-var
- x2, y2: Integer;
- {
- wassc: Boolean;
- scxywh: array[0..3] of GLint;
- vpxywh: array[0..3] of GLint;
- }
- w, h, dw, cw, ch, yofs: Integer;
- u, v, cu, cv: Single;
- onlyOneY: Boolean;
-
- {
- procedure setScissorGLInternal (x, y, w, h: Integer);
- begin
- //if not scallowed then exit;
- x := trunc(x*scale);
- y := trunc(y*scale);
- w := trunc(w*scale);
- h := trunc(h*scale);
- y := vpxywh[3]-(y+h);
- if not intersectRect(x, y, w, h, scxywh[0], scxywh[1], scxywh[2], scxywh[3]) then
- begin
- glScissor(0, 0, 0, 0);
- end
- else
- begin
- //writeln(' (', x, ',', y, ')-(', w, ',', h, ')');
- glScissor(x, y, w, h);
- end;
- end;
- }
-
-begin
- if e_NoGraphics then exit;
- ambientBlendMode := false;
-
- if (wdt < 1) or (hgt < 1) then exit;
-
- if (wdt mod e_Textures[ID].tx.width = 0) and (hgt mod e_Textures[ID].tx.height = 0) then
- begin
- e_DrawFill(id, x, y, wdt div e_Textures[ID].tx.width, hgt div e_Textures[ID].tx.height, alpha, alphachannel, blending, ambientBlendMode);
- exit;
- end;
-
- glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
-
- if (Alpha > 0) or AlphaChannel or Blending then
- begin
- glEnable(GL_BLEND);
- end
- else
- begin
- if not ambientBlendMode then glDisable(GL_BLEND);
- end;
- if AlphaChannel or (Alpha > 0) then glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- if (Alpha > 0) then glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255-Alpha);
- if Blending then glBlendFunc(GL_SRC_ALPHA, GL_ONE);
-
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, e_Textures[ID].tx.id);
-
- x2 := x+wdt;
- y2 := y+hgt;
-
- //k8: this SHOULD work... i hope
- if {false and} (e_Textures[ID].tx.width = e_Textures[ID].tx.glwidth) and (e_Textures[ID].tx.height = e_Textures[ID].tx.glheight) then
- begin
- glBegin(GL_QUADS);
- glTexCoord2f(0, hgt/e_Textures[ID].tx.height); glVertex2i(x, y);
- glTexCoord2f(wdt/e_Textures[ID].tx.width, hgt/e_Textures[ID].tx.height); glVertex2i(x2, y);
- glTexCoord2f(wdt/e_Textures[ID].tx.width, 0); glVertex2i(x2, y2);
- glTexCoord2f(0, 0); glVertex2i(x, y2);
- glEnd();
- end
- else
- begin
- // hard day's night; setup scissor
- {
- glGetIntegerv(GL_VIEWPORT, @vpxywh[0]);
- wassc := (glIsEnabled(GL_SCISSOR_TEST) <> 0);
- if wassc then glGetIntegerv(GL_SCISSOR_BOX, @scxywh[0]) else glGetIntegerv(GL_VIEWPORT, @scxywh[0]);
- //writeln('(', scxywh[0], ',', scxywh[1], ')-(', scxywh[2], ',', scxywh[3], ')');
- //glEnable(GL_SCISSOR_TEST);
- setScissorGLInternal(x, y, wdt, hgt);
- }
- // draw quads
- u := e_Textures[ID].tx.u;
- v := e_Textures[ID].tx.v;
- w := e_Textures[ID].tx.width;
- h := e_Textures[ID].tx.height;
- x2 := x;
- if (hgt > h) then begin y += hgt-h; onlyOneY := false; end else onlyOneY := true;
- glBegin(GL_QUADS);
- while (hgt > 0) do
- begin
- if (hgt >= h) then begin ch := h; cv := v; yofs := 0; end else begin ch := hgt; cv := v/(h/hgt); yofs := h-hgt; end;
- if onlyOneY then yofs := 0;
- Dec(hgt, h);
- dw := wdt;
- x := x2;
- while (dw > 0) do
- begin
- if (dw >= w) then begin cw := w; cu := u; end else begin cw := dw; cu := u/(w/dw); end;
- Dec(dw, w);
- glTexCoord2f(0, cv); glVertex2i(X, Y+yofs);
- glTexCoord2f(cu, cv); glVertex2i(X+cw, Y+yofs);
- glTexCoord2f(cu, 0); glVertex2i(X+cw, Y+ch+yofs);
- glTexCoord2f(0, 0); glVertex2i(X, Y+ch+yofs);
- Inc(X, w);
- end;
- Dec(Y, h);
- end;
- glEnd();
- //if wassc then glEnable(GL_SCISSOR_TEST) else glDisable(GL_SCISSOR_TEST);
- end;
-
- glDisable(GL_BLEND);
-end;
-
-
-procedure e_AmbientQuad (x, y, w, h: Integer; r, g, b, a: Byte);
-begin
- if e_NoGraphics then exit;
- if (w < 1) or (h < 1) then exit;
- if (a <> 255) or ((r or g or b) <> 0) then
- begin
- glEnable(GL_BLEND);
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, a);
- if ((r or g or b) <> 0) then
- begin
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glBegin(GL_QUADS);
- glVertex2i(x, y);
- glVertex2i(x+w, y);
- glVertex2i(x+w, y+h);
- glVertex2i(x, y+h);
- glEnd();
- end;
- glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
- glBegin(GL_QUADS);
- glVertex2i(x, y);
- glVertex2i(x+w, y);
- glVertex2i(x+w, y+h);
- glVertex2i(x, y+h);
- glEnd();
- glDisable(GL_BLEND);
- end;
-end;
-
-
-procedure e_DrawAdv(ID: DWORD; X, Y: Integer; Alpha: Byte; AlphaChannel: Boolean;
- Blending: Boolean; Angle: Single; RC: PDFPoint; Mirror: TMirrorType = TMirrorType.None);
-begin
- if e_NoGraphics then Exit;
-
- glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
-
- if (Alpha > 0) or (AlphaChannel) or (Blending) then
- glEnable(GL_BLEND)
- else
- glDisable(GL_BLEND);
-
- if (AlphaChannel) or (Alpha > 0) then
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- if Alpha > 0 then
- glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255-Alpha);
-
- if Blending then
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
-
- if (Angle <> 0) and (RC <> nil) then
- begin
- glPushMatrix();
- glTranslatef(X+RC.X, Y+RC.Y, 0);
- glRotatef(Angle, 0, 0, 1);
- glTranslatef(-(X+RC.X), -(Y+RC.Y), 0);
- end;
-
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, e_Textures[id].tx.id);
- glBegin(GL_QUADS); //0-1 1-1
- //00 10
- drawTxQuad(X, Y, e_Textures[id].tx.width, e_Textures[id].tx.height, e_Textures[id].tx.width, e_Textures[id].tx.height, e_Textures[ID].tx.u, e_Textures[ID].tx.v, Mirror);
- glEnd();
-
- if Angle <> 0 then
- glPopMatrix();
-
- glDisable(GL_BLEND);
-end;
-
-procedure e_DrawPoint(Size: Byte; X, Y: Integer; Red, Green, Blue: Byte);
-begin
- if e_NoGraphics then Exit;
- glDisable(GL_TEXTURE_2D);
- glColor3ub(Red, Green, Blue);
- glPointSize(Size);
-
- if (Size = 2) or (Size = 4) then
- X := X + 1;
-
- glBegin(GL_POINTS);
- glVertex2f(X+0.3, Y+1.0);
- glEnd();
-
- glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
-end;
-
-procedure e_LineCorrection(var X1, Y1, X2, Y2: Integer);
-begin
- // Make lines only top-left/bottom-right and top-right/bottom-left
- if Y2 < Y1 then
- begin
- X1 := X1 xor X2;
- X2 := X1 xor X2;
- X1 := X1 xor X2;
-
- Y1 := Y1 xor Y2;
- Y2 := Y1 xor Y2;
- Y1 := Y1 xor Y2;
- end;
-
- // Pixel-perfect hack
- if X1 < X2 then
- Inc(X2)
- else
- Inc(X1);
- Inc(Y2);
-end;
-
-procedure e_DrawQuad(X1, Y1, X2, Y2: Integer; Red, Green, Blue: Byte; Alpha: Byte = 0);
-var
- nX1, nY1, nX2, nY2: Integer;
-begin
- if e_NoGraphics then Exit;
- // Only top-left/bottom-right quad
- if X1 > X2 then
- begin
- X1 := X1 xor X2;
- X2 := X1 xor X2;
- X1 := X1 xor X2;
- end;
- if Y1 > Y2 then
- begin
- Y1 := Y1 xor Y2;
- Y2 := Y1 xor Y2;
- Y1 := Y1 xor Y2;
- end;
-
- if Alpha > 0 then
- begin
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- end
- else
- glDisable(GL_BLEND);
-
- glDisable(GL_TEXTURE_2D);
- glColor4ub(Red, Green, Blue, 255-Alpha);
- glLineWidth(1);
- glBegin(GL_LINES);
- nX1 := X1; nY1 := Y1;
- nX2 := X2; nY2 := Y1;
- e_LineCorrection(nX1, nY1, nX2, nY2); // Pixel-perfect lines
- glVertex2i(nX1, nY1);
- glVertex2i(nX2, nY2);
-
- nX1 := X2; nY1 := Y1;
- nX2 := X2; nY2 := Y2;
- e_LineCorrection(nX1, nY1, nX2, nY2);
- glVertex2i(nX1, nY1);
- glVertex2i(nX2, nY2);
-
- nX1 := X2; nY1 := Y2;
- nX2 := X1; nY2 := Y2;
- e_LineCorrection(nX1, nY1, nX2, nY2);
- glVertex2i(nX1, nY1);
- glVertex2i(nX2, nY2);
-
- nX1 := X1; nY1 := Y2;
- nX2 := X1; nY2 := Y1;
- e_LineCorrection(nX1, nY1, nX2, nY2);
- glVertex2i(nX1, nY1);
- glVertex2i(nX2, nY2);
- glEnd();
- glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
- glDisable(GL_BLEND);
-end;
-
-procedure e_DrawFillQuad(X1, Y1, X2, Y2: Integer; Red, Green, Blue, Alpha: Byte;
- Blending: TBlending = TBlending.None);
-begin
- if e_NoGraphics then Exit;
- if (Alpha > 0) or (Blending <> TBlending.None) then
- glEnable(GL_BLEND)
- else
- glDisable(GL_BLEND);
-
- case Blending of
- TBlending.None: if Alpha > 0 then glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- TBlending.Blend: glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- TBlending.Invert: glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
- TBlending.Filter: glBlendFunc(GL_ZERO, GL_SRC_COLOR);
- end;
-
- glDisable(GL_TEXTURE_2D);
- glColor4ub(Red, Green, Blue, 255-Alpha);
-
- X2 := X2 + 1;
- Y2 := Y2 + 1;
-
- glBegin(GL_QUADS);
- glVertex2i(X1, Y1);
- glVertex2i(X2, Y1);
- glVertex2i(X2, Y2);
- glVertex2i(X1, Y2);
- glEnd();
-
- glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
- glDisable(GL_BLEND);
-end;
-
-
-// ////////////////////////////////////////////////////////////////////////// //
-procedure e_DarkenQuad (x0, y0, x1, y1: Integer; a: Integer);
-begin
- if (a < 0) then a := 0;
- if (a > 255) then a := 255;
- glEnable(GL_BLEND);
- glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
- glDisable(GL_TEXTURE_2D);
- glColor4ub(0, 0, 0, Byte(255-a));
- glBegin(GL_QUADS);
- glVertex2i(x0, y0);
- glVertex2i(x1, y0);
- glVertex2i(x1, y1);
- glVertex2i(x0, y1);
- glEnd();
- //glRect(x, y, x+w, y+h);
- glColor4ub(1, 1, 1, 1);
- glDisable(GL_BLEND);
- //glBlendEquation(GL_FUNC_ADD);
-end;
-
-procedure e_DarkenQuadWH (x, y, w, h: Integer; a: Integer);
-begin
- if (w > 0) and (h > 0) then e_DarkenQuad(x, y, x+w, y+h, a);
-end;
-
-
-procedure e_DrawLine(Width: Byte; X1, Y1, X2, Y2: Integer; Red, Green, Blue: Byte; Alpha: Byte = 0);
-begin
- if e_NoGraphics then Exit;
- // Pixel-perfect lines
- if Width = 1 then
- e_LineCorrection(X1, Y1, X2, Y2);
-
- if Alpha > 0 then
- begin
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- end else
- glDisable(GL_BLEND);
-
- glDisable(GL_TEXTURE_2D);
- glColor4ub(Red, Green, Blue, 255-Alpha);
- glLineWidth(Width);
- glBegin(GL_LINES);
- glVertex2i(X1, Y1);
- glVertex2i(X2, Y2);
- glEnd();
- glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
-
- glDisable(GL_BLEND);
-end;
-
-//------------------------------------------------------------------
-// Удаляет текстуру из массива
-//------------------------------------------------------------------
-procedure e_DeleteTexture(ID: DWORD);
-begin
- if not e_NoGraphics then
- glDeleteTextures(1, @e_Textures[ID].tx.id);
- e_Textures[ID].tx.id := 0;
- e_Textures[ID].tx.Width := 0;
- e_Textures[ID].tx.Height := 0;
-end;
-
-//------------------------------------------------------------------
-// Удаляет все текстуры
-//------------------------------------------------------------------
-procedure e_RemoveAllTextures();
-var
- i: integer;
-begin
- if e_Textures = nil then Exit;
-
- for i := 0 to High(e_Textures) do
- if e_Textures[i].tx.Width <> 0 then e_DeleteTexture(i);
- e_Textures := nil;
-end;
-
-//------------------------------------------------------------------
-// Удаляет движок
-//------------------------------------------------------------------
-procedure e_ReleaseEngine();
-begin
- e_RemoveAllTextures;
- e_RemoveAllTextureFont;
-end;
-
-procedure e_BeginRender();
-begin
- if e_NoGraphics then Exit;
- glEnable(GL_ALPHA_TEST);
- glAlphaFunc(GL_GREATER, 0.0);
-end;
-
-procedure e_Clear(Mask: TGLbitfield; Red, Green, Blue: Single); overload;
-begin
- if e_NoGraphics then Exit;
- glClearColor(Red, Green, Blue, 0);
- glClear(Mask);
-end;
-
-procedure e_Clear(Red, Green, Blue: Single); overload;
-begin
- if e_NoGraphics then Exit;
- glClearColor(Red, Green, Blue, 0);
- glClear(GL_COLOR_BUFFER_BIT);
-end;
-
-procedure e_Clear(); overload;
-begin
- if e_NoGraphics then Exit;
- glClearColor(0, 0, 0, 0);
- glClear(GL_COLOR_BUFFER_BIT);
-end;
-
-procedure e_EndRender();
-begin
- if e_NoGraphics then Exit;
- glPopMatrix();
-end;
-
-{$IFDEF USE_SDL2}
-function e_GetGamma(win: PSDL_Window): Byte;
-var
- ramp: array [0..256*3-1] of Word;
- rgb: array [0..2] of Double;
- sum: double;
- count: integer;
- min: integer;
- max: integer;
- A, B: double;
- i, j: integer;
-begin
- Result := 0;
- if e_NoGraphics then Exit;
- rgb[0] := 1.0;
- rgb[1] := 1.0;
- rgb[2] := 1.0;
-
- SDL_GetWindowGammaRamp(win, @ramp[0], @ramp[256], @ramp[512]);
-
- for i := 0 to 2 do
- begin
- sum := 0;
- count := 0;
- min := 256 * i;
- max := min + 256;
-
- for j := min to max - 1 do
- if ramp[j] > 0 then
- begin
- B := (j mod 256)/256;
- A := ramp[j]/65536;
- sum := sum + ln(A)/ln(B);
- inc(count);
- end;
- rgb[i] := sum / count;
- end;
-
- Result := 100 - Trunc(((rgb[0] + rgb[1] + rgb[2])/3 - 0.23) * 100/(2.7 - 0.23));
-end;
-
-procedure e_SetGamma(win: PSDL_Window; Gamma: Byte);
-var
- ramp: array [0..256*3-1] of Word;
- i: integer;
- r: double;
- g: double;
-begin
- if e_NoGraphics then Exit;
- g := (100 - Gamma)*(2.7 - 0.23)/100 + 0.23;
-
- for i := 0 to 255 do
- begin
- r := Exp(g * ln(i/256))*65536;
- if r < 0 then r := 0
- else if r > 65535 then r := 65535;
- ramp[i] := trunc(r);
- ramp[i + 256] := trunc(r);
- ramp[i + 512] := trunc(r);
- end;
-
- SDL_SetWindowGammaRamp(win, @ramp[0], @ramp[256], @ramp[512]);
-end;
-{$ENDIF}
-
-function e_CharFont_Create(sp: ShortInt=0): DWORD;
-var
- i, id: DWORD;
-begin
- e_WriteLog('Creating CharFont...', TMsgType.Notify);
-
- id := DWORD(-1);
-
- if e_CharFonts <> nil then
- for i := 0 to High(e_CharFonts) do
- if not e_CharFonts[i].alive then
- begin
- id := i;
- Break;
- end;
-
- if id = DWORD(-1) then
- begin
- SetLength(e_CharFonts, Length(e_CharFonts) + 1);
- id := High(e_CharFonts);
- end;
-
- with e_CharFonts[id] do
- begin
- for i := 0 to High(Chars) do
- with Chars[i] do
- begin
- TextureID := -1;
- Width := 0;
- end;
-
- Space := sp;
- alive := True;
- end;
-
- Result := id;
-end;
-
-procedure e_CharFont_AddChar(FontID: DWORD; Texture: Integer; c: Char; w: Byte);
-begin
- with e_CharFonts[FontID].Chars[Ord(c)] do
- begin
- TextureID := Texture;
- Width := w;
- end;
-end;
-
-procedure e_CharFont_Print(FontID: DWORD; X, Y: Integer; Text: string);
-var
- a: Integer;
-begin
- if e_NoGraphics then Exit;
- if Text = '' then Exit;
- if e_CharFonts = nil then Exit;
- if Integer(FontID) > High(e_CharFonts) then Exit;
-
- with e_CharFonts[FontID] do
- begin
- for a := 1 to Length(Text) do
- with Chars[Ord(Text[a])] do
- if TextureID <> -1 then
- begin
- e_Draw(TextureID, X, Y, 0, True, False);
- X := X+Width+IfThen(a = Length(Text), 0, Space);
- end;
- end;
-end;
-
-procedure e_CharFont_PrintEx(FontID: DWORD; X, Y: Integer; Text: string;
- Color: TRGB; Scale: Single = 1.0);
-var
- a: Integer;
- c: TRGB;
-begin
- if e_NoGraphics then Exit;
- if Text = '' then Exit;
- if e_CharFonts = nil then Exit;
- if Integer(FontID) > High(e_CharFonts) then Exit;
-
- with e_CharFonts[FontID] do
- begin
- for a := 1 to Length(Text) do
- with Chars[Ord(Text[a])] do
- if TextureID <> -1 then
- begin
- if Scale <> 1.0 then
- begin
- glPushMatrix;
- glScalef(Scale, Scale, 0);
- end;
-
- c := e_Colors;
- e_Colors := Color;
- e_Draw(TextureID, X, Y, 0, True, False);
- e_Colors := c;
-
- if Scale <> 1.0 then glPopMatrix;
-
- X := X+Width+IfThen(a = Length(Text), 0, Space);
- end;
- end;
-end;
-
-procedure e_CharFont_PrintFmt(FontID: DWORD; X, Y: Integer; Text: string);
-var
- a, TX, TY, len: Integer;
- tc, c: TRGB;
- w, h: Word;
-begin
- if e_NoGraphics then Exit;
- if Text = '' then Exit;
- if e_CharFonts = nil then Exit;
- if Integer(FontID) > High(e_CharFonts) then Exit;
-
- c.R := 255;
- c.G := 255;
- c.B := 255;
-
- TX := X;
- TY := Y;
- len := Length(Text);
-
- e_CharFont_GetSize(FontID, 'A', w, h);
-
- with e_CharFonts[FontID] do
- begin
- for a := 1 to len do
- begin
- case Text[a] of
- #10: // line feed
- begin
- TX := X;
- TY := TY + h;
- continue;
- end;
- #1: // black
- begin
- c.R := 0; c.G := 0; c.B := 0;
- continue;
- end;
- #2: // white
- begin
- c.R := 255; c.G := 255; c.B := 255;
- continue;
- end;
- #3: // darker
- begin
- c.R := c.R div 2; c.G := c.G div 2; c.B := c.B div 2;
- continue;
- end;
- #4: // lighter
- begin
- c.R := Min(c.R * 2, 255); c.G := Min(c.G * 2, 255); c.B := Min(c.B * 2, 255);
- continue;
- end;
- #18: // red
- begin
- c.R := 255; c.G := 0; c.B := 0;
- continue;
- end;
- #19: // green
- begin
- c.R := 0; c.G := 255; c.B := 0;
- continue;
- end;
- #20: // blue
- begin
- c.R := 0; c.G := 0; c.B := 255;
- continue;
- end;
- #21: // yellow
- begin
- c.R := 255; c.G := 255; c.B := 0;
- continue;
- end;
- end;
-
- with Chars[Ord(Text[a])] do
- if TextureID <> -1 then
- begin
- tc := e_Colors;
- e_Colors := c;
- e_Draw(TextureID, TX, TY, 0, True, False);
- e_Colors := tc;
-
- TX := TX+Width+IfThen(a = Length(Text), 0, Space);
- end;
- end;
- end;
-end;
-
-procedure e_CharFont_GetSize(FontID: DWORD; Text: string; var w, h: Word);
-var
- a: Integer;
- h2: Word;
-begin
- w := 0;
- h := 0;
-
- if Text = '' then Exit;
- if e_CharFonts = nil then Exit;
- if Integer(FontID) > High(e_CharFonts) then Exit;
-
- with e_CharFonts[FontID] do
- begin
- for a := 1 to Length(Text) do
- with Chars[Ord(Text[a])] do
- if TextureID <> -1 then
- begin
- w := w+Width+IfThen(a = Length(Text), 0, Space);
- e_GetTextureSize(TextureID, nil, @h2);
- if h2 > h then h := h2;
- end;
- end;
-end;
-
-procedure e_CharFont_GetSizeFmt(FontID: DWORD; Text: string; var w, h: Word);
-var
- a, lines, len: Integer;
- h2, w2, tw, th: Word;
-begin
- w2 := 0;
- h2 := 0;
- tw := 0;
- th := 0;
-
- if Text = '' then Exit;
- if e_CharFonts = nil then Exit;
- if Integer(FontID) > High(e_CharFonts) then Exit;
-
- lines := 1;
- len := Length(Text);
-
- with e_CharFonts[FontID] do
- begin
- for a := 1 to len do
- begin
- if Text[a] = #10 then
- begin
- Inc(lines);
- if w2 > tw then tw := w2;
- w2 := 0;
- continue;
- end;
-
- with Chars[Ord(Text[a])] do
- if TextureID <> -1 then
- begin
- w2 := w2 + Width + IfThen(a = len, 0, Space);
- e_GetTextureSize(TextureID, nil, @h2);
- if h2 > th then th := h2;
- end;
- end;
- end;
-
- if w2 > tw then
- tw := w2;
-
- w := tw;
- h := th * lines;
-end;
-
-function e_CharFont_GetMaxWidth(FontID: DWORD): Word;
-var
- a: Integer;
-begin
- Result := 0;
-
- if e_CharFonts = nil then Exit;
- if Integer(FontID) > High(e_CharFonts) then Exit;
-
- for a := 0 to High(e_CharFonts[FontID].Chars) do
- Result := Max(Result, e_CharFonts[FontID].Chars[a].Width);
-end;
-
-function e_CharFont_GetMaxHeight(FontID: DWORD): Word;
-var
- a: Integer;
- h2: Word;
-begin
- Result := 0;
-
- if e_CharFonts = nil then Exit;
- if Integer(FontID) > High(e_CharFonts) then Exit;
-
- for a := 0 to High(e_CharFonts[FontID].Chars) do
- begin
- if e_CharFonts[FontID].Chars[a].TextureID <> -1 then
- e_GetTextureSize(e_CharFonts[FontID].Chars[a].TextureID, nil, @h2)
- else h2 := 0;
- if h2 > Result then Result := h2;
- end;
-end;
-
-procedure e_CharFont_Remove(FontID: DWORD);
-var
- a: Integer;
-begin
- with e_CharFonts[FontID] do
- for a := 0 to High(Chars) do
- if Chars[a].TextureID <> -1 then e_DeleteTexture(Chars[a].TextureID);
-
- e_CharFonts[FontID].alive := False;
-end;
-
-procedure e_CharFont_RemoveAll();
-var
- a: Integer;
-begin
- if e_CharFonts = nil then Exit;
-
- for a := 0 to High(e_CharFonts) do
- e_CharFont_Remove(a);
-
- e_CharFonts := nil;
-end;
-
-procedure e_TextureFontBuild(Tex: DWORD; var FontID: DWORD; XCount, YCount: Word;
- Space: ShortInt=0);
-var
-{$IFDEF NOGL_LISTS}
- loop1 : GLuint;
- cx, cy : real;
-{$ENDIF}
- i, id: DWORD;
-begin
- if e_NoGraphics then Exit;
- e_WriteLog('Creating texture font...', TMsgType.Notify);
-
- id := DWORD(-1);
-
- if e_TextureFonts <> nil then
- for i := 0 to High(e_TextureFonts) do
- if e_TextureFonts[i].Base = 0 then
- begin
- id := i;
- Break;
- end;
-
- if id = DWORD(-1) then
- begin
- SetLength(e_TextureFonts, Length(e_TextureFonts) + 1);
- id := High(e_TextureFonts);
- end;
-
- with e_TextureFonts[id] do
- begin
-{$IFDEF NOGL_LISTS}
- Base := glGenLists(XCount*YCount);
-{$ENDIF}
- TextureID := e_Textures[Tex].tx.id;
- CharWidth := (e_Textures[Tex].tx.Width div XCount)+Space;
- CharHeight := e_Textures[Tex].tx.Height div YCount;
- XC := XCount;
- YC := YCount;
- Texture := Tex;
- SPC := Space;
- end;
-
-{$IFDEF NOGL_LISTS}
- glBindTexture(GL_TEXTURE_2D, e_Textures[Tex].tx.id);
- for loop1 := 0 to XCount*YCount-1 do
- begin
- cx := (loop1 mod XCount)/XCount;
- cy := (loop1 div YCount)/YCount;
-
- glNewList(e_TextureFonts[id].Base+loop1, GL_COMPILE);
- glBegin(GL_QUADS);
- glTexCoord2f(cx, 1.0-cy-1/YCount);
- glVertex2i(0, e_Textures[Tex].tx.Height div YCount);
-
- glTexCoord2f(cx+1/XCount, 1.0-cy-1/YCount);
- glVertex2i(e_Textures[Tex].tx.Width div XCount, e_Textures[Tex].tx.Height div YCount);
-
- glTexCoord2f(cx+1/XCount, 1.0-cy);
- glVertex2i(e_Textures[Tex].tx.Width div XCount, 0);
-
- glTexCoord2f(cx, 1.0-cy);
- glVertex2i(0, 0);
- glEnd();
- glTranslated((e_Textures[Tex].tx.Width div XCount)+Space, 0, 0);
- glEndList();
- end;
-{$ENDIF}
-
- FontID := id;
-end;
-
-procedure e_TextureFontKill(FontID: DWORD);
-begin
- if e_NoGraphics then Exit;
-{$IFDEF NOGL_LISTS}
- glDeleteLists(e_TextureFonts[FontID].Base, 256);
-{$ENDIF}
- e_TextureFonts[FontID].Base := 0;
-end;
-
-{$IFNDEF NOGL_LISTS}
-procedure e_TextureFontDrawChar(ch: Char; FontID: DWORD);
- var
- index: Integer;
- cx, cy: GLfloat;
- Tex: Integer;
- Width, Height: Integer;
- XCount, YCount: Integer;
-begin
- index := Ord(ch) - 32;
- Tex := e_TextureFonts[FontID].Texture;
- Width := e_Textures[Tex].tx.Width;
- Height := e_Textures[Tex].tx.Height;
- XCount := e_TextureFonts[FontID].XC;
- YCount := e_TextureFonts[FontID].YC;
- cx := (index mod XCount)/XCount;
- cy := (index div YCount)/YCount;
- glBegin(GL_QUADS);
- glTexCoord2f(cx, 1 - cy - 1/YCount);
- glVertex2i(0, Height div YCount);
- glTexCoord2f(cx + 1/XCount, 1 - cy - 1/YCount);
- glVertex2i(Width div XCount, Height div YCount);
- glTexCoord2f(cx + 1/XCount, 1 - cy);
- glVertex2i(Width div XCount, 0);
- glTexCoord2f(cx, 1 - cy);
- glVertex2i(0, 0);
- glEnd();
- glTranslatef((e_Textures[Tex].tx.Width div XCount) + e_TextureFonts[FontID].SPC, 0, 0);
-end;
-
-procedure e_TextureFontDrawString(Text: String; FontID: DWORD);
- var
- i: Integer;
-begin
- for i := 1 to High(Text) do
- e_TextureFontDrawChar(Text[i], FontID);
-end;
-{$ENDIF}
-
-procedure e_TextureFontPrint(X, Y: GLint; Text: string; FontID: DWORD);
-begin
- if e_NoGraphics then Exit;
- if Integer(FontID) > High(e_TextureFonts) then Exit;
- if Text = '' then Exit;
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
-
- glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
-
- glPushMatrix;
- glBindTexture(GL_TEXTURE_2D, e_TextureFonts[FontID].TextureID);
- glEnable(GL_TEXTURE_2D);
- glTranslatef(x, y, 0);
-{$IFDEF NOGL_LISTS}
- glListBase(DWORD(Integer(e_TextureFonts[FontID].Base)-32));
- glCallLists(Length(Text), GL_UNSIGNED_BYTE, PChar(Text));
-{$ELSE}
- e_TextureFontDrawString(Text, FontID);
-{$ENDIF}
- glDisable(GL_TEXTURE_2D);
- glPopMatrix;
-
- glDisable(GL_BLEND);
-end;
-
-// god forgive me for this, but i cannot figure out how to do it without lists
-procedure e_TextureFontPrintChar(X, Y: Integer; Ch: Char; FontID: DWORD; Shadow: Boolean = False);
-begin
- if e_NoGraphics then Exit;
- glPushMatrix;
-
- if Shadow then
- begin
- glColor4ub(0, 0, 0, 128);
- glTranslatef(X+1, Y+1, 0);
-{$IFDEF NOGL_LISTS}
- glCallLists(1, GL_UNSIGNED_BYTE, @Ch);
-{$ELSE}
- e_TextureFontDrawChar(Ch, FontID);
-{$ENDIF}
- glPopMatrix;
- glPushMatrix;
- end;
-
- glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
- glTranslatef(X, Y, 0);
-{$IFDEF NOGL_LISTS}
- glCallLists(1, GL_UNSIGNED_BYTE, @Ch);
-{$ELSE}
- e_TextureFontDrawChar(Ch, FontID);
-{$ENDIF}
-
- glPopMatrix;
-end;
-
-procedure e_TextureFontPrintCharEx (X, Y: Integer; Ch: Char; FontID: DWORD; Shadow: Boolean = False);
-begin
- glBindTexture(GL_TEXTURE_2D, e_TextureFonts[FontID].TextureID);
- glEnable(GL_TEXTURE_2D);
- //glListBase(DWORD(Integer(e_TextureFonts[FontID].Base)-32));
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
- e_TextureFontPrintChar(X, Y, Ch, FontID, Shadow);
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_BLEND);
-end;
-
-function e_TextureFontCharWidth (ch: Char; FontID: DWORD): Integer;
-begin
- result := e_TextureFonts[FontID].CharWidth;
-end;
-
-procedure e_TextureFontPrintFmt(X, Y: GLint; Text: string; FontID: DWORD;
- Shadow: Boolean = False; Newlines: Boolean = False);
-var
- a, TX, TY, len: Integer;
- tc, c: TRGB;
- w, h: Word;
-begin
- if e_NoGraphics then Exit;
- if Text = '' then Exit;
- if e_TextureFonts = nil then Exit;
- if Integer(FontID) > High(e_TextureFonts) then Exit;
-
- c.R := 255;
- c.G := 255;
- c.B := 255;
-
- TX := X;
- TY := Y;
- len := Length(Text);
-
- w := e_TextureFonts[FontID].CharWidth;
- h := e_TextureFonts[FontID].CharHeight;
-
- with e_TextureFonts[FontID] do
- begin
- glBindTexture(GL_TEXTURE_2D, e_TextureFonts[FontID].TextureID);
- glEnable(GL_TEXTURE_2D);
-
-{$IFDEF NOGL_LISTS}
- glListBase(DWORD(Integer(e_TextureFonts[FontID].Base)-32));
-{$ENDIF}
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
-
- for a := 1 to len do
- begin
- case Text[a] of
- #10: // line feed
- begin
- if Newlines then
- begin
- TX := X;
- TY := TY + h;
- continue;
- end;
- end;
- #1: // black
- begin
- c.R := 0; c.G := 0; c.B := 0;
- continue;
- end;
- #2: // white
- begin
- c.R := 255; c.G := 255; c.B := 255;
- continue;
- end;
- #3: // darker
- begin
- c.R := c.R div 2; c.G := c.G div 2; c.B := c.B div 2;
- continue;
- end;
- #4: // lighter
- begin
- c.R := Min(c.R * 2, 255); c.G := Min(c.G * 2, 255); c.B := Min(c.B * 2, 255);
- continue;
- end;
- #18: // red
- begin
- c.R := 255; c.G := 0; c.B := 0;
- continue;
- end;
- #19: // green
- begin
- c.R := 0; c.G := 255; c.B := 0;
- continue;
- end;
- #20: // blue
- begin
- c.R := 0; c.G := 0; c.B := 255;
- continue;
- end;
- #21: // yellow
- begin
- c.R := 255; c.G := 255; c.B := 0;
- continue;
- end;
- end;
-
- tc := e_Colors;
- e_Colors := c;
- e_TextureFontPrintChar(TX, TY, Text[a], FontID, Shadow);
- e_Colors := tc;
-
- TX := TX+w;
- end;
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_BLEND);
- end;
-end;
-
-procedure e_TextureFontPrintEx(X, Y: GLint; Text: string; FontID: DWORD; Red, Green,
- Blue: Byte; Scale: Single; Shadow: Boolean = False);
-begin
- if e_NoGraphics then Exit;
- if Text = '' then Exit;
-
- glPushMatrix;
- glBindTexture(GL_TEXTURE_2D, e_TextureFonts[FontID].TextureID);
- glEnable(GL_TEXTURE_2D);
-
-{$IFDEF NOGL_LISTS}
- glListBase(DWORD(Integer(e_TextureFonts[FontID].Base)-32));
-{$ENDIF}
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
-
- if Shadow then
- begin
- glColor4ub(0, 0, 0, 128);
- glTranslatef(x+1, y+1, 0);
- glScalef(Scale, Scale, 0);
-{$IFDEF NOGL_LISTS}
- glCallLists(Length(Text), GL_UNSIGNED_BYTE, PChar(Text));
-{$ELSE}
- e_TextureFontDrawString(Text, FontID);
-{$ENDIF}
- glPopMatrix;
- glPushMatrix;
- end;
-
- glColor4ub(Red, Green, Blue, 255);
- glTranslatef(x, y, 0);
- glScalef(Scale, Scale, 0);
-{$IFDEF NOGL_LISTS}
- glCallLists(Length(Text), GL_UNSIGNED_BYTE, PChar(Text));
-{$ELSE}
- e_TextureFontDrawString(Text, FontID);
-{$ENDIF}
-
- glDisable(GL_TEXTURE_2D);
- glPopMatrix;
- glColor3ub(e_Colors.R, e_Colors.G, e_Colors.B);
- glDisable(GL_BLEND);
-end;
-
-procedure e_TextureFontGetSize(ID: DWORD; out CharWidth, CharHeight: Byte);
-begin
- CharWidth := 16;
- CharHeight := 16;
- if e_NoGraphics then Exit;
- if Integer(ID) > High(e_TextureFonts) then
- Exit;
- CharWidth := e_TextureFonts[ID].CharWidth;
- CharHeight := e_TextureFonts[ID].CharHeight;
-end;
-
-procedure e_RemoveAllTextureFont();
-var
- i: integer;
-begin
- if e_NoGraphics then Exit;
- if e_TextureFonts = nil then Exit;
-
- for i := 0 to High(e_TextureFonts) do
- if e_TextureFonts[i].Base <> 0 then
- begin
-{$IFDEF NOGL_LISTS}
- glDeleteLists(e_TextureFonts[i].Base, 256);
-{$ENDIF}
- e_TextureFonts[i].Base := 0;
- end;
-
- e_TextureFonts := nil;
-end;
-
-procedure e_MakeScreenshot (st: TStream; Width, Height: Word);
-var
- pixels, obuf, scln, ps, pd: PByte;
- obufsize: Integer;
- dlen: Cardinal;
- i, x, y, res: Integer;
- sign: array [0..7] of Byte;
- hbuf: array [0..12] of Byte;
- crc: LongWord;
- img: TImageData;
- clr: TColor32Rec;
-begin
- if e_NoGraphics then Exit;
- obuf := nil;
-
- // first, extract and pack graphics data
- if (Width mod 4) > 0 then Width := Width+4-(Width mod 4);
-
- GetMem(pixels, Width*Height*3);
- try
- FillChar(pixels^, Width*Height*3, 0);
- glReadPixels(0, 0, Width, Height, GL_RGB, GL_UNSIGNED_BYTE, pixels);
- //e_WriteLog('PNG: pixels read', MSG_NOTIFY);
-
- if e_FastScreenshots then
- begin
- // create scanlines
- GetMem(scln, (Width*3+1)*Height);
- try
- ps := pixels;
- pd := scln;
- Inc(ps, (Width*3)*(Height-1));
- for i := 0 to Height-1 do
- begin
- pd^ := 0; // filter
- Inc(pd);
- Move(ps^, pd^, Width*3);
- Dec(ps, Width*3);
- Inc(pd, Width*3);
- end;
- except
- FreeMem(scln);
- raise;
- end;
- FreeMem(pixels);
- pixels := scln;
-
- // pack it
- obufsize := (Width*3+1)*Height*2;
- GetMem(obuf, obufsize);
- try
- while true do
- begin
- dlen := obufsize;
- res := compress2(Pointer(obuf), dlen, Pointer(pixels), (Width*3+1)*Height, 9);
- if res = Z_OK then break;
- if res <> Z_BUF_ERROR then raise Exception.Create('can''t pack data for PNG');
- obufsize := obufsize*2;
- FreeMem(obuf);
- obuf := nil;
- GetMem(obuf, obufsize);
- end;
- //e_WriteLog(Format('PNG: pixels compressed from %d to %d', [Integer(Width*Height*3), Integer(dlen)]), MSG_NOTIFY);
-
- // now write PNG
-
- // signature
- sign[0] := 137;
- sign[1] := 80;
- sign[2] := 78;
- sign[3] := 71;
- sign[4] := 13;
- sign[5] := 10;
- sign[6] := 26;
- sign[7] := 10;
- st.writeBuffer(sign, 8);
- //e_WriteLog('PNG: signature written', MSG_NOTIFY);
-
- // header
- writeIntBE(st, LongWord(13));
- sign[0] := 73;
- sign[1] := 72;
- sign[2] := 68;
- sign[3] := 82;
- st.writeBuffer(sign, 4);
- crc := crc32(0, @sign[0], 4);
- hbuf[0] := 0;
- hbuf[1] := 0;
- hbuf[2] := (Width shr 8) and $ff;
- hbuf[3] := Width and $ff;
- hbuf[4] := 0;
- hbuf[5] := 0;
- hbuf[6] := (Height shr 8) and $ff;
- hbuf[7] := Height and $ff;
- hbuf[8] := 8; // bit depth
- hbuf[9] := 2; // RGB
- hbuf[10] := 0; // compression method
- hbuf[11] := 0; // filter method
- hbuf[12] := 0; // no interlace
- crc := crc32(crc, @hbuf[0], 13);
- st.writeBuffer(hbuf, 13);
- writeIntBE(st, crc);
- //e_WriteLog('PNG: header written', MSG_NOTIFY);
-
- // image data
- writeIntBE(st, LongWord(dlen));
- sign[0] := 73;
- sign[1] := 68;
- sign[2] := 65;
- sign[3] := 84;
- st.writeBuffer(sign, 4);
- crc := crc32(0, @sign[0], 4);
- crc := crc32(crc, obuf, dlen);
- st.writeBuffer(obuf^, dlen);
- writeIntBE(st, crc);
- //e_WriteLog('PNG: image data written', MSG_NOTIFY);
-
- // image data end
- writeIntBE(st, LongWord(0));
- sign[0] := 73;
- sign[1] := 69;
- sign[2] := 78;
- sign[3] := 68;
- st.writeBuffer(sign, 4);
- crc := crc32(0, @sign[0], 4);
- writeIntBE(st, crc);
- //e_WriteLog('PNG: end marker written', MSG_NOTIFY);
- finally
- if obuf <> nil then FreeMem(obuf);
- end;
- end
- else
- begin
- Imaging.SetOption(ImagingPNGCompressLevel, 9);
- Imaging.SetOption(ImagingPNGPreFilter, 6);
- InitImage(img);
- try
- NewImage(Width, Height, TImageFormat.ifR8G8B8, img);
- ps := pixels;
- //writeln(stderr, 'moving pixels...');
- for y := Height-1 downto 0 do
- begin
- for x := 0 to Width-1 do
- begin
- clr.r := ps^; Inc(ps);
- clr.g := ps^; Inc(ps);
- clr.b := ps^; Inc(ps);
- clr.a := 255;
- SetPixel32(img, x, y, clr);
- end;
- end;
- GlobalMetadata.ClearMetaItems();
- GlobalMetadata.ClearMetaItemsForSaving();
- //writeln(stderr, 'compressing image...');
- if not SaveImageToStream('png', st, img) then raise Exception.Create('screenshot writing error');
- //writeln(stderr, 'done!');
- finally
- FreeImage(img);
- end;
- end;
- finally
- FreeMem(pixels);
- end;
-end;
-
-
-end.
diff --git a/src/game/opengl/r_gui.pas b/src/game/opengl/r_gui.pas
+++ /dev/null
@@ -1,717 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_gui;
-
-interface
-
- uses g_gui;
-
- procedure r_GUI_Load;
- procedure r_GUI_Free;
-
- procedure r_GUI_GetSize (ctrl: TGUIControl; out w, h: Integer);
- procedure r_GUI_GetLogoSize (out w, h: Integer);
- procedure r_GUI_GetMaxFontSize (BigFont: Boolean; out w, h: Integer);
- procedure r_GUI_GetStringSize (BigFont: Boolean; str: String; out w, h: Integer);
-
- procedure r_GUI_Draw_Window (win: TGUIWindow);
-
-implementation
-
- uses
- Classes, Math,
- MAPDEF, utils,
- g_basic, g_base, e_input, g_options,
- r_graphics, r_textures, r_playermodel, r_game,
- g_game, g_menu
- ;
-
- const
- BOX1 = 'BOX1';
- BOX2 = 'BOX2';
- BOX3 = 'BOX3';
- BOX4 = 'BOX4';
- BOX5 = 'BOX5';
- BOX6 = 'BOX6';
- BOX7 = 'BOX7';
- BOX8 = 'BOX8';
- BOX9 = 'BOX9';
-
- MAINMENU_MARKER1 = 'MAINMENU_MARKER1';
- MAINMENU_MARKER2 = 'MAINMENU_MARKER2';
- SCROLL_LEFT = 'SCROLL_LEFT';
- SCROLL_RIGHT = 'SCROLL_RIGHT';
- SCROLL_MIDDLE = 'SCROLL_MIDDLE';
- SCROLL_MARKER = 'SCROLL_MARKER';
- EDIT_LEFT = 'EDIT_LEFT';
- EDIT_RIGHT = 'EDIT_RIGHT';
- EDIT_MIDDLE = 'EDIT_MIDDLE';
- EDIT_CURSORCOLOR: TRGB = (R:200; G:0; B:0);
- EDIT_CURSORLEN = 10;
- BSCROLL_UPA = 'BSCROLL_UP_A';
- BSCROLL_UPU = 'BSCROLL_UP_U';
- BSCROLL_DOWNA = 'BSCROLL_DOWN_A';
- BSCROLL_DOWNU = 'BSCROLL_DOWN_U';
- BSCROLL_MIDDLE = 'BSCROLL_MIDDLE';
-
- type
- TFontType = (Texture, Character);
-
- TFont = class{$IFDEF USE_MEMPOOL}(TPoolObject){$ENDIF}
- private
- FID: DWORD;
- FScale: Single;
- FFontType: TFontType;
- public
- constructor Create(FontID: DWORD; FontType: TFontType);
- destructor Destroy; override;
- procedure Draw(X, Y: Integer; Text: string; R, G, B: Byte);
- procedure GetTextSize(Text: string; var w, h: Word);
- property Scale: Single read FScale write FScale;
- property ID: DWORD read FID;
- end;
-
- var
- Box: Array [0..8] of DWORD;
- MarkerID: array [Boolean] of DWORD;
- ScrollLeft, ScrollRight, ScrollMiddle, ScrollMarker: DWORD;
- EditLeft, EditRight, EditMiddle: DWORD;
-
- Font: array [boolean] of TFont; (* Small[FALSE] / Big[TRUE] *)
- LogoTex: DWORD;
-
- constructor TFont.Create (FontID: DWORD; FontType: TFontType);
- begin
- FID := FontID;
- FScale := 1;
- FFontType := FontType;
- end;
-
- destructor TFont.Destroy;
- begin
- inherited;
- end;
-
- procedure TFont.Draw (X, Y: Integer; Text: string; R, G, B: Byte);
- begin
- if FFontType = TFontType.Character then
- e_CharFont_PrintEx(ID, X, Y, Text, _RGB(R, G, B), FScale)
- else
- e_TextureFontPrintEx(X, Y, Text, ID, R, G, B, FScale)
- end;
-
- procedure TFont.GetTextSize (Text: string; var w, h: Word);
- var cw, ch: Byte;
- begin
- if FFontType = TFontType.Character then
- e_CharFont_GetSize(ID, Text, w, h)
- else
- begin
- e_TextureFontGetSize(ID, cw, ch);
- w := cw * Length(Text);
- h := ch;
- end;
- w := Round(w * FScale);
- h := Round(h * FScale);
- end;
-
- procedure r_GUI_GetMaxFontSize (BigFont: Boolean; out w, h: Integer);
- var f: TFont;
- begin
- f := Font[BigFont];
- w := e_CharFont_GetMaxWidth(f.ID);
- h := e_CharFont_GetMaxHeight(f.ID);
- end;
-
- procedure r_GUI_GetStringSize (BigFont: Boolean; str: String; out w, h: Integer);
- var ww, hh: WORD;
- begin
- e_CharFont_GetSize(Font[BigFont].ID, str, ww, hh);
- w := ww;
- h := hh;
- end;
-
- procedure r_GUI_GetLogoSize (out w, h: Integer);
- var ww, hh: WORD;
- begin
- ww := 0;
- hh := 0;
- if LogoTex <> 0 then
- e_GetTextureSize(LogoTex, @ww, @hh);
- w := ww;
- h := hh;
- end;
-
- procedure r_GUI_Load;
- begin
- g_Texture_CreateWADEx('MAINMENU_LOGO', GameWAD + ':TEXTURES\MAINLOGO');
- g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD + ':TEXTURES\MARKER1');
- g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD + ':TEXTURES\MARKER2');
- g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD + ':TEXTURES\SLEFT');
- g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD + ':TEXTURES\SRIGHT');
- g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD + ':TEXTURES\SMIDDLE');
- g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD + ':TEXTURES\SMARKER');
- g_Texture_CreateWADEx('EDIT_LEFT', GameWAD + ':TEXTURES\ELEFT');
- g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD + ':TEXTURES\ERIGHT');
- g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD + ':TEXTURES\EMIDDLE');
- g_Texture_CreateWADEx('BOX1', GameWAD + ':TEXTURES\BOX1');
- g_Texture_CreateWADEx('BOX2', GameWAD + ':TEXTURES\BOX2');
- g_Texture_CreateWADEx('BOX3', GameWAD + ':TEXTURES\BOX3');
- g_Texture_CreateWADEx('BOX4', GameWAD + ':TEXTURES\BOX4');
- g_Texture_CreateWADEx('BOX5', GameWAD + ':TEXTURES\BOX5');
- g_Texture_CreateWADEx('BOX6', GameWAD + ':TEXTURES\BOX6');
- g_Texture_CreateWADEx('BOX7', GameWAD + ':TEXTURES\BOX7');
- g_Texture_CreateWADEx('BOX8', GameWAD + ':TEXTURES\BOX8');
- g_Texture_CreateWADEx('BOX9', GameWAD + ':TEXTURES\BOX9');
- g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD + ':TEXTURES\SCROLLUPA');
- g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD + ':TEXTURES\SCROLLUPU');
- g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD + ':TEXTURES\SCROLLDOWNA');
- g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD + ':TEXTURES\SCROLLDOWNU');
- g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD + ':TEXTURES\SCROLLMIDDLE');
- g_Texture_CreateWADEx('NOPIC', GameWAD + ':TEXTURES\NOPIC');
-
- g_Texture_Get(MAINMENU_MARKER1, MarkerID[FALSE]);
- g_Texture_Get(MAINMENU_MARKER2, MarkerID[TRUE]);
-
- g_Texture_Get(BOX1, Box[0]);
- g_Texture_Get(BOX2, Box[1]);
- g_Texture_Get(BOX3, Box[2]);
- g_Texture_Get(BOX4, Box[3]);
- g_Texture_Get(BOX5, Box[4]);
- g_Texture_Get(BOX6, Box[5]);
- g_Texture_Get(BOX7, Box[6]);
- g_Texture_Get(BOX8, Box[7]);
- g_Texture_Get(BOX9, Box[8]);
-
- g_Texture_Get(SCROLL_LEFT, ScrollLeft);
- g_Texture_Get(SCROLL_RIGHT, ScrollRight);
- g_Texture_Get(SCROLL_MIDDLE, ScrollMiddle);
- g_Texture_Get(SCROLL_MARKER, ScrollMarker);
-
- g_Texture_Get(EDIT_LEFT, EditLeft);
- g_Texture_Get(EDIT_RIGHT, EditRight);
- g_Texture_Get(EDIT_MIDDLE, EditMiddle);
-
- Font[FALSE] := TFont.Create(gMenuSmallFont, TFontType.Character);
- Font[TRUE] := TFont.Create(gMenuFont, TFontType.Character);
-
- g_Texture_Get('MAINMENU_LOGO', LogoTex)
- end;
-
- procedure r_GUI_Free;
- begin
- g_Texture_Delete('MAINMENU_LOGO');
- g_Texture_Delete('MAINMENU_MARKER1');
- g_Texture_Delete('MAINMENU_MARKER2');
- g_Texture_Delete('SCROLL_LEFT');
- g_Texture_Delete('SCROLL_RIGHT');
- g_Texture_Delete('SCROLL_MIDDLE');
- g_Texture_Delete('SCROLL_MARKER');
- g_Texture_Delete('EDIT_LEFT');
- g_Texture_Delete('EDIT_RIGHT');
- g_Texture_Delete('EDIT_MIDDLE');
- g_Texture_Delete('BOX1');
- g_Texture_Delete('BOX2');
- g_Texture_Delete('BOX3');
- g_Texture_Delete('BOX4');
- g_Texture_Delete('BOX5');
- g_Texture_Delete('BOX6');
- g_Texture_Delete('BOX7');
- g_Texture_Delete('BOX8');
- g_Texture_Delete('BOX9');
- g_Texture_Delete('BSCROLL_UP_A');
- g_Texture_Delete('BSCROLL_UP_U');
- g_Texture_Delete('BSCROLL_DOWN_A');
- g_Texture_Delete('BSCROLL_DOWN_U');
- g_Texture_Delete('BSCROLL_MIDDLE');
- g_Texture_Delete('NOPIC');
- end;
-
- procedure r_GUI_GetSize_TextButton (ctrl: TGUITextButton; out w, h: Integer);
- var ww, hh: WORD; f: TFont;
- begin
- f := Font[ctrl.BigFont];
- f.GetTextSize(ctrl.Caption, ww, hh);
- w := ww;
- h := hh;
- end;
-
- procedure r_GUI_GetSize_Label (ctrl: TGUILabel; out w, h: Integer);
- var ww, hh: WORD; f: TFont;
- begin
- f := Font[ctrl.BigFont];
- f.GetTextSize(ctrl.Text, ww, hh);
- h := hh;
- if ctrl.FixedLength = 0 then
- w := ww
- else
- w := e_CharFont_GetMaxWidth(f.ID) * ctrl.FixedLength
- end;
-
- procedure r_GUI_GetSize_Switch (ctrl: TGUISwitch; out w, h: Integer);
- var i: Integer; ww, hh: WORD; f: TFont;
- begin
- w := 0;
- h := 0;
- if ctrl.Items <> nil then
- begin
- for i := 0 to High(ctrl.Items) do
- begin
- f := Font[ctrl.BigFont];
- f.GetTextSize(ctrl.Items[i], ww, hh);
- if ww > w then
- w := ww;
- end;
- end;
- end;
-
- procedure r_GUI_GetSize_KeyRead (ctrl: TGUIKeyRead; out w, h: Integer);
- var i: Integer; ww, hh: WORD; f: TFont;
- begin
- w := 0;
- h := 0; // ??? always 0
- f := Font[ctrl.BigFont];
- for i := 0 to 255 do
- begin
- f.GetTextSize(e_KeyNames[i], ww, hh);
- w := MAX(w, ww);
- end;
- f.GetTextSize(KEYREAD_QUERY, ww, hh);
- if ww > w then w := ww;
- f.GetTextSize(KEYREAD_CLEAR, ww, hh);
- if ww > w then w := ww;
- end;
-
- procedure r_GUI_GetSize (ctrl: TGUIControl; out w, h: Integer);
- begin
- w := 0;
- h := 0;
- if ctrl is TGUITextButton then
- r_GUI_GetSize_TextButton(ctrl as TGUITextButton, w, h)
- else if ctrl is TGUILabel then
- r_GUI_GetSize_Label(ctrl as TGUILabel, w, h)
- else if ctrl is TGUIScroll then
- w := 16 + ((ctrl as TGUIScroll).Max + 1) * 8 // ??? but h = 0
- else if ctrl is TGUISwitch then
- r_GUI_GetSize_Switch(ctrl as TGUISwitch, w, h)
- else if ctrl is TGUIEdit then
- w := 16 + (ctrl as TGUIEdit).Width * 16 // ??? but h = 0
- else if ctrl is TGUIKeyRead then
- r_GUI_GetSize_KeyRead(ctrl as TGUIKeyRead, w, h)
- else if ctrl is TGUIKeyRead2 then
- w := (ctrl as TGUIKeyRead2).MaxKeyNameWdt * 2 + 8 + 8 + 16 // ??? but h = 0
- else if ctrl is TGUIListBox then
- begin
- w := 8 + ((ctrl as TGUIListBox).Width + 1) * 16; // recheck w & h
- h := 8 + (ctrl as TGUIListBox).Height * 16;
- end
- else if ctrl is TGUIMemo then
- begin
- w := 8 + ((ctrl as TGUIMemo).Width + 1) * 16;
- h := 8 + (ctrl as TGUIMemo).Height * 16;
- end
- else
- begin
- w := ctrl.GetWidth();
- h := ctrl.GetHeight();
- end;
- end;
-
- procedure r_GUI_Draw_Control (ctrl: TGUIControl); forward;
-
- procedure r_GUI_Draw_TextButton (ctrl: TGUITextButton);
- var f: TFont;
- begin
- f := Font[ctrl.BigFont];
- f.Draw(ctrl.X, ctrl.Y, ctrl.Caption, ctrl.Color.R, ctrl.Color.G, ctrl.Color.B)
- end;
-
- procedure r_GUI_Draw_Label (ctrl: TGUILabel);
- var w, h: Word; f: TFont;
- begin
- f := Font[ctrl.BigFont];
- if ctrl.RightAlign then
- begin
- f.GetTextSize(ctrl.Text, w, h);
- f.Draw(ctrl.X + ctrl.CMaxWidth - w, ctrl.Y, ctrl.Text, ctrl.Color.R, ctrl.Color.G, ctrl.Color.B);
- end
- else
- f.Draw(ctrl.X, ctrl.Y, ctrl.Text, ctrl.Color.R, ctrl.Color.G, ctrl.Color.B);
- end;
-
- procedure r_GUI_Draw_Scroll (ctrl: TGUIScroll);
- var a: Integer;
- begin
- e_Draw(ScrollLeft, ctrl.X, ctrl.Y, 0, True, False);
- e_Draw(ScrollRight, ctrl.X + 8 + (ctrl.Max + 1) * 8, ctrl.Y, 0, True, False);
- for a := 0 to ctrl.Max do
- e_Draw(ScrollMiddle, ctrl.X + 8 + a * 8, ctrl.Y, 0, True, False);
- e_Draw(ScrollMarker, ctrl.X + 8 + ctrl.Value * 8, ctrl.Y, 0, True, False);
- end;
-
- procedure r_GUI_Draw_Switch (ctrl: TGUISwitch);
- var f: TFont;
- begin
- f := Font[ctrl.BigFont];
- f.Draw(ctrl.X, ctrl.Y, ctrl.Items[ctrl.ItemIndex], ctrl.Color.R, ctrl.Color.G, ctrl.Color.B);
- end;
-
- procedure r_GUI_Draw_Edit (ctrl: TGUIEdit);
- var c, w, h: Word; r, g, b: Byte; f: TFont;
- begin
- e_Draw(EditLeft, ctrl.X, ctrl.Y, 0, True, False);
- e_Draw(EditRight, ctrl.X + 8 + ctrl.Width * 16, ctrl.Y, 0, True, False);
- for c := 0 to ctrl.Width - 1 do
- e_Draw(EditMiddle, ctrl.X + 8 + c * 16, ctrl.Y, 0, True, False);
- r := ctrl.Color.R;
- g := ctrl.Color.G;
- b := ctrl.Color.B;
- if ctrl.Invalid and (ctrl.Window.ActiveControl <> ctrl) then
- begin
- r := 128;
- g := 128;
- b := 128;
- end;
- f := Font[ctrl.BigFont];
- f.Draw(ctrl.X + 8, ctrl.Y, ctrl.Text, r, g, b);
- if ctrl.Window.ActiveControl = ctrl then
- begin
- f.GetTextSize(Copy(ctrl.Text, 1, ctrl.CaretPos), w, h);
- h := e_CharFont_GetMaxHeight(f.ID);
- e_DrawLine(2, ctrl.X + 8 + w, ctrl.Y + h - 3, ctrl.X + 8 + w + EDIT_CURSORLEN, ctrl.Y + h - 3, EDIT_CURSORCOLOR.R, EDIT_CURSORCOLOR.G, EDIT_CURSORCOLOR.B);
- end;
- end;
-
- procedure r_GUI_Draw_KeyRead (ctrl: TGUIKeyRead);
- var k: AnsiString; f: TFont;
- begin
- if ctrl.IsQuery then
- k := KEYREAD_QUERY
- else if ctrl.Key <> 0 then
- k := e_KeyNames[ctrl.Key]
- else
- k := KEYREAD_CLEAR;
- f := Font[ctrl.BigFont];
- f.Draw(ctrl.X, ctrl.Y, k, ctrl.Color.R, ctrl.Color.G, ctrl.Color.B);
- end;
-
- procedure r_GUI_Draw_KeyRead2 (ctrl: TGUIKeyRead2);
-
- procedure drawText (idx: Integer);
- var x, y: Integer; r, g, b: Byte; kk: DWORD; str: AnsiString; f: TFont;
- begin
- if idx = 0 then kk := ctrl.Key0 else kk := ctrl.Key1;
- y := ctrl.Y;
- if idx = 0 then x := ctrl.X + 8 else x := ctrl.X + 8 + ctrl.MaxKeyNameWdt + 16;
- r := 255;
- g := 0;
- b := 0;
- if ctrl.KeyIdx = idx then
- begin
- r := 255; g := 255; b := 255;
- end;
- f := Font[ctrl.BigFont];
- if ctrl.IsQuery and (ctrl.KeyIdx = idx) then
- begin
- f.Draw(x, y, KEYREAD_QUERY, r, g, b)
- end
- else
- begin
- if kk <> 0 then
- str := e_KeyNames[kk]
- else
- str := KEYREAD_CLEAR;
- f.Draw(x, y, str, r, g, b);
- end
- end;
-
- begin
- drawText(0);
- drawText(1);
- end;
-
- procedure DrawBox(X, Y: Integer; Width, Height: Word);
- begin
- e_Draw(Box[0], X, Y, 0, False, False);
- e_DrawFill(Box[1], X + 4, Y, Width * 4, 1, 0, False, False);
- e_Draw(Box[2], X + 4 + Width * 16, Y, 0, False, False);
- e_DrawFill(Box[3], X, Y + 4, 1, Height * 4, 0, False, False);
- e_DrawFill(Box[4], X + 4, Y + 4, Width, Height, 0, False, False);
- e_DrawFill(Box[5], X + 4 + Width * 16, Y + 4, 1, Height * 4, 0, False, False);
- e_Draw(Box[6], X, Y + 4 + Height * 16, 0, False, False);
- e_DrawFill(Box[7], X + 4, Y + 4 + Height * 16, Width * 4, 1, 0, False, False);
- e_Draw(Box[8], X + 4 + Width * 16, Y + 4 + Height * 16, 0, False, False);
- end;
-
- procedure r_GUI_Draw_ModelView (ctrl: TGUIModelView);
- begin
- DrawBox(ctrl.X, ctrl.Y, 4, 4);
- if ctrl.Model <> nil then
- r_PlayerModel_Draw(ctrl.Model, ctrl.X + 4, ctrl.Y + 4);
- end;
-
- procedure r_GUI_Draw_MapPreview (ctrl: TGUIMapPreview);
- var a: Integer; r, g, b: Byte;
- begin
- DrawBox(ctrl.X, ctrl.Y, MAPPREVIEW_WIDTH, MAPPREVIEW_HEIGHT);
- if (ctrl.MapSize.X <= 0) or (ctrl.MapSize.Y <= 0) then
- Exit;
- e_DrawFillQuad(ctrl.X + 4, ctrl.Y + 4, ctrl.X + 4 + Trunc(ctrl.MapSize.X / ctrl.Scale) - 1, ctrl.Y + 4 + Trunc(ctrl.MapSize.Y / ctrl.Scale) - 1, 32, 32, 32, 0);
- if ctrl.MapData <> nil then
- for a := 0 to High(ctrl.MapData) do
- with ctrl.MapData[a] do
- begin
- if X1 > MAPPREVIEW_WIDTH * 16 then Continue;
- if Y1 > MAPPREVIEW_HEIGHT * 16 then Continue;
- if X2 < 0 then Continue;
- if Y2 < 0 then Continue;
- if X2 > MAPPREVIEW_WIDTH * 16 then X2 := MAPPREVIEW_WIDTH * 16;
- if Y2 > MAPPREVIEW_HEIGHT * 16 then Y2 := MAPPREVIEW_HEIGHT * 16;
- if X1 < 0 then X1 := 0;
- if Y1 < 0 then Y1 := 0;
- case PanelType of
- PANEL_WALL:
- begin
- r := 255; g := 255; b := 255;
- end;
- PANEL_CLOSEDOOR:
- begin
- r := 255; g := 255; b := 0;
- end;
- PANEL_WATER:
- begin
- r := 0; g := 0; b := 192;
- end;
- PANEL_ACID1:
- begin
- r := 0; g := 176; b := 0;
- end;
- PANEL_ACID2:
- begin
- r := 176; g := 0; b := 0;
- end;
- else
- r := 128; g := 128; b := 128;
- end;
- if ((X2 - X1) > 0) and ((Y2 - Y1) > 0) then
- e_DrawFillQuad(ctrl.X + 4 + X1, ctrl.Y + 4 + Y1, ctrl.X + 4 + X2 - 1, ctrl.Y + 4 + Y2 - 1, r, g, b, 0);
- end;
- end;
-
- procedure r_GUI_Draw_Image (ctrl: TGUIImage);
- var ID: DWORD;
- begin
- if ctrl.ImageRes = '' then
- begin
- if g_Texture_Get(ctrl.DefaultRes, ID) then
- e_Draw(ID, ctrl.X, ctrl.Y, 0, True, False);
- end
- else
- begin
- if g_Texture_CreateWADEx(ctrl.ImageRes, ctrl.ImageRes) then
- begin
- if g_Texture_Get(ctrl.ImageRes, ID) then
- e_Draw(ID, ctrl.X, ctrl.Y, 0, True, False);
- g_Texture_Delete(ctrl.ImageRes);
- end;
- end;
- end;
-
- procedure DrawScroll(X, Y: Integer; Height: Word; Up, Down: Boolean);
- var ID: DWORD;
- begin
- if Height < 3 then
- Exit;
- if Up then
- g_Texture_Get(BSCROLL_UPA, ID)
- else
- g_Texture_Get(BSCROLL_UPU, ID);
- e_Draw(ID, X, Y, 0, False, False);
- if Down then
- g_Texture_Get(BSCROLL_DOWNA, ID)
- else
- g_Texture_Get(BSCROLL_DOWNU, ID);
- e_Draw(ID, X, Y + (Height - 1) * 16, 0, False, False);
- g_Texture_Get(BSCROLL_MIDDLE, ID);
- e_DrawFill(ID, X, Y + 16, 1, Height - 2, 0, False, False);
- end;
-
- procedure r_GUI_Draw_ListBox (ctrl: TGUIListBox); // + TGUIFileListBox
- var w2, h2: Word; a: Integer; s: string; f: TFont;
- begin
- if ctrl.DrawBack then
- DrawBox(ctrl.X, ctrl.Y, ctrl.Width + 1, ctrl.Height);
- if ctrl.DrawScrollBar then
- DrawScroll(ctrl.X + 4 + ctrl.Width * 16, ctrl.Y + 4, ctrl.Height, (ctrl.StartLine > 0) and (ctrl.Items <> nil), (ctrl.StartLine + ctrl.Height - 1 < High(ctrl.Items)) and (ctrl.Items <> nil));
- if ctrl.Items <> nil then
- begin
- f := Font[ctrl.BigFont];
- for a := ctrl.StartLine to Min(High(ctrl.Items), ctrl.StartLine + ctrl.Height - 1) do
- begin
- s := ctrl.Items[a];
- f.GetTextSize(s, w2, h2);
- while (Length(s) > 0) and (w2 > ctrl.Width * 16) do
- begin
- SetLength(s, Length(s) - 1);
- f.GetTextSize(s, w2, h2);
- end;
- if a = ctrl.ItemIndex then
- f.Draw(ctrl.X + 4, ctrl.Y + 4 + (a - ctrl.StartLine) * 16, s, ctrl.ActiveColor.R, ctrl.ActiveColor.G, ctrl.ActiveColor.B)
- else
- f.Draw(ctrl.X + 4, ctrl.Y + 4 + (a - ctrl.StartLine) * 16, s, ctrl.UnActiveColor.R, ctrl.UnActiveColor.G, ctrl.UnActiveColor.B);
- end;
- end;
- end;
-
- procedure r_GUI_Draw_Memo (ctrl: TGUIMemo);
- var a: Integer; f: TFont;
- begin
- f := Font[ctrl.BigFont];
- if ctrl.DrawBack then
- DrawBox(ctrl.X, ctrl.Y, ctrl.Width + 1, ctrl.Height);
- if ctrl.DrawScrollBar then
- DrawScroll(ctrl.X + 4 + ctrl.Width * 16, ctrl.Y + 4, ctrl.Height, (ctrl.StartLine > 0) and (ctrl.Lines <> nil), (ctrl.StartLine + ctrl.Height - 1 < High(ctrl.Lines)) and (ctrl.Lines <> nil));
- if ctrl.Lines <> nil then
- for a := ctrl.StartLine to Min(High(ctrl.Lines), ctrl.StartLine + ctrl.Height - 1) do
- f.Draw(ctrl.X + 4, ctrl.Y + 4 + (a - ctrl.StartLine) * 16, ctrl.Lines[a], ctrl.Color.R, ctrl.Color.G, ctrl.Color.B);
- end;
-
- procedure r_GUI_Draw_MainMenu (ctrl: TGUIMainMenu);
- var a: Integer; w, h: Word; ID: DWORD;
- begin
- if ctrl.Header <> nil then
- begin
- r_GUI_Draw_Label(ctrl.Header)
- end
- else if LogoTex <> 0 then
- begin
- e_GetTextureSize(LogoTex, @w, @h);
- e_Draw(LogoTex, ((gScreenWidth div 2) - (w div 2)), ctrl.Buttons[0].Y - ctrl.Buttons[0].GetHeight - h, 0, True, False);
- end;
- if ctrl.Buttons <> nil then
- begin
- for a := 0 to High(ctrl.Buttons) do
- if ctrl.Buttons[a] <> nil then
- r_GUI_Draw_TextButton(ctrl.Buttons[a]);
- if ctrl.Index <> -1 then
- begin
- ID := MarkerID[ctrl.Counter DIV MAINMENU_MARKERDELAY MOD 2 <> 0];
- e_Draw(ID, ctrl.Buttons[ctrl.Index].X - 48, ctrl.Buttons[ctrl.Index].Y, 0, True, False);
- end
- end;
- end;
-
- procedure r_GUI_Draw_Menu (ctrl: TGUIMenu);
- var a, locx, locy: Integer; f: TFont;
- begin
- if ctrl.Header <> nil then
- r_GUI_Draw_Label(ctrl.Header);
- if ctrl.Items <> nil then
- begin
- for a := 0 to High(ctrl.Items) do
- begin
- if ctrl.Items[a].Text <> nil then
- r_GUI_Draw_Control(ctrl.Items[a].Text);
- if ctrl.Items[a].Control <> nil then
- r_GUI_Draw_Control(ctrl.Items[a].Control);
- end;
- end;
- if (ctrl.Index <> -1) and (ctrl.Counter > MENU_MARKERDELAY div 2) then
- begin
- locx := 0;
- locy := 0;
- if ctrl.Items[ctrl.Index].Text <> nil then
- begin
- locx := ctrl.Items[ctrl.Index].Text.X;
- locy := ctrl.Items[ctrl.Index].Text.Y;
- //HACK!
- if ctrl.Items[ctrl.Index].Text.RightAlign then
- begin
- locx := locx + ctrl.Items[ctrl.Index].Text.CMaxWidth - ctrl.Items[ctrl.Index].Text.GetWidth;
- end;
- end
- else if ctrl.Items[ctrl.Index].Control <> nil then
- begin
- locx := ctrl.Items[ctrl.Index].Control.X;
- locy := ctrl.Items[ctrl.Index].Control.Y;
- end;
- f := Font[ctrl.BigFont];
- locx := locx - e_CharFont_GetMaxWidth(f.ID);
- e_CharFont_PrintEx(f.ID, locx, locy, #16, _RGB(255, 0, 0));
- end;
- end;
-
- procedure r_GUI_Draw_Control (ctrl: TGUIControl);
- begin
- if ctrl is TGUITextButton then
- r_GUI_Draw_TextButton(TGUITextButton(ctrl))
- else if ctrl is TGUILabel then
- r_GUI_Draw_Label(TGUILabel(ctrl))
- else if ctrl is TGUIScroll then
- r_GUI_Draw_Scroll(TGUIScroll(ctrl))
- else if ctrl is TGUISwitch then
- r_GUI_Draw_Switch(TGUISwitch(ctrl))
- else if ctrl is TGUIEdit then
- r_GUI_Draw_Edit(TGUIEdit(ctrl))
- else if ctrl is TGUIKeyRead then
- r_GUI_Draw_KeyRead(TGUIKeyRead(ctrl))
- else if ctrl is TGUIKeyRead2 then
- r_GUI_Draw_KeyRead2(TGUIKeyRead2(ctrl))
- else if ctrl is TGUIModelView then
- r_GUI_Draw_ModelView(TGUIModelView(ctrl))
- else if ctrl is TGUIMapPreview then
- r_GUI_Draw_MapPreview(TGUIMapPreview(ctrl))
- else if ctrl is TGUIImage then
- r_GUI_Draw_Image(TGUIImage(ctrl))
- else if ctrl is TGUIListBox then
- r_GUI_Draw_ListBox(TGUIListBox(ctrl)) // + TGUIFileListBox
- else if ctrl is TGUIMemo then
- r_GUI_Draw_Memo(TGUIMemo(ctrl))
- else if ctrl is TGUIMainMenu then
- r_GUI_Draw_MainMenu(TGUIMainMenu(ctrl))
- else if ctrl is TGUIMenu then
- r_GUI_Draw_Menu(TGUIMenu(ctrl))
- else
- Assert(False)
- end;
-
- procedure r_GUI_Draw_Window (win: TGUIWindow);
- var i: Integer; ID: DWORD; tw, th: Word;
- begin
- // Here goes code duplication from g_game.pas:DrawMenuBackground()
- if win.BackTexture <> '' then
- if g_Texture_Get(win.BackTexture, ID) then
- begin
- e_Clear(0, 0, 0);
- e_GetTextureSize(ID, @tw, @th);
- if tw = th then
- tw := round(tw * 1.333 * (gScreenHeight / th))
- else
- tw := trunc(tw * (gScreenHeight / th));
- e_DrawSize(ID, (gScreenWidth - tw) div 2, 0, 0, False, False, tw, gScreenHeight);
- end
- else
- e_Clear(0.5, 0.5, 0.5);
-
- // small hack here
- if win.Name = 'AuthorsMenu' then
- e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
- for i := 0 to High(win.Childs) do
- if win.Childs[i] <> nil then
- r_GUI_Draw_Control(win.Childs[i]);
- end;
-
-end.
diff --git a/src/game/opengl/r_items.pas b/src/game/opengl/r_items.pas
+++ /dev/null
@@ -1,203 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_items;
-
-interface
-
- uses MAPDEF; // ITEM_MAX
-
- procedure r_Items_Load;
- procedure r_Items_Free;
- procedure r_Items_Draw;
- procedure r_Items_DrawDrop;
- procedure r_Items_Update;
-
-implementation
-
- uses
- SysUtils, Classes, Math,
- r_graphics, r_animations, r_textures,
- g_base, g_basic, g_game, g_options, g_animations,
- g_items
- ;
-
- var
- items: Array [0..ITEM_MAX] of record
- id: DWORD;
- anim: TAnimState;
- end;
-
- procedure LoadItem (i: Integer; name: String; w, h, delay, n: Integer; backanim: Boolean);
- begin
- g_Frames_CreateWAD(@items[i].id, '', GameWAD + ':TEXTURES\' + name, w, h, n, backanim);
- if backanim then n := n * 2 - 2;
- items[i].anim := TAnimState.Create(True, delay, n);
- end;
-
- procedure r_Items_Load;
- var i: Integer;
- begin
- // i name w h d n backanim
- LoadItem(ITEM_NONE, 'NOTEXTURE', 16, 16, 0, 1, False);
- LoadItem(ITEM_MEDKIT_SMALL, 'MED1', 16, 16, 0, 1, False);
- LoadItem(ITEM_MEDKIT_LARGE, 'MED2', 32, 32, 0, 1, False);
- LoadItem(ITEM_MEDKIT_BLACK, 'BMED', 32, 32, 0, 1, False);
- LoadItem(ITEM_ARMOR_GREEN, 'ARMORGREEN', 32, 16, 20, 3, True);
- LoadItem(ITEM_ARMOR_BLUE, 'ARMORBLUE', 32, 16, 20, 3, True);
- LoadItem(ITEM_SPHERE_BLUE, 'SBLUE', 32, 32, 15, 4, True);
- LoadItem(ITEM_SPHERE_WHITE, 'SWHITE', 32, 32, 20, 4, True);
- LoadItem(ITEM_SUIT, 'SUIT', 32, 64, 0, 1, False);
- LoadItem(ITEM_OXYGEN, 'OXYGEN', 16, 32, 0, 1, False);
- LoadItem(ITEM_INVUL, 'INVUL', 32, 32, 20, 4, True);
- LoadItem(ITEM_WEAPON_SAW, 'SAW', 64, 32, 0, 1, False);
- LoadItem(ITEM_WEAPON_SHOTGUN1, 'SHOTGUN1', 64, 16, 0, 1, False);
- LoadItem(ITEM_WEAPON_SHOTGUN2, 'SHOTGUN2', 64, 16, 0, 1, False);
- LoadItem(ITEM_WEAPON_CHAINGUN, 'MGUN', 64, 16, 0, 1, False);
- LoadItem(ITEM_WEAPON_ROCKETLAUNCHER, 'RLAUNCHER', 64, 16, 0, 1, False);
- LoadItem(ITEM_WEAPON_PLASMA, 'PGUN', 64, 16, 0, 1, False);
- LoadItem(ITEM_WEAPON_BFG, 'BFG', 64, 64, 0, 1, False);
- LoadItem(ITEM_WEAPON_SUPERPULEMET, 'SPULEMET', 64, 16, 0, 1, False);
- LoadItem(ITEM_AMMO_BULLETS, 'CLIP', 16, 16, 0, 1, False);
- LoadItem(ITEM_AMMO_BULLETS_BOX, 'AMMO', 32, 16, 0, 1, False);
- LoadItem(ITEM_AMMO_SHELLS, 'SHELL1', 16, 8, 0, 1, False);
- LoadItem(ITEM_AMMO_SHELLS_BOX, 'SHELL2', 32, 16, 0, 1, False);
- LoadItem(ITEM_AMMO_ROCKET, 'ROCKET', 16, 32, 0, 1, False);
- LoadItem(ITEM_AMMO_ROCKET_BOX, 'ROCKETS', 64, 32, 0, 1, False);
- LoadItem(ITEM_AMMO_CELL, 'CELL', 16, 16, 0, 1, False);
- LoadItem(ITEM_AMMO_CELL_BIG, 'CELL2', 32, 32, 0, 1, False);
- LoadItem(ITEM_AMMO_BACKPACK, 'BPACK', 32, 32, 0, 1, False);
- LoadItem(ITEM_KEY_RED, 'KEYR', 16, 16, 0, 1, False);
- LoadItem(ITEM_KEY_GREEN, 'KEYG', 16, 16, 0, 1, False);
- LoadItem(ITEM_KEY_BLUE, 'KEYB', 16, 16, 0, 1, False);
- LoadItem(ITEM_WEAPON_KASTET, 'KASTET', 64, 32, 0, 1, False);
- LoadItem(ITEM_WEAPON_PISTOL, 'PISTOL', 64, 16, 0, 1, False);
- LoadItem(ITEM_BOTTLE, 'BOTTLE', 64, 32, 20, 4, True);
- LoadItem(ITEM_HELMET, 'HELMET', 64, 16, 20, 4, True);
- LoadItem(ITEM_JETPACK, 'JETPACK', 96, 32, 15, 3, True);
- LoadItem(ITEM_INVIS, 'INVIS', 128, 32, 20, 4, True);
- LoadItem(ITEM_WEAPON_FLAMETHROWER, 'FLAMETHROWER', 64, 32, 0, 1, False);
- LoadItem(ITEM_AMMO_FUELCAN, 'FUELCAN', 16, 32, 0, 1, False);
-
- // fill with NOTEXURE forgotten item
- for i := ITEM_AMMO_FUELCAN + 1 to ITEM_MAX do
- LoadItem(i,'NOTEXTURE', 16, 16, 0, 1, False);
-
- // hud
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_BLUESPHERE', GameWAD+':TEXTURES\SBLUE', 32, 32, 4, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_WHITESPHERE', GameWAD+':TEXTURES\SWHITE', 32, 32, 4, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_ARMORGREEN', GameWAD+':TEXTURES\ARMORGREEN', 32, 16, 3, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_ARMORBLUE', GameWAD+':TEXTURES\ARMORBLUE', 32, 16, 3, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_JETPACK', GameWAD+':TEXTURES\JETPACK', 32, 32, 3, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_INVUL', GameWAD+':TEXTURES\INVUL', 32, 32, 4, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_INVIS', GameWAD+':TEXTURES\INVIS', 32, 32, 4, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_RESPAWN', GameWAD+':TEXTURES\ITEMRESPAWN', 32, 32, 5, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_BOTTLE', GameWAD+':TEXTURES\BOTTLE', 16, 32, 4, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_HELMET', GameWAD+':TEXTURES\HELMET', 16, 16, 4, True);
- g_Frames_CreateWAD(nil, 'FRAMES_FLAG_RED', GameWAD+':TEXTURES\FLAGRED', 64, 64, 5, False);
- g_Frames_CreateWAD(nil, 'FRAMES_FLAG_BLUE', GameWAD+':TEXTURES\FLAGBLUE', 64, 64, 5, False);
- g_Frames_CreateWAD(nil, 'FRAMES_FLAG_DOM', GameWAD+':TEXTURES\FLAGDOM', 64, 64, 5, False);
- g_Texture_CreateWADEx('ITEM_MEDKIT_SMALL', GameWAD+':TEXTURES\MED1');
- g_Texture_CreateWADEx('ITEM_MEDKIT_LARGE', GameWAD+':TEXTURES\MED2');
- g_Texture_CreateWADEx('ITEM_WEAPON_SAW', GameWAD+':TEXTURES\SAW');
- g_Texture_CreateWADEx('ITEM_WEAPON_PISTOL', GameWAD+':TEXTURES\PISTOL');
- g_Texture_CreateWADEx('ITEM_WEAPON_KASTET', GameWAD+':TEXTURES\KASTET');
- g_Texture_CreateWADEx('ITEM_WEAPON_SHOTGUN1', GameWAD+':TEXTURES\SHOTGUN1');
- g_Texture_CreateWADEx('ITEM_WEAPON_SHOTGUN2', GameWAD+':TEXTURES\SHOTGUN2');
- g_Texture_CreateWADEx('ITEM_WEAPON_CHAINGUN', GameWAD+':TEXTURES\MGUN');
- g_Texture_CreateWADEx('ITEM_WEAPON_ROCKETLAUNCHER', GameWAD+':TEXTURES\RLAUNCHER');
- g_Texture_CreateWADEx('ITEM_WEAPON_PLASMA', GameWAD+':TEXTURES\PGUN');
- g_Texture_CreateWADEx('ITEM_WEAPON_BFG', GameWAD+':TEXTURES\BFG');
- g_Texture_CreateWADEx('ITEM_WEAPON_SUPERPULEMET', GameWAD+':TEXTURES\SPULEMET');
- g_Texture_CreateWADEx('ITEM_WEAPON_FLAMETHROWER', GameWAD+':TEXTURES\FLAMETHROWER');
- g_Texture_CreateWADEx('ITEM_AMMO_BULLETS', GameWAD+':TEXTURES\CLIP');
- g_Texture_CreateWADEx('ITEM_AMMO_BULLETS_BOX', GameWAD+':TEXTURES\AMMO');
- g_Texture_CreateWADEx('ITEM_AMMO_SHELLS', GameWAD+':TEXTURES\SHELL1');
- g_Texture_CreateWADEx('ITEM_AMMO_SHELLS_BOX', GameWAD+':TEXTURES\SHELL2');
- g_Texture_CreateWADEx('ITEM_AMMO_ROCKET', GameWAD+':TEXTURES\ROCKET');
- g_Texture_CreateWADEx('ITEM_AMMO_ROCKET_BOX', GameWAD+':TEXTURES\ROCKETS');
- g_Texture_CreateWADEx('ITEM_AMMO_CELL', GameWAD+':TEXTURES\CELL');
- g_Texture_CreateWADEx('ITEM_AMMO_CELL_BIG', GameWAD+':TEXTURES\CELL2');
- g_Texture_CreateWADEx('ITEM_AMMO_FUELCAN', GameWAD+':TEXTURES\FUELCAN');
- g_Texture_CreateWADEx('ITEM_AMMO_BACKPACK', GameWAD+':TEXTURES\BPACK');
- g_Texture_CreateWADEx('ITEM_KEY_RED', GameWAD+':TEXTURES\KEYR');
- g_Texture_CreateWADEx('ITEM_KEY_GREEN', GameWAD+':TEXTURES\KEYG');
- g_Texture_CreateWADEx('ITEM_KEY_BLUE', GameWAD+':TEXTURES\KEYB');
- g_Texture_CreateWADEx('ITEM_OXYGEN', GameWAD+':TEXTURES\OXYGEN');
- g_Texture_CreateWADEx('ITEM_SUIT', GameWAD+':TEXTURES\SUIT');
- g_Texture_CreateWADEx('ITEM_WEAPON_KASTET', GameWAD+':TEXTURES\KASTET');
- g_Texture_CreateWADEx('ITEM_MEDKIT_BLACK', GameWAD+':TEXTURES\BMED');
- end;
-
- procedure r_Items_Free;
- var i: Integer;
- begin
- for i := 0 to ITEM_MAX do
- g_Frames_DeleteByID(items[i].id);
- end;
-
-procedure itemsDrawInternal (dropflag: Boolean);
-var
- i, fX, fY: Integer;
- it: PItem;
-begin
- if (ggItems = nil) then exit;
-
- for i := 0 to High(ggItems) do
- begin
- it := @ggItems[i];
- if (not it.used) or (it.ItemType = ITEM_NONE) then continue; // just in case
- if not it.alive then continue;
- if (it.dropped <> dropflag) then continue;
-
- with it^ do
- begin
- if g_Collide(Obj.X, Obj.Y, Obj.Rect.Width, Obj.Rect.Height, sX, sY, sWidth, sHeight) then
- begin
- Obj.lerp(gLerpFactor, fX, fY);
-
- r_AnimState_Draw(items[it.ItemType].id, items[it.ItemType].anim, fX, fY, 0, TMirrorType.None, False);
-
- if g_debug_Frames then
- begin
- e_DrawQuad(Obj.X+Obj.Rect.X,
- Obj.Y+Obj.Rect.Y,
- Obj.X+Obj.Rect.X+Obj.Rect.Width-1,
- Obj.Y+Obj.Rect.Y+Obj.Rect.Height-1,
- 0, 255, 0);
- end;
- end;
- end;
- end;
-end;
-
-procedure r_Items_Draw;
-begin
- itemsDrawInternal(false);
-end;
-
-procedure r_Items_DrawDrop;
-begin
- itemsDrawInternal(true);
-end;
-
- procedure r_Items_Update;
- var i: Integer;
- begin
- for i := 0 to ITEM_MAX do
- items[i].anim.Update;
- end;
-
-end.
diff --git a/src/game/opengl/r_map.pas b/src/game/opengl/r_map.pas
+++ /dev/null
@@ -1,421 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_map;
-
-interface
-
- uses g_panel, MAPDEF, binheap; // TPanel, TDFColor
-
- procedure r_Map_Initialize;
- procedure r_Map_Finalize;
-
- procedure r_Map_Load;
- procedure r_Map_Free;
-
- procedure r_Map_LoadTextures;
- procedure r_Map_FreeTextures;
-
- procedure r_Map_Update;
-
- procedure r_Map_DrawPanels (PanelType: Word; hasAmbient: Boolean; constref ambColor: TDFColor); // unaccelerated
- procedure r_Map_CollectDrawPanels (x0, y0, wdt, hgt: Integer);
- procedure r_Map_DrawPanelShadowVolumes (lightX: Integer; lightY: Integer; radius: Integer);
- procedure r_Map_DrawFlags;
-
- procedure r_Panel_Draw (constref p: TPanel; hasAmbient: Boolean; constref ambColor: TDFColor);
- procedure r_Panel_DrawShadowVolume (constref p: TPanel; lightX, lightY: Integer; radius: Integer);
-
- type
- TBinHeapPanelDrawCmp = class
- public
- class function less (const a, b: TPanel): Boolean; inline;
- end;
-
- TBinHeapPanelDraw = specialize TBinaryHeapBase<TPanel, TBinHeapPanelDrawCmp>;
-
- var
- gDrawPanelList: TBinHeapPanelDraw = nil; // binary heap of all walls we have to render, populated by `g_Map_CollectDrawPanels()`
-
-implementation
-
- uses
- {$INCLUDE ../nogl/noGLuses.inc}
- SysUtils, Classes, Math, e_log, wadreader, CONFIG, utils, g_language,
- r_graphics, r_animations, r_textures, g_animations,
- g_base, g_basic, g_game, g_options,
- g_map
- ;
-
- var
- RenTextures: array of record
- ID: DWORD;
- Width, Height: WORD;
- Anim: Boolean;
- end;
- FlagFrames: array [FLAG_RED..FLAG_BLUE] of DWORD;
- FlagAnim: TAnimState;
-
- class function TBinHeapPanelDrawCmp.less (const a, b: TPanel): Boolean; inline;
- begin
- if (a.tag < b.tag) then begin result := true; exit; end;
- if (a.tag > b.tag) then begin result := false; exit; end;
- result := (a.arrIdx < b.arrIdx);
- end;
-
- procedure r_Map_Initialize;
- begin
- FlagAnim := TAnimState.Create(True, 8, 5);
- end;
-
- procedure r_Map_Finalize;
- begin
- FlagAnim.Invalidate;
- end;
-
- procedure r_Map_Load;
- begin
- g_Frames_CreateWAD(@FlagFrames[FLAG_RED], 'FRAMES_FLAG_RED', GameWAD + ':TEXTURES\FLAGRED', 64, 64, 5, False);
- g_Frames_CreateWAD(@FlagFrames[FLAG_BLUE], 'FRAMES_FLAG_BLUE', GameWAD + ':TEXTURES\FLAGBLUE', 64, 64, 5, False);
- end;
-
- procedure r_Map_Free;
- begin
- g_Frames_DeleteByName('FRAMES_FLAG_RED');
- g_Frames_DeleteByName('FRAMES_FLAG_BLUE');
- end;
-
- procedure r_Map_LoadTextures;
- const
- log = True;
- var
- i, n: Integer;
- WadName, ResName: String;
- WAD, WADZ: TWADFile;
- ResData, ReszData: Pointer;
- ResLen, ReszLen: Integer;
- cfg: TConfig;
- TextureResource: String;
- Width, Height: Integer;
- FramesCount: Integer;
- BackAnim: Boolean;
- begin
- if Textures <> nil then
- begin
- n := Length(Textures);
- SetLength(RenTextures, n);
- for i := 0 to n - 1 do
- begin
- // e_LogWritefln('r_Map_LoadTextures: -> [%s] :: [%s]', [Textures[i].FullName, Textures[i].TextureName]);
- RenTextures[i].ID := LongWord(TEXTURE_NONE);
- RenTextures[i].Width := 0;
- RenTextures[i].Height := 0;
- RenTextures[i].Anim := False;
- case Textures[i].TextureName of
- TEXTURE_NAME_WATER: RenTextures[i].ID := LongWord(TEXTURE_SPECIAL_WATER);
- TEXTURE_NAME_ACID1: RenTextures[i].ID := LongWord(TEXTURE_SPECIAL_ACID1);
- TEXTURE_NAME_ACID2: RenTextures[i].ID := LongWord(TEXTURE_SPECIAL_ACID2);
- else
- WadName := g_ExtractWadName(Textures[i].FullName);
- ResName := g_ExtractFilePathName(Textures[i].FullName);
- WAD := TWADFile.Create();
- if WAD.ReadFile(WadName) then
- begin
- if WAD.GetResource(ResName, ResData, ResLen, log) then
- begin
- if IsWadData(ResData, ResLen) then
- begin
- WADz := TWADFile.Create();
- if WADz.ReadMemory(ResData, ResLen) then
- begin
- if WADz.GetResource('TEXT/ANIM', ReszData, ReszLen) then
- begin
- cfg := TConfig.CreateMem(ReszData, ReszLen);
- FreeMem(ReszData);
- if cfg <> nil then
- begin
- TextureResource := cfg.ReadStr('', 'resource', '');
- Width := cfg.ReadInt('', 'framewidth', 0);
- Height := cfg.ReadInt('', 'frameheight', 0);
- FramesCount := cfg.ReadInt('', 'framecount', 0);
- // Speed := cfg.ReadInt('', 'waitcount', 0);
- BackAnim := cfg.ReadBool('', 'backanimation', False);
- RenTextures[i].Width := Width;
- RenTextures[i].Height := Height;
- if TextureResource <> '' then
- begin
- if WADz.GetResource('TEXTURES/' + TextureResource, ReszData, ReszLen) then
- begin
- if g_Frames_CreateMemory(@RenTextures[i].ID, '', ReszData, ReszLen, Width, Height, FramesCount, BackAnim) then
- RenTextures[i].Anim := True
- else
- e_LogWritefln('r_Map_LoadTextures: failed to create frames object (%s)', [Textures[i].FullName]);
- FreeMem(ReszData)
- end
- else
- e_LogWritefln('r_Map_LoadTextures: failed to open animation resources (%s)', [Textures[i].FullName])
- end
- else
- e_LogWritefln('r_Map_LoadTextures: failed to animation has no texture resource string (%s)', [Textures[i].FullName]);
- cfg.Free
- end
- else
- e_LogWritefln('r_Map_LoadTextures: failed to parse animation description (%s)', [Textures[i].FullName])
- end
- else
- e_LogWritefln('r_Map_LoadTextures: failed to open animation description (%s)', [Textures[i].FullName])
- end
- else
- e_LogWritefln('r_Map_LoadTextures: failed to open animation (%s)', [Textures[i].FullName]);
- WADz.Free
- end
- else
- begin
- if e_CreateTextureMem(ResData, ResLen, RenTextures[i].ID) then
- e_GetTextureSize(RenTextures[i].ID, @RenTextures[i].Width, @RenTextures[i].Height)
- else
- e_LogWritefln('r_Map_LoadTextures: failed to create texture (%s)', [Textures[i].FullName])
- end;
- FreeMem(ResData);
- end
- else
- e_LogWritefln('r_Map_LoadTextures: failed to open (%s)', [Textures[i].FullName])
- end
- else
- e_LogWritefln('r_Map_LoadTextures: failed to open %s', [WadName]);
- WAD.Free;
- end
- end
- end
- end;
-
- procedure r_Map_FreeTextures;
- begin
- // TODO
- end;
-
-procedure dplClear ();
-begin
- if (gDrawPanelList = nil) then gDrawPanelList := TBinHeapPanelDraw.Create() else gDrawPanelList.clear();
-end;
-
-// old algo
-procedure r_Map_DrawPanels (PanelType: Word; hasAmbient: Boolean; constref ambColor: TDFColor);
-
- procedure DrawPanels (constref panels: TPanelArray; drawDoors: Boolean=False);
- var
- idx: Integer;
- begin
- if (panels <> nil) then
- begin
- // alas, no visible set
- for idx := 0 to High(panels) do
- begin
- if not (drawDoors xor panels[idx].Door) then
- r_Panel_Draw(panels[idx], hasAmbient, ambColor);
- end;
- end;
- end;
-
-begin
- case PanelType of
- PANEL_WALL: DrawPanels(gWalls);
- PANEL_CLOSEDOOR: DrawPanels(gWalls, True);
- PANEL_BACK: DrawPanels(gRenderBackgrounds);
- PANEL_FORE: DrawPanels(gRenderForegrounds);
- PANEL_WATER: DrawPanels(gWater);
- PANEL_ACID1: DrawPanels(gAcid1);
- PANEL_ACID2: DrawPanels(gAcid2);
- PANEL_STEP: DrawPanels(gSteps);
- end;
-end;
-
-// new algo
-procedure r_Map_CollectDrawPanels (x0, y0, wdt, hgt: Integer);
-var
- mwit: PPanel;
- it: TPanelGrid.Iter;
-begin
- dplClear();
- it := mapGrid.forEachInAABB(x0, y0, wdt, hgt, GridDrawableMask);
- for mwit in it do if (((mwit^.tag and GridTagDoor) <> 0) = mwit^.Door) then gDrawPanelList.insert(mwit^);
- it.release();
- // list will be rendered in `g_game.DrawPlayer()`
-end;
-
-procedure r_Map_DrawPanelShadowVolumes (lightX: Integer; lightY: Integer; radius: Integer);
-var
- mwit: PPanel;
- it: TPanelGrid.Iter;
-begin
- it := mapGrid.forEachInAABB(lightX-radius, lightY-radius, radius*2, radius*2, (GridTagWall or GridTagDoor));
- for mwit in it do r_Panel_DrawShadowVolume(mwit^, lightX, lightY, radius);
- it.release();
-end;
-
- procedure r_Map_DrawFlags;
- var i, dx, tx, ty: Integer; Mirror: TMirrorType; f: PFlag;
- begin
- if gGameSettings.GameMode = GM_CTF then
- begin
- for i := FLAG_RED to FLAG_BLUE do
- begin
- f := @gFlags[i];
- if not (f.State in [FLAG_STATE_NONE, FLAG_STATE_CAPTURED]) then
- begin
- f.Obj.lerp(gLerpFactor, tx, ty);
- if f.Direction = TDirection.D_LEFT then
- Mirror := TMirrorType.Horizontal
- else
- Mirror := TMirrorType.None;
- dx := IfThen(f.Direction = TDirection.D_LEFT, -1, +1);
- r_AnimState_Draw(FlagFrames[i], FlagAnim, tx + dx, ty + 1, 0, Mirror, False);
- if g_debug_Frames then
- e_DrawQuad(tx + f.Obj.Rect.X, ty + f.Obj.Rect.Y, tx + f.Obj.Rect.X + f.Obj.Rect.Width - 1, ty + f.Obj.Rect.Y + f.Obj.Rect.Height - 1, 0, 255, 0)
- end
- end
- end
- end;
-
- procedure Panel_Lerp (p: TPanel; t: Single; out tX, tY, tW, tH: Integer);
- begin
- if p.movingActive then
- begin
- tX := nlerp(p.OldX, p.X, t);
- tY := nlerp(p.OldY, p.Y, t);
- tW := nlerp(p.OldWidth, p.Width, t);
- tH := nlerp(p.OldHeight, p.Height, t);
- end
- else
- begin
- tX := p.X;
- tY := p.Y;
- tW := p.Width;
- tH := p.Height;
- end;
- end;
-
- procedure r_Panel_Draw (constref p: TPanel; hasAmbient: Boolean; constref ambColor: TDFColor);
- var tx, ty, tw, th, xx, yy: Integer; NoTextureID, TextureID, FramesID: DWORD; NW, NH: Word; Texture: Cardinal; IsAnim: Boolean; w, h: Integer;
- begin
- if {p.Enabled and} (p.FCurTexture >= 0) and (p.Width > 0) and (p.Height > 0) and (p.Alpha < 255) {and g_Collide(X, Y, Width, Height, sX, sY, sWidth, sHeight)} then
- begin
- Panel_Lerp(p, gLerpFactor, tx, ty, tw, th);
- Texture := p.TextureIDs[p.FCurTexture].Texture;
- IsAnim := RenTextures[Texture].Anim;
- if IsAnim then
- begin
- if p.TextureIDs[p.FCurTexture].AnTex.IsValid() then
- begin
- FramesID := RenTextures[Texture].ID;
- w := RenTextures[Texture].Width;
- h := RenTextures[Texture].Height;
- for xx := 0 to tw div w - 1 do
- for yy := 0 to th div h - 1 do
- r_AnimState_Draw(FramesID, p.TextureIDs[p.FCurTexture].AnTex, tx + xx * w, ty + yy * h, p.Alpha, TMirrorType.None, p.Blending);
- end
- end
- else
- begin
- TextureID := RenTextures[Texture].ID;
- w := RenTextures[Texture].Width;
- h := RenTextures[Texture].Height;
- case TextureID of
- LongWord(TEXTURE_SPECIAL_WATER): e_DrawFillQuad(tx, ty, tx + tw - 1, ty + th - 1, 0, 0, 255, 0, TBlending.Filter);
- LongWord(TEXTURE_SPECIAL_ACID1): e_DrawFillQuad(tx, ty, tx + tw - 1, ty + th - 1, 0, 230, 0, 0, TBlending.Filter);
- LongWord(TEXTURE_SPECIAL_ACID2): e_DrawFillQuad(tx, ty, tx + tw - 1, ty + th - 1, 230, 0, 0, 0, TBlending.Filter);
- LongWord(TEXTURE_NONE):
- if g_Texture_Get('NOTEXTURE', NoTextureID) then
- begin
- e_GetTextureSize(NoTextureID, @NW, @NH);
- e_DrawFill(NoTextureID, tx, ty, tw div NW, th div NH, 0, False, False);
- end
- else
- begin
- xx := tx + (tw div 2);
- yy := ty + (th div 2);
- e_DrawFillQuad(tx, ty, xx, yy, 255, 0, 255, 0);
- e_DrawFillQuad(xx, ty, tx + tw - 1, yy, 255, 255, 0, 0);
- e_DrawFillQuad(tx, yy, xx, ty + th - 1, 255, 255, 0, 0);
- e_DrawFillQuad(xx, yy, tx + tw - 1, ty + th - 1, 255, 0, 255, 0);
- end;
- else
- if not p.movingActive then
- e_DrawFill(TextureID, tx, ty, tw div w, th div h, p.Alpha, True, p.Blending, hasAmbient)
- else
- e_DrawFillX(TextureID, tx, ty, tw, th, p.Alpha, True, p.Blending, g_dbg_scale, hasAmbient);
- if hasAmbient then
- e_AmbientQuad(tx, ty, tw, th, ambColor.r, ambColor.g, ambColor.b, ambColor.a);
- end
- end
- end
- end;
-
- procedure r_Panel_DrawShadowVolume (constref p: TPanel; lightX, lightY: Integer; radius: Integer);
- var tx, ty, tw, th: Integer; Texture: Cardinal;
-
- procedure extrude (x: Integer; y: Integer);
- begin
- glVertex2i(x + (x - lightX) * 500, y + (y - lightY) * 500);
- //e_WriteLog(Format(' : (%d,%d)', [x + (x - lightX) * 300, y + (y - lightY) * 300]), MSG_WARNING);
- end;
-
- procedure drawLine (x0: Integer; y0: Integer; x1: Integer; y1: Integer);
- begin
- // does this side facing the light?
- if ((x1 - x0) * (lightY - y0) - (lightX - x0) * (y1 - y0) >= 0) then exit;
- //e_WriteLog(Format('lightpan: (%d,%d)-(%d,%d)', [x0, y0, x1, y1]), MSG_WARNING);
- // this edge is facing the light, extrude and draw it
- glVertex2i(x0, y0);
- glVertex2i(x1, y1);
- extrude(x1, y1);
- extrude(x0, y0);
- end;
-
- begin
- if radius < 4 then exit;
- if p.Enabled and (p.FCurTexture >= 0) and (p.Width > 0) and (p.Height > 0) and (p.Alpha < 255) {and g_Collide(X, Y, tw, th, sX, sY, sWidth, sHeight)} then
- begin
- Panel_Lerp(p, gLerpFactor, tx, ty, tw, th);
- Texture := p.TextureIDs[p.FCurTexture].Texture;
- if not RenTextures[Texture].Anim then
- begin
- case RenTextures[Texture].ID of
- LongWord(TEXTURE_SPECIAL_WATER): exit;
- LongWord(TEXTURE_SPECIAL_ACID1): exit;
- LongWord(TEXTURE_SPECIAL_ACID2): exit;
- LongWord(TEXTURE_NONE): exit;
- end;
- end;
- if (tx + tw < lightX - radius) then exit;
- if (ty + th < lightY - radius) then exit;
- if (tx > lightX + radius) then exit;
- if (ty > lightY + radius) then exit;
- //e_DrawFill(TextureIDs[FCurTexture].Tex, X, Y, tw div TextureWidth, th div TextureHeight, Alpha, True, Blending);
- glBegin(GL_QUADS);
- drawLine(tx, ty, tx + tw, ty); // top
- drawLine(tx + tw, ty, tx + tw, ty + th); // right
- drawLine(tx + tw, ty + th, tx, ty + th); // bottom
- drawLine(tx, ty + th, tx, ty); // left
- glEnd;
- end
- end;
-
- procedure r_Map_Update;
- begin
- FlagAnim.Update
- end;
-
-end.
diff --git a/src/game/opengl/r_monsters.pas b/src/game/opengl/r_monsters.pas
+++ /dev/null
@@ -1,471 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_monsters;
-
-interface
-
- procedure r_Monsters_Load;
- procedure r_Monsters_Free;
- procedure r_Monsters_Draw;
- procedure r_Monsters_DrawHealth;
-
-implementation
-
- uses
- SysUtils, Classes, Math, e_log,
- r_graphics, g_options, r_animations, r_game,
- MAPDEF,
- g_base, g_basic, g_game, g_phys,
- g_monsters
- ;
-
- type
- TMonsterAnims = array [ANIM_SLEEP..ANIM_PAIN, TDirection.D_LEFT..TDirection.D_RIGHT] of DWORD;
-
- var
- VileFire: DWORD;
- monFrames: array [MONSTER_DEMON..MONSTER_MAN] of TMonsterAnims;
-
- procedure r_Monsters_Free;
- begin
- g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_MESS');
- g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_ATTACK_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_SERG_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_SERG_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_SERG_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_SERG_MESS');
- g_Frames_DeleteByName('FRAMES_MONSTER_SERG_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_SERG_ATTACK_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_SERG_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_MAN_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_MAN_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_MAN_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_MAN_MESS');
- g_Frames_DeleteByName('FRAMES_MONSTER_MAN_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_MAN_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_SLEEP_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_GO_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_MESS');
- g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_ATTACK_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_PAIN_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_IMP_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_IMP_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_IMP_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_IMP_MESS');
- g_Frames_DeleteByName('FRAMES_MONSTER_IMP_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_IMP_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_FISH_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_FISH_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_FISH_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_FISH_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_FISH_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_PAIN_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_BSP_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_BSP_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_BSP_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_BSP_PAIN_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_BSP_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_BSP_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_CACO_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_CACO_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_CACO_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_CACO_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_CACO_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_BARON_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_BARON_SLEEP_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_BARON_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_BARON_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_BARON_PAIN_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_BARON_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_BARON_ATTACK_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_BARON_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_SLEEP_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_PAIN_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_ATTACK_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_SLEEP_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_PAIN_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK2');
- g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK2_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_VILE_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_VILE_SLEEP_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_VILE_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_VILE_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_VILE_PAIN_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK2');
- g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK2_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_VILE_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_ATTACK2');
- g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_DIE');
- g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_SLEEP');
- g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_SLEEP_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_GO');
- g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_GO_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_PAIN');
- g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_PAIN_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK');
- g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK2');
- g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK2_L');
- g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_DIE');
- end;
-
- procedure r_Monsters_Load;
- var m, a: Integer; s: String; FramesID: DWORD;
- begin
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_SLEEP', GameWAD+':MTEXTURES\BARREL_SLEEP', 64, 64, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_DIE', GameWAD+':MTEXTURES\BARREL_DIE', 64, 64, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_PAIN', GameWAD+':MTEXTURES\BARREL_PAIN', 64, 64, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_SLEEP', GameWAD+':MTEXTURES\ZOMBY_SLEEP', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_GO', GameWAD+':MTEXTURES\ZOMBY_GO', 64, 64, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_DIE', GameWAD+':MTEXTURES\ZOMBY_DIE', 64, 64, 6);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_MESS', GameWAD+':MTEXTURES\ZOMBY_MESS', 64, 64, 9);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_ATTACK', GameWAD+':MTEXTURES\ZOMBY_ATTACK', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_ATTACK_L', GameWAD+':MTEXTURES\ZOMBY_ATTACK_L', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_PAIN', GameWAD+':MTEXTURES\ZOMBY_PAIN', 64, 64, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_SLEEP', GameWAD+':MTEXTURES\SERG_SLEEP', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_GO', GameWAD+':MTEXTURES\SERG_GO', 64, 64, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_DIE', GameWAD+':MTEXTURES\SERG_DIE', 64, 64, 5);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_MESS', GameWAD+':MTEXTURES\SERG_MESS', 64, 64, 9);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_ATTACK', GameWAD+':MTEXTURES\SERG_ATTACK', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_ATTACK_L', GameWAD+':MTEXTURES\SERG_ATTACK_L', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_PAIN', GameWAD+':MTEXTURES\SERG_PAIN', 64, 64, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_SLEEP', GameWAD+':MTEXTURES\MAN_SLEEP', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_GO', GameWAD+':MTEXTURES\MAN_GO', 64, 64, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_DIE', GameWAD+':MTEXTURES\MAN_DIE', 64, 64, 7);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_MESS', GameWAD+':MTEXTURES\MAN_MESS', 64, 64, 9);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_ATTACK', GameWAD+':MTEXTURES\MAN_ATTACK', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_PAIN', GameWAD+':MTEXTURES\MAN_PAIN', 64, 64, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_SLEEP', GameWAD+':MTEXTURES\CGUN_SLEEP', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_SLEEP_L', GameWAD+':MTEXTURES\CGUN_SLEEP_L', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_GO', GameWAD+':MTEXTURES\CGUN_GO', 64, 64, 4);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_GO_L', GameWAD+':MTEXTURES\CGUN_GO_L', 64, 64, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_DIE', GameWAD+':MTEXTURES\CGUN_DIE', 64, 64, 7);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_MESS', GameWAD+':MTEXTURES\CGUN_MESS', 64, 64, 6);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_ATTACK', GameWAD+':MTEXTURES\CGUN_ATTACK', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_ATTACK_L', GameWAD+':MTEXTURES\CGUN_ATTACK_L', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_PAIN', GameWAD+':MTEXTURES\CGUN_PAIN', 64, 64, 1);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_PAIN_L', GameWAD+':MTEXTURES\CGUN_PAIN_L', 64, 64, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_SLEEP', GameWAD+':MTEXTURES\IMP_SLEEP', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_GO', GameWAD+':MTEXTURES\IMP_GO', 64, 64, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_DIE', GameWAD+':MTEXTURES\IMP_DIE', 64, 64, 5);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_MESS', GameWAD+':MTEXTURES\IMP_MESS', 64, 64, 8);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_ATTACK', GameWAD+':MTEXTURES\IMP_ATTACK', 64, 64, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_PAIN', GameWAD+':MTEXTURES\IMP_PAIN', 64, 64, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_SLEEP', GameWAD+':MTEXTURES\DEMON_SLEEP', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_GO', GameWAD+':MTEXTURES\DEMON_GO', 64, 64, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_DIE', GameWAD+':MTEXTURES\DEMON_DIE', 64, 64, 6);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_ATTACK', GameWAD+':MTEXTURES\DEMON_ATTACK', 64, 64, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_PAIN', GameWAD+':MTEXTURES\DEMON_PAIN', 64, 64, 1);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_SLEEP', GameWAD+':MTEXTURES\SOUL_SLEEP', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_GO', GameWAD+':MTEXTURES\SOUL_GO', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_PAIN', GameWAD+':MTEXTURES\SOUL_PAIN', 64, 64, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_ATTACK', GameWAD+':MTEXTURES\SOUL_ATTACK', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_DIE', GameWAD+':MTEXTURES\SOUL_DIE', 128, 128, 7);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_SLEEP', GameWAD+':MTEXTURES\FISH_SLEEP', 32, 32, 2);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_GO', GameWAD+':MTEXTURES\FISH_GO', 32, 32, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_PAIN', GameWAD+':MTEXTURES\FISH_PAIN', 32, 32, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_ATTACK', GameWAD+':MTEXTURES\FISH_ATTACK', 32, 32, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_DIE', GameWAD+':MTEXTURES\FISH_DIE', 32, 32, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_SLEEP', GameWAD+':MTEXTURES\SPIDER_SLEEP', 256, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_GO', GameWAD+':MTEXTURES\SPIDER_GO', 256, 128, 6);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_PAIN', GameWAD+':MTEXTURES\SPIDER_PAIN', 256, 128, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_PAIN_L', GameWAD+':MTEXTURES\SPIDER_PAIN_L', 256, 128, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_ATTACK', GameWAD+':MTEXTURES\SPIDER_ATTACK', 256, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_DIE', GameWAD+':MTEXTURES\SPIDER_DIE', 256, 128, 10);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_SLEEP', GameWAD+':MTEXTURES\BSP_SLEEP', 128, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_GO', GameWAD+':MTEXTURES\BSP_GO', 128, 64, 6);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_PAIN', GameWAD+':MTEXTURES\BSP_PAIN', 128, 64, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_PAIN_L', GameWAD+':MTEXTURES\BSP_PAIN_L', 128, 64, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_ATTACK', GameWAD+':MTEXTURES\BSP_ATTACK', 128, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_DIE', GameWAD+':MTEXTURES\BSP_DIE', 128, 64, 7);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_SLEEP', GameWAD+':MTEXTURES\CACO_SLEEP', 128, 128, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_GO', GameWAD+':MTEXTURES\CACO_GO', 128, 128, 1);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_PAIN', GameWAD+':MTEXTURES\CACO_PAIN', 128, 128, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_ATTACK', GameWAD+':MTEXTURES\CACO_ATTACK', 128, 128, 6);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_DIE', GameWAD+':MTEXTURES\CACO_DIE', 128, 128, 7);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_SLEEP', GameWAD+':MTEXTURES\PAIN_SLEEP', 128, 128, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_GO', GameWAD+':MTEXTURES\PAIN_GO', 128, 128, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_PAIN', GameWAD+':MTEXTURES\PAIN_PAIN', 128, 128, 1);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_ATTACK', GameWAD+':MTEXTURES\PAIN_ATTACK', 128, 128, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_DIE', GameWAD+':MTEXTURES\PAIN_DIE', 128, 128, 7);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_SLEEP', GameWAD+':MTEXTURES\BARON_SLEEP', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_SLEEP_L', GameWAD+':MTEXTURES\BARON_SLEEP_L', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_GO', GameWAD+':MTEXTURES\BARON_GO', 128, 128, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_PAIN', GameWAD+':MTEXTURES\BARON_PAIN', 128, 128, 1);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_PAIN_L', GameWAD+':MTEXTURES\BARON_PAIN_L', 128, 128, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_ATTACK', GameWAD+':MTEXTURES\BARON_ATTACK', 128, 128, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_ATTACK_L', GameWAD+':MTEXTURES\BARON_ATTACK_L', 128, 128, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_DIE', GameWAD+':MTEXTURES\BARON_DIE', 128, 128, 7);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_SLEEP', GameWAD+':MTEXTURES\KNIGHT_SLEEP', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_SLEEP_L', GameWAD+':MTEXTURES\KNIGHT_SLEEP_L', 128, 128, 2);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_GO', GameWAD+':MTEXTURES\KNIGHT_GO', 128, 128, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_PAIN', GameWAD+':MTEXTURES\KNIGHT_PAIN', 128, 128, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_PAIN_L', GameWAD+':MTEXTURES\KNIGHT_PAIN_L', 128, 128, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_ATTACK', GameWAD+':MTEXTURES\KNIGHT_ATTACK', 128, 128, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_ATTACK_L', GameWAD+':MTEXTURES\KNIGHT_ATTACK_L', 128, 128, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_DIE', GameWAD+':MTEXTURES\KNIGHT_DIE', 128, 128, 7);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_SLEEP', GameWAD+':MTEXTURES\MANCUB_SLEEP', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_GO', GameWAD+':MTEXTURES\MANCUB_GO', 128, 128, 6);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_PAIN', GameWAD+':MTEXTURES\MANCUB_PAIN', 128, 128, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_ATTACK', GameWAD+':MTEXTURES\MANCUB_ATTACK', 128, 128, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_DIE', GameWAD+':MTEXTURES\MANCUB_DIE', 128, 128, 10);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_SLEEP', GameWAD+':MTEXTURES\SKEL_SLEEP', 128, 128, 2);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_SLEEP_L', GameWAD+':MTEXTURES\SKEL_SLEEP_L', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_GO', GameWAD+':MTEXTURES\SKEL_GO', 128, 128, 6);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_PAIN', GameWAD+':MTEXTURES\SKEL_PAIN', 128, 128, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_PAIN_L', GameWAD+':MTEXTURES\SKEL_PAIN_L', 128, 128, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK', GameWAD+':MTEXTURES\SKEL_ATTACK', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK_L', GameWAD+':MTEXTURES\SKEL_ATTACK_L', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK2', GameWAD+':MTEXTURES\SKEL_ATTACK2', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK2_L', GameWAD+':MTEXTURES\SKEL_ATTACK2_L', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_DIE', GameWAD+':MTEXTURES\SKEL_DIE', 128, 128, 5);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_SLEEP', GameWAD+':MTEXTURES\VILE_SLEEP', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_SLEEP_L', GameWAD+':MTEXTURES\VILE_SLEEP_L', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_GO', GameWAD+':MTEXTURES\VILE_GO', 128, 128, 6);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_PAIN', GameWAD+':MTEXTURES\VILE_PAIN', 128, 128, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_PAIN_L', GameWAD+':MTEXTURES\VILE_PAIN_L', 128, 128, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK', GameWAD+':MTEXTURES\VILE_ATTACK', 128, 128, 10);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK_L', GameWAD+':MTEXTURES\VILE_ATTACK_L', 128, 128, 10);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK2', GameWAD+':MTEXTURES\VILE_ATTACK2', 128, 128, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK2_L', GameWAD+':MTEXTURES\VILE_ATTACK2_L', 128, 128, 3);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_DIE', GameWAD+':MTEXTURES\VILE_DIE', 128, 128, 9);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_SLEEP', GameWAD+':MTEXTURES\ROBO_SLEEP', 128, 128, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_GO', GameWAD+':MTEXTURES\ROBO_GO', 128, 128, 12);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_ATTACK', GameWAD+':MTEXTURES\ROBO_ATTACK', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_ATTACK2', GameWAD+':MTEXTURES\ROBO_ATTACK2', 128, 128, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_DIE', GameWAD+':MTEXTURES\ROBO_DIE', 128, 128, 1);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_SLEEP', GameWAD+':MTEXTURES\CYBER_SLEEP', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_SLEEP_L', GameWAD+':MTEXTURES\CYBER_SLEEP_L', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_GO', GameWAD+':MTEXTURES\CYBER_GO', 128, 128, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_GO_L', GameWAD+':MTEXTURES\CYBER_GO_L', 128, 128, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_PAIN', GameWAD+':MTEXTURES\CYBER_PAIN', 128, 128, 1);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_PAIN_L', GameWAD+':MTEXTURES\CYBER_PAIN_L', 128, 128, 1);
-
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK', GameWAD+':MTEXTURES\CYBER_ATTACK', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK_L', GameWAD+':MTEXTURES\CYBER_ATTACK_L', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK2', GameWAD+':MTEXTURES\CYBER_ATTACK2', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK2_L', GameWAD+':MTEXTURES\CYBER_ATTACK2_L', 128, 128, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_DIE', GameWAD+':MTEXTURES\CYBER_DIE', 128, 128, 9);
-
- g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD+':TEXTURES\FIRE', 64, 128, 8);
-
- g_Frames_Get(vilefire, 'FRAMES_FIRE');
- for m := MONSTER_DEMON to MONSTER_MAN do
- begin
- for a := ANIM_SLEEP to ANIM_PAIN do
- begin
- monFrames[m, a, TDirection.D_LEFT] := DWORD(-1);
- monFrames[m, a, TDirection.D_RIGHT] := DWORD(-1);
- if (ANIMTABLE[a].name <> '') and (MONSTER_ANIMTABLE[m].AnimSpeed[a] <> 0) then
- begin
- s := 'FRAMES_MONSTER_' + MONSTERTABLE[m].Name + '_' + ANIMTABLE[a].name;
- if not (g_Frames_Exists(s) and g_Frames_Get(FramesID, s)) then
- begin
- // Заменяем только ANIM_MESS на ANIM_DIE:
- if a <> ANIM_MESS then
- Continue;
- if g_Frames_Get(FramesID, 'FRAMES_MONSTER_' + MONSTERTABLE[m].Name + '_' + ANIMTABLE[ANIM_DIE].name) then
- begin
- monFrames[m, a, TDirection.D_RIGHT] := FramesID;
- monFrames[m, a, TDirection.D_LEFT] := FramesID;
- Continue;
- end;
- end;
- monFrames[m, a, TDirection.D_RIGHT] := FramesID;
- // Если есть отдельная левая анимация - загружаем:
- if MONSTER_ANIMTABLE[m].LeftAnim then
- begin
- s := 'FRAMES_MONSTER_' + MONSTERTABLE[m].Name + '_' + ANIMTABLE[a].name + '_L';
- if g_Frames_Exists(s) then
- g_Frames_Get(FramesID, s);
- end;
- monFrames[m, a, TDirection.D_LEFT] := FramesID;
- end
- end
- end
- end;
-
- procedure r_Monsters_Draw (constref monster: TMonster);
- var m: TMirrorType; dx, dy, c, fX, fY, mw, mh: Integer; o: TObj;
- begin
- with monster do
- begin
- //e_CharFont_Print(gMenuSmallFont, Obj.X + Obj.Rect.X, Obj.Y + Obj.Rect.Y, 'TYPE: ' + IntToStr(MonsterType));
- //e_CharFont_Print(gMenuSmallFont, Obj.X + Obj.Rect.X, Obj.Y + Obj.Rect.Y + 16, 'STATE: ' + IntToStr(MonsterState));
-
- Obj.lerp(gLerpFactor, fX, fY);
-
- // Если колдун стреляет, то рисуем огонь:
- if MonsterType = MONSTER_VILE then
- if MonsterState = MONSTATE_SHOOT then
- if GetPos(MonsterTargetUID, @o) then
- r_AnimState_Draw(VileFire, VileFireAnim, o.X + o.Rect.X + (o.Rect.Width div 2) - 32, o.Y + o.Rect.Y + o.Rect.Height - 128, 0, TMirrorType.None, False);
-
- // Не в области рисования не ресуем:
- //FIXME!
- if (g_dbg_scale = 1.0) then
- begin
- if not g_Collide(Obj.X + Obj.Rect.X, Obj.Y + Obj.Rect.Y, Obj.Rect.Width, Obj.Rect.Height, sX - 128, sY - 128, sWidth + 256, sHeight + 256) then
- Exit;
- end;
-
- // Эти монстры, умирая, не оставляют трупов:
- if MonsterState = MONSTATE_DEAD then
- case MonsterType of
- MONSTER_BARREL, MONSTER_SOUL, MONSTER_PAIN: Exit;
- end;
-
- // Есть что рисовать при текущем поведении:
- if monFrames[MonsterType, MonsterAnim, GameDirection] <> DWORD(-1) then
- begin
- // Если нет левой анимации или она совпадает с правой => отражаем правую:
- if (GameDirection = TDirection.D_LEFT) and ((not MONSTER_ANIMTABLE[MonsterType].LeftAnim) or (monFrames[MonsterType, MonsterAnim, TDirection.D_LEFT] = monFrames[MonsterType, MonsterAnim, TDirection.D_RIGHT])) and (MonsterType <> MONSTER_BARREL) then
- m := TMirrorType.Horizontal
- else
- m := TMirrorType.None;
-
- // Левая анимация => меняем смещение относительно центра:
- if (GameDirection = TDirection.D_LEFT) and (MonsterType <> MONSTER_BARREL) then
- begin
- dx := MONSTER_ANIMTABLE[MonsterType].AnimDeltaLeft[MonsterAnim].X;
- dy := MONSTER_ANIMTABLE[MonsterType].AnimDeltaLeft[MonsterAnim].Y;
-
- if m = TMirrorType.Horizontal then
- begin
- // Нет отдельной левой анимации
- // Расстояние от края текстуры до края визуального положения объекта на текстуре:
- c := (MONSTERTABLE[MonsterType].Rect.X - dx) + MONSTERTABLE[MonsterType].Rect.Width;
- // Расстояние от края хит бокса до края визуального положения объекта на текстуре:
- g_Frames_GetFrameSize(monFrames[MonsterType, MonsterAnim, GameDirection], mw, mh);
- dx := mw - c - MONSTERTABLE[MonsterType].Rect.X; // !!! ^^^
- // Т.к. двигать текстуру нужно будет в противоположном направлении:
- dx := -dx;
- // Это значит: dX := -frameWidth - animDeltaX + hitX + hitWidth + hitX
- end
- end
- else // Правая анимация
- begin
- dx := MONSTER_ANIMTABLE[MonsterType].AnimDeltaRight[MonsterAnim].X;
- dy := MONSTER_ANIMTABLE[MonsterType].AnimDeltaRight[MonsterAnim].Y;
- end;
-
- r_AnimState_Draw(monFrames[MonsterType, MonsterAnim, GameDirection], DirAnim[MonsterAnim, GameDirection], fX + dx, fY + dy, 0, m, False);
- end;
-
- if g_debug_Frames then
- begin
- e_DrawQuad(Obj.X + Obj.Rect.X, Obj.Y + Obj.Rect.Y, Obj.X + Obj.Rect.X + Obj.Rect.Width - 1, Obj.Y + Obj.Rect.Y + Obj.Rect.Height - 1, 0, 255, 0);
- end
- end
- end;
-
- procedure r_Monsters_Draw;
- var a: Integer;
- begin
- if gMonsters <> nil then
- for a := 0 to High(gMonsters) do
- if (gMonsters[a] <> nil) then r_Monsters_Draw(gMonsters[a]);
- end;
-
- procedure r_Monsters_DrawHealth;
- var a: Integer; fW, fH: Byte;
- begin
- if gMonsters = nil then Exit;
- e_TextureFontGetSize(gStdFont, fW, fH);
- for a := 0 to High(gMonsters) do
- begin
- if gMonsters[a] <> nil then
- begin
- e_TextureFontPrint(gMonsters[a].Obj.X + gMonsters[a].Obj.Rect.X,
- gMonsters[a].Obj.Y + gMonsters[a].Obj.Rect.Y + gMonsters[a].Obj.Rect.Height - fH,
- IntToStr(gMonsters[a].MonsterHealth), gStdFont);
- end
- end
- end;
-
-end.
diff --git a/src/game/opengl/r_netmaster.pas b/src/game/opengl/r_netmaster.pas
+++ /dev/null
@@ -1,181 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_netmaster;
-
-interface
-
- uses g_netmaster;
-
- procedure r_Serverlist_Draw (var SL: TNetServerList; var ST: TNetServerTable);
-
-implementation
-
- uses
- {$IFDEF ENABLE_MENU}
- g_menu,
- {$ENDIF}
- SysUtils, Classes, Math,
- r_graphics, r_game,
- g_basic, g_language, g_game
- ;
-
-procedure r_Serverlist_Draw (var SL: TNetServerList; var ST: TNetServerTable);
-var
- Srv: TNetServer;
- sy, i, y, mw, mx, l, motdh: Integer;
- cw: Byte = 0;
- ch: Byte = 0;
- ww: Word = 0;
- hh: Word = 0;
- ip: AnsiString;
-begin
- ip := '';
- sy := 0;
-
- e_CharFont_GetSize(gMenuFont, _lc[I_NET_SLIST], ww, hh);
- e_CharFont_Print(gMenuFont, (gScreenWidth div 2) - (ww div 2), 16, _lc[I_NET_SLIST]);
-
- e_TextureFontGetSize(gStdFont, cw, ch);
-
- ip := _lc[I_NET_SLIST_HELP];
- mw := (Length(ip) * cw) div 2;
-
- motdh := gScreenHeight - 49 - ch * b_Text_LineCount(slMOTD);
-
- e_DrawFillQuad(16, 64, gScreenWidth-16, motdh, 64, 64, 64, 110);
- e_DrawQuad(16, 64, gScreenWidth-16, motdh, 255, 127, 0);
-
- e_TextureFontPrintEx(gScreenWidth div 2 - mw, gScreenHeight-24, ip, gStdFont, 225, 225, 225, 1);
-
- // MOTD
- if slMOTD <> '' then
- begin
- e_DrawFillQuad(16, motdh, gScreenWidth-16, gScreenHeight-44, 64, 64, 64, 110);
- e_DrawQuad(16, motdh, gScreenWidth-16, gScreenHeight-44, 255, 127, 0);
- e_TextureFontPrintFmt(20, motdh + 3, slMOTD, gStdFont, False, True);
- end;
-
- // Urgent message
- if not slReadUrgent and (slUrgent <> '') then
- begin
- e_DrawFillQuad(17, 65, gScreenWidth-17, motdh-1, 64, 64, 64, 128);
- e_DrawFillQuad(gScreenWidth div 2 - 256, gScreenHeight div 2 - 60,
- gScreenWidth div 2 + 256, gScreenHeight div 2 + 60, 64, 64, 64, 128);
- e_DrawQuad(gScreenWidth div 2 - 256, gScreenHeight div 2 - 60,
- gScreenWidth div 2 + 256, gScreenHeight div 2 + 60, 255, 127, 0);
- e_DrawLine(1, gScreenWidth div 2 - 256, gScreenHeight div 2 - 40,
- gScreenWidth div 2 + 256, gScreenHeight div 2 - 40, 255, 127, 0);
- l := Length(_lc[I_NET_SLIST_URGENT]) div 2;
- e_TextureFontPrint(gScreenWidth div 2 - cw * l, gScreenHeight div 2 - 58,
- _lc[I_NET_SLIST_URGENT], gStdFont);
- l := Length(slUrgent) div 2;
- e_TextureFontPrintFmt(gScreenWidth div 2 - 253, gScreenHeight div 2 - 38,
- slUrgent, gStdFont, False, True);
- l := Length(_lc[I_NET_SLIST_URGENT_CONT]) div 2;
- e_TextureFontPrint(gScreenWidth div 2 - cw * l, gScreenHeight div 2 + 41,
- _lc[I_NET_SLIST_URGENT_CONT], gStdFont);
- e_DrawLine(1, gScreenWidth div 2 - 256, gScreenHeight div 2 + 40,
- gScreenWidth div 2 + 256, gScreenHeight div 2 + 40, 255, 127, 0);
- Exit;
- end;
-
- if SL = nil then
- begin
- l := Length(slWaitStr) div 2;
- e_DrawFillQuad(17, 65, gScreenWidth-17, motdh-1, 64, 64, 64, 128);
- e_DrawQuad(gScreenWidth div 2 - 192, gScreenHeight div 2 - 10,
- gScreenWidth div 2 + 192, gScreenHeight div 2 + 11, 255, 127, 0);
- e_TextureFontPrint(gScreenWidth div 2 - cw * l, gScreenHeight div 2 - ch div 2,
- slWaitStr, gStdFont);
- Exit;
- end;
-
- y := 90;
- if (slSelection < Length(ST)) then
- begin
- I := slSelection;
- sy := y + 42 * I - 4;
- Srv := GetServerFromTable(I, SL, ST);
- ip := _lc[I_NET_ADDRESS] + ' ' + Srv.IP + ':' + IntToStr(Srv.Port);
- if Srv.Password then
- ip := ip + ' ' + _lc[I_NET_SERVER_PASSWORD] + ' ' + _lc[I_MENU_YES]
- else
- ip := ip + ' ' + _lc[I_NET_SERVER_PASSWORD] + ' ' + _lc[I_MENU_NO];
- end else
- if Length(ST) > 0 then
- slSelection := 0;
-
- mw := (gScreenWidth - 188);
- mx := 16 + mw;
-
- e_DrawFillQuad(16 + 1, sy, gScreenWidth - 16 - 1, sy + 40, 64, 64, 64, 0);
- e_DrawLine(1, 16 + 1, sy, gScreenWidth - 16 - 1, sy, 205, 205, 205);
- e_DrawLine(1, 16 + 1, sy + 41, gScreenWidth - 16 - 1, sy + 41, 255, 255, 255);
-
- e_DrawLine(1, 16, 85, gScreenWidth - 16, 85, 255, 127, 0);
- e_DrawLine(1, 16, motdh-20, gScreenWidth-16, motdh-20, 255, 127, 0);
-
- e_DrawLine(1, mx - 70, 64, mx - 70, motdh, 255, 127, 0);
- e_DrawLine(1, mx, 64, mx, motdh-20, 255, 127, 0);
- e_DrawLine(1, mx + 52, 64, mx + 52, motdh-20, 255, 127, 0);
- e_DrawLine(1, mx + 104, 64, mx + 104, motdh-20, 255, 127, 0);
-
- e_TextureFontPrintEx(18, 68, 'NAME/MAP', gStdFont, 255, 127, 0, 1);
- e_TextureFontPrintEx(mx - 68, 68, 'PING', gStdFont, 255, 127, 0, 1);
- e_TextureFontPrintEx(mx + 2, 68, 'MODE', gStdFont, 255, 127, 0, 1);
- e_TextureFontPrintEx(mx + 54, 68, 'PLRS', gStdFont, 255, 127, 0, 1);
- e_TextureFontPrintEx(mx + 106, 68, 'VER', gStdFont, 255, 127, 0, 1);
-
- y := 90;
- for I := 0 to High(ST) do
- begin
- Srv := GetServerFromTable(I, SL, ST);
- // Name and map
- e_TextureFontPrintEx(18, y, Srv.Name, gStdFont, 255, 255, 255, 1);
- e_TextureFontPrintEx(18, y + 16, Srv.Map, gStdFont, 210, 210, 210, 1);
-
- // Ping and similar count
- if (Srv.Ping < 0) or (Srv.Ping > 999) then
- e_TextureFontPrintEx(mx - 68, y, _lc[I_NET_SLIST_NO_ACCESS], gStdFont, 255, 0, 0, 1)
- else
- if Srv.Ping = 0 then
- e_TextureFontPrintEx(mx - 68, y, '<1' + _lc[I_NET_SLIST_PING_MS], gStdFont, 255, 255, 255, 1)
- else
- e_TextureFontPrintEx(mx - 68, y, IntToStr(Srv.Ping) + _lc[I_NET_SLIST_PING_MS], gStdFont, 255, 255, 255, 1);
-
- if Length(ST[I].Indices) > 1 then
- e_TextureFontPrintEx(mx - 68, y + 16, '< ' + IntToStr(Length(ST[I].Indices)) + ' >', gStdFont, 210, 210, 210, 1);
-
- // Game mode
- e_TextureFontPrintEx(mx + 2, y, g_Game_ModeToText(Srv.GameMode), gStdFont, 255, 255, 255, 1);
-
- // Players
- e_TextureFontPrintEx(mx + 54, y, IntToStr(Srv.Players) + '/' + IntToStr(Srv.MaxPlayers), gStdFont, 255, 255, 255, 1);
- e_TextureFontPrintEx(mx + 54, y + 16, IntToStr(Srv.LocalPl) + '+' + IntToStr(Srv.Bots), gStdFont, 210, 210, 210, 1);
-
- // Version
- e_TextureFontPrintEx(mx + 106, y, IntToStr(Srv.Protocol), gStdFont, 255, 255, 255, 1);
-
- y := y + 42;
- end;
-
- e_TextureFontPrintEx(20, motdh-20+3, ip, gStdFont, 205, 205, 205, 1);
- ip := IntToStr(Length(ST)) + _lc[I_NET_SLIST_SERVERS];
- e_TextureFontPrintEx(gScreenWidth - 48 - (Length(ip) + 1)*cw,
- motdh-20+3, ip, gStdFont, 205, 205, 205, 1);
-end;
-
-end.
diff --git a/src/game/opengl/r_player.pas b/src/game/opengl/r_player.pas
+++ /dev/null
@@ -1,909 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_player;
-
-interface
-
- uses g_player, g_base; // TPlayer, TRGB
-
- procedure r_Player_Load;
- procedure r_Player_Free;
-
- procedure r_Player_DrawAll;
- procedure r_Player_DrawDebug (p: TPlayer);
- procedure r_Player_DrawHealth;
-
- procedure r_Player_Draw (p: TPlayer);
- procedure r_Player_DrawIndicator (p: TPlayer; Color: TRGB);
- procedure r_Player_DrawBubble (p: TPlayer);
- procedure r_Player_DrawAim (p: TPlayer);
- procedure r_Player_DrawGUI (pl: TPlayer);
- procedure r_Player_DrawRulez (p: TPlayer);
- procedure r_Player_DrawPain (p: TPlayer);
- procedure r_Player_DrawPickup (p: TPlayer);
-
- {$IFDEF ENABLE_SHELLS}
- procedure r_Player_DrawShells;
- {$ENDIF}
-
- {$IFDEF ENABLE_CORPSES}
- procedure r_Player_DrawCorpses;
- {$ENDIF}
-
-implementation
-
- uses
- {$IFDEF ENABLE_HOLMES}
- g_holmes,
- {$ENDIF}
- {$IFDEF ENABLE_MENU}
- g_menu,
- {$ENDIF}
- {$IFDEF ENABLE_SHELLS}
- g_shells,
- {$ENDIF}
- {$IFDEF ENABLE_CORPSES}
- g_corpses,
- {$ENDIF}
- SysUtils, Classes, Math,
- MAPDEF, utils,
- g_basic, g_game, g_phys, g_map, g_language, g_weapons, g_items, g_net, g_options,
- r_playermodel, r_graphics, r_animations, r_textures, r_items, r_game, r_map
- ;
-
- var
- gItemsTexturesID: array [0..ITEM_MAX] of DWORD;
- PunchFrames: array [Boolean, 0..2] of DWORD;
- BulletTexture: DWORD;
- ShellTexture: DWORD;
-
- procedure r_Player_Load;
- begin
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_BLUESPHERE', GameWAD+':TEXTURES\SBLUE', 32, 32, 4, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_WHITESPHERE', GameWAD+':TEXTURES\SWHITE', 32, 32, 4, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_ARMORGREEN', GameWAD+':TEXTURES\ARMORGREEN', 32, 16, 3, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_ARMORBLUE', GameWAD+':TEXTURES\ARMORBLUE', 32, 16, 3, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_JETPACK', GameWAD+':TEXTURES\JETPACK', 32, 32, 3, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_INVUL', GameWAD+':TEXTURES\INVUL', 32, 32, 4, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_INVIS', GameWAD+':TEXTURES\INVIS', 32, 32, 4, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_RESPAWN', GameWAD+':TEXTURES\ITEMRESPAWN', 32, 32, 5, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_BOTTLE', GameWAD+':TEXTURES\BOTTLE', 16, 32, 4, True);
- g_Frames_CreateWAD(nil, 'FRAMES_ITEM_HELMET', GameWAD+':TEXTURES\HELMET', 16, 16, 4, True);
- g_Frames_CreateWAD(nil, 'FRAMES_FLAG_RED', GameWAD+':TEXTURES\FLAGRED', 64, 64, 5, False);
- g_Frames_CreateWAD(nil, 'FRAMES_FLAG_BLUE', GameWAD+':TEXTURES\FLAGBLUE', 64, 64, 5, False);
- g_Frames_CreateWAD(nil, 'FRAMES_FLAG_DOM', GameWAD+':TEXTURES\FLAGDOM', 64, 64, 5, False);
- g_Texture_CreateWADEx('ITEM_MEDKIT_SMALL', GameWAD+':TEXTURES\MED1');
- g_Texture_CreateWADEx('ITEM_MEDKIT_LARGE', GameWAD+':TEXTURES\MED2');
- g_Texture_CreateWADEx('ITEM_WEAPON_SAW', GameWAD+':TEXTURES\SAW');
- g_Texture_CreateWADEx('ITEM_WEAPON_PISTOL', GameWAD+':TEXTURES\PISTOL');
- g_Texture_CreateWADEx('ITEM_WEAPON_KASTET', GameWAD+':TEXTURES\KASTET');
- g_Texture_CreateWADEx('ITEM_WEAPON_SHOTGUN1', GameWAD+':TEXTURES\SHOTGUN1');
- g_Texture_CreateWADEx('ITEM_WEAPON_SHOTGUN2', GameWAD+':TEXTURES\SHOTGUN2');
- g_Texture_CreateWADEx('ITEM_WEAPON_CHAINGUN', GameWAD+':TEXTURES\MGUN');
- g_Texture_CreateWADEx('ITEM_WEAPON_ROCKETLAUNCHER', GameWAD+':TEXTURES\RLAUNCHER');
- g_Texture_CreateWADEx('ITEM_WEAPON_PLASMA', GameWAD+':TEXTURES\PGUN');
- g_Texture_CreateWADEx('ITEM_WEAPON_BFG', GameWAD+':TEXTURES\BFG');
- g_Texture_CreateWADEx('ITEM_WEAPON_SUPERPULEMET', GameWAD+':TEXTURES\SPULEMET');
- g_Texture_CreateWADEx('ITEM_WEAPON_FLAMETHROWER', GameWAD+':TEXTURES\FLAMETHROWER');
- g_Texture_CreateWADEx('ITEM_AMMO_BULLETS', GameWAD+':TEXTURES\CLIP');
- g_Texture_CreateWADEx('ITEM_AMMO_BULLETS_BOX', GameWAD+':TEXTURES\AMMO');
- g_Texture_CreateWADEx('ITEM_AMMO_SHELLS', GameWAD+':TEXTURES\SHELL1');
- g_Texture_CreateWADEx('ITEM_AMMO_SHELLS_BOX', GameWAD+':TEXTURES\SHELL2');
- g_Texture_CreateWADEx('ITEM_AMMO_ROCKET', GameWAD+':TEXTURES\ROCKET');
- g_Texture_CreateWADEx('ITEM_AMMO_ROCKET_BOX', GameWAD+':TEXTURES\ROCKETS');
- g_Texture_CreateWADEx('ITEM_AMMO_CELL', GameWAD+':TEXTURES\CELL');
- g_Texture_CreateWADEx('ITEM_AMMO_CELL_BIG', GameWAD+':TEXTURES\CELL2');
- g_Texture_CreateWADEx('ITEM_AMMO_FUELCAN', GameWAD+':TEXTURES\FUELCAN');
- g_Texture_CreateWADEx('ITEM_AMMO_BACKPACK', GameWAD+':TEXTURES\BPACK');
- g_Texture_CreateWADEx('ITEM_KEY_RED', GameWAD+':TEXTURES\KEYR');
- g_Texture_CreateWADEx('ITEM_KEY_GREEN', GameWAD+':TEXTURES\KEYG');
- g_Texture_CreateWADEx('ITEM_KEY_BLUE', GameWAD+':TEXTURES\KEYB');
- g_Texture_CreateWADEx('ITEM_OXYGEN', GameWAD+':TEXTURES\OXYGEN');
- g_Texture_CreateWADEx('ITEM_SUIT', GameWAD+':TEXTURES\SUIT');
- g_Texture_CreateWADEx('ITEM_WEAPON_KASTET', GameWAD+':TEXTURES\KASTET');
- g_Texture_CreateWADEx('ITEM_MEDKIT_BLACK', GameWAD+':TEXTURES\BMED');
-
- g_Texture_Get('ITEM_MEDKIT_SMALL', gItemsTexturesID[ITEM_MEDKIT_SMALL]);
- g_Texture_Get('ITEM_MEDKIT_LARGE', gItemsTexturesID[ITEM_MEDKIT_LARGE]);
- g_Texture_Get('ITEM_MEDKIT_BLACK', gItemsTexturesID[ITEM_MEDKIT_BLACK]);
- g_Texture_Get('ITEM_SUIT', gItemsTexturesID[ITEM_SUIT]);
- g_Texture_Get('ITEM_OXYGEN', gItemsTexturesID[ITEM_OXYGEN]);
- g_Texture_Get('ITEM_WEAPON_SAW', gItemsTexturesID[ITEM_WEAPON_SAW]);
- g_Texture_Get('ITEM_WEAPON_SHOTGUN1', gItemsTexturesID[ITEM_WEAPON_SHOTGUN1]);
- g_Texture_Get('ITEM_WEAPON_SHOTGUN2', gItemsTexturesID[ITEM_WEAPON_SHOTGUN2]);
- g_Texture_Get('ITEM_WEAPON_CHAINGUN', gItemsTexturesID[ITEM_WEAPON_CHAINGUN]);
- g_Texture_Get('ITEM_WEAPON_ROCKETLAUNCHER', gItemsTexturesID[ITEM_WEAPON_ROCKETLAUNCHER]);
- g_Texture_Get('ITEM_WEAPON_PLASMA', gItemsTexturesID[ITEM_WEAPON_PLASMA]);
- g_Texture_Get('ITEM_WEAPON_BFG', gItemsTexturesID[ITEM_WEAPON_BFG]);
- g_Texture_Get('ITEM_WEAPON_SUPERPULEMET', gItemsTexturesID[ITEM_WEAPON_SUPERPULEMET]);
- g_Texture_Get('ITEM_WEAPON_FLAMETHROWER', gItemsTexturesID[ITEM_WEAPON_FLAMETHROWER]);
- g_Texture_Get('ITEM_AMMO_BULLETS', gItemsTexturesID[ITEM_AMMO_BULLETS]);
- g_Texture_Get('ITEM_AMMO_BULLETS_BOX', gItemsTexturesID[ITEM_AMMO_BULLETS_BOX]);
- g_Texture_Get('ITEM_AMMO_SHELLS', gItemsTexturesID[ITEM_AMMO_SHELLS]);
- g_Texture_Get('ITEM_AMMO_SHELLS_BOX', gItemsTexturesID[ITEM_AMMO_SHELLS_BOX]);
- g_Texture_Get('ITEM_AMMO_ROCKET', gItemsTexturesID[ITEM_AMMO_ROCKET]);
- g_Texture_Get('ITEM_AMMO_ROCKET_BOX', gItemsTexturesID[ITEM_AMMO_ROCKET_BOX]);
- g_Texture_Get('ITEM_AMMO_CELL', gItemsTexturesID[ITEM_AMMO_CELL]);
- g_Texture_Get('ITEM_AMMO_CELL_BIG', gItemsTexturesID[ITEM_AMMO_CELL_BIG]);
- g_Texture_Get('ITEM_AMMO_FUELCAN', gItemsTexturesID[ITEM_AMMO_FUELCAN]);
- g_Texture_Get('ITEM_AMMO_BACKPACK', gItemsTexturesID[ITEM_AMMO_BACKPACK]);
- g_Texture_Get('ITEM_KEY_RED', gItemsTexturesID[ITEM_KEY_RED]);
- g_Texture_Get('ITEM_KEY_GREEN', gItemsTexturesID[ITEM_KEY_GREEN]);
- g_Texture_Get('ITEM_KEY_BLUE', gItemsTexturesID[ITEM_KEY_BLUE]);
- g_Texture_Get('ITEM_WEAPON_KASTET', gItemsTexturesID[ITEM_WEAPON_KASTET]);
- g_Texture_Get('ITEM_WEAPON_PISTOL', gItemsTexturesID[ITEM_WEAPON_PISTOL]);
-
- g_Frames_CreateWAD(@PunchFrames[False, 0], 'FRAMES_PUNCH', GameWAD + ':WEAPONS\PUNCH', 64, 64, 4, False);
- g_Frames_CreateWAD(@PunchFrames[False, 1], 'FRAMES_PUNCH_UP', GameWAD + ':WEAPONS\PUNCH_UP', 64, 64, 4, False);
- g_Frames_CreateWAD(@PunchFrames[False, 2], 'FRAMES_PUNCH_DN', GameWAD + ':WEAPONS\PUNCH_DN', 64, 64, 4, False);
- g_Frames_CreateWAD(@PunchFrames[True, 0], 'FRAMES_PUNCH_BERSERK', GameWAD + ':WEAPONS\PUNCHB', 64, 64, 4, False);
- g_Frames_CreateWAD(@PunchFrames[True, 1], 'FRAMES_PUNCH_BERSERK_UP', GameWAD + ':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
- g_Frames_CreateWAD(@PunchFrames[True, 2], 'FRAMES_PUNCH_BERSERK_DN', GameWAD + ':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
- g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD + ':TEXTURES\EBULLET');
- g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD + ':TEXTURES\ESHELL');
- g_Texture_Get('TEXTURE_SHELL_BULLET', BulletTexture);
- g_Texture_Get('TEXTURE_SHELL_SHELL', ShellTexture);
- end;
-
- procedure r_Player_Free;
- begin
- g_Frames_DeleteByName('FRAMES_PUNCH');
- g_Frames_DeleteByName('FRAMES_PUNCH_UP');
- g_Frames_DeleteByName('FRAMES_PUNCH_DN');
- g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
- g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
- g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
- end;
-
- procedure r_Player_DrawAll;
- var i: Integer;
- begin
- if gPlayers <> nil then
- for i := 0 to High(gPlayers) do
- if gPlayers[i] <> nil then
- r_Player_Draw(gPlayers[i])
- end;
-
-procedure r_Player_DrawDebug (p: TPlayer);
-var
- fW, fH: Byte;
-begin
- if p = nil then Exit;
- if (@p.Obj) = nil then Exit;
-
- e_TextureFontGetSize(gStdFont, fW, fH);
-
- e_TextureFontPrint(0, 0 , 'Pos X: ' + IntToStr(p.Obj.X), gStdFont);
- e_TextureFontPrint(0, fH , 'Pos Y: ' + IntToStr(p.Obj.Y), gStdFont);
- e_TextureFontPrint(0, fH * 2, 'Vel X: ' + IntToStr(p.Obj.Vel.X), gStdFont);
- e_TextureFontPrint(0, fH * 3, 'Vel Y: ' + IntToStr(p.Obj.Vel.Y), gStdFont);
- e_TextureFontPrint(0, fH * 4, 'Acc X: ' + IntToStr(p.Obj.Accel.X), gStdFont);
- e_TextureFontPrint(0, fH * 5, 'Acc Y: ' + IntToStr(p.Obj.Accel.Y), gStdFont);
- e_TextureFontPrint(0, fH * 6, 'Old X: ' + IntToStr(p.Obj.oldX), gStdFont);
- e_TextureFontPrint(0, fH * 7, 'Old Y: ' + IntToStr(p.Obj.oldY), gStdFont);
-end;
-
-procedure r_Player_DrawHealth;
-var
- i: Integer;
- fW, fH: Byte;
-begin
- if gPlayers = nil then Exit;
- e_TextureFontGetSize(gStdFont, fW, fH);
-
- for i := 0 to High(gPlayers) do
- if gPlayers[i] <> nil then
- begin
- e_TextureFontPrint(gPlayers[i].Obj.X + gPlayers[i].Obj.Rect.X,
- gPlayers[i].Obj.Y + gPlayers[i].Obj.Rect.Y + gPlayers[i].Obj.Rect.Height - fH * 2,
- IntToStr(gPlayers[i].Health), gStdFont);
- e_TextureFontPrint(gPlayers[i].Obj.X + gPlayers[i].Obj.Rect.X,
- gPlayers[i].Obj.Y + gPlayers[i].Obj.Rect.Y + gPlayers[i].Obj.Rect.Height - fH,
- IntToStr(gPlayers[i].Armor), gStdFont);
- end;
-end;
-
-{$IFDEF ENABLE_CORPSES}
- procedure r_Player_DrawCorpse (p: TCorpse);
- var fX, fY: Integer;
- begin
- if (p.State <> CORPSE_STATE_REMOVEME) and (p.Model <> nil) then
- begin
- p.Obj.lerp(gLerpFactor, fX, fY);
- r_PlayerModel_Draw(p.Model, fX, fY)
- end
- end;
-
- procedure r_Player_DrawCorpses;
- var i: Integer;
- begin
- if gCorpses <> nil then
- for i := 0 to High(gCorpses) do
- if gCorpses[i] <> nil then
- r_Player_DrawCorpse(gCorpses[i])
- end;
-{$ENDIF}
-
-{$IFDEF ENABLE_SHELLS}
- procedure r_Player_DrawShells;
- var i, fX, fY: Integer; a: TDFPoint; TextureID: DWORD = DWORD(-1);
- begin
- if gShells <> nil then
- begin
- for i := 0 to High(gShells) do
- begin
- if gShells[i].alive and g_Obj_Collide(sX, sY, sWidth, sHeight, @gShells[i].Obj) then
- begin
- gShells[i].Obj.lerp(gLerpFactor, fX, fY);
- case gShells[i].SType of
- SHELL_BULLET:
- begin
- TextureID := BulletTexture;
- a.X := 2;
- a.Y := 1;
- end;
- SHELL_SHELL, SHELL_DBLSHELL:
- begin
- TextureID := ShellTexture;
- a.X := 4;
- a.Y := 2;
- end
- else
- Assert(false)
- end;
- e_DrawAdv(TextureID, fX, fY, 0, True, False, gShells[i].RAngle, @a, TMirrorType.None);
- end
- end
- end
- end;
-{$ENDIF}
-
-procedure r_Player_DrawIndicator (p: TPlayer; Color: TRGB);
-var
- indX, indY, fX, fY, fSlope: Integer;
- indW, indH: Word;
- indA: Single;
- a: TDFPoint;
- nW, nH: Byte;
- ID: DWORD;
- c: TRGB;
-begin
- if p.Alive then
- begin
- p.Obj.lerp(gLerpFactor, fX, fY);
- fSlope := nlerp(p.SlopeOld, p.Obj.slopeUpLeft, gLerpFactor);
-
- case gPlayerIndicatorStyle of
- 0:
- begin
- if g_Texture_Get('TEXTURE_PLAYER_INDICATOR', ID) then
- begin
- e_GetTextureSize(ID, @indW, @indH);
- a.X := indW div 2;
- a.Y := indH div 2;
-
- if (p.Obj.X + p.Obj.Rect.X) < 0 then
- begin
- indA := 90;
- indX := fX + p.Obj.Rect.X + p.Obj.Rect.Width;
- indY := fY + p.Obj.Rect.Y + (p.Obj.Rect.Height - indW) div 2;
- end
-
- else if (p.Obj.X + p.Obj.Rect.X + p.Obj.Rect.Width) > Max(gMapInfo.Width, gPlayerScreenSize.X) then
- begin
- indA := 270;
- indX := fX + p.Obj.Rect.X - indH;
- indY := fY + p.Obj.Rect.Y + (p.Obj.Rect.Height - indW) div 2;
- end
-
- else if (p.Obj.Y - indH) < 0 then
- begin
- indA := 180;
- indX := fX + p.Obj.Rect.X + (p.Obj.Rect.Width - indW) div 2;
- indY := fY + p.Obj.Rect.Y + p.Obj.Rect.Height;
- end
-
- else
- begin
- indA := 0;
- indX := fX + p.Obj.Rect.X + (p.Obj.Rect.Width - indW) div 2;
- indY := fY - indH;
- end;
-
- indY := indY + fSlope;
- indX := EnsureRange(indX, 0, Max(gMapInfo.Width, gPlayerScreenSize.X) - indW);
- indY := EnsureRange(indY, 0, Max(gMapInfo.Height, gPlayerScreenSize.Y) - indH);
-
- c := e_Colors;
- e_Colors := Color;
- e_DrawAdv(ID, indX, indY, 0, True, False, indA, @a);
- e_Colors := c;
- end;
- end;
-
- 1:
- begin
- e_TextureFontGetSize(gStdFont, nW, nH);
- indX := fX + p.Obj.Rect.X + (p.Obj.Rect.Width - Length(p.Name) * nW) div 2;
- indY := fY - nH + fSlope;
- e_TextureFontPrintEx(indX, indY, p.Name, gStdFont, Color.R, Color.G, Color.B, 1.0, True);
- end;
- end;
- end
-end;
-
-procedure r_Player_DrawBubble (p: TPlayer);
-var
- bubX, bubY, fX, fY: Integer;
- ID: LongWord;
- Rb, Gb, Bb,
- Rw, Gw, Bw: SmallInt;
- Dot: Byte;
- CObj: TObj;
-begin
- {$IFDEF ENABLE_CORPSES}
- CObj := g_Corpses_GetCameraObj(p);
- {$ELSE}
- CObj := p.Obj;
- {$ENDIF}
- CObj.lerp(gLerpFactor, fX, fY);
- // NB: _F_Obj.Rect is used to keep the bubble higher; this is not a mistake
- bubX := fX + p.Obj.Rect.X + IfThen(p.Direction = TDirection.D_LEFT, -4, 18);
- bubY := fY + p.Obj.Rect.Y - 18;
- Rb := 64;
- Gb := 64;
- Bb := 64;
- Rw := 240;
- Gw := 240;
- Bw := 240;
- case gChatBubble of
- 1: // simple textual non-bubble
- begin
- bubX := fX + p.Obj.Rect.X - 11;
- bubY := fY + p.Obj.Rect.Y - 17;
- e_TextureFontPrint(bubX, bubY, '[...]', gStdFont);
- Exit;
- end;
- 2: // advanced pixel-perfect bubble
- begin
- if p.Team = TEAM_RED then
- Rb := 255
- else
- if p.Team = TEAM_BLUE then
- Bb := 255;
- end;
- 3: // colored bubble
- begin
- Rb := p.Model.Color.R;
- Gb := p.Model.Color.G;
- Bb := p.Model.Color.B;
- Rw := Min(Rb * 2 + 64, 255);
- Gw := Min(Gb * 2 + 64, 255);
- Bw := Min(Bb * 2 + 64, 255);
- if (Abs(Rw - Rb) < 32)
- or (Abs(Gw - Gb) < 32)
- or (Abs(Bw - Bb) < 32) then
- begin
- Rb := Max(Rw div 2 - 16, 0);
- Gb := Max(Gw div 2 - 16, 0);
- Bb := Max(Bw div 2 - 16, 0);
- end;
- end;
- 4: // custom textured bubble
- begin
- if g_Texture_Get('TEXTURE_PLAYER_TALKBUBBLE', ID) then
- if p.Direction = TDirection.D_RIGHT then
- e_Draw(ID, bubX - 6, bubY - 7, 0, True, False)
- else
- e_Draw(ID, bubX - 6, bubY - 7, 0, True, False, TMirrorType.Horizontal);
- Exit;
- end;
- end;
-
- // Outer borders
- e_DrawQuad(bubX + 1, bubY , bubX + 18, bubY + 13, Rb, Gb, Bb);
- e_DrawQuad(bubX , bubY + 1, bubX + 19, bubY + 12, Rb, Gb, Bb);
- // Inner box
- e_DrawFillQuad(bubX + 1, bubY + 1, bubX + 18, bubY + 12, Rw, Gw, Bw, 0);
-
- // Tail
- Dot := IfThen(p.Direction = TDirection.D_LEFT, 14, 5);
- e_DrawLine(1, bubX + Dot, bubY + 14, bubX + Dot, bubY + 16, Rb, Gb, Bb);
- e_DrawLine(1, bubX + IfThen(p.Direction = TDirection.D_LEFT, Dot - 1, Dot + 1), bubY + 13, bubX + IfThen(p.Direction = TDirection.D_LEFT, Dot - 1, Dot + 1), bubY + 15, Rw, Gw, Bw);
- e_DrawLine(1, bubX + IfThen(p.Direction = TDirection.D_LEFT, Dot - 2, Dot + 2), bubY + 13, bubX + IfThen(p.Direction = TDirection.D_LEFT, Dot - 2, Dot + 2), bubY + 14, Rw, Gw, Bw);
- e_DrawLine(1, bubX + IfThen(p.Direction = TDirection.D_LEFT, Dot - 3, Dot + 3), bubY + 13, bubX + IfThen(p.Direction = TDirection.D_LEFT, Dot - 3, Dot + 3), bubY + 13, Rw, Gw, Bw);
- e_DrawLine(1, bubX + IfThen(p.Direction = TDirection.D_LEFT, Dot - 3, Dot + 3), bubY + 14, bubX + IfThen(p.Direction = TDirection.D_LEFT, Dot - 1, Dot + 1), bubY + 16, Rb, Gb, Bb);
-
- // Dots
- Dot := 6;
- e_DrawFillQuad(bubX + Dot, bubY + 8, bubX + Dot + 1, bubY + 9, Rb, Gb, Bb, 0);
- e_DrawFillQuad(bubX + Dot + 3, bubY + 8, bubX + Dot + 4, bubY + 9, Rb, Gb, Bb, 0);
- e_DrawFillQuad(bubX + Dot + 6, bubY + 8, bubX + Dot + 7, bubY + 9, Rb, Gb, Bb, 0);
-end;
-
-procedure r_Player_Draw (p: TPlayer);
-var
- ID: DWORD;
- w, h: Word;
- dr: Boolean;
- Mirror: TMirrorType;
- fX, fY, fSlope: Integer;
-begin
- p.Obj.lerp(gLerpFactor, fX, fY);
- fSlope := nlerp(p.SlopeOld, p.Obj.slopeUpLeft, gLerpFactor);
-
- if p.Alive then
- begin
- if p.Direction = TDirection.D_RIGHT then
- Mirror := TMirrorType.None
- else
- Mirror := TMirrorType.Horizontal;
-
- if p.PunchAnim.IsValid() and p.PunchAnim.enabled then
- begin
- if p.FKeys[KEY_DOWN].Pressed then ID := PunchFrames[R_BERSERK in p.FRulez, 2]
- else if p.FKeys[KEY_UP].Pressed then ID := PunchFrames[R_BERSERK in p.FRulez, 1]
- else ID := PunchFrames[R_BERSERK in p.FRulez, 0];
- r_AnimState_Draw(ID, p.PunchAnim, fX + IfThen(p.Direction = TDirection.D_LEFT, 15 - p.Obj.Rect.X, p.Obj.Rect.X - 15), fY + fSlope + p.Obj.Rect.Y - 11, 0, Mirror, False);
- end;
-
- if (p.FMegaRulez[MR_INVUL] > gTime) and ((gPlayerDrawn <> p) or (p.SpawnInvul >= gTime)) then
- if g_Texture_Get('TEXTURE_PLAYER_INVULPENTA', ID) then
- begin
- e_GetTextureSize(ID, @w, @h);
- if p.Direction = TDirection.D_LEFT then
- e_Draw(ID, fX + p.Obj.Rect.X + (p.Obj.Rect.Width div 2) - (w div 2) + 4,
- fY + p.Obj.Rect.Y + (p.Obj.Rect.Height div 2) - (h div 2) - 7 + fSlope, 0, True, False)
- else
- e_Draw(ID, fX + p.Obj.Rect.X + (p.Obj.Rect.Width div 2) - (w div 2) - 2,
- fY + p.Obj.Rect.Y + (p.Obj.Rect.Height div 2) - (h div 2) - 7 + fSlope, 0, True, False)
- end;
-
- if p.FMegaRulez[MR_INVIS] > gTime then
- begin
- if (gPlayerDrawn <> nil) and ((p = gPlayerDrawn) or
- ((p.Team = gPlayerDrawn.Team) and (gGameSettings.GameMode <> GM_DM))) then
- begin
- if (p.FMegaRulez[MR_INVIS] - gTime) <= 2100 then
- dr := not Odd((p.FMegaRulez[MR_INVIS] - gTime) div 300)
- else
- dr := True;
- if dr then
- r_PlayerModel_Draw(p.Model, fX, fY + fSlope, 200)
- else
- r_PlayerModel_Draw(p.Model, fX, fY + fSlope);
- end
- else
- r_PlayerModel_Draw(p.Model, fX, fY + fSlope, 254);
- end
- else
- r_PlayerModel_Draw(p.Model, fX, fY + fSlope);
- end;
-
- if g_debug_Frames then
- begin
- e_DrawQuad(p.Obj.X + p.Obj.Rect.X,
- p.Obj.Y + p.Obj.Rect.Y,
- p.Obj.X + p.Obj.Rect.X + p.Obj.Rect.Width - 1,
- p.Obj.Y + p.Obj.Rect.Y + p.Obj.Rect.Height - 1,
- 0, 255, 0);
- end;
-
- if (gChatBubble > 0) and (p.FKeys[KEY_CHAT].Pressed) and not p.Ghost then
- if (p.FMegaRulez[MR_INVIS] <= gTime) or ((gPlayerDrawn <> nil) and ((p = gPlayerDrawn) or
- ((p.Team = gPlayerDrawn.Team) and (gGameSettings.GameMode <> GM_DM)))) then
- r_Player_DrawBubble(p);
-
- // e_DrawPoint(5, 335, 288, 255, 0, 0); // DL, UR, DL, UR
- if gAimLine and p.Alive and ((p = gPlayer1) or (p = gPlayer2)) then
- r_Player_DrawAim(p);
-end;
-
-procedure r_Player_DrawAim (p: TPlayer);
-
- procedure drawCast (sz: Integer; ax0, ay0, ax1, ay1: Integer);
- var
- ex, ey: Integer;
- begin
-
-{$IFDEF ENABLE_HOLMES}
- if p.isValidViewPort() and (p = gPlayer1) then
- begin
- g_Holmes_plrLaser(ax0, ay0, ax1, ay1);
- end;
-{$ENDIF}
-
- e_DrawLine(sz, ax0, ay0, ax1, ay1, 255, 0, 0, 96);
- if (g_Map_traceToNearestWall(ax0, ay0, ax1, ay1, @ex, @ey) <> nil) then
- begin
- e_DrawLine(sz, ax0, ay0, ex, ey, 0, 255, 0, 96);
- end
- else
- begin
- e_DrawLine(sz, ax0, ay0, ex, ey, 0, 0, 255, 96);
- end;
- end;
-
-var
- wx, wy, xx, yy: Integer;
- angle: SmallInt;
- sz, len: Word;
-begin
- wx := p.Obj.X + WEAPONPOINT[p.Direction].X + IfThen(p.Direction = TDirection.D_LEFT, 7, -7);
- wy := p.Obj.Y + WEAPONPOINT[p.Direction].Y;
- angle := p.Angle_;
- len := 1024;
- sz := 2;
- case p.CurrWeap of
- 0: begin // Punch
- len := 12;
- sz := 4;
- end;
- 1: begin // Chainsaw
- len := 24;
- sz := 6;
- end;
- 2: begin // Pistol
- len := 1024;
- sz := 2;
- if angle = ANGLE_RIGHTUP then Dec(angle, 2);
- if angle = ANGLE_RIGHTDOWN then Inc(angle, 4);
- if angle = ANGLE_LEFTUP then Inc(angle, 2);
- if angle = ANGLE_LEFTDOWN then Dec(angle, 4);
- end;
- 3: begin // Shotgun
- len := 1024;
- sz := 3;
- if angle = ANGLE_RIGHTUP then Dec(angle, 2);
- if angle = ANGLE_RIGHTDOWN then Inc(angle, 4);
- if angle = ANGLE_LEFTUP then Inc(angle, 2);
- if angle = ANGLE_LEFTDOWN then Dec(angle, 4);
- end;
- 4: begin // Double Shotgun
- len := 1024;
- sz := 4;
- if angle = ANGLE_RIGHTUP then Dec(angle, 2);
- if angle = ANGLE_RIGHTDOWN then Inc(angle, 4);
- if angle = ANGLE_LEFTUP then Inc(angle, 2);
- if angle = ANGLE_LEFTDOWN then Dec(angle, 4);
- end;
- 5: begin // Chaingun
- len := 1024;
- sz := 3;
- if angle = ANGLE_RIGHTUP then Dec(angle, 2);
- if angle = ANGLE_RIGHTDOWN then Inc(angle, 4);
- if angle = ANGLE_LEFTUP then Inc(angle, 2);
- if angle = ANGLE_LEFTDOWN then Dec(angle, 4);
- end;
- 6: begin // Rocket Launcher
- len := 1024;
- sz := 7;
- if angle = ANGLE_RIGHTUP then Inc(angle, 2);
- if angle = ANGLE_RIGHTDOWN then Inc(angle, 4);
- if angle = ANGLE_LEFTUP then Dec(angle, 2);
- if angle = ANGLE_LEFTDOWN then Dec(angle, 4);
- end;
- 7: begin // Plasmagun
- len := 1024;
- sz := 5;
- if angle = ANGLE_RIGHTUP then Inc(angle);
- if angle = ANGLE_RIGHTDOWN then Inc(angle, 3);
- if angle = ANGLE_LEFTUP then Dec(angle);
- if angle = ANGLE_LEFTDOWN then Dec(angle, 3);
- end;
- 8: begin // BFG
- len := 1024;
- sz := 12;
- if angle = ANGLE_RIGHTUP then Inc(angle, 1);
- if angle = ANGLE_RIGHTDOWN then Inc(angle, 2);
- if angle = ANGLE_LEFTUP then Dec(angle, 1);
- if angle = ANGLE_LEFTDOWN then Dec(angle, 2);
- end;
- 9: begin // Super Chaingun
- len := 1024;
- sz := 4;
- if angle = ANGLE_RIGHTUP then Dec(angle, 2);
- if angle = ANGLE_RIGHTDOWN then Inc(angle, 4);
- if angle = ANGLE_LEFTUP then Inc(angle, 2);
- if angle = ANGLE_LEFTDOWN then Dec(angle, 4);
- end;
- end;
- xx := Trunc(Cos(-DegToRad(angle)) * len) + wx;
- yy := Trunc(Sin(-DegToRad(angle)) * len) + wy;
- {$IF DEFINED(D2F_DEBUG)}
- drawCast(sz, wx, wy, xx, yy);
- {$ELSE}
- e_DrawLine(sz, wx, wy, xx, yy, 255, 0, 0, 96);
- {$ENDIF}
-end;
-
-procedure r_Player_DrawGUI (pl: TPlayer);
-var
- ID: DWORD;
- X, Y, SY, a, p, m: Integer;
- tw, th: Word;
- cw, ch: Byte;
- s: string;
- stat: TPlayerStatArray;
-begin
- X := gPlayerScreenSize.X;
- SY := gPlayerScreenSize.Y;
- Y := 0;
-
- if gShowScore and (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
- begin
- if gGameSettings.GameMode = GM_CTF then
- a := 32 + 8
- else
- a := 0;
- if gGameSettings.GameMode = GM_CTF then
- begin
- s := 'TEXTURE_PLAYER_REDFLAG';
- if gFlags[FLAG_RED].State = FLAG_STATE_CAPTURED then
- s := 'TEXTURE_PLAYER_REDFLAG_S';
- if gFlags[FLAG_RED].State = FLAG_STATE_DROPPED then
- s := 'TEXTURE_PLAYER_REDFLAG_D';
- if g_Texture_Get(s, ID) then
- e_Draw(ID, X-16-32, 240-72-4, 0, True, False);
- end;
-
- s := IntToStr(gTeamStat[TEAM_RED].Score);
- e_CharFont_GetSize(gMenuFont, s, tw, th);
- e_CharFont_PrintEx(gMenuFont, X-16-a-tw, 240-72-4, s, TEAMCOLOR[TEAM_RED]);
-
- if gGameSettings.GameMode = GM_CTF then
- begin
- s := 'TEXTURE_PLAYER_BLUEFLAG';
- if gFlags[FLAG_BLUE].State = FLAG_STATE_CAPTURED then
- s := 'TEXTURE_PLAYER_BLUEFLAG_S';
- if gFlags[FLAG_BLUE].State = FLAG_STATE_DROPPED then
- s := 'TEXTURE_PLAYER_BLUEFLAG_D';
- if g_Texture_Get(s, ID) then
- e_Draw(ID, X-16-32, 240-32-4, 0, True, False);
- end;
-
- s := IntToStr(gTeamStat[TEAM_BLUE].Score);
- e_CharFont_GetSize(gMenuFont, s, tw, th);
- e_CharFont_PrintEx(gMenuFont, X-16-a-tw, 240-32-4, s, TEAMCOLOR[TEAM_BLUE]);
- end;
-
- if g_Texture_Get('TEXTURE_PLAYER_HUDBG', ID) then
- e_DrawFill(ID, X, 0, 1, (gPlayerScreenSize.Y div 256)+IfThen(gPlayerScreenSize.Y mod 256 > 0, 1, 0),
- 0, False, False);
-
- if g_Texture_Get('TEXTURE_PLAYER_HUD', ID) then
- e_Draw(ID, X+2, Y, 0, True, False);
-
- if gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT] then
- begin
- if gShowStat then
- begin
- s := IntToStr(pl.Frags);
- e_CharFont_GetSize(gMenuFont, s, tw, th);
- e_CharFont_PrintEx(gMenuFont, X-16-tw, Y, s, _RGB(255, 0, 0));
-
- s := '';
- p := 1;
- m := 0;
- stat := g_Player_GetStats();
- if stat <> nil then
- begin
- p := 1;
-
- for a := 0 to High(stat) do
- if stat[a].Name <> pl.Name then
- begin
- if stat[a].Frags > m then m := stat[a].Frags;
- if stat[a].Frags > pl.Frags then p := p+1;
- end;
- end;
-
- s := IntToStr(p)+' / '+IntToStr(Length(stat))+' ';
- if pl.Frags >= m then s := s+'+' else s := s+'-';
- s := s+IntToStr(Abs(pl.Frags-m));
-
- e_CharFont_GetSize(gMenuSmallFont, s, tw, th);
- e_CharFont_PrintEx(gMenuSmallFont, X-16-tw, Y+32, s, _RGB(255, 0, 0));
- end;
-
- if gLMSRespawn > LMS_RESPAWN_NONE then
- begin
- s := _lc[I_GAME_WARMUP];
- e_CharFont_GetSize(gMenuFont, s, tw, th);
- s := s + ': ' + IntToStr((gLMSRespawnTime - gTime) div 1000);
- e_CharFont_PrintEx(gMenuFont, X-64-tw, SY-32, s, _RGB(0, 255, 0));
- end
- else if gShowLives and (gGameSettings.MaxLives > 0) then
- begin
- s := IntToStr(pl.Lives);
- e_CharFont_GetSize(gMenuFont, s, tw, th);
- e_CharFont_PrintEx(gMenuFont, X-16-tw, SY-32, s, _RGB(0, 255, 0));
- end;
- end;
-
- e_CharFont_GetSize(gMenuSmallFont, pl.Name, tw, th);
- e_CharFont_PrintEx(gMenuSmallFont, X+98-(tw div 2), Y+8, pl.Name, _RGB(255, 0, 0));
-
- if R_BERSERK in pl.FRulez then
- e_Draw(gItemsTexturesID[ITEM_MEDKIT_BLACK], X+37, Y+45, 0, True, False)
- else
- e_Draw(gItemsTexturesID[ITEM_MEDKIT_LARGE], X+37, Y+45, 0, True, False);
-
- if g_Texture_Get('TEXTURE_PLAYER_ARMORHUD', ID) then
- e_Draw(ID, X+36, Y+77, 0, True, False);
-
- s := IntToStr(IfThen(pl.Health > 0, pl.Health, 0));
- e_CharFont_GetSize(gMenuFont, s, tw, th);
- e_CharFont_PrintEx(gMenuFont, X+178-tw, Y+40, s, _RGB(255, 0, 0));
-
- s := IntToStr(pl.Armor);
- e_CharFont_GetSize(gMenuFont, s, tw, th);
- e_CharFont_PrintEx(gMenuFont, X+178-tw, Y+68, s, _RGB(255, 0, 0));
-
- s := IntToStr(pl.GetAmmoByWeapon(pl.CurrWeap));
-
- case pl.CurrWeap of
- WEAPON_KASTET:
- begin
- s := '--';
- ID := gItemsTexturesID[ITEM_WEAPON_KASTET];
- end;
- WEAPON_SAW:
- begin
- s := '--';
- ID := gItemsTexturesID[ITEM_WEAPON_SAW];
- end;
- WEAPON_PISTOL: ID := gItemsTexturesID[ITEM_WEAPON_PISTOL];
- WEAPON_CHAINGUN: ID := gItemsTexturesID[ITEM_WEAPON_CHAINGUN];
- WEAPON_SHOTGUN1: ID := gItemsTexturesID[ITEM_WEAPON_SHOTGUN1];
- WEAPON_SHOTGUN2: ID := gItemsTexturesID[ITEM_WEAPON_SHOTGUN2];
- WEAPON_SUPERPULEMET: ID := gItemsTexturesID[ITEM_WEAPON_SUPERPULEMET];
- WEAPON_ROCKETLAUNCHER: ID := gItemsTexturesID[ITEM_WEAPON_ROCKETLAUNCHER];
- WEAPON_PLASMA: ID := gItemsTexturesID[ITEM_WEAPON_PLASMA];
- WEAPON_BFG: ID := gItemsTexturesID[ITEM_WEAPON_BFG];
- WEAPON_FLAMETHROWER: ID := gItemsTexturesID[ITEM_WEAPON_FLAMETHROWER];
- end;
-
- e_CharFont_GetSize(gMenuFont, s, tw, th);
- e_CharFont_PrintEx(gMenuFont, X+178-tw, Y+158, s, _RGB(255, 0, 0));
- e_Draw(ID, X+20, Y+160, 0, True, False);
-
- if R_KEY_RED in pl.FRulez then
- e_Draw(gItemsTexturesID[ITEM_KEY_RED], X+78, Y+214, 0, True, False);
-
- if R_KEY_GREEN in pl.FRulez then
- e_Draw(gItemsTexturesID[ITEM_KEY_GREEN], X+95, Y+214, 0, True, False);
-
- if R_KEY_BLUE in pl.FRulez then
- e_Draw(gItemsTexturesID[ITEM_KEY_BLUE], X+112, Y+214, 0, True, False);
-
- if pl.JetFuel > 0 then
- begin
- if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID) then
- e_Draw(ID, X+2, Y+116, 0, True, False);
- if g_Texture_Get('TEXTURE_PLAYER_HUDJET', ID) then
- e_Draw(ID, X+2, Y+126, 0, True, False);
- e_DrawLine(4, X+16, Y+122, X+16+Trunc(168*IfThen(pl.Air > 0, pl.Air, 0)/AIR_MAX), Y+122, 0, 0, 196);
- e_DrawLine(4, X+16, Y+132, X+16+Trunc(168*pl.JetFuel/JET_MAX), Y+132, 208, 0, 0);
- end
- else
- begin
- if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID) then
- e_Draw(ID, X+2, Y+124, 0, True, False);
- e_DrawLine(4, X+16, Y+130, X+16+Trunc(168*IfThen(pl.Air > 0, pl.Air, 0)/AIR_MAX), Y+130, 0, 0, 196);
- end;
-
- if gShowPing and g_Game_IsClient then
- begin
- s := _lc[I_GAME_PING_HUD] + IntToStr(NetPeer.lastRoundTripTime) + _lc[I_NET_SLIST_PING_MS];
- e_TextureFontPrint(X + 4, Y + 242, s, gStdFont);
- Y := Y + 16;
- end;
-
- if pl.Spectator then
- begin
- e_TextureFontPrint(X + 4, Y + 242, _lc[I_PLAYER_SPECT], gStdFont);
- e_TextureFontPrint(X + 4, Y + 258, _lc[I_PLAYER_SPECT2], gStdFont);
- e_TextureFontPrint(X + 4, Y + 274, _lc[I_PLAYER_SPECT1], gStdFont);
- if pl.NoRespawn then
- begin
- e_TextureFontGetSize(gStdFont, cw, ch);
- s := _lc[I_PLAYER_SPECT4];
- e_TextureFontPrintEx(gScreenWidth div 2 - cw*(Length(s) div 2),
- gScreenHeight-4-ch, s, gStdFont, 255, 255, 255, 1, True);
- e_TextureFontPrint(X + 4, Y + 290, _lc[I_PLAYER_SPECT1S], gStdFont);
- end;
-
- end;
-end;
-
-procedure r_Player_DrawRulez (p: TPlayer);
-var
- dr: Boolean;
-begin
- // При взятии неуязвимости рисуется инверсионный белый фон
- if (p.FMegaRulez[MR_INVUL] >= gTime) and (p.SpawnInvul < gTime) then
- begin
- if (p.FMegaRulez[MR_INVUL]-gTime) <= 2100 then
- dr := not Odd((p.FMegaRulez[MR_INVUL]-gTime) div 300)
- else
- dr := True;
-
- if dr then
- e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1,
- 191, 191, 191, 0, TBlending.Invert);
- end;
-
- // При взятии защитного костюма рисуется зеленоватый фон
- if p.FMegaRulez[MR_SUIT] >= gTime then
- begin
- if (p.FMegaRulez[MR_SUIT]-gTime) <= 2100 then
- dr := not Odd((p.FMegaRulez[MR_SUIT]-gTime) div 300)
- else
- dr := True;
-
- if dr then
- e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1,
- 0, 96, 0, 200, TBlending.None);
- end;
-
- // При взятии берсерка рисуется красноватый фон
- if (p.Berserk >= 0) and (LongWord(p.Berserk) >= gTime) and (gFlash = 2) then
- begin
- e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1,
- 255, 0, 0, 200, TBlending.None);
- end;
-end;
-
-procedure r_Player_DrawPain (p: TPlayer);
-var
- a, h: Integer;
-begin
- if p.Pain = 0 then Exit;
-
- a := p.Pain;
-
- if a < 15 then h := 0
- else if a < 35 then h := 1
- else if a < 55 then h := 2
- else if a < 75 then h := 3
- else if a < 95 then h := 4
- else h := 5;
-
- //if a > 255 then a := 255;
-
- e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 255, 0, 0, 255-h*50);
- //e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 255-min(128, a), 255-a, 255-a, 0, B_FILTER);
-end;
-
-procedure r_Player_DrawPickup (p: TPlayer);
-var
- a, h: Integer;
-begin
- if p.Pickup = 0 then Exit;
-
- a := p.Pickup;
-
- if a < 15 then h := 1
- else if a < 35 then h := 2
- else if a < 55 then h := 3
- else if a < 75 then h := 4
- else h := 5;
-
- e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 150, 200, 150, 255-h*50);
-end;
-
-end.
diff --git a/src/game/opengl/r_playermodel.pas b/src/game/opengl/r_playermodel.pas
+++ /dev/null
@@ -1,434 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_playermodel;
-
-interface
-
- uses g_playermodel, g_base; // TPlayerModel, TRectWH
-
- procedure r_PlayerModel_Initialize;
- procedure r_PlayerModel_Finalize;
- procedure r_PlayerModel_Load;
- procedure r_PlayerModel_Free;
- procedure r_PlayerModel_Update;
- procedure r_PlayerModel_Draw (pm: TPlayerModel; X, Y: Integer; Alpha: Byte = 0);
-
- {$IFDEF ENABLE_GIBS}
- procedure r_PlayerModel_DrawGibs;
- function r_PlayerModel_GetGibRect (m, id: Integer): TRectWH;
- {$ENDIF}
-
-implementation
-
- uses
- {$IFDEF ENABLE_GIBS}
- g_gibs,
- {$ENDIF}
- SysUtils, Classes, Math,
- MAPDEF, utils, e_log, wadreader,
- ImagingTypes, Imaging, ImagingUtility,
- r_graphics, g_options, r_animations, r_textures,
- g_basic, g_map, g_weapons, g_animations, g_player, g_phys, g_game
- ;
-
- const
- WeapNames: Array [WP_FIRST + 1..WP_LAST] of String = ('csaw', 'hgun', 'sg', 'ssg', 'mgun', 'rkt', 'plz', 'bfg', 'spl', 'flm');
-
- type
- TDirIdx = TDirection.D_LEFT..TDirection.D_RIGHT;
- TAnimIdx = A_STAND..A_LAST;
-
- var
- WeaponID: Array [WP_FIRST + 1..WP_LAST, W_POS_NORMAL..W_POS_DOWN, W_ACT_NORMAL..W_ACT_FIRE] of DWORD;
- Models: Array of record
- Frames: Array [TDirIdx, TAnimIdx] of record
- base: DWORD;
- mask: DWORD;
- end;
- {$IFDEF ENABLE_GIBS}
- Gibs: Array of record
- base: DWORD;
- mask: DWORD;
- rect: TRectWH;
- end;
- {$ENDIF}
- end;
- RedFlagFrames: DWORD;
- BlueFlagFrames: DWORD;
- FlagAnimState: TAnimState;
-
-{$IFDEF ENABLE_GIBS}
- function r_PlayerModel_GetGibRect (m, id: Integer): TRectWH;
- begin
- Result := Models[m].Gibs[id].rect
- end;
-{$ENDIF}
-
- procedure r_PlayerModel_Initialize;
- begin
- FlagAnimState := TAnimState.Create(True, 8, 5);
- end;
-
- procedure r_PlayerModel_Finalize;
- begin
- FlagAnimState.Invalidate;
- end;
-
- procedure ExtAnimFromBaseAnim(MName: String; AIdx: Integer);
- const
- CopyAnim: array [A_LASTBASE+1..A_LASTEXT] of Integer = (
- A_WALK, A_WALK, A_WALK, A_WALK, A_WALK,
- A_STAND, A_WALK, A_ATTACK, A_WALK, A_SEEUP, A_SEEDOWN,
- A_ATTACKUP, A_ATTACKDOWN
- );
- var
- OIdx: Integer;
- AName, OName: String;
- begin
- // HACK: shitty workaround to duplicate base animations
- // in place of extended, replace with something better later
-
- Assert((AIdx > A_LASTBASE) and (AIdx <= A_LASTEXT));
- OIdx := CopyAnim[AIdx];
-
- AName := MName + '_RIGHTANIM' + IntToStr(AIdx);
- OName := MName + '_RIGHTANIM' + IntToStr(OIdx);
- Assert(g_Frames_Dup(AName, OName));
- Assert(g_Frames_Dup(AName + '_MASK', OName + '_MASK'));
- AName := MName + '_LEFTANIM' + IntToStr(AIdx);
- OName := MName + '_LEFTANIM' + IntToStr(OIdx);
- if g_Frames_Exists(AName) then
- begin
- g_Frames_Dup(AName, OName);
- g_Frames_Dup(AName + '_MASK', OName + '_MASK');
- end;
- end;
-
- procedure r_PlayerModel_LoadResource (resource: AnsiString; var pData: Pointer; var len: Integer);
- var WAD: TWADFile;
- begin
- pData := nil;
- len := 0;
- WAD := TWADFile.Create;
- WAD.ReadFile(g_ExtractWadName(resource));
- WAD.GetResource(g_ExtractFilePathName(resource), pData, len);
- WAD.Free;
- end;
-
- function g_PlayerModel_CalcGibSize (pData: Pointer; dataSize, x, y, w, h: Integer): TRectWH;
- var i, j: Integer; done: Boolean; img: TImageData;
-
- function IsVoid (i, j: Integer): Boolean;
- begin
- result := Byte((PByte(img.bits) + (y+j)*img.width*4 + (x+i)*4 + 3)^) = 0
- end;
-
- begin
- InitImage(img);
- assert(LoadImageFromMemory(pData, dataSize, img));
-
- (* trace x from right to left *)
- done := false; i := 0;
- while not done and (i < w) do
- begin
- j := 0;
- while (j < h) and IsVoid(i, j) do inc(j);
- done := (j < h) and (IsVoid(i, j) = false);
- result.x := i;
- inc(i);
- end;
-
- (* trace y from up to down *)
- done := false; j := 0;
- while not done and (j < h) do
- begin
- i := 0;
- while (i < w) and IsVoid(i, j) do inc(i);
- done := (i < w) and (IsVoid(i, j) = false);
- result.y := j;
- inc(j);
- end;
-
- (* trace x from right to left *)
- done := false; i := w - 1;
- while not done and (i >= 0) do
- begin
- j := 0;
- while (j < h) and IsVoid(i, j) do inc(j);
- done := (j < h) and (IsVoid(i, j) = false);
- result.width := i - result.x + 1;
- dec(i);
- end;
-
- (* trace y from down to up *)
- done := false; j := h - 1;
- while not done and (j >= 0) do
- begin
- i := 0;
- while (i < w) and IsVoid(i, j) do inc(i);
- done := (i < w) and (IsVoid(i, j) = false);
- result.height := j - result.y + 1;
- dec(j);
- end;
-
- FreeImage(img);
- end;
-
- procedure r_PlayerModel_Load;
- {$IFDEF ENABLE_GIBS}
- var base, mask: Pointer; baseLen, maskLen: Integer;
- {$ENDIF}
- var ID1, ID2: DWORD; i, a, b: Integer; prefix, aname: String;
- begin
- g_Frames_CreateWAD(@RedFlagFrames, 'FRAMES_FLAG_RED', GameWAD + ':TEXTURES\FLAGRED', 64, 64, 5, False);
- g_Frames_CreateWAD(@BlueFlagFrames, 'FRAMES_FLAG_BLUE', GameWAD + ':TEXTURES\FLAGBLUE', 64, 64, 5, False);
- for a := WP_FIRST + 1 to WP_LAST do
- begin
- g_Texture_CreateWAD(WeaponID[a][W_POS_NORMAL][W_ACT_NORMAL], GameWAD+':WEAPONS\'+UpperCase(WeapNames[a]));
- g_Texture_CreateWAD(WeaponID[a][W_POS_NORMAL][W_ACT_FIRE], GameWAD+':WEAPONS\'+UpperCase(WeapNames[a])+'_FIRE');
- g_Texture_CreateWAD(WeaponID[a][W_POS_UP][W_ACT_NORMAL], GameWAD+':WEAPONS\'+UpperCase(WeapNames[a])+'_UP');
- g_Texture_CreateWAD(WeaponID[a][W_POS_UP][W_ACT_FIRE], GameWAD+':WEAPONS\'+UpperCase(WeapNames[a])+'_UP_FIRE');
- g_Texture_CreateWAD(WeaponID[a][W_POS_DOWN][W_ACT_NORMAL], GameWAD+':WEAPONS\'+UpperCase(WeapNames[a])+'_DN');
- g_Texture_CreateWAD(WeaponID[a][W_POS_DOWN][W_ACT_FIRE], GameWAD+':WEAPONS\'+UpperCase(WeapNames[a])+'_DN_FIRE');
- end;
- Models := nil;
- if PlayerModelsArray <> nil then
- begin
- SetLength(Models, Length(PlayerModelsArray));
- for i := 0 to High(PlayerModelsArray) do
- begin
- prefix := PlayerModelsArray[i].FileName + ':TEXTURES\';
- for b := A_STAND to A_LAST do
- begin
- aname := PlayerModelsArray[i].Name + '_RIGHTANIM' + IntToStr(b);
- with PlayerModelsArray[i].Anim[TDirection.D_RIGHT, b] do
- begin
- if not (g_Frames_CreateWAD(@ID1, aname, prefix + Resource, 64, 64, Frames, Back) and
- g_Frames_CreateWAD(@ID2, aname + '_MASK', prefix + Mask, 64, 64, Frames, Back)) then
- begin
- if b > A_LASTBASE then
- begin
- ExtAnimFromBaseAnim(PlayerModelsArray[i].Name, b);
- continue
- end
- end;
- Models[i].Frames[TDirection.D_RIGHT, b].base := ID1;
- Models[i].Frames[TDirection.D_RIGHT, b].mask := ID2;
- end;
- with PlayerModelsArray[i].Anim[TDirection.D_LEFT, b] do
- begin
- if (Resource <> '') and (Mask <> '') then
- begin
- aname := PlayerModelsArray[i].Name + '_LEFTANIM' + IntToStr(b);
- g_Frames_CreateWAD(@ID1, aname, prefix + Resource, 64, 64, Frames, Back);
- g_Frames_CreateWAD(@ID2, aname + '_MASK', prefix + Mask, 64, 64, Frames, Back);
- Models[i].Frames[TDirection.D_LEFT, b].base := ID1;
- Models[i].Frames[TDirection.D_LEFT, b].mask := ID2;
- end
- end
- end;
- {$IFDEF ENABLE_GIBS}
- SetLength(Models[i].Gibs, PlayerModelsArray[i].GibsCount);
- if PlayerModelsArray[i].GibsCount > 0 then
- begin
- r_PlayerModel_LoadResource(prefix + PlayerModelsArray[i].GibsResource, base, baseLen);
- r_PlayerModel_LoadResource(prefix + PlayerModelsArray[i].GibsMask, mask, maskLen);
- if (base <> nil) and (mask <> nil) then
- begin
- for a := 0 to PlayerModelsArray[i].GibsCount - 1 do
- begin
- if e_CreateTextureMemEx(base, baseLen, Models[i].Gibs[a].base, a * 32, 0, 32, 32) and
- e_CreateTextureMemEx(mask, maskLen, Models[i].Gibs[a].mask, a * 32, 0, 32, 32) then
- begin
- Models[i].Gibs[a].rect := g_PlayerModel_CalcGibSize(base, baseLen, a * 32, 0, 32, 32);
- with Models[i].Gibs[a].Rect do
- if Height > 3 then
- Height := Height - 1 - Random(2); // ???
- end
- end
- end;
- FreeMem(mask);
- FreeMem(base);
- end
- {$ENDIF}
- end
- end
- end;
-
- procedure r_PlayerModel_Free;
- var i, a, b, c: Integer;
- begin
- e_DeleteTexture(RedFlagFrames);
- e_DeleteTexture(BlueFlagFrames);
- if PlayerModelsArray = nil then Exit;
- for i := 0 to High(PlayerModelsArray) do
- begin
- with PlayerModelsArray[i] do
- begin
- for a := A_STAND to A_LAST do
- begin
- g_Frames_DeleteByName(Name + '_LEFTANIM' + IntToStr(a));
- g_Frames_DeleteByName(Name + '_LEFTANIM' + IntToStr(a) + '_MASK');
- g_Frames_DeleteByName(Name + '_RIGHTANIM' + IntToStr(a));
- g_Frames_DeleteByName(Name + '_RIGHTANIM' + IntToStr(a) + '_MASK');
- end;
- end
- // !!! delete gibs textures here
- end;
- for a := WP_FIRST + 1 to WP_LAST do
- for b := W_POS_NORMAL to W_POS_DOWN do
- for c := W_ACT_NORMAL to W_ACT_FIRE do
- e_DeleteTexture(WeaponID[a][b][c])
- end;
-
- procedure r_PlayerModel_Update;
- begin
- FlagAnimState.Update
- end;
-
-procedure r_PlayerModel_Draw (pm: TPlayerModel; X, Y: Integer; Alpha: Byte = 0);
-var
- Mirror: TMirrorType;
- pos, act: Byte;
- fp, p: TDFPoint;
- FramesID: DWORD;
- fa: Integer;
-begin
-// Флаги:
- if pm.Direction = TDirection.D_LEFT then
- Mirror := TMirrorType.None
- else
- Mirror := TMirrorType.Horizontal;
-
- FramesID := 0;
- case pm.Flag of
- FLAG_RED: FramesID := RedFlagFrames;
- FLAG_BLUE: FramesID := BlueFlagFrames;
- end;
- if (FramesID <> 0) and (not (pm.CurrentAnimation in [A_DIE1, A_DIE2])) then
- begin
- fp := PlayerModelsArray[pm.id].FlagPoint;
- fa := PlayerModelsArray[pm.id].FlagAngle;
- p.X := IfThen(pm.Direction = TDirection.D_LEFT, FLAG_BASEPOINT.X, 64 - FLAG_BASEPOINT.X);
- p.Y := FLAG_BASEPOINT.Y;
- r_AnimState_DrawEx(
- FramesID,
- FlagAnimState,
- X + IfThen(pm.Direction = TDirection.D_LEFT, fp.X - 1, 2 * FLAG_BASEPOINT.X - fp.X + 1) - FLAG_BASEPOINT.X,
- Y + fp.Y - FLAG_BASEPOINT.Y + 1,
- 0,
- Mirror,
- False,
- p,
- IfThen(pm.Direction = TDirection.D_RIGHT, fa, -fa)
- );
- end;
-
-// Оружие:
- if pm.Direction = TDirection.D_RIGHT then
- Mirror := TMirrorType.None
- else
- Mirror := TMirrorType.Horizontal;
-
- if PlayerModelsArray[pm.id].HaveWeapon and (not (pm.CurrentAnimation in [A_DIE1, A_DIE2, A_PAIN])) and (pm.CurrentWeapon in [WP_FIRST + 1..WP_LAST]) then
- begin
- if pm.CurrentAnimation in [A_SEEUP, A_ATTACKUP] then
- pos := W_POS_UP
- else
- if pm.CurrentAnimation in [A_SEEDOWN, A_ATTACKDOWN] then
- pos := W_POS_DOWN
- else
- pos := W_POS_NORMAL;
-
- if (pm.CurrentAnimation in [A_ATTACK, A_ATTACKUP, A_ATTACKDOWN]) or pm.GetFire() then
- act := W_ACT_FIRE
- else
- act := W_ACT_NORMAL;
-
- if Alpha < 201 then
- e_Draw(
- WeaponID[pm.CurrentWeapon][pos][act],
- X + PlayerModelsArray[pm.id].WeaponPoints[pm.CurrentWeapon, pm.CurrentAnimation, pm.Direction, pm.AnimState.CurrentFrame].X,
- Y + PlayerModelsArray[pm.id].WeaponPoints[pm.CurrentWeapon, pm.CurrentAnimation, pm.Direction, pm.AnimState.CurrentFrame].Y,
- 0,
- True,
- False,
- Mirror
- );
- end;
-
-// Модель:
- if (pm.Direction = TDirection.D_LEFT) and (Models[pm.id].Frames[TDirection.D_LEFT, pm.CurrentAnimation].base <> 0) then
- begin
- FramesID := Models[pm.id].Frames[TDirection.D_LEFT, pm.CurrentAnimation].base;
- r_AnimState_Draw(FramesID, pm.AnimState, X, Y, Alpha, TMirrorType.None, False);
- end
- else
- begin
- FramesID := Models[pm.id].Frames[TDirection.D_RIGHT, pm.CurrentAnimation].base;
- r_AnimState_Draw(FramesID, pm.AnimState, X, Y, Alpha, Mirror, False);
- end;
-
-// Маска модели:
- e_Colors := pm.Color;
-
- if (pm.Direction = TDirection.D_LEFT) and (Models[pm.id].Frames[TDirection.D_LEFT, pm.CurrentAnimation].mask <> 0) then
- begin
- FramesID := Models[pm.id].Frames[TDirection.D_LEFT, pm.CurrentAnimation].mask;
- r_AnimState_Draw(FramesID, pm.AnimState, X, Y, Alpha, TMirrorType.None, False);
- end
- else
- begin
- FramesID := Models[pm.id].Frames[TDirection.D_RIGHT, pm.CurrentAnimation].mask;
- r_AnimState_Draw(FramesID, pm.AnimState, X, Y, Alpha, Mirror, False);
- end;
-
- e_Colors.R := 255;
- e_Colors.G := 255;
- e_Colors.B := 255;
-end;
-
-{$IFDEF ENABLE_GIBS}
- procedure r_PlayerModel_DrawGibs;
- var i, fX, fY, m, id: Integer; a: TDFPoint; pobj: ^TObj;
- begin
- if gGibs <> nil then
- begin
- for i := 0 to High(gGibs) do
- begin
- if gGibs[i].alive then
- begin
- pobj := @gGibs[i].Obj;
- if not g_Obj_Collide(sX, sY, sWidth, sHeight, pobj) then
- Continue;
- pobj.lerp(gLerpFactor, fX, fY);
- a.X := pobj.Rect.X + (pobj.Rect.Width div 2);
- a.y := pobj.Rect.Y + (pobj.Rect.Height div 2);
- m := gGibs[i].ModelID;
- id := gGibs[i].GibID;
- e_DrawAdv(Models[m].Gibs[id].base, fX, fY, 0, True, False, gGibs[i].RAngle, @a, TMirrorType.None);
- e_Colors := gGibs[i].Color;
- e_DrawAdv(Models[m].Gibs[id].mask, fX, fY, 0, True, False, gGibs[i].RAngle, @a, TMirrorType.None);
- e_Colors.R := 255;
- e_Colors.G := 255;
- e_Colors.B := 255;
- end
- end
- end
- end;
-{$ENDIF}
-
-end.
diff --git a/src/game/opengl/r_render.pas b/src/game/opengl/r_render.pas
+++ /dev/null
@@ -1,405 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_render;
-
-interface
-
- uses
- {$IFDEF ENABLE_MENU}
- g_gui,
- {$ENDIF}
- g_base // TRectWH
- ;
-
- procedure r_Render_Initialize;
- procedure r_Render_Finalize;
-
- procedure r_Render_Load;
- procedure r_Render_Free;
-
- procedure r_Render_LoadTextures;
- procedure r_Render_FreeTextures;
-
- procedure r_Render_Update;
- procedure r_Render_Draw;
-
- procedure r_Render_Resize (w, h: Integer);
- procedure r_Render_Apply;
-
- function r_Render_WriteScreenShot (filename: String): Boolean;
-
- {$IFDEF ENABLE_GIBS}
- function r_Render_GetGibRect (m, id: Integer): TRectWH;
- {$ENDIF}
-
- {$IFDEF ENABLE_GFX}
- procedure r_Render_QueueEffect (AnimType, X, Y: Integer);
- {$ENDIF}
-
- {$IFDEF ENABLE_TOUCH}
- // touch screen button location and size
- procedure r_Render_GetKeyRect (key: Integer; out x, y, w, h: Integer; out founded: Boolean);
- {$ENDIF}
-
- {$IFDEF ENABLE_MENU}
- procedure r_Render_GetControlSize (ctrl: TGUIControl; out w, h: Integer);
- procedure r_Render_GetLogoSize (out w, h: Integer);
- procedure r_Render_GetMaxFontSize (BigFont: Boolean; out w, h: Integer);
- procedure r_Render_GetStringSize (BigFont: Boolean; str: String; out w, h: Integer);
- {$ENDIF}
-
- procedure r_Render_DrawLoading (force: Boolean); // !!! remove it
-
-implementation
-
- uses
- {$INCLUDE ../../nogl/noGLuses.inc}
- {$IFDEF ENABLE_TOUCH}
- r_touch,
- {$ENDIF}
- {$IFDEF ENABLE_GFX}
- r_gfx,
- {$ENDIF}
- {$IFDEF ENABLE_SYSTEM}
- g_system,
- {$ENDIF}
- {$IFDEF ENABLE_MENU}
- r_gui,
- {$ENDIF}
- SysUtils, Classes, Math,
- e_log, utils,
- g_game, g_options, g_console,
- r_window, r_graphics, r_console, r_playermodel, r_textures, r_animations,
- r_weapons, r_items, r_monsters, r_map, r_player, r_game
- ;
-
- var
- LoadedGL: Boolean = false;
-
- function GLExtensionList (): SSArray;
- var s: PChar; i, j, num: GLint;
- begin
- result := nil;
- s := glGetString(GL_EXTENSIONS);
- if s <> nil then
- begin
- num := 0;
- i := 0;
- j := 0;
- while (s[i] <> #0) and (s[i] = ' ') do Inc(i);
- while (s[i] <> #0) do
- begin
- while (s[i] <> #0) and (s[i] <> ' ') do Inc(i);
- SetLength(result, num+1);
- result[num] := Copy(s, j+1, i-j);
- while (s[i] <> #0) and (s[i] = ' ') do Inc(i);
- j := i;
- Inc(num)
- end
- end
- end;
-
- function GLExtensionSupported (ext: AnsiString): Boolean;
- var e: AnsiString;
- begin
- {$IFDEF NOGL_INIT}
- Result := nogl_ExtensionSupported(ext);
- {$ELSE}
- result := false;
- for e in GLExtensionList() do
- begin
- if strEquCI1251(e, ext) then
- begin
- result := true;
- exit
- end
- end
- {$ENDIF}
- end;
-
- function HaveNPOTSupport (): Boolean;
- begin
- Result := GLExtensionSupported('GL_ARB_texture_non_power_of_two') or
- GLExtensionSupported('GL_OES_texture_npot')
- end;
-
- function HaveFBOSupport (): Boolean;
- begin
- Result := GLExtensionSupported('GL_ARB_framebuffer_object') or
- GLExtensionSupported('GL_OES_framebuffer_object')
- end;
-
- procedure PrintGLSupportedExtensions;
- begin
- e_LogWritefln('GL Vendor: %s', [glGetString(GL_VENDOR)]);
- e_LogWritefln('GL Renderer: %s', [glGetString(GL_RENDERER)]);
- e_LogWritefln('GL Version: %s', [glGetString(GL_VERSION)]);
- e_LogWritefln('GL Shaders: %s', [glGetString(GL_SHADING_LANGUAGE_VERSION)]);
- e_LogWritefln('GL Extensions: %s', [glGetString(GL_EXTENSIONS)]);
- end;
-
- procedure r_Window_Initialize;
- begin
-{$IFNDEF USE_SYSSTUB}
- PrintGLSupportedExtensions;
- glLegacyNPOT := not HaveNPOTSupport();
-{$ELSE}
- glLegacyNPOT := False;
- glRenderToFBO := False;
-{$ENDIF}
- if glNPOTOverride and glLegacyNPOT then
- begin
- glLegacyNPOT := true;
- e_logWriteln('NPOT texture emulation: FORCED')
- end
- else
- begin
- if glLegacyNPOT then
- e_logWriteln('NPOT texture emulation: enabled')
- else
- e_logWriteln('NPOT texture emulation: disabled')
- end
- end;
-
- procedure LoadGL;
- var fboload: Boolean;
- begin
- if LoadedGL = false then
- begin
- {$IFDEF NOGL_INIT}
- nogl_Init;
- {$ENDIF}
- if glRenderToFBO then
- begin
- fboload := True;
- {$IFDEF NOGL_INIT}
- fboload := True; // !!! but if not?
- {$ELSE}
- fboload := Load_GL_ARB_framebuffer_object();
- {$ENDIF}
- if (fboload = False) or (HaveFBOSupport() = False) or (HaveNPOTSupport() = False) then
- begin
- e_LogWriteln('GL: framebuffer objects not supported; disabling FBO rendering');
- glRenderToFBO := false
- end;
- end;
- LoadedGL := true
- end
- end;
-
- procedure FreeGL;
- begin
- if LoadedGL = true then
- begin
- {$IFDEF NOGL_INIT}
- nogl_Quit;
- {$ENDIF}
- LoadedGL := false
- end
- end;
-
- procedure r_Render_LoadTextures;
- begin
- r_Game_LoadTextures;
- r_Map_LoadTextures;
- end;
-
- procedure r_Render_FreeTextures;
- begin
- r_Map_FreeTextures;
- r_Game_FreeTextures;
- end;
-
- procedure r_Render_Load;
- begin
- r_Game_Load; // load first!
- r_Player_Load;
- r_Map_Load;
- r_PlayerModel_Load;
- r_Monsters_Load;
- r_Weapon_Load;
- r_Items_Load;
- {$IFDEF ENABLE_GFX}
- r_GFX_Load;
- {$ENDIF}
- {$IFDEF ENABLE_MENU}
- r_GUI_Load;
- {$ENDIF}
- end;
-
- procedure r_Render_Free;
- begin
- {$IFDEF ENABLE_MENU}
- r_GUI_Free;
- {$ENDIF}
- {$IFDEF ENABLE_GFX}
- r_GFX_Free;
- {$ENDIF}
- r_Items_Free;
- r_Weapon_Free;
- r_Monsters_Free;
- r_PlayerModel_Free;
- r_Map_Free;
- r_Player_Free;
- r_Game_Free;
- g_Texture_DeleteAll;
- g_Frames_DeleteAll;
- end;
-
- procedure r_Render_Initialize;
- begin
- {$IFDEF ENABLE_SYSTEM}
- if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = False then
- raise Exception.Create('Failed to set videomode on startup.');
- {$ENDIF}
- LoadGL;
- r_Window_Initialize;
- r_Console_Init;
- r_PlayerModel_Initialize;
- r_Map_Initialize;
- end;
-
- procedure r_Render_Finalize;
- begin
- r_Map_Finalize;
- r_PlayerModel_Finalize;
- FreeGL;
- e_ReleaseEngine
- end;
-
- procedure r_Render_Update;
- begin
- {$IFDEF ENABLE_GFX}
- r_GFX_Update;
- {$ENDIF}
- r_Map_Update;
- r_PlayerModel_Update;
- r_Console_Update;
- r_Items_Update;
- end;
-
- procedure r_Render_Draw;
- begin
- r_Game_Draw;
- {$IFDEF ENABLE_TOUCH}
- r_Touch_Draw;
- {$ENDIF}
- end;
-
- procedure r_Render_Resize (w, h: Integer);
- begin
- LoadGL;
- gWinSizeX := w;
- gWinSizeY := h;
- gRC_Width := w;
- gRC_Height := h;
- if glRenderToFBO then
- begin
- // store real window size in gWinSize, downscale resolution now
- w := round(w / r_pixel_scale);
- h := round(h / r_pixel_scale);
- if not e_ResizeFramebuffer(w, h) then
- begin
- e_LogWriteln('GL: could not create framebuffer, falling back to --no-fbo');
- glRenderToFBO := False;
- w := gWinSizeX;
- h := gWinSizeY;
- end;
- end;
- gScreenWidth := w;
- gScreenHeight := h;
- e_ResizeWindow(w, h);
- e_InitGL;
- r_Game_SetupScreenSize;
- end;
-
- procedure r_Render_Apply;
- begin
- {$IFDEF ENABLE_SYSTEM}
- if sys_SetDisplayMode(Max(1, gRC_Width), Max(1, gRC_Height), Max(1, gBPP), gRC_FullScreen, gRC_Maximized) then
- e_LogWriteln('resolution changed')
- else
- e_LogWriteln('resolution not changed');
- sys_EnableVSync(gVSync)
- {$ENDIF}
- end;
-
- function r_Render_WriteScreenShot (filename: String): Boolean;
- var s: TStream;
- begin
- Result := False;
- try
- s := CreateDiskFile(filename);
- try
- e_MakeScreenshot(s, gWinSizeX, gWinSizeX);
- Result := True;
- except
- DeleteFile(filename)
- end;
- s.Free;
- finally
- end
- end;
-
-{$IFDEF ENABLE_GIBS}
- function r_Render_GetGibRect (m, id: Integer): TRectWH;
- begin
- Result := r_PlayerModel_GetGibRect(m, id)
- end;
-{$ENDIF}
-
-{$IFDEF ENABLE_GFX}
- procedure r_Render_QueueEffect (AnimType, X, Y: Integer);
- begin
- r_GFX_OnceAnim(AnimType, X, Y)
- end;
-{$ENDIF}
-
-{$IFDEF ENABLE_TOUCH}
- procedure r_Render_GetKeyRect (key: Integer; out x, y, w, h: Integer; out founded: Boolean);
- begin
- r_Touch_GetKeyRect (key, x, y, w, h, founded)
- end;
-{$ENDIF}
-
-{$IFDEF ENABLE_MENU}
- procedure r_Render_GetControlSize (ctrl: TGUIControl; out w, h: Integer);
- begin
- r_GUI_GetSize(ctrl, w, h)
- end;
-
- procedure r_Render_GetLogoSize (out w, h: Integer);
- begin
- r_GUI_GetLogoSize(w, h)
- end;
-
- procedure r_Render_GetMaxFontSize (BigFont: Boolean; out w, h: Integer);
- begin
- r_GUI_GetMaxFontSize(BigFont, w, h)
- end;
-
- procedure r_Render_GetStringSize (BigFont: Boolean; str: String; out w, h: Integer);
- begin
- r_GUI_GetStringSize(BigFont, str, w, h)
- end;
-{$ENDIF}
-
- procedure r_Render_DrawLoading (force: Boolean);
- begin
- r_Window_DrawLoading(force)
- end;
-
-end.
diff --git a/src/game/opengl/r_texture.pas b/src/game/opengl/r_texture.pas
+++ /dev/null
@@ -1,380 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_texture;
-
-{ This unit provides interface to load 24-bit and 32-bit uncompressed images
- from Truevision Targa (TGA) graphic files, and create OpenGL textures
- from it's data. }
-
-interface
-
-uses
- {$INCLUDE ../nogl/noGLuses.inc}
- SysUtils, e_log, ImagingTypes, Imaging, ImagingUtility;
-
-type
- GLTexture = record
- id: GLuint;
- width, height: Word; // real
- glwidth, glheight: Word; // powerof2
- u, v: Single; // usually 1.0
- fmt: GLuint;
- end;
-
-var
- e_DummyTextures: Boolean = False;
-
-function CreateTexture (var tex: GLTexture; Width, Height, aFormat: Word; pData: Pointer; filter: Boolean = False): Boolean;
-
-// Standard set of images loading functions
-function LoadTexture (Filename: String; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
-function LoadTextureEx (Filename: String; var Texture: GLTexture; fX, fY, fWidth, fHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
-function LoadTextureMem (pData: Pointer; dataSize: LongInt; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
-function LoadTextureMemEx (pData: Pointer; dataSize: LongInt; var Texture: GLTexture; fX, fY, fWidth, fHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
-
-// `img` must be valid!
-function LoadTextureImg (var img: TImageData; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
-
-
-implementation
-
-uses
- Classes, g_options, utils;
-
-
-function AlignP2 (n: Word): Word;
-begin
- Dec(n);
- n := n or (n shr 1);
- n := n or (n shr 2);
- n := n or (n shr 4);
- n := n or (n shr 8);
- n := n or (n shr 16);
- Inc(n);
- Result := n;
-end;
-
-
-// This is auxiliary function that creates OpenGL texture from raw image data
-function CreateTexture (var tex: GLTexture; Width, Height, aFormat: Word; pData: Pointer; filter: Boolean = False): Boolean;
-var
- Texture: GLuint;
- fmt: GLenum;
- //buf: PByte;
- //f, c: Integer;
- TEXTUREFILTER: Integer;
-begin
- tex.width := Width;
- tex.height := Height;
- tex.glwidth := Width;
- tex.glheight := Height;
- tex.u := 1;
- tex.v := 1;
-
- if glLegacyNPOT then
- begin
- tex.glwidth := AlignP2(Width);
- tex.glheight := AlignP2(Height);
- if tex.glwidth <> tex.width then tex.u := (tex.width+0.0)/(tex.glwidth+0.0);
- if tex.glheight <> tex.height then tex.v := (tex.height+0.0)/(tex.glheight+0.0);
- end;
-
- //if (tex.glwidth <> tex.width) or (tex.glheight <> tex.height) then
- // e_WriteLog(Format('NPOT: orig is %ux%u; gl is %ux%u; u=%f; v=%f', [Width, Height, tex.glwidth, tex.glheight, tex.u, tex.v]), MSG_NOTIFY);
-
- if e_DummyTextures then
- begin
- tex.id := GLuint(-1);
- Result := True;
- Exit;
- end;
-
- Texture := 0;
- glGenTextures(1, @Texture);
- tex.id := Texture;
- glBindTexture(GL_TEXTURE_2D, Texture);
-
- if (tex.glwidth <> tex.width) or (tex.glheight <> tex.height) then
- e_WriteLog(Format('NPOT: %u is %ux%u; gl is %ux%u; u=%f; v=%f', [tex.id, Width, Height, tex.glwidth, tex.glheight, tex.u, tex.v]), TMsgType.Notify);
-
- // texture blends with object background
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- // texture does NOT blend with object background
- //glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
-
- {
- Select a filtering type.
- BiLinear filtering produces very good results with little performance impact
-
- GL_NEAREST - Basic texture (grainy looking texture)
- GL_LINEAR - BiLinear filtering
- GL_LINEAR_MIPMAP_NEAREST - Basic mipmapped texture
- GL_LINEAR_MIPMAP_LINEAR - BiLinear Mipmapped texture
- }
-
- if filter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
-
- // for GL_TEXTURE_MAG_FILTER only first two can be used
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TEXTUREFILTER);
- // for GL_TEXTURE_MIN_FILTER all of the above can be used
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TEXTUREFILTER);
-
- // create empty texture
- if aFormat = GL_RGBA then fmt := GL_RGBA else fmt := GL_RGB; // silly, yeah?
- glTexImage2D(GL_TEXTURE_2D, 0, fmt, tex.glwidth, tex.glheight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil);
-
- (*
- GetMem(buf, tex.glwidth*4*tex.glheight);
- try
- FillChar(buf^, tex.glwidth*4*tex.glheight, 255);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, tex.glwidth, tex.glheight, fmt, GL_UNSIGNED_BYTE, buf);
- if (tex.glheight = 128) and (tex.height = 80) then
- begin
- for f := 0 to tex.glheight-1 do
- begin
- for c := 0 to tex.glwidth-1 do
- begin
- buf[f*(tex.glwidth*4)+c*4+0] := 255;
- buf[f*(tex.glwidth*4)+c*4+1] := 127;
- buf[f*(tex.glwidth*4)+c*4+2] := 0;
- end;
- end;
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 82, tex.glwidth, {tex.glheight}1, fmt, GL_UNSIGNED_BYTE, buf);
- end;
- finally
- FreeMem(buf);
- end;
- *)
-
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, Width, Height, fmt, GL_UNSIGNED_BYTE, pData);
- //glTexSubImage2D(GL_TEXTURE_2D, 0, 0, tex.glheight-tex.height, Width, Height, fmt, GL_UNSIGNED_BYTE, pData);
-
- glBindTexture(GL_TEXTURE_2D, 0);
-
- // so driver will really upload the texture (this is *sometimes* required for buggy videodrivers)
- glFlush();
- glFinish();
-
- Result := true;
-end;
-
-// `img` must be valid!
-function LoadTextureImg (var img: TImageData; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
-var
- image, ii: PByte;
- width, height: Integer;
- imageSize: Integer;
- x, y: Integer;
- clr: TColor32Rec;
-begin
- result := false;
- pWidth := 0;
- pHeight := 0;
- if Fmt <> nil then Fmt^ := GL_RGBA; // anyway
-
- if (img.width < 1) or (img.width > 32768) or (img.height < 1) or (img.height > 32768) then
- begin
- e_WriteLog('Error loading texture: invalid image dimensions', TMsgType.Warning);
- exit;
- end;
- //ConvertImage(img, ifA8R8G8B8);
- width := img.width;
- height := img.height;
- pWidth := width;
- pHeight := height;
- imageSize := Width*Height*4;
- GetMem(image, imageSize);
- try
- // it is slow, but i don't care for now
- ii := image;
- for y := height-1 downto 0 do
- begin
- for x := 0 to width-1 do
- begin
- clr := GetPixel32(img, x, y);
- ii^ := clr.r; Inc(ii);
- ii^ := clr.g; Inc(ii);
- ii^ := clr.b; Inc(ii);
- ii^ := clr.a; Inc(ii);
- end;
- end;
- CreateTexture(Texture, width, height, GL_RGBA, image, filter);
- result := true;
- finally
- FreeMem(image);
- end;
-end;
-
-
-function LoadTextureMem (pData: Pointer; dataSize: LongInt; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
-var
- //image, ii: PByte;
- //width, height: Integer;
- //imageSize: Integer;
- img: TImageData;
- //x, y: Integer;
- //clr: TColor32Rec;
-begin
- result := false;
- pWidth := 0;
- pHeight := 0;
- if Fmt <> nil then Fmt^ := GL_RGBA; // anyway
-
- InitImage(img);
- if not LoadImageFromMemory(pData, dataSize, img) then
- begin
- e_WriteLog('Error loading texture: unknown image format', TMsgType.Warning);
- exit;
- end;
- try
- result := LoadTextureImg(img, Texture, pWidth, pHeight, Fmt, filter);
- finally
- FreeImage(img);
- end;
-end;
-
-
-function LoadTextureMemEx (pData: Pointer; dataSize: LongInt; var Texture: GLTexture; fX, fY, fWidth, fHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
-var
- image, ii: PByte;
- //width, height: Integer;
- imageSize: Integer;
- img: TImageData;
- x, y: Integer;
- clr: TColor32Rec;
-begin
- result := false;
- if Fmt <> nil then Fmt^ := GL_RGBA; // anyway
-
- InitImage(img);
- if not LoadImageFromMemory(pData, dataSize, img) then
- begin
- e_WriteLog('Error loading texture: unknown image format', TMsgType.Warning);
- exit;
- end;
- try
- if (img.width < 1) or (img.width > 32768) or (img.height < 1) or (img.height > 32768) then
- begin
- e_WriteLog('Error loading texture: invalid image dimensions', TMsgType.Warning);
- exit;
- end;
- //ConvertImage(img, ifA8R8G8B8);
- if fX > img.width then exit;
- if fY > img.height then exit;
- if fX+fWidth > img.width then exit;
- if fY+fHeight > img.height then exit;
- //writeln('fX=', fX, '; fY=', fY, '; fWidth=', fWidth, '; fHeight=', fHeight);
- imageSize := img.width*img.height*4;
- GetMem(image, imageSize);
- try
- // it is slow, but i don't care for now
- ii := image;
- for y := fY+fHeight-1 downto fY do
- begin
- for x := fX to fX+fWidth-1 do
- begin
- clr := GetPixel32(img, x, y);
- ii^ := clr.r; Inc(ii);
- ii^ := clr.g; Inc(ii);
- ii^ := clr.b; Inc(ii);
- ii^ := clr.a; Inc(ii);
- end;
- end;
- CreateTexture(Texture, fWidth, fHeight, GL_RGBA, image, filter);
- result := true;
- finally
- FreeMem(image);
- end;
- finally
- FreeImage(img);
- end;
-end;
-
-
-function LoadTexture (filename: AnsiString; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
-var
- fs: TStream;
- img: Pointer;
- imageSize: LongInt;
-begin
- result := False;
- pWidth := 0;
- pHeight := 0;
- if Fmt <> nil then Fmt^ := GL_RGBA; // anyway
- fs := nil;
-
- try
- fs := openDiskFileRO(filename);
- except
- fs := nil;
- end;
- if fs = nil then
- begin
- e_WriteLog('Texture "'+filename+'" not found', TMsgType.Warning);
- exit;
- end;
-
- try
- imageSize := fs.size;
- GetMem(img, imageSize);
- try
- fs.readBuffer(img^, imageSize);
- result := LoadTextureMem(img, imageSize, Texture, pWidth, pHeight, Fmt, filter);
- finally
- FreeMem(img);
- end;
- finally
- fs.Free();
- end;
-end;
-
-
-function LoadTextureEx (filename: AnsiString; var Texture: GLTexture; fX, fY, fWidth, fHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
-var
- fs: TStream;
- img: Pointer;
- imageSize: LongInt;
-begin
- result := False;
- if Fmt <> nil then Fmt^ := GL_RGBA; // anyway
- fs := nil;
-
- try
- fs := openDiskFileRO(filename);
- except
- fs := nil;
- end;
- if fs = nil then
- begin
- e_WriteLog('Texture "'+filename+'" not found', TMsgType.Warning);
- exit;
- end;
-
- try
- imageSize := fs.size;
- GetMem(img, imageSize);
- try
- fs.readBuffer(img^, imageSize);
- result := LoadTextureMemEx(img, imageSize, Texture, fX, fY, fWidth, fHeight, Fmt, filter);
- finally
- FreeMem(img);
- end;
- finally
- fs.Free();
- end;
-end;
-
-end.
diff --git a/src/game/opengl/r_textures.pas b/src/game/opengl/r_textures.pas
+++ /dev/null
@@ -1,259 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_textures;
-
-interface
-
- function g_Texture_CreateWAD (var ID: LongWord; const Resource: AnsiString; filterHint: Boolean = False): Boolean;
- function g_Texture_CreateFile (var ID: LongWord; const FileName: AnsiString): Boolean;
- function g_Texture_CreateWADEx (const textureName, Resource: AnsiString; filterHint: Boolean = False): 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;
-
-implementation
-
- uses
- SysUtils, Classes, Math,
- WadReader, utils,
- e_log,
- r_graphics,
- g_language, g_game
- ;
-
- type
- _TTexture = record
- name: AnsiString;
- id: LongWord;
- width, height: Word;
- used: Boolean;
- end;
-
- var
- texturesArray: array of _TTexture = nil;
-
-function allocTextureSlot (): LongWord;
-var
- f: integer;
-begin
- for f := 0 to High(texturesArray) do
- begin
- if (not texturesArray[f].used) then
- begin
- result := f;
- exit;
- end;
- end;
-
- result := Length(texturesArray);
- SetLength(texturesArray, result+64);
- for f := result to High(texturesArray) do
- begin
- with texturesArray[f] do
- begin
- name := '';
- id := 0;
- width := 0;
- height := 0;
- used := false;
- end;
- end;
-end;
-
-function g_Texture_CreateWAD (var ID: LongWord; const Resource: AnsiString; filterHint: Boolean = False): Boolean;
-var
- WAD: TWADFile;
- FileName: AnsiString;
- TextureData: Pointer;
- ResourceLength: Integer;
-begin
- result := false;
- FileName := g_ExtractWadName(Resource);
-
- WAD := TWADFile.Create;
- WAD.ReadFile(FileName);
-
- if WAD.GetResource(g_ExtractFilePathName(Resource), TextureData, ResourceLength) then
- begin
- if e_CreateTextureMem(TextureData, ResourceLength, ID, filterHint) then
- result := true;
- FreeMem(TextureData)
- end
- else
- begin
- e_WriteLog(Format('Error loading texture %s', [Resource]), TMsgType.Warning);
- //e_WriteLog(Format('WAD Reader error: %s', [WAD.GetLastErrorStr]), MSG_WARNING);
- end;
- WAD.Free();
-end;
-
-
-function g_Texture_CreateFile (var ID: LongWord; const FileName: AnsiString): Boolean;
-begin
- result := true;
- if not e_CreateTexture(FileName, ID) then
- begin
- e_WriteLog(Format('Error loading texture %s', [FileName]), TMsgType.Warning);
- result := false;
- end;
-end;
-
-function g_Texture_CreateWADEx (const textureName, Resource: AnsiString; filterHint: Boolean = False): Boolean;
-var
- WAD: TWADFile;
- FileName: AnsiString;
- TextureData: Pointer;
- find_id: LongWord;
- ResourceLength: Integer;
-begin
- FileName := g_ExtractWadName(Resource);
-
- find_id := allocTextureSlot();
-
- WAD := TWADFile.Create;
- WAD.ReadFile(FileName);
-
- if WAD.GetResource(g_ExtractFilePathName(Resource), TextureData, ResourceLength) then
- begin
- result := e_CreateTextureMem(TextureData, ResourceLength, texturesArray[find_id].ID, filterHint);
- if result then
- begin
- e_GetTextureSize(texturesArray[find_id].ID, @texturesArray[find_id].width, @texturesArray[find_id].height);
- texturesArray[find_id].used := true;
- texturesArray[find_id].Name := textureName;
- end;
- FreeMem(TextureData)
- end
- else
- begin
- e_WriteLog(Format('Error loading texture %s', [Resource]), TMsgType.Warning);
- //e_WriteLog(Format('WAD Reader error: %s', [WAD.GetLastErrorStr]), MSG_WARNING);
- result := false;
- end;
- WAD.Free();
-end;
-
-
-function g_Texture_CreateFileEx (const textureName, FileName: AnsiString): Boolean;
-var
- find_id: LongWord;
-begin
- find_id := allocTextureSlot();
- result := e_CreateTexture(FileName, texturesArray[find_id].ID);
- if result then
- begin
- texturesArray[find_id].used := true;
- texturesArray[find_id].Name := textureName;
- e_GetTextureSize(texturesArray[find_id].ID, @texturesArray[find_id].width, @texturesArray[find_id].height);
- end
- else e_WriteLog(Format('Error loading texture %s', [FileName]), TMsgType.Warning);
-end;
-
-
-function g_Texture_Get (const textureName: AnsiString; var id: LongWord): Boolean;
-var
- a: Integer;
-begin
- result := false;
- 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
- id := texturesArray[a].id;
- result := true;
- break;
- end;
- end;
- //if not Result then g_ConsoleAdd('Texture '+TextureName+' not found');
-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;
-begin
- 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
- e_DeleteTexture(texturesArray[a].ID);
- texturesArray[a].used := false;
- texturesArray[a].name := '';
- texturesArray[a].id := 0;
- texturesArray[a].width := 0;
- texturesArray[a].height := 0;
- end;
- end;
-end;
-
-procedure g_Texture_DeleteAll ();
-var
- a: Integer;
-begin
- for a := 0 to High(texturesArray) do
- begin
- if (texturesArray[a].used) then e_DeleteTexture(texturesArray[a].ID);
- end;
- texturesArray := nil;
-end;
-
-end.
diff --git a/src/game/opengl/r_touch.pas b/src/game/opengl/r_touch.pas
+++ /dev/null
@@ -1,184 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_touch;
-
-interface
-
- procedure r_Touch_GetKeyRect (key: Integer; out x, y, w, h: Integer; out founded: Boolean);
- procedure r_Touch_Draw;
-
-implementation
-
- uses
- {$IFDEF USE_SDL2}
- SDL2,
- {$ENDIF}
- SysUtils,
- e_input, g_options, g_system,
- r_game, r_graphics
- ;
-
- function GetKeyName (key: Integer): String;
- begin
- case key of
- VK_SHOWKBD: result := 'KBD';
- VK_HIDEKBD: result := 'KBD';
- VK_LEFT: result := 'LEFT';
- VK_RIGHT: result := 'RIGHT';
- VK_UP: result := 'UP';
- VK_DOWN: result := 'DOWN';
- VK_FIRE: result := 'FIRE';
- VK_OPEN: result := 'OPEN';
- VK_JUMP: result := 'JUMP';
- VK_CHAT: result := 'CHAT';
- VK_ESCAPE: result := 'ESC';
- VK_0: result := '0';
- VK_1: result := '1';
- VK_2: result := '2';
- VK_3: result := '3';
- VK_4: result := '4';
- VK_5: result := '5';
- VK_6: result := '6';
- VK_7: result := '7';
- VK_8: result := '8';
- VK_9: result := '9';
- VK_A: result := '10';
- VK_B: result := '11';
- VK_C: result := '12';
- VK_D: result := '13';
- VK_E: result := '14';
- VK_F: result := '15';
- VK_CONSOLE: result := 'CON';
- VK_STATUS: result := 'STAT';
- VK_TEAM: result := 'TEAM';
- VK_PREV: result := '<PREW';
- VK_NEXT: result := 'NEXT>';
- VK_LSTRAFE: result := '<';
- VK_RSTRAFE: result := '>';
- else
- if (key > 0) and (key < e_MaxInputKeys) then
- result := e_KeyNames[key]
- else
- result := '<' + IntToStr(key) + '>'
- end
- end;
-
- procedure r_Touch_GetKeyRect (key: Integer; out x, y, w, h: Integer; out founded: Boolean);
- var
- sw, sh, sz: Integer;
- dpi: Single;
-
- procedure S (xx, yy, ww, hh: Single);
- begin
- x := Trunc(xx);
- y := Trunc(yy);
- w := Trunc(ww);
- h := Trunc(hh);
- founded := true;
- end;
-
- begin
- founded := false;
- {$IF DEFINED(USE_SDL2) AND NOT DEFINED(SDL2_NODPI)}
- if SDL_GetDisplayDPI(0, @dpi, nil, nil) <> 0 then
- dpi := 96;
- {$ELSE}
- dpi := 96;
- {$ENDIF}
-
- sz := Trunc(g_touch_size * dpi); sw := gWinSizeX; sh := gWinSizeY;
- x := 0; y := Round(sh * g_touch_offset / 100);
- w := sz; h := sz;
-
- if sys_IsTextInputActive() then
- case key of
- VK_HIDEKBD: S(sw - (sz/2), 0, sz / 2, sz / 2);
- end
- else if g_touch_alt then
- case key of
- (* top ------- x ------------------------------- y w ----- h -- *)
- VK_CONSOLE: S(0, 0, sz / 2, sz / 2);
- VK_ESCAPE: S(sw - 1*(sz/2) - 1, 0, sz / 2, sz / 2);
- VK_SHOWKBD: S(sw - 2*(sz/2) - 1, 0, sz / 2, sz / 2);
- VK_CHAT: S(sw / 2 - (sz/2) / 2 - (sz/2) - 1, 0, sz / 2, sz / 2);
- VK_STATUS: S(sw / 2 - (sz/2) / 2 - 1, 0, sz / 2, sz / 2);
- VK_TEAM: S(sw / 2 - (sz/2) / 2 + (sz/2) - 1, 0, sz / 2, sz / 2);
- (* left --- x - y -------------- w - h --- *)
- VK_PREV: S(0, sh - 3.0*sz - 1, sz, sz / 2);
- VK_LEFT: S(0, sh - 2.0*sz - 1, sz, sz * 2);
- VK_RIGHT: S(sz, sh - 2.0*sz - 1, sz, sz * 2);
- (* right - x ------------ y -------------- w - h -- *)
- VK_NEXT: S(sw - 1*sz - 1, sh - 3.0*sz - 1, sz, sz / 2);
- VK_UP: S(sw - 2*sz - 1, sh - 2.0*sz - 1, sz, sz / 2);
- VK_FIRE: S(sw - 2*sz - 1, sh - 1.5*sz - 1, sz, sz);
- VK_DOWN: S(sw - 2*sz - 1, sh - 0.5*sz - 1, sz, sz / 2);
- VK_JUMP: S(sw - 1*sz - 1, sh - 2.0*sz - 1, sz, sz);
- VK_OPEN: S(sw - 1*sz - 1, sh - 1.0*sz - 1, sz, sz);
- end
- else
- case key of
- (* left ----- x ----- y -------------- w ----- h -- *)
- VK_ESCAPE: S(0.0*sz, y - 1*sz - sz/2, sz, sz / 2);
- VK_LSTRAFE: S(0.0*sz, y - 0*sz - sz/2, sz / 2, sz);
- VK_LEFT: S(0.5*sz, y - 0*sz - sz/2, sz, sz);
- VK_RIGHT: S(1.5*sz, y - 0*sz - sz/2, sz, sz);
- VK_RSTRAFE: S(2.5*sz, y - 0*sz - sz/2, sz / 2, sz);
- (* right - x ------------ y --------------- w - h *)
- VK_UP: S(sw - 1*sz - 1, y - 1*sz - sz/2, sz, sz);
- VK_FIRE: S(sw - 1*sz - 1, y - 0*sz - sz/2, sz, sz);
- VK_DOWN: S(sw - 1*sz - 1, y - -1*sz - sz/2, sz, sz);
- VK_NEXT: S(sw - 2*sz - 1, y - 1*sz - sz/2, sz, sz);
- VK_JUMP: S(sw - 2*sz - 1, y - 0*sz - sz/2, sz, sz);
- VK_PREV: S(sw - 3*sz - 1, y - 1*sz - sz/2, sz, sz);
- VK_OPEN: S(sw - 3*sz - 1, y - 0*sz - sz/2, sz, sz);
- (* bottom ---- x -------------------------- y ---------------- w ----- h -- *)
- VK_CHAT: S(sw/2 - sz/4 - 2*(sz/2) - 1, sh - 2*(sz/2) - 1, sz / 2, sz / 2);
- VK_CONSOLE: S(sw/2 - sz/4 - 1*(sz/2) - 1, sh - 2*(sz/2) - 1, sz / 2, sz / 2);
- VK_STATUS: S(sw/2 - sz/4 - 0*(sz/2) - 1, sh - 2*(sz/2) - 1, sz / 2, sz / 2);
- VK_TEAM: S(sw/2 - sz/4 - -1*(sz/2) - 1, sh - 2*(sz/2) - 1, sz / 2, sz / 2);
- VK_SHOWKBD: S(sw/2 - sz/4 - -2*(sz/2) - 1, sh - 2*(sz/2) - 1, sz / 2, sz / 2);
- VK_0: S(sw/2 - sz/4 - 5*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
- VK_1: S(sw/2 - sz/4 - 4*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
- VK_2: S(sw/2 - sz/4 - 3*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
- VK_3: S(sw/2 - sz/4 - 2*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
- VK_4: S(sw/2 - sz/4 - 1*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
- VK_5: S(sw/2 - sz/4 - 0*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
- VK_6: S(sw/2 - sz/4 - -1*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
- VK_7: S(sw/2 - sz/4 - -2*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
- VK_8: S(sw/2 - sz/4 - -3*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
- VK_9: S(sw/2 - sz/4 - -4*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
- VK_A: S(sw/2 - sz/4 - -5*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
- end
- end;
-
- procedure r_Touch_Draw;
- var i, x, y, w, h: Integer; founded: Boolean;
- begin
- if g_touch_enabled then
- begin
- for i := VK_FIRSTKEY to VK_LASTKEY do
- begin
- r_Touch_GetKeyRect(i, x, y, w, h, founded);
- if founded then
- begin
- e_DrawQuad(x, y, x + w, y + h, 0, 255, 0, 31);
- e_TextureFontPrintEx(x, y, GetKeyName(i), gStdFont, 255, 255, 255, 1, True)
- end
- end
- end
- end;
-
-end.
diff --git a/src/game/opengl/r_weapons.pas b/src/game/opengl/r_weapons.pas
+++ /dev/null
@@ -1,173 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_weapons;
-
-interface
-
- procedure r_Weapon_Load;
- procedure r_Weapon_Free;
- procedure r_Weapon_Draw;
-
-implementation
-
- uses
- SysUtils, Classes, Math,
- MAPDEF,
- r_graphics, r_animations, r_textures,
- g_base, g_basic, g_game, g_options,
- g_weapons
- ;
-
- var
- ShotTexture, ShotFrames: array [WEAPON_KASTET..WEAPON_SKEL_FIRE] of DWORD;
-
- procedure r_Weapon_Load;
- begin
- g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD+':TEXTURES\BROCKET');
- g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD+':TEXTURES\BSKELFIRE', 64, 16, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD+':TEXTURES\BBFG', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD+':TEXTURES\BPLASMA', 16, 16, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD+':TEXTURES\BIMPFIRE', 16, 16, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD+':TEXTURES\BBSPFIRE', 16, 16, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD+':TEXTURES\BCACOFIRE', 16, 16, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD+':TEXTURES\BBARONFIRE', 64, 16, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD+':TEXTURES\EROCKET', 128, 128, 6);
- g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD+':TEXTURES\ESKELFIRE', 64, 64, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD+':TEXTURES\EBFG', 128, 128, 6);
- g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD+':TEXTURES\EIMPFIRE', 64, 64, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD+':TEXTURES\BFGHIT', 64, 64, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD+':TEXTURES\FIRE', 64, 128, 8);
- g_Frames_CreateWAD(nil, 'FRAMES_FLAME', GameWAD+':TEXTURES\FLAME', 32, 32, 11);
- g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD+':TEXTURES\EPLASMA', 32, 32, 4, True);
- g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD+':TEXTURES\EBSPFIRE', 32, 32, 5);
- g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD+':TEXTURES\ECACOFIRE', 64, 64, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD+':TEXTURES\EBARONFIRE', 64, 64, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD+':TEXTURES\SMOKE', 32, 32, 10, False);
-
- g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD+':TEXTURES\EBULLET');
- g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD+':TEXTURES\ESHELL');
-
- (* WEAPON_ROCKETLAUNCHER *)
- g_Texture_Get('TEXTURE_WEAPON_ROCKET', ShotTexture[WEAPON_ROCKETLAUNCHER]);
-
- (* WEAPON_PLASMA *)
- g_Frames_Get(ShotFrames[WEAPON_PLASMA], 'FRAMES_WEAPON_PLASMA');
- // Animation := TAnimation.Create(FramesID, True, 5);
-
- (* WEAPON_BFG *)
- g_Frames_Get(ShotFrames[WEAPON_BFG], 'FRAMES_WEAPON_BFG');
- // Animation := TAnimation.Create(FramesID, True, 6);
-
- (* WEAPON_FLAMETHROWER *)
- //g_Frames_Get(ShotTexture[WEAPON_FLAMETHROWER], 'FRAMES_FLAME');
- //g_Frames_Get(ShotFrames[WEAPON_FLAMETHROWER], 'FRAMES_FLAME');
-
- (* WEAPON_IMP_FIRE *)
- g_Frames_Get(ShotFrames[WEAPON_IMP_FIRE], 'FRAMES_WEAPON_IMPFIRE');
- // Animation := TAnimation.Create(FramesID, True, 4);
-
- (* WEAPON_CACO_FIRE *)
- g_Frames_Get(ShotFrames[WEAPON_CACO_FIRE], 'FRAMES_WEAPON_CACOFIRE');
- // Animation := TAnimation.Create(FramesID, True, 4);
-
- (* WEAPON_MANCUB_FIRE *)
- g_Frames_Get(ShotFrames[WEAPON_MANCUB_FIRE], 'FRAMES_WEAPON_MANCUBFIRE');
- // Animation := TAnimation.Create(FramesID, True, 4);
-
- (* WEAPON_BARON_FIRE *)
- g_Frames_Get(ShotFrames[WEAPON_BARON_FIRE], 'FRAMES_WEAPON_BARONFIRE');
- // Animation := TAnimation.Create(FramesID, True, 4);
-
- (* WEAPON_BSP_FIRE *)
- g_Frames_Get(ShotFrames[WEAPON_BSP_FIRE], 'FRAMES_WEAPON_BSPFIRE');
- // Animation := TAnimation.Create(FramesID, True, 4);
-
- (* WEAPON_SKEL_FIRE *)
- g_Frames_Get(ShotFrames[WEAPON_SKEL_FIRE], 'FRAMES_WEAPON_SKELFIRE');
- // Animation := TAnimation.Create(FramesID, True, 5);
- end;
-
- procedure r_Weapon_Free;
- begin
- g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
- g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
- g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
- g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
- g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
- g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
- g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
- g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
- g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
- g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
- g_Frames_DeleteByName('FRAMES_BFGHIT');
- g_Frames_DeleteByName('FRAMES_FIRE');
- g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
- g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
- g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
- g_Frames_DeleteByName('FRAMES_SMOKE');
- g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
- g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
- end;
-
- procedure r_Weapon_Draw;
- var i, fX, fY, xx, yy: Integer; a: SmallInt; p: TDFPoint;
- begin
- if Shots = nil then
- Exit;
-
- for i := 0 to High(Shots) do
- begin
- if Shots[i].ShotType <> 0 then
- begin
- with Shots[i] do
- begin
- if Shots[i].ShotType in [WEAPON_ROCKETLAUNCHER, WEAPON_BARON_FIRE, WEAPON_MANCUB_FIRE, WEAPON_SKEL_FIRE] then
- a := -GetAngle2(Obj.Vel.X, Obj.Vel.Y)
- else
- a := 0;
-
- Obj.lerp(gLerpFactor, fX, fY);
- p.X := Obj.Rect.Width div 2;
- p.Y := Obj.Rect.Height div 2;
-
- if Animation.IsValid() then
- begin
- if Shots[i].ShotType in [WEAPON_BARON_FIRE, WEAPON_MANCUB_FIRE, WEAPON_SKEL_FIRE] then
- r_AnimState_DrawEx(ShotFrames[Shots[i].ShotType], Animation, fX, fY, 0, TMirrorType.None, False, p, a)
- else
- r_AnimState_Draw(ShotFrames[Shots[i].ShotType], Animation, fX, fY, 0, TMirrorType.None, False);
- end
- else if ShotTexture[Shots[i].ShotType] <> 0 then
- begin
- if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) then
- e_DrawAdv(ShotTexture[Shots[i].ShotType], fX, fY, 0, True, False, a, @p, TMirrorType.None)
- else if (Shots[i].ShotType <> WEAPON_FLAMETHROWER) then
- e_Draw(ShotTexture[Shots[i].ShotType], fX, fY, 0, True, False);
- end;
-
- if g_debug_Frames then
- begin
- xx := Obj.X + Obj.Rect.X;
- yy := Obj.Y + Obj.Rect.Y;
- e_DrawQuad(xx, yy, xx + Obj.Rect.Width - 1, yy + Obj.Rect.Height - 1, 0, 255, 0);
- end
- end
- end
- end
- end;
-
-end.
diff --git a/src/game/opengl/r_window.pas b/src/game/opengl/r_window.pas
+++ /dev/null
@@ -1,75 +0,0 @@
-(* Copyright (C) Doom 2D: Forever Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License ONLY.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *)
-{$INCLUDE ../../shared/a_modes.inc}
-unit r_window;
-
-interface
-
- procedure r_Window_DrawLoading (forceUpdate: Boolean);
-
-implementation
-
- uses
- {$INCLUDE ../nogl/noGLuses.inc}
- {$IFDEF ENABLE_SYSTEM}
- g_system,
- {$ENDIF}
- SysUtils, Classes,
- e_log, utils,
- r_graphics, r_game, r_console,
- g_options, g_game, g_console,
- xprofiler
- ;
-
- const
- ProgressUpdateMSecs = 35; //1;//100;
-
- var
- prevLoadingUpdateTime: UInt64;
-
- procedure r_Window_DrawLoading (forceUpdate: Boolean);
- var stt: UInt64;
- begin
- if e_NoGraphics = False then
- begin
- if not forceUpdate then
- begin
- stt := getTimeMilli();
- forceUpdate := (stt < prevLoadingUpdateTime) or (stt-prevLoadingUpdateTime >= ProgressUpdateMSecs);
- end;
-
- if forceUpdate then
- begin
- e_SetRendertarget(True);
- e_SetViewPort(0, 0, gScreenWidth, gScreenHeight);
-
- r_Game_DrawMenuBackground('INTER');
- e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
- r_Game_DrawLoadingStat();
- r_Console_Draw(True);
-
- e_SetRendertarget(False);
- e_SetViewPort(0, 0, gWinSizeX, gWinSizeY);
- e_BlitFramebuffer(gWinSizeX, gWinSizeY);
-
- {$IFDEF ENABLE_SYSTEM}
- sys_Repaint;
- {$ENDIF}
- prevLoadingUpdateTime := getTimeMilli();
- end;
- end;
- end;
-
-end.
index 80783b6d7f82784d21db3a21ab4e1b90d29e7719..e6aa258de895144c6148f43f61a4c59c3b44e06a 100644 (file)
if gShowScore and (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
begin
- (* RED TEAM GOALS *)
+ (* RED TEAM SCORE *)
fw := 0;
if gGameSettings.GameMode = GM_CTF then
begin
end;
r_Common_DrawText(IntToStr(gTeamStat[TEAM_RED].Score), x + w - 16 - fw, y + 240 - 72 - 4, TEAMCOLOR[TEAM_RED].R, TEAMCOLOR[TEAM_RED].G, TEAMCOLOR[TEAM_RED].B, 255, menufont, TBasePoint.BP_RIGHTUP);
- (* BLUE TEAM GOALS *)
+ (* BLUE TEAM SCORE *)
fw := 0;
if gGameSettings.GameMode = GM_CTF then
begin
w3 := cw * 8; (* frags width *)
w2 := cw * 12; (* ping/loss width *)
w1 := w - w2 - w3 - w4; (* name width *)
- tw := w1 - cw * 2 - w2; (* team goals *)
+ tw := w1 - cw * 2 - w2; (* team score *)
if cs.PlayerStat = nil then players := 0 else players := Length(cs.PlayerStat);
yy := y;
if cs.GameMode in [GM_TDM, GM_CTF] then