Skip to content

Commit

Permalink
Merge pull request #200 from zymex22/Issue-#80
Browse files Browse the repository at this point in the history
Added update on load to the Designator default label
  • Loading branch information
zymex22 authored Oct 14, 2020
2 parents f841f79 + cd62f52 commit fb8d107
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
1 change: 1 addition & 0 deletions Languages/English/Keyed/AllKeyed_Other.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<PRFDroneStationLockdownAllDesc>Activate the Lockdown for all drone stations on the map.</PRFDroneStationLockdownAllDesc>
<PRFDroneStationLiftLockdownAll>Reactivate all</PRFDroneStationLiftLockdownAll>
<PRFDroneStationLfttLockdownAllDesc>Lift the Lockdown for all drone stations on the map.</PRFDroneStationLfttLockdownAllDesc>
<PRFDroneStationSelectArea>{0}\nSelect Area</PRFDroneStationSelectArea>

<ITab_DroneStation_labelKey>Settings</ITab_DroneStation_labelKey>
<ITab_DroneStation_InfoLabel>Toggle Jobs for this Drone Station</ITab_DroneStation_InfoLabel>
Expand Down
34 changes: 20 additions & 14 deletions Source/ProjectRimFactory/Drones/Building_DroneStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ public class DroneAreaSelector : Designator

public static Area SelectedArea => selectedArea;





public override AcceptanceReport CanDesignateCell(IntVec3 loc)
{
return loc.InBounds(base.Map) && Designator_AreaAllowed.SelectedArea != null && !Designator_AreaAllowed.SelectedArea[loc];
Expand Down Expand Up @@ -224,9 +226,9 @@ public void Update_droneAllowedArea_forDrones(Area dr = null)
{
//Refresh the area
droneAllowedArea = dr ?? (Area)GetDroneAllowedArea;
foreach (Pawn_Drone sdrone in spawnedDrones)
for (int i = 0; i < spawnedDrones.Count; i++)
{
sdrone.playerSettings.AreaRestriction = droneAllowedArea;
spawnedDrones[i].playerSettings.AreaRestriction = droneAllowedArea;
}
}

Expand Down Expand Up @@ -328,11 +330,22 @@ public override void SpawnSetup(Map map, bool respawningAfterLoad)
GenSpawn.Spawn(drone, Position, Map);
drone.Destroy();
}
//Init the Designator default Label
update_droneAreaSelectorLable(droneAllowedArea);
}




private void update_droneAreaSelectorLable(Area a)
{
if (a == null)
{
droneAreaSelectorLable = "PRFDroneStationSelectArea".Translate("Unrestricted".Translate());
}
else
{
droneAreaSelectorLable = "PRFDroneStationSelectArea".Translate(a.Label);
}
}

public override void Draw()
{
base.Draw();
Expand Down Expand Up @@ -533,14 +546,7 @@ Holds example of how i want this Gizmo Implemented
selectAction = (a) =>
{
Update_droneAllowedArea_forDrones(a);
if (a == null)
{
droneAreaSelectorLable = "Unrestricted\nSelect Area";
}
else
{
droneAreaSelectorLable = a.Label + "\nSelect Area";
}
update_droneAreaSelectorLable(a);

}
};
Expand Down

0 comments on commit fb8d107

Please sign in to comment.