コード例 #1
0
ファイル: RenderNode.cs プロジェクト: remy22/GameBox
        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
ファイル: Text.cs プロジェクト: remy22/GameBox
 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
ファイル: Animator.cs プロジェクト: remy22/GameBox
 public Animator(GBXMLContainer initdata)
     : base(initdata)
 {
     initData = (GBXMLContainer)initdata.Clone();
     name = InitData.Name;
     Reload();
 }
コード例 #4
0
ファイル: GBProperties.cs プロジェクト: remy22/GameBox
        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
ファイル: Scene.cs プロジェクト: remy22/GameBox
        public Scene(GBXMLContainer data)
            : base(data, null)
        {
            size = GBXMLContainer.ReadSizeF(InitData);
            isFirst = bool.Parse(InitData["IsFirst", bool.FalseString].Text);

            LoadResourceInfo();
        }
コード例 #6
0
ファイル: Animator.cs プロジェクト: remy22/GameBox
 public override void DispatchAction(GBEvent evnt, string action, GBXMLContainer actionData)
 {
     switch (action)
     {
         case "StartAnimator":
             Start();
             break;
     }
 }
コード例 #7
0
ファイル: GBXMLContainer.cs プロジェクト: remy22/GameBox
 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
ファイル: GBXMLContainer.cs プロジェクト: remy22/GameBox
        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
ファイル: PatternObjects.cs プロジェクト: remy22/GameBox
 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
ファイル: GBColor.cs プロジェクト: remy22/GameBox
 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
ファイル: Image.cs プロジェクト: remy22/GameBox
        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
ファイル: PatternObjects.cs プロジェクト: remy22/GameBox
 public void AddObject(GBXMLContainer newObject)
 {
     data.AddChild(newObject);
 }
コード例 #13
0
ファイル: GBEvent.cs プロジェクト: remy22/GameBox
 public GBEvent(params string[] properties)
 {
     data = GBXMLContainer.LoadFromProperties(properties);
     SetProperties();
 }
コード例 #14
0
ファイル: GBXMLContainer.cs プロジェクト: remy22/GameBox
 public static bool FieldExists(GBXMLContainer stream, string field)
 {
     return stream.Exists(field);
 }
コード例 #15
0
ファイル: GBSystem.cs プロジェクト: remy22/GameBox
 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
ファイル: GBXMLContainer.cs プロジェクト: remy22/GameBox
 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
ファイル: GBXMLContainer.cs プロジェクト: remy22/GameBox
 public static RectangleF ReadRectangleF(GBXMLContainer stream)
 {
     return new RectangleF(
         ReadPointF(stream),
         ReadSizeF(stream)
     );
 }
コード例 #18
0
ファイル: GBXMLContainer.cs プロジェクト: remy22/GameBox
 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
ファイル: GBXMLContainer.cs プロジェクト: remy22/GameBox
 public static PointF ReadPointF(GBXMLContainer stream)
 {
     return ReadPointFFrom(stream, "Position");
 }
コード例 #20
0
ファイル: GBXMLContainer.cs プロジェクト: remy22/GameBox
 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
ファイル: GBEventReceiver.cs プロジェクト: remy22/GameBox
 public virtual void DispatchAction(GBEvent evnt, string action,GBXMLContainer actionData)
 {
 }
コード例 #22
0
ファイル: Process.cs プロジェクト: remy22/GameBox
 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
ファイル: GBXMLContainer.cs プロジェクト: remy22/GameBox
 public void AddChild(GBXMLContainer container)
 {
     children.Add(container);
 }
コード例 #24
0
ファイル: GBXMLContainer.cs プロジェクト: remy22/GameBox
        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
ファイル: GBEventReceiver.cs プロジェクト: remy22/GameBox
 public GBEventReceiver(GBXMLContainer initData)
 {
     eventsToProcess = (GBXMLContainer)initData["ReceiveEvents"].Clone();
 }
コード例 #26
0
ファイル: GBXMLContainer.cs プロジェクト: remy22/GameBox
 public object Clone()
 {
     GBXMLContainer cloned = new GBXMLContainer(this);
     return cloned;
 }
コード例 #27
0
ファイル: GBXMLContainer.cs プロジェクト: remy22/GameBox
 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
ファイル: GBXMLContainer.cs プロジェクト: remy22/GameBox
 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
ファイル: Process.cs プロジェクト: remy22/GameBox
 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
ファイル: GBEvent.cs プロジェクト: remy22/GameBox
 public GBEvent(GBXMLContainer data_)
 {
     data = (GBXMLContainer)data_.Clone();
 }