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