Skip to content

Commit c1902e8

Browse files
committed
Bootleg adding and removing for mission best times and challenge counts
1 parent ffb71a5 commit c1902e8

10 files changed

+742
-2
lines changed

RainWorldSaveEditor/Forms/ExpeditionCoreSaveForm.Designer.cs

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RainWorldSaveEditor/Forms/ExpeditionCoreSaveForm.cs

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ private void SetupFromSave(ExpeditionCoreSave? save)
319319
{
320320
var realName = ExpeditionMissionInfo.Missions.ContainsKey(item.Mission) ? ExpeditionMissionInfo.Missions[item.Mission].Name : item.Mission;
321321

322-
missionBestTimesListBox.Items.Add($"{realName}: {item.Time}");
322+
missionBestTimesListBox.Items.Add($"{realName}: {TimeSpan.FromSeconds(item.Time):hh\\:mm\\:ss}");
323323
}
324324

325325
challengesListBox.Items.Clear();
@@ -647,4 +647,56 @@ private void completedQuestsAddButton_Click(object sender, EventArgs e)
647647
_save.Quests.Add(item);
648648
}
649649
}
650+
651+
private void missionBestTimesAddButton_Click(object sender, EventArgs e)
652+
{
653+
using var dialog = new TimeSpanValueInputForm();
654+
655+
dialog.AvailableOptions = ExpeditionMissionInfo.Missions.Values
656+
.Select(x => new TimeSpanValueInputForm.Option
657+
{
658+
Value = x.Key,
659+
Display = $"{x.Name} ({x.Key})"
660+
}).ToList();
661+
662+
dialog.ShowDialog();
663+
664+
var item = dialog.SelectedOption;
665+
var time = dialog.SelectedTime;
666+
667+
if (!string.IsNullOrWhiteSpace(item))
668+
{
669+
var realName = ExpeditionMissionInfo.Missions.ContainsKey(item) ? ExpeditionMissionInfo.Missions[item].Name : item;
670+
671+
missionBestTimesListBox.Items.Add($"{realName}: {time:hh\\:mm\\:ss}");
672+
_save.MissionBestTimes.Add(new MissionBestTime
673+
{
674+
Mission = item,
675+
Time = (int)time.TotalSeconds
676+
});
677+
}
678+
}
679+
680+
private void challengesAddButton_Click(object sender, EventArgs e)
681+
{
682+
using var dialog = new IntValueInputForm();
683+
684+
// TODO: Add options for challenges you can add
685+
dialog.AvailableOptions = [];
686+
687+
dialog.ShowDialog();
688+
689+
var item = dialog.SelectedOption;
690+
var count = dialog.SelectedNumber;
691+
692+
if (!string.IsNullOrWhiteSpace(item))
693+
{
694+
challengesListBox.Items.Add($"{item}: {count}");
695+
_save.ChallengeTypes.Add(new ChallengeType
696+
{
697+
Type = item,
698+
Count = count
699+
});
700+
}
701+
}
650702
}

RainWorldSaveEditor/Forms/IntValueInputForm.Designer.cs

Lines changed: 157 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Data;
5+
using System.Drawing;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Text.RegularExpressions;
9+
using System.Threading.Tasks;
10+
using System.Windows.Forms;
11+
using static System.Runtime.InteropServices.JavaScript.JSType;
12+
13+
namespace RainWorldSaveEditor.Forms;
14+
public partial class IntValueInputForm : Form
15+
{
16+
public struct Option
17+
{
18+
public string Value;
19+
public string Display;
20+
}
21+
22+
public List<Option> AvailableOptions { get; set; } = [];
23+
24+
public string? SelectedOption { get; set; }
25+
public int SelectedNumber { get; set; }
26+
27+
public IntValueInputForm()
28+
{
29+
InitializeComponent();
30+
}
31+
32+
private void StringValueInputForm_Load(object sender, EventArgs e)
33+
{
34+
comboBox.Items.Clear();
35+
foreach (var item in AvailableOptions)
36+
{
37+
comboBox.Items.Add(item.Display);
38+
}
39+
}
40+
41+
private void addSelectionButton_Click(object sender, EventArgs e)
42+
{
43+
if (comboBox.SelectedIndex != -1 && int.TryParse(numberTextBox.Text, out var number))
44+
{
45+
SelectedOption = AvailableOptions[comboBox.SelectedIndex].Value;
46+
SelectedNumber = number;
47+
Close();
48+
}
49+
}
50+
51+
private void addCustomButton_Click(object sender, EventArgs e)
52+
{
53+
if (textBox.Text != "" && int.TryParse(numberTextBox.Text, out var number))
54+
{
55+
SelectedOption = textBox.Text;
56+
SelectedNumber = number;
57+
Close();
58+
}
59+
}
60+
61+
private void cancelButton_Click(object sender, EventArgs e)
62+
{
63+
SelectedOption = null;
64+
SelectedNumber = 0;
65+
Close();
66+
}
67+
}

0 commit comments

Comments
 (0)