Пример #1
0
        public RenderNode(GBXMLContainer initData, RenderNode parent)
        {
            Initdata = (GBXMLContainer)initData.Clone();
            Parent = parent;
            name = InitData.Name;

            LoadPatterns();

            state = InitData["InitialState"].Text;
            position = GBXMLContainer.ReadPointF(InitData);
            color = new GBColor(InitData["Color"]);

            zOrder = NumberConverter.ParseFloat(Initdata["ZOrder", "0.0"].Text);
            GBXMLContainer ch = Initdata["Children"];
            foreach (GBXMLContainer container in ch.Children)
            {
                string type = container["Type"].Text;
                Type chType = Type.GetType("GameBox.Graphics.Nodes." + type);
                RenderNode newChild = (RenderNode)Activator.CreateInstance(chType, container, this);
                childrenNode.Add(newChild);
            }

            GBXMLContainer animXML = Initdata["Animators"];
            foreach (GBXMLContainer animator in animXML.Children)
            {
                GBXMLContainer animatorParsed = ProcessManager.ActiveProcess.patternObjects.ParsePattern(animator);
                animators.Add(new Animator(animatorParsed));
            }
        }
Пример #2
0
 public Text(GBXMLContainer initData, RenderNode parent)
     : base(initData, parent)
 {
     text = InitData["Text"].Text;
     font = ProcessManager.ActiveProcess.rManager.GetOrCreateFont(InitData["Font"].Text);
     autoText = bool.Parse(InitData["AutoText","true"].Text);
 }
Пример #3
0
 public Animator(GBXMLContainer initdata)
     : base(initdata)
 {
     initData = (GBXMLContainer)initdata.Clone();
     name = InitData.Name;
     Reload();
 }
Пример #4
0
        public static void Init()
        {
            generalProperties = GBXMLContainer.LoadOrNull ("properties.xml");

            GBDebug.WriteLineIf (generalProperties == null, "Properties file not found. Using defaults");

            if (generalProperties == null)
            {
                // Create the default properties.
                generalProperties = GBXMLContainer.LoadFromString(
                    "<properties>" +
                        "<window>" +
                            "<screenResolution type=\"Vector3\">" +
                                "<x>800</x>" +
                                "<y>600</y>" +
                            "</screenResolution>" +
                            "<bpp>32</bpp>" +
                        "</window>" +
                    "</properties>"
                    );
            }

            GBDebug.WriteLine("Properties:");
            GBDebug.WriteLine(generalProperties);
        }
Пример #5
0
        public Scene(GBXMLContainer data)
            : base(data, null)
        {
            size = GBXMLContainer.ReadSizeF(InitData);
            isFirst = bool.Parse(InitData["IsFirst", bool.FalseString].Text);

            LoadResourceInfo();
        }
Пример #6
0
 public override void DispatchAction(GBEvent evnt, string action, GBXMLContainer actionData)
 {
     switch (action)
     {
         case "StartAnimator":
             Start();
             break;
     }
 }
Пример #7
0
 public GBXMLContainer(XmlTextReader reader)
 {
     while (reader.NodeType != XmlNodeType.Element)
     {
         reader.Read();
     }
     name = reader.Name;
     // check if the element has any attributes
     if (reader.HasAttributes) {
         // move to the first attribute
         reader.MoveToFirstAttribute ();
         for (int i = 0; i < reader.AttributeCount; i++) {
             // read the current attribute
             reader.MoveToAttribute (i);
             if (AttributesToChildren)
             {
                 GBXMLContainer newChild = new GBXMLContainer();
                 newChild.name = reader.Name;
                 newChild.textValue = reader.Value;
                 children.Add(newChild);
             }
             else
             {
                 attributes [reader.Name] = reader.Value;
             }
         }
     }
     reader.MoveToContent ();
     bool EndReached = reader.IsEmptyElement;
     while (!EndReached && reader.Read()) {
         switch (reader.NodeType) {
         case XmlNodeType.Element:
             GBXMLContainer newChild = new GBXMLContainer (reader);
             children.Add (newChild);
             break;
         case XmlNodeType.Text:
             textValue = reader.Value;
             break;
         case XmlNodeType.XmlDeclaration:
         case XmlNodeType.ProcessingInstruction:
             break;
         case XmlNodeType.Comment:
             break;
         case XmlNodeType.EndElement:
             EndReached = true;
             break;
         }
     }
 }
Пример #8
0
        public GBXMLContainer(GBXMLContainer other)
        {
            this.name = other.name;
            foreach (KeyValuePair<string, string> keypair in attributes)
            {
                this.attributes[keypair.Key] = keypair.Value;
            }

            textValue = other.textValue;

            foreach (GBXMLContainer ch in other.children)
            {
                children.Add(new GBXMLContainer(ch));
            }
        }
Пример #9
0
 internal GBXMLContainer ParsePattern(GBXMLContainer patternOrigin)
 {
     if (patternOrigin.Name.StartsWith("CopyPattern."))
     {
         string cpStr = "CopyPattern.";
         int cpLen = cpStr.Length;
         string originPattern = patternOrigin.Name.Substring(cpLen, patternOrigin.Name.Length - cpLen);
         GBXMLContainer retVal = (GBXMLContainer)data[originPattern].Clone();
         retVal.Overwrite(patternOrigin);
         if (patternOrigin.Exists("newName"))
         {
             retVal.Name = patternOrigin["newName"].Text;
         }
         return retVal;
     }
     return patternOrigin;
 }
Пример #10
0
 public GBColor(GBXMLContainer initData)
 {
     if (initData.Name.Equals("ColorB"))
     {
         setColorValueFromByte(Alpha, byte.Parse(initData["Alpha", byte.MaxValue.ToString()].Text));
         setColorValueFromByte(Red, byte.Parse(initData["Red", byte.MaxValue.ToString()].Text));
         setColorValueFromByte(Green, byte.Parse(initData["Green", byte.MaxValue.ToString()].Text));
         setColorValueFromByte(Blue, byte.Parse(initData["Blue", byte.MaxValue.ToString()].Text));
     }
     else
     {
         setColorValueFromFloat(Alpha, NumberConverter.ParseFloat(initData["Alpha", "1.0"].Text));
         setColorValueFromFloat(Red, NumberConverter.ParseFloat(initData["Red", "1.0"].Text));
         setColorValueFromFloat(Green, NumberConverter.ParseFloat(initData["Green", "1.0"].Text));
         setColorValueFromFloat(Blue, NumberConverter.ParseFloat(initData["Blue", "1.0"].Text));
     }
 }
Пример #11
0
        public Image(GBXMLContainer initData, RenderNode parent)
            : base(initData, parent)
        {
            string textureName = InitData["Image",string.Empty].Text;
            size = GBXMLContainer.ReadSizeF(InitData);

            borderColors[0] = new GBColor(InitData["BorderColors"]["TopLeft"]);
            borderColors[1] = new GBColor(InitData["BorderColors"]["TopRight"]);
            borderColors[2] = new GBColor(InitData["BorderColors"]["BottomLeft"]);
            borderColors[3] = new GBColor(InitData["BorderColors"]["BottomRight"]);

            if (InitData["BorderColors"].Exists("Top"))
            {
                borderColors[0] = new GBColor(InitData["BorderColors"]["Top"]);
                borderColors[1] = new GBColor(InitData["BorderColors"]["Top"]);
            }

            if (InitData["BorderColors"].Exists("Bottom"))
            {
                borderColors[2] = new GBColor(InitData["BorderColors"]["Bottom"]);
                borderColors[3] = new GBColor(InitData["BorderColors"]["Bottom"]);
            }

            if (InitData["BorderColors"].Exists("Left"))
            {
                borderColors[0] = new GBColor(InitData["BorderColors"]["Left"]);
                borderColors[2] = new GBColor(InitData["BorderColors"]["Left"]);
            }

            if (InitData["BorderColors"].Exists("Right"))
            {
                borderColors[1] = new GBColor(InitData["BorderColors"]["Right"]);
                borderColors[3] = new GBColor(InitData["BorderColors"]["Right"]);
            }

            borderColors[0].Multiply(color);
            borderColors[1].Multiply(color);
            borderColors[2].Multiply(color);
            borderColors[3].Multiply(color);

            if (textureName != string.Empty)
                textures.Add(ProcessManager.ActiveProcess.rManager.GetOrCreateTexture(textureName));
        }
Пример #12
0
 public void AddObject(GBXMLContainer newObject)
 {
     data.AddChild(newObject);
 }
Пример #13
0
 public GBEvent(params string[] properties)
 {
     data = GBXMLContainer.LoadFromProperties(properties);
     SetProperties();
 }
Пример #14
0
 public static bool FieldExists(GBXMLContainer stream, string field)
 {
     return stream.Exists(field);
 }
Пример #15
0
 static void LoadModulesData()
 {
     modulesXMLData = GBXMLContainer.LoadOrNull ("modules.xml");
     if (modulesXMLData == null)
     {
         // Create the default modules.
         modulesXMLData = GBXMLContainer.LoadFromString(
             "<modules>" +
                 "<module>" +
                     "<FileName>Brocker</FileName>" +
                     "<BaseDir>../../../Brocker/bin/Debug</BaseDir>" +
                 "</module>" +
             "</modules>"
             );
     }
 }
Пример #16
0
 public static SizeF ReadSizeF(GBXMLContainer stream)
 {
     return new SizeF(
         NumberConverter.ParseFloat(stream["Length"]["Width", "-1.0"].Text),
         NumberConverter.ParseFloat(stream["Length"]["Height", "-1.0"].Text)
     );
 }
Пример #17
0
 public static RectangleF ReadRectangleF(GBXMLContainer stream)
 {
     return new RectangleF(
         ReadPointF(stream),
         ReadSizeF(stream)
     );
 }
Пример #18
0
 public static PointF ReadPointFFrom(GBXMLContainer stream, string field)
 {
     return new PointF(
         NumberConverter.ParseFloat(stream[field]["X", "0.0"].Text),
         NumberConverter.ParseFloat(stream[field]["Y", "0.0"].Text)
     );
 }
Пример #19
0
 public static PointF ReadPointF(GBXMLContainer stream)
 {
     return ReadPointFFrom(stream, "Position");
 }
Пример #20
0
 public static GBXMLContainer LoadFromProperties(string[] data)
 {
     GBXMLContainer temp = new GBXMLContainer();
     if (data.Length > 0)
     {
         temp.name = data[0];
         int index = 1;
         while (data.Length > index)
         {
             GBXMLContainer internalTemp = new GBXMLContainer();
             internalTemp.name = data[index];
             index++;
             internalTemp.textValue = (data.Length > index) ? data[index] : "";
             temp.children.Add(internalTemp);
             index++;
         }
     }
     return temp;
 }
Пример #21
0
 public virtual void DispatchAction(GBEvent evnt, string action,GBXMLContainer actionData)
 {
 }
Пример #22
0
 public void DispatchAction(GBEvent evnt, string action, GBXMLContainer actionData)
 {
     if (action.StartsWith("Process."))
     {
         string shortAction = action.Substring("Process.".Length);
         switch (shortAction)
         {
             case "Finish":
                 GBDebug.WriteLine("TODO: Finishing process");
                 ProcessManager.FinishActiveProcess();
                 break;
         }
     }
 }
Пример #23
0
 public void AddChild(GBXMLContainer container)
 {
     children.Add(container);
 }
Пример #24
0
        public GBXMLContainer this[string field, string notFound = ""]
        {
            get {
                foreach (GBXMLContainer cont in children)
                {
                    if (cont.name == field)
                        return cont;
                }

                // Do not return null objects to avoid crashes.
            //				GBDebug.Warning("Warning. Returning notFound (" + notFound + ") field for field: "+field);
                GBXMLContainer def = new GBXMLContainer();
                def.name = field;
                def.textValue = notFound;
                return def;
            }
        }
Пример #25
0
 public GBEventReceiver(GBXMLContainer initData)
 {
     eventsToProcess = (GBXMLContainer)initData["ReceiveEvents"].Clone();
 }
Пример #26
0
 public object Clone()
 {
     GBXMLContainer cloned = new GBXMLContainer(this);
     return cloned;
 }
Пример #27
0
 public GBXMLContainer getPropertiesStartingWith(string strStart)
 {
     GBXMLContainer cp = new GBXMLContainer();
     cp.name = name;
     foreach (GBXMLContainer ch in children)
     {
         if (ch.name.StartsWith(strStart))
         {
             cp.AddChild((GBXMLContainer)ch.Clone());
         }
     }
     return cp;
 }
Пример #28
0
 public void Overwrite(GBXMLContainer data)
 {
     textValue = data.textValue;
     foreach (GBXMLContainer container in data.children)
     {
         if (Exists(container.name))
         {
             this[container.name].Overwrite(data[container.name]);
         }
         else
         {
             AddChild(new GBXMLContainer(data[container.name]));
         }
     }
 }
Пример #29
0
 public void LoadMetadata(string fileName)
 {
     GBDebug.Assert(prState == ProcessState.NotLoaded, "Process state error. It is " + prState + ". It must be " + ProcessState.NotLoaded);
     completePropertiesFileName = GBFileSystem.CompleteFileNameForFile(baseDir, fileName + "." + MetaDataExtension);
     if (GBFileSystem.FileExists(completePropertiesFileName))
     {
         metadata = GBXMLContainer.LoadOrNull(completePropertiesFileName);
         GBDebug.WriteLine(metadata);
     }
     else
     {
         prState = ProcessState.InitError;
         throw new GBException(GBException.Reason.FileNotFound);
     }
 }
Пример #30
0
 public GBEvent(GBXMLContainer data_)
 {
     data = (GBXMLContainer)data_.Clone();
 }