From e2cdd62f67c91ec8ce236bdfe24232c427efcbf6 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Sun, 21 Jul 2019 18:08:43 +0300 Subject: [PATCH 01/16] add command line passing for map test --- src/editor/f_main.pas | 46 +++++++++++++++++++++++++++++++++++++--- src/editor/f_maptest.lfm | 10 ++++++++- src/editor/f_maptest.pas | 5 +++++ 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index 99ddcd9..481f597 100644 --- a/src/editor/f_main.pas +++ b/src/editor/f_main.pas @@ -8,7 +8,7 @@ uses LCLIntf, LCLType, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ComCtrls, ValEdit, Types, Menus, ExtCtrls, - CheckLst, Grids, OpenGLContext, utils, UTF8Process; + CheckLst, Grids, OpenGLContext, Utils, UTF8Process; type @@ -313,7 +313,7 @@ var TestOptionsAllowExit: Boolean; TestOptionsWeaponStay: Boolean; TestOptionsMonstersDM: Boolean; - TestD2dExe: String; + TestD2dExe, TestD2DArgs: String; TestMapOnce: Boolean; LayerEnabled: Array [LAYER_BACK..LAYER_TRIGGERS] of Boolean = @@ -6626,11 +6626,47 @@ begin MapTestForm.ShowModal(); end; +type SSArray = array of String; + +function ParseString (Str: AnsiString): SSArray; + function GetStr (var Str: AnsiString): AnsiString; + var a, b: Integer; + begin + Result := ''; + if Str[1] = '"' then + for b := 1 to Length(Str) do + if (b = Length(Str)) or (Str[b + 1] = '"') then + begin + Result := Copy(Str, 2, b - 1); + Delete(Str, 1, b + 1); + Str := Trim(Str); + Exit; + end; + for a := 1 to Length(Str) do + if (a = Length(Str)) or (Str[a + 1] = ' ') then + begin + Result := Copy(Str, 1, a); + Delete(Str, 1, a + 1); + Str := Trim(Str); + Exit; + end; + end; +begin + Result := nil; + Str := Trim(Str); + while Str <> '' do + begin + SetLength(Result, Length(Result)+1); + Result[High(Result)] := GetStr(Str); + end; +end; + procedure TMainForm.miTestMapClick(Sender: TObject); var mapWAD, mapToRun, tempWAD: String; + args: SSArray; opt: LongWord; - time: Integer; + time, i: Integer; proc: TProcessUTF8; res: Boolean; begin @@ -6688,6 +6724,10 @@ begin if TestMapOnce then proc.Parameters.Add('--close'); + args := ParseString(TestD2DArgs); + for i := 0 to High(args) do + proc.Parameters.Add(args[i]); + res := True; try proc.Execute(); diff --git a/src/editor/f_maptest.lfm b/src/editor/f_maptest.lfm index 6e5fa1e..c3cc7d1 100644 --- a/src/editor/f_maptest.lfm +++ b/src/editor/f_maptest.lfm @@ -214,6 +214,14 @@ object MapTestForm: TMapTestForm ParentFont = False TabOrder = 15 end + object edD2DArgs: TEdit + Left = 14 + Height = 21 + Top = 200 + Width = 297 + TabOrder = 16 + Text = '' + end object cbMapOnce: TCheckBox Left = 14 Height = 17 @@ -226,7 +234,7 @@ object MapTestForm: TMapTestForm object FindD2dDialog: TOpenDialog Title = 'Выберите файл игры Doom 2D: Forever' DefaultExt = '.exe' - Filter = 'Doom2DF.exe|Doom2DF.exe' + Filter = 'Doom2DF.exe|Doom2DF.exe;Doom2DF' Options = [ofHideReadOnly, ofNoChangeDir, ofEnableSizing] left = 320 top = 144 diff --git a/src/editor/f_maptest.pas b/src/editor/f_maptest.pas index 69f7f40..b35dc46 100644 --- a/src/editor/f_maptest.pas +++ b/src/editor/f_maptest.pas @@ -38,6 +38,7 @@ type // Путь: LabelPath: TLabel; edD2dexe: TEdit; + edD2DArgs: TEdit; bChooseD2d: TButton; FindD2dDialog: TOpenDialog; @@ -113,6 +114,8 @@ begin config.WriteStr('TestRun', 'Exe', edD2dExe.Text); TestD2dExe := edD2dExe.Text; + config.WriteStr('TestRun', 'Args', edD2DArgs.Text); + TestD2DArgs := edD2DArgs.Text; config.SaveFile(EditorDir+'Editor.cfg'); config.Free(); @@ -146,6 +149,7 @@ begin cbMonstersDM.Checked := TestOptionsMonstersDM; cbMapOnce.Checked := TestMapOnce; edD2dExe.Text := TestD2dExe; + edD2DArgs.Text := TestD2DArgs; end; procedure TMapTestForm.FormCreate(Sender: TObject); @@ -165,6 +169,7 @@ begin TestOptionsMonstersDM := config.ReadBool('TestRun', 'MonstersDM', False); TestMapOnce := config.ReadBool('TestRun', 'MapOnce', False); TestD2dExe := config.ReadStr('TestRun', 'Exe', EditorDir+'Doom2DF.exe'); + TestD2DArgs := config.ReadStr('TestRun', 'Args', ''); config.Free(); -- 2.29.2 From 1ec6c5d2252441662f455c88e8b777fac19b024c Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Fri, 2 Aug 2019 17:49:48 +0300 Subject: [PATCH 02/16] fix map test settings interface (by Joseph Stalin) --- src/editor/Editor.lpi | 9 ++-- src/editor/f_maptest.lfm | 99 ++++++++++++++++++++------------------- src/editor/f_maptest.pas | 4 ++ src/editor/g_language.pas | 5 ++ 4 files changed, 66 insertions(+), 51 deletions(-) diff --git a/src/editor/Editor.lpi b/src/editor/Editor.lpi index 896b9b3..f012103 100644 --- a/src/editor/Editor.lpi +++ b/src/editor/Editor.lpi @@ -1,7 +1,7 @@ - + @@ -81,9 +81,10 @@ - - - + + + + diff --git a/src/editor/f_maptest.lfm b/src/editor/f_maptest.lfm index c3cc7d1..89503fb 100644 --- a/src/editor/f_maptest.lfm +++ b/src/editor/f_maptest.lfm @@ -1,12 +1,12 @@ object MapTestForm: TMapTestForm Left = 291 - Height = 270 + Height = 322 Top = 194 Width = 367 BorderIcons = [biSystemMenu] BorderStyle = bsSingle Caption = 'Настройки теста в игре' - ClientHeight = 270 + ClientHeight = 322 ClientWidth = 367 Color = clBtnFace Font.Color = clWindowText @@ -15,11 +15,11 @@ object MapTestForm: TMapTestForm OnActivate = FormActivate OnCreate = FormCreate Position = poScreenCenter - LCLVersion = '1.6.4.0' + LCLVersion = '2.0.2.0' object bOK: TButton Left = 192 Height = 25 - Top = 240 + Top = 280 Width = 75 Caption = 'OK' Default = True @@ -29,7 +29,7 @@ object MapTestForm: TMapTestForm object bCancel: TButton Left = 286 Height = 25 - Top = 240 + Top = 280 Width = 75 Cancel = True Caption = 'Отмена' @@ -38,23 +38,23 @@ object MapTestForm: TMapTestForm end object GroupBox1: TGroupBox Left = 8 - Height = 233 + Height = 264 Top = 0 Width = 353 - ClientHeight = 215 - ClientWidth = 349 + ClientHeight = 262 + ClientWidth = 351 TabOrder = 0 object LabelTime: TLabel Left = 14 - Height = 13 + Height = 16 Top = 98 - Width = 83 + Width = 80 Caption = 'Лимит времени:' ParentColor = False end object LabelSecs: TLabel Left = 174 - Height = 13 + Height = 16 Top = 98 Width = 35 Caption = 'секунд' @@ -62,25 +62,25 @@ object MapTestForm: TMapTestForm end object LabelScore: TLabel Left = 14 - Height = 13 + Height = 16 Top = 122 - Width = 68 + Width = 66 Caption = 'Лимит очков:' ParentColor = False end object LabelPath: TLabel Left = 14 - Height = 13 + Height = 16 Top = 170 - Width = 107 + Width = 103 Caption = 'Путь к Doom2DF.exe:' ParentColor = False end object rbDM: TRadioButton Left = 14 - Height = 17 + Height = 21 Top = 2 - Width = 76 + Width = 84 Caption = 'Deathmatch' Checked = True TabOrder = 0 @@ -88,49 +88,49 @@ object MapTestForm: TMapTestForm end object rbTDM: TRadioButton Left = 14 - Height = 17 + Height = 21 Top = 18 - Width = 106 + Width = 113 Caption = 'Team Deathmatch' TabOrder = 1 end object rbCTF: TRadioButton Left = 14 - Height = 17 + Height = 21 Top = 34 - Width = 96 + Width = 106 Caption = 'Capture the Flag' TabOrder = 2 end object rbCOOP: TRadioButton Left = 14 - Height = 17 + Height = 21 Top = 50 - Width = 75 + Width = 83 Caption = 'Cooperative' TabOrder = 3 end object cbTwoPlayers: TCheckBox Left = 174 - Height = 17 + Height = 21 Top = 2 - Width = 77 + Width = 80 Caption = 'Два игрока' TabOrder = 4 end object cbTeamDamage: TCheckBox Left = 174 - Height = 17 + Height = 21 Top = 18 - Width = 124 + Width = 126 Caption = 'Урон своей команде' TabOrder = 5 end object cbAllowExit: TCheckBox Left = 174 - Height = 17 + Height = 21 Top = 34 - Width = 103 + Width = 109 Caption = 'Выход из уровня' Checked = True State = cbChecked @@ -138,23 +138,23 @@ object MapTestForm: TMapTestForm end object cbWeaponStay: TCheckBox Left = 174 - Height = 17 + Height = 21 Top = 50 - Width = 106 + Width = 112 Caption = 'Оружие остается' TabOrder = 7 end object cbMonstersDM: TCheckBox Left = 174 - Height = 17 + Height = 21 Top = 66 - Width = 93 + Width = 98 Caption = 'Монстры в DM' TabOrder = 8 end object edTime: TEdit Left = 102 - Height = 21 + Height = 28 Top = 98 Width = 49 TabOrder = 9 @@ -162,7 +162,7 @@ object MapTestForm: TMapTestForm end object edScore: TEdit Left = 102 - Height = 21 + Height = 28 Top = 122 Width = 49 TabOrder = 10 @@ -170,7 +170,7 @@ object MapTestForm: TMapTestForm end object UpDown2: TUpDown Left = 151 - Height = 21 + Height = 28 Top = 122 Width = 12 Associate = edScore @@ -178,11 +178,10 @@ object MapTestForm: TMapTestForm Min = 0 Position = 0 TabOrder = 12 - Wrap = False end object UpDown1: TUpDown Left = 151 - Height = 21 + Height = 28 Top = 98 Width = 12 Associate = edTime @@ -190,11 +189,10 @@ object MapTestForm: TMapTestForm Min = 0 Position = 0 TabOrder = 11 - Wrap = False end object edD2dexe: TEdit Left = 14 - Height = 21 + Height = 28 Top = 186 Width = 297 TabOrder = 14 @@ -216,27 +214,34 @@ object MapTestForm: TMapTestForm end object edD2DArgs: TEdit Left = 14 - Height = 21 - Top = 200 + Height = 28 + Top = 232 Width = 297 TabOrder = 16 - Text = '' end object cbMapOnce: TCheckBox Left = 14 - Height = 17 + Height = 21 Top = 146 - Width = 209 + Width = 211 Caption = 'Закрыть игру после выхода из карты' TabOrder = 13 end + object LabelArgs: TLabel + Left = 14 + Height = 16 + Top = 216 + Width = 103 + Caption = 'Параметры запуска:' + ParentColor = False + end end object FindD2dDialog: TOpenDialog Title = 'Выберите файл игры Doom 2D: Forever' DefaultExt = '.exe' Filter = 'Doom2DF.exe|Doom2DF.exe;Doom2DF' Options = [ofHideReadOnly, ofNoChangeDir, ofEnableSizing] - left = 320 - top = 144 + left = 296 + top = 128 end end diff --git a/src/editor/f_maptest.pas b/src/editor/f_maptest.pas index b35dc46..ed08dc7 100644 --- a/src/editor/f_maptest.pas +++ b/src/editor/f_maptest.pas @@ -10,10 +10,14 @@ uses ComCtrls; type + + { TMapTestForm } + TMapTestForm = class (TForm) bOK: TButton; bCancel: TButton; GroupBox1: TGroupBox; + LabelArgs: TLabel; // Режим игры: rbDM: TRadioButton; rbTDM: TRadioButton; diff --git a/src/editor/g_language.pas b/src/editor/g_language.pas index 75d8787..ea8c562 100644 --- a/src/editor/g_language.pas +++ b/src/editor/g_language.pas @@ -534,6 +534,7 @@ Type I_LAB_LAUNCH_SECS, I_LAB_LAUNCH_SCORE, I_LAB_LAUNCH_PATH, + I_LAB_LAUNCH_ARGS, I_LAB_ES_GRID, I_LAB_ES_GRID_COLOR, @@ -1663,6 +1664,8 @@ Const 'Лимит очков:'), ('LAB LAUNCH PATH', 'Path to Doom2DF.exe:', 'Путь к Doom2DF.exe:'), + ('LAB LAUNCH ARGS', 'Launch Arguments:', + 'Параметры запуска:'), ('LAB ES GRID', 'Grid Step:', 'Шаг сетки:'), @@ -2323,6 +2326,8 @@ begin // Путь: LabelPath.Caption := _lc[I_LAB_LAUNCH_PATH]; FindD2dDialog.Title := _lc[I_CTRL_LAUNCH_OPEN]; + + LabelArgs.Caption := _lc[I_LAB_LAUNCH_ARGS]; end; // Форма "Настройки редактора": -- 2.29.2 From 3f6a265be15702407d13e055359463f27dd3e742 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Tue, 6 Aug 2019 01:31:39 +0300 Subject: [PATCH 03/16] Triggers: Add DamageKind to TRIGGER_DAMAGE --- src/editor/f_main.pas | 39 ++++++++++++++++++++++++++++++++++++++ src/editor/g_language.pas | 24 +++++++++++++++++++++++ src/shared/MAPDEF.pas | 3 ++- src/shared/mapstructio.inc | 2 ++ 4 files changed, 67 insertions(+), 1 deletion(-) diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index 481f597..74d43c0 100644 --- a/src/editor/f_main.pas +++ b/src/editor/f_main.pas @@ -1410,6 +1410,20 @@ begin EditStyle := esSimple; MaxLength := 5; end; + case Data.DamageKind of + 3: str := _lc[I_PROP_TR_DAMAGE_KIND_3]; + 4: str := _lc[I_PROP_TR_DAMAGE_KIND_4]; + 5: str := _lc[I_PROP_TR_DAMAGE_KIND_5]; + 6: str := _lc[I_PROP_TR_DAMAGE_KIND_6]; + 7: str := _lc[I_PROP_TR_DAMAGE_KIND_7]; + 8: str := _lc[I_PROP_TR_DAMAGE_KIND_8]; + else str := _lc[I_PROP_TR_DAMAGE_KIND_0]; + end; + with ItemProps[InsertRow(_lc[I_PROP_TR_DAMAGE_KIND], str, True)] do + begin + EditStyle := esPickList; + ReadOnly := True; + end; end; TRIGGER_HEALTH: @@ -4765,6 +4779,16 @@ begin Values.Add(_lc[I_PROP_TR_SHOT_AIM_2]); Values.Add(_lc[I_PROP_TR_SHOT_AIM_3]); end + else if KeyName = _lc[I_PROP_TR_DAMAGE_KIND] then + begin + Values.Add(_lc[I_PROP_TR_DAMAGE_KIND_0]); + Values.Add(_lc[I_PROP_TR_DAMAGE_KIND_3]); + Values.Add(_lc[I_PROP_TR_DAMAGE_KIND_4]); + Values.Add(_lc[I_PROP_TR_DAMAGE_KIND_5]); + Values.Add(_lc[I_PROP_TR_DAMAGE_KIND_6]); + Values.Add(_lc[I_PROP_TR_DAMAGE_KIND_7]); + Values.Add(_lc[I_PROP_TR_DAMAGE_KIND_8]); + end else if (KeyName = _lc[I_PROP_PANEL_BLEND]) or (KeyName = _lc[I_PROP_DM_ONLY]) or (KeyName = _lc[I_PROP_ITEM_FALLS]) or @@ -5168,6 +5192,21 @@ begin StrToIntDef(vleObjectProperty.Values[_lc[I_PROP_TR_DAMAGE_VALUE]], 0), 0), 65535); Data.DamageInterval := Min(Max( StrToIntDef(vleObjectProperty.Values[_lc[I_PROP_TR_INTERVAL]], 0), 0), 65535); + s := vleObjectProperty.Values[_lc[I_PROP_TR_DAMAGE_KIND]]; + if s = _lc[I_PROP_TR_DAMAGE_KIND_3] then + Data.DamageKind := 3 + else if s = _lc[I_PROP_TR_DAMAGE_KIND_4] then + Data.DamageKind := 4 + else if s = _lc[I_PROP_TR_DAMAGE_KIND_5] then + Data.DamageKind := 5 + else if s = _lc[I_PROP_TR_DAMAGE_KIND_6] then + Data.DamageKind := 6 + else if s = _lc[I_PROP_TR_DAMAGE_KIND_7] then + Data.DamageKind := 7 + else if s = _lc[I_PROP_TR_DAMAGE_KIND_8] then + Data.DamageKind := 8 + else + Data.DamageKind := 0; end; TRIGGER_HEALTH: diff --git a/src/editor/g_language.pas b/src/editor/g_language.pas index ea8c562..0ba24c1 100644 --- a/src/editor/g_language.pas +++ b/src/editor/g_language.pas @@ -234,6 +234,14 @@ Type I_PROP_TR_SCORE_CON, I_PROP_TR_SCORE_MSG, I_PROP_TR_DAMAGE_VALUE, + I_PROP_TR_DAMAGE_KIND, + I_PROP_TR_DAMAGE_KIND_0, + I_PROP_TR_DAMAGE_KIND_3, + I_PROP_TR_DAMAGE_KIND_4, + I_PROP_TR_DAMAGE_KIND_5, + I_PROP_TR_DAMAGE_KIND_6, + I_PROP_TR_DAMAGE_KIND_7, + I_PROP_TR_DAMAGE_KIND_8, I_PROP_TR_HEALTH_MAX, I_PROP_TR_SHOT_TYPE, I_PROP_TR_SHOT_SOUND, @@ -1092,6 +1100,22 @@ Const 'Сообщение в игру'), ('PROP TR DAMAGE VALUE', 'Damage', 'Ущерб'), + ('PROP TR DAMAGE KIND', 'Damage type', + 'Тип урона'), + ('PROP TR DAMAGE KIND 0', 'HIT_SOME', + 'HIT_SOME'), + ('PROP TR DAMAGE KIND 3', 'HIT_TRAP', + 'HIT_TRAP'), + ('PROP TR DAMAGE KIND 4', 'HIT_FALL', + 'HIT_FALL'), + ('PROP TR DAMAGE KIND 5', 'HIT_WATER', + 'HIT_WATER'), + ('PROP TR DAMAGE KIND 6', 'HIT_ACID', + 'HIT_ACID'), + ('PROP TR DAMAGE KIND 7', 'HIT_ELECTRO', + 'HIT_ELECTRO'), + ('PROP TR DAMAGE KIND 8', 'HIT_FLAME', + 'HIT_FLAME'), ('PROP TR HEALTH MAX', 'To maximum', 'До максимума'), ('PROP TR SHOT TYPE', 'Projectile', diff --git a/src/shared/MAPDEF.pas b/src/shared/MAPDEF.pas index a94f1ec..b39b5fa 100644 --- a/src/shared/MAPDEF.pas +++ b/src/shared/MAPDEF.pas @@ -293,7 +293,8 @@ Type MessageText: Char100; MessageTime: Word); TRIGGER_DAMAGE: (DamageValue: Word; - DamageInterval: Word); + DamageInterval: Word; + DamageKind: Byte); TRIGGER_HEALTH: (HealValue: Word; HealInterval: Word; HealMax: Boolean; diff --git a/src/shared/mapstructio.inc b/src/shared/mapstructio.inc index ae432b9..d1198d5 100644 --- a/src/shared/mapstructio.inc +++ b/src/shared/mapstructio.inc @@ -184,6 +184,7 @@ procedure mb_Read_TriggerData (var tr: TTriggerData; ttype: Integer; const buf; begin getWordAt(tr.DamageValue, buf, 0); getWordAt(tr.DamageInterval, buf, 2); + getBytesAt(tr.DamageKind, buf, 4); end; procedure xreadHealth (); @@ -495,6 +496,7 @@ procedure mb_Write_TriggerData (var buf; bufsize: Integer; ttype: Integer; var t begin putWordAt(buf, 0, tr.DamageValue); putWordAt(buf, 2, tr.DamageInterval); + putBytesAt(buf, 4, tr.DamageKind); end; procedure xwriteHealth (); -- 2.29.2 From 8c19c641c31c73e2603a8230fbf7e83948a4feea Mon Sep 17 00:00:00 2001 From: fgsfds Date: Tue, 6 Aug 2019 01:35:35 +0300 Subject: [PATCH 04/16] whoops, how did this work before --- src/shared/mapstructio.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/mapstructio.inc b/src/shared/mapstructio.inc index d1198d5..f17a476 100644 --- a/src/shared/mapstructio.inc +++ b/src/shared/mapstructio.inc @@ -184,7 +184,7 @@ procedure mb_Read_TriggerData (var tr: TTriggerData; ttype: Integer; const buf; begin getWordAt(tr.DamageValue, buf, 0); getWordAt(tr.DamageInterval, buf, 2); - getBytesAt(tr.DamageKind, buf, 4); + getBytesAt(tr.DamageKind, buf, 4, 1); end; procedure xreadHealth (); @@ -496,7 +496,7 @@ procedure mb_Write_TriggerData (var buf; bufsize: Integer; ttype: Integer; var t begin putWordAt(buf, 0, tr.DamageValue); putWordAt(buf, 2, tr.DamageInterval); - putBytesAt(buf, 4, tr.DamageKind); + putBytesAt(buf, 4, tr.DamageKind, 1); end; procedure xwriteHealth (); -- 2.29.2 From 6e52b3dc2eb459c745e571dfef5afb5c2ccd546f Mon Sep 17 00:00:00 2001 From: Ketmar Dark Date: Tue, 17 Sep 2019 18:11:38 +0300 Subject: [PATCH 05/16] changed license to GPLv3 only; sorry, no trust to FSF anymore --- src/engine/e_graphics.pas | 3 +-- src/engine/e_textures.pas | 3 +-- src/sfs/sfs.pas | 3 +-- src/sfs/sfsPlainFS.pas | 3 +-- src/sfs/sfsZipFS.pas | 3 +-- src/shared/dfzip.pas | 3 +-- src/shared/utils.pas | 3 +-- src/shared/xstreams.pas | 3 +-- 8 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/engine/e_graphics.pas b/src/engine/e_graphics.pas index c9a16c2..96513d9 100644 --- a/src/engine/e_graphics.pas +++ b/src/engine/e_graphics.pas @@ -2,8 +2,7 @@ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * the Free Software Foundation, version 3 of the License ONLY. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/src/engine/e_textures.pas b/src/engine/e_textures.pas index 6055678..7e1bcea 100644 --- a/src/engine/e_textures.pas +++ b/src/engine/e_textures.pas @@ -2,8 +2,7 @@ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * the Free Software Foundation, version 3 of the License ONLY. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/src/sfs/sfs.pas b/src/sfs/sfs.pas index c3c7410..11e1045 100644 --- a/src/sfs/sfs.pas +++ b/src/sfs/sfs.pas @@ -2,8 +2,7 @@ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * the Free Software Foundation, version 3 of the License ONLY. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/src/sfs/sfsPlainFS.pas b/src/sfs/sfsPlainFS.pas index e6571ef..51b0c0d 100644 --- a/src/sfs/sfsPlainFS.pas +++ b/src/sfs/sfsPlainFS.pas @@ -2,8 +2,7 @@ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * the Free Software Foundation, version 3 of the License ONLY. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/src/sfs/sfsZipFS.pas b/src/sfs/sfsZipFS.pas index e5e9968..2f4c613 100644 --- a/src/sfs/sfsZipFS.pas +++ b/src/sfs/sfsZipFS.pas @@ -2,8 +2,7 @@ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * the Free Software Foundation, version 3 of the License ONLY. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/src/shared/dfzip.pas b/src/shared/dfzip.pas index 5b00a3b..0d2ac8a 100644 --- a/src/shared/dfzip.pas +++ b/src/shared/dfzip.pas @@ -2,8 +2,7 @@ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * the Free Software Foundation, version 3 of the License ONLY. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/src/shared/utils.pas b/src/shared/utils.pas index 14e6f76..10f7f93 100644 --- a/src/shared/utils.pas +++ b/src/shared/utils.pas @@ -2,8 +2,7 @@ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * the Free Software Foundation, version 3 of the License ONLY. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/src/shared/xstreams.pas b/src/shared/xstreams.pas index e27f73a..36e73f9 100644 --- a/src/shared/xstreams.pas +++ b/src/shared/xstreams.pas @@ -2,8 +2,7 @@ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * the Free Software Foundation, version 3 of the License ONLY. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of -- 2.29.2 From ead479e9d67b2199edc9ea45e1243963aac41323 Mon Sep 17 00:00:00 2001 From: Joseph Stalin Date: Sat, 30 Nov 2019 04:38:47 +0500 Subject: [PATCH 06/16] Some improvements to grid and navigation Extended viewable area past map border; Made scrollbars non-discrete (per-pixel instead of per-tile); Bound grid to map origin instead of viewport, same for cursor snap; Added speed modifier for WASD navigation (hold Shift); Changed and enforced possible grid sizes to 4-2048; Fixed related crawled-up bugs, changed code logic here and there, made other stuff I forgot to mention. --- src/editor/f_main.pas | 127 +++++++++++++++++++++++---------------- src/editor/f_options.lfm | 10 +-- src/editor/f_options.pas | 6 +- 3 files changed, 82 insertions(+), 61 deletions(-) diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index 74d43c0..7282c78 100644 --- a/src/editor/f_main.pas +++ b/src/editor/f_main.pas @@ -292,8 +292,8 @@ var DotColor: TColor; DotEnable: Boolean; - DotStep: Byte; - DotStepOne, DotStepTwo: Byte; + DotStep: Word; + DotStepOne, DotStepTwo: Word; DotSize: Byte; DrawTexturePanel: Boolean; DrawPanelSize: Boolean; @@ -694,10 +694,10 @@ begin begin ScaleSz := 16 div Scale; // Размер видимой части карты: - rx := min(Normalize16(Width), Normalize16(gMapInfo.Width)) div 2; - ry := min(Normalize16(Height), Normalize16(gMapInfo.Height)) div 2; + rx := Min(Normalize16(Width), Normalize16(gMapInfo.Width)) div 2; + ry := Min(Normalize16(Height), Normalize16(gMapInfo.Height)) div 2; // Место клика на мини-карте: - MapOffset.X := X - (Width-max(gMapInfo.Width div ScaleSz, 1)-1); + MapOffset.X := X - (Width - Max(gMapInfo.Width div ScaleSz, 1) - 1); MapOffset.Y := Y - 1; // Это же место на "большой" карте: MapOffset.X := MapOffset.X * ScaleSz; @@ -706,17 +706,17 @@ begin MapOffset.X := MapOffset.X - rx; MapOffset.Y := MapOffset.Y - ry; // Выход за границы: - if MapOffset.X < 0 then - MapOffset.X := 0; - if MapOffset.Y < 0 then - MapOffset.Y := 0; + if MapOffset.X < MainForm.sbHorizontal.Min then + MapOffset.X := MainForm.sbHorizontal.Min; + if MapOffset.Y < MainForm.sbVertical.Min then + MapOffset.Y := MainForm.sbVertical.Min; if MapOffset.X > MainForm.sbHorizontal.Max then MapOffset.X := MainForm.sbHorizontal.Max; if MapOffset.Y > MainForm.sbVertical.Max then MapOffset.Y := MainForm.sbVertical.Max; // Кратно 16: - MapOffset.X := Normalize16(MapOffset.X); - MapOffset.Y := Normalize16(MapOffset.Y); + // MapOffset.X := Normalize16(MapOffset.X); + // MapOffset.Y := Normalize16(MapOffset.Y); end; MainForm.sbHorizontal.Position := MapOffset.X; @@ -2853,12 +2853,22 @@ begin else a := 0; - for x := 0 to (RenderPanel.Width div DotStep) do - for y := 0 to (RenderPanel.Height div DotStep) do - e_DrawPoint(DotSize, x*DotStep + a, y*DotStep + a, + x := MapOffset.X mod DotStep; + y := MapOffset.Y mod DotStep; + + while x < RenderPanel.Width do + begin + while y < RenderPanel.Height do + begin + e_DrawPoint(DotSize, x + a, y + a, GetRValue(DotColor), GetGValue(DotColor), GetBValue(DotColor)); + y += DotStep; + end; + x += DotStep; + y := MapOffset.Y mod DotStep; + end; end; // Превью текстуры: @@ -3109,18 +3119,13 @@ procedure TMainForm.FormResize(Sender: TObject); begin e_SetViewPort(0, 0, RenderPanel.Width, RenderPanel.Height); - if gMapInfo.Width >= RenderPanel.Width then - sbHorizontal.Max := Normalize16(gMapInfo.Width-RenderPanel.Width+16) - else - sbHorizontal.Max := 0; - - if gMapInfo.Height >= RenderPanel.Height then - sbVertical.Max := Normalize16(gMapInfo.Height-RenderPanel.Height+16) - else - sbVertical.Max := 0; + sbHorizontal.Min := Min(gMapInfo.Width - RenderPanel.Width, -RenderPanel.Width div 2); + sbHorizontal.Max := Max(0, gMapInfo.Width - RenderPanel.Width div 2); + sbVertical.Min := Min(gMapInfo.Height - RenderPanel.Height, -RenderPanel.Height div 2); + sbVertical.Max := Max(0, gMapInfo.Height - RenderPanel.Height div 2); - MapOffset.X := -Normalize16(sbHorizontal.Position); - MapOffset.Y := -Normalize16(sbVertical.Position); + MapOffset.X := -sbHorizontal.Position; + MapOffset.Y := -sbVertical.Position; end; procedure SelectNextObject(X, Y: Integer; ObjectType: Byte; ID: DWORD); @@ -4100,8 +4105,8 @@ begin end else begin // Кнопки мыши не зажаты - MousePos.X := (Round(X/sX)*sX); - MousePos.Y := (Round(Y/sY)*sY); + MousePos.X := Round((-MapOffset.X + X) / sX) * sX + MapOffset.X; + MousePos.Y := Round((-MapOffset.Y + Y) / sY) * sY + MapOffset.Y; end; // Изменение размера закончилось - ставим обычный курсор: @@ -4406,34 +4411,42 @@ begin begin if Key = Ord('W') then begin - if (MouseLDown or MouseRDown) and (Position >= DotStep) then + dy := Position; + if ssShift in Shift then Position := EnsureRange(Position - DotStep * 4, Min, Max) + else Position := EnsureRange(Position - DotStep, Min, Max); + MapOffset.Y := -Position; + dy -= Position; + + if (MouseLDown or MouseRDown) then begin if DrawRect <> nil then begin - Inc(MouseLDownPos.y, DotStep); - Inc(MouseRDownPos.y, DotStep); + Inc(MouseLDownPos.y, dy); + Inc(MouseRDownPos.y, dy); end; - Inc(LastMovePoint.Y, DotStep); + Inc(LastMovePoint.Y, dy); RenderPanelMouseMove(Sender, Shift, RenderMousePos().X, RenderMousePos().Y); end; - Position := IfThen(Position > DotStep, Position-DotStep, 0); - MapOffset.Y := -Round(Position/16) * 16; end; if Key = Ord('S') then begin - if (MouseLDown or MouseRDown) and (Position+DotStep <= Max) then + dy := Position; + if ssShift in Shift then Position := EnsureRange(Position + DotStep * 4, Min, Max) + else Position := EnsureRange(Position + DotStep, Min, Max); + MapOffset.Y := -Position; + dy -= Position; + + if (MouseLDown or MouseRDown) then begin if DrawRect <> nil then begin - Dec(MouseLDownPos.y, DotStep); - Dec(MouseRDownPos.y, DotStep); + Inc(MouseLDownPos.y, dy); + Inc(MouseRDownPos.y, dy); end; - Dec(LastMovePoint.Y, DotStep); + Inc(LastMovePoint.Y, dy); RenderPanelMouseMove(Sender, Shift, RenderMousePos().X, RenderMousePos().Y); end; - Position := IfThen(Position+DotStep < Max, Position+DotStep, Max); - MapOffset.Y := -Round(Position/16) * 16; end; end; @@ -4442,34 +4455,42 @@ begin begin if Key = Ord('A') then begin - if (MouseLDown or MouseRDown) and (Position >= DotStep) then + dx := Position; + if ssShift in Shift then Position := EnsureRange(Position - DotStep * 4, Min, Max) + else Position := EnsureRange(Position - DotStep, Min, Max); + MapOffset.X := -Position; + dx -= Position; + + if (MouseLDown or MouseRDown) then begin if DrawRect <> nil then begin - Inc(MouseLDownPos.x, DotStep); - Inc(MouseRDownPos.x, DotStep); + Inc(MouseLDownPos.x, dx); + Inc(MouseRDownPos.x, dx); end; - Inc(LastMovePoint.X, DotStep); + Inc(LastMovePoint.X, dx); RenderPanelMouseMove(Sender, Shift, RenderMousePos().X, RenderMousePos().Y); end; - Position := IfThen(Position > DotStep, Position-DotStep, 0); - MapOffset.X := -Round(Position/16) * 16; end; if Key = Ord('D') then begin - if (MouseLDown or MouseRDown) and (Position+DotStep <= Max) then + dx := Position; + if ssShift in Shift then Position := EnsureRange(Position + DotStep * 4, Min, Max) + else Position := EnsureRange(Position + DotStep, Min, Max); + MapOffset.X := -Position; + dx -= Position; + + if (MouseLDown or MouseRDown) then begin if DrawRect <> nil then begin - Dec(MouseLDownPos.x, DotStep); - Dec(MouseRDownPos.x, DotStep); + Inc(MouseLDownPos.x, dx); + Inc(MouseRDownPos.x, dx); end; - Dec(LastMovePoint.X, DotStep); + Inc(LastMovePoint.X, dx); RenderPanelMouseMove(Sender, Shift, RenderMousePos().X, RenderMousePos().Y); end; - Position := IfThen(Position+DotStep < Max, Position+DotStep, Max); - MapOffset.X := -Round(Position/16) * 16; end; end; end @@ -6793,13 +6814,13 @@ end; procedure TMainForm.sbVerticalScroll(Sender: TObject; ScrollCode: TScrollCode; var ScrollPos: Integer); begin - MapOffset.Y := -Normalize16(sbVertical.Position); + MapOffset.Y := -sbVertical.Position; end; procedure TMainForm.sbHorizontalScroll(Sender: TObject; ScrollCode: TScrollCode; var ScrollPos: Integer); begin - MapOffset.X := -Normalize16(sbHorizontal.Position); + MapOffset.X := -sbHorizontal.Position; end; procedure TMainForm.miOpenWadMapClick(Sender: TObject); diff --git a/src/editor/f_options.lfm b/src/editor/f_options.lfm index 3e6cc23..c6e3e9b 100644 --- a/src/editor/f_options.lfm +++ b/src/editor/f_options.lfm @@ -1,6 +1,6 @@ object OptionsForm: TOptionsForm Left = 202 - Height = 285 + Height = 300 Top = 174 Width = 435 BorderIcons = [biSystemMenu] @@ -124,8 +124,8 @@ object OptionsForm: TOptionsForm Top = 74 Width = 12 Associate = eDotStepOne - Max = 255 - Min = 2 + Max = 2048 + Min = 4 Position = 16 TabOrder = 4 Wrap = False @@ -230,8 +230,8 @@ object OptionsForm: TOptionsForm Top = 98 Width = 12 Associate = eDotStepTwo - Max = 255 - Min = 2 + Max = 2048 + Min = 4 Position = 8 TabOrder = 6 Wrap = False diff --git a/src/editor/f_options.pas b/src/editor/f_options.pas index 8a77b18..91cc695 100644 --- a/src/editor/f_options.pas +++ b/src/editor/f_options.pas @@ -7,7 +7,7 @@ interface uses LCLIntf, LCLType, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, - ExtCtrls, ComCtrls, Registry; + ExtCtrls, ComCtrls, Registry, Math; type @@ -182,8 +182,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 -- 2.29.2 From acc4fbaaecd9113aa28251b5137522f3571e6231 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Sat, 30 Nov 2019 14:31:23 +0300 Subject: [PATCH 07/16] more portable texture/sky preview --- src/editor/f_addresource_sky.pas | 42 +++++++------------ src/editor/f_addresource_texture.pas | 60 ++++++++++------------------ 2 files changed, 37 insertions(+), 65 deletions(-) diff --git a/src/editor/f_addresource_sky.pas b/src/editor/f_addresource_sky.pas index 79362df..e4a0f44 100644 --- a/src/editor/f_addresource_sky.pas +++ b/src/editor/f_addresource_sky.pas @@ -40,7 +40,6 @@ var img: TImageData; clr: TColor32Rec; bgc: TColor32Rec; - ii: PByte; Width, Height: Integer; x, y: Integer; @@ -68,47 +67,36 @@ begin Width := img.width; Height := img.height; - BitMap := TBitMap.Create(); BitMap.PixelFormat := pf24bit; - BitMap.Width := Width; BitMap.Height := Height; - -// Копируем в BitMap: - ii := BitMap.RawImage.Data; - for y := 0 to height-1 do + for y := 0 to height - 1 do begin - for x := 0 to width-1 do + for x := 0 to width - 1 do begin clr := GetPixel32(img, x, y); // HACK: Lazarus's TBitMap doesn't seem to have a working 32 bit mode, so // mix color with checkered background. Also, can't really read // CHECKERS.tga from here. FUCK! if UseCheckerboard then - begin - if (((x shr 3) and 1) = 0) xor (((y shr 3) and 1) = 0) then - bgc.Color := $FDFDFD - else - bgc.Color := $CBCBCB; - end + begin + if (((x shr 3) and 1) = 0) xor (((y shr 3) and 1) = 0) then + bgc.Color := $FDFDFD + else + bgc.Color := $CBCBCB + end else - begin - bgc.r := GetRValue(PreviewColor); - bgc.g := GetGValue(PreviewColor); - bgc.b := GetBValue(PreviewColor); - end; + begin + bgc.r := GetRValue(PreviewColor); + bgc.g := GetGValue(PreviewColor); + bgc.b := GetBValue(PreviewColor) + end; clr.r := ClampToByte((Byte(255 - clr.a) * bgc.r + clr.a * clr.r) div 255); clr.g := ClampToByte((Byte(255 - clr.a) * bgc.g + clr.a * clr.g) div 255); clr.b := ClampToByte((Byte(255 - clr.a) * bgc.b + clr.a * clr.b) div 255); - // TODO: check for RGB/BGR somehow? - ii^ := clr.b; Inc(ii); - ii^ := clr.g; Inc(ii); - ii^ := clr.r; Inc(ii); - - (* Why this works in linux? *) - {$IFNDEF WINDOWS}Inc(ii){$ENDIF} - end; + BitMap.Canvas.Pixels[x, y] := RGBToColor(clr.r, clr.g, clr.b) + end end; FreeMem(TextureData); FreeImage(img); diff --git a/src/editor/f_addresource_texture.pas b/src/editor/f_addresource_texture.pas index 62d0fd5..cdd0621 100644 --- a/src/editor/f_addresource_texture.pas +++ b/src/editor/f_addresource_texture.pas @@ -93,67 +93,51 @@ begin end end; -function CreateBitMap(Data: Pointer; DataSize: Cardinal): TBitMap; +function CreateBitMap (Data: Pointer; DataSize: Cardinal): TBitMap; var - img: TImageData; - clr: TColor32Rec; - bgc: TColor32Rec; - ii: PByte; - Width, - Height: Integer; - x, y: Integer; - BitMap: TBitMap; - + img: TImageData; + clr, bgc: TColor32Rec; + Width, Height: Integer; + x, y: Integer; + BitMap: TBitMap; begin Result := nil; - InitImage(img); if not LoadImageFromMemory(Data, DataSize, img) then Exit; Width := img.width; Height := img.height; - BitMap := TBitMap.Create(); - BitMap.PixelFormat := pf24bit; - + BitMap.PixelFormat := pf24bit; BitMap.Width := Width; BitMap.Height := Height; - -// Копируем в BitMap: - ii := BitMap.RawImage.Data; - for y := 0 to height-1 do + for y := 0 to Height - 1 do begin - for x := 0 to width-1 do + for x := 0 to Width - 1 do begin clr := GetPixel32(img, x, y); // HACK: Lazarus's TBitMap doesn't seem to have a working 32 bit mode, so // mix color with checkered background. Also, can't really read // CHECKERS.tga from here. FUCK! if UseCheckerboard then - begin - if (((x shr 3) and 1) = 0) xor (((y shr 3) and 1) = 0) then - bgc.Color := $FDFDFD - else - bgc.Color := $CBCBCB; - end + begin + if (((x shr 3) and 1) = 0) xor (((y shr 3) and 1) = 0) then + bgc.Color := $FDFDFD + else + bgc.Color := $CBCBCB + end else - begin - bgc.r := GetRValue(PreviewColor); - bgc.g := GetGValue(PreviewColor); - bgc.b := GetBValue(PreviewColor); - end; + begin + bgc.r := GetRValue(PreviewColor); + bgc.g := GetGValue(PreviewColor); + bgc.b := GetBValue(PreviewColor) + end; clr.r := ClampToByte((Byte(255 - clr.a) * bgc.r + clr.a * clr.r) div 255); clr.g := ClampToByte((Byte(255 - clr.a) * bgc.g + clr.a * clr.g) div 255); clr.b := ClampToByte((Byte(255 - clr.a) * bgc.b + clr.a * clr.b) div 255); - // TODO: check for RGB/BGR somehow? - ii^ := clr.b; Inc(ii); - ii^ := clr.g; Inc(ii); - ii^ := clr.r; Inc(ii); - - (* Why this works in linux? *) - {$IFNDEF WINDOWS}Inc(ii){$ENDIF} - end; + BitMap.Canvas.Pixels[x, y] := RGBToColor(clr.r, clr.g, clr.b) + end end; FreeImage(img); Result := BitMap; -- 2.29.2 From f9041cfd23f3f5eff7e56f2960c7a571bb3c4607 Mon Sep 17 00:00:00 2001 From: Joseph Stalin Date: Sat, 30 Nov 2019 19:39:39 +0500 Subject: [PATCH 08/16] Darken everything beyond map borders Also finally "fixed" editor options form. Yay. --- src/editor/f_options.lfm | 12 ++++++------ src/editor/g_map.pas | 28 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/editor/f_options.lfm b/src/editor/f_options.lfm index c6e3e9b..f82ccf8 100644 --- a/src/editor/f_options.lfm +++ b/src/editor/f_options.lfm @@ -1,12 +1,12 @@ object OptionsForm: TOptionsForm Left = 202 - Height = 300 + Height = 310 Top = 174 Width = 435 BorderIcons = [biSystemMenu] BorderStyle = bsSingle Caption = 'Настройки редактора' - ClientHeight = 285 + ClientHeight = 310 ClientWidth = 435 Color = clBtnFace Font.Color = clWindowText @@ -17,10 +17,10 @@ object OptionsForm: TOptionsForm LCLVersion = '1.8.4.0' object GroupBox1: TGroupBox Left = 8 - Height = 248 + Height = 272 Top = 0 Width = 425 - ClientHeight = 246 + ClientHeight = 272 ClientWidth = 423 TabOrder = 0 object sDotColor: TShape @@ -298,7 +298,7 @@ object OptionsForm: TOptionsForm object bOK: TButton Left = 262 Height = 25 - Top = 256 + Top = 280 Width = 75 Caption = 'ОК' Default = True @@ -308,7 +308,7 @@ object OptionsForm: TOptionsForm object bCancel: TButton Left = 358 Height = 25 - Top = 256 + Top = 280 Width = 75 Cancel = True Caption = 'Отмена' diff --git a/src/editor/g_map.pas b/src/editor/g_map.pas index 2f1435c..6c6f191 100644 --- a/src/editor/g_map.pas +++ b/src/editor/g_map.pas @@ -2720,25 +2720,25 @@ begin // Границы карты: if PreviewMode = 0 then begin - e_DrawFillQuad(-32+MapOffset.X, - -32+MapOffset.Y, - gMapInfo.Width+31+MapOffset.X, - -1+MapOffset.Y, + e_DrawFillQuad(0, + 0, + MainForm.RenderPanel.Width, + -1 + MapOffset.Y, drEdge[0], drEdge[1], drEdge[2], drEdge[3], B_NONE); // Top - e_DrawFillQuad(-32+MapOffset.X, - gMapInfo.Height+MapOffset.Y, - gMapInfo.Width+31+MapOffset.X, - gMapInfo.Height+31+MapOffset.Y, + e_DrawFillQuad(0, + gMapInfo.Height + MapOffset.Y, + MainForm.RenderPanel.Width, + MainForm.RenderPanel.Height, drEdge[0], drEdge[1], drEdge[2], drEdge[3], B_NONE); // Bottom - e_DrawFillQuad(-32+MapOffset.X, + e_DrawFillQuad(0, MapOffset.Y, - -1+MapOffset.X, - gMapInfo.Height+MapOffset.Y-1, + -1 + MapOffset.X, + gMapInfo.Height + MapOffset.Y - 1, drEdge[0], drEdge[1], drEdge[2], drEdge[3], B_NONE); // Left - e_DrawFillQuad(gMapInfo.Width+MapOffset.X, + e_DrawFillQuad(gMapInfo.Width + MapOffset.X, MapOffset.Y, - gMapInfo.Width+31+MapOffset.X, - gMapInfo.Height+MapOffset.Y-1, + MainForm.RenderPanel.Width, + gMapInfo.Height + MapOffset.Y - 1, drEdge[0], drEdge[1], drEdge[2], drEdge[3], B_NONE); // Right end; end; -- 2.29.2 From 45810fb687edbe574a027520711f3dab3d880e21 Mon Sep 17 00:00:00 2001 From: Joseph Stalin Date: Mon, 2 Dec 2019 04:16:40 +0500 Subject: [PATCH 09/16] Add more formats to Map Open/Save/Pack dialogs --- src/editor/f_main.lfm | 4 ++-- src/editor/f_packmap.lfm | 2 +- src/editor/g_language.pas | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/editor/f_main.lfm b/src/editor/f_main.lfm index 4eae45a..b568cbc 100644 --- a/src/editor/f_main.lfm +++ b/src/editor/f_main.lfm @@ -748,7 +748,7 @@ object MainForm: TMainForm end object OpenDialog: TOpenDialog DefaultExt = '.dfz' - Filter = 'Карты Doom 2D: Forever (*.dfz, *.wad)|*.dfz;*.wad|Старые карты Doom 2D: Forever 0.30 (*.ini)|*.ini|Все файлы (*.*)|*.*' + Filter = 'Карты Doom 2D: Forever (*.dfz, *.dfzip, *.zip, *.wad)|*.dfz;*.dfzip;*.zip;*.wad|Старые карты Doom 2D: Forever 0.30 (*.ini)|*.ini|Все файлы (*.*)|*.*' Options = [ofHideReadOnly, ofNoChangeDir, ofPathMustExist, ofFileMustExist, ofEnableSizing, ofDontAddToRecent] left = 32 top = 64 @@ -1722,7 +1722,7 @@ object MainForm: TMainForm end object SaveDialog: TSaveDialog DefaultExt = '.dfz' - Filter = 'Карты Doom 2D: Forever (*.dfz)|*.dfz|Карты Doom 2D: Forever (*.wad)|Все файлы (*.*)|*.*' + Filter = 'Карты Doom 2D: Forever (*.dfz)|*.dfz|Карты Doom 2D: Forever (*.dfzip)|*.dfzip|Карты Doom 2D: Forever (*.zip)|*.zip|Карты Doom 2D: Forever (*.wad)|*.wad|Все файлы (*.*)|*.*' Options = [ofHideReadOnly, ofNoChangeDir, ofPathMustExist, ofNoReadOnlyReturn, ofEnableSizing, ofDontAddToRecent] left = 64 top = 64 diff --git a/src/editor/f_packmap.lfm b/src/editor/f_packmap.lfm index f5babda..9a6db34 100644 --- a/src/editor/f_packmap.lfm +++ b/src/editor/f_packmap.lfm @@ -178,7 +178,7 @@ object PackMapForm: TPackMapForm end object SaveDialog: TSaveDialog DefaultExt = '.dfz' - Filter = 'Карты Doom2D: Forever (*.wad)|*.wad|All files (*.*)|*.*' + Filter = 'Карты Doom 2D: Forever (*.dfz)|*.dfz|Карты Doom 2D: Forever (*.dfzip)|*.dfzip|Карты Doom 2D: Forever (*.zip)|*.zip|Карты Doom2D: Forever (*.wad)|*.wad|All files (*.*)|*.*' Options = [ofHideReadOnly, ofPathMustExist, ofEnableSizing, ofDontAddToRecent] left = 8 top = 200 diff --git a/src/editor/g_language.pas b/src/editor/g_language.pas index 0ba24c1..e2c0a34 100644 --- a/src/editor/g_language.pas +++ b/src/editor/g_language.pas @@ -1829,10 +1829,10 @@ Const ('WAD SPECIAL TEXS', '', '<СПЕЦТЕКСТУРЫ>'), - ('FILE FILTER ALL', 'Doom 2D: Forever Maps (*.dfz, *.wad)|*.dfz;*.wad|Doom 2D: Forever 0.30 Maps (*.ini)|*.ini|Все файлы (*.*)|*.*', - 'Карты Doom 2D: Forever (*.dfz, *.wad)|*.dfz;*.wad|Старые карты Doom 2D: Forever 0.30 (*.ini)|*.ini|Все файлы (*.*)|*.*'), - ('FILE FILTER WAD', 'Doom 2D: Forever Maps (*.dfz)|*.dfz|Doom 2D: Forever Maps (*.wad)|*.wad|Все файлы (*.*)|*.*', - 'Карты Doom 2D: Forever (*.dfz)|*.dfz|Карты Doom 2D: Forever (*.wad)|*.wad|Все файлы (*.*)|*.*'), + ('FILE FILTER ALL', 'Doom 2D: Forever Maps (*.dfz, *.dfzip, *.zip, *.wad)|*.dfz;*.dfzip;*.zip;*.wad|Doom 2D: Forever 0.30 Maps (*.ini)|*.ini|All Files (*.*)|*.*', + 'Карты Doom 2D: Forever (*.dfz, *.dfzip, *.zip, *.wad)|*.dfz;*.dfzip;*.zip;*.wad|Старые карты Doom 2D: Forever 0.30 (*.ini)|*.ini|Все файлы (*.*)|*.*'), + ('FILE FILTER WAD', 'Doom 2D: Forever Maps (*.dfz)|*.dfz|Doom 2D: Forever Maps (*.dfzip)|*.dfzip|Doom 2D: Forever Maps (*.zip)|*.zip|Doom 2D: Forever Maps (*.wad)|*.wad|All Files (*.*)|*.*', + 'Карты Doom 2D: Forever (*.dfz)|*.dfz|Карты Doom 2D: Forever (*.dfzip)|*.dfzip|Карты Doom 2D: Forever (*.zip)|*.zip|Карты Doom 2D: Forever (*.wad)|*.wad|Все файлы (*.*)|*.*'), ('EDITOR TITLE', 'Doom 2D: Forever Map Editor', 'Редактор карт Doom 2D: Forever'), -- 2.29.2 From 69266ae60d7e68ff22673e3fe1ebad8236658aee Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Mon, 2 Dec 2019 17:16:12 +0300 Subject: [PATCH 10/16] allow to open any wad type from recent files --- src/editor/f_main.pas | 48 +++++--------- src/shared/wadreader.pas | 136 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+), 33 deletions(-) create mode 100644 src/shared/wadreader.pas diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index 7282c78..ca14ebe 100644 --- a/src/editor/f_main.pas +++ b/src/editor/f_main.pas @@ -337,7 +337,7 @@ uses f_options, e_graphics, e_log, GL, Math, f_mapoptions, g_basic, f_about, f_mapoptimization, f_mapcheck, f_addresource_texture, g_textures, - f_activationtype, f_keys, + f_activationtype, f_keys, wadreader, MAPREADER, f_selectmap, f_savemap, WADEDITOR, MAPDEF, g_map, f_saveminimap, f_addresource, CONFIG, f_packmap, f_addresource_sound, f_maptest, f_choosetype, @@ -2583,45 +2583,27 @@ end; procedure TMainForm.aRecentFileExecute(Sender: TObject); var - n, pw: Integer; - s, fn: String; - b: Boolean; + n: Integer; + fn, s: String; begin s := LowerCase((Sender as TMenuItem).Caption); Delete(s, Pos('&', s), 1); s := Trim(Copy(s, 1, 2)); n := StrToIntDef(s, 0) - 1; - - if (n < 0) or (n >= RecentFiles.Count) then - Exit; - - s := RecentFiles[n]; - pw := Pos('.wad:\', LowerCase(s)); - b := False; - - if pw > 0 then - begin // Map name included - fn := Copy(s, 1, pw + 3); - Delete(s, 1, pw + 5); - if (FileExists(fn)) then - begin - OpenMap(fn, s); - b := True; - end; + if (n >= 0) and (n <= RecentFiles.Count) then + begin + fn := g_ExtractWadName(RecentFiles[n]); + if FileExists(fn) then + begin + s := g_ExtractFilePathName(RecentFiles[n]); + OpenMap(fn, s) end - else // Only wad name - if (FileExists(s)) then + else if MessageBox(0, PChar(_lc[I_MSG_DEL_RECENT_PROMT]), PChar(_lc[I_MSG_DEL_RECENT]), MB_ICONQUESTION or MB_YESNO) = idYes then begin - OpenMap(s, ''); - b := True; - end; - - if (not b) and (MessageBox(0, PChar(_lc[I_MSG_DEL_RECENT_PROMT]), - PChar(_lc[I_MSG_DEL_RECENT]), MB_ICONQUESTION or MB_YESNO) = idYes) then - begin - RecentFiles.Delete(n); - RefreshRecentMenu(); - end; + RecentFiles.Delete(n); + RefreshRecentMenu(); + end + end end; procedure TMainForm.aEditorOptionsExecute(Sender: TObject); diff --git a/src/shared/wadreader.pas b/src/shared/wadreader.pas new file mode 100644 index 0000000..72dc64b --- /dev/null +++ b/src/shared/wadreader.pas @@ -0,0 +1,136 @@ +(* Copyright (C) Doom 2D: Forever Developers + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License ONLY. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *) +{$INCLUDE a_modes.inc} +unit wadreader; + +interface + +// g_ExtractWadName C:\svr\shit.wad:\MAPS\MAP01 -> C:/svr/shit.wad +function g_ExtractWadName (resourceStr: AnsiString): AnsiString; + +// g_ExtractWadNameNoPath C:\svr\shit.wad:\MAPS\MAP01 -> shit.wad +function g_ExtractWadNameNoPath (resourceStr: AnsiString): AnsiString; + +// g_ExtractFilePath C:\svr\shit.wad:\MAPS\MAP01 -> :/MAPS +function g_ExtractFilePath (resourceStr: AnsiString): AnsiString; + +// g_ExtractFileName C:\svr\shit.wad:\MAPS\MAP01 -> MAP01 +function g_ExtractFileName (resourceStr: AnsiString): AnsiString; // without path + +// g_ExtractFilePathName C:\svr\shit.wad:\MAPS\MAP01 -> MAPS/MAP01 +function g_ExtractFilePathName (resourceStr: AnsiString): AnsiString; + +implementation + +function normSlashes (s: AnsiString): AnsiString; +var + f: Integer; +begin + for f := 1 to length(s) do if s[f] = '\' then s[f] := '/'; + result := s; +end; + +function g_ExtractWadNameNoPath (resourceStr: AnsiString): AnsiString; +var + f, c: Integer; +begin + for f := length(resourceStr) downto 1 do + begin + if resourceStr[f] = ':' then + begin + result := normSlashes(Copy(resourceStr, 1, f-1)); + c := length(result); + while (c > 0) and (result[c] <> '/') do Dec(c); + if c > 0 then result := Copy(result, c+1, length(result)); + exit; + end; + end; + result := ''; +end; + +function g_ExtractWadName (resourceStr: AnsiString): AnsiString; +var + f: Integer; +begin + for f := length(resourceStr) downto 1 do + begin + if resourceStr[f] = ':' then + begin + result := normSlashes(Copy(resourceStr, 1, f-1)); + exit; + end; + end; + result := ''; +end; + +function g_ExtractFilePath (resourceStr: AnsiString): AnsiString; +var + f, lastSlash: Integer; +begin + result := ''; + lastSlash := -1; + for f := length(resourceStr) downto 1 do + begin + if (lastSlash < 0) and (resourceStr[f] = '\') or (resourceStr[f] = '/') then lastSlash := f; + if resourceStr[f] = ':' then + begin + if lastSlash > 0 then + begin + result := normSlashes(Copy(resourceStr, f, lastSlash-f)); + while (length(result) > 0) and (result[1] = '/') do Delete(result, 1, 1); + end; + exit; + end; + end; + if lastSlash > 0 then result := normSlashes(Copy(resourceStr, 1, lastSlash-1)); +end; + +function g_ExtractFileName (resourceStr: AnsiString): AnsiString; // without path +var + f, lastSlash: Integer; +begin + result := ''; + lastSlash := -1; + for f := length(resourceStr) downto 1 do + begin + if (lastSlash < 0) and (resourceStr[f] = '\') or (resourceStr[f] = '/') then lastSlash := f; + if resourceStr[f] = ':' then + begin + if lastSlash > 0 then result := Copy(resourceStr, lastSlash+1, length(resourceStr)); + exit; + end; + end; + if lastSlash > 0 then result := Copy(resourceStr, lastSlash+1, length(resourceStr)); +end; + +function g_ExtractFilePathName (resourceStr: AnsiString): AnsiString; +var + f: Integer; +begin + result := ''; + for f := length(resourceStr) downto 1 do + begin + if resourceStr[f] = ':' then + begin + result := normSlashes(Copy(resourceStr, f+1, length(resourceStr))); + while (length(result) > 0) and (result[1] = '/') do Delete(result, 1, 1); + exit; + end; + end; + result := normSlashes(resourceStr); + while (length(result) > 0) and (result[1] = '/') do Delete(result, 1, 1); +end; + +end. -- 2.29.2 From f8e97692d89c62868c4cc460f605b675f9d21fdf Mon Sep 17 00:00:00 2001 From: Joseph Stalin Date: Mon, 2 Dec 2019 19:45:37 +0500 Subject: [PATCH 11/16] Implemented Middle Mouse Button panning --- src/editor/f_main.pas | 53 +++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index ca14ebe..d2f7b2e 100644 --- a/src/editor/f_main.pas +++ b/src/editor/f_main.pas @@ -442,8 +442,10 @@ var LastMovePoint: Types.TPoint; MouseLDown: Boolean; MouseRDown: Boolean; + MouseMDown: Boolean; MouseLDownPos: Types.TPoint; MouseRDownPos: Types.TPoint; + MouseMDownPos: Types.TPoint; SelectFlag: Byte = SELECTFLAG_NONE; MouseAction: Byte = MOUSEACTION_NONE; @@ -706,14 +708,8 @@ begin MapOffset.X := MapOffset.X - rx; MapOffset.Y := MapOffset.Y - ry; // Выход за границы: - if MapOffset.X < MainForm.sbHorizontal.Min then - MapOffset.X := MainForm.sbHorizontal.Min; - if MapOffset.Y < MainForm.sbVertical.Min then - MapOffset.Y := MainForm.sbVertical.Min; - if MapOffset.X > MainForm.sbHorizontal.Max then - MapOffset.X := MainForm.sbHorizontal.Max; - if MapOffset.Y > MainForm.sbVertical.Max then - MapOffset.Y := MainForm.sbVertical.Max; + MapOffset.X := EnsureRange(MapOffset.X, MainForm.sbHorizontal.Min, MainForm.sbHorizontal.Max); + MapOffset.Y := EnsureRange(MapOffset.Y, MainForm.sbVertical.Min, MainForm.sbVertical.Max); // Кратно 16: // MapOffset.X := Normalize16(MapOffset.X); // MapOffset.Y := Normalize16(MapOffset.Y); @@ -3598,6 +3594,16 @@ begin end; end; // if Button = mbRight + if Button = mbMiddle then // Middle Mouse Button + begin + SetCapture(RenderPanel.Handle); + RenderPanel.Cursor := crSize; + end; + + MouseMDown := Button = mbMiddle; + if MouseMDown then + MouseMDownPos := Mouse.CursorPos; + MouseRDown := Button = mbRight; if MouseRDown then MouseRDownPos := MousePos; @@ -3635,6 +3641,8 @@ begin MouseLDown := False; if Button = mbRight then MouseRDown := False; + if Button = mbMiddle then + MouseMDown := False; DrawRect := nil; ResizeType := RESIZETYPE_NONE; @@ -3944,7 +3952,7 @@ begin MouseAction := MOUSEACTION_NONE; end; end // if Button = mbLeft... - else // Right Mouse Button: + else if Button = mbRight then // Right Mouse Button: begin if MouseAction = MOUSEACTION_NOACTION then begin @@ -3955,6 +3963,7 @@ begin // Объект передвинут или изменен в размере: if MouseAction in [MOUSEACTION_MOVEOBJ, MOUSEACTION_RESIZE] then begin + RenderPanel.Cursor := crDefault; MouseAction := MOUSEACTION_NONE; FillProperty(); Exit; @@ -4007,6 +4016,12 @@ begin SelectObjects(pcObjects.ActivePageIndex+1); FillProperty(); + end + + else // Middle Mouse Button + begin + RenderPanel.Cursor := crDefault; + ReleaseCapture(); end; end; @@ -4091,12 +4106,8 @@ begin MousePos.Y := Round((-MapOffset.Y + Y) / sY) * sY + MapOffset.Y; end; -// Изменение размера закончилось - ставим обычный курсор: - if ResizeType = RESIZETYPE_NONE then - RenderPanel.Cursor := crDefault; - // Зажата только правая кнопка мыши: - if (not MouseLDown) and (MouseRDown) then + if (not MouseLDown) and (MouseRDown) and (not MouseMDown) then begin // Рисуем прямоугольник выделения: if MouseAction = MOUSEACTION_NONE then @@ -4145,7 +4156,7 @@ begin end; // Зажата только левая кнопка мыши: - if (not MouseRDown) and (MouseLDown) then + if (not MouseRDown) and (MouseLDown) and (not MouseMDown) then begin // Рисуем прямоугольник планирования панели: if MouseAction in [MOUSEACTION_DRAWPANEL, @@ -4185,6 +4196,18 @@ begin end; end; +// Only Middle Mouse Button is pressed + if (not MouseLDown) and (not MouseRDown) and (MouseMDown) then + begin + MapOffset.X := -EnsureRange(-MapOffset.X + MouseMDownPos.X - Mouse.CursorPos.X, + sbHorizontal.Min, sbHorizontal.Max); + sbHorizontal.Position := -MapOffset.X; + MapOffset.Y := -EnsureRange(-MapOffset.Y + MouseMDownPos.Y - Mouse.CursorPos.Y, + sbVertical.Min, sbVertical.Max); + sbVertical.Position := -MapOffset.Y; + MouseMDownPos := Mouse.CursorPos; + end; + // Клавиши мыши не зажаты: if (not MouseRDown) and (not MouseLDown) then DrawRect := nil; -- 2.29.2 From 4b7a983868b2447702b82c0077bce1cb70cdc72b Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Mon, 2 Dec 2019 17:46:40 +0300 Subject: [PATCH 12/16] always save temp map before test --- src/editor/f_main.pas | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index d2f7b2e..4498ee9 100644 --- a/src/editor/f_main.pas +++ b/src/editor/f_main.pas @@ -6728,21 +6728,13 @@ end; procedure TMainForm.miTestMapClick(Sender: TObject); var - mapWAD, mapToRun, tempWAD: String; + mapWAD, tempWAD: String; args: SSArray; opt: LongWord; time, i: Integer; proc: TProcessUTF8; res: Boolean; begin - mapToRun := ''; - if OpenedMap <> '' then - begin - // Указываем текущую карту для теста: - g_ProcessResourceStr(OpenedMap, @mapWAD, nil, @mapToRun); - mapToRun := mapWAD + ':\' + mapToRun; - mapToRun := ExtractRelativePath(ExtractFilePath(TestD2dExe) + 'maps/', mapToRun); - end; // Сохраняем временную карту: time := 0; repeat @@ -6751,11 +6743,7 @@ begin until not FileExists(mapWAD); tempWAD := mapWAD + ':\' + TEST_MAP_NAME; SaveMap(tempWAD); - tempWAD := ExtractRelativePath(ExtractFilePath(TestD2dExe) + 'maps/', tempWAD); -// Если карта не была открыта, указываем временную в качестве текущей: - if mapToRun = '' then - mapToRun := tempWAD; // Опции игры: opt := 32 + 64; @@ -6774,7 +6762,7 @@ begin proc := TProcessUTF8.Create(nil); proc.Executable := TestD2dExe; proc.Parameters.Add('-map'); - proc.Parameters.Add(mapToRun); + proc.Parameters.Add(tempWAD); proc.Parameters.Add('-testmap'); proc.Parameters.Add(tempWAD); proc.Parameters.Add('-gm'); -- 2.29.2 From 7105f91988f424587dd22f78f4d9c56b108e82e6 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Thu, 5 Dec 2019 17:05:48 +0300 Subject: [PATCH 13/16] copy map resources before test map --- src/editor/f_main.pas | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index 4498ee9..5a246b1 100644 --- a/src/editor/f_main.pas +++ b/src/editor/f_main.pas @@ -337,7 +337,7 @@ uses f_options, e_graphics, e_log, GL, Math, f_mapoptions, g_basic, f_about, f_mapoptimization, f_mapcheck, f_addresource_texture, g_textures, - f_activationtype, f_keys, wadreader, + f_activationtype, f_keys, wadreader, fileutil, MAPREADER, f_selectmap, f_savemap, WADEDITOR, MAPDEF, g_map, f_saveminimap, f_addresource, CONFIG, f_packmap, f_addresource_sound, f_maptest, f_choosetype, @@ -6728,7 +6728,7 @@ end; procedure TMainForm.miTestMapClick(Sender: TObject); var - mapWAD, tempWAD: String; + newWAD, oldWAD, tempMap: String; args: SSArray; opt: LongWord; time, i: Integer; @@ -6738,12 +6738,18 @@ begin // Сохраняем временную карту: time := 0; repeat - mapWAD := ExtractFilePath(TestD2dExe) + Format('maps/temp%.4d.wad', [time]); + newWAD := ExtractFilePath(TestD2dExe) + Format('maps/temp%.4d.wad', [time]); Inc(time); - until not FileExists(mapWAD); - tempWAD := mapWAD + ':\' + TEST_MAP_NAME; - SaveMap(tempWAD); - tempWAD := ExtractRelativePath(ExtractFilePath(TestD2dExe) + 'maps/', tempWAD); + until not FileExists(newWAD); + if OpenedMap <> '' then + begin + oldWad := g_ExtractWadName(OpenedMap); + if CopyFile(oldWad, newWad) = false then + e_WriteLog('MapTest: unable to copy [' + oldWad + '] to [' + newWad + ']', MSG_WARNING) + end; + tempMap := newWAD + ':\' + TEST_MAP_NAME; + SaveMap(tempMap); + tempMap := ExtractRelativePath(ExtractFilePath(TestD2dExe) + 'maps/', tempMap); // Опции игры: opt := 32 + 64; @@ -6762,9 +6768,7 @@ begin proc := TProcessUTF8.Create(nil); proc.Executable := TestD2dExe; proc.Parameters.Add('-map'); - proc.Parameters.Add(tempWAD); - proc.Parameters.Add('-testmap'); - proc.Parameters.Add(tempWAD); + proc.Parameters.Add(tempMap); proc.Parameters.Add('-gm'); proc.Parameters.Add(TestGameMode); proc.Parameters.Add('-limt'); @@ -6800,7 +6804,7 @@ begin end; proc.Free(); - SysUtils.DeleteFile(mapWAD); + SysUtils.DeleteFile(newWAD); Application.Restore(); end; -- 2.29.2 From e784adbf59a182d6049d259d97ba92b06333b94d Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Thu, 5 Dec 2019 20:16:00 +0300 Subject: [PATCH 14/16] add build info --- src/editor/f_main.pas | 4 ++++ src/editor/g_basic.pas | 35 +++++++++++++++++++++++++++++++++++ src/editor/g_language.pas | 9 +++++---- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index 5a246b1..00802bb 100644 --- a/src/editor/f_main.pas +++ b/src/editor/f_main.pas @@ -2651,6 +2651,10 @@ begin EditorDir := ExtractFilePath(Application.ExeName); e_InitLog(EditorDir+'Editor.log', WM_NEWFILE); + e_WriteLog('Doom 2D: Forever Editor version ' + EDITOR_VERSION, MSG_NOTIFY); + e_WriteLog('Build date: ' + EDITOR_BUILDDATE + ' ' + EDITOR_BUILDTIME, MSG_NOTIFY); + e_WriteLog('Build hash: ' + g_GetBuildHash(), MSG_NOTIFY); + e_WriteLog('Build by: ' + g_GetBuilderName(), MSG_NOTIFY); slInvalidTextures := TStringList.Create; diff --git a/src/editor/g_basic.pas b/src/editor/g_basic.pas index e7d3a71..17254de 100644 --- a/src/editor/g_basic.pas +++ b/src/editor/g_basic.pas @@ -7,6 +7,11 @@ interface uses LCLIntf, LCLType, LMessages; +const + EDITOR_VERSION = '0.667'; + EDITOR_BUILDDATE = {$I %DATE%}; + EDITOR_BUILDTIME = {$I %TIME%}; + Type String16 = String[16]; Char16 = packed array[0..15] of Char; @@ -19,6 +24,9 @@ Type TDirection = (D_LEFT, D_RIGHT); +function g_GetBuilderName (): AnsiString; +function g_GetBuildHash (full: Boolean = True): AnsiString; + function g_Collide(X1, Y1: Integer; Width1, Height1: Word; X2, Y2: Integer; Width2, Height2: Word): Boolean; function g_CollidePoint(X, Y, X2, Y2: Integer; Width, Height: Word): Boolean; @@ -53,6 +61,33 @@ implementation uses Math, g_map, MAPDEF, SysUtils; +{$PUSH} +{$WARN 2054 OFF} // unknwon env var +{$WARN 6018 OFF} // unreachable code +function g_GetBuilderName (): AnsiString; +begin + if {$I %D2DF_BUILD_USER%} <> '' then + result := {$I %D2DF_BUILD_USER%} // custom + else if {$I %USER%} <> '' then + result := {$I %USER%} // unix username + else if {$I %USERNAME%} <> '' then + result := {$I %USERNAME%} // windows username + else + result := 'unknown' +end; + +function g_GetBuildHash (full: Boolean = True): AnsiString; +begin + if {$I %D2DF_BUILD_HASH%} <> '' then + if full then + result := {$I %D2DF_BUILD_HASH%} + else + result := Copy({$I %D2DF_BUILD_HASH%}, 1, 7) + else + result := 'custom build' +end; +{$POP} + procedure g_ChangeDir(var dir: TDirection); begin if dir = D_LEFT then diff --git a/src/editor/g_language.pas b/src/editor/g_language.pas index e2c0a34..af6a857 100644 --- a/src/editor/g_language.pas +++ b/src/editor/g_language.pas @@ -2056,15 +2056,16 @@ begin end; procedure SetupCaptions(); -var - i: Integer; - + var i: Integer; s: AnsiString; begin // Главная форма: with MainForm do begin // Заголовок: - FormCaption := _lc[I_EDITOR_TITLE]; + s := g_GetBuildHash(false); + if s = 'custom build' then + s := s + ' by ' + g_GetBuilderName() + ' ' + EDITOR_BUILDDATE + ' ' + EDITOR_BUILDTIME; + FormCaption := _lc[I_EDITOR_TITLE] + ' (' + s + ')'; i := Pos('-', Caption); if i > 0 then begin -- 2.29.2 From fd99178e87f17fe1416ef9c73278e8a877f8f925 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Sat, 7 Dec 2019 20:22:19 +0300 Subject: [PATCH 15/16] save temp wad with ext from opened wad --- src/editor/f_main.pas | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index 00802bb..225daec 100644 --- a/src/editor/f_main.pas +++ b/src/editor/f_main.pas @@ -6732,7 +6732,7 @@ end; procedure TMainForm.miTestMapClick(Sender: TObject); var - newWAD, oldWAD, tempMap: String; + newWAD, oldWAD, tempMap, ext: String; args: SSArray; opt: LongWord; time, i: Integer; @@ -6742,14 +6742,19 @@ begin // Сохраняем временную карту: time := 0; repeat - newWAD := ExtractFilePath(TestD2dExe) + Format('maps/temp%.4d.wad', [time]); + newWAD := ExtractFilePath(TestD2dExe) + Format('maps/temp%.4d', [time]); Inc(time); until not FileExists(newWAD); if OpenedMap <> '' then begin oldWad := g_ExtractWadName(OpenedMap); + newWad := newWad + ExtractFileExt(oldWad); if CopyFile(oldWad, newWad) = false then e_WriteLog('MapTest: unable to copy [' + oldWad + '] to [' + newWad + ']', MSG_WARNING) + end + else + begin + newWad := newWad + '.wad' end; tempMap := newWAD + ':\' + TEST_MAP_NAME; SaveMap(tempMap); -- 2.29.2 From 53ee9bbf75ec69253d01f1b073ab2a82476cea7e Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Fri, 13 Dec 2019 23:45:34 +0300 Subject: [PATCH 16/16] fix invalid value for TRIGGER_MUSIC.action --- src/editor/f_main.pas | 2 +- src/shared/MAPWRITER.pas | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index 225daec..1d1d2ce 100644 --- a/src/editor/f_main.pas +++ b/src/editor/f_main.pas @@ -5155,7 +5155,7 @@ begin if vleObjectProperty.Values[_lc[I_PROP_TR_MUSIC_ACT]] = _lc[I_PROP_TR_MUSIC_ON] then Data.MusicAction := 1 else - Data.MusicAction := 2; + Data.MusicAction := 0; end; TRIGGER_PUSH: diff --git a/src/shared/MAPWRITER.pas b/src/shared/MAPWRITER.pas index 4c7a637..95a181d 100644 --- a/src/shared/MAPWRITER.pas +++ b/src/shared/MAPWRITER.pas @@ -50,7 +50,7 @@ type implementation uses - BinEditor, SysUtils; + MAPDEF, BinEditor, SysUtils, Math; { TMapWriter } @@ -268,7 +268,8 @@ end; function TMapWriter_1.AddTriggers(Triggers: TTriggersRec1Array): Boolean; var - a, size: LongWord; + a, i, size: LongWord; + tr: ^TTriggerData; begin if Triggers = nil then begin @@ -276,6 +277,15 @@ begin Exit; end; + // fix broken maps + for i := 0 to High(Triggers) do + begin + tr := @Triggers[i].data; + case Triggers[i].TriggerType of + TRIGGER_MUSIC: tr.MusicAction := Min(Max(tr.MusicAction, 0), 1); + end + end; + SetLength(FDataBlocks, Length(FDataBlocks)+1); size := SizeOf(TTriggerRec_1); -- 2.29.2