Skip to content

Commit

Permalink
Production summary add multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowTheAge committed Feb 8, 2022
1 parent 3a50ec4 commit b467fa2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
8 changes: 8 additions & 0 deletions YAFC/Widgets/ImmediateWidgets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public static void BuildFactorioObjectIcon(this ImGui gui, FactorioObject obj, M
}
}
}

public static bool BuildFloatInput(this ImGui gui, float value, out float newValue, UnitOfMeasure unit, Padding padding)
{
if (gui.BuildTextInput(DataUtils.FormatAmount(value, unit), out var newText, null, Icon.None, true, padding) && DataUtils.TryParseAmount(newText, out newValue, unit))
return true;
newValue = value;
return false;
}

public static bool BuildFactorioObjectButton(this ImGui gui, Rect rect, FactorioObject obj, SchemeColor bgColor = SchemeColor.None, bool extendHeader = false)
{
Expand Down
25 changes: 15 additions & 10 deletions YAFC/Workspace/ProductionSummaryView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,23 @@ public override void BuildHeader(ImGui gui)

public override void BuildElement(ImGui gui, ProductionSummaryEntry entry)
{
gui.spacing = 0.2f;
var icon = entry.icon;
if (icon != Icon.None)
gui.BuildIcon(entry.icon);
gui.BuildText(entry.name);
gui.allocator = RectAllocator.LeftAlign;
using (gui.EnterRow(0.2f))
{
var icon = entry.icon;
if (icon != Icon.None)
gui.BuildIcon(entry.icon);
gui.BuildText(entry.name);
}
if (gui.action == ImGuiAction.MouseMove && gui.ConsumeMouseOver(gui.lastRect))
MainScreen.Instance.ShowTooltip(gui, entry.page.page, false, gui.lastRect);

if (gui.action == ImGuiAction.MouseMove)
using (gui.EnterFixedPositioning(3f, 2f, default))
{
var fullRect = gui.statePosition;
fullRect.Height = 4.5f;
if (gui.ConsumeMouseOver(fullRect))
MainScreen.Instance.ShowTooltip(gui, entry.page.page, false, fullRect);
gui.allocator = RectAllocator.LeftRow;
gui.BuildText("x");
if (gui.BuildFloatInput(entry.multiplier, out var newMultiplier, UnitOfMeasure.None, default))
entry.RecordUndo().multiplier = newMultiplier;
}
}
}
Expand Down
1 change: 0 additions & 1 deletion YAFCui/ImGui/ImGuiDrag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public void SetDraggingArea<T>(Rect rect, T draggingObject, SchemeColor bgColor)

public void UpdateDraggingObject(object obj)
{
Console.WriteLine("Currently dragging "+obj.GetType()+" "+obj.GetHashCode());
if (currentDraggingObject != null)
currentDraggingObject = obj;
}
Expand Down

0 comments on commit b467fa2

Please sign in to comment.