Exemplo n.º 1
0
 protected override void Layout(Skin skin)
 {
     base.Layout(skin);
     SetPosition(
         (Parent.Bounds.Width - Bounds.Width) / 2,
         Parent.Bounds.Height / 2 - Bounds.Height);
 }
Exemplo n.º 2
0
        public void Init(Renderer renderer, string textureName)
        {
            Renderer = renderer;
            Skin = new TexturedSkin(renderer, textureName);
            Canvas = new Canvas(Skin);

            Init();
        }
Exemplo n.º 3
0
        void InitializeGui()
        {
            GuiRenderer = new GwenRenderer();

            var textureName = "DefaultSkin.png";
            var defaultFont = new Font("Vera.ttf", 16);

            var resMan = Engine.GetEngine().ResourceManager;
            var options = new ResourceLoadOptions {Name = textureName, AsynchronousLoad = false};
            var imageHandle = resMan.LoadResource<Image>(options);
            if (imageHandle.Id == 0)
                throw new Exception("Could not load GUI texture: " + textureName);

            Skin = new TexturedSkin(GuiRenderer, imageHandle, defaultFont);
            Canvas = new Canvas(Skin);

            Input = new GwenInput(Engine.GetEngine().InputManager);
            Input.Initialize(Canvas);
        }
Exemplo n.º 4
0
Arquivo: GUI.cs Projeto: chartly/flood
        public GUI(string textureName, string defaultFontName, int defaultFontSize)
        {
            PlatformManager = new PlatformManager(CreateWxPlatformManager());

            Engine = new Engine(PlatformManager);
            Engine.Init();

            // Search for the location of the main assets folder.
            string assetsPath;
            if (!SearchForAssetsDirectory(out assetsPath))
                throw new Exception("Editor assets were not found");

            Archive = new ArchiveVirtual();
            Archive.MountDirectories(assetsPath, Allocator.GetHeap());

            ResourceManager = Engine.ResourceManager;
            ResourceManager.Archive = Archive;

            WindowManager = Engine.WindowManager;

            MainWindow = CreateWindow();
            var context = MainWindow.CreateContext(new RenderContextSettings());

            MainView = MainWindow.CreateView();
            MainView.ClearColor = Color.Red;

            MainWindow.MakeCurrent();
            context.Init();

            RenderDevice = Engine.RenderDevice;
            RenderDevice.ActiveView = MainView;

            var options = new ResourceLoadOptions {Name = textureName, AsynchronousLoad = false};
            var imageHandle = ResourceManager.LoadResource<Image>(options);
            if (imageHandle.Id == 0)
                return;

            Renderer = new GwenRenderer();
            Skin = new TexturedSkin(Renderer, imageHandle, new Flood.GUI.Font(defaultFontName, defaultFontSize));

            if (!Directory.Exists(StoredValuesDirectory))
                Directory.CreateDirectory(StoredValuesDirectory);
        }
Exemplo n.º 5
0
        protected override void PostLayout(Skin skin)
        {
            var  bounds = InnerBounds;
            var pos = new Point( bounds.X, bounds.Y );

            var right = 0;
            var line = 0;

            foreach (var pChild in Children)
            {
                if ( pChild.Dock != Pos.None ) continue;

                if(right + pChild.Width > Width)
                {
                    line++;
                    right = 0;
                }

                pChild.SetPosition(right, line * lineHeight);

                right += pChild.Width;
            }
        }
Exemplo n.º 6
0
 protected override void Layout(Skin skin)
 {
     base.Layout(skin);
 }
Exemplo n.º 7
0
        private void CreateGradientBitmap(Skin skin)
        {
            /*var bitmap = new Bitmap(Width, Height);

            for (int y = 0; y < Height; y++)
            {
                Color c = GetColorAtHeight(y);
                for (int x = 0; x < Width; x++)
                {
                    bitmap.SetPixel(x,y, new Color(c.R,c.G,c.B,c.A));
                }
            }

            imageHandle = new MaterialHandle(skin.Renderer);
            imageHandle.LoadBitmap(bitmap);*/
        }
Exemplo n.º 8
0
 protected override void Render(Skin skin)
 {
     skin.Renderer.DrawColor = Color.Red;
     var testRect = new Rectangle(0, 0, 20, 20);
     skin.Renderer.DrawFilledRect(testRect);
     base.Render(skin);
 }
Exemplo n.º 9
0
        private void CreateGradientBitmap(Skin skin)
        {
            //var bitmap = new Bitmap(Width, Height);

            //for (int y = 0; y < Height; y++)
            //{
            //    for (int x = 0; x < Width; x++)
            //    {
            //        Color c = GetColorAt(x, y);
            //        bitmap.SetPixel(x, y, Color.FromArgb(c.A, c.R, c.G, c.B));
            //    }
            //}

            //m_Texture = new MaterialHandle(skin.Renderer);
            //m_Texture.LoadBitmap(bitmap);
        }