index 174769b68f578edcece9a7b3f17964a8328df372..774b352d78cc6dba9605802d877a442c63eb9d52 100644 (file)
interface
- uses r_textures, r_fonts, g_player, g_phys;
+ uses r_textures, r_fonts, g_player, g_phys, g_panel;
type
TBasePoint = (
var
r_Common_ProcessLoadingCallback: TProcedure;
+ procedure r_Common_FreeAndNil (var obj);
+ procedure r_Common_FreeMemAndNil (var p);
+
function r_Common_LoadThis (const name: AnsiString; var here: THereTexture): Boolean;
procedure r_Common_FreeThis (var here: THereTexture);
function r_Common_TimeToStr (t: LongWord): AnsiString;
- procedure r_Common_GetObjectPos (const obj: TObj; out x, y: Integer);
+ procedure r_Common_GetPanelPos (const p: TPanel; out x, y, w, h: Integer);
+ procedure r_Common_GetObjectPos (constref obj: TObj; out x, y: Integer);
procedure r_Common_GetPlayerPos (const p: TPlayer; out x, y: Integer);
procedure r_Common_GetCameraPos (const p: TPlayer; center: Boolean; out x, y: Integer);
function r_Common_GetPosByUID (uid: WORD; out obj: TObj; out x, y: Integer): Boolean;
procedure r_Common_StepLoading (incval: Integer);
procedure r_Common_DrawLoading (force: Boolean);
- function r_Common_LoadTextureFromFile (const filename: AnsiString; log: Boolean = True): TGLTexture;
- function r_Common_LoadTextureMultiFromFile (const filename: AnsiString; log: Boolean = True): TGLMultiTexture;
- function r_Common_LoadTextureMultiFromFileAndInfo (const filename: AnsiString; w, h, count: Integer; log: Boolean = True): TGLMultiTexture;
- function r_Common_LoadTextureMultiTextFromFile (const filename: AnsiString; var txt: TAnimTextInfo; log: Boolean = True): TGLMultiTexture;
- function r_Common_LoadTextureStreamFromFile (const filename: AnsiString; w, h, count, cw: Integer; st: TGLTextureArray; rs: TRectArray; log: Boolean = True): Boolean;
+ function r_Common_LoadTextureFromFile (const filename: AnsiString; hints: TGLHintsSet; log: Boolean = True): TGLTexture;
+ function r_Common_LoadTextureMultiFromFile (const filename: AnsiString; hints: TGLHintsSet; log: Boolean = True): TGLMultiTexture;
+ function r_Common_LoadTextureMultiFromFileAndInfo (const filename: AnsiString; w, h, count: Integer; hints: TGLHintsSet; log: Boolean = True): TGLMultiTexture;
+ function r_Common_LoadTextureMultiTextFromFile (const filename: AnsiString; var txt: TAnimTextInfo; hints: TGLHintsSet; log: Boolean = True): TGLMultiTexture;
+ function r_Common_LoadTextureStreamFromFile (const filename: AnsiString; w, h, count, cw: Integer; st: TGLTextureArray; rs: TRectArray; hints: TGLHintsSet; log: Boolean = True): Boolean;
function r_Common_LoadTextureFontFromFile (const filename: AnsiString; constref f: TFontInfo; font2enc: TConvProc; log: Boolean = true): TGLFont;
procedure r_Common_Load;
var
BackgroundTexture: THereTexture;
- procedure r_Common_GetObjectPos (const obj: TObj; out x, y: Integer);
- var fx, fy: Integer;
+ procedure r_Common_FreeAndNil (var obj);
+ var temp: TObject;
+ begin
+ temp := TObject(obj);
+ Pointer(obj) := nil;
+ if temp <> nil then
+ temp.Free;
+ end;
+
+ procedure r_Common_FreeMemAndNil (var p);
+ var temp: Pointer;
+ begin
+ temp := Pointer(p);
+ Pointer(p) := nil;
+ if temp <> nil then
+ FreeMem(temp)
+ end;
+
+ procedure r_Common_GetPanelPos (const p: TPanel; out x, y, w, h: Integer);
+ begin
+ ASSERT(p <> nil);
+ if p.OldMovingActive then
+ begin
+ x := nlerp(p.oldX, p.x, gLerpFactor);
+ y := nlerp(p.oldY, p.y, gLerpFactor);
+ w := nlerp(p.oldWidth, p.width, gLerpFactor);
+ h := nlerp(p.oldHeight, p.height, gLerpFactor);
+ end
+ else
+ begin
+ x := p.x;
+ y := p.y;
+ w := p.width;
+ h := p.height;
+ end;
+ end;
+
+ procedure r_Common_GetObjectPos (constref obj: TObj; out x, y: Integer);
begin
- obj.Lerp(gLerpFactor, fx, fy);
- x := fx;
- y := fy + obj.slopeUpLeft;
+ x := nlerp(obj.oldx, obj.x, gLerpFactor);
+ y := nlerp(obj.oldy, obj.y, gLerpFactor) + obj.slopeUpLeft;
end;
procedure r_Common_GetPlayerPos (const p: TPlayer; out x, y: Integer);
- var fx, fy, fSlope: Integer;
begin
ASSERT(p <> nil);
- p.obj.Lerp(gLerpFactor, fx, fy);
- fSlope := nlerp(p.SlopeOld, p.obj.slopeUpLeft, gLerpFactor);
- x := fx;
- y := fy + fSlope;
+ x := nlerp(p.obj.oldx, p.obj.x, gLerpFactor);
+ y := nlerp(p.obj.oldy + p.SlopeOld, p.obj.y + p.obj.slopeUpLeft, gLerpFactor);
end;
{$IFDEF ENABLE_CORPSES}
procedure r_Common_FreeThis (var here: THereTexture);
begin
here.name := '';
- if here.id <> nil then
- here.id.Free;
- here.id := nil;
+ r_Common_FreeAndNil(here.id);
end;
function r_Common_LoadThis (const name: AnsiString; var here: THereTexture): Boolean;
if name <> here.name then
r_Common_FreeThis(here);
if (name <> '') and (here.name <> name) then
- here.id := r_Textures_LoadFromFile(name);
+ here.id := r_Textures_LoadFromFile(name, []); // !!!
result := here.id <> nil;
end;
procedure r_Common_DrawBackgroundImage (img: TGLTexture);
- var fw, w, h: LongInt;
+ var fw, w, h: LongInt; OldFilter: Boolean;
begin
if img <> nil then
begin
img := BackgroundTexture.id;
+ OldFilter := img.filter;
+ r_Draw_SetFilter(img, gTextureFilter);
if img.width = img.height then fw := img.width * 4 div 3 else fw := img.width; // 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);
+ r_Draw_SetFilter(img, OldFilter);
end
end;
procedure r_Common_Free;
begin
r_Common_FreeThis(BackgroundTexture);
- menufont.Free;
- smallfont.Free;
- stdfont.Free;
+ FreeAndNil(menufont);
+ FreeAndNil(smallfont);
+ FreeAndNil(stdfont);
end;
(* --------- Loading screen helpers --------- *)
r_Common_DrawLoading(false);
end;
- function r_Common_LoadTextureFromFile (const filename: AnsiString; log: Boolean = True): TGLTexture;
+ function r_Common_LoadTextureFromFile (const filename: AnsiString; hints: TGLHintsSet; log: Boolean = True): TGLTexture;
begin
- result := r_Textures_LoadFromFile(filename, log);
+ result := r_Textures_LoadFromFile(filename, hints, log);
r_Common_StepLoading(1);
end;
- function r_Common_LoadTextureMultiFromFile (const filename: AnsiString; log: Boolean = True): TGLMultiTexture;
+ function r_Common_LoadTextureMultiFromFile (const filename: AnsiString; hints: TGLHintsSet; log: Boolean = True): TGLMultiTexture;
begin
- result := r_Textures_LoadMultiFromFile(filename, log);
+ result := r_Textures_LoadMultiFromFile(filename, hints, log);
r_Common_StepLoading(1);
end;
- function r_Common_LoadTextureMultiFromFileAndInfo (const filename: AnsiString; w, h, count: Integer; log: Boolean = True): TGLMultiTexture;
+ function r_Common_LoadTextureMultiFromFileAndInfo (const filename: AnsiString; w, h, count: Integer; hints: TGLHintsSet; log: Boolean = True): TGLMultiTexture;
begin
- result := r_Textures_LoadMultiFromFileAndInfo(filename, w, h, count, log);
+ result := r_Textures_LoadMultiFromFileAndInfo(filename, w, h, count, hints, log);
r_Common_StepLoading(1);
end;
- function r_Common_LoadTextureMultiTextFromFile (const filename: AnsiString; var txt: TAnimTextInfo; log: Boolean = True): TGLMultiTexture;
+ function r_Common_LoadTextureMultiTextFromFile (const filename: AnsiString; var txt: TAnimTextInfo; hints: TGLHintsSet; log: Boolean = True): TGLMultiTexture;
begin
- result := r_Textures_LoadMultiTextFromFile(filename, txt, log);
+ result := r_Textures_LoadMultiTextFromFile(filename, txt, hints, log);
r_Common_StepLoading(1);
end;
- function r_Common_LoadTextureStreamFromFile (const filename: AnsiString; w, h, count, cw: Integer; st: TGLTextureArray; rs: TRectArray; log: Boolean = True): Boolean;
+ function r_Common_LoadTextureStreamFromFile (const filename: AnsiString; w, h, count, cw: Integer; st: TGLTextureArray; rs: TRectArray; hints: TGLHintsSet; log: Boolean = True): Boolean;
begin
- r_Textures_LoadStreamFromFile(filename, w, h, count, cw, st, rs, log);
+ result := r_Textures_LoadStreamFromFile(filename, w, h, count, cw, st, rs, hints, log);
r_Common_StepLoading(1);
end;