This repository has been archived by the owner on May 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathForm1.cs
122 lines (100 loc) · 3.65 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PK2SDK;
namespace PK2ScoreEditor
{
public partial class Form1 : Form
{
PK2EpisodeScores scores = new PK2EpisodeScores();
String file;
public Form1()
{
InitializeComponent();
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
scores.SetEpisodeTopPlayer(textBox1.Text);
scores.EpisodeTopScore = (int) numericUpDown1.Value;
scores.TopPlayer[0][0] = (char) 0x20;
scores.FastestPlayer[0][0] = (char) 0x20;
for (int i = 1; i < 20; i++)
{
scores.TopPlayer[0][i] = (char) 0x0;
scores.FastestPlayer[0][i] = (char) 0x0;
}
for (int i = 1; i < dataGridView1.Rows.Count; i++)
{
scores.SetTopPlayer(i, dataGridView1.Rows[i - 1].Cells[0].Value.ToString());
scores.BestScores[i] = Convert.ToInt32(dataGridView1.Rows[i - 1].Cells[1].Value);
scores.SetFastestPlayer(i, dataGridView2.Rows[i - 1].Cells[0].Value.ToString());
scores.BestTimes[i] = Convert.ToInt32(dataGridView2.Rows[i - 1].Cells[1].Value);
}
Console.WriteLine(scores.TopPlayer.Count);
bool k = scores.save(file);
if (k)
{
Console.WriteLine("OK");
} else
{
Console.WriteLine("NAH!");
}
}
private void Form1_Load(object sender, EventArgs e)
{
toolStripComboBox1.SelectedIndex = 0;
}
private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (toolStripComboBox1.SelectedIndex == 0)
{
scores.setLevelLimit(50);
} else
{
scores.setLevelLimit(100);
}
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
DialogResult r = openFileDialog1.ShowDialog();
if (r == DialogResult.OK)
{
bool ok = false;
try
{
file = openFileDialog1.FileName;
ok = scores.load(openFileDialog1.FileName);
}
catch (Exception ex)
{
if (ex.GetType() == typeof(System.IO.EndOfStreamException))
{
MessageBox.Show("Couldn't read file.\nTry to change the version.", "Wrong version");
}
}
if (ok)
{
dataGridView1.Rows.Clear();
dataGridView1.Refresh();
dataGridView2.Rows.Clear();
dataGridView2.Refresh();
for (int i = 1; i < scores.getLevelLimit(); i++)
{
dataGridView1.Rows.Add(scores.GetTopPlayer(i));
dataGridView1.Rows[i - 1].Cells[1].Value = scores.BestScores[i].ToString();
dataGridView2.Rows.Add(scores.GetFastestPlayer(i));
dataGridView2.Rows[i - 1].Cells[1].Value = scores.BestTimes[i].ToString();
}
textBox1.Text = new String(scores.EpisodeTopPlayer);
numericUpDown1.Value = (int) scores.EpisodeTopScore;
}
}
}
}
}