Skip to content

Commit

Permalink
layout: Show ctrl click hint only once
Browse files Browse the repository at this point in the history
Decease header size
  • Loading branch information
Dorus committed May 6, 2024
1 parent 395524b commit d375062
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions Yafc.UI/Rendering/Font.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Yafc.UI {
public class Font {
public static Font header;
public static Font subheader;
public static Font subsubheader;
public static Font text;

public readonly float size;
Expand Down
1 change: 1 addition & 0 deletions Yafc/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ private static void Main(string[] args) {
Font.header = new Font(overriddenFontFile ?? new FontFile("Data/Roboto-Light.ttf"), 2f);
var regular = overriddenFontFile ?? new FontFile("Data/Roboto-Regular.ttf");
Font.subheader = new Font(regular, 1.5f);
Font.subsubheader = new Font(regular, 1.23f);
Font.text = new Font(regular, 1f);

ProjectDefinition cliProject = CommandLineParser.Parse(args);
Expand Down
6 changes: 1 addition & 5 deletions Yafc/Widgets/ImmediateWidgets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static bool BuildFactorioObjectButtonWithText(this ImGui gui, FactorioObj

public static bool BuildInlineObjectList<T>(this ImGui gui, IEnumerable<T> list, IComparer<T> ordering, string header, out T selected, int maxCount = 10,
Predicate<T> checkMark = null, Func<T, string> extra = null) where T : FactorioObject {
gui.BuildText(header, Font.subheader);
gui.BuildText(header, Font.subsubheader);
var sortedList = ordering == DataUtils.AlreadySortedRecipe ? list.AsEnumerable() : list.OrderBy(e => e, ordering ?? DataUtils.DefaultOrdering);
selected = null;
foreach (var elem in sortedList.Take(maxCount)) {
Expand Down Expand Up @@ -152,10 +152,6 @@ public static void BuildInlineObjectListAndButton<T>(this ImGui gui, ICollection
SelectSingleObjectPanel.Select(list, header, select, ordering, allowNone);
}
}

if (multiple && list.Count > 1) {
gui.BuildText("Hint: ctrl+click to add multiple", wrap: true, color: SchemeColor.BackgroundTextFaint);
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions Yafc/Workspace/ProductionTable/ProductionTableView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,10 @@ void DropDownContent(ImGui gui) {
}
}

int multiple = 0;
if (type != ProductDropdownType.Product && goods != null && allProduction.Length > 0) {
gui.BuildInlineObjectListAndButton(allProduction, comparer, addRecipe, "Add production recipe", 6, true, recipeExists);
multiple += allProduction.Length;
if (link == null) {
Rect iconRect = new Rect(gui.lastRect.Right - 2f, gui.lastRect.Top, 2f, 2f);
gui.DrawIcon(iconRect.Expand(-0.2f), Icon.OpenNew, gui.textColor);
Expand All @@ -773,14 +775,21 @@ void DropDownContent(ImGui gui) {

if (type != ProductDropdownType.Fuel && goods != null && type != ProductDropdownType.Ingredient && goods.usages.Length > 0) {
gui.BuildInlineObjectListAndButton(goods.usages, DataUtils.DefaultRecipeOrdering, addRecipe, "Add consumption recipe", type == ProductDropdownType.Product ? 6 : 3, true, recipeExists);
multiple += goods.usages.Length;
}

if (type != ProductDropdownType.Fuel && goods != null && type != ProductDropdownType.Ingredient && fuelUseList.Length > 0) {
gui.BuildInlineObjectListAndButton(fuelUseList, DataUtils.AlreadySortedRecipe, (x) => { selectedFuel = goods; addRecipe(x); }, "Add fuel usage", type == ProductDropdownType.Product ? 6 : 3, true, recipeExists);
multiple += fuelUseList.Length;
}

if (type == ProductDropdownType.Product && goods != null && allProduction.Length > 0) {
gui.BuildInlineObjectListAndButton(allProduction, comparer, addRecipe, "Add production recipe", 1, true, recipeExists);
multiple += allProduction.Length;
}

if (multiple > 1) {
gui.BuildText("Hint: ctrl+click to add multiple", wrap: true, color: SchemeColor.BackgroundTextFaint);
}

if (link != null && gui.BuildCheckBox("Allow overproduction", link.algorithm == LinkAlgorithm.AllowOverProduction, out bool newValue)) {
Expand Down

0 comments on commit d375062

Please sign in to comment.