-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves #705.
- Loading branch information
Showing
18 changed files
with
182 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System.Drawing; | ||
using System.Text.RegularExpressions; | ||
using TRGE.Core; | ||
using TRImageControl; | ||
|
||
namespace TRRandomizerCore.Editors; | ||
|
||
public class TRRTitleEditor | ||
{ | ||
private static readonly Regex _titleRegex = new(@"TITLE_[A-Z]{2}\.DDS", RegexOptions.IgnoreCase); | ||
|
||
private static readonly Dictionary<TRVersion, Point> _badgePositions = new() | ||
{ | ||
[TRVersion.TR1] = new(645, 588), | ||
[TRVersion.TR2] = new(625, 665), | ||
[TRVersion.TR3] = new(262, 266), | ||
}; | ||
|
||
public static void Stamp(TRRScript script, TRDirectoryIOArgs io) | ||
{ | ||
IEnumerable<string> titleFiles = script.GetAdditionalBackupFiles() | ||
.Select(f => Path.GetFileName(f)) | ||
.Where(f => _titleRegex.IsMatch(f)); | ||
if (!titleFiles.Any()) | ||
{ | ||
return; | ||
} | ||
|
||
string sharedFolder = Path.GetFullPath(Path.Combine(io.BackupDirectory.FullName, @"..\..\TRR")); | ||
Directory.CreateDirectory(sharedFolder); | ||
|
||
TRImage badge = null; | ||
foreach (string titleFile in titleFiles) | ||
{ | ||
string cachedFile = Path.Combine(sharedFolder, | ||
$"{Path.GetFileNameWithoutExtension(titleFile)}_{script.Edition.Version}{Path.GetExtension(titleFile)}"); | ||
if (!File.Exists(cachedFile)) | ||
{ | ||
// This is slow with debugger attached and intensive in release, so we only want to do it once per game. | ||
TRImage titleImage = new(Path.Combine(io.BackupDirectory.FullName, titleFile)); | ||
badge ??= new($@"Resources\Shared\Graphics\{script.Edition.Version}badge-small.png"); | ||
titleImage.Import(badge, _badgePositions[script.Edition.Version], true); | ||
titleImage.Save(cachedFile); | ||
} | ||
|
||
File.Copy(cachedFile, Path.Combine(io.WIPOutputDirectory.FullName, titleFile), true); | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters