X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Feditor%2Ff_options.pas;h=2f7d323eb23977e1e8df2c6891e949cbe942658c;hb=6f6c01c59fa41269434569e5e69b966b83ea18d7;hp=b52113c85cf36b8b716f614e7605c809cd7629b4;hpb=19f8a082fb249eb52f8fe49ad50a794d3176babd;p=d2df-editor.git diff --git a/src/editor/f_options.pas b/src/editor/f_options.pas index b52113c..2f7d323 100644 --- a/src/editor/f_options.pas +++ b/src/editor/f_options.pas @@ -7,93 +7,61 @@ interface uses LCLIntf, LCLType, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, - ExtCtrls, ComCtrls, ActnList, Registry, Math, Types; + ExtCtrls, ComCtrls, ActnList, Spin, EditBtn, Registry, Math, Types; type - - { TOptionsForm } - TOptionsForm = class (TForm) bOK: TButton; bCancel: TButton; + cbAllowExit: TCheckBox; cbCheckerboard: TCheckBox; - cbCompress: TCheckBox; - cbBackup: TCheckBox; cbLanguage: TComboBox; - PageControl: TPageControl; - TabGeneral: TTabSheet; - TabFiles: TTabSheet; - TabTesting: TTabSheet; - ColorDialog: TColorDialog; - // Общие настройки: + 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; - // Масштаб миникарты: - LabelMinimap: TLabel; - cbScale: TComboBox; - // Количество недавно открытых: - LabelRecent: TLabel; - eRecent: TEdit; - UpDown3: TUpDown; - LabelLanguage: TLabel; LabelGridSize: TLabel; - cbDotSize: TComboBox; - // Map testing: + LabelLanguage: TLabel; + LabelMinimap: TLabel; LabelPath: TLabel; - edD2dexe: TEdit; - bChooseD2d: TButton; - FindD2dDialog: TOpenDialog; - LabelArgs: TLabel; - edD2DArgs: TEdit; + LabelPreview: TLabel; + LabelRecent: TLabel; + LabelScore: TLabel; + LabelSecs: TLabel; + LabelTime: TLabel; + PageControl: TPageControl; 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; - + SpinEdit1: TSpinEdit; + SpinEdit2: TSpinEdit; + SpinEdit3: TSpinEdit; + SpinEdit4: TSpinEdit; + SpinEdit5: TSpinEdit; + TabFiles: TTabSheet; + TabGeneral: TTabSheet; + TabTesting: TTabSheet; - procedure bGridClick(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 } - public - { Public declarations } end; var @@ -104,7 +72,7 @@ procedure RegisterFileType(ext: String; FileName: String); implementation uses - LazFileUtils, f_main, StdConvs, CONFIG, g_language, g_resources, g_options; + LazFileUtils, f_main, StdConvs, CONFIG, WADEDITOR, g_language, g_options; {$R *.lfm} @@ -132,67 +100,47 @@ begin end; end; -procedure TOptionsForm.bGridClick(Sender: TObject); -begin - if ColorDialog.Execute then - sDotColor.Brush.Color := ColorDialog.Color; -end; - -procedure TOptionsForm.bChooseD2dClick(Sender: TObject); -begin - if FindD2dDialog.Execute then - edD2dExe.Text := FindD2dDialog.FileName; -end; - procedure TOptionsForm.FormShow(Sender: TObject); - const langfilename = 'editor'; - var info: TSearchRec; + var list: TStringList; begin - sDotColor.Brush.Color := DotColor; + // General Tab: + ColorButton1.ButtonColor := DotColor; + ColorButton2.ButtonColor := BackColor; + ColorButton3.ButtonColor := PreviewColor; + SpinEdit1.Value := DotStepOne; + SpinEdit2.Value := DotStepTwo; + 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; cbCheckerboard.Checked := UseCheckerboard; - cbCompress.Checked := Compress; - cbBackup.Checked := Backup; - 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); + + SpinEdit4.Value := DotSize; + SpinEdit5.Value := Scale; try cbLanguage.Items.BeginUpdate; cbLanguage.Items.Clear; - cbLanguage.Items.Add('Auto'); - if FindFirst(LangDir + DirectorySeparator + langfilename + '.*.mo', faAnyFile, info) = 0 then - begin - repeat - cbLanguage.Items.Add(Copy(ExtractFileNameWithoutExt(info.Name), Length(langfilename) + 2)); - until FindNext(info) <> 0; - FindClose(info); - end; + 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; - if TestGameMode = 'TDM' then - rbTDM.Checked := True - else if TestGameMode = 'CTF' then - rbCTF.Checked := True - else if TestGameMode = 'COOP' then - rbCOOP.Checked := True - else - rbDM.Checked := True; + // 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; @@ -202,73 +150,53 @@ begin 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, n: Integer; - d1: Boolean; str: String; begin - // General tab - - if cbLanguage.ItemIndex <= 0 then str := '' else str := cbLanguage.Items[cbLanguage.ItemIndex]; - if (str = '') or (gLanguage <> str) then + // General tab: + if cbLanguage.ItemIndex >= 0 then begin - gLanguage := str; - 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 := EnsureRange(StrToIntDef(eDotStepOne.Text, 16), 4, 2048); - DotStepTwo := EnsureRange(StrToIntDef(eDotStepTwo.Text, 8), 4, 2048); - 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; - if cbScale.ItemIndex = 1 then - Scale := 2 - else - Scale := 1; + // Files tab: + re := SpinEdit3.Value; - if cbDotSize.ItemIndex = 1 then - DotSize := 2 - else - DotSize := 1; - - // Files tab - - re := Min(Max(StrToIntDef(eRecent.Text, 5), 2), 10); - Compress := cbCompress.Checked; - Backup := cbBackup.Checked; - - // Testing tab + // Testing tab: + TestD2DExe := ExeEdit.Text; + TestD2DArgs := edD2DArgs.Text; - if rbTDM.Checked then - TestGameMode := 'TDM' - else if rbCTF.Checked then - TestGameMode := 'CTF' - else if rbCOOP.Checked then - TestGameMode := 'COOP' - else - TestGameMode := 'DM'; + 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 @@ -280,35 +208,31 @@ begin TestOptionsTwoPlayers := cbTwoPlayers.Checked; TestOptionsTeamDamage := cbTeamDamage.Checked; - TestOptionsAllowExit := cbAllowExit.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('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.WriteBool('Editor', 'UseCheckerboard', UseCheckerboard); - config.WriteInt('Editor', 'Scale', cbScale.ItemIndex); + config.WriteInt('Editor', 'Scale', SpinEdit5.Value); 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); @@ -344,35 +268,15 @@ begin Close(); end; -procedure TOptionsForm.bBackClick(Sender: TObject); -begin - if ColorDialog.Execute then - sBackColor.Brush.Color := ColorDialog.Color; -end; - -procedure TOptionsForm.bPreviewClick(Sender: TObject); -begin - if ColorDialog.Execute then - 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) + if LowerCase(ExtractFileExt(TestD2DExe)) = '.app' then + ExeEdit.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'; + ExeEdit.InitialDir := TestD2DExe; {$ELSE} - FindD2dDialog.InitialDir := TestD2dExe; - FindD2dDialog.DefaultExt := ''; - FindD2dDialog.Filter := 'Doom2DF|Doom2DF;*'; + ExeEdit.InitialDir := TestD2DExe; {$ENDIF} end;