From e4fe580ec842382c26d90a8f8e672277fa3e9496 Mon Sep 17 00:00:00 2001
From: secsome <302702960@qq.com>
Date: Thu, 19 Aug 2021 23:48:37 +0800
Subject: [PATCH 1/8] Implement auto-saving feature
---
FA2sp.vcxproj | 1 +
FA2sp.vcxproj.filters | 3 +
FA2sp/FA2sp.Constants.h | 5 -
FA2sp/FA2sp.cpp | 17 +++
FA2sp/FA2sp.h | 4 +
FA2sp/Miscs/Hooks.SaveMap.cpp | 190 ++++++++++++++++++++++++++++++++++
README.md | 10 ++
7 files changed, 225 insertions(+), 5 deletions(-)
create mode 100644 FA2sp/Miscs/Hooks.SaveMap.cpp
diff --git a/FA2sp.vcxproj b/FA2sp.vcxproj
index 0efc64b..e1bf014 100644
--- a/FA2sp.vcxproj
+++ b/FA2sp.vcxproj
@@ -149,6 +149,7 @@
+
diff --git a/FA2sp.vcxproj.filters b/FA2sp.vcxproj.filters
index 3232614..a9fd12a 100644
--- a/FA2sp.vcxproj.filters
+++ b/FA2sp.vcxproj.filters
@@ -275,6 +275,9 @@
源文件
+
+ 源文件
+
diff --git a/FA2sp/FA2sp.Constants.h b/FA2sp/FA2sp.Constants.h
index dd32087..54139a5 100644
--- a/FA2sp/FA2sp.Constants.h
+++ b/FA2sp/FA2sp.Constants.h
@@ -1,10 +1,5 @@
#pragma once
-#define wstr(x) wstr_(x)
-#define wstr_(x) L ## #x
-#define str(x) str_(x)
-#define str_(x) #x
-
constexpr int PRODUCT_MAJOR = 1;
constexpr int PRODUCT_MINOR = 0;
constexpr int PRODUCT_REVISION = 3;
diff --git a/FA2sp/FA2sp.cpp b/FA2sp/FA2sp.cpp
index 97ab221..44849b8 100644
--- a/FA2sp/FA2sp.cpp
+++ b/FA2sp/FA2sp.cpp
@@ -35,6 +35,10 @@ int ExtConfigs::Waypoint_Background_Color;
bool ExtConfigs::ExtWaypoints;
int ExtConfigs::UndoRedoLimit;
bool ExtConfigs::UseRGBHouseColor;
+bool ExtConfigs::SaveMap;
+bool ExtConfigs::SaveMap_AutoSave;
+int ExtConfigs::SaveMap_AutoSave_Interval;
+int ExtConfigs::SaveMap_AutoSave_MaxCount;
MultimapHelper Variables::Rules = { &GlobalVars::INIFiles::Rules(), &GlobalVars::INIFiles::CurrentDocument() };
@@ -81,6 +85,19 @@ void FA2sp::ExtConfigsInitialize()
ExtConfigs::UndoRedoLimit = fadata.GetInteger("ExtConfigs", "UndoRedoLimit", 16);
ExtConfigs::UseRGBHouseColor = fadata.GetBool("ExtConfigs", "UseRGBHouseColor");
+
+ if (ExtConfigs::SaveMap = fadata.GetBool("ExtConfigs", "SaveMap"))
+ {
+ if (ExtConfigs::SaveMap_AutoSave = fadata.GetBool("ExtConfigs", "SaveMap.AutoSave"))
+ {
+ ExtConfigs::SaveMap_AutoSave_Interval = fadata.GetInteger("ExtConfigs", "SaveMap.AutoSave.Interval", 300);
+ ExtConfigs::SaveMap_AutoSave_MaxCount = fadata.GetInteger("ExtConfigs", "SaveMap.AutoSave.MaxCount", 10);
+ }
+ else
+ {
+ ExtConfigs::SaveMap_AutoSave_Interval = -1;
+ }
+ }
}
// DllMain
diff --git a/FA2sp/FA2sp.h b/FA2sp/FA2sp.h
index 6410f86..d5468f9 100644
--- a/FA2sp/FA2sp.h
+++ b/FA2sp/FA2sp.h
@@ -45,6 +45,10 @@ class ExtConfigs
static bool ExtWaypoints;
static int UndoRedoLimit;
static bool UseRGBHouseColor;
+ static bool SaveMap;
+ static bool SaveMap_AutoSave;
+ static int SaveMap_AutoSave_Interval;
+ static int SaveMap_AutoSave_MaxCount;
};
class Variables
diff --git a/FA2sp/Miscs/Hooks.SaveMap.cpp b/FA2sp/Miscs/Hooks.SaveMap.cpp
new file mode 100644
index 0000000..391ff8e
--- /dev/null
+++ b/FA2sp/Miscs/Hooks.SaveMap.cpp
@@ -0,0 +1,190 @@
+#include
+
+#include
+#include
+#include
+#include
+
+#include "../FA2sp.h"
+#include "../FA2sp.Constants.h"
+
+#include