示例#1
0
        public bool LoadStructure(System.IO.BinaryReader br)
        {
            String s = "";

            while (true)
            {
                s = br.ReadString();
                if (s.StartsWith("0"))//CSC
                {
                    var a = GUIEngine.s_componentSelector._getComponent(s.Substring(1));
                    if (a == null)
                    {
                        return(false);
                    }
                    GUIEngine.s_componentSelector.AddComponent(this, a);
                    continue;
                }
                if (s.StartsWith("1"))//CSF
                {
                    CSFolder f = GetCreateSubfolder(s.Substring(1));

                    if (!f.LoadStructure(br))
                    {
                        return(false);
                    }
                    continue;
                }
                if (s.StartsWith("2"))//folder end
                {
                    break;
                }
            }

            return(true);
        }
示例#2
0
        public bool LoadStructure()
        {
            IO.Log.Write("        CS load structure");
            rootTiles.Clear();
            allTiles.Clear();

            if (!Directory.Exists("Saves")) return false;
            if (!File.Exists("Saves/cs.prf")) return false;

            IO.Log.Write("        Reading from file...");
            BinaryReader br = new BinaryReader(new FileStream("Saves/cs.prf", FileMode.Open));
            int t = br.ReadInt32();
            IO.Log.Write("        " + t.ToString() + " components in checksum");
            if (t != components.Count)
            {
                br.Close();
                return false;
            }

            String s = "";
            while (true)
            {
                s = br.ReadString();
                if (s.StartsWith("0"))//CSC
                {
                    var a = _getComponent(s.Substring(1));
                    if (a == null)
                    {
                        br.Close();
                        return false;
                    }
                    AddComponent(null, a);
                    continue;
                }
                if (s.StartsWith("1"))//CSF
                {
                    CSFolder f = new CSFolder();
                    f.Text = s.Substring(1);
                    if (ComponentSelector.folderTextures.ContainsKey(f.Text))
                        f.Texture = ResourceManager.Load<Texture2D>(ComponentSelector.folderTextures[f.Text]);
                    else
                        f.Texture = GraphicsEngine.pixel;
                    f.position = new Vector2(4, 4 + rootTiles.Count * 40);
                    f.parent = null;
                    f.localIndex = rootTiles.Count;
                    f.isVisible = true;
                    f.Color = Color.White;
                    rootTiles.Add(f);
                    allTiles.Add(f);

                    if (!f.LoadStructure(br))
                    {
                        br.Close();
                        return false;
                    }
                    continue;
                }
                if (s.StartsWith("3"))//file end
                    break;
            }

            br.Close();
            //scan fav folder
            IO.Log.Write("        Scanning for favourites");
            CSFolder fav = GetFavFolder();
            if (fav != null)
            {
                for (int i = 0; i < fav.Tiles.Count; i++)
                {
                    for (int j = 0; j < components.Count; j++)
                    {
                        if (components[j].Text == fav.Tiles[i].Text)
                        {
                            components[j].isFavourite = true;
                        }
                    }
                }
            }

            return true;
        }
示例#3
0
        public bool LoadStructure()
        {
            IO.Log.Write("        CS load structure");
            rootTiles.Clear();
            allTiles.Clear();

            if (!Directory.Exists("Saves"))
            {
                return(false);
            }
            if (!File.Exists("Saves/cs.prf"))
            {
                return(false);
            }

            IO.Log.Write("        Reading from file...");
            BinaryReader br = new BinaryReader(new FileStream("Saves/cs.prf", FileMode.Open));
            int          t  = br.ReadInt32();

            IO.Log.Write("        " + t.ToString() + " components in checksum");
            if (t != components.Count)
            {
                br.Close();
                return(false);
            }

            String s = "";

            while (true)
            {
                s = br.ReadString();
                if (s.StartsWith("0"))//CSC
                {
                    var a = _getComponent(s.Substring(1));
                    if (a == null)
                    {
                        br.Close();
                        return(false);
                    }
                    AddComponent(null, a);
                    continue;
                }
                if (s.StartsWith("1"))//CSF
                {
                    CSFolder f = new CSFolder();
                    f.Text = s.Substring(1);
                    if (ComponentSelector.folderTextures.ContainsKey(f.Text))
                    {
                        f.Texture = ResourceManager.Load <Texture2D>(ComponentSelector.folderTextures[f.Text]);
                    }
                    else
                    {
                        f.Texture = GraphicsEngine.pixel;
                    }
                    f.position   = new Vector2(4, 4 + rootTiles.Count * 40);
                    f.parent     = null;
                    f.localIndex = rootTiles.Count;
                    f.isVisible  = true;
                    f.Color      = Color.White;
                    rootTiles.Add(f);
                    allTiles.Add(f);

                    if (!f.LoadStructure(br))
                    {
                        br.Close();
                        return(false);
                    }
                    continue;
                }
                if (s.StartsWith("3"))//file end
                {
                    break;
                }
            }

            br.Close();
            //scan fav folder
            IO.Log.Write("        Scanning for favourites");
            CSFolder fav = GetFavFolder();

            if (fav != null)
            {
                for (int i = 0; i < fav.Tiles.Count; i++)
                {
                    for (int j = 0; j < components.Count; j++)
                    {
                        if (components[j].Text == fav.Tiles[i].Text)
                        {
                            components[j].isFavourite = true;
                        }
                    }
                }
            }

            return(true);
        }