private void ShowSplashScreen()
        {
            // Do nothing when we're on DEBUG builds.
            // The splash is just annoying.
            const int SIZE_X = 600;
            const int SIZE_Y = 300;
            var       Size   = new Vector2i(SIZE_X, SIZE_Y);
            // Size of the NT logo in the bottom right.
            const float NT_SIZE_X = SIZE_X / 10f;
            const float NT_SIZE_Y = SIZE_Y / 10f;
            var         NTSize    = new Vector2(NT_SIZE_X, NT_SIZE_Y);
            var         window    = CluwneLib.ShowSplashScreen(new VideoMode(SIZE_X, SIZE_Y)).Graphics;

            var logo = _resourceCache.GetSprite("ss14_logo");

            logo.Position = Size / 2 - logo.TextureRect.Size / 2;

            var background = _resourceCache.GetSprite("ss14_logo_background");

            background.Scale = (Vector2)Size / background.TextureRect.Size;

            var nanotrasen = _resourceCache.GetSprite("ss14_logo_nt");

            nanotrasen.Scale    = NTSize / nanotrasen.TextureRect.Size;
            nanotrasen.Position = Size - NTSize - 5;
            nanotrasen.Color    = Color.White.WithAlpha(64);

            window.Draw(background);
            window.Draw(logo);
            window.Draw(nanotrasen);
            window.Display();
        }
Exemple #2
0
        public Listbox(int dropDownLength, int width, IResourceCache resourceCache,
                       List <string> initialOptions = null)
        {
            _resourceCache = resourceCache;

            _width        = width;
            _listboxLeft  = _resourceCache.GetSprite("button_left");
            _listboxMain  = _resourceCache.GetSprite("button_middle");
            _listboxRight = _resourceCache.GetSprite("button_right");

            _selectedLabel = new TextSprite("ListboxLabel", "", _resourceCache.GetResource <FontResource>(@"Fonts/CALIBRI.TTF").Font)
            {
                Color = Color4.Black
            };

            _dropDown = new ScrollableContainer("ListboxContents", new Vector2i(width, dropDownLength), _resourceCache);
            _dropDown.SetVisible(false);

            if (initialOptions != null)
            {
                _contentStrings = initialOptions;
                RebuildList();
            }

            Update(0);
        }
        private void ShowSplashScreen()
        {
            // Do nothing when we're on DEBUG builds.
            // The splash is just annoying.
            const uint SIZE_X = 600;
            const uint SIZE_Y = 300;
            // Size of the NT logo in the bottom right.
            const float NT_SIZE_X = SIZE_X / 10f;
            const float NT_SIZE_Y = SIZE_Y / 10f;
            var         window    = CluwneLib.ShowSplashScreen(new VideoMode(SIZE_X, SIZE_Y)).Graphics;

            var logo = _resourceCache.GetSprite("ss14_logo");

            logo.Position = new Vector2f(SIZE_X / 2 - logo.TextureRect.Width / 2, SIZE_Y / 2 - logo.TextureRect.Height / 2);

            var background = _resourceCache.GetSprite("ss14_logo_background");

            background.Scale = new Vector2f((float)SIZE_X / background.TextureRect.Width, (float)SIZE_Y / background.TextureRect.Height);

            var nanotrasen = _resourceCache.GetSprite("ss14_logo_nt");

            nanotrasen.Scale    = new Vector2f(NT_SIZE_X / nanotrasen.TextureRect.Width, NT_SIZE_Y / nanotrasen.TextureRect.Height);
            nanotrasen.Position = new Vector2f(SIZE_X - NT_SIZE_X - 5, SIZE_Y - NT_SIZE_Y - 5);
            nanotrasen.Color    = new Color(255, 255, 255, 64);

            window.Draw(background);
            window.Draw(logo);
            window.Draw(nanotrasen);
            window.Display();
        }
Exemple #4
0
        public void GaussianBlurRadius11_ShouldBlur()
        {
            preblur       = new RenderImage("testGaussianBlur", 1280, 768);
            _gaussianBlur = new GaussianBlur(_resourceCache);

            _gaussianBlur.SetRadius(11);
            _gaussianBlur.SetAmount(2);
            _gaussianBlur.SetSize(preblur.Size);

            while (CluwneLib.IsRunning)
            {
                var lastFrameTime = clock.ElapsedTimeAsSeconds();
                clock.Restart();
                _frameEvent = new FrameEventArgs(lastFrameTime);
                CluwneLib.ClearCurrentRendertarget(Color4.Black);
                CluwneLib.Window.DispatchEvents();

                preblur.BeginDrawing(); // set temp as CRT (Current Render Target)
                //preblur.Clear();       //Clear
                sprite          = _resourceCache.GetSprite("flashlight_mask");
                sprite.Position = Vector2.Zero;
                sprite.Draw();
                preblur.EndDrawing();  // set previous rendertarget as CRT (screen in this case)

                //_gaussianBlur.PerformGaussianBlur(preblur); // blur rendertarget

                preblur.Blit(0, 0, preblur.Width, preblur.Height, Color.White, BlitterSizeMode.Crop); // draw blurred nosprite logo

                CluwneLib.Window.Graphics.Display();
            }
        }
Exemple #5
0
        public Checkbox(IResourceCache resourceCache)
        {
            _resourceCache = resourceCache;
            checkbox       = _resourceCache.GetSprite("checkbox0");
            checkboxCheck  = _resourceCache.GetSprite("checkbox1");

            ClientArea = Box2i.FromDimensions(Position,
                                              new Vector2i((int)checkbox.GetLocalBounds().Width, (int)checkbox.GetLocalBounds().Height));
            Update(0);
        }
        public Checkbox(IResourceCache resourceCache)
        {
            _resourceCache = resourceCache;
            checkbox       = _resourceCache.GetSprite("checkbox0");
            checkboxCheck  = _resourceCache.GetSprite("checkbox1");

            ClientArea = new IntRect(Position,
                                     new SFML.System.Vector2i((int)checkbox.GetLocalBounds().Width, (int)checkbox.GetLocalBounds().Height));
            Update(0);
        }
Exemple #7
0
        public Button(string buttonText, IResourceCache resourceCache)
        {
            _resourceCache = resourceCache;
            _buttonLeft    = _resourceCache.GetSprite("button_left");
            _buttonMain    = _resourceCache.GetSprite("button_middle");
            _buttonRight   = _resourceCache.GetSprite("button_right");

            Label = new TextSprite("ButtonLabel" + buttonText, buttonText, _resourceCache.GetResource <FontResource>("Fonts/CALIBRI.TTF").Font)
            {
                Color = Color4.Black
            };

            Update(0);
        }
Exemple #8
0
        public Textbox(int width, IResourceCache resourceCache)
        {
            _resourceCache = resourceCache;
            _textboxLeft   = _resourceCache.GetSprite("text_left");
            _textboxMain   = _resourceCache.GetSprite("text_middle");
            _textboxRight  = _resourceCache.GetSprite("text_right");

            Width = width;

            Label = new TextSprite("Textbox", "", _resourceCache.GetResource <FontResource>(@"Fonts/CALIBRI.TTF").Font)
            {
                Color = Color4.Black
            };

            Update(0);
        }
        public override void InitializeResources(IResourceCache resourceCache)
        {
            tileSprite = resourceCache.GetSprite("wall_texture");
            var bounds = tileSprite.GetLocalBounds();

            shape = new RectangleShape(new SFML.System.Vector2f(bounds.Width, bounds.Height));
        }
        private void PreparePlacement(string templateName)
        {
            var prototype = _prototypeManager.Index <EntityPrototype>(templateName);

            ComponentParameter spriteParam = prototype.GetBaseSpriteParameters().FirstOrDefault();
            //Will break if states not ordered correctly.

            var    spriteName = spriteParam == null ? "" : spriteParam.GetValue <string>();
            Sprite sprite     = ResourceCache.GetSprite(spriteName);

            CurrentBaseSprite    = sprite;
            CurrentBaseSpriteKey = spriteName;
            CurrentPrototype     = prototype;

            IsActive = true;
        }
        /// <summary>
        ///  Renders UI components to screen.
        /// </summary>
        public void Render(FrameEventArgs e)
        {
            IOrderedEnumerable <IGuiComponent> renderList = from IGuiComponent comp in _components
                                                            where comp.IsVisible()
                                                            orderby comp.Focus ascending
                                                            orderby comp.ZDepth ascending
                                                            select comp;

            foreach (IGuiComponent component in renderList)
            {
                component.Render();
            }

            if (_console.IsVisible())
            {
                _console.Render();
            }

            if (showCursor)
            {
                _cursorSprite = DragInfo.DragSprite != null && DragInfo.IsActive
                                    ? DragInfo.DragSprite
                                    : _resourceCache.GetSprite("cursor");

                _cursorSprite.Position = ((Vector2)MousePos).Convert();
                _cursorSprite.Draw();
            }
        }
 public void DefaultDrawMethod_ShouldDrawToScreen()
 {
     test.BeginDrawing();
     test.Clear(Color.Black);
     resources.GetSprite("flashlight_mask").Draw();
     test.EndDrawing();
     test.Blit(0, 0, 1280, 720, Color.White, BlitterSizeMode.Scale);
 }
        public FloatingDecoration(IResourceCache resourceCache, string spriteName)
        {
            _resourceCache = resourceCache;
            DrawSprite     = _resourceCache.GetSprite(spriteName);

            _uiMgr = (UserInterfaceManager)IoCManager.Resolve <IUserInterfaceManager>();

            Update(0);
        }
        public ContextMenuButton(ContextMenuEntry entry, Vector2 size, IResourceCache resourceCache)
        {
            _resourceCache = resourceCache;

            UserData    = entry.ComponentMessage;
            Size        = size;
            _iconSprite = _resourceCache.GetSprite(entry.IconName);
            _textLabel  = new Label(entry.EntryName, "CALIBRI", _resourceCache);
            _textLabel.Update(0);
        }
Exemple #15
0
        public int size = 300; //Graphical length of the bar.

        public Scrollbar(bool horizontal, IResourceCache resourceCache)
        {
            _resourceCache = resourceCache;

            Horizontal = horizontal;
            if (Horizontal)
            {
                scrollbarButton = _resourceCache.GetSprite("scrollbutton_h");
            }
            else
            {
                scrollbarButton = _resourceCache.GetSprite("scrollbutton_v");
            }

            DEBUG             = new TextSprite("DEBUGSLIDER", "Position:", _resourceCache.GetResource <FontResource>(@"Fonts/CALIBRI.TTF").Font);
            DEBUG.Color       = new Color4(255, 128, 0, 255);
            DEBUG.ShadowColor = new Color4(0, 0, 128, 255);
            DEBUG.Shadowed    = true;
            Update(0);
        }
Exemple #16
0
        public void Setup()
        {
            base.InitializeCluwneLib(1280, 720, false, 60);

            resources       = base.GetResourceCache;
            testRenderImage = new RenderImage("TestShaders", 1280, 720);
            testsprite      = resources.GetSprite("flashlight_mask");

            SS14UnitTest.InjectedMethod += LoadTestShader_ShouldDrawAllRed;

            base.StartCluwneLibLoop();
        }
        public void LoadTestShader_ShouldDrawAllRed()
        {
            testRenderImage.BeginDrawing();

            GLSLShader currshader = resources.GetShader("RedShader");

            currshader.SetUniform("TextureUnit0", testsprite.Texture);
            currshader.setAsCurrentShader();
            testsprite.Draw();
            testRenderImage.EndDrawing();
            currshader.ResetCurrentShader();
            testRenderImage.Blit(0, 0, 1280, 720, Color.White, BlitterSizeMode.Crop);

            resources.GetSprite("flashlight_mask").Draw();
        }
Exemple #18
0
        /// <summary>
        ///  Renders UI components to screen.
        /// </summary>
        public void Render(FrameEventArgs e)
        {
            IOrderedEnumerable <IGuiComponent> renderList = from IGuiComponent comp in _components
                                                            where comp.IsVisible()
                                                            orderby comp.Focus ascending
                                                            orderby comp.ZDepth ascending
                                                            select comp;

            foreach (IGuiComponent component in renderList)
            {
                component.Render();

                if (moveMode)
                { /*
                   * CluwneLib.Screen.BlendingMode = BlendingModes.Modulated;
                   * CluwneLib.Screen.FilledRectangle(component.ClientArea.X, component.ClientArea.Y,
                   *                              component.ClientArea.Width, component.ClientArea.Height,
                   *                              Color.FromArgb(100, Color.Green));
                   * CluwneLib.Screen.Rectangle(component.ClientArea.X, component.ClientArea.Y, component.ClientArea.Width,
                   *                        component.ClientArea.Height, Color.LightGreen);
                   * CluwneLib.Screen.BlendingMode = BlendingModes.None;
                   */
                }
            }

            if (_console.IsVisible())
            {
                _console.Render();
            }

            if (showCursor)
            {
                _cursorSprite = DragInfo.DragSprite != null && DragInfo.IsActive
                                    ? DragInfo.DragSprite
                                    : _resourceCache.GetSprite("cursor");

                _cursorSprite.Position = MousePos.ToFloat();
                _cursorSprite.Draw();
            }
        }
Exemple #19
0
        //Todo encapsulate this further down as components -- AnimatedSpriteState, AnimatedSpriteStateDirection
        public void LoadSprites(AnimationCollection collection, IResourceCache resourceCache)
        {
            float x = 0, y = 0, h = 0, w = 0;
            int   t = 0;

            foreach (var info in collection.Animations)
            {
                _sprites.Add(info.Name, new Dictionary <Direction, Sprite[]>());

                //Because we have a shitload of frames, we're going to store the average size as the AABB for each direction and each animation
                _averageAABBs.Add(info.Name, new Dictionary <Direction, Box2>());

                var sprites      = _sprites[info.Name];
                var averageAABBs = _averageAABBs[info.Name];
                AnimationStates.Add(info.Name, new AnimationState(info));
                foreach (var dir in Enum.GetValues(typeof(Direction)).Cast <Direction>())
                {
                    sprites.Add(dir, new Sprite[info.Frames]);
                    var thisDirSprites = sprites[dir];
                    for (var i = 0; i < info.Frames; i++)
                    {
                        var spritename = collection.Name.ToLowerInvariant() + "_" + info.Name.ToLowerInvariant() + "_"
                                         + DirectionToUriComponent(dir) + "_" + i;
                        thisDirSprites[i] = resourceCache.GetSprite(spritename);
                        var bounds = thisDirSprites[i].LocalBounds;
                        x += bounds.Left;
                        y += bounds.Top;
                        w += bounds.Width;
                        h += bounds.Height;
                        t++;
                    }
                    averageAABBs.Add(dir, Box2.FromDimensions(x / t, y / t, w / t, h / t));
                    t = 0;
                    x = 0;
                    y = 0;
                    w = 0;
                    h = 0;
                }
            }
        }
Exemple #20
0
        /// <summary>
        ///     Renders UI Components to screen.
        /// </summary>
        public void Render(FrameEventArgs e)
        {
            foreach (var component in _components)
            {
                component.Draw();
            }

            if (_console.Visible)
            {
                _console.Draw();
            }

            if (showCursor)
            {
                _cursorSprite = DragInfo.DragSprite != null && DragInfo.IsActive
                    ? DragInfo.DragSprite
                    : _resourceCache.GetSprite("cursor");

                _cursorSprite.Position = MousePos;
                _cursorSprite.Draw();
            }
        }
Exemple #21
0
        public static void DrawTiles(IResourceCache resCache, IEnumerable <TileRef> tileRefs, SpriteBatch floorBatch, SpriteBatch gasBatch)
        {
            Sprite          sprite  = null;
            ITileDefinition lastDef = null;
            var             ppm     = CluwneLib.Camera.PixelsPerMeter;

            foreach (var tileReference in tileRefs)
            {
                if (tileReference.TileDef != lastDef)
                {
                    lastDef = tileReference.TileDef;
                    sprite  = resCache.GetSprite(lastDef.SpriteName);
                }

                if (sprite == null)
                {
                    continue;
                }

                sprite.Position = new Vector2(tileReference.X, tileReference.Y) * ppm;
                floorBatch.Draw(sprite);
            }
        }
        public EntitySpawnSelectButton(EntityPrototype entityTemplate, string templateName,
                                       IResourceCache resourceCache)
        {
            _resourceCache = resourceCache;

            var    spriteNameParam = entityTemplate.GetBaseSpriteParamaters().FirstOrDefault();
            string SpriteName      = "";

            if (spriteNameParam != null)
            {
                SpriteName = spriteNameParam.GetValue <string>();
            }
            string ObjectName = entityTemplate.Name;

            associatedTemplate     = entityTemplate;
            associatedTemplateName = templateName;

            objectSprite = _resourceCache.GetSprite(SpriteName);

            font       = _resourceCache.GetResource <FontResource>(@"Fonts/CALIBRI.TTF").Font;
            name       = new TextSprite("Label" + SpriteName, "Name", font);
            name.Color = Color4.Black;
            name.Text  = ObjectName;
        }
 public override void InitializeResources(IResourceCache resourceCache)
 {
     tileSprite = resourceCache.GetSprite("floor_texture");
 }
 public void InitializeResources(IResourceCache resourceCache)
 {
     tileSprite = resourceCache.GetSprite("space_texture");
 }