forked from akanyan/mu3-mods
feat: various enhancements
* AttractVideoPlayer,LoadBoost: allow setting a cache directory * AttractVideoPlayer: color leds * BetterGiveUp: prevent multiple restarts in a row * use GetTriggerOn in general where applicable
This commit is contained in:
@ -5,18 +5,22 @@ using System.IO;
|
||||
namespace MU3.Operation;
|
||||
|
||||
class patch_OperationManager: OperationManager {
|
||||
private static readonly string _fname = "data_advert_cache.txt";
|
||||
private ReadOnlyCollection<MovieData> _movieDataList;
|
||||
private int _movieIndex;
|
||||
private string _fileName;
|
||||
|
||||
~patch_OperationManager() {
|
||||
try {
|
||||
File.WriteAllText(_fname, _movieIndex.ToString());
|
||||
} catch(Exception) {}
|
||||
File.WriteAllText(_fileName, MovieIndex.ToString());
|
||||
} catch(Exception) { }
|
||||
}
|
||||
public int MovieIndex {
|
||||
set {
|
||||
_movieIndex = (value + _movieDataList.Count) % _movieDataList.Count;
|
||||
if(_movieDataList.Count > 0) {
|
||||
_movieIndex = (value + _movieDataList.Count) % _movieDataList.Count;
|
||||
} else {
|
||||
_movieIndex = 0;
|
||||
}
|
||||
}
|
||||
get {
|
||||
return _movieIndex;
|
||||
@ -25,7 +29,7 @@ class patch_OperationManager: OperationManager {
|
||||
public new MovieData movieData {
|
||||
get {
|
||||
if(_movieDataList.Count > 0) {
|
||||
return _movieDataList[_movieIndex];
|
||||
return _movieDataList[MovieIndex];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -35,8 +39,12 @@ class patch_OperationManager: OperationManager {
|
||||
|
||||
public new void initialize() {
|
||||
orig_initialize();
|
||||
|
||||
using IniFile iniFile = new("mu3.ini");
|
||||
_fileName = Path.Combine(iniFile.getValue("Extra", "CacheDir", "."), "data_advert_cache.txt");
|
||||
|
||||
try {
|
||||
_movieIndex = Math.Max(0, int.Parse(File.ReadAllText(_fname)));
|
||||
_movieIndex = Math.Max(0, int.Parse(File.ReadAllText(_fileName)));
|
||||
} catch(Exception) {
|
||||
_movieIndex = 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user