Skip to content

Commit

Permalink
grab a background image on Intralism to Pulsarc conversion
Browse files Browse the repository at this point in the history
Only works on maps with less than one image for every 10 seconds of gameplay. So most maps with 1 image, or any maps that don't use high-frame rate image animation.
Users can define an override and choose what image they want for the converted map in config.ini
  • Loading branch information
dustdustinthewind committed Nov 22, 2019
1 parent d399b17 commit 9f4eac0
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 8 deletions.
5 changes: 4 additions & 1 deletion Pulsarc/Pulsarc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
<AssemblyName>Pulsarc</AssemblyName>
<ApplicationIcon>Icon.ico</ApplicationIcon>
<StartupObject></StartupObject>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Pulsarc/UI/Screens/Gameplay/GameplayEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ private void HandleActiveEvents()
// If the event is active, handle it
if (ActiveEvents[i].Active)
ActiveEvents[i].Handle(this);
// Otherwise, add this to a list of events to remove from active events
// Otherwise, add remove it
else
ActiveEvents.RemoveAt(i--);
}
Expand Down
30 changes: 28 additions & 2 deletions Pulsarc/Utils/BeatmapConversion/IntralismToPulsarc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ public List<Beatmap> Convert(string folder_path)
List<Beatmap> results = new List<Beatmap>();
Beatmap result = new Beatmap();

string backgroundImage = Config.Get["Converting"]["BGImage"];

// See if the provided path exists
if(Directory.Exists(folder_path))
if (Directory.Exists(folder_path))
{
string configPath = $"{folder_path}/config.txt";

Expand All @@ -41,6 +43,20 @@ public List<Beatmap> Convert(string folder_path)
// Convert the config file to an IntrlaismBeatmap
IntralismBeatmap beatmap = JsonConvert.DeserializeObject<IntralismBeatmap>(File.ReadAllText(configPath, Encoding.UTF8));

string name = "";

// If the user specified an image path to use, use that path.
if (backgroundImage != null && !backgroundImage.Equals(""))
name = backgroundImage;

// If there's an average of 1 image per 10 seconds of map time or less
// and the user-defined path doesn't exist, grab the first image path in
// the beatmap.
if (!File.Exists($"{folder_path}/{name}") && beatmap.LevelResources.Count < Math.Ceiling(beatmap.MusicTime / 10))
beatmap.LevelResources[0].TryGetValue("path", out name);

result.Background = name;

// Fill in the missing metadata
result.FormatVersion = "1";
result.Mapper = "Intralism";
Expand Down Expand Up @@ -134,7 +150,7 @@ public void Save(string folder_path)
{
Beatmap map = Convert(folder_path).First();

if(map.Audio != null)
if (map.Audio != null)
{
string audioPath = $"{folder_path}/{map.Audio}";

Expand All @@ -148,8 +164,18 @@ public void Save(string folder_path)
if (!Directory.Exists(dirName))
Directory.CreateDirectory(dirName);

// Copy Audio File
File.Copy(audioPath, $"{dirName}/{map.Audio}", true);

// Copy Background Image
string backgroundPath = $"{folder_path}/{map.Background}";

if (File.Exists(backgroundPath))
File.Copy(backgroundPath, $"{dirName}/{map.Background}", true);
else
map.Background = "";


// The file name will look like "Unknown - MapTitle [Converted] (Mapper).psc"
string difficultyFileName = string.Join("_", ($"{map.Artist} - {map.Title} [{map.Version}] ({map.Mapper})").Split(Path.GetInvalidFileNameChars()));

Expand Down
2 changes: 2 additions & 0 deletions Pulsarc/Utils/BeatmapConversion/ManiaToPulsarc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ public void Save(string folder_path)
if (!Directory.Exists(dirName))
Directory.CreateDirectory(dirName);

// Copy Audio File
File.Copy(audioPath, $"{dirName}/{map.Audio}", true);

// Copy Background Image
string backgroundPath = $"{folder_path}/{map.Background}";

if (File.Exists(backgroundPath))
Expand Down
13 changes: 9 additions & 4 deletions Pulsarc/config.ini
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
[Converting]
Game = Intralism
Path = D:\SteamLibrary\steamapps\common\Intralism\Editor\KobaryoLotusQuest
Path = D:\SteamLibrary\steamapps\common\Intralism\Editor\TristamOnceAgain

;Pulsarc will automatically grab the first image of a non-animated Intralism map.
;To override this, type in the image name (with extension) below
;i.e. "background2.png"
BGImage = norm.jpg

[Profile]
Username = Player

[Gameplay]
SongRate = 1
ApproachSpeed = 32
ApproachSpeed = 25
BackgroundDim = 70
FadeTime = 200
Hidden = false
Autoplay = false

[Audio]
GlobalOffset = 0
MusicVolume = 30
MusicVolume = 0
RatePitch = false

[Bindings]
Expand All @@ -25,7 +30,7 @@ Down = J
Right = K
Pause = P
Continue = O
Retry = DollarSign
Retry = OemTilde
Convert = C

[Graphics]
Expand Down

0 comments on commit 9f4eac0

Please sign in to comment.