Construction UI improvements
This commit is contained in:
@@ -48,7 +48,7 @@ namespace Content.Client.Construction
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
Placement = (PlacementManager) IoCManager.Resolve<IPlacementManager>();
|
||||
Placement.PlacementCanceled += OnPlacementCanceled;
|
||||
Placement.PlacementChanged += OnPlacementChanged;
|
||||
|
||||
Title = "Construction";
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Content.Client.Construction
|
||||
TextAlign = Label.AlignMode.Center,
|
||||
Text = "Build!",
|
||||
Disabled = true,
|
||||
ToggleMode = false
|
||||
ToggleMode = true
|
||||
};
|
||||
EraseButton = new Button
|
||||
{
|
||||
@@ -108,7 +108,7 @@ namespace Content.Client.Construction
|
||||
hSplitContainer.AddChild(guide);
|
||||
Contents.AddChild(hSplitContainer);
|
||||
|
||||
BuildButton.OnPressed += OnBuildPressed;
|
||||
BuildButton.OnToggled += OnBuildToggled;
|
||||
EraseButton.OnToggled += OnEraseToggled;
|
||||
SearchBar.OnTextChanged += OnTextEntered;
|
||||
RecipeList.OnItemSelected += OnItemSelected;
|
||||
@@ -123,7 +123,7 @@ namespace Content.Client.Construction
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
Placement.PlacementCanceled -= OnPlacementCanceled;
|
||||
Placement.PlacementChanged -= OnPlacementChanged;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,37 +226,57 @@ namespace Content.Client.Construction
|
||||
PopulateTree(string.IsNullOrWhiteSpace(str) ? null : str.ToLowerInvariant());
|
||||
}
|
||||
|
||||
void OnBuildPressed(BaseButton.ButtonEventArgs args)
|
||||
void OnBuildToggled(BaseButton.ButtonToggledEventArgs args)
|
||||
{
|
||||
var prototype = (ConstructionPrototype) RecipeList.Selected.Metadata;
|
||||
if (prototype == null)
|
||||
if (args.Pressed)
|
||||
{
|
||||
return;
|
||||
var prototype = (ConstructionPrototype) RecipeList.Selected.Metadata;
|
||||
if (prototype == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (prototype.Type != ConstructionType.Structure)
|
||||
{
|
||||
// In-hand attackby doesn't exist so this is the best alternative.
|
||||
var loc = Owner.Owner.GetComponent<ITransformComponent>().GridPosition;
|
||||
Owner.SpawnGhost(prototype, loc, Direction.North);
|
||||
return;
|
||||
}
|
||||
|
||||
Placement.BeginHijackedPlacing(
|
||||
new PlacementInformation
|
||||
{
|
||||
IsTile = false,
|
||||
PlacementOption = prototype.PlacementMode
|
||||
},
|
||||
new ConstructionPlacementHijack(prototype, Owner));
|
||||
}
|
||||
|
||||
if (prototype.Type != ConstructionType.Structure)
|
||||
else
|
||||
{
|
||||
// In-hand attackby doesn't exist so this is the best alternative.
|
||||
var loc = Owner.Owner.GetComponent<ITransformComponent>().GridPosition;
|
||||
Owner.SpawnGhost(prototype, loc, Direction.North);
|
||||
return;
|
||||
Placement.Clear();
|
||||
}
|
||||
|
||||
var hijack = new ConstructionPlacementHijack(prototype, Owner);
|
||||
var info = new PlacementInformation
|
||||
{
|
||||
IsTile = false,
|
||||
PlacementOption = prototype.PlacementMode,
|
||||
};
|
||||
|
||||
|
||||
Placement.BeginHijackedPlacing(info, hijack);
|
||||
BuildButton.Pressed = args.Pressed;
|
||||
}
|
||||
|
||||
private void OnEraseToggled(BaseButton.ButtonToggledEventArgs args)
|
||||
{
|
||||
var hijack = new ConstructionPlacementHijack(null, Owner);
|
||||
Placement.ToggleEraserHijacked(hijack);
|
||||
if (args.Pressed)
|
||||
{
|
||||
Placement.Clear();
|
||||
Placement.ToggleEraserHijacked(new ConstructionPlacementHijack(null, Owner));
|
||||
}
|
||||
else
|
||||
{
|
||||
Placement.ToggleEraserHijacked(new ConstructionPlacementHijack(null, Owner));
|
||||
}
|
||||
EraseButton.Pressed = args.Pressed;
|
||||
}
|
||||
|
||||
private void OnPlacementChanged(object sender, EventArgs e)
|
||||
{
|
||||
BuildButton.Pressed = false;
|
||||
EraseButton.Pressed = false;
|
||||
}
|
||||
|
||||
void PopulatePrototypeList()
|
||||
@@ -363,11 +383,6 @@ namespace Content.Client.Construction
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPlacementCanceled(object sender, EventArgs e)
|
||||
{
|
||||
EraseButton.Pressed = false;
|
||||
}
|
||||
|
||||
private static int ComparePrototype(ConstructionPrototype x, ConstructionPrototype y)
|
||||
{
|
||||
return String.Compare(x.Name, y.Name, StringComparison.Ordinal);
|
||||
|
||||
Reference in New Issue
Block a user