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

📄 functionconfig.pas

📁 M2server 的功能插件 值得研究 此插件支持最新英雄M2
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit FunctionConfig;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Spin, ComCtrls, EngineAPI, EngineType, Menus, IniFiles;

type
  TFrmFunctionConfig = class(TForm)
    FunctionConfigControl: TPageControl;
    Label14: TLabel;
    TabSheet2: TTabSheet;
    TabSheet3: TTabSheet;
    GroupBox21: TGroupBox;
    ListBoxitemList: TListBox;
    ButtonDisallowDel: TButton;
    ButtonDisallowSave: TButton;
    GroupBox5: TGroupBox;
    ListBoxUserCommand: TListBox;
    Label3: TLabel;
    EditCommandName: TEdit;
    ButtonUserCommandAdd: TButton;
    Label4: TLabel;
    SpinEditCommandIdx: TSpinEdit;
    ButtonUserCommandDel: TButton;
    ButtonUserCommandChg: TButton;
    GroupBox1: TGroupBox;
    ButtonDisallowDrop: TButton;
    ButtonDisallowDeal: TButton;
    ButtonDisallowStorage: TButton;
    ListViewDisallow: TListView;
    ButtonDisallowRepair: TButton;
    ButtonUserCommandSave: TButton;
    ButtonLoadCheckItemList: TButton;
    ButtonLoadUserCommandList: TButton;
    procedure ListBoxUserCommandClick(Sender: TObject);
    procedure ButtonUserCommandAddClick(Sender: TObject);
    procedure ButtonUserCommandDelClick(Sender: TObject);
    procedure ButtonUserCommandChgClick(Sender: TObject);
    procedure ButtonUserCommandSaveClick(Sender: TObject);
    procedure ButtonLoadUserCommandListClick(Sender: TObject);
    procedure ListBoxitemListDblClick(Sender: TObject);
    procedure ListViewDisallowClick(Sender: TObject);
    procedure ButtonDisallowDropClick(Sender: TObject);
    procedure ButtonDisallowDealClick(Sender: TObject);
    procedure ButtonDisallowStorageClick(Sender: TObject);
    procedure ButtonDisallowRepairClick(Sender: TObject);
    procedure ButtonDisallowDelClick(Sender: TObject);
    procedure ButtonDisallowSaveClick(Sender: TObject);
    procedure ButtonLoadCheckItemListClick(Sender: TObject);
  private
    { Private declarations }
    procedure uModValue;
    procedure ModValue;
    procedure RefLoadDisallowStdItems();
    function InCommandListOfName(sCommandName: string): Boolean;
    function InCommandListOfIndex(nIndex: Integer): Boolean;
    function InListBoxitemList(sItemName: string): Boolean;
  public
    { Public declarations }
    procedure Open();
  end;
var
  FrmFunctionConfig: TFrmFunctionConfig;
  boModValued, boOpened: Boolean;
implementation
uses
  PlayUserCmd, PlayUser, PlugShare;
{$R *.dfm}

procedure TFrmFunctionConfig.Open();
var
  I: Integer;
  StdItem: _LPTOSTDITEM;
  List: Classes.TList;
begin
  boOpened := False;
  uModValue();
  ListBoxitemList.Items.Clear;
  ListBoxUserCommand.Items.Clear;
  if TUserEngine_GetStdItemList <> nil then begin
    List := Classes.TList(TUserEngine_GetStdItemList);
    for I := 0 to List.Count - 1 do begin
      StdItem := List.Items[I];
      ListBoxitemList.Items.AddObject(StdItem.szName, TObject(StdItem));
    end;
  end;
  RefLoadDisallowStdItems();
  ListBoxUserCommand.Items.AddStrings(g_UserCmdList);
  FunctionConfigControl.ActivePageIndex := 0;
  boOpened := True;
  ShowModal;
end;

procedure TFrmFunctionConfig.ModValue;
begin
  boModValued := True;
  ButtonUserCommandSave.Enabled := True;
  ButtonDisallowSave.Enabled := True;
end;

procedure TFrmFunctionConfig.uModValue;
begin
  boModValued := False;
  ButtonUserCommandDel.Enabled := False;
  ButtonUserCommandChg.Enabled := False;
  ButtonDisallowDel.Enabled := False;
end;

procedure TFrmFunctionConfig.ListBoxUserCommandClick(Sender: TObject);
begin
  try
    EditCommandName.Text := ListBoxUserCommand.Items.Strings[ListBoxUserCommand.ItemIndex];
    SpinEditCommandIdx.Value := Integer(ListBoxUserCommand.Items.Objects[ListBoxUserCommand.ItemIndex]);
    ButtonUserCommandDel.Enabled := True;
    ButtonUserCommandChg.Enabled := True;
  except
    EditCommandName.Text := '';
    SpinEditCommandIdx.Value := 0;
    ButtonUserCommandDel.Enabled := False;
    ButtonUserCommandChg.Enabled := False;
  end;
end;

function TFrmFunctionConfig.InCommandListOfIndex(nIndex: Integer): Boolean;
var
  I: Integer;
begin
  Result := False;
  for I := 0 to ListBoxUserCommand.Items.Count - 1 do begin
    if nIndex = Integer(ListBoxUserCommand.Items.Objects[I]) then begin
      Result := True;
      Break;
    end;
  end;
end;

function TFrmFunctionConfig.InCommandListOfName(sCommandName: string): Boolean;
var
  I, nCount: Integer;
begin
  Result := False;
  for I := 0 to ListBoxUserCommand.Items.Count - 1 do begin
    if CompareText(sCommandName, ListBoxUserCommand.Items.Strings[I]) = 0 then begin
      Result := True;
      Break;
    end;
  end;
end;

procedure TFrmFunctionConfig.ButtonUserCommandAddClick(Sender: TObject);
var
  sCommandName: string;
  nCommandIndex: Integer;
begin
  sCommandName := Trim(EditCommandName.Text);
  nCommandIndex := SpinEditCommandIdx.Value;
  if sCommandName = '' then begin
    Application.MessageBox('请输入命令!!!', '提示信息', MB_ICONQUESTION);
    Exit;
  end;
  if InCommandListOfName(sCommandName) then begin
    Application.MessageBox('输入的命令已经存在,请选择其他命令!!!', '提示信息', MB_ICONQUESTION);
    Exit;
  end;
  if InCommandListOfIndex(nCommandIndex) then begin
    Application.MessageBox('输入的命令编号已经存在,请选择其他命令编号!!!', '提示信息', MB_ICONQUESTION);
    Exit;
  end;
  ListBoxUserCommand.Items.AddObject(sCommandName, TObject(nCommandIndex));
end;

procedure TFrmFunctionConfig.ButtonUserCommandDelClick(Sender: TObject);
begin
  if Application.MessageBox('是否确认删除此命令?', '确认信息', MB_YESNO + MB_ICONQUESTION) = mrYes then begin
    try
      ListBoxUserCommand.DeleteSelected;
    except
    end;
  end;
end;

procedure TFrmFunctionConfig.ButtonUserCommandChgClick(Sender: TObject);
var
  sCommandName: string;
  nCommandIndex: Integer;
  I, nItemIndex: Integer;
begin
  sCommandName := Trim(EditCommandName.Text);
  nCommandIndex := SpinEditCommandIdx.Value;
  if sCommandName = '' then begin
    Application.MessageBox('请输入命令!!!', '提示信息', MB_ICONQUESTION);
    Exit;
  end;
  if InCommandListOfName(sCommandName) then begin
    Application.MessageBox('你要修改的命令已经存在,请选择其他命令!!!', '提示信息', MB_ICONQUESTION);
    Exit;
  end;
  if InCommandListOfIndex(nCommandIndex) then begin
    Application.MessageBox('你要修改的命令编号已经存在,请选择其他命令编号!!!', '提示信息', MB_ICONQUESTION);
    Exit;
  end;
  nItemIndex := ListBoxUserCommand.ItemIndex;
  try
    ListBoxUserCommand.Items.Strings[nItemIndex] := sCommandName;
    ListBoxUserCommand.Items.Objects[nItemIndex] := TObject(nCommandIndex);
    Application.MessageBox('修改完成!!!', '提示信息', MB_ICONQUESTION);
  except
    Application.MessageBox('修改失败!!!', '提示信息', MB_ICONQUESTION);
  end;
end;

procedure TFrmFunctionConfig.ButtonUserCommandSaveClick(Sender: TObject);
var
  sFileName: string;
  I: Integer;
  sCommandName: string;
  nCommandIndex: Integer;
  SaveList: Classes.TStringList;
begin
  ButtonUserCommandSave.Enabled := False;
  sFileName := '.\UserCmd.txt';
  SaveList := Classes.TStringList.Create;
  SaveList.Add(';引擎插件配置文件');
  SaveList.Add(';命令名称'#9'对应编号');
  for I := 0 to ListBoxUserCommand.Items.Count - 1 do begin
    sCommandName := ListBoxUserCommand.Items.Strings[I];
    nCommandIndex := Integer(ListBoxUserCommand.Items.Objects[I]);
    SaveList.Add(sCommandName + #9 + IntToStr(nCommandIndex));
  end;
  SaveList.SaveToFile(sFileName);
  SaveList.Free;
  Application.MessageBox('保存完成!!!', '提示信息', MB_ICONQUESTION);
  ButtonUserCommandSave.Enabled := True;
end;

procedure TFrmFunctionConfig.ButtonLoadUserCommandListClick(
  Sender: TObject);
begin
  ButtonLoadUserCommandList.Enabled := False;
  LoadUserCmdList();
  ListBoxUserCommand.Items.Clear;
  ListBoxUserCommand.Items.AddStrings(g_UserCmdList);
  Application.MessageBox('重新加载自定义命令列表完成!!!', '提示信息', MB_ICONQUESTION);
  ButtonLoadUserCommandList.Enabled := True;
end;

function TFrmFunctionConfig.InListBoxitemList(sItemName: string): Boolean;
var
  I: Integer;
  ListItem: TListItem;
begin
  Result := False;
  ListViewDisallow.Items.BeginUpdate;
  try
    for I := 0 to ListViewDisallow.Items.Count - 1 do begin
      ListItem := ListViewDisallow.Items.Item[I];
      if CompareText(sItemName, ListItem.Caption) = 0 then begin
        Result := True;
        Break;

⌨️ 快捷键说明

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