summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b874151)
raw | patch | inline | side by side (parent: b874151)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 18 Jul 2022 15:02:34 +0000 (18:02 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 9 Jun 2023 08:54:00 +0000 (11:54 +0300) |
index ba934c5ceedfa4d362c6a564aeb60ecd0c8edc65..61d03439a5423d5c00c2ee77e15a37d984d86183 100644 (file)
uses r_textures;
+ type
+ THereTexture = record
+ name: AnsiString;
+ id: TGLTexture;
+ end;
+
var
stdfont: TGLFont;
smallfont: TGLFont;
menufont: TGLFont;
+ function r_Common_LoadThis (const name: AnsiString; var here: THereTexture): Boolean;
+ procedure r_Common_FreeThis (var here: THereTexture);
+
+ procedure r_Common_CalcAspect (ow, oh, nw, nh: LongInt; horizontal: Boolean; out ww, hh: LongInt);
+
procedure r_Common_Load;
procedure r_Common_Free;
uses e_log, r_fonts, g_options;
+ procedure r_Common_FreeThis (var here: THereTexture);
+ begin
+ here.name := '';
+ if here.id <> nil then
+ here.id.Free;
+ here.id := nil;
+ end;
+
+ function r_Common_LoadThis (const name: AnsiString; var here: THereTexture): Boolean;
+ begin
+ if name <> here.name then
+ r_Common_FreeThis(here);
+ if (name <> '') and (here.name <> name) then
+ here.id := r_Textures_LoadFromFile(name);
+
+ result := here.id <> nil;
+
+ if result then
+ here.name := name;
+ end;
+
+ procedure r_Common_CalcAspect (ow, oh, nw, nh: LongInt; horizontal: Boolean; out ww, hh: LongInt);
+ begin
+ if horizontal then
+ begin
+ ww := nw;
+ hh := nw * oh div ow;
+ end
+ else
+ begin
+ ww := nh * ow div oh;
+ hh := nh;
+ end;
+ end;
+
function r_Common_LoadFont (const name: AnsiString): TGLFont;
var info: TFontInfo; skiphack: Integer;
begin
index 7016db9b17456ed6c7ee0f8587b6b5e257a76b2a..0619108abcd45036b8d861e2141e4572a211dae5 100644 (file)
const
EDIT_CURSORLEN = 10;
- type
- THereTexture = record
- name: AnsiString;
- id: TGLTexture;
- end;
-
var
Box: Array [0..8] of TGLTexture;
MarkerID: array [Boolean] of TGLTexture;
Background: THereTexture;
ImageControl: THereTexture;
- procedure r_GUI_FreeThis (var here: THereTexture);
- begin
- here.name := '';
- if here.id <> nil then
- here.id.Free;
- here.id := nil;
- end;
-
- function r_GUI_LoadThis (const name: AnsiString; var here: THereTexture): Boolean;
- begin
- r_GUI_FreeThis(here);
- if (name <> '') and (here.name <> name) then
- here.id := r_Textures_LoadFromFile(name);
- result := here.id <> nil;
- end;
-
procedure r_GUI_Load;
var i: Integer;
begin
LogoTex.Free;
nopic.Free;
- r_GUI_FreeThis(Background);
- r_GUI_FreeThis(ImageControl);
+ r_Common_FreeThis(Background);
+ r_Common_FreeThis(ImageControl);
end;
procedure r_GUI_GetMaxFontSize (BigFont: Boolean; out w, h: Integer);
begin
pic := nopic;
if ctrl.ImageRes <> '' then
- if r_GUI_LoadThis(ctrl.ImageRes, ImageControl) then
+ if r_Common_LoadThis(ctrl.ImageRes, ImageControl) then
pic := ImageControl.id;
if pic <> nil then
r_Draw_Texture(pic, ctrl.x, ctrl.y, pic.width, pic.height, false, 255, 255, 255, 255, false);
begin
// Here goes code duplication from g_game.pas:DrawMenuBackground()
if win.BackTexture <> '' then
- if r_GUI_LoadThis(win.BackTexture, Background) then
+ if r_Common_LoadThis(win.BackTexture, Background) then
begin
r_Draw_FillRect(0, 0, gScreenWidth - 1, gScreenHeight - 1, 0, 0, 0, 255);
tw := Background.id.width;
index f010f29fff452175c44c0c14922ad7c9de88f642..812fd85cd59c5c7f114309e002d690208f5daf77 100644 (file)
end;
{$ENDIF}
- procedure r_Map_CalcAspect (ow, oh, nw, nh: LongInt; horizontal: Boolean; out ww, hh: LongInt);
- begin
- if horizontal then
- begin
- ww := nw;
- hh := nw * oh div ow;
- end
- else
- begin
- ww := nh * ow div oh;
- hh := nh;
- end;
- end;
-
procedure r_Map_CalcSkyParallax (cx, cy, vw, vh, sw, sh, mw, mh: LongInt; out x, y, w, h: LongInt);
const
factor = 120; (* size ratio between view and sky (120%) *)
begin
msw := vw * factor div 100;
msh := vh * factor div 100;
- r_Map_CalcAspect(sw, sh, msw, msh, (sw / sh) <= (msw / msh), w, h);
+ r_Common_CalcAspect(sw, sh, msw, msh, (sw / sh) <= (msw / msh), w, h);
(* calc x parallax or sky center on speed limit *)
mvw := MAX(1, mw - vw);
index 8b67f060679935e743f31a0bea4daa6c279a2cda..ec08bf13b4c4b2274e8902855850f8d8a462913c 100644 (file)
);
var
- menuBG: TGLTexture;
+ BackgroundTexture: THereTexture;
hud, hudbg: TGLTexture;
hudhp: array [Boolean] of TGLTexture;
i: Integer;
begin
r_Common_Load;
- menuBG := r_Textures_LoadFromFile(GameWAD + ':TEXTURES/TITLE');
+ BackgroundTexture := DEFAULT(THereTexture);
hud := r_Textures_LoadFromFile(GameWAD + ':TEXTURES/HUD');
hudbg := r_Textures_LoadFromFile(GameWAD + ':TEXTURES/HUDBG');
hudhp[false] := r_Textures_LoadFromFile(GameWAD + ':TEXTURES/MED2');
hudhp[false].Free;
hudbg.Free;
hud.Free;
- menuBG.Free;
+ r_Common_FreeThis(BackgroundTexture);
r_Common_Free;
end;
r_Draw_SetRect(l, t, r, b);
end;
+ procedure r_Render_DrawBackgroundImage (img: TGLTexture);
+ var fw, w, h: LongInt;
+ begin
+ if img <> nil then
+ begin
+ img := BackgroundTexture.id;
+ fw := img.width * 4 div 3; // fix aspect 4:3
+ r_Common_CalcAspect(fw, img.height, gScreenWidth, gScreenHeight, false, w, h);
+ r_Draw_Texture(img, gScreenWidth div 2 - w div 2, 0, w, h, false, 255, 255, 255, 255, false);
+ end
+ end;
+
+ procedure r_Render_DrawBackground (const name: AnsiString);
+ begin
+ if r_Common_LoadThis(name, BackgroundTexture) then
+ r_Render_DrawBackgroundImage(BackgroundTexture.id)
+ end;
+
procedure r_Render_Draw;
begin
if gExit = EXIT_QUIT then
//e_LogWritefln('r_render_draw: %sx%s', [gScreenWidth, gScreenHeight]);
- if gGameOn or (gState = STATE_FOLD) then
+ if gGameOn or ((gState in [STATE_FOLD]) and (EndingGameCounter < 255)) then
begin
- // TODO setup player view
// TODO setup sectator mode
// TODO setup player hear point
- // TODO setup player view siz
- // TODO draw player view + setup screen coords
if (gPlayer1 <> nil) and (gPlayer2 <> nil) then
- begin
+ begin
r_Render_DrawPlayerView(0, 0, gScreenWidth, gScreenHeight div 2 - 2, gPlayer1);
r_Render_DrawPlayerView(0, gScreenHeight div 2 + 2, gScreenWidth, gScreenHeight div 2, gPlayer2);
end
if not gGameOn then
begin
case gState of
- STATE_MENU: ; // TODO draw menu bg
- STATE_FOLD: ;
- STATE_INTERCUSTOM: ;
- STATE_INTERSINGLE: ;
- STATE_ENDPIC: ;
- STATE_SLIST: ;
+ STATE_NONE: (* do nothing *) ;
+ STATE_MENU: r_Render_DrawBackground(GameWad + ':TEXTURES/TITLE');
+ STATE_FOLD:
+ begin
+ if EndingGameCounter > 0 then
+ r_Draw_FillRect(0, 0, gScreenWidth - 1, gScreenHeight - 1, 0, 0, 0, MIN(MAX(255 - EndingGameCounter, 0), 255));
+ end;
+ STATE_INTERCUSTOM:
+ begin
+ if gLastMap and (gGameSettings.GameMode = GM_COOP) then
+ if EndPicPath <> '' then
+ r_Render_DrawBackground(EndPicPath)
+ else
+ r_Render_DrawBackground(GameWad + ':TEXTURES/' + _lc[I_TEXTURE_ENDPIC])
+ else
+ r_Render_DrawBackground(GameWad + ':TEXTURES/INTER');
+ // TODO draw custom stata
+ {$IFDEF ENABLE_MENU}
+ if g_ActiveWindow <> nil then
+ r_Draw_FillRect(0, 0, gScreenWidth - 1, gScreenHeight - 1, 0, 0, 0, 105);
+ {$ENDIF}
+ end;
+ STATE_INTERSINGLE, STATE_INTERTEXT, STATE_INTERPIC:
+ begin
+ if EndingGameCounter > 0 then
+ begin
+ r_Draw_FillRect(0, 0, gScreenWidth - 1, gScreenHeight - 1, 0, 0, 0, MIN(MAX(255 - EndingGameCounter, 0), 255));
+ end
+ else
+ begin
+ r_Render_DrawBackground(GameWad + ':TEXTURES/INTER');
+ // TODO darw single stats
+ {$IFDEF ENABLE_MENU}
+ if g_ActiveWindow <> nil then
+ r_Draw_FillRect(0, 0, gScreenWidth - 1, gScreenHeight - 1, 0, 0, 0, 105);
+ {$ENDIF}
+ end;
+ end;
+ STATE_ENDPIC:
+ begin
+ if EndPicPath <> '' then
+ r_Render_DrawBackground(EndPicPath)
+ else
+ r_Render_DrawBackground(GameWad + ':TEXTURES/' + _lc[I_TEXTURE_ENDPIC]);
+ {$IFDEF ENABLE_MENU}
+ if g_ActiveWindow <> nil then
+ r_Draw_FillRect(0, 0, gScreenWidth - 1, gScreenHeight - 1, 0, 0, 0, 105);
+ {$ENDIF}
+ end;
+ STATE_SLIST:
+ begin
+ r_Render_DrawBackground(GameWad + ':TEXTURES/TITLE');
+ r_Draw_FillRect(0, 0, gScreenWidth - 1, gScreenHeight - 1, 0, 0, 0, 105);
+ // TODO draw serverlist
+ end;
end;
end;