From 72191f97c8a3cc96c9b71f74998bd199760e1c37 Mon Sep 17 00:00:00 2001 From: KirillGutyrchik Date: Wed, 29 May 2024 08:53:16 +0300 Subject: [PATCH 1/4] Fix binding attached objects in generic --- .../ObjectsTree/UniversalObject/AttachedObjects.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/TechObject/ObjectsTree/UniversalObject/AttachedObjects.cs b/src/TechObject/ObjectsTree/UniversalObject/AttachedObjects.cs index 93a1b4eb..7d078dc1 100644 --- a/src/TechObject/ObjectsTree/UniversalObject/AttachedObjects.cs +++ b/src/TechObject/ObjectsTree/UniversalObject/AttachedObjects.cs @@ -29,8 +29,7 @@ public override bool SetNewValue(string newValue) string oldValue = Value; var thisObjNum = owner?.GlobalNum ?? 0; var isGeneric = owner is GenericTechObject; - List newNumbers = strategy.GetValidTechObjNums(newValue, - thisObjNum, isGeneric); + List newNumbers = strategy.GetValidTechObjNums(newValue, thisObjNum); newValue = string.Join(" ", newNumbers); string sortedValue = MoveNewValuesInTheEndOfString(newValue, @@ -631,8 +630,9 @@ public interface IAttachedObjectsStrategy /// /// Входная строка /// Номер редактируемого объекта + /// Редактируемый объект - типовой /// - List GetValidTechObjNums(string value, int objNum, bool isGeneric); + List GetValidTechObjNums(string value, int objNum, bool isGeneric = false); /// /// Нужно ли инициализировать привязанные объекты @@ -708,7 +708,7 @@ public BaseStrategy(string name, string luaName, /// Номер редактируемого объекта /// - типовой объект public List GetValidTechObjNums(string value, - int selectedObjNum, bool isGeneric) + int selectedObjNum, bool isGeneric = false) { var validNumbers = new List(); List numbers = value.Split(' ') From 64f874ee39dfc92cbe2d3d70df324c3c7b008f67 Mon Sep 17 00:00:00 2001 From: KirillGutyrchik Date: Wed, 29 May 2024 15:40:16 +0300 Subject: [PATCH 2/4] Fix log error attached objects in generic --- src/TechObject/ObjectsTree/UniversalObject/AttachedObjects.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TechObject/ObjectsTree/UniversalObject/AttachedObjects.cs b/src/TechObject/ObjectsTree/UniversalObject/AttachedObjects.cs index 7d078dc1..3ca82f79 100644 --- a/src/TechObject/ObjectsTree/UniversalObject/AttachedObjects.cs +++ b/src/TechObject/ObjectsTree/UniversalObject/AttachedObjects.cs @@ -294,7 +294,7 @@ public string Check() { var res = ""; var objNum = TechObjectManager.GetInstance().GetTechObjectN(Owner); - List numbers = strategy.GetValidTechObjNums(Value, objNum, Owner is GenericTechObject); + List numbers = strategy.GetValidTechObjNums(Value, objNum); string checkedValue = string.Join(" ", numbers); if (checkedValue != Value) { From 96ecd61a55f4654861e9adfa2c4a19df97338cf6 Mon Sep 17 00:00:00 2001 From: KirillGutyrchik Date: Thu, 30 May 2024 09:24:45 +0300 Subject: [PATCH 3/4] Fix edit new operations created by generic --- src/TechObject/ObjectsTree/UniversalObject/ModesManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TechObject/ObjectsTree/UniversalObject/ModesManager.cs b/src/TechObject/ObjectsTree/UniversalObject/ModesManager.cs index 0c1c56cf..defba7c4 100644 --- a/src/TechObject/ObjectsTree/UniversalObject/ModesManager.cs +++ b/src/TechObject/ObjectsTree/UniversalObject/ModesManager.cs @@ -603,6 +603,7 @@ public void UpdateOnGenericTechObject(ModesManager genericModesManager) if (mode is null) { mode = AddMode(genericMode.Name, genericMode.BaseOperation.LuaName); + mode.AddParent(this); } else { From cb7b469c96add3a14ca4e311c86dd032da5d719c Mon Sep 17 00:00:00 2001 From: KirillGutyrchik Date: Thu, 30 May 2024 10:26:57 +0300 Subject: [PATCH 4/4] Generic-update object groups --- .../UniversalObject/GenericTechObject.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/TechObject/ObjectsTree/UniversalObject/GenericTechObject.cs b/src/TechObject/ObjectsTree/UniversalObject/GenericTechObject.cs index 2ccc5312..6c6fd343 100644 --- a/src/TechObject/ObjectsTree/UniversalObject/GenericTechObject.cs +++ b/src/TechObject/ObjectsTree/UniversalObject/GenericTechObject.cs @@ -69,6 +69,7 @@ public void SetUpEventsHandlers() paramsManager.ValueChanged += UpdateParamsManager; ModesManager.ValueChanged += UpdateModesManager; AttachedObjects.ValueChanged += UpdateAttachedObjects; + BaseTechObject.ObjectGroupsList.ForEach(gr => gr.ValueChanged += UpdateObjectGroups); } /// @@ -83,6 +84,7 @@ public void Update() UpdateEquipment(null); UpdateParamsManager(null); UpdateTechObjectsData(null); + UpdateObjectGroups(null); } /// @@ -99,6 +101,24 @@ private void UpdateAttachedObjects(object sender) InheritedTechObjects.ForEach(to => to.AttachedObjects.UpdateOnGenericTechObject(AttachedObjects)); } + /// + /// Обновить поля групп танков: Группа танков, Источники/Приемники + /// + private void UpdateObjectGroups(object sender) + { + inheritedTechObjects.ForEach(to => + { + var genericObjGrList = BaseTechObject.ObjectGroupsList; + var inheritedObjGrList = to.BaseTechObject.ObjectGroupsList; + + var objectsGroups = genericObjGrList.Zip(inheritedObjGrList, (g, i) => new { Generic = g, Inherited = i }); + foreach (var og in objectsGroups) + { + og.Inherited.UpdateOnGenericTechObject(og.Generic); + } + }); + } + /// /// Обновить поле "Операции" ///