【传奇服务器爱好者】-IGE引擎M2-Plug-In-zPlugOfEngine

avatar
作者
筋斗云
阅读量:6

文章目录

插件开发-zPlugOfEngine

提示:初始化DLL
const
PlugName = ‘网络引擎功能插件 (2016/8/18)’;
LoadPlus = ‘正在加载网络引擎功能插件’;
nFindObj = 5;
nPlugHandle = 6;
type
TMsgProc = procedure(Msg: PChar; nMsgLen: Integer; nMode: Integer); stdcall;
TFindProc = function(sProcName: PChar; nNameLen: Integer): Pointer; stdcall;
TFindObj = function(sObjName: PChar; nNameLen: Integer): TObject; stdcall;
TSetProc = function(ProcAddr: Pointer; ProcName: PChar; nNameLen: Integer): Boolean; stdcall;
TGetFunAddr = function(nIndex: Integer): Pointer; stdcall;
function Init(AppHandle: HWnd; MsgProc: TMsgProc; FindProc: TFindProc; SetProc: TSetProc; GetFunAddr: TGetFunAddr): PChar; stdcall;
//var
//FindObj: TFindObj;
begin
PlugHandle := 0;
MsgProc(LoadPlus, length(LoadPlus), 0);
//FindObj := TFindObj(GetFunAddr(nFindObj));
PlugHandle := PInteger(GetFunAddr(nPlugHandle))^;
InitPlug();
Result := PlugName;
end;

procedure UnInit();
begin
UnInitPlug();
end;

procedure Config(); stdcall;
begin
FrmFunctionConfig := TFrmFunctionConfig.Create(nil);
FrmFunctionConfig.Open();
FrmFunctionConfig.Free;
end;

exports
Init, UnInit, Config;

提示:包含引擎的开发API包
在这里插入图片描述
提示:插件设置界面
在这里插入图片描述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 ListView

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!