Skip to content

Commit

Permalink
actually fix pseudo read-only
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiiks committed Apr 2, 2019
1 parent 0b40fa0 commit 45b7db3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion SekiroSpeedrunUtil/MemoryThread.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Threading;
using SekiroSpeedrunUtil.structs;

Expand Down Expand Up @@ -35,7 +36,6 @@ private void ThreadProc() {
_manualResetEvent.WaitOne();
Thread.Sleep((int)_threadPriority);
try {

var remoteProc = RemoteProc.Instance();
if(remoteProc == null) continue;

Expand Down
2 changes: 1 addition & 1 deletion SekiroSpeedrunUtil/ui/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private void SetStatus(string status, Color color) {
});
}

private void UpdateCtrl(ISynchronizeInvoke obj, MethodInvoker action) {
private static void UpdateCtrl(ISynchronizeInvoke obj, MethodInvoker action) {
obj.InvokeIfRequired(action);
}

Expand Down
15 changes: 8 additions & 7 deletions SekiroSpeedrunUtil/ui/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ private void InitLogic() {
private void Init() {
Diag.WriteLine("Initializing");
SetStatus("Initializing", Color.OrangeRed);

var remoteProc = RemoteProc.Instance();
if (remoteProc == null) {
MetroMessageBox.Show(this, "Sekiro should be running but was not found..", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}

InitHotkeys();

foreach (var flag in Defs.Flags.FastReverse()) {
Expand Down Expand Up @@ -87,13 +95,6 @@ private void Init() {
});
LastIdol.Start();

var remoteProc = RemoteProc.Instance();
if (remoteProc == null) {
MetroMessageBox.Show(this, "Sekiro should be running but was not found..", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}

var lastIdol = remoteProc.Read<int>(Defs.PointerByName("LastCommutedIdol").GetAddress(remoteProc));
var idol = Defs.IdolById(lastIdol);
if (idol == null) {
Expand Down
17 changes: 8 additions & 9 deletions SekiroSpeedrunUtil/ui/MainSaveMan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private void SaveGame(string name) {
private void QuickLoad() {
if (_smQuickLoadLastItem == string.Empty || _smQuickLoadLastProfile == string.Empty) return;
try {
var fPath = $"{ProfileDir(_smQuickLoadLastProfile)}/{_smQuickLoadLastItem.Replace(" ", "_")}";
var fPath = $"{ProfileDir(true)}/{_smQuickLoadLastItem.Replace(" ", "_")}";
File.Copy(fPath, $"{_sekiroDir}/S0000.sl2", true);
Toast("Quickload Success!", Color.MediumAquamarine, Color.Black);
} catch (Exception ex) {
Expand All @@ -112,7 +112,7 @@ private void QuickLoad() {
private void QuickLoadQuick() {
if (_smQuickLoadLastQuick == string.Empty || _smQuickLoadLastProfile == string.Empty) return;
try {
var fPath = $"{ProfileDir(_smQuickLoadLastProfile)}/{_smQuickLoadLastQuick.Replace(" ", "_")}";
var fPath = $"{ProfileDir(true)}/{_smQuickLoadLastQuick.Replace(" ", "_")}";
File.Copy(fPath, $"{_sekiroDir}/S0000.sl2", true);
Toast("Quickload Success!", Color.MediumAquamarine, Color.Black);
} catch (Exception ex) {
Expand Down Expand Up @@ -190,6 +190,7 @@ private void SmOpenSavesDir_Click(object sender, EventArgs e) {
private void SmProfiles_SelectedIndexChanged(object sender, EventArgs e) {
try {
_profileDir = ProfileDir();
_smQuickLoadLastProfile = smProfiles.SelectedItem.ToString();
SmListSaves();
} catch (Exception ex) {
MetroMessageBox.Show(this,
Expand All @@ -213,9 +214,9 @@ private string SaveDir() {
return $"{appdataPath}/{_saveDir}/saves";
}

private string ProfileDir(string name = null) {
if(name != null) _smQuickLoadLastProfile = smProfiles.SelectedItem.ToString();
var dir = name == null ? $"{SaveDir()}/{smProfiles.SelectedItem}" : $"{SaveDir()}/{name}";
private string ProfileDir(bool quick = false) {
var name = quick ? _smQuickLoadLastProfile : smProfiles.SelectedItem;
var dir = $"{SaveDir()}/{name}";
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
return dir;
}
Expand Down Expand Up @@ -272,13 +273,11 @@ private void SmPseudoReadonlyHandler(object sender, GlobalEventArgs e) {
if (b == 0) {
if (_smSelfWrite) return;
_smSelfWrite = true;
//QuickLoad();

if (_smQuickLoadLastItem == string.Empty || _smQuickLoadLastProfile == string.Empty) return;
try {
var fPath = $"{ProfileDir(_smQuickLoadLastProfile)}/{_smQuickLoadLastItem.Replace(" ", "_")}";
var fPath = $"{ProfileDir(true)}/{_smQuickLoadLastItem.Replace(" ", "_")}";
File.Copy(fPath, $"{_sekiroDir}/S0000.sl2", true);
Toast("Quickload Success!", Color.MediumAquamarine, Color.Black);
Diag.WriteLine("Pseudo read-only success");
} catch (Exception ex) {
MetroMessageBox.Show(this,
ex.Message,
Expand Down

0 comments on commit 45b7db3

Please sign in to comment.