Example #1
0
        public Viewport(WorldRenderer wr, Map map)
        {
            worldRenderer = wr;
            var grid = Game.ModData.Manifest.Get <MapGrid>();

            viewportSizes   = Game.ModData.Manifest.Get <WorldViewportSizes>();
            graphicSettings = Game.Settings.Graphics;

            // Calculate map bounds in world-px
            if (wr.World.Type == WorldType.Editor)
            {
                // The full map is visible in the editor
                var width  = map.MapSize.X * grid.TileSize.Width;
                var height = map.MapSize.Y * grid.TileSize.Height;
                if (wr.World.Map.Grid.Type == MapGridType.RectangularIsometric)
                {
                    height /= 2;
                }

                mapBounds      = new Rectangle(0, 0, width, height);
                CenterLocation = new int2(width / 2, height / 2);
            }
            else
            {
                var tl = wr.ScreenPxPosition(map.ProjectedTopLeft);
                var br = wr.ScreenPxPosition(map.ProjectedBottomRight);
                mapBounds      = Rectangle.FromLTRB(tl.X, tl.Y, br.X, br.Y);
                CenterLocation = (tl + br) / 2;
            }

            tileSize = grid.TileSize;

            UpdateViewportZooms();
        }
Example #2
0
        public DisplaySettingsLogic(Action <string, string, Func <Widget, Func <bool> >, Func <Widget, Action> > registerPanel, string panelID, string label, ModData modData, WorldRenderer worldRenderer)
        {
            this.worldRenderer = worldRenderer;
            this.modData       = modData;
            viewportSizes      = modData.Manifest.Get <WorldViewportSizes>();

            registerPanel(panelID, label, InitPanel, ResetPanel);
        }
Example #3
0
        public static void ShowBattlefieldCameraDropdown(DropDownButtonWidget dropdown, WorldViewportSizes viewportSizes, GraphicSettings gs)
        {
            Func <WorldViewport, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
            {
                var item = ScrollItemWidget.Setup(itemTemplate,
                                                  () => gs.ViewportDistance == o,
                                                  () => gs.ViewportDistance = o);

                var label = ViewportSizeNames[o];
                item.Get <LabelWidget>("LABEL").GetText = () => label;
                return(item);
            };

            var windowHeight = Game.Renderer.NativeResolution.Height;

            var validSizes = new List <WorldViewport>()
            {
                WorldViewport.Close
            };

            if (viewportSizes.GetSizeRange(WorldViewport.Medium).X < windowHeight)
            {
                validSizes.Add(WorldViewport.Medium);
            }

            var farRange = viewportSizes.GetSizeRange(WorldViewport.Far);

            if (farRange.X < windowHeight)
            {
                validSizes.Add(WorldViewport.Far);
            }

            if (viewportSizes.AllowNativeZoom && farRange.Y < windowHeight)
            {
                validSizes.Add(WorldViewport.Native);
            }

            dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, validSizes, setupItem);
        }