📄 functionconfig.pas
字号:
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;
TabSheet5: TTabSheet;
GroupBox21: TGroupBox;
ListBoxitemList: TListBox;
ButtonDisallowDel: TButton;
ButtonDisallowSave: TButton;
GroupBox22: TGroupBox;
ListViewMsgFilter: TListView;
GroupBox23: TGroupBox;
Label22: TLabel;
Label23: TLabel;
EditFilterMsg: TEdit;
EditNewMsg: TEdit;
ButtonMsgFilterAdd: TButton;
ButtonMsgFilterDel: TButton;
ButtonMsgFilterSave: TButton;
ButtonMsgFilterChg: 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;
ButtonLoadMsgFilterList: 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);
procedure ListViewMsgFilterClick(Sender: TObject);
procedure ButtonLoadMsgFilterListClick(Sender: TObject);
procedure ButtonMsgFilterSaveClick(Sender: TObject);
procedure ButtonMsgFilterAddClick(Sender: TObject);
procedure ButtonMsgFilterChgClick(Sender: TObject);
procedure ButtonMsgFilterDelClick(Sender: TObject);
private
{ Private declarations }
procedure RefLoadMsgFilterList();
procedure RefLoadDisallowStdItems();
function InCommandListOfName(sCommandName: string): Boolean;
function InCommandListOfIndex(nIndex: Integer): Boolean;
function InListBoxitemList(sItemName: string): Boolean;
function InFilterMsgList(sFilterMsg: string): Boolean;
public
{ Public declarations }
procedure Open();
end;
var
FrmFunctionConfig: TFrmFunctionConfig;
boModValued, boOpened: Boolean;
boButtonDrop: Boolean;
boButtonDeal: Boolean;
boButtonStorage: Boolean;
boButtonRepair: Boolean;
implementation
uses
PlayUserCmd, PlayUser, PlugShare;
{$R *.dfm}
procedure TFrmFunctionConfig.Open();
var
I: Integer;
StdItem: _LPTOSTDITEM;
List: Classes.TList;
begin
boOpened := False;
boModValued := False;
ButtonUserCommandDel.Enabled := False;
ButtonUserCommandChg.Enabled := False;
ButtonDisallowDel.Enabled := False;
ButtonMsgFilterDel.Enabled := False;
ButtonMsgFilterChg.Enabled := False;
ListBoxitemList.Items.Clear;
ListBoxUserCommand.Items.Clear;
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;
RefLoadMsgFilterList();
RefLoadDisallowStdItems();
ListBoxUserCommand.Items.Clear;
ListBoxUserCommand.Items.AddStrings(g_UserCmdList);
boOpened := True;
FunctionConfigControl.ActivePageIndex := 0;
ShowModal;
end;
procedure TFrmFunctionConfig.ListBoxUserCommandClick(Sender: TObject);
var
nItemIndex: Integer;
begin
try
nItemIndex := ListBoxUserCommand.ItemIndex;
EditCommandName.Text := ListBoxUserCommand.Items.Strings[nItemIndex];
SpinEditCommandIdx.Value := Integer(ListBoxUserCommand.Items.Objects[nItemIndex]);
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: 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;
end;
end;
finally
ListViewDisallow.Items.EndUpdate;
end;
end;
procedure TFrmFunctionConfig.ListBoxitemListDblClick(Sender: TObject);
var
ListItem: TListItem;
sItemName: string;
I: Integer;
nItemIndex:Integer;
begin
nItemIndex:=ListBoxitemList.ItemIndex;
try
sItemName := ListBoxitemList.Items.Strings[nItemIndex];
except
sItemName := '';
end;
if (sItemName <> '') then begin
if InListBoxitemList(sItemName) then begin
Application.MessageBox('你要选择的物品已经在禁止物品列表中,请选择其他物品!!!', '提示信息', MB_ICONQUESTION);
Exit;
end;
ListViewDisallow.Items.BeginUpdate;
try
ListItem := ListViewDisallow.Items.Add;
ListItem.Caption := sItemName;
ListItem.SubItems.Add('0');
ListItem.SubItems.Add('0');
ListItem.SubItems.Add('0');
ListItem.SubItems.Add('0');
finally
ListViewDisallow.Items.EndUpdate;
end;
end;
end;
procedure TFrmFunctionConfig.ListViewDisallowClick(Sender: TObject);
var
ListItem: TListItem;
boCanDrop: Boolean;
boCanDeal: Boolean;
boCanStorage: Boolean;
boCanRepair: Boolean;
nItemIndex:Integer;
begin
try
nItemIndex:=ListViewDisallow.ItemIndex;
ListItem := ListViewDisallow.Items.Item[nItemIndex];
boCanDrop := Boolean(StrToInt(ListItem.SubItems.Strings[0]));
boCanDeal := Boolean(StrToInt(ListItem.SubItems.Strings[1]));
boCanStorage := Boolean(StrToInt(ListItem.SubItems.Strings[2]));
boCanRepair := Boolean(StrToInt(ListItem.SubItems.Strings[3]));
ButtonDisallowDrop.Enabled := True;
ButtonDisallowDeal.Enabled := True;
ButtonDisallowStorage.Enabled := True;
ButtonDisallowRepair.Enabled := True;
ButtonDisallowDel.Enabled := True;
if not boCanDrop then begin
ButtonDisallowDrop.Caption := '禁止仍';
boButtonDrop := False;
end else begin
ButtonDisallowDrop.Caption := '允许仍';
boButtonDrop := True;
end;
if not boCanDeal then begin
ButtonDisallowDeal.Caption := '禁止交易';
boButtonDeal := False;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -