Exemplo n.º 1
0
        private void InitSystem()
        {
            Hashtable sysConfig = new Hashtable();
            string    filename  = "config.sav";
            string    savepath  = LoadSaveTool.GetSavePath(filename);

            if (!LoadSaveTool.IsFileExists(savepath))
            {
                //若不存在则创建默认数据
                ResetSysConfig();
                sysConfig = datapool.GetSystemTable();
                //string toSave = LoadSaveTool.RijndaelEncrypt(JsonConvert.SerializeObject(sysConfig), LoadSaveTool.GetKey());
                string toSave = JsonConvert.SerializeObject(sysConfig);
                LoadSaveTool.CreateDirectory(LoadSaveTool.SAVE_PATH);
                LoadSaveTool.CreateFile(savepath, toSave);
            }
            else
            {
                StreamReader savefile = new StreamReader(savepath);
                //string toLoad = LoadSaveTool.RijndaelDecrypt(savefile.ReadToEnd(), LoadSaveTool.GetKey());
                string toLoad = savefile.ReadToEnd();
                //string x = (string)JsonMapper.ToObject(toLoad);
                sysConfig = JsonConvert.DeserializeObject <Hashtable>(toLoad);
                LoadSysConfig(sysConfig);
            }
        }
Exemplo n.º 2
0
        public void Load(int i)
        {
            string       filename = "data" + i + ".sav";
            StreamReader savefile = new StreamReader(LoadSaveTool.GetSavePath(filename));
            string       toLoad   = savefile.ReadToEnd();

            //toLoad = LoadSaveTool.RijndaelDecrypt(toLoad, LoadSaveTool.GetKey());
            LoadDataFromJson(toLoad);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 初始化多周目数据
        /// </summary>
        private void InitMultiplay()
        {
            List <bool> musicTable  = new List <bool>();
            List <bool> cgTable     = new List <bool>();
            List <bool> endingTable = new List <bool>();
            List <bool> caseTable   = new List <bool>();

            string filename = "datamp.sav";
            string savepath = LoadSaveTool.GetSavePath(filename);

            //若不存在 则生成默认数据表 并写入本地文件
            if (!LoadSaveTool.IsFileExists(savepath))
            {
                #region 临时测试用 静态表
                musicTable.Add(true);
                cgTable.Add(true);
                endingTable.Add(true);
                caseTable.Add(true);
                #endregion

                //Hashtable SysSave = new Hashtable();
                Dictionary <string, List <bool> > SysSave = new Dictionary <string, List <bool> >();
                SysSave.Add("MusicTable", musicTable);
                SysSave.Add("CGTable", cgTable);
                SysSave.Add("EndingTable", endingTable);
                SysSave.Add("CaseTable", caseTable);

                //string toSave = LoadSaveTool.RijndaelEncrypt(JsonConvert.SerializeObject(SysSave), LoadSaveTool.GetKey());
                string toSave = JsonConvert.SerializeObject(SysSave);
                LoadSaveTool.CreateDirectory(LoadSaveTool.SAVE_PATH);
                LoadSaveTool.CreateFile(savepath, toSave);
            }
            else
            {
                //存在 则读取二周目数据
                StreamReader savefile = new StreamReader(savepath);
                //string toLoad = LoadSaveTool.RijndaelDecrypt(savefile.ReadToEnd(), LoadSaveTool.GetKey());
                string toLoad = savefile.ReadToEnd();
                Dictionary <string, List <bool> > sysSave = JsonConvert.DeserializeObject <Dictionary <string, List <bool> > >(toLoad);
                musicTable  = sysSave["MusicTable"];
                cgTable     = sysSave["CGTable"];
                endingTable = sysSave["EndingTable"];
                caseTable   = sysSave["CaseTable"];
            }
            datapool.WriteSystemVar("音乐表", musicTable);
            datapool.WriteSystemVar("画廊表", cgTable);
            datapool.WriteSystemVar("结局表", endingTable);
            datapool.WriteSystemVar("案件表", caseTable);


            //TODO:静态表格 例如cginfo
            Dictionary <int, string> cgInfo = new Dictionary <int, string>();
            cgInfo.Add(0, "Logo");
            cgInfo.Add(1, "classroom");
            datapool.WriteSystemVar("CG信息表", cgInfo);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 读取存档的图片并写入Data
        /// </summary>
        public void RefreshSavePic()
        {
            Dictionary <int, SavingInfo> list    = (Dictionary <int, SavingInfo>)datapool.GetSystemVar("存档信息");
            Dictionary <string, byte[]>  savepic = new Dictionary <string, byte[]>();

            foreach (KeyValuePair <int, SavingInfo> kv in list)
            {
                string     picname = "data" + kv.Key + ".png";
                string     picpath = LoadSaveTool.GetSavePath(picname);
                FileStream fs      = new FileStream(picpath, FileMode.Open, FileAccess.Read);
                byte[]     bytes   = new byte[fs.Length];
                fs.Read(bytes, 0, (int)fs.Length);
                fs.Close();
                savepic.Add(kv.Value.picPath, bytes);
            }
            datapool.WriteSystemVar("存档缩略图", savepic);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 初始化存档
        /// </summary>
        private void InitSaving()
        {
            Dictionary <int, SavingInfo> list = new Dictionary <int, SavingInfo>();
            string filename = "datasv.sav";
            string savepath = LoadSaveTool.GetSavePath(filename);

            if (LoadSaveTool.IsFileExists(savepath))
            {
                //读取存档列表
                StreamReader savefile = new StreamReader(savepath);
                //string toLoad = LoadSaveTool.RijndaelDecrypt(savefile.ReadToEnd(), LoadSaveTool.GetKey());
                string toLoad = savefile.ReadToEnd();
                //string x = (string)JsonMapper.ToObject(toLoad);
                list = JsonConvert.DeserializeObject <Dictionary <int, SavingInfo> >(toLoad);
            }
            datapool.WriteSystemVar("存档信息", list);
            RefreshSavePic();
        }
Exemplo n.º 6
0
        public void Delete(int i)
        {
            //删除存档
            string filename = "data" + i + ".sav";

            LoadSaveTool.DeleteFile(filename);
            //删除截图
            string picname = "data" + i + ".png";

            LoadSaveTool.DeleteFile(picname);
            //更新存档信息
            Dictionary <int, SavingInfo> savedic = (Dictionary <int, SavingInfo>)datapool.GetSystemVar("存档信息");

            if (savedic.ContainsKey(i))
            {
                savedic.Remove(i);
            }
            //写入系统存档
            string sysSave = JsonConvert.SerializeObject(savedic);

            LoadSaveTool.CreateFile(LoadSaveTool.GetSavePath("datasv.sav"), sysSave);
            RefreshSavePic();
        }
Exemplo n.º 7
0
        public void Save(int i)
        {
            //string toSave = LoadSaveTool.RijndaelEncrypt(DataToJsonString(), LoadSaveTool.GetKey());
            string toSave   = DataToJsonString();
            string filename = "data" + i + ".sav";

            LoadSaveTool.CreateDirectory(LoadSaveTool.SAVE_PATH);
            LoadSaveTool.CreateFile(LoadSaveTool.GetSavePath(filename), toSave);
            //储存截图
            string picname = "data" + i + ".png";

            byte[] picdata = (byte[])datapool.GetSystemVar("缩略图");
            LoadSaveTool.CreatByteFile(LoadSaveTool.GetSavePath(picname), picdata);
            //更新存档信息
            Dictionary <int, SavingInfo> savedic = (Dictionary <int, SavingInfo>)datapool.GetSystemVar("存档信息");
            //TODO: 获取状态
            string     gamemode   = GetGameVar <string>("MODE");
            string     savetime   = DateTime.Now.ToString("yyyy/MM/dd\nHH:mm");
            string     customtext = "存档了!";
            SavingInfo info       = new SavingInfo(gamemode, savetime, customtext, picname);

            if (savedic.ContainsKey(i))
            {
                savedic[i] = info;
            }
            else
            {
                savedic.Add(i, info);
            }
            //写入系统存档
            //string sysSave = LoadSaveTool.RijndaelEncrypt(JsonMapper.Serialize(savedic), LoadSaveTool.GetKey());
            string sysSave = JsonConvert.SerializeObject(savedic);

            LoadSaveTool.CreateFile(LoadSaveTool.GetSavePath("datasv.sav"), sysSave);
            RefreshSavePic();
        }