Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: wrapped options.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 13, 2023
1 parent 6980efd commit a46957e
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>net7.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Authors>ArchiTed</Authors>
<Version>3.1.4.1</Version>
<Version>3.1.4.2</Version>
<PlatformTarget>x64</PlatformTarget>
<Platforms>AnyCPU</Platforms>

Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Data/IconSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public static TextureWrap GetTexture(string path)
public static bool GetTexture(string path, out TextureWrap texture)
=> ThreadLoadImageHandler.TryGetTextureWrap(path, out texture)
|| (path.StartsWith("http:", StringComparison.OrdinalIgnoreCase) || path.StartsWith("https:", StringComparison.OrdinalIgnoreCase))
&& GetTexture((uint)(62571 + Environment.TickCount / 500 % 3), out texture); // loading pics.
&& GetTexture((uint)(62571 + Environment.TickCount / 300 % 3), out texture); // loading pics.

private static readonly Dictionary<uint, uint> _actionIcons = new();

Expand Down
8 changes: 4 additions & 4 deletions RotationSolver/UI/RotationConfigWindowNew.cs
Original file line number Diff line number Diff line change
Expand Up @@ -754,10 +754,10 @@ private static void DrawRotationInformation()
var version = assembly.GetName().Version;
if (version != null)
{
ImGui.Text("v " + version.ToString());
ImGui.Text(" v " + version.ToString());
}

ImGui.Text("- " + info.Author);
ImGui.Text(" - " + info.Author);
ImGui.EndGroup();

var link = rotation.GetType().GetCustomAttribute<SourceCodeAttribute>();
Expand Down Expand Up @@ -979,10 +979,10 @@ private static void DrawRotationsLoaded()
var version = assembly.GetName().Version;
if (version != null)
{
ImGui.Text("v " + version.ToString());
ImGui.Text(" v " + version.ToString());
}

ImGui.Text("- " + info.Author);
ImGui.Text(" - " + info.Author);

ImGui.TableNextColumn();

Expand Down
13 changes: 7 additions & 6 deletions RotationSolver/UI/SearchableConfigs/CheckBoxSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,17 @@ protected override void DrawMain(Job job)
var hasIcon = Action != ActionID.None && IconSet.GetTexture(Action, out texture);

var enable = GetValue(job);
if (ImGui.Checkbox(!hasChild && !hasIcon ? $"{Name}##{ID}" : $"##{ID}", ref enable))
if (ImGui.Checkbox($"##{ID}", ref enable))
{
SetValue(job, enable);
}
if (ImGui.IsItemHovered()) ShowTooltip(job);

if (!hasChild && !hasIcon) return;
ImGui.SameLine();

var name = $"{Name}##Config_{ID}";
if(hasIcon)
{
ImGui.SameLine();

ImGui.BeginGroup();
var cursor = ImGui.GetCursorPos();
var size = ImGuiHelpers.GlobalScale * 32;
Expand All @@ -97,8 +95,6 @@ protected override void DrawMain(Job job)
}
else if (hasChild)
{
ImGui.SameLine();

if (enable)
{
var x = ImGui.GetCursorPosX();
Expand Down Expand Up @@ -127,5 +123,10 @@ protected override void DrawMain(Job job)
ImGui.PopStyleColor(2);
}
}
else
{
ImGui.TextWrapped(Name);
if (ImGui.IsItemHovered()) ShowTooltip(job, false);
}
}
}
15 changes: 8 additions & 7 deletions RotationSolver/UI/SearchableConfigs/DragFloatRangeSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,15 @@ internal class DragFloatRangeSearchJob : DragFloatRangeSearch

public override LinkDescription[] Tooltips => _configMin.ToAction();

protected override bool IsJob => true;

public DragFloatRangeSearchJob(JobConfigFloat configMin, JobConfigFloat configMax, float min, float max, float speed)
: base (min, max, speed)
{
_configMin = configMin;
_configMax = configMax;
}

protected override void DrawMain(Job job)
{
base.DrawMain(job);
DrawJobIcon();
}

public override void ResetToDefault(Job job)
{
Service.ConfigNew.SetValue(job, _configMin, Service.ConfigNew.GetDefault(job, _configMin));
Expand Down Expand Up @@ -125,11 +121,16 @@ protected override void DrawMain(Job job)
var minValue = GetMinValue(job);
var maxValue = GetMaxValue(job);
ImGui.SetNextItemWidth(Scale * DRAG_WIDTH);
if (ImGui.DragFloatRange2($"{Name}##Config_{ID}", ref minValue, ref maxValue, Speed, Min, Max))
if (ImGui.DragFloatRange2($"##Config_{ID}", ref minValue, ref maxValue, Speed, Min, Max))
{
SetMinValue(job, Math.Max(Math.Min(minValue, maxValue), Min));
SetMaxValue(job, Math.Min(Math.Max(minValue, maxValue), Max));
}
if (ImGui.IsItemHovered()) ShowTooltip(job);

if (IsJob) DrawJobIcon();
ImGui.SameLine();
ImGui.TextWrapped(Name);
if (ImGui.IsItemHovered()) ShowTooltip(job, false);
}
}
15 changes: 8 additions & 7 deletions RotationSolver/UI/SearchableConfigs/DragFloatSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,14 @@ internal class DragFloatSearchJob : DragFloatSearch
public override LinkDescription[] Tooltips => _config.ToAction();

public override string Command => _config.ToCommand();
protected override bool IsJob => true;

public DragFloatSearchJob(JobConfigFloat config, float min, float max, float speed)
: base(min, max, speed)
{
_config = config;
}

protected override void DrawMain(Job job)
{
base.DrawMain(job);
DrawJobIcon();
}

public override void ResetToDefault(Job job)
{
Service.ConfigNew.SetValue(job, _config, Service.ConfigNew.GetDefault(job, _config));
Expand Down Expand Up @@ -101,10 +96,16 @@ protected override void DrawMain(Job job)
{
var value = GetValue(job);
ImGui.SetNextItemWidth(Scale * DRAG_WIDTH);
if (ImGui.DragFloat($"{Name}##Config_{ID}", ref value, Speed, Min, Max))
if (ImGui.DragFloat($"##Config_{ID}", ref value, Speed, Min, Max))
{
SetValue(job, Math.Min(Math.Max(value, Min), Max));
}
if (ImGui.IsItemHovered()) ShowTooltip(job);

if (IsJob) DrawJobIcon();

ImGui.SameLine();
ImGui.TextWrapped(Name);
if (ImGui.IsItemHovered()) ShowTooltip(job, false);
}
}
14 changes: 7 additions & 7 deletions RotationSolver/UI/SearchableConfigs/DragIntRangeSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal class DragIntRangeSearchJob : DragIntRangeSearch
public override string Description => _configMin.ToDescription();

public override LinkDescription[] Tooltips => _configMin.ToAction();
protected override bool IsJob => true;

public DragIntRangeSearchJob(JobConfigInt configMin, JobConfigInt configMax, int min, int max, float speed)
:base (min, max, speed)
Expand All @@ -23,12 +24,6 @@ public DragIntRangeSearchJob(JobConfigInt configMin, JobConfigInt configMax, int
_configMax = configMax;
}

protected override void DrawMain(Job job)
{
base.DrawMain(job);
DrawJobIcon();
}

public override void ResetToDefault(Job job)
{
Service.ConfigNew.SetValue(job, _configMin, Service.ConfigNew.GetDefault(job, _configMin));
Expand Down Expand Up @@ -126,11 +121,16 @@ protected override void DrawMain(Job job)
var minValue = GetMinValue(job);
var maxValue = GetMaxValue(job);
ImGui.SetNextItemWidth(Scale * DRAG_WIDTH);
if (ImGui.DragIntRange2($"{Name}##Config_{ID}", ref minValue, ref maxValue, Speed, Min, Max))
if (ImGui.DragIntRange2($"##Config_{ID}", ref minValue, ref maxValue, Speed, Min, Max))
{
SetMinValue(job, Math.Max(Math.Min(minValue, maxValue), Min));
SetMaxValue(job, Math.Min(Math.Max(minValue, maxValue), Max));
}
if (ImGui.IsItemHovered()) ShowTooltip(job);

if (IsJob) DrawJobIcon();
ImGui.SameLine();
ImGui.TextWrapped(Name);
if (ImGui.IsItemHovered()) ShowTooltip(job, false);
}
}
15 changes: 8 additions & 7 deletions RotationSolver/UI/SearchableConfigs/DragIntSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@ internal class DragIntSearchJob : DragIntSearch

public override string Command => _config.ToCommand();

protected override bool IsJob => true;

public DragIntSearchJob(JobConfigInt config, int min, int max, float speed)
:base (min, max, speed)
{
_config = config;
}

protected override void DrawMain(Job job)
{
base.DrawMain(job);
DrawJobIcon();
}

public override void ResetToDefault(Job job)
{
Service.ConfigNew.SetValue(job, _config, Service.ConfigNew.GetDefault(job, _config));
Expand Down Expand Up @@ -98,10 +94,15 @@ protected override void DrawMain(Job job)
{
var value = GetValue(job);
ImGui.SetNextItemWidth(Scale * DRAG_WIDTH);
if(ImGui.DragInt($"{Name}##Config_{ID}", ref value, Speed, Min, Max))
if(ImGui.DragInt($"##Config_{ID}", ref value, Speed, Min, Max))
{
SetValue(job, Math.Min(Math.Max(value, Min), Max));
}
if (ImGui.IsItemHovered()) ShowTooltip(job);

if (IsJob) DrawJobIcon();
ImGui.SameLine();
ImGui.TextWrapped(Name);
if (ImGui.IsItemHovered()) ShowTooltip(job, false);
}
}
2 changes: 1 addition & 1 deletion RotationSolver/UI/SearchableConfigs/Searchable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal abstract class Searchable : ISearchable
public abstract LinkDescription[] Tooltips { get; }
public abstract string ID { get; }
private string Popup_Key => "Rotation Solver RightClicking: " + ID;

protected virtual bool IsJob => false;
public void Draw(Job job)
{
if (string.IsNullOrEmpty(Name)) return;
Expand Down
5 changes: 4 additions & 1 deletion RotationSolver/Updaters/RotationUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ private static async Task<bool> DownloadOneUrlAsync(string url, string relayFold
{
if (File.Exists(filePath) && !mustDownload)
{
if (new FileInfo(filePath).Length == response.Content.Headers.ContentLength)
var fileInfo = new FileInfo(filePath);
var header = response.Content.Headers;
if (header.LastModified.HasValue && header.LastModified.Value.UtcDateTime < fileInfo.LastWriteTimeUtc
&& fileInfo.Length == header.ContentLength)
{
return false;
}
Expand Down

0 comments on commit a46957e

Please sign in to comment.