Beispiel #1
0
        public IAddOnDecorator Create(ICoffee coffee, AddOnType addOnType)
        {
            switch (addOnType)
            {
            case AddOnType.Milk:
                return(new MilkDecorator(coffee));

            case AddOnType.Chocolate:
                return(new ChocolateDecorator(coffee));

            case AddOnType.Cinnamon:
                return(new CinnamonDecorator(coffee));

            case AddOnType.WhippedCream:
                return(new WhippedCreamDecorator(coffee));

            case AddOnType.Ice:
                return(new IceDecorator(coffee));

            case AddOnType.Caramel:
                return(new CaramelDecorator(coffee));

            case AddOnType.Water:
                return(new WaterDecorator(coffee));

            default:
                throw new ArgumentException(nameof(addOnType));
            }
        }
Beispiel #2
0
        public void AddXML(string xml)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);
            XmlElement root = doc.DocumentElement;

            if (root.Name.ToLower() != "cevo_addonset")
            {
                throw new Exception("Wrong file format!");
            }

            currentVersion = AddOn.StringToVersion(root.GetAttribute("vcurrent"));
            foreach (XmlElement addOnNode in root.ChildNodes)
            {
                AddOnType type = AddOnType.Other;
                switch (addOnNode.Name.ToLower())
                {
                case "language": type = AddOnType.Language; break;

                case "bookset": type = AddOnType.BookSet; break;

                case "mapset": type = AddOnType.MapSet; break;

                case "ai": type = AddOnType.AI; break;
                }
                AddOn addOn = new AddOn(type, addOnNode.GetAttribute("id"), installed);
                addOn.Name    = addOnNode.GetAttribute("name");
                addOn.Creator = addOnNode.GetAttribute("creator");
                addOn.Readme  = addOnNode.GetAttribute("readme");
                addOn.Info    = addOnNode.GetAttribute("info");
                addOn.URL     = addOnNode.GetAttribute("url");
                addOn.Version = AddOn.StringToVersion(addOnNode.GetAttribute("v"));
                string sizeString = addOnNode.GetAttribute("size");
                if (!long.TryParse(sizeString, out addOn.Size))
                {
                    addOn.Size = 0;
                }

                foreach (XmlElement fileNode in addOnNode.ChildNodes)
                {
                    if (fileNode.Name.ToLower() == "file")
                    {
                        addOn.Files.Add(fileNode.GetAttribute("path"));
                    }
                }

                if (addOn.ID != "" && addOn.Name != "")
                {
                    Add(addOn);
                }
            }
        }
Beispiel #3
0
 public static bool CanInstall(AddOnType type, out string message)
 {
     message = "";
     if (type == AddOnType.AI)
     {
         if (HaveWriteAccess(programFolder))
         {
             return(true);
         }
         else
         {
             message = "Adding or removing AI modules requires write access to the C-evo program folder. Please contact your administrator.";
             return(false);
         }
     }
     else
     {
         return(true);
     }
 }
Beispiel #4
0
 public void SetData(AddOnSet installed, AddOnSet available, AddOnType type)
 {
     this.type = type;
     foreach (AddOn addOn in installed)
     {
         if (addOn.Type == type)
         {
             AddListItem(addOn);
             AddOn current = available.Find(addOn);
             if (current != null && current.Version > addOn.Version)
             {
                 AddListItem(current);
             }
         }
     }
     foreach (AddOn addOn in available)
     {
         if (addOn.Type == type && installed.Find(addOn) == null)
         {
             AddListItem(addOn);
         }
     }
     enabled = Installer.CanInstall(type, out disabledMessage);
 }
Beispiel #5
0
 public AddOn(AddOnType type, string id, bool installed)
 {
     this.Type      = type;
     this.ID        = id;
     this.Installed = installed;
 }
 public AddOn(string id, AddOnType type)
 {
     Id   = id;
     Type = type;
 }