сохранение records почти доделал вкладку команды, осталось лишь групповые ответы добавить
This commit is contained in:
+166
-62
@@ -3,10 +3,12 @@ unit fCommands;
|
||||
interface
|
||||
|
||||
uses
|
||||
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
|
||||
System.SysUtils, System.Types, System.UITypes, System.Classes,
|
||||
System.Variants,
|
||||
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
|
||||
System.Rtti, FMX.Grid.Style, FMX.Memo.Types, FMX.Grid, FMX.Layouts, uRecords,
|
||||
FMX.ListBox, FMX.Memo, FMX.Edit, FMX.Controls.Presentation, FMX.ScrollBox;
|
||||
FMX.ListBox, FMX.Memo, FMX.Edit, FMX.Controls.Presentation, FMX.ScrollBox,
|
||||
fSimpleGrid, fContruct;
|
||||
|
||||
type
|
||||
TfrCommands = class(TFrame)
|
||||
@@ -14,24 +16,6 @@ type
|
||||
scCommand: TStringColumn;
|
||||
scResponse: TStringColumn;
|
||||
GroupBox1: TGroupBox;
|
||||
Label12: TLabel;
|
||||
edtCommand: TEdit;
|
||||
mResponse: TMemo;
|
||||
Label14: TLabel;
|
||||
GroupBox7: TGroupBox;
|
||||
btnAddUserName: TButton;
|
||||
btnGetDateFollow: TButton;
|
||||
btnGetAgeAccaunt: TButton;
|
||||
btnCounterAddtoText: TButton;
|
||||
cbCounterName: TComboBox;
|
||||
btnGPT: TButton;
|
||||
btnRandomUserName: TButton;
|
||||
btnGetChannelStat: TButton;
|
||||
btnAIPic: TButton;
|
||||
btnAddCommand: TButton;
|
||||
btnEditCommand: TButton;
|
||||
btnRmCommand: TButton;
|
||||
cbTextToSpeech: TCheckBox;
|
||||
GroupBox9: TGroupBox;
|
||||
lbRandomGroup: TListBox;
|
||||
lbRandomRespons: TListBox;
|
||||
@@ -53,43 +37,40 @@ type
|
||||
IntegerColumn1: TIntegerColumn;
|
||||
scRIntTo: TIntegerColumn;
|
||||
GroupBox11: TGroupBox;
|
||||
btnSoundAdd: TButton;
|
||||
btnSoundDel: TButton;
|
||||
edtSoundName: TEdit;
|
||||
edtSoundFileName: TEdit;
|
||||
btnSoundOpen: TButton;
|
||||
tbSoundVolume: TTrackBar;
|
||||
btnSoundTest: TButton;
|
||||
sgSAFiles: TStringGrid;
|
||||
sgSAName: TStringColumn;
|
||||
sgSAFile: TStringColumn;
|
||||
GroupBox24: TGroupBox;
|
||||
btnTextAdd: TButton;
|
||||
btnTextDel: TButton;
|
||||
edtTextName: TEdit;
|
||||
edtTextFileName: TEdit;
|
||||
btnTextOpen: TButton;
|
||||
sgTFiles: TStringGrid;
|
||||
scTFileName: TStringColumn;
|
||||
scTFileFile: TStringColumn;
|
||||
OpenDialog1: TOpenDialog;
|
||||
GroupBox2: TGroupBox;
|
||||
sgAIGen: TStringGrid;
|
||||
StringColumn1: TStringColumn;
|
||||
StringColumn2: TStringColumn;
|
||||
edtAIGenName: TEdit;
|
||||
edtAIGenRequest: TEdit;
|
||||
btnAIGenAdd: TButton;
|
||||
btnAIGenDel: TButton;
|
||||
btnAIGetTextUser: TButton;
|
||||
frsgSounds: TfrSimpleGrid;
|
||||
frsgFiles: TfrSimpleGrid;
|
||||
frsgNeiro: TfrSimpleGrid;
|
||||
frContruct1: TfrContruct;
|
||||
procedure btnRandAddClick(Sender: TObject);
|
||||
procedure btnRandDelClick(Sender: TObject);
|
||||
procedure frsgSoundsbtnSoundDelClick(Sender: TObject);
|
||||
procedure frsgSoundssgCellDblClick(const Column: TColumn;
|
||||
const Row: Integer);
|
||||
procedure frsgFilessgCellDblClick(const Column: TColumn;
|
||||
const Row: Integer);
|
||||
procedure frsgNeirosgCellDblClick(const Column: TColumn;
|
||||
const Row: Integer);
|
||||
procedure frContruct1btnAddCommandClick(Sender: TObject);
|
||||
procedure frContruct1btnEditCommandClick(Sender: TObject);
|
||||
procedure frContruct1btnRmCommandClick(Sender: TObject);
|
||||
procedure sgCommandsCellClick(const Column: TColumn; const Row: Integer);
|
||||
procedure sgRandomIntCellDblClick(const Column: TColumn;
|
||||
const Row: Integer);
|
||||
private
|
||||
{ Private declarations }
|
||||
procedure UpdateGridFromArray;
|
||||
|
||||
public
|
||||
{ Public declarations }
|
||||
RandomCounters: TArray<TRandomCounters>;
|
||||
listSounds: TArray<TListCommands>;
|
||||
listFiles: TArray<TListCommands>;
|
||||
listNeiro: TArray<TListCommands>;
|
||||
listCommands: TArray<TListCommands>;
|
||||
|
||||
procedure UpdateGridFromArray;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@@ -103,16 +84,126 @@ var
|
||||
i, RowIndex: Integer;
|
||||
begin
|
||||
RowIndex := sgRandomInt.Row;
|
||||
if (RowIndex < 0) or (RowIndex > High(RandomCounters)) then Exit;
|
||||
if (RowIndex < 0) or (RowIndex > High(RandomCounters)) then
|
||||
Exit;
|
||||
|
||||
// Ñäâèãàåì ýëåìåíòû ìàññèâà
|
||||
for i := RowIndex to High(RandomCounters)-1 do
|
||||
RandomCounters[i] := RandomCounters[i+1];
|
||||
|
||||
for i := RowIndex to High(RandomCounters) - 1 do
|
||||
RandomCounters[i] := RandomCounters[i + 1];
|
||||
SetLength(RandomCounters, Length(RandomCounters) - 1);
|
||||
UpdateGridFromArray;
|
||||
DB.SaveRecordArray<TRandomCounters>('RandomCounters', RandomCounters);
|
||||
end;
|
||||
|
||||
procedure TfrCommands.frContruct1btnAddCommandClick(Sender: TObject);
|
||||
var
|
||||
sCommand: string;
|
||||
NewRec: TListCommands;
|
||||
begin
|
||||
sCommand := frContruct1.edtCommand.text;
|
||||
if (sCommand = '') or (sCommand = '!') or (frContruct1.mResponse.text = '') then
|
||||
exit;
|
||||
if (sCommand <> '') and (sCommand[1] = '!') then
|
||||
begin
|
||||
Delete(sCommand, 1, 1);
|
||||
end;
|
||||
|
||||
NewRec.R1 := sCommand;
|
||||
NewRec.R2 := frContruct1.mResponse.text;
|
||||
SetLength(listCommands, Length(listCommands) + 1);
|
||||
listCommands[High(listCommands)] := NewRec;
|
||||
UpdateGridFromArray;
|
||||
DB.SaveRecordArray<TListCommands>('listCommands', listCommands);
|
||||
end;
|
||||
|
||||
procedure TfrCommands.frContruct1btnEditCommandClick(Sender: TObject);
|
||||
var RowIndex: integer; sCommand:string;
|
||||
begin
|
||||
RowIndex := sgCommands.Row;
|
||||
|
||||
sCommand := frContruct1.edtCommand.text;
|
||||
if (sCommand = '') or (sCommand = '!') or (frContruct1.mResponse.text = '') then
|
||||
exit;
|
||||
if (sCommand <> '') and (sCommand[1] = '!') then
|
||||
begin
|
||||
Delete(sCommand, 1, 1);
|
||||
end;
|
||||
|
||||
if (RowIndex < 0) or (RowIndex > High(listCommands)) then
|
||||
exit;
|
||||
listCommands[RowIndex].R1 := sCommand;
|
||||
listCommands[RowIndex].R2 := frContruct1.mResponse.text;
|
||||
|
||||
UpdateGridFromArray;
|
||||
DB.SaveGridToTable('sgRandomInt', sgRandomInt);
|
||||
DB.SaveRecordArray<TListCommands>('listCommands', listCommands);
|
||||
end;
|
||||
|
||||
procedure TfrCommands.frContruct1btnRmCommandClick(Sender: TObject);
|
||||
var
|
||||
i, RowIndex: Integer;
|
||||
begin
|
||||
RowIndex := sgCommands.Row;
|
||||
if (RowIndex < 0) or (RowIndex > High(listCommands)) then
|
||||
exit;
|
||||
for i := RowIndex to High(listCommands) - 1 do
|
||||
listCommands[i] := listCommands[i + 1];
|
||||
SetLength(listCommands, Length(listCommands) - 1);
|
||||
UpdateGridFromArray;
|
||||
DB.SaveRecordArray<TListCommands>('listCommands', listCommands);
|
||||
|
||||
end;
|
||||
|
||||
procedure TfrCommands.frsgFilessgCellDblClick(const Column: TColumn;
|
||||
const Row: Integer);
|
||||
begin
|
||||
frContruct1.mResponse.Lines.text := frContruct1.mResponse.Lines.text + ' ' +
|
||||
frsgFiles.Hint + frsgFiles.sg.Cells[0, Row] + frsgFiles.Hint;
|
||||
end;
|
||||
|
||||
procedure TfrCommands.frsgNeirosgCellDblClick(const Column: TColumn;
|
||||
const Row: Integer);
|
||||
begin
|
||||
frContruct1.mResponse.Lines.text := frContruct1.mResponse.Lines.text + ' ' +
|
||||
frsgNeiro.Hint + frsgNeiro.sg.Cells[0, Row] + frsgNeiro.Hint;
|
||||
end;
|
||||
|
||||
procedure TfrCommands.frsgSoundsbtnSoundDelClick(Sender: TObject);
|
||||
var
|
||||
i, RowIndex: Integer;
|
||||
begin
|
||||
RowIndex := frsgSounds.sg.Row;
|
||||
if (RowIndex < 0) or (RowIndex > High(listSounds)) then
|
||||
Exit;
|
||||
|
||||
// Ñäâèãàåì ýëåìåíòû ìàññèâà
|
||||
for i := RowIndex to High(listSounds) - 1 do
|
||||
listSounds[i] := listSounds[i + 1];
|
||||
|
||||
SetLength(listSounds, Length(listSounds) - 1);
|
||||
|
||||
UpdateGridFromArray;
|
||||
DB.SaveRecordArray<TListCommands>('listSounds', listSounds);
|
||||
end;
|
||||
|
||||
procedure TfrCommands.frsgSoundssgCellDblClick(const Column: TColumn;
|
||||
const Row: Integer);
|
||||
begin
|
||||
frContruct1.mResponse.Lines.text := frContruct1.mResponse.Lines.text + ' ' +
|
||||
frsgSounds.Hint + frsgSounds.sg.Cells[0, Row] + frsgSounds.Hint;
|
||||
end;
|
||||
|
||||
procedure TfrCommands.sgCommandsCellClick(const Column: TColumn;
|
||||
const Row: Integer);
|
||||
begin
|
||||
frContruct1.edtCommand.text := sgCommands.Cells[0, Row];
|
||||
frContruct1.mResponse.text := sgCommands.Cells[1, Row];
|
||||
end;
|
||||
|
||||
procedure TfrCommands.sgRandomIntCellDblClick(const Column: TColumn;
|
||||
const Row: Integer);
|
||||
begin
|
||||
frContruct1.mResponse.Lines.text := frContruct1.mResponse.Lines.text + ' [[' + sgRandomInt.Cells
|
||||
[0, Row] + ']]';
|
||||
end;
|
||||
|
||||
procedure TfrCommands.UpdateGridFromArray;
|
||||
@@ -121,37 +212,50 @@ var
|
||||
begin
|
||||
sgRandomInt.BeginUpdate;
|
||||
try
|
||||
sgRandomInt.RowCount := 1; // Ñáðàñûâàåì ñòðîêè (îñòàâëÿåì òîëüêî çàãîëîâêè)
|
||||
sgRandomInt.RowCount := 0; // Ñáðàñûâàåì ñòðîêè (îñòàâëÿåì òîëüêî çàãîëîâêè)
|
||||
|
||||
for i := 0 to High(RandomCounters) do
|
||||
begin
|
||||
sgRandomInt.RowCount := i + 1;
|
||||
sgRandomInt.Cells[0, i] := RandomCounters[i].Name;
|
||||
sgRandomInt.RowCount := i +1;
|
||||
sgRandomInt.Cells[0, i] := RandomCounters[i].rndName;
|
||||
sgRandomInt.Cells[1, i] := IntToStr(RandomCounters[i].Ot);
|
||||
sgRandomInt.Cells[2, i] := IntToStr(RandomCounters[i].ToValue);
|
||||
end;
|
||||
finally
|
||||
sgRandomInt.EndUpdate;
|
||||
end;
|
||||
sgCommands.BeginUpdate;
|
||||
try
|
||||
sgCommands.RowCount := 0; // Ñáðàñûâàåì ñòðîêè (îñòàâëÿåì òîëüêî çàãîëîâêè)
|
||||
|
||||
for i := 0 to High(listCommands) do
|
||||
begin
|
||||
sgCommands.RowCount := i+1 ;
|
||||
sgCommands.Cells[0, i] := listCommands[i].R1;
|
||||
sgCommands.Cells[1, i] := listCommands[i].R2; //9067254178
|
||||
end;
|
||||
finally
|
||||
sgCommands.EndUpdate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrCommands.btnRandAddClick(Sender: TObject);
|
||||
var
|
||||
NewRec: TRandomCounters;
|
||||
begin
|
||||
NewRec.Name := edtRandomName.Text;
|
||||
NewRec.Ot := StrToIntDef(edtOt.Text, 0);
|
||||
NewRec.ToValue := StrToIntDef(edtTo.Text, 100);
|
||||
NewRec.rndName := edtRandomName.text;
|
||||
NewRec.Ot := StrToIntDef(edtOt.text, 0);
|
||||
NewRec.ToValue := StrToIntDef(edtTo.text, 100);
|
||||
|
||||
SetLength(RandomCounters, Length(RandomCounters) + 1);
|
||||
RandomCounters[High(RandomCounters)] := NewRec;
|
||||
|
||||
UpdateGridFromArray;
|
||||
// DB.SaveGridToTable('sgRandomInt', sgRandomInt);
|
||||
// DB.SaveGridToTable('sgRandomInt', sgRandomInt);
|
||||
DB.SaveRecordArray<TRandomCounters>('RandomCounters', RandomCounters);
|
||||
edtRandomName.Text := '';
|
||||
edtOt.Text := '0';
|
||||
edtTo.Text := '100';
|
||||
edtRandomName.text := '';
|
||||
edtOt.text := '0';
|
||||
edtTo.text := '100';
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user