unit LoadForm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
Vcl.StdCtrls, Vcl.FileCtrl, System.IniFiles, Vcl.Buttons;
type
TForm1 = class(TForm)
grp_path: TGroupBox;
lbl_serverpath: TLabel;
lbl_clientpath: TLabel;
edt_serverpath: TEdit;
edt_clientpath: TEdit;
btn_selectserverpath: TButton;
btn_selectclientpath: TButton;
grp_cgpath: TGroupBox;
lbl_cgipath: TLabel;
lbl_cggpath: TLabel;
edt_cgipath: TEdit;
edt_cggpath: TEdit;
btn_selectcgipath: TButton;
btn_selectcggpath: TButton;
OpenDialog1: TOpenDialog;
grp_lzpath: TGroupBox;
lbl_lzipath: TLabel;
lbl_lzgpath: TLabel;
edt_lzipath: TEdit;
edt_lzgpath: TEdit;
btn_selectlzipath: TButton;
btn_selectlzgpath: TButton;
btn1: TButton;
procedure FormCreate(Sender: TObject);
procedure btn_selectserverpathClick(Sender: TObject);
procedure btn_selectclientpathClick(Sender: TObject);
procedure btn_selectcgipathClick(Sender: TObject);
procedure btn_selectcggpathClick(Sender: TObject);
procedure btn_selectlzipathClick(Sender: TObject);
procedure btn_selectlzgpathClick(Sender: TObject);
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
const
SERVER_TXTS: array[0..17] of string = ('npc', 'itemset', 'enemy', 'enemybase', 'enemyai', 'enemytalk', 'group', 'encount', 'dungeonconf', 'jobs', 'skill', 'skilllv', 'tech', 'itemmaterial', 'itemrecipe', 'techarea', 'titlename', 'titleconfig');
CLIENT_BINS: array[0..3] of string = ('GraphicInfo_66', 'Graphic_66', 'GraphicEx_5', 'GraphicInfoEx_5');
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
var
conf: TIniFile;
begin
if (Form1.edt_serverpath.Text <> '') and (Form1.edt_clientpath.Text <> '') and (Form1.edt_cgipath.Text <> '') and (Form1.edt_cggpath.Text <> '') and (Form1.edt_lzipath.Text <> '') and (Form1.edt_lzgpath.Text <> '') then
begin
// 实例化一个inifile对象
conf := Tinifile.Create('.\config.ini');
// 写配置项目
conf.WriteString('Base', 'Server', Form1.edt_serverpath.Text);
conf.WriteString('Base', 'Client', Form1.edt_clientpath.Text);
conf.WriteString('Bin', 'CGI', Form1.edt_cgipath.Text);
conf.WriteString('Bin', 'CGG', Form1.edt_cggpath.Text);
conf.WriteString('Bin', 'LZI', Form1.edt_lzipath.Text);
conf.WriteString('Bin', 'LZG', Form1.edt_lzgpath.Text);
// 释放
conf.Free;
end
else
begin
Application.MessageBox(PWideChar('为了更好的体验,请先对程序进行配置!'), '出错了:', 48);
end;
;
end;
procedure TForm1.btn_selectcggpathClick(Sender: TObject);
begin
if Form1.OpenDialog1.Execute then
begin
Form1.edt_cggpath.text := ExtractFileName(Form1.OpenDialog1.FileName);
end;
end;
procedure TForm1.btn_selectcgipathClick(Sender: TObject);
begin
if Form1.OpenDialog1.Execute then
begin
Form1.edt_cgipath.text := ExtractFileName(Form1.OpenDialog1.FileName);
end;
end;
procedure TForm1.btn_selectclientpathClick(Sender: TObject);
var
filePath: string;
index: Integer;
begin
// 选择客户端文件夹路径
if selectdirectory('请选择你的客户端bin路径:', '', filePath) then
begin
// 补齐文件夹路径末尾
if filePath[Length(filePath)] <> '\' then
filePath := filePath + '\';
// 判断服务端文件是否齐全,【注意】:后期可以写成公共函数来调用
for index := 0 to 3 do
begin
if not FileExists(filePath + CLIENT_BINS[index] + '.bin') then
begin
Application.MessageBox(PWideChar('未发现' + CLIENT_BINS[index] + '.bin,客户端不完整!'), '出错了:', 48);
Exit;
end;
end;
// 显示选择的文件夹路径
Form1.edt_clientpath.Text := filePath;
end;
end;
procedure TForm1.btn_selectlzgpathClick(Sender: TObject);
begin
if Form1.OpenDialog1.Execute then
begin
Form1.edt_lzgpath.text := ExtractFileName(Form1.OpenDialog1.FileName);
end;
end;
procedure TForm1.btn_selectlzipathClick(Sender: TObject);
begin
if Form1.OpenDialog1.Execute then
begin
Form1.edt_lzipath.text := ExtractFileName(Form1.OpenDialog1.FileName);
end;
end;
procedure TForm1.btn_selectserverpathClick(Sender: TObject);
var
filePath: string;
index: Integer;
begin
// 选择服务端文件夹路径
if selectdirectory('请选择你的服务端data路径:', '', filePath) then
begin
// 补齐文件夹路径末尾
if filePath[Length(filePath)] <> '\' then
filePath := filePath + '\';
// 判断服务端文件是否齐全,【注意】:后期可以写成公共函数来调用
for index := 0 to 17 do
begin
if not FileExists(filePath + SERVER_TXTS[index] + '.txt') then
begin
Application.MessageBox(PWideChar('未发现' + SERVER_TXTS[index] + '.txt,服务端不完整!'), '出错了:', 48);
Exit;
end;
end;
// 显示选择的文件夹路径
Form1.edt_serverpath.Text := filePath;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ShowMessage('我先加载了哦');
end;
end.
最近刚自学的DELPHI,实操一下,涉及[变量,常量,函数,写配置项]
发布时间 2024-01-05 11:07:16作者: 三十三自学编程