2 SppList - SPP
\83v
\83\89\83O
\83C
\83\93\82ð
\8c\9f\8dõ
\82µ
\82Ä
\95Û
\8e\9d\82·
\82é
9 uses Classes, Windows, SysUtils, Contnrs, Forms, Dialogs,
10 Graphics, ProgressWindow, Plugins;
13 TLoadPluginEventType = (lpPreLoad, lpPostLoad);
14 TLoadPluginEvent = procedure(Sender: TObject;
15 Status: TLoadPluginEventType; Plugin: String) of object;
17 TSppList = class(TObjectList)
19 FImageCache: TObjectList;
20 FOnLoadPlugin: TLoadPluginEvent;
21 function GetSppItem(Index: integer): TSppPlugin;
22 procedure SetOnLoadPlugin(const Value: TLoadPluginEvent);
24 procedure ClearImagePool;
25 constructor Create(OwnsObject: boolean);
26 destructor Destroy; override;
27 procedure LoadFromDirectory(Dir: String);
28 function TryGetImage(const Ghost: String; const Surface: integer;
29 Bitmap: TBitmap): boolean;
30 property SppItem[Index: integer]: TSppPlugin read GetSppItem;
31 property OnLoadPlugin: TLoadPluginEvent read FOnLoadPlugin write SetOnLoadPlugin;
45 procedure TSppList.ClearImagePool;
50 constructor TSppList.Create(OwnsObject: boolean);
52 inherited Create(true);
53 if OwnsObject = false then
54 raise Exception.Create('TSppList.OwnsObject must be set to true');
55 FImageCache := TObjectList.Create;
58 destructor TSppList.Destroy;
64 function TSppList.GetSppItem(Index: integer): TSppPlugin;
66 Result := Items[Index] as TSppPlugin;
69 procedure TSppList.LoadFromDirectory(Dir: String);
73 ProgressWindow: TfrmProgressWindow;
75 Clear; //
\91O
\82É
\93Ç
\82Ý
\8d\9e\82ñ
\82¾
\82Ì
\82Í
\91S
\95\94\8fÁ
\82¦
\82é
77 ProgressWindow := TfrmProgressWindow.Create(nil);
80 i := FindFirst(Dir + '\*.dll', 0, F);
84 if Assigned(FOnLoadPlugin) then
85 FOnLoadPlugin(Self, lpPreLoad, F.Name);
86 ProgressWindow.StatusText := Format('
\83v
\83\89\83O
\83C
\83\93%s
\82ð
\93Ç
\82Ý
\8d\9e\82Ý
\92\86...', [F.Name]);
87 Item := TSppPlugin.Create(Dir + '\' + F.Name);
89 if Assigned(FOnLoadPlugin) then
90 FOnLoadPlugin(Self, lpPostLoad, F.Name);
92 on E: ESppException do
94 ShowMessage('SPP
\83v
\83\89\83O
\83C
\83\93\83\8d\81[
\83h
\8e¸
\94s:'#13#10 + E.Message);
106 procedure TSppList.SetOnLoadPlugin(const Value: TLoadPluginEvent);
108 FOnLoadPlugin := Value;
111 function TSppList.TryGetImage(const Ghost: String; const Surface: integer;
112 Bitmap: TBitmap): boolean;
118 //
\8aù
\82É
\83L
\83\83\83b
\83V
\83\85\8dÏ
\82Ý
\82Ì
\8fê
\8d\87
119 for i := 0 to FImageCache.Count-1 do
121 if (FImageCache[i] as TSppImage).KeyMatchTest(Ghost, Surface, 0) then
123 OutputDebugString(PChar('Cache Used: ' + Ghost + IntToStr(Surface)));
125 Bitmap.Assign((FImageCache[i] as TSppImage).Bitmap);
126 FImageCache.Move(i, 0); //
\90æ
\93ª
\82É
\8e\9d\82Á
\82Ä
\82
\82é
131 // DLL
\82ð
\8eÀ
\8dÛ
\82É
\8cÄ
\82Ñ
\8fo
\82µ
\82Ä
\8c\9f\8dõ
\82·
\82é
132 for i := 0 to Self.Count-1 do
134 SppImage := (Items[i] as TSppPlugin).GetImage(Ghost, Surface, 0);
135 if SppImage <> nil then
138 Bitmap.Assign(SppImage.Bitmap);
142 // DLL
\8cÄ
\82Ñ
\8fo
\82µ
\82Ì
\8c\8b\89Ê
\82ð
\83L
\83\83\83b
\83V
\83\85\82·
\82é
143 if SppImage <> nil then
145 FImageCache.Insert(0, SppImage);
148 SppImage := TSppImage.Create;
149 SppImage.Ghost := Ghost;
150 SppImage.SurfaceKey := IntToStr(Surface) + ',*';
151 FImageCache.Insert(0, SppImage);
154 //
\82 \82Ó
\82ê
\82½
\83L
\83\83\83b
\83V
\83\85\82Ì
\83N
\83\8a\83A
155 if FImageCache.Count > MaxPoolImage then
156 for j := FImageCache.Count-1 downto MaxPoolImage do
157 FImageCache.Delete(j);
162 Spps := TSppList.Create(true);