aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Frontend
diff options
context:
space:
mode:
authorRogueAI42 <[email protected]>2017-08-03 22:11:35 +1000
committerRogueAI42 <[email protected]>2017-08-03 22:11:35 +1000
commit80f7d54de91246197607ee4d3829bf6a54d63bca (patch)
treeafb6a182659169e392a58ff69cfa1e5da5677000 /ShiftOS.Frontend
parent19fceb8326fc395bee1fd858ec6617564cbbac74 (diff)
downloadshiftos_thereturn-80f7d54de91246197607ee4d3829bf6a54d63bca.tar.gz
shiftos_thereturn-80f7d54de91246197607ee4d3829bf6a54d63bca.tar.bz2
shiftos_thereturn-80f7d54de91246197607ee4d3829bf6a54d63bca.zip
added save/load support (not enabled) to chat AI
OnUnload() doesn't actually seem to get called, ever, so I added an ifdef'd out line to the message send function that would save the cache every single time the user sent a message. It works, but eugh... my poor SSD works hard. I want to give it a break.
Diffstat (limited to 'ShiftOS.Frontend')
-rw-r--r--ShiftOS.Frontend/Apps/ChatClient.cs22
1 files changed, 18 insertions, 4 deletions
diff --git a/ShiftOS.Frontend/Apps/ChatClient.cs b/ShiftOS.Frontend/Apps/ChatClient.cs
index de9d80f..acb6b6f 100644
--- a/ShiftOS.Frontend/Apps/ChatClient.cs
+++ b/ShiftOS.Frontend/Apps/ChatClient.cs
@@ -93,7 +93,12 @@ namespace ShiftOS.Frontend.Apps
//Let's try the AI stuff... :P
if (!messagecache.Contains(_messages.Last().Message))
+ {
messagecache.Add(_messages.Last().Message);
+#if RIP_USERS_SSD
+ SaveCache();
+#endif
+ }
var rmsg = messagecache[rnd.Next(messagecache.Count)];
var split = new List<string>(rmsg.Split(' '));
List<string> nmsg = new List<string>();
@@ -127,7 +132,7 @@ namespace ShiftOS.Frontend.Apps
readonly string[] outcomes = new string[] { "ok", "sure", "yeah", "yes", "no", "nope", "alright" };
Random rnd = new Random();
- List<string> messagecache = new List<string>();
+ private List<string> messagecache = new List<string>();
public void SendClientMessage(string nick, string message)
{
@@ -170,21 +175,30 @@ namespace ShiftOS.Frontend.Apps
}
gfx.DrawRectangle(vertSeparatorLeft, 0, 1, _bottomseparator, UIManager.SkinTextures["ControlTextColor"]);
}
-
+
public void OnLoad()
{
-
+ if (System.IO.File.Exists("aicache.dat"))
+ messagecache = System.IO.File.ReadAllLines("aicache.dat").ToList();
}
public void OnSkinLoad()
{
}
-
+
public bool OnUnload()
{
+ // this doesn't get called... dammit
+ SaveCache();
return true;
}
+ private void SaveCache()
+ {
+ // It's watching you...
+ System.IO.File.WriteAllLines("aicache.dat", messagecache);
+ }
+
public void OnUpgrade()
{
}