index 99be37674802e7264d71763af56ebcaee5ec2093..2f7d323eb23977e1e8df2c6891e949cbe942658c 100644 (file)
--- a/src/editor/f_options.pas
+++ b/src/editor/f_options.pas
unit f_options;
-{$MODE Delphi}
+{$INCLUDE ../shared/a_modes.inc}
interface
uses
- LCLIntf, LCLType, LMessages, Messages, SysUtils, Variants, Classes,
+ LCLIntf, LCLType, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls,
- ExtCtrls, ComCtrls, Registry;
+ ExtCtrls, ComCtrls, ActnList, Spin, EditBtn, Registry, Math, Types;
type
TOptionsForm = class (TForm)
bOK: TButton;
bCancel: TButton;
- ColorDialog: TColorDialog;
- GroupBox1: TGroupBox;
- // Общие настройки:
+ cbAllowExit: TCheckBox;
+ cbCheckerboard: TCheckBox;
+ cbLanguage: TComboBox;
+ cbMapOnce: TCheckBox;
+ cbMonstersDM: TCheckBox;
cbShowDots: TCheckBox;
- cbShowTexture: TCheckBox;
cbShowSize: TCheckBox;
- // Шаги сетки:
+ cbShowTexture: TCheckBox;
+ cbTeamDamage: TCheckBox;
+ cbTwoPlayers: TCheckBox;
+ cbWeaponStay: TCheckBox;
+ ColorButton1: TColorButton;
+ ColorButton2: TColorButton;
+ ColorButton3: TColorButton;
+ edD2DArgs: TEdit;
+ edScore: TEdit;
+ edTime: TEdit;
+ ExeEdit: TFileNameEdit;
+ LabelArgs: TLabel;
+ LabelBack: TLabel;
LabelGrid: TLabel;
- eDotStepOne: TEdit;
- UpDown1: TUpDown;
- eDotStepTwo: TEdit;
- UpDown2: TUpDown;
- // Цвет сетки:
LabelGridCol: TLabel;
- sDotColor: TShape;
- bGrid: TButton;
- // Цвет фона:
- LabelBack: TLabel;
- sBackColor: TShape;
- bBack: TButton;
- // Цвет превью:
- LabelPreview: TLabel;
- sPreviewColor: TShape;
- bPreview: TButton;
- // Масштаб миникарты:
+ LabelGridSize: TLabel;
+ LabelLanguage: TLabel;
LabelMinimap: TLabel;
- cbScale: TComboBox;
- // Количество недавно открытых:
+ LabelPath: TLabel;
+ LabelPreview: TLabel;
LabelRecent: TLabel;
- eRecent: TEdit;
- UpDown3: TUpDown;
- LabelLanguage: TLabel;
- rbRussian: TRadioButton;
- rbEnglish: TRadioButton;
- LabelGridSize: TLabel;
- cbDotSize: TComboBox;
-
- procedure bGridClick(Sender: TObject);
- procedure FormActivate(Sender: TObject);
+ LabelScore: TLabel;
+ LabelSecs: TLabel;
+ LabelTime: TLabel;
+ PageControl: TPageControl;
+ rbCOOP: TRadioButton;
+ rbCTF: TRadioButton;
+ rbDM: TRadioButton;
+ rbTDM: TRadioButton;
+ SpinEdit1: TSpinEdit;
+ SpinEdit2: TSpinEdit;
+ SpinEdit3: TSpinEdit;
+ SpinEdit4: TSpinEdit;
+ SpinEdit5: TSpinEdit;
+ TabFiles: TTabSheet;
+ TabGeneral: TTabSheet;
+ TabTesting: TTabSheet;
+
+ procedure FormShow(Sender: TObject);
procedure bOKClick(Sender: TObject);
procedure bCancelClick(Sender: TObject);
- procedure bBackClick(Sender: TObject);
- procedure bPreviewClick(Sender: TObject);
-
- private
- { Private declarations }
- public
- { Public declarations }
+ procedure FormCreate(Sender: TObject);
end;
var
implementation
uses
- f_main, StdConvs, CONFIG, g_language;
+ LazFileUtils, f_main, StdConvs, CONFIG, WADEDITOR, g_language, g_options;
{$R *.lfm}
end;
end;
-procedure TOptionsForm.bGridClick(Sender: TObject);
+procedure TOptionsForm.FormShow(Sender: TObject);
+ var list: TStringList;
begin
- if ColorDialog.Execute then
- sDotColor.Brush.Color := ColorDialog.Color;
-end;
+ // General Tab:
+ ColorButton1.ButtonColor := DotColor;
+ ColorButton2.ButtonColor := BackColor;
+ ColorButton3.ButtonColor := PreviewColor;
+ SpinEdit1.Value := DotStepOne;
+ SpinEdit2.Value := DotStepTwo;
-procedure TOptionsForm.FormActivate(Sender: TObject);
-begin
- sDotColor.Brush.Color := DotColor;
cbShowDots.Checked := DotEnable;
cbShowTexture.Checked := DrawTexturePanel;
cbShowSize.Checked := DrawPanelSize;
- eDotStepOne.Text := IntToStr(DotStepOne);
- eDotStepTwo.Text := IntToStr(DotStepTwo);
- sBackColor.Brush.Color := BackColor;
- sPreviewColor.Brush.Color := PreviewColor;
- if Scale = 2 then
- cbScale.ItemIndex := 1
- else
- cbScale.ItemIndex := 0;
- if DotSize = 2 then
- cbDotSize.ItemIndex := 1
- else
- cbDotSize.ItemIndex := 0;
- eRecent.Text := IntToStr(RecentCount);
-
-// Язык:
- if gLanguage = LANGUAGE_RUSSIAN then
- begin
- rbRussian.Checked := True;
- rbEnglish.Checked := False;
- end
- else
- begin
- rbRussian.Checked := False;
- rbEnglish.Checked := True;
- end;
+ cbCheckerboard.Checked := UseCheckerboard;
+
+ SpinEdit4.Value := DotSize;
+ SpinEdit5.Value := Scale;
+
+ try
+ cbLanguage.Items.BeginUpdate;
+ cbLanguage.Items.Clear;
+ cbLanguage.Items.Add(MsgLabEsLanguageAuto);
+ list := g_Language_GetList();
+ cbLanguage.Items.AddStrings(list);
+ list.Free();
+ cbLanguage.ItemIndex := IfThen(gLanguage = '', 0, cbLanguage.Items.IndexOf(gLanguage));
+ finally
+ cbLanguage.Items.EndUpdate;
+ end;
+
+ // Files Tab:
+ SpinEdit3.Value := RecentCount;
+
+ // Testing Tab:
+ ExeEdit.Text := TestD2dExe;
+ edD2DArgs.Text := TestD2DArgs;
+
+ rbDM.Checked := TestGameMode = 'DM';
+ rbTDM.Checked := TestGameMode = 'TDM';
+ rbCTF.Checked := TestGameMode = 'CTF';
+ rbCOOP.Checked := TestGameMode = 'COOP';
+
+ edTime.Text := TestLimTime;
+ edScore.Text := TestLimScore;
+ cbTwoPlayers.Checked := TestOptionsTwoPlayers;
+ cbTeamDamage.Checked := TestOptionsTeamDamage;
+ cbAllowExit.Checked := TestOptionsAllowExit;
+ cbWeaponStay.Checked := TestOptionsWeaponStay;
+ cbMonstersDM.Checked := TestOptionsMonstersDM;
+ cbMapOnce.Checked := TestMapOnce;
end;
procedure TOptionsForm.bOKClick(Sender: TObject);
var
config: TConfig;
- re: Integer;
- d1: Boolean;
+ re, n: Integer;
str: String;
begin
- re := StrToIntDef(eRecent.Text, 5);
- if re < 2 then
- re := 2;
- if re > 10 then
- re := 10;
-
- if rbRussian.Checked then
- str := LANGUAGE_RUSSIAN
- else
- str := LANGUAGE_ENGLISH;
-
-// Нужно сменить язык:
- if gLanguage <> str then
+ // General tab:
+ if cbLanguage.ItemIndex >= 0 then
begin
- gLanguage := str;
- //e_WriteLog('Read language file', MSG_NOTIFY);
- //g_Language_Load(EditorDir+'\data\'+gLanguage+LANGUAGE_FILE_NAME);
- g_Language_Set(gLanguage);
+ if cbLanguage.ItemIndex = 0 then str := '' else str := cbLanguage.Items[cbLanguage.ItemIndex];
+ if (str = '') or (gLanguage <> str) then
+ begin
+ gLanguage := str;
+ g_Language_Set(gLanguage);
+ end;
end;
-
- DotColor := sDotColor.Brush.Color;
- DotEnable := cbShowDots.Checked;
-
- if DotStep = DotStepOne then
- d1 := True
- else
- d1 := False;
- DotStepOne := StrToIntDef(eDotStepOne.Text, 16);
- DotStepTwo := StrToIntDef(eDotStepTwo.Text, 8);
- if d1 then
- DotStep := DotStepOne
- else
- DotStep := DotStepTwo;
+
+ DotColor := ColorButton1.ButtonColor;
+ BackColor := ColorButton2.ButtonColor;
+ PreviewColor := ColorButton3.ButtonColor;
+
+ DotEnable := cbShowDots.Checked;
+ DotStep := IfThen(DotStep = DotStepOne, SpinEdit1.Value, SpinEdit2.Value);
+ DotStepOne := SpinEdit1.Value;
+ DotStepTwo := SpinEdit2.Value;
DrawTexturePanel := cbShowTexture.Checked;
DrawPanelSize := cbShowSize.Checked;
- BackColor := sBackColor.Brush.Color;
- PreviewColor := sPreviewColor.Brush.Color;
+ UseCheckerboard := cbCheckerboard.Checked;
+ DotSize := SpinEdit4.Value;
+ Scale := SpinEdit5.Value;
+
+ // Files tab:
+ re := SpinEdit3.Value;
+
+ // Testing tab:
+ TestD2DExe := ExeEdit.Text;
+ TestD2DArgs := edD2DArgs.Text;
+
+ TestGameMode := 'DM';
+ if rbTDM.Checked then TestGameMode := 'TDM';
+ if rbCTF.Checked then TestGameMode := 'CTF';
+ if rbCOOP.Checked then TestGameMode := 'COOP';
+ if rbDM.Checked then TestGameMode := 'DM';
+
+ TestLimTime := edTime.Text;
+ if (not TryStrToInt(TestLimTime, n)) then
+ TestLimTime := '0';
- if cbScale.ItemIndex = 1 then
- Scale := 2
- else
- Scale := 1;
+ TestLimScore := edScore.Text;
+ if (not TryStrToInt(TestLimScore, n)) then
+ TestLimScore := '0';
- if cbDotSize.ItemIndex = 1 then
- DotSize := 2
- else
- DotSize := 1;
+ TestOptionsTwoPlayers := cbTwoPlayers.Checked;
+ TestOptionsTeamDamage := cbTeamDamage.Checked;
+ TestOptionsAllowExit := cbAllowExit.Checked;
+ TestOptionsWeaponStay := cbWeaponStay.Checked;
+ TestOptionsMonstersDM := cbMonstersDM.Checked;
+ TestMapOnce := cbMapOnce.Checked;
- config := TConfig.CreateFile(EditorDir+'/Editor.cfg');
+ // save into config
+ config := TConfig.CreateFile(CfgFileName);
+
+ config.WriteInt('WADEditor', 'LogLevel', gWADEditorLogLevel);
config.WriteInt('Editor', 'DotColor', DotColor);
config.WriteBool('Editor', 'DotEnable', DotEnable);
config.WriteInt('Editor', 'DotStepOne', DotStepOne);
config.WriteInt('Editor', 'DotStepTwo', DotStepTwo);
config.WriteInt('Editor', 'DotStep', DotStep);
- config.WriteInt('Editor', 'DotSize', cbDotSize.ItemIndex);
+ config.WriteInt('Editor', 'DotSize', SpinEdit4.Value);
config.WriteBool('Editor', 'DrawTexturePanel', DrawTexturePanel);
config.WriteBool('Editor', 'DrawPanelSize', DrawPanelSize);
config.WriteInt('Editor', 'BackColor', BackColor);
config.WriteInt('Editor', 'PreviewColor', PreviewColor);
- config.WriteInt('Editor', 'Scale', cbScale.ItemIndex);
- config.WriteInt('Editor', 'RecentCount', re);
+ config.WriteBool('Editor', 'UseCheckerboard', UseCheckerboard);
+ config.WriteInt('Editor', 'Scale', SpinEdit5.Value);
config.WriteStr('Editor', 'Language', gLanguage);
+ config.WriteInt('Editor', 'RecentCount', re);
+
+ config.WriteStr('TestRun', 'GameMode', TestGameMode);
+ config.WriteStr('TestRun', 'LimTime', TestLimTime);
+ config.WriteStr('TestRun', 'LimScore', TestLimScore);
+ config.WriteBool('TestRun', 'TwoPlayers', TestOptionsTwoPlayers);
+ config.WriteBool('TestRun', 'TeamDamage', TestOptionsTeamDamage);
+ config.WriteBool('TestRun', 'AllowExit', TestOptionsAllowExit);
+ config.WriteBool('TestRun', 'WeaponStay', TestOptionsWeaponStay);
+ config.WriteBool('TestRun', 'MonstersDM', TestOptionsMonstersDM);
+ config.WriteBool('TestRun', 'MapOnce', TestMapOnce);
+ {$IF DEFINED(DARWIN)}
+ config.WriteStr('TestRun', 'ExeDrawin', TestD2dExe);
+ {$ELSEIF DEFINED(WINDOWS)}
+ config.WriteStr('TestRun', 'ExeWindows', TestD2dExe);
+ {$ELSE}
+ config.WriteStr('TestRun', 'ExeUnix', TestD2dExe);
+ {$ENDIF}
+ config.WriteStr('TestRun', 'Args', TestD2DArgs);
+
if RecentCount <> re then
begin
RecentCount := re;
MainForm.RefreshRecentMenu();
end;
- config.SaveFile(EditorDir+'/Editor.cfg');
+ config.SaveFile(CfgFileName);
config.Free();
Close();
end;
Close();
end;
-procedure TOptionsForm.bBackClick(Sender: TObject);
-begin
- if ColorDialog.Execute then
- sBackColor.Brush.Color := ColorDialog.Color;
-end;
-
-procedure TOptionsForm.bPreviewClick(Sender: TObject);
+procedure TOptionsForm.FormCreate(Sender: TObject);
begin
- if ColorDialog.Execute then
- sPreviewColor.Brush.Color := ColorDialog.Color;
+ {$IF DEFINED(DARWIN)}
+ if LowerCase(ExtractFileExt(TestD2DExe)) = '.app' then
+ ExeEdit.InitialDir := ExtractFileDir(TestD2DExe)
+ else
+ ExeEdit.InitialDir := TestD2DExe;
+ {$ELSE}
+ ExeEdit.InitialDir := TestD2DExe;
+ {$ENDIF}
end;
end.