progress, maybe

makes a properties file (and doesnt compile)

oh haha that rhymed
This commit is contained in:
ThatZeoMan 2022-08-17 22:08:10 -05:00
parent 3b7b87d1c8
commit 8ac8131458
3 changed files with 88 additions and 0 deletions

View file

@ -343,6 +343,10 @@ namespace HeavenStudio.Editor
using (var zipStream = levelFile.Open())
zipStream.Write(Encoding.UTF8.GetBytes(GetJson()), 0, Encoding.UTF8.GetBytes(GetJson()).Length);
var PropertiesFile = archive.CreateEntry("properties.json", System.IO.Compression.CompressionLevel.NoCompression);
using (var zipStream = PropertiesFile.Open())
zipStream.Write(Encoding.UTF8.GetBytes(GetPropertiesJson()), 0, Encoding.UTF8.GetBytes(GetPropertiesJson()).Length);
if (changedMusic || currentRemixPath != path)
{
// this gets rid of the music file for some reason, someone remind me to find a fix for this soon
@ -352,6 +356,8 @@ namespace HeavenStudio.Editor
var musicFile = archive.CreateEntry("song.ogg", System.IO.Compression.CompressionLevel.NoCompression);
using (var zipStream = musicFile.Open())
zipStream.Write(bytes, 0, bytes.Length);
}
currentRemixPath = path;
@ -369,6 +375,11 @@ namespace HeavenStudio.Editor
Timeline.FitToSong();
}
public void GetProperties(string json = "")
{
PropController.instance.LoadProperties(json);
}
public void OpenRemix()
{
var extensions = new[]
@ -419,6 +430,20 @@ namespace HeavenStudio.Editor
}
}
}
if (entry.Name == "properties.json")
{
using (var stream = entry.Open())
{
byte[] bytes;
using (var ms = new MemoryStream())
{
stream.CopyTo(ms);
bytes = ms.ToArray();
string json = Encoding.UTF8.GetString(bytes);
GetProperties(json);
}
}
}
}
}
}
@ -483,6 +508,13 @@ namespace HeavenStudio.Editor
return json;
}
public string GetPropertiesJson()
{
string json = string.Empty;
json = JsonConvert.SerializeObject(GameManager.instance.Beatmap);
return json;
}
public void SetGameEventTitle(string txt)
{
GameEventSelectorTitle.text = txt;

View file

@ -0,0 +1,45 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Starpelly;
using Newtonsoft.Json;
using HeavenStudio.Games;
namespace HeavenStudio.Editor
{
public class PropController : MonoBehaviour
{
public static PropController instance { get; private set; }
public Properties Properties = new Properties();
public void LoadProperties(string json = "")
{
SortPropertyList();
if (json != "")
{
Properties = JsonConvert.DeserializeObject<Properties>(json);
}
else
{
NewProperties();
}
Conductor.instance.SetBpm(Beatmap.bpm);
Conductor.instance.SetVolume(Beatmap.musicVolume);
Conductor.instance.firstBeatOffset = Beatmap.firstBeatOffset;
Stop(0);
SetCurrentEventToClosest(0);
}
public void SortPropertyList()
{
Beatmap.entities.Sort((x, y) => x.beat.CompareTo(y.beat));
Beatmap.tempoChanges.Sort((x, y) => x.beat.CompareTo(y.beat));
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7a85f5c7b1938474abd9f0e0ac8a558a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: