Skip to content

Commit 5425754

Browse files
committed
add some extra stuff
1 parent 8b20a1a commit 5425754

5 files changed

Lines changed: 97 additions & 31 deletions

File tree

Binary/Binary.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
<TargetFramework>netcoreapp3.1</TargetFramework>
66
<UseWindowsForms>true</UseWindowsForms>
77
<ApplicationIcon>binary.ico</ApplicationIcon>
8-
<Version>2.8.0</Version>
8+
<Version>2.8.3</Version>
99
<Authors>MaxHwoy</Authors>
10+
<PublisherName>MaxHwoy</PublisherName>
1011
<Description>Tool for editing Need for Speed binary files (.BIN, .BUN, .LZC).</Description>
1112
<Copyright>Copyright © 2021 MaxHwoy</Copyright>
12-
<AssemblyVersion>2.8.0.0</AssemblyVersion>
13-
<FileVersion>2.8.0.0</FileVersion>
13+
<AssemblyVersion>2.8.3.0</AssemblyVersion>
14+
<FileVersion>2.8.3.0</FileVersion>
1415
</PropertyGroup>
1516

1617
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

Binary/Editor.cs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,8 @@ private void LoadProfile(string filename, bool showerrors)
14081408
Launch.Deserialize(filename, out Launch launch);
14091409
launch.ThisDir = Path.GetDirectoryName(filename);
14101410

1411+
this.FixLaunchDirectory(launch, filename);
1412+
14111413
if (launch.UsageID != eUsage.Modder)
14121414
{
14131415

@@ -1429,13 +1431,6 @@ private void LoadProfile(string filename, bool showerrors)
14291431

14301432
}
14311433

1432-
//if (launch.Files.Count > 10)
1433-
//{
1434-
//
1435-
// throw new Exception($"Cannot load more than 10 files at a time");
1436-
//
1437-
//}
1438-
14391434
this.EditorPropertyGrid.SelectedObject = null;
14401435
this.Profile = BaseProfile.NewProfile(launch.GameID, launch.Directory);
14411436
this.EditorStatusLabel.Text = "Loading... Please wait...";
@@ -1482,6 +1477,27 @@ private void LoadProfile(string filename, bool showerrors)
14821477
#endif
14831478
}
14841479

1480+
private void FixLaunchDirectory(Launch launch, string filename)
1481+
{
1482+
var directory = Path.GetDirectoryName(filename);
1483+
1484+
try
1485+
{
1486+
if (Path.IsPathRooted(launch.Directory))
1487+
{
1488+
return;
1489+
}
1490+
1491+
var maybePath = Path.GetFullPath(Path.Combine(directory, launch.Directory));
1492+
1493+
if (Directory.Exists(maybePath))
1494+
{
1495+
launch.Directory = maybePath;
1496+
}
1497+
}
1498+
catch { }
1499+
}
1500+
14851501
private void LoadTreeView(string selected = null)
14861502
{
14871503
this.EditorTreeView.BeginUpdate();

Binary/UI/VectorEditor.cs

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -235,36 +235,72 @@ private void ImportSVGToolStripMenuItem_Click(object sender, EventArgs e)
235235

236236
private void ExportSVGToolStripMenuItem_Click(object sender, EventArgs e)
237237
{
238-
using var dialog = new SaveFileDialog()
238+
var options = new string[]
239239
{
240-
AddExtension = true,
241-
AutoUpgradeEnabled = true,
242-
CheckPathExists = true,
243-
DefaultExt = ".svg",
244-
Filter = "Scalable Vector Graphics Files|*.svg|Any Files|*.*",
245-
FileName = this.Vector.CollectionName,
246-
OverwritePrompt = true,
247-
SupportMultiDottedExtensions = true,
248-
Title = "Select filename where vector should be exported",
240+
"512x512",
241+
"1024x1024",
242+
"2048x2048",
243+
"4096x4096",
244+
"8192x8192",
245+
"16384x16384",
246+
"32768x32768",
247+
"65536x65536",
249248
};
250249

251-
if (dialog.ShowDialog() == DialogResult.OK)
250+
var resolutions = new int[]
252251
{
252+
512,
253+
1024,
254+
2048,
255+
4096,
256+
8192,
257+
16384,
258+
32768,
259+
65536,
260+
};
253261

254-
try
262+
var description = "Select resolution in which vector vinyl should be exported";
263+
264+
using (var selection = new Prompt.Combo(options, description, false))
265+
{
266+
267+
if (selection.ShowDialog() == DialogResult.OK)
255268
{
269+
270+
using var dialog = new SaveFileDialog()
271+
{
272+
AddExtension = true,
273+
AutoUpgradeEnabled = true,
274+
CheckPathExists = true,
275+
DefaultExt = ".svg",
276+
Filter = "Scalable Vector Graphics Files|*.svg|Any Files|*.*",
277+
FileName = this.Vector.CollectionName,
278+
OverwritePrompt = true,
279+
SupportMultiDottedExtensions = true,
280+
Title = "Select filename where vector should be exported",
281+
};
256282

257-
var svg = this.Vector.GetSVGString(4096);
258-
File.WriteAllText(dialog.FileName, svg);
259-
MessageBox.Show($"Vector {this.Vector.CollectionName} has been successfully exported.", "Info",
260-
MessageBoxButtons.OK, MessageBoxIcon.Information);
283+
if (dialog.ShowDialog() == DialogResult.OK)
284+
{
261285

286+
try
287+
{
262288

263-
}
264-
catch (Exception ex)
265-
{
289+
var svg = this.Vector.GetSVGString(resolutions[selection.Value]);
290+
File.WriteAllText(dialog.FileName, svg);
291+
MessageBox.Show($"Vector {this.Vector.CollectionName} has been successfully exported.", "Info",
292+
MessageBoxButtons.OK, MessageBoxIcon.Information);
266293

267-
MessageBox.Show(ex.GetLowestMessage(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
294+
295+
}
296+
catch (Exception ex)
297+
{
298+
299+
MessageBox.Show(ex.GetLowestMessage(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
300+
301+
}
302+
303+
}
268304

269305
}
270306

Binary/Utils.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,5 +262,18 @@ public static string GetStatusString(int loadedFiles, long millisecondsToLoad, s
262262
{
263263
return $"Files: {loadedFiles} | {addon} Time: {millisecondsToLoad}ms | Real Time: {DateTime.Now:HH:mm:ss} | Script: {GetTruncatedPath(path)}";
264264
}
265+
266+
public static bool PathHasIllegalCharacters(string path)
267+
{
268+
try
269+
{
270+
Path.Combine(path, String.Empty); // amusement hack
271+
return true;
272+
}
273+
catch
274+
{
275+
return false;
276+
}
277+
}
265278
}
266279
}

0 commit comments

Comments
 (0)