RichEdit, Clipbrd, SsParser, MPlayer, SakuraSeeker,
HeadValue, Logs,
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdSLPP20,
- IdException, HttpThread, IdHTTP, IdURI, DirectSstp, XPMan, LogDownload;
+ IdException, HttpThread, IdHTTP, IdURI, DirectSstp, XPMan, LogDownload,
+ ScriptConsts;
type
TfrmSender = class(TForm)
procedure UpdateJoinChannelList(Dat: THeadValue);
procedure NoLuidError;
procedure UpdateIfGhostBox;
+ procedure BuildMenu(Root: TMenuItem; Event: TNotifyEvent);
public
function GetChannelPrefs(const ChannelName: String): TChannelPrefs;
function DoTrans(var Script: String;
procedure TfrmSender.FormCreate(Sender: TObject);
begin
+ ScriptConstList.LoadFromDir(ExtractFileDir(Application.ExeName)+'\consts');
+ Notified;
+
FOriginalCaption := Self.Caption;
FMutex := OpenMutex(MUTEX_ALL_ACCESS, false, 'SSTPBottleClient2');
mnGotoVote.Hint := Pref.VotePage;
mnGotoHelp.Hint := Pref.HelpPage;
-
mnGetNewId.Enabled := (Pref.LUID = '');
try
Bottom := Self.Top + Self.Height - 1;
end;
- ReleaseMutex(FMutex);
-
if FChannelList <> nil then begin
FChannelList.Clear;
FChannelList.Free;
if FJoinChannels <> nil then FJoinChannels.Free;
if FJoinChannelsBackup <> nil then FJoinChannelsBackup.Free;
if FCueGhost <> nil then FCueGhost.Free;
+
+ ScriptConstList.Save;
+
+ ReleaseMutex(FMutex);
end;
procedure TfrmSender.FormClose(Sender: TObject; var Action: TCloseAction);
begin
EndConnect;
- frmConstEditor.SaveToFile(ExtractFilePath(Application.ExeName) + 'constlist.txt');
end;
procedure TfrmSender.ApplicationEventsMinimize(Sender: TObject);
procedure TfrmSender.Notified;
begin
- frmConstEditor.BuildMenu(mnPopConst, mnConstClick);
- frmConstEditor.BuildMenu(mnPopUpConst.Items, mnConstClick);
- frmConstEditor.BuildMenu(ConstBarMenu.Items, mnConstClick);
+ BuildMenu(mnPopConst, mnConstClick);
+ BuildMenu(mnPopUpConst.Items, mnConstClick);
+ BuildMenu(ConstBarMenu.Items, mnConstClick);
ConstMenuBar.Menu := nil;
ConstMenuBar.AutoSize := false;
ConstMenuBar.Width := 1000;
end;
end;
+procedure TfrmSender.BuildMenu(Root: TMenuItem; Event: TNotifyEvent);
+var i, j, k: integer;
+ ConstData: TScriptConst;
+ Menu1, Menu2: TMenuItem;
+begin
+ for i := Root.Count-1 downto 0 do begin
+ if Root.Items[i].Tag >= 0 then begin
+ Root.Items[i].Free;
+ end;
+ end;
+ for i := 0 to ScriptConstList.Count-1 do begin
+ for j := 0 to ScriptConstList[i].Count-1 do begin
+ Menu1 := TMenuItem.Create(Root);
+ Menu1.Caption := ScriptConstList[i][j].Caption;
+ Menu1.Hint := ScriptConstList[i][j].Caption;
+ Menu1.AutoHotkeys := maManual;
+ Menu1.Tag := ScriptConstList[i][j].ID;
+ Root.Add(Menu1);
+ Menu1.Enabled := ScriptConstList[i][j].Count > 0;
+ for k := 0 to ScriptConstList[i][j].Count-1 do begin
+ ConstData := ScriptConstList[i][j][k];
+ Menu2 := TMenuItem.Create(Root);
+ Menu2.Caption := ConstData.Caption;
+ Menu2.Hint := ConstData.ConstText;
+ if ConstData.ShortCut <> 0 then Menu2.Hint := Menu2.Hint
+ + ' (' + ShortCutToText(ConstData.ShortCut) + ')';
+ Menu2.ShortCut := ConstData.ShortCut;
+ Menu2.OnClick := Event;
+ Menu2.AutoHotkeys := maManual;
+ Menu2.Tag := ConstData.ID;
+ Menu1.Add(Menu2);
+ end;
+ end;
+ end;
+end;
+
end.
FConstText: String;
FShortCut: TShortCut;
FCaption: String;
+ FID: integer;
procedure SetCaption(const Value: String);
procedure SetConstText(const Value: String);
procedure SetShortCut(const Value: TShortCut);
public
+ constructor Create;
property Caption: String read FCaption write SetCaption;
property ShortCut: TShortCut read FShortCut write SetShortCut;
property ConstText: String read FConstText write SetConstText;
+ property ID: integer read FID;
function ToString: String; // \95¶\8e\9a\97ñ\95\\8c»\82É\95Ï\8a·
procedure FromString(const Str: String); // \93Ç\82Ý\8fo\82µ
procedure Assign(Source: TPersistent); override;
FConsts: TObjectList;
FCaption: String;
FIfGhost: String;
+ FID: integer;
function GetCount: integer;
function GetConsts(Index: integer): TScriptConst;
procedure SetCaption(const Value: String);
public
constructor Create;
destructor Destroy; override;
+ property ID: integer read FID;
property Count: integer read GetCount;
property Consts[Index: integer]: TScriptConst read GetConsts; default;
property Caption: String read FCaption write SetCaption;
property IfGhost: String read FIfGhost write SetIfGhost;
procedure Load(Lines: TStrings);
procedure Save(Lines: TStrings);
+ procedure Delete(const ID: integer);
end;
TScriptConstFile = class(TObject) // \8eq\81BTScriptConstMenu\82Ì\83\8a\83X\83g\81B
property Menus[Index: integer]: TScriptConstMenu read GetMenus; default;
procedure LoadFromFile(LoadFileName: String);
procedure SaveToFile;
+ procedure Delete(const ID: integer);
end;
TScriptConstList = class(TObject) // \90e\81BScriptConstFile\82Ì\83\8a\83X\83g\81B
procedure Save;
property Files[Index: integer]: TScriptConstFile read GetFiles; default;
property Count: integer read GetCount;
+ function GetConstByID(const ID: integer): TScriptConst;
+ function GetMenuByID(const ID: integer): TScriptConstMenu;
+ //procedure MoveUp(const ID: integer);
+ //procedure MoveDown(const ID: integer);
+ procedure Delete(const ID: integer);
end;
+var
+ ScriptConstList: TScriptConstList;
+
implementation
+var OldID: integer; // \92è\8c^\8bå\82Ì\93à\95\94ID\81BTag\82É\93ü\82ê\82é\97p
+
+
// \92P\8f\83\82É\83o\83C\83g\92P\88Ê\82Å\95¶\8e\9a\97ñ\82ð\8c©\82Ä\82¢\82«\95ª\89ð\82·\82é\83\86\81[\83e\83B\83\8a\83e\83B\8aÖ\90\94
function Token(const Str: String; const Delimiter: char;
const Index: integer): String;
FFiles := TObjectList.Create(true);
end;
+procedure TScriptConstList.Delete(const ID: integer);
+var i: integer;
+begin
+ for i := Count-1 downto 0 do begin
+ Files[i].Delete(ID);
+ end;
+end;
+
destructor TScriptConstList.Destroy;
begin
FreeAndNil(FFiles);
inherited;
end;
+function TScriptConstList.GetConstByID(const ID: integer): TScriptConst;
+var i, j, k: integer;
+begin
+ Result := nil;
+ for i := 0 to Count-1 do begin
+ for j := 0 to Files[i].Count-1 do begin
+ for k := 0 to Files[i][j].Count-1 do begin
+ if Files[i][j][k].ID = ID then begin
+ Result := Files[i][j][k];
+ Exit;
+ end;
+ end;
+ end;
+ end;
+end;
+
function TScriptConstList.GetCount: integer;
begin
Result := FFiles.Count;
Result := FFiles[Index] as TScriptConstFile;
end;
+function TScriptConstList.GetMenuByID(const ID: integer): TScriptConstMenu;
+var i, j: integer;
+begin
+ Result := nil;
+ for i := 0 to Count-1 do begin
+ for j := 0 to Files[i].Count-1 do begin
+ if Files[i][j].ID = ID then begin
+ Result := Files[i][j];
+ Exit;
+ end;
+ end;
+ end;
+end;
+
procedure TScriptConstList.LoadFromDir(const Dir: String);
var F: TSearchRec;
i: integer;
end;
end;
+constructor TScriptConst.Create;
+begin
+ // \92è\8c^\8bå\82ÌID\82ð\90¶\90¬\82·\82é
+ // TMenuItem\82ÌTag\82É\93ü\82ê\82é\82±\82Æ\82Å\83\81\83j\83\85\81[\8d\80\96Ú\82ª\8e©\95ª\82É\91Î\89\9e\82·\82éTScriptConst\82ð
+ // \92m\82é\82±\82Æ\82ª\82Å\82«\82é
+ FID := OldID+1;
+ OldID := OldID+1;
+end;
+
procedure TScriptConst.FromString(const Str: String);
begin
if Str[1] <> #9 then
FMenus := TObjectList.Create(true);
end;
+procedure TScriptConstFile.Delete(const ID: integer);
+var i: integer;
+begin
+ for i := FMenus.Count-1 downto 0 do begin
+ Menus[i].Delete(ID); // Item\82ð\8dí\8f\9c(\82µ\82æ\82¤\82Æ\82·\82é)
+ if Menus[i].ID = ID then begin
+ FMenus.Delete(i); // Menu\82ð\8dí\8f\9c
+ Exit;
+ end;
+ end;
+end;
+
destructor TScriptConstFile.Destroy;
begin
FreeAndNil(FMenus);
constructor TScriptConstMenu.Create;
begin
+ FID := OldID + 1;
+ OldID := OldID + 1;
FConsts := TObjectList.Create(true);
end;
+procedure TScriptConstMenu.Delete(const ID: integer);
+var i: integer;
+begin
+ for i := Count-1 downto 0 do begin
+ if Consts[i].ID = ID then FConsts.Delete(i);
+ end;
+end;
+
destructor TScriptConstMenu.Destroy;
begin
FreeAndNil(FConsts);
FIfGhost := Value;
end;
+initialization
+
+ScriptConstList := TScriptConstList.Create;
+OldID := 0;
+
+finalization
+
+ScriptConstList.Free;
+
end.