Skip to content

Commit

Permalink
Fixed sorting gencode
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinKlein1508 committed Mar 21, 2024
1 parent 9f066a8 commit 6234cfa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CSGencodes.Core/Models/Weapon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public string GetGencode(decimal @float, int pattern, List<AppliedSticker> stick

var sortedStickers = stickers.OrderBy(x => x.PosId).ToList();

// We have two stickers, both same position

int addedStickers = 0;
int currentPos = 0;
foreach (var sticker in sortedStickers)
{
Expand All @@ -61,14 +64,15 @@ public string GetGencode(decimal @float, int pattern, List<AppliedSticker> stick
break;
}

while (sticker.PosId != currentPos)
while (sticker.PosId != (currentPos - addedStickers))
{
sb.Append(" 0 0.00");
currentPos++;
}

sb.Append($" {sticker.gen_id} {sticker.Scratched.ToString("0.00", CultureInfo.InvariantCulture)}");
currentPos++;
addedStickers++;
}

string gencode = sb.ToString();
Expand Down
8 changes: 5 additions & 3 deletions CSGencodes/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
@if (SelectedWeapon is not null)
{
var inspectLink = inspectService.GenerateInspectLink(SelectedWeapon, Float, Pattern, SelectedStickers);

<div class="input-group mb-3">

<div class="form-floating">
<input type="text" value="@SelectedWeapon.GetGencode(Float, Pattern, SelectedStickers)" class="form-control" placeholder="Gencode" id="gencode" />
<label for="gencode">Gencode</label>
</div>

@if (!inspectLink.commandMode)
{
<a class="inspect-btn btn btn-info" href="@inspectLink.url">Inspect</a>
Expand All @@ -32,15 +34,15 @@

<button type="button" class="btn btn-primary" onclick="copyGencode()"><i class="fa-solid fa-copy"></i></button>
</div>

if (inspectLink.commandMode)
{
<Alert Color="AlertColor.Warning">
<strong>Attention!</strong> The generated inspect link is too long. In order to inspect the skin ingame you must paste the following command into the console.
</Alert>

<textarea value="@inspectLink.url" class="d-none" id="inspect-console-command" />
}
}
}

<div class="generator-wrapper">
Expand Down

0 comments on commit 6234cfa

Please sign in to comment.