⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adkiniloader.pas

📁 N年前有个法国小组用Delphi写了一个2D网游(AD&D类型)
💻 PAS
字号:
unit ADKIniLoader;

{
 Gestionnaire de fichier ini pour le projet ADK-ISO (c)2002 Paul TOTH <tothpaul@free.fr>

 http://www.web-synergy.net/naug-land/

}

{
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; either version 2
of the License, or (at your option) any later version.

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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
interface
}

interface

uses
 Windows,Classes,SysUtils,
 ADKSprites;

type
 TAction=(aStand,aWalk,aRun);

 TSprites=class
  Animations:array[TAction] of TADKSprite;
 end;

function GetSprites(AName:string):TSprites;
function StringProperty(Item,Name:string):string;
function IntegerProperty(Item,Name:string):integer;

procedure FreeResources;

implementation

type
 TStringList2=class(TStringList)
 public
  destructor Destroy; override;
 end;

destructor TStringList2.Destroy;
var
 i:integer;
begin
 for i:=0 to Count-1 do Objects[i].Free;
 inherited;
end;

var
 gFileName:string;
 gBasePath:string;
 gSprites :TStringList2;

procedure FreeResources;
begin
 gSprites.Free;
end;

function IntegerProperty(Item,Name:string):integer;
begin
 Result:=StrToInt(StringProperty(Item,Name));
end;

function StringProperty(Item,Name:string):string;
var
 s:string;
begin
 SetLength(s,128);
 SetLength(s,GetPrivateProfileString(PChar(Item),PChar(Name),nil,@s[1],128,PChar(gFileName)));
 result:=s;
end;

function GetSprites(AName:string):TSprites;
var
 i:integer;
 s:string;
begin
 s:=StringProperty('Path','Root')+StringProperty('Path','Sprites');
 i:=gSprites.IndexOf(AName);
 if i<0 then begin
  Result:=TSprites.Create;
  Result.Animations[aStand]:=TADKSprite.Create(s+StringProperty(AName,'Stand'));
  Result.Animations[aWalk]:=TADKSprite.Create(s+StringProperty(AName,'Walk'));
  Result.Animations[aRun]:=TADKSprite.Create(s+StringProperty(AName,'Run'));
  gSprites.AddObject(AName,Result);
 end else begin
  Result:=gSprites.Objects[i] as TSprites;
 end;
end;

initialization
 gFileName:=ChangeFileExt(ParamStr(0),'.INI');
 gBasePath:=ExtractFilePath(gFileName);
 gSprites :=TStringList2.Create;
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -