X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Feditor%2Ff_options.pas;h=588d9c49a8c807e34d42960c4fdf9c762f977ff1;hb=cd1d110f20a449413d8bce030b23847770d75d40;hp=28debba765666f781e334d94807db7cdd40e0cdd;hpb=3dc2fe6b3d29cd54425db8f590e922f2dce50e99;p=d2df-editor.git diff --git a/src/editor/f_options.pas b/src/editor/f_options.pas index 28debba..588d9c4 100644 --- a/src/editor/f_options.pas +++ b/src/editor/f_options.pas @@ -5,16 +5,26 @@ unit f_options; 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, Registry, Math, Types; type + + { TOptionsForm } + TOptionsForm = class (TForm) bOK: TButton; bCancel: TButton; + cbCheckerboard: TCheckBox; + cbCompress: TCheckBox; + cbBackup: TCheckBox; + cbLanguage: TComboBox; + PageControl: TPageControl; + TabGeneral: TTabSheet; + TabFiles: TTabSheet; + TabTesting: TTabSheet; ColorDialog: TColorDialog; - GroupBox1: TGroupBox; // Общие настройки: cbShowDots: TCheckBox; cbShowTexture: TCheckBox; @@ -45,17 +55,40 @@ type eRecent: TEdit; UpDown3: TUpDown; LabelLanguage: TLabel; - rbRussian: TRadioButton; - rbEnglish: TRadioButton; LabelGridSize: TLabel; cbDotSize: TComboBox; + // Map testing: + LabelPath: TLabel; + edD2dexe: TEdit; + bChooseD2d: TButton; + FindD2dDialog: TOpenDialog; + LabelArgs: TLabel; + edD2DArgs: TEdit; + rbCOOP: TRadioButton; + rbCTF: TRadioButton; + rbDM: TRadioButton; + rbTDM: TRadioButton; + cbAllowExit: TCheckBox; + cbMapOnce: TCheckBox; + cbMonstersDM: TCheckBox; + cbTeamDamage: TCheckBox; + cbTwoPlayers: TCheckBox; + cbWeaponStay: TCheckBox; + LabelScore: TLabel; + LabelSecs: TLabel; + edScore: TEdit; + LabelTime: TLabel; + edTime: TEdit; + procedure bGridClick(Sender: TObject); - procedure FormActivate(Sender: TObject); + procedure FormShow(Sender: TObject); procedure bOKClick(Sender: TObject); procedure bCancelClick(Sender: TObject); procedure bBackClick(Sender: TObject); procedure bPreviewClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure bChooseD2dClick(Sender: TObject); private { Private declarations } @@ -71,7 +104,7 @@ procedure RegisterFileType(ext: String; FileName: String); implementation uses - f_main, StdConvs, CONFIG, g_language; + LazFileUtils, f_main, StdConvs, CONFIG, g_language, g_resources, g_options; {$R *.lfm} @@ -105,7 +138,14 @@ begin sDotColor.Brush.Color := ColorDialog.Color; end; -procedure TOptionsForm.FormActivate(Sender: TObject); +procedure TOptionsForm.bChooseD2dClick(Sender: TObject); +begin + if FindD2dDialog.Execute then + edD2dExe.Text := FindD2dDialog.FileName; +end; + +procedure TOptionsForm.FormShow(Sender: TObject); + var list: TStringList; begin sDotColor.Brush.Color := DotColor; cbShowDots.Checked := DotEnable; @@ -115,6 +155,9 @@ begin eDotStepTwo.Text := IntToStr(DotStepTwo); sBackColor.Brush.Color := BackColor; sPreviewColor.Brush.Color := PreviewColor; + cbCheckerboard.Checked := UseCheckerboard; + cbCompress.Checked := Compress; + cbBackup.Checked := Backup; if Scale = 2 then cbScale.ItemIndex := 1 else @@ -125,47 +168,59 @@ begin cbDotSize.ItemIndex := 0; eRecent.Text := IntToStr(RecentCount); -// Язык: - if gLanguage = LANGUAGE_RUSSIAN then - begin - rbRussian.Checked := True; - rbEnglish.Checked := False; - end + try + cbLanguage.Items.BeginUpdate; + cbLanguage.Items.Clear; + cbLanguage.Items.Add('Auto'); + list := g_Language_GetList(); + cbLanguage.Items.AddStrings(list); + list.Free(); + cbLanguage.ItemIndex := IfThen(gLanguage = '', 0, cbLanguage.Items.IndexOf(gLanguage)); + finally + cbLanguage.Items.EndUpdate; + end; + + if TestGameMode = 'TDM' then + rbTDM.Checked := True + else if TestGameMode = 'CTF' then + rbCTF.Checked := True + else if TestGameMode = 'COOP' then + rbCOOP.Checked := True else - begin - rbRussian.Checked := False; - rbEnglish.Checked := True; - end; + rbDM.Checked := True; + + edTime.Text := TestLimTime; + edScore.Text := TestLimScore; + cbTwoPlayers.Checked := TestOptionsTwoPlayers; + cbTeamDamage.Checked := TestOptionsTeamDamage; + cbAllowExit.Checked := TestOptionsAllowExit; + cbWeaponStay.Checked := TestOptionsWeaponStay; + cbMonstersDM.Checked := TestOptionsMonstersDM; + cbMapOnce.Checked := TestMapOnce; + edD2dExe.Text := TestD2dExe; + edD2DArgs.Text := TestD2DArgs; end; procedure TOptionsForm.bOKClick(Sender: TObject); var config: TConfig; - re: Integer; + re, n: Integer; d1: Boolean; 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; + // General tab -// Нужно сменить язык: - if gLanguage <> str then + 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; @@ -173,8 +228,8 @@ begin d1 := True else d1 := False; - DotStepOne := StrToIntDef(eDotStepOne.Text, 16); - DotStepTwo := StrToIntDef(eDotStepTwo.Text, 8); + DotStepOne := EnsureRange(StrToIntDef(eDotStepOne.Text, 16), 4, 2048); + DotStepTwo := EnsureRange(StrToIntDef(eDotStepTwo.Text, 8), 4, 2048); if d1 then DotStep := DotStepOne else @@ -184,6 +239,7 @@ begin DrawPanelSize := cbShowSize.Checked; BackColor := sBackColor.Brush.Color; PreviewColor := sPreviewColor.Brush.Color; + UseCheckerboard := cbCheckerboard.Checked; if cbScale.ItemIndex = 1 then Scale := 2 @@ -195,7 +251,44 @@ begin else DotSize := 1; - config := TConfig.CreateFile(EditorDir+'Editor.cfg'); + // Files tab + + re := Min(Max(StrToIntDef(eRecent.Text, 5), 2), 10); + Compress := cbCompress.Checked; + Backup := cbBackup.Checked; + + // Testing tab + + if rbTDM.Checked then + TestGameMode := 'TDM' + else if rbCTF.Checked then + TestGameMode := 'CTF' + else if rbCOOP.Checked then + TestGameMode := 'COOP' + else + TestGameMode := 'DM'; + + TestLimTime := edTime.Text; + if (not TryStrToInt(TestLimTime, n)) then + TestLimTime := '0'; + + TestLimScore := edScore.Text; + if (not TryStrToInt(TestLimScore, n)) then + TestLimScore := '0'; + + TestOptionsTwoPlayers := cbTwoPlayers.Checked; + TestOptionsTeamDamage := cbTeamDamage.Checked; + TestOptionsAllowExit := cbAllowExit.Checked; + TestOptionsWeaponStay := cbWeaponStay.Checked; + TestOptionsMonstersDM := cbMonstersDM.Checked; + TestMapOnce := cbMapOnce.Checked; + + TestD2dExe := edD2dExe.Text; + TestD2DArgs := edD2DArgs.Text; + + // save into config + + config := TConfig.CreateFile(CfgFileName); config.WriteInt('Editor', 'DotColor', DotColor); config.WriteBool('Editor', 'DotEnable', DotEnable); @@ -207,17 +300,39 @@ begin config.WriteBool('Editor', 'DrawPanelSize', DrawPanelSize); config.WriteInt('Editor', 'BackColor', BackColor); config.WriteInt('Editor', 'PreviewColor', PreviewColor); + config.WriteBool('Editor', 'UseCheckerboard', UseCheckerboard); config.WriteInt('Editor', 'Scale', cbScale.ItemIndex); - config.WriteInt('Editor', 'RecentCount', re); config.WriteStr('Editor', 'Language', gLanguage); + config.WriteInt('Editor', 'RecentCount', re); + config.WriteBool('Editor', 'Compress', Compress); + config.WriteBool('Editor', 'Backup', Backup); + + 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; @@ -239,4 +354,24 @@ begin sPreviewColor.Brush.Color := ColorDialog.Color; end; +procedure TOptionsForm.FormCreate(Sender: TObject); +begin + {$IF DEFINED(DARWIN)} + if LowerCase(ExtractFileExt(TestD2dExe)) = '.app' then + FindD2dDialog.InitialDir := ExtractFileDir(TestD2dExe) + else + FindD2dDialog.InitialDir := TestD2dExe; + FindD2dDialog.DefaultExt := '.app'; + FindD2dDialog.Filter := 'Doom 2D Forever.app|*.app|Doom 2D Forever (Unix Executable)|Doom2DF;*'; + {$ELSEIF DEFINED(WINDOWS)} + FindD2dDialog.InitialDir := TestD2dExe; + FindD2dDialog.DefaultExt := '.exe'; + FindD2dDialog.Filter := 'Doom2DF.exe|Doom2DF.exe;*.exe'; + {$ELSE} + FindD2dDialog.InitialDir := TestD2dExe; + FindD2dDialog.DefaultExt := ''; + FindD2dDialog.Filter := 'Doom2DF|Doom2DF;*'; + {$ENDIF} +end; + end.