Esempio n. 1
0
    public override bool addElement(int type, string atrezzoId)
    {
        bool elementAdded = false;

        if (type == Controller.ATREZZO)
        {
            // Show a dialog asking for the item id
            if (atrezzoId == null || atrezzoId.Equals(""))
            {
                atrezzoId = controller.showInputDialog(TC.get("Operation.AddAtrezzoTitle"), TC.get("Operation.AddAtrezzoMessage"), TC.get("Operation.AddAtrezzoDefaultValue"));
            }

            // If some value was typed and the identifier is valid
            if (atrezzoId != null && controller.isElementIdValid(atrezzoId))
            {
                // Add thew new item
                Atrezzo newAtrezzo = new Atrezzo(atrezzoId);
                atrezzoList.Add(newAtrezzo);
                atrezzoDataControlList.Add(new AtrezzoDataControl(newAtrezzo));
                controller.getIdentifierSummary().addAtrezzoId(atrezzoId);
                //controller.dataModified( );
                elementAdded = true;
            }
        }

        return(elementAdded);
    }
Esempio n. 2
0
    /**
     * Returns an atrezzo item with the given id.
     *
     * @param atrezzoId
     *            Atrezzo id
     * @return Atrezzo item requested, null if it was not found
     */

    public Atrezzo getAtrezzo(string atrezzoId)
    {
        Atrezzo selectedAtrezzo = null;

        foreach (Atrezzo at in atrezzo)
        {
            if (at.getId().Equals(atrezzoId))
            {
                selectedAtrezzo = at;
            }
        }

        return(selectedAtrezzo);
    }
        private void performAddElement(object sender, string atrezzoId)
        {
            // If some value was typed and the identifier is valid
            if (!controller.isElementIdValid(atrezzoId))
            {
                atrezzoId = controller.makeElementValid(atrezzoId);
            }

            // Add thew new item
            Atrezzo newAtrezzo = new Atrezzo(atrezzoId);

            atrezzoList.Add(newAtrezzo);
            atrezzoDataControlList.Add(new AtrezzoDataControl(newAtrezzo));
            controller.IdentifierSummary.addId <Atrezzo>(atrezzoId);
            controller.DataModified();
        }
Esempio n. 4
0
    public override bool moveElementUp(DataControl dataControl)
    {
        bool elementMoved = false;
        int  elementIndex = atrezzoList.IndexOf((Atrezzo)dataControl.getContent());

        if (elementIndex > 0)
        {
            Atrezzo            e = atrezzoList[elementIndex];
            AtrezzoDataControl c = atrezzoDataControlList[elementIndex];
            atrezzoList.RemoveAt(elementIndex);
            atrezzoDataControlList.RemoveAt(elementIndex);
            atrezzoList.Insert(elementIndex + 1, e);
            atrezzoDataControlList.Insert(elementIndex + 1, c);
            //controller.dataModified( );
            elementMoved = true;
        }

        return(elementMoved);
    }
    /**
     * Constructor.
     *
     * @param atrezzo
     *            Contained atrezzo item
     */
    public AtrezzoDataControl(Atrezzo atrezzo)
    {
        this.atrezzo       = atrezzo;
        this.resourcesList = atrezzo.getResources();

        selectedResources = 0;

        // Add a new resource if the list is empty
        if (resourcesList.Count == 0)
        {
            resourcesList.Add(new ResourcesUni());
        }

        // Create the subcontrollers
        resourcesDataControlList = new List <ResourcesDataControl>();
        foreach (ResourcesUni resources in resourcesList)
        {
            resourcesDataControlList.Add(new ResourcesDataControl(resources, Controller.ATREZZO));
        }
    }
        public override bool duplicateElement(DataControl dataControl)
        {
            if (!(dataControl is AtrezzoDataControl))
            {
                return(false);
            }

            Atrezzo newElement = (Atrezzo)(((Atrezzo)(dataControl.getContent())).Clone());
            string  id         = newElement.getId();

            if (!controller.isElementIdValid(id))
            {
                id = controller.makeElementValid(id);
            }

            newElement.setId(id);
            atrezzoList.Add(newElement);
            atrezzoDataControlList.Add(new AtrezzoDataControl(newElement));
            controller.IdentifierSummary.addId <Atrezzo>(id);
            return(true);
        }
Esempio n. 7
0
    public override bool duplicateElement(DataControl dataControl)
    {
        if (!(dataControl is AtrezzoDataControl))
        {
            return(false);
        }

        Atrezzo newElement = (Atrezzo)(((Atrezzo)(dataControl.getContent())).Clone());
        string  id         = newElement.getId();
        int     i          = 1;

        do
        {
            id = newElement.getId() + i;
            i++;
        } while (!controller.isElementIdValid(id, false));
        newElement.setId(id);
        atrezzoList.Add(newElement);
        atrezzoDataControlList.Add(new AtrezzoDataControl(newElement));
        controller.getIdentifierSummary().addAtrezzoId(id);
        return(true);
    }
Esempio n. 8
0
    /*
     * @Override
     * public Object clone() throws CloneNotSupportedException
     * {
     *
     *  Atrezzo a = (Atrezzo) super.clone( );
     *  return a;
     * }
     */

    public override object Clone()
    {
        Atrezzo a = (Atrezzo)base.Clone();

        return(a);
    }
Esempio n. 9
0
 /**
  * Adds an atrezzo item to the list of atrezzo items in the game
  *
  * @param atrezzo
  *            the atrezzo item to add
  */
 public void addAtrezzo(Atrezzo atrezzo)
 {
     this.atrezzo.Add(atrezzo);
 }
Esempio n. 10
0
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string,
     *      java.lang.string, org.xml.sax.Attributes)
     */
    public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {
            // If it is a object tag, create the new object (with its id)
            if (qName.Equals("atrezzoobject"))
            {
                string atrezzoId = "";

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("id"))
                    {
                        atrezzoId = entry.Value.ToString();
                    }
                }

                atrezzo = new Atrezzo(atrezzoId);

                descriptions = new List <Description>();
                atrezzo.setDescriptions(descriptions);
            }

            // If it is a resources tag, create the new resources and switch the state
            else if (qName.Equals("resources"))
            {
                currentResources = new ResourcesUni();

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("name"))
                    {
                        currentResources.setName(entry.Value.ToString());
                    }
                }

                reading = READING_RESOURCES;
            }

            // If it is an asset tag, read it and add it to the current resources
            else if (qName.Equals("asset"))
            {
                string type = "";
                string path = "";

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("type"))
                    {
                        type = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("uri"))
                    {
                        path = entry.Value.ToString();
                    }
                }

                // If the asset is not an special one
                //				if( !AssetsController.isAssetSpecial( path ) )
                currentResources.addAsset(type, path);
            }

            // If it is a description tag, create the new description (with its id)
            else if (qName.Equals("description"))
            {
                description = new Description();
                subParser   = new DescriptionsSubParser(description, chapter);
                subParsing  = SUBPARSING_DESCRIPTION;
            }

            // If it is a condition tag, create new conditions and switch the state
            else if (qName.Equals("condition"))
            {
                currentConditions = new Conditions();
                subParser         = new ConditionSubParser(currentConditions, chapter);
                subParsing        = SUBPARSING_CONDITION;
            }

            // If it is a effect tag, create new effects and switch the state
            else if (qName.Equals("effect"))
            {
                subParser  = new EffectSubParser(currentEffects, chapter);
                subParsing = SUBPARSING_EFFECT;
            }
        }

        // If it is reading an effect or a condition, spread the call
        if (subParsing != SUBPARSING_NONE)
        {
            //string id = this.atrezzo.getId( );
            subParser.startElement(namespaceURI, sName, qName, attrs);
        }
    }
Esempio n. 11
0
    public static XmlNode buildDOM(Atrezzo atrezzo)
    {
        XmlElement atrezzoElement = null;

        // Create the necessary elements to create the DOM
        XmlDocument doc = Writer.GetDoc();

        // Create the root node
        atrezzoElement = doc.CreateElement("atrezzoobject");
        atrezzoElement.SetAttribute("id", atrezzo.getId());

        // Append the documentation (if avalaible)
        if (atrezzo.getDocumentation() != null)
        {
            XmlNode atrezzoDocumentationNode = doc.CreateElement("documentation");
            atrezzoDocumentationNode.AppendChild(doc.CreateTextNode(atrezzo.getDocumentation()));
            atrezzoElement.AppendChild(atrezzoDocumentationNode);
        }

        // Append the resources
        foreach (ResourcesUni resources in atrezzo.getResources())
        {
            XmlNode resourcesNode = ResourcesDOMWriter.buildDOM(resources, ResourcesDOMWriter.RESOURCES_ITEM);
            doc.ImportNode(resourcesNode, true);
            atrezzoElement.AppendChild(resourcesNode);
        }

        // atrezzo only have name
        // Create the description
        XmlNode descriptionNode = doc.CreateElement("description");

        // Create and append the name, brief description and detailed description and its soundPaths
        XmlElement nameNode = doc.CreateElement("name");

        if (atrezzo.getDescription(0).getNameSoundPath() != null &&
            !atrezzo.getDescription(0).getNameSoundPath().Equals(""))
        {
            nameNode.SetAttribute("soundPath", atrezzo.getDescription(0).getNameSoundPath());
        }
        nameNode.AppendChild(doc.CreateTextNode(atrezzo.getDescription(0).getName()));
        descriptionNode.AppendChild(nameNode);

        XmlElement briefNode = doc.CreateElement("brief");

        /* if (description.getDescriptionSoundPath( )!=null && !description.getDescriptionSoundPath( ).Equals( "" )){
         *       briefNode.SetAttribute( "soundPath", description.getDescriptionSoundPath( ) );
         *   }
         *   briefNode.AppendChild( doc.CreateTextNode( description.getDescription( ) ) );*/
        briefNode.AppendChild(doc.CreateTextNode(""));
        descriptionNode.AppendChild(briefNode);

        XmlElement detailedNode = doc.CreateElement("detailed");

        /* if (description.getDetailedDescriptionSoundPath( )!=null && !description.getDetailedDescriptionSoundPath( ).Equals( "" )){
         *       detailedNode.SetAttribute( "soundPath", description.getDetailedDescriptionSoundPath( ) );
         *   }
         *   detailedNode.AppendChild( doc.CreateTextNode( description.getDetailedDescription( ) ) );*/
        detailedNode.AppendChild(doc.CreateTextNode(""));
        descriptionNode.AppendChild(detailedNode);

        // Append the description
        atrezzoElement.AppendChild(descriptionNode);


        return(atrezzoElement);
    }
Esempio n. 12
0
    /**
     * Adds an atrezzo item to the list of atrezzo items in the game
     *
     * @param atrezzo
     *            the atrezzo item to add
     */

    public void addAtrezzo(Atrezzo atrezzo)
    {
        this.atrezzo.Add(atrezzo);
    }
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            resourcess = element.SelectNodes("resources"),
            descriptionss = element.SelectNodes("description"),
            assets,
            conditions,
            effects = element.SelectNodes("effect");

        string tmpArgVal;

        string atrezzoId = element.GetAttribute("id");
        atrezzo = new Atrezzo(atrezzoId);

        descriptions = new List<Description>();
        atrezzo.setDescriptions(descriptions);

        if (element.SelectSingleNode("documentation") != null)
            atrezzo.setDocumentation(element.SelectSingleNode("documentation").InnerText);

        foreach (XmlElement el in resourcess)
        {
            currentResources = new ResourcesUni();
            tmpArgVal = el.GetAttribute("name");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentResources.setName(el.GetAttribute(tmpArgVal));
            }

            assets = el.SelectNodes("asset");
            foreach (XmlElement ell in assets)
            {
                string type = "";
                string path = "";

                tmpArgVal = ell.GetAttribute("type");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    type = tmpArgVal;
                }
                tmpArgVal = ell.GetAttribute("uri");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    path = tmpArgVal;
                }
                currentResources.addAsset(type, path);
            }

            conditions = el.SelectNodes("condition");
            foreach (XmlElement ell in conditions)
            {
                currentConditions = new Conditions();
                new ConditionSubParser_(currentConditions, chapter).ParseElement(ell);
                currentResources.setConditions(currentConditions);
            }

            atrezzo.addResources(currentResources);
        }

        foreach (XmlElement el in descriptionss)
        {
            description = new Description();
            new DescriptionsSubParser_(description, chapter).ParseElement(el);
            this.descriptions.Add(description);
        }

        foreach (XmlElement el in effects)
        {
            currentEffects = new Effects();
            new EffectSubParser_(currentEffects, chapter).ParseElement(el);
        }

        chapter.addAtrezzo(atrezzo);
    }
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string,
     *      java.lang.string, org.xml.sax.Attributes)
     */
    public override void startElement(string namespaceURI, string sName, string qName, Dictionary<string, string> attrs)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {
            // If it is a object tag, create the new object (with its id)
            if (qName.Equals("atrezzoobject"))
            {
                string atrezzoId = "";

                foreach (KeyValuePair<string, string> entry in attrs)
                    if (entry.Key.Equals("id"))
                        atrezzoId = entry.Value.ToString();

                atrezzo = new Atrezzo(atrezzoId);

                descriptions = new List<Description>();
                atrezzo.setDescriptions(descriptions);
            }

            // If it is a resources tag, create the new resources and switch the state
            else if (qName.Equals("resources"))
            {
                currentResources = new ResourcesUni();

                foreach (KeyValuePair<string, string> entry in attrs)
                {
                    if (entry.Key.Equals("name"))
                        currentResources.setName(entry.Value.ToString());
                }

                reading = READING_RESOURCES;
            }

            // If it is an asset tag, read it and add it to the current resources
            else if (qName.Equals("asset"))
            {
                string type = "";
                string path = "";

                foreach (KeyValuePair<string, string> entry in attrs)
                {
                    if (entry.Key.Equals("type"))
                        type = entry.Value.ToString();
                    if (entry.Key.Equals("uri"))
                        path = entry.Value.ToString();
                }

                // If the asset is not an special one
                //				if( !AssetsController.isAssetSpecial( path ) )
                currentResources.addAsset(type, path);
            }

            // If it is a description tag, create the new description (with its id)
            else if (qName.Equals("description"))
            {
                description = new Description();
                subParser = new DescriptionsSubParser(description, chapter);
                subParsing = SUBPARSING_DESCRIPTION;
            }

            // If it is a condition tag, create new conditions and switch the state
            else if (qName.Equals("condition"))
            {
                currentConditions = new Conditions();
                subParser = new ConditionSubParser(currentConditions, chapter);
                subParsing = SUBPARSING_CONDITION;
            }

            // If it is a effect tag, create new effects and switch the state
            else if (qName.Equals("effect"))
            {
                subParser = new EffectSubParser(currentEffects, chapter);
                subParsing = SUBPARSING_EFFECT;
            }
        }

        // If it is reading an effect or a condition, spread the call
        if (subParsing != SUBPARSING_NONE)
        {
            //string id = this.atrezzo.getId( );
            subParser.startElement(namespaceURI, sName, qName, attrs);
        }
    }
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            resourcess    = element.SelectNodes("resources"),
            descriptionss = element.SelectNodes("description"),
            assets,
            conditions,
            effects = element.SelectNodes("effect");

        string tmpArgVal;

        string atrezzoId = element.GetAttribute("id");

        atrezzo = new Atrezzo(atrezzoId);

        descriptions = new List <Description>();
        atrezzo.setDescriptions(descriptions);

        if (element.SelectSingleNode("documentation") != null)
        {
            atrezzo.setDocumentation(element.SelectSingleNode("documentation").InnerText);
        }

        foreach (XmlElement el in resourcess)
        {
            currentResources = new ResourcesUni();
            tmpArgVal        = el.GetAttribute("name");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentResources.setName(el.GetAttribute(tmpArgVal));
            }

            assets = el.SelectNodes("asset");
            foreach (XmlElement ell in assets)
            {
                string type = "";
                string path = "";

                tmpArgVal = ell.GetAttribute("type");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    type = tmpArgVal;
                }
                tmpArgVal = ell.GetAttribute("uri");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    path = tmpArgVal;
                }
                currentResources.addAsset(type, path);
            }

            conditions = el.SelectNodes("condition");
            foreach (XmlElement ell in conditions)
            {
                currentConditions = new Conditions();
                new ConditionSubParser_(currentConditions, chapter).ParseElement(ell);
                currentResources.setConditions(currentConditions);
            }

            atrezzo.addResources(currentResources);
        }

        foreach (XmlElement el in descriptionss)
        {
            description = new Description();
            new DescriptionsSubParser_(description, chapter).ParseElement(el);
            this.descriptions.Add(description);
        }

        foreach (XmlElement el in effects)
        {
            currentEffects = new Effects();
            new EffectSubParser_(currentEffects, chapter).ParseElement(el);
        }

        chapter.addAtrezzo(atrezzo);
    }