Skip to content

Commit

Permalink
v.0.7.2
Browse files Browse the repository at this point in the history
IEEE754, benchmark theme, craft range, ui tweaks, optimizations, download speed increase
  • Loading branch information
Prevter committed Jun 8, 2021
1 parent 8007210 commit 44b3887
Show file tree
Hide file tree
Showing 12 changed files with 1,573 additions and 642 deletions.
51 changes: 49 additions & 2 deletions FloatToolGUI/Benchmark.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Microsoft.Win32;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
Expand All @@ -15,6 +16,7 @@
using System.Threading.Tasks;
using System.Windows.Forms;
using static FloatToolGUI.Calculation;
using static FloatToolGUI.Utils;

namespace FloatToolGUI
{
Expand All @@ -27,16 +29,19 @@ public enum SearchMode
Greater
}
SearchMode CurrentSearchMode = SearchMode.Equal;
private Pallete CurrentPallete;

public void parseCraft(List<InputSkin> inputs, List<Skin> outputs, string want)
{
decimal wantFloat = 1;
if (CurrentSearchMode != SearchMode.Equal)
decimal.TryParse(want, NumberStyles.Any, CultureInfo.InvariantCulture, out wantFloat);

var inputArr = inputs.ToArray();

for (int i = 0; i < outputs.Count; i++)
{
decimal flotOrigin = Math.Round(craft(inputs, outputs[i].MinFloat, outputs[i].MaxFloat), 14);
decimal flotOrigin = Math.Round(craft(inputArr, outputs[i].MinFloat, outputs[i].FloatRange), 14);

if (
(flotOrigin.ToString(CultureInfo.InvariantCulture).StartsWith(want, StringComparison.Ordinal) && CurrentSearchMode == SearchMode.Equal) ||
Expand All @@ -58,6 +63,42 @@ public void secndThread(List<Skin> craftList, string wanted, List<InputSkin> poo
}
}

public void SetTheme()
{
panel3.BackColor = GetPalleteColor(CurrentPallete, PalleteColor.Primary3);
label8.ForeColor = GetPalleteColor(CurrentPallete, PalleteColor.Secondary1);
closeBtn.ForeColor = GetPalleteColor(CurrentPallete, PalleteColor.Secondary1);
panel4.BackColor = GetPalleteColor(CurrentPallete, PalleteColor.Primary1);

benchmarkScoreboardLayout.BackColor = GetPalleteColor(CurrentPallete, PalleteColor.Primary4);
benchmarkScoreboardLayout.ForeColor = GetPalleteColor(CurrentPallete, PalleteColor.Secondary1);

cpuNameLabel.ForeColor = GetPalleteColor(CurrentPallete, PalleteColor.Secondary1);
threadCountLabel.ForeColor = GetPalleteColor(CurrentPallete, PalleteColor.Secondary1);
versionLabel2.ForeColor = GetPalleteColor(CurrentPallete, PalleteColor.Secondary1);
label4.ForeColor = GetPalleteColor(CurrentPallete, PalleteColor.Secondary1);
speedLabel.ForeColor = GetPalleteColor(CurrentPallete, PalleteColor.Secondary1);
label2.ForeColor = GetPalleteColor(CurrentPallete, PalleteColor.Secondary1);

benchmarkThreadsNumericUpdown.ForeColor = GetPalleteColor(CurrentPallete, PalleteColor.Secondary1);
benchmarkThreadsNumericUpdown.BackColor = GetPalleteColor(CurrentPallete, PalleteColor.Primary6);

updateBenchmarksButton.ForeColor = GetPalleteColor(CurrentPallete, PalleteColor.Secondary1);
updateBenchmarksButton.BackColor = GetPalleteColor(CurrentPallete, PalleteColor.Primary5);
submitScoreBtn.ForeColor = GetPalleteColor(CurrentPallete, PalleteColor.Secondary1);
submitScoreBtn.BackColor = GetPalleteColor(CurrentPallete, PalleteColor.Primary5);
startBenchmarkBtn.ForeColor = GetPalleteColor(CurrentPallete, PalleteColor.Secondary1);
startBenchmarkBtn.BackColor = GetPalleteColor(CurrentPallete, PalleteColor.Primary5);

updateBenchmarksButton.FlatAppearance.MouseOverBackColor = GetPalleteColor(CurrentPallete, PalleteColor.OverBackColor2);
submitScoreBtn.FlatAppearance.MouseOverBackColor = GetPalleteColor(CurrentPallete, PalleteColor.OverBackColor2);
startBenchmarkBtn.FlatAppearance.MouseOverBackColor = GetPalleteColor(CurrentPallete, PalleteColor.OverBackColor2);

customProgressBar1.ForeColor = GetPalleteColor(CurrentPallete, PalleteColor.Secondary1);
customProgressBar1.ProgressColor = GetPalleteColor(CurrentPallete, PalleteColor.Secondary3);
customProgressBar1.BackColor = GetPalleteColor(CurrentPallete, PalleteColor.Primary4);
}

private void runCycle()
{
Console.WriteLine("Thread loaded!");
Expand Down Expand Up @@ -152,6 +193,12 @@ public Benchmark(string version)
warningPic.Image = SystemIcons.Warning.ToBitmap();
Thread t = new Thread(new ThreadStart(LoadStats));
t.Start();

CheckRegistry();
var registryData = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\FloatTool", true);
var themeRK = registryData.GetValue("theme");
CurrentPallete = (Pallete)themeRK;
SetTheme();
}

private void startBenchmarkBtn_Click(object sender, EventArgs e)
Expand Down
62 changes: 14 additions & 48 deletions FloatToolGUI/Calculation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ namespace FloatToolGUI
{
static class Calculation
{
[DllImport("FloatCore.dll")]
static public extern double GetOutputWear(double[] floats, float minWear, float maxWear);
[DllImport("FloatCore.dll", CallingConvention = CallingConvention.Cdecl)]
static public extern void GetOutputWear(float[] floats, float minWear, float maxWear, StringBuilder stringBuilder);

static public string GetOutputWearString(float[] floats, float minWear, float maxWear) {
StringBuilder sb = new StringBuilder(19);
GetOutputWear(floats, minWear, maxWear, sb);
return sb.ToString();
}

/// <summary>
/// Calculates wear value based of input skins and min/max value of outcome
Expand All @@ -21,69 +27,32 @@ static class Calculation
/// <param name="minFloat">Minimal wear value of skin that is going to be crafted</param>
/// <param name="maxFloat">Maximum wear value of skin that is going to be crafted</param>
/// <returns>Wear value represented in decimal type</returns>
static public decimal craft(List<InputSkin> ingridients, decimal minFloat, decimal maxFloat)
static public decimal craft(InputSkin[] ingridients, decimal minFloat, decimal floatRange)
{
decimal avgFloat = ingridients[0].WearValue;
for (int i = 1; i < 10; i++)
{
avgFloat += ingridients[i].WearValue;
}
avgFloat /= 10;
return (maxFloat - minFloat) * avgFloat + minFloat;
return floatRange * avgFloat + minFloat;
}

/// <summary>
/// Does same job as craft(List<InputSkin>, float, float), but uses float as type
/// Does same job as craft(List<InputSkin>, float, float), but uses c++ dll with IEEE754 precision
/// </summary>
/// <param name="ingridients">List of 10 skins</param>
/// <param name="minFloat">Minimal wear value of skin that is going to be crafted</param>
/// <param name="maxFloat">Maximum wear value of skin that is going to be crafted</param>
/// <returns>Float wear value in string</returns>
static public string craftF(List<InputSkin> ingridients, decimal minFloat, decimal maxFloat)
static public string craftF(List<InputSkin> ingridients, float minFloat, float maxFloat)
{
float avgFloat = 0;
float[] arrInput = new float[10];
for (int i = 0; i < 10; i++)
{
arrInput[i] = Convert.ToSingle(ingridients[i].WearValue);
}
for (int i = 0; i < 10; i++)
{
avgFloat += Convert.ToSingle(arrInput[i]);
arrInput[i] = (float)ingridients[i].WearValue;
}
avgFloat /= 10;
return setprecission(((float)(maxFloat - minFloat) * avgFloat) + (float)minFloat, 10);
}

public static string setprecission(double number, int figures)
{
int e = 0;
while (number >= 10.0)
{
e += 1;
number /= 10;
}
while (number < 1.0)
{
e -= 1;
number *= 10;
}
figures--;
number = (float)Math.Round(number, figures);
figures += 0 - e;
while (e > 0)
{
number *= 10;
e -= 1;
}
while (e < 0)
{
number /= 10;
e += 1;
}
if (figures < 0)
figures = 0;
return number.ToString($"f{figures}", CultureInfo.InvariantCulture);
return GetOutputWearString(arrInput, minFloat, maxFloat);
}

public static Quality FromString(string value)
Expand Down Expand Up @@ -154,8 +123,5 @@ static public IEnumerable Combinations<T>(IEnumerable<T> elements, int start, in
step++;
} while (NextCombination(numbers, size));
}



}
}
Loading

0 comments on commit 44b3887

Please sign in to comment.