예제 #1
0
        protected bool LoadGameLibrary()
        {
            // load game library
            try
            {
                GameLibraryDownloader gldl = new GameLibraryDownloader(GardenConfig.Instance.NewestGameLibraryVersion);
                gldl.Start();
                GameLib = new GameLibrary();
                GameLib.LoadBin(GardenConfig.Instance.NewestGameLibraryVersion);
            }
            catch (Exception ex)
            {
                // if fails, try loading default lib from file, as alternative
                try
                {
                    GameLib = new GameLibrary();
                    GameLib.LoadBin(Path.Combine(Content.RootDirectory, "gamelib.bin"));
                }
                catch (Exception)
                {
                    IsMouseVisible = true;
                    MsgBox.Show("Could not load game library file", "Could not load game library file. Technical:\n" + ex.Message + ";\n" + ex.StackTrace);
                    initError = ex;
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
 protected bool LoadGameLibrary()
 {
     try
     {
         GameLib = new GameLibrary();
         GameLib.LoadBin(Path.Combine(Content.RootDirectory, "gamelib.bin"));
     }
     catch (Exception ex)
     {
         IsMouseVisible = true;
         MsgBox.Show("Could not load game library file", "Could not load game library file. Technical:\n" + ex.Message + ";\n" + ex.StackTrace);
         initError = ex;
         return(false);
     }
     return(true);
 }
예제 #3
0
        //string GAMELIB_UNPACKED_PATH = Path.Combine(CONFIG_DIR, GAMELIB_UNPACKED_TARGET_DIR, GAMELIB_BIN_FILE);
        //string GAMELIB_UNPACKED_DIR_PATH = Path.Combine(CONFIG_DIR, GAMELIB_UNPACKED_TARGET_DIR);
        //string GAMELIB_CONTENTFOLDER_PATH = Path.Combine(CONTENT_TARGET_DIR, GAMELIB_BIN_FILE);

        public void Run()
        {
            int t0, t1;

            Log("GameLibCompiler started.");

            GameLib = new GameLibrary();
            t0      = Environment.TickCount;
            GameLib.LoadJson(GAMELIB_JSON_PATH);
            t1 = Environment.TickCount;
            Log("Json load: " + (t1 - t0) + " ms.");
            Log("Library matrix size: X by Y = " + GameLib.GardenSizeX + " by " + GameLib.GardenSizeY);
            Log(GameLib.GetList().Count + " items loaded in library.");

            // save
            using (var file = File.Create(GAMELIB_BIN_PATH))
            {
                t0 = Environment.TickCount;
                Serializer.Serialize(file, GameLib.GetList().AsList());
                t1 = Environment.TickCount;
                Log("Bin  save: " + (t1 - t0) + " ms.");
            }

            // test load
            List <GardenItem> l;

            using (var file = File.OpenRead(GAMELIB_BIN_PATH))
            {
                t0 = Environment.TickCount;
                l  = Serializer.Deserialize <List <GardenItem> >(file);
                t1 = Environment.TickCount;
                Log("Bin  load test 1: " + (t1 - t0) + " ms.");
            }

            // test load 2
            t0 = Environment.TickCount;
            GameLibrary gl = new GameLibrary();

            gl.LoadBin(GAMELIB_BIN_PATH);
            t1 = Environment.TickCount;
            Log("Bin load test 2: " + (t1 - t0) + " ms.");
            int c = gl.GetList().Count;
        }