示例#1
0
        protected override WndTopLevelWindow LoadEntry(FileSystemEntry entry, ContentManager contentManager, Game game, LoadOptions loadOptions)
        {
            var wndFile = WndFile.FromFileSystemEntry(entry);

            var result = CreateElementRecursive(
                wndFile.RootWindow,
                contentManager,
                _wndCallbackResolver);

            var window = new WndTopLevelWindow(wndFile, result, _wndCallbackResolver);

            void setWindowRecursive(WndWindow element)
            {
                element.Window = window;

                foreach (var child in element.Children)
                {
                    setWindowRecursive(child);
                }
            }

            setWindowRecursive(result);

            return(window);
        }
示例#2
0
        internal WndTopLevelWindow(WndFile wndFile, WndWindow root, WndCallbackResolver callbackResolver)
        {
            Root = root;

            LayoutInit     = callbackResolver.GetGuiWindowCallback(wndFile.LayoutBlock.LayoutInit);
            LayoutUpdate   = callbackResolver.GetGuiWindowCallback(wndFile.LayoutBlock.LayoutUpdate);
            LayoutShutdown = callbackResolver.GetGuiWindowCallback(wndFile.LayoutBlock.LayoutShutdown);
        }
示例#3
0
        internal WndTopLevelWindow(WndFile wndFile, WndWindow root)
        {
            Root = root;

            LayoutInit     = CallbackUtility.GetGuiWindowCallback(wndFile.LayoutBlock.LayoutInit);
            LayoutUpdate   = CallbackUtility.GetGuiWindowCallback(wndFile.LayoutBlock.LayoutUpdate);
            LayoutShutdown = CallbackUtility.GetGuiWindowCallback(wndFile.LayoutBlock.LayoutShutdown);
        }
示例#4
0
        public void CanReadWndFiles()
        {
            InstalledFilesTestData.ReadFiles(".wnd", _output, entry =>
            {
                var wndFile = WndFile.FromFileSystemEntry(entry);

                Assert.NotNull(wndFile);
            });
        }
示例#5
0
 public Window(WndFile wndFile, Game game, WndCallbackResolver wndCallbackResolver)
     : this(wndFile.RootWindow.ScreenRect.CreationResolution, CreateRootControl(wndFile, game.ContentManager, game.AssetStore, wndCallbackResolver), game.ContentManager)
 {
     Game           = game;
     Bounds         = wndFile.RootWindow.ScreenRect.ToRectangle();
     LayoutInit     = wndCallbackResolver.GetWindowCallback(wndFile.LayoutBlock.LayoutInit);
     LayoutUpdate   = wndCallbackResolver.GetWindowCallback(wndFile.LayoutBlock.LayoutUpdate);
     LayoutShutdown = wndCallbackResolver.GetWindowCallback(wndFile.LayoutBlock.LayoutShutdown);
 }
示例#6
0
 private static Control CreateRootControl(
     WndFile wndFile,
     ContentManager contentManager,
     AssetStore assetStore,
     WndCallbackResolver wndCallbackResolver)
 {
     return(CreateRecursive(
                wndFile.RootWindow,
                contentManager,
                assetStore,
                wndCallbackResolver,
                wndFile.RootWindow.ScreenRect.UpperLeft));
 }
示例#7
0
        protected override Window LoadEntry(FileSystemEntry entry, ContentManager contentManager, Game game, LoadOptions loadOptions)
        {
            var wndFile = WndFile.FromFileSystemEntry(entry);

            var rootControl = CreateElementRecursive(
                wndFile.RootWindow,
                contentManager,
                _wndCallbackResolver,
                wndFile.RootWindow.ScreenRect.ToRectangle().Location);

            return(new Window(wndFile.RootWindow.ScreenRect.CreationResolution, rootControl, contentManager)
            {
                LayoutInit = _wndCallbackResolver.GetWindowCallback(wndFile.LayoutBlock.LayoutInit),
                LayoutUpdate = _wndCallbackResolver.GetWindowCallback(wndFile.LayoutBlock.LayoutUpdate),
                LayoutShutdown = _wndCallbackResolver.GetWindowCallback(wndFile.LayoutBlock.LayoutShutdown)
            });
        }
示例#8
0
        public Window(WndFile wndFile, Game game, WndCallbackResolver wndCallbackResolver)
            : this(wndFile.RootWindow.ScreenRect.CreationResolution, game.GraphicsLoadContext)
        {
            Game           = game;
            Bounds         = wndFile.RootWindow.ScreenRect.ToRectangle();
            LayoutInit     = wndCallbackResolver.GetWindowCallback(wndFile.LayoutBlock.LayoutInit);
            LayoutUpdate   = wndCallbackResolver.GetWindowCallback(wndFile.LayoutBlock.LayoutUpdate);
            LayoutShutdown = wndCallbackResolver.GetWindowCallback(wndFile.LayoutBlock.LayoutShutdown);

            Root = CreateRecursive(
                wndFile.RootWindow,
                ImageLoader,
                game.ContentManager,
                game.AssetStore,
                wndCallbackResolver,
                wndFile.RootWindow.ScreenRect.UpperLeft);
            Controls.Add(Root);
        }
示例#9
0
        public WndFileContentViewModel(FileSystemEntry file)
            : base(file)
        {
            _fileSystem = file.FileSystem;

            _csfFile = CsfFile.FromFileSystemEntry(_fileSystem.GetFile(@"Data\English\generals.csf"));

            var iniDataContext = new IniDataContext(_fileSystem);

            iniDataContext.LoadIniFiles(@"Data\INI\MappedImages\HandCreated\");
            iniDataContext.LoadIniFiles(@"Data\INI\MappedImages\TextureSize_512\");
            _mappedImages = iniDataContext.MappedImages;

            var wndFile = WndFile.FromFileSystemEntry(file);

            ContainerView = new NonInheritingCanvas
            {
                Width  = wndFile.RootWindow.ScreenRect.CreationResolution.Width,
                Height = wndFile.RootWindow.ScreenRect.CreationResolution.Height,
            };
            AddWindow(wndFile.RootWindow);
        }
示例#10
0
        public WndFile ParseFile()
        {
            var result = new WndFile();

            while (Current.TokenType != WndTokenType.EndOfFile)
            {
                switch (Current.TokenType)
                {
                case WndTokenType.Identifier:
                    switch (Current.StringValue)
                    {
                    case "FILE_VERSION":
                        result.FileVersion = ParseProperty(NextIntegerLiteralTokenValue);
                        break;

                    case "STARTLAYOUTBLOCK":
                        result.LayoutBlock = ParseLayoutBlock();
                        break;

                    case "WINDOW":
                        result.RootWindow = ParseWindow();
                        break;

                    default:
                        UnexpectedToken(Current);
                        break;
                    }
                    break;

                default:
                    UnexpectedToken(Current);
                    break;
                }
            }

            return(result);
        }