コード例 #1
0
ファイル: Skin.cs プロジェクト: hakanaku2009/svn-dump
        public override void Init()
        {
            base.Init();

            for (int i = 0; i < fonts.Count; i++)
            {
                content.UseArchive = fonts[i].Archive;
                string asset = GetAsset("Fonts", fonts[i].Asset, fonts[i].Addon);
                asset = content.UseArchive ? asset : Path.GetFullPath(asset);
                (fonts[i].Resource) = content.Load <SpriteFont>(asset);
            }

#if (!XBOX && !XBOX_FAKE)
            for (int i = 0; i < cursors.Count; i++)
            {
                content.UseArchive = cursors[i].Archive;
                string asset = GetAsset("Cursors", cursors[i].Asset, cursors[i].Addon);
                asset = content.UseArchive ? asset : Path.GetFullPath(asset);
                cursors[i].Resource = content.Load <Cursor>(asset);
            }
#endif

            for (int i = 0; i < images.Count; i++)
            {
                content.UseArchive = images[i].Archive;
                string asset = GetAsset("Images", images[i].Asset, images[i].Addon);
                asset = content.UseArchive ? asset : Path.GetFullPath(asset);
                images[i].Resource = content.Load <Texture2D>(asset);
            }

            for (int i = 0; i < controls.Count; i++)
            {
                for (int j = 0; j < controls[i].Layers.Count; j++)
                {
                    if (controls[i].Layers[j].Image.Name != null)
                    {
                        controls[i].Layers[j].Image = images[controls[i].Layers[j].Image.Name];
                    }
                    else
                    {
                        controls[i].Layers[j].Image = images[0];
                    }

                    if (controls[i].Layers[j].Text.Name != null)
                    {
                        controls[i].Layers[j].Text.Font = fonts[controls[i].Layers[j].Text.Name];
                    }
                    else
                    {
                        controls[i].Layers[j].Text.Font = fonts[0];
                    }
                }
            }
        }
コード例 #2
0
        public static Container Load(Manager manager, string asset)
        {
            Container         win     = null;
            LayoutXmlDocument doc     = new LayoutXmlDocument();
            ArchiveManager    content = new ArchiveManager(manager.Game.Services);

            try {
                content.RootDirectory = manager.LayoutDirectory;

#if (!XBOX && !XBOX_FAKE)
                string file = content.RootDirectory + asset;

                if (File.Exists(file))
                {
                    doc.Load(file);
                }
                else
#endif
                {
                    doc = content.Load <LayoutXmlDocument>(asset);
                }


                if (doc != null && doc["Layout"]["Controls"] != null && doc["Layout"]["Controls"].HasChildNodes)
                {
                    XmlNode node = doc["Layout"]["Controls"].GetElementsByTagName("Control").Item(0);
                    string  cls  = node.Attributes["Class"].Value;
                    Type    type = Type.GetType(cls);

                    if (type == null)
                    {
                        cls  = "GodLesZ.Library.Xna.WindowLibrary.Controls." + cls;
                        type = Type.GetType(cls);
                    }

                    win = (Container)LoadControl(manager, node, type, null);
                }
            } finally {
                content.Dispose();
            }

            return(win);
        }
コード例 #3
0
ファイル: Layout.cs プロジェクト: GodLesZ/svn-dump
		public static Container Load(Manager manager, string asset) {
			Container win = null;
			LayoutXmlDocument doc = new LayoutXmlDocument();
			ArchiveManager content = new ArchiveManager(manager.Game.Services);

			try {
				content.RootDirectory = manager.LayoutDirectory;

#if (!XBOX && !XBOX_FAKE)

				string file = content.RootDirectory + asset;

				if (File.Exists(file)) {
					doc.Load(file);
				} else

#endif
 {
					doc = content.Load<LayoutXmlDocument>(asset);
				}


				if (doc != null && doc["Layout"]["Controls"] != null && doc["Layout"]["Controls"].HasChildNodes) {
					XmlNode node = doc["Layout"]["Controls"].GetElementsByTagName("Control").Item(0);
					string cls = node.Attributes["Class"].Value;
					Type type = Type.GetType(cls);

					if (type == null) {
						cls = "GodLesZ.Library.Xna.WindowLibrary.Controls." + cls;
						type = Type.GetType(cls);
					}

					win = (Container)LoadControl(manager, node, type, null);
				}

			} finally {
				content.Dispose();
			}

			return win;
		}