Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tmp merge #1387

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/TechObject/ObjectsTree/UniversalObject/AttachedObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public override bool SetNewValue(string newValue)
string oldValue = Value;
var thisObjNum = owner?.GlobalNum ?? 0;
var isGeneric = owner is GenericTechObject;
List<int> newNumbers = strategy.GetValidTechObjNums(newValue,
thisObjNum, isGeneric);
List<int> newNumbers = strategy.GetValidTechObjNums(newValue, thisObjNum);

newValue = string.Join(" ", newNumbers);
string sortedValue = MoveNewValuesInTheEndOfString(newValue,
Expand Down Expand Up @@ -295,7 +294,7 @@ public string Check()
{
var res = "";
var objNum = TechObjectManager.GetInstance().GetTechObjectN(Owner);
List<int> numbers = strategy.GetValidTechObjNums(Value, objNum, Owner is GenericTechObject);
List<int> numbers = strategy.GetValidTechObjNums(Value, objNum);
string checkedValue = string.Join(" ", numbers);
if (checkedValue != Value)
{
Expand Down Expand Up @@ -631,8 +630,9 @@ public interface IAttachedObjectsStrategy
/// </summary>
/// <param name="value">Входная строка</param>
/// <param name="objNum">Номер редактируемого объекта</param>
/// <param name="isGeneric">Редактируемый объект - типовой</param>
/// <returns></returns>
List<int> GetValidTechObjNums(string value, int objNum, bool isGeneric);
List<int> GetValidTechObjNums(string value, int objNum, bool isGeneric = false);

/// <summary>
/// Нужно ли инициализировать привязанные объекты
Expand Down Expand Up @@ -708,7 +708,7 @@ public BaseStrategy(string name, string luaName,
/// <param name="selectedObjNum">Номер редактируемого объекта</param>
/// <param name="isGeneric"><paramref name="selectedObjNum"/> - типовой объект</param>
public List<int> GetValidTechObjNums(string value,
int selectedObjNum, bool isGeneric)
int selectedObjNum, bool isGeneric = false)
{
var validNumbers = new List<int>();
List<int> numbers = value.Split(' ')
Expand Down
20 changes: 20 additions & 0 deletions src/TechObject/ObjectsTree/UniversalObject/GenericTechObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public void SetUpEventsHandlers()
paramsManager.ValueChanged += UpdateParamsManager;
ModesManager.ValueChanged += UpdateModesManager;
AttachedObjects.ValueChanged += UpdateAttachedObjects;
BaseTechObject.ObjectGroupsList.ForEach(gr => gr.ValueChanged += UpdateObjectGroups);
}

/// <summary>
Expand All @@ -83,6 +84,7 @@ public void Update()
UpdateEquipment(null);
UpdateParamsManager(null);
UpdateTechObjectsData(null);
UpdateObjectGroups(null);
}

/// <summary>
Expand All @@ -99,6 +101,24 @@ private void UpdateAttachedObjects(object sender)
InheritedTechObjects.ForEach(to => to.AttachedObjects.UpdateOnGenericTechObject(AttachedObjects));
}

/// <summary>
/// Обновить поля групп танков: Группа танков, Источники/Приемники
/// </summary>
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);
}
});
}

/// <summary>
/// Обновить поле "Операции"
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/TechObject/ObjectsTree/UniversalObject/ModesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ public void UpdateOnGenericTechObject(ModesManager genericModesManager)
if (mode is null)
{
mode = AddMode(genericMode.Name, genericMode.BaseOperation.LuaName);
mode.AddParent(this);
}
else
{
Expand Down