index 9c6b8b420ff0052207db872a45f3dae8b494dbbb..331988249b287a83355b7df4e07a522875e6ef15 100644 (file)
var
r_Common_ProcessLoadingCallback: TProcedure;
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_LoadThis (const name: AnsiString; var here: THereTexture): Boolean;
procedure r_Common_FreeThis (var here: THereTexture);
procedure r_Common_StepLoading (incval: Integer);
procedure r_Common_DrawLoading (force: 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_LoadTextureFontFromFile (const filename: AnsiString; constref f: TFontInfo; skipch: Integer; log: Boolean = true): TGLFont;
+ 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;
procedure r_Common_Free;
procedure r_Common_Load;
procedure r_Common_Free;
var
BackgroundTexture: THereTexture;
var
BackgroundTexture: THereTexture;
+ 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_GetObjectPos (const obj: TObj; out x, y: Integer);
var fx, fy: Integer;
begin
procedure r_Common_GetObjectPos (const obj: TObj; out x, y: Integer);
var fx, fy: Integer;
begin
procedure r_Common_FreeThis (var here: THereTexture);
begin
here.name := '';
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;
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
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;
result := here.id <> nil;
r_Common_DrawBackgroundImage(BackgroundTexture.id)
end;
r_Common_DrawBackgroundImage(BackgroundTexture.id)
end;
+ function r_Common_Std2Win (i: Integer): Integer;
+ begin
+ case i of
+ 0..223: result := i + 32;
+ 224..255: result := i - 224;
+ otherwise result := -1;
+ end
+ end;
+
function r_Common_LoadFont (const name: AnsiString): TGLFont;
function r_Common_LoadFont (const name: AnsiString): TGLFont;
- var info: TFontInfo; skiphack: Integer;
+ var info: TFontInfo; p: TConvProc;
begin
result := nil;
begin
result := nil;
- if name = 'STD' then skiphack := 144 else skiphack := 0;
+ if name = 'STD' then p := @r_Common_Std2Win else p := nil;
if r_Font_LoadInfoFromFile(GameWad + ':FONTS/' + name + 'TXT', info) then
if r_Font_LoadInfoFromFile(GameWad + ':FONTS/' + name + 'TXT', info) then
- result := r_Common_LoadTextureFontFromFile(GameWad + ':FONTS/' + name + 'FONT', info, skiphack, true);
+ result := r_Common_LoadTextureFontFromFile(GameWad + ':FONTS/' + name + 'FONT', info, p, true);
if result = nil then
e_logwritefln('failed to load font %s', [name]);
end;
if result = nil then
e_logwritefln('failed to load font %s', [name]);
end;
procedure r_Common_Free;
begin
r_Common_FreeThis(BackgroundTexture);
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 --------- *)
end;
(* --------- Loading screen helpers --------- *)
r_Common_DrawLoading(false);
end;
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
begin
- result := r_Textures_LoadFromFile(filename, log);
+ result := r_Textures_LoadFromFile(filename, hints, log);
r_Common_StepLoading(1);
end;
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
begin
- result := r_Textures_LoadMultiFromFile(filename, log);
+ result := r_Textures_LoadMultiFromFile(filename, hints, log);
r_Common_StepLoading(1);
end;
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
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;
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
begin
- result := r_Textures_LoadMultiTextFromFile(filename, txt, log);
+ result := r_Textures_LoadMultiTextFromFile(filename, txt, hints, log);
r_Common_StepLoading(1);
end;
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
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;
r_Common_StepLoading(1);
end;
- function r_Common_LoadTextureFontFromFile (const filename: AnsiString; constref f: TFontInfo; skipch: Integer; log: Boolean = true): TGLFont;
+ function r_Common_LoadTextureFontFromFile (const filename: AnsiString; constref f: TFontInfo; font2enc: TConvProc; log: Boolean = true): TGLFont;
begin
begin
- result := r_Textures_LoadFontFromFile (filename, f, skipch, log);
+ result := r_Textures_LoadFontFromFile (filename, f, font2enc, log);
r_Common_StepLoading(1);
end;
r_Common_StepLoading(1);
end;