-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBotOptionsFormUnit.pas
More file actions
139 lines (116 loc) · 4.4 KB
/
BotOptionsFormUnit.pas
File metadata and controls
139 lines (116 loc) · 4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
unit BotOptionsFormUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, SpTBXItem, SpTBXControls, StdCtrls, SpTBXEditors, TB2Item, Menus,
TntForms, SpTBXSkins;
type
TBotOptionsForm = class(TForm)
SpTBXTitleBar1: TSpTBXTitleBar;
ColorPopupMenu: TSpTBXPopupMenu;
mnuTeamColorPalette: TSpTBXColorPalette;
mnuTeamColorCustomize: TSpTBXItem;
SpTBXSeparatorItem1: TSpTBXSeparatorItem;
mnuTeamColorCancel: TSpTBXItem;
pnlMain: TSpTBXPanel;
gbGameOptions: TSpTBXGroupBox;
lblId: TSpTBXLabel;
BotTeamButton: TSpTBXSpinEdit;
BotSideButton: TSpTBXSpeedButton;
lblTeam: TSpTBXLabel;
BotAllyButton: TSpTBXSpinEdit;
BotTeamColorButton: TSpTBXSpeedButton;
gpOtherOptions: TSpTBXGroupBox;
AIOptionsScrollBox: TTntScrollBox;
procedure FormCreate(Sender: TObject);
procedure CreateParams(var Params: TCreateParams); override;
procedure FormShow(Sender: TObject);
procedure mnuTeamColorCustomizeClick(Sender: TObject);
procedure mnuTeamColorPaletteCellClick(Sender: TObject; ACol,
ARow: Integer; var Allow: Boolean);
procedure BotAllyButtonExit(Sender: TObject);
procedure BotTeamButtonExit(Sender: TObject);
procedure mnuTeamColorPaletteGetColor(Sender: TObject; ACol,
ARow: Integer; var Color: TColor; var Name: WideString);
procedure BotSideButtonClick(Sender: TObject);
private
{ Private declarations }
public
Bot: TObject;
procedure UpdateBot;
end;
var
BotOptionsForm: TBotOptionsForm;
implementation
uses PreferencesFormUnit, MainUnit, BattleFormUnit, Misc;
{$R *.dfm}
procedure TBotOptionsForm.FormCreate(Sender: TObject);
begin
if Preferences.ThemeType = sknSkin then
begin
SpTBXTitleBar1.Active := True;
BorderStyle := bsNone;
BotAllyButton.Color := SkinManager.CurrentSkin.Options(skncEditFrame,sknsNormal).Body.Color1;
BotAllyButton.Font.Color := SkinManager.CurrentSkin.GetTextColor(skncEditFrame,sknsNormal);
BotTeamButton.Color := SkinManager.CurrentSkin.Options(skncEditFrame,sknsNormal).Body.Color1;
BotTeamButton.Font.Color := SkinManager.CurrentSkin.GetTextColor(skncEditFrame,sknsNormal);
AIOptionsScrollBox.Color := PreferencesForm.IfNotClNone(SkinManager.CurrentSkin.Options(skncTabBackground).Body.Color1,clBtnFace);
end;
BotAllyButton.SpinOptions.MaxValue := MAX_TEAMS;
BotTeamButton.SpinOptions.MaxValue := MAX_TEAMS;
end;
procedure TBotOptionsForm.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
if not PreferencesFormUnit.Preferences.TaskbarButtons then Exit;
if Preferences.TaskbarButtons then Self.FormStyle := fsNormal
else Self.FormStyle := fsStayOnTop;
with Params do begin
ExStyle := ExStyle or WS_EX_APPWINDOW;
WndParent := GetDesktopWindow;
end;
end;
procedure TBotOptionsForm.FormShow(Sender: TObject);
begin
MainForm.UpdateColorImageList;
BotTeamColorButton.ImageIndex := Length(TeamColors)*2+1+BattleState.Battle.Bots.IndexOf(Bot);
end;
procedure TBotOptionsForm.mnuTeamColorCustomizeClick(Sender: TObject);
begin
TBot(Bot).SetTeamColor(Misc.InputColor(TBot(Bot).Name+' color',TBot(Bot).TeamColor));
UpdateBot;
end;
procedure TBotOptionsForm.UpdateBot;
begin
MainForm.TryToSendCommand('UPDATEBOT', TBot(Bot).Name + ' ' + IntToStr(TBot(Bot).BattleStatus) + ' ' + IntToStr(TBot(Bot).TeamColor));
end;
procedure TBotOptionsForm.mnuTeamColorPaletteCellClick(Sender: TObject;
ACol, ARow: Integer; var Allow: Boolean);
begin
TBot(Bot).SetTeamColor(TeamColors[ARow*5+ACol]);
UpdateBot;
end;
procedure TBotOptionsForm.BotAllyButtonExit(Sender: TObject);
begin
TBot(Bot).SetAllyNo(BotAllyButton.SpinOptions.ValueAsInteger-1);
UpdateBot;
end;
procedure TBotOptionsForm.BotTeamButtonExit(Sender: TObject);
begin
TBot(Bot).SetTeamNo(BotTeamButton.SpinOptions.ValueAsInteger-1);
UpdateBot;
end;
procedure TBotOptionsForm.mnuTeamColorPaletteGetColor(Sender: TObject;
ACol, ARow: Integer; var Color: TColor; var Name: WideString);
begin
Color := TeamColors[ARow*5+ACol];
end;
procedure TBotOptionsForm.BotSideButtonClick(Sender: TObject);
var
SideIndex: Integer;
begin
SideIndex := BattleForm.ChooseSideDialog(Sender as TControl, TBot(Bot).GetSide);
if SideIndex = -1 then Exit;
TBot(Bot).SetSide(SideIndex);
end;
end.