Skip to content

Commit

Permalink
Add fleet tooltip to Selector
Browse files Browse the repository at this point in the history
  • Loading branch information
behindcurtain3 committed Mar 26, 2024
1 parent ea60a85 commit 5af15fc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 19 deletions.
3 changes: 3 additions & 0 deletions Pulsar4X/GameEngine/Engine/Entities/EntityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ public Entity CreateAndAddEntity(ProtoEntity protoEntity)

public void Transfer(Entity entity)
{
// Don't allow an entity to transer to the manager it's already in
if(entity.Manager == this) return;

var dataBlobs = new List<BaseDataBlob>();
if(entity.Manager != null)
{
Expand Down
30 changes: 12 additions & 18 deletions Pulsar4X/GameEngine/Engine/Factories/DefaultStartFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -425,26 +425,20 @@ public static Entity DefaultHumans(Game game, string name)

//var pos = Distance.AuToMt(new Vector3(8.52699302490434E-05, 0, 0));
//var vel = new Vector3(0, 10000.0, 0);
var pos = Distance.AuToMt(new Vector3(0, 8.52699302490434E-05, 0));
var vel = new Vector3(-10000.0, 0, 0);

var gunShip1Mass = gunShip1.GetDataBlob<MassVolumeDB>().MassTotal;
var earthmass = earth.GetDataBlob<MassVolumeDB>().MassTotal;

//give the gunship a hypobolic orbit to test:
var orbit = OrbitDB.FromVector(earth, gunShip1Mass, earthmass, pos, vel, game.TimePulse.GameGlobalDateTime);
gunShip1.GetDataBlob<PositionDB>().RelativePosition = pos;
gunShip1.SetDataBlob<OrbitDB>(orbit);
var pos2 = gunShip1.GetRelativeFuturePosition(game.TimePulse.GameGlobalDateTime);





// var nmdb = new NewtonMoveDB(earth, new Vector3(-10000.0, 0, 0));
// gunShip1.SetDataBlob<NewtonMoveDB>(nmdb);
// var pos = Distance.AuToMt(new Vector3(0, 8.52699302490434E-05, 0));
// var vel = new Vector3(-10000.0, 0, 0);

// var gunShip1Mass = gunShip1.GetDataBlob<MassVolumeDB>().MassTotal;
// var earthmass = earth.GetDataBlob<MassVolumeDB>().MassTotal;

// //give the gunship a hypobolic orbit to test:
// var orbit = OrbitDB.FromVector(earth, gunShip1Mass, earthmass, pos, vel, game.TimePulse.GameGlobalDateTime);
// gunShip1.GetDataBlob<PositionDB>().RelativePosition = pos;
// gunShip1.SetDataBlob<OrbitDB>(orbit);
// var pos2 = gunShip1.GetRelativeFuturePosition(game.TimePulse.GameGlobalDateTime);

// var nmdb = new NewtonMoveDB(earth, new Vector3(-10000.0, 0, 0));
// gunShip1.SetDataBlob<NewtonMoveDB>(nmdb);

solSys.SetDataBlob(gunShip0.Id, new TransitableDB());
solSys.SetDataBlob(ship2.Id, new TransitableDB());
Expand Down
22 changes: 21 additions & 1 deletion Pulsar4X/Pulsar4X.Client/EmpireManagement/Selector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,31 @@ internal override void Display()
foreach(var fleet in fleets)
{
bool visible = FleetWindow.GetInstance().GetActive() && FleetWindow.GetInstance().SelectedFleet?.Id == fleet.Id;
if(ImGui.Selectable(fleet.GetName(_uiState.Faction.Id), visible))
string display = fleet.GetName(_uiState.Faction.Id);
if(ImGui.Selectable(display, visible))
{
FleetWindow.GetInstance().SetActive(true);
FleetWindow.GetInstance().SelectFleet(fleet);
}
if (ImGui.IsItemHovered())
{
ImGui.BeginTooltip();

if(fleet.TryGetDatablob<OrderableDB>(out var orderableDb)
&& orderableDb.ActionList.Count > 0)
{
ImGui.Text("Orders:");
for(int i = 0; i < orderableDb.ActionList.Count; i++)
{
ImGui.Text(orderableDb.ActionList[i].Name);
}
}
else
{
ImGui.Text("No orders");
}
ImGui.EndTooltip();
}
}
}
ImGui.End();
Expand Down

0 comments on commit 5af15fc

Please sign in to comment.