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(); }
private void ImplementSettings(GraphicSettings settings) { TextureQuality.value = settings.TextureQuality; MultiSampling.value = settings.MultiSampling; VSync.value = settings.VSync; FrameRate.value = settings.FrameRate; }
public MainWindowViewModel(Languages languages) { Languages = languages; GraphicSettings = new GraphicSettings(); CurrentComparer = SettingsManager.Comparer; LoadState(); }
public Renderer(GraphicSettings graphicSettings, ServerSettings serverSettings) { var resolution = GetResolution(graphicSettings); var rendererName = serverSettings.Dedicated ? "Null" : graphicSettings.Renderer; var rendererPath = Platform.ResolvePath(".", "OpenRA.Renderer." + rendererName + ".dll"); Device = CreateDevice(Assembly.LoadFile(rendererPath), resolution.Width, resolution.Height, graphicSettings.Mode); if (!serverSettings.Dedicated) { TempBufferSize = graphicSettings.BatchSize; TempBufferCount = graphicSettings.NumTempBuffers; SheetSize = graphicSettings.SheetSize; } WorldSpriteRenderer = new SpriteRenderer(this, Device.CreateShader("shp")); WorldRgbaSpriteRenderer = new SpriteRenderer(this, Device.CreateShader("rgba")); WorldLineRenderer = new LineRenderer(this, Device.CreateShader("line")); WorldVoxelRenderer = new VoxelRenderer(this, Device.CreateShader("vxl")); LineRenderer = new LineRenderer(this, Device.CreateShader("line")); WorldQuadRenderer = new QuadRenderer(this, Device.CreateShader("line")); RgbaSpriteRenderer = new SpriteRenderer(this, Device.CreateShader("rgba")); SpriteRenderer = new SpriteRenderer(this, Device.CreateShader("shp")); for (var i = 0; i < TempBufferCount; i++) { tempBuffers.Enqueue(Device.CreateVertexBuffer(TempBufferSize)); } }
Action ResetDisplayPanel(Widget panel) { var ds = Game.Settings.Graphics; var gs = Game.Settings.Game; var ps = Game.Settings.Player; var dds = new GraphicSettings(); var dgs = new GameSettings(); var dps = new PlayerSettings(); return(() => { gs.ShowShellmap = dgs.ShowShellmap; ds.CapFramerate = dds.CapFramerate; ds.MaxFramerate = dds.MaxFramerate; ds.Language = dds.Language; ds.Mode = dds.Mode; ds.WindowedSize = dds.WindowedSize; ds.PixelDouble = dds.PixelDouble; ds.CursorDouble = dds.CursorDouble; worldRenderer.Viewport.Zoom = ds.PixelDouble ? 2 : 1; ps.Color = dps.Color; ps.Name = dps.Name; }); }
Action ResetPanel(Widget panel) { var ds = Game.Settings.Graphics; var ps = Game.Settings.Player; var gs = Game.Settings.Game; var dds = new GraphicSettings(); var dps = new PlayerSettings(); var dgs = new GameSettings(); return(() => { ds.CapFramerate = dds.CapFramerate; ds.MaxFramerate = dds.MaxFramerate; ds.GLProfile = dds.GLProfile; ds.Mode = dds.Mode; ds.VideoDisplay = dds.VideoDisplay; ds.WindowedSize = dds.WindowedSize; ds.CursorDouble = dds.CursorDouble; ds.ViewportDistance = dds.ViewportDistance; if (ds.UIScale != dds.UIScale) { var oldScale = ds.UIScale; ds.UIScale = dds.UIScale; Game.Renderer.SetUIScale(dds.UIScale); RecalculateWidgetLayout(Ui.Root); Viewport.LastMousePos = (Viewport.LastMousePos.ToFloat2() * oldScale / ds.UIScale).ToInt2(); } ps.Color = dps.Color; ps.Name = dps.Name; gs.TextNotificationPoolFilters = dgs.TextNotificationPoolFilters; }); }
static void ShowWindowModeDropdown(DropDownButtonWidget dropdown, GraphicSettings s, ScrollPanelWidget scrollPanel) { var options = new Dictionary <string, WindowMode>() { { "Fullscreen", WindowMode.PseudoFullscreen }, { "Fullscreen (Legacy)", WindowMode.Fullscreen }, { "Windowed", WindowMode.Windowed }, }; Func <string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, () => s.Mode == options[o], () => { s.Mode = options[o]; SettingsUtils.AdjustSettingsScrollPanelLayout(scrollPanel); }); item.Get <LabelWidget>("LABEL").GetText = () => o; return(item); }; dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem); }
public LinkedList <ModRectangle> Split(double h, RuleM rule, GraphicSettings settings = null) { LinkedList <ModRectangle> rect = new LinkedList <ModRectangle>(); for (int i = 0; i < lowerCorner.Count; i++) { if (upperCorner[i] - lowerCorner[i] > h) { List <double> newLow = new List <double>(lowerCorner); newLow[i] += h; List <double> newUp = new List <double>(upperCorner); for (int j = 0; j < i; j++) { newUp[j] = Math.Min(newLow[j] + h, upperCorner[j]); } if (rule == RuleM.FIFO) { rect.AddFirst(new ModRectangle(newLow, newUp, settings)); } else { rect.AddLast(new ModRectangle(newLow, newUp, settings)); } } } return(rect); }
public static void ShowUIScaleDropdown(DropDownButtonWidget dropdown, GraphicSettings gs) { Func <float, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, () => gs.UIScale == o, () => { Game.RunAfterTick(() => { var oldScale = gs.UIScale; gs.UIScale = o; Game.Renderer.SetUIScale(o); RecalculateWidgetLayout(Ui.Root); Viewport.LastMousePos = (Viewport.LastMousePos.ToFloat2() * oldScale / gs.UIScale).ToInt2(); }); }); var label = $"{(int)(100 * o)}%"; item.Get <LabelWidget>("LABEL").GetText = () => label; return(item); }; var viewportSizes = Game.ModData.Manifest.Get <WorldViewportSizes>(); var maxScales = new float2(Game.Renderer.NativeResolution) / new float2(viewportSizes.MinEffectiveResolution); var maxScale = Math.Min(maxScales.X, maxScales.Y); var validScales = new[] { 1f, 1.25f, 1.5f, 1.75f, 2f }.Where(x => x <= maxScale); dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, validScales, setupItem); }
public BasicRenderer(GraphicSettings graphicSettings, ContentManager content, float degreeFov, Tracker tracker) { _camera = new Camera(graphicSettings, MathHelper.ToRadians(degreeFov), tracker); _viewMatrix = _camera.MatrixView; _graphics = graphicSettings.GraphicDevice; _spritebatch = new SpriteBatch(_graphics); _font = content.Load <SpriteFont>("Arial"); }
static Size GetResolution(GraphicSettings graphicsSettings) { var size = (graphicsSettings.Mode == WindowMode.Windowed) ? graphicsSettings.WindowedSize : graphicsSettings.FullscreenSize; return(new Size(size.X, size.Y)); }
public GameHost() { //_graphicsDeviceManager = new GraphicsDeviceManager(this); _graphicSettings = new GraphicSettings(this); //, 1000, 300); Content.RootDirectory = "Content"; this.Window.Title = "Gandalf VS Zombie"; IsMouseVisible = true; }
public ActionList(Game game, GraphicSettings settings) { _game = game; _graphicSettings = settings; ToggleFullScreen = new ActionVoid(this.M_ToggleFullScreen); Exit = new ActionVoid(this.M_Exit); }
public CursorManager(CursorProvider cursorProvider) { hardwareCursorsDisabled = Game.Settings.Graphics.DisableHardwareCursors; graphicSettings = Game.Settings.Graphics; sheetBuilder = new SheetBuilder(SheetType.BGRA); foreach (var kv in cursorProvider.Cursors) { var frames = kv.Value.Frames; var palette = !string.IsNullOrEmpty(kv.Value.Palette) ? cursorProvider.Palettes[kv.Value.Palette] : null; var c = new Cursor { Name = kv.Key, Bounds = Rectangle.FromLTRB(0, 0, 1, 1), Length = 0, Sprites = new Sprite[frames.Length], Cursors = new IHardwareCursor[frames.Length] }; // Hardware cursors have a number of odd platform-specific bugs/limitations. // Reduce the number of edge cases by padding the individual frames such that: // - the hotspot is inside the frame bounds (enforced by SDL) // - all frames within a sequence have the same size (needed for macOS 10.15) // - the frame size is a multiple of 8 (needed for Windows) foreach (var f in frames) { // Hotspot is specified relative to the center of the frame var hotspot = f.Offset.ToInt2() - kv.Value.Hotspot - new int2(f.Size) / 2; // SheetBuilder expects data in BGRA var data = FrameToBGRA(kv.Key, f, palette); c.Sprites[c.Length++] = sheetBuilder.Add(data, f.Size, 0, hotspot); // Bounds relative to the hotspot c.Bounds = Rectangle.Union(c.Bounds, new Rectangle(hotspot, f.Size)); } // Pad bottom-right edge to make the frame size a multiple of 8 c.PaddedSize = 8 * new int2((c.Bounds.Width + 7) / 8, (c.Bounds.Height + 7) / 8); cursors.Add(kv.Key, c); } CreateOrUpdateHardwareCursors(); foreach (var s in sheetBuilder.AllSheets) { s.ReleaseBuffer(); } Update(); }
// Token: 0x06000D44 RID: 3396 RVA: 0x0005C444 File Offset: 0x0005A644 private void SetCurrentQuality(int qualityLevel) { this._currentQuality = qualityLevel; if (this._currentQuality < QualitySettings.names.Length) { ApplicationDataManager.ApplicationOptions.IsUsingCustom = false; GraphicSettings.SetQualityLevel(this._currentQuality); this.SyncGraphicsSettings(); } else { ApplicationDataManager.ApplicationOptions.IsUsingCustom = true; } }
static void ShowDisplaySelectionDropdown(DropDownButtonWidget dropdown, GraphicSettings s) { Func <int, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, () => s.VideoDisplay == o, () => s.VideoDisplay = o); var label = $"Display {o + 1}"; item.Get <LabelWidget>("LABEL").GetText = () => label; return(item); }; dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, Enumerable.Range(0, Game.Renderer.DisplayCount), setupItem); }
public (DihtomiaRectangle first, DihtomiaRectangle second) SplitByMaxSide(GraphicSettings settings = null) { int splitDimension = GetMaxSide().dimension; List <double> firstUp = new List <double>(upperCorner); firstUp[splitDimension] = (lowerCorner[splitDimension] / 2 + upperCorner[splitDimension] / 2); DihtomiaRectangle first = new DihtomiaRectangle(new List <double>(lowerCorner), firstUp, settings); List <double> secondLow = new List <double>(lowerCorner); secondLow[splitDimension] = (lowerCorner[splitDimension] / 2 + upperCorner[splitDimension] / 2); DihtomiaRectangle second = new DihtomiaRectangle(secondLow, new List <double>(upperCorner), settings); return(first, second); }
public CustomActionList(Game game, GraphicSettings setting, CustomWorld world, Tracker tracker) : base(game, setting) { _world = world; _tracker = tracker; PlayerForward = new ActionVoid(this.PlayerMoveForward); PlayerRight = new ActionVoid(this.PlayerMoveRight); PlayerBackward = new ActionVoid(this.PlayerMoveBackward); PlayerLeft = new ActionVoid(this.PlayerMoveLeft); CameraRotation = new ActionFloatFloat(this.RotateCamera); RotateCameraHorizontally = new ActionFloat(this.M_RotateCameraX); RotateCameraVertically = new ActionFloat(this.M_RotateCameraY); Pause = new ActionVoid(this.M_Pause); Shoot = new ActionVoid(this.MethodShoot); }
private void LoadSettings() { var path = Path.Combine(Application.persistentDataPath, "Settings", "GraphicSettings.json"); if (File.Exists(path)) { graphicSettings = JsonUtility.FromJson <GraphicSettings>(File.ReadAllText(path)); antiAliasingDropdown.value = graphicSettings.AntiAliasing; fullscreenToggle.isOn = graphicSettings.FullScreen; textureDropdown.value = graphicSettings.Texture; //resolutionsDropdown.value = graphicSettings.ResolutionIndex; vSyncDropdown.value = graphicSettings.VSync; //resolutionsDropdown.RefreshShownValue(); } }
static void ShowGLProfileDropdown(DropDownButtonWidget dropdown, GraphicSettings s) { Func <GLProfile, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, () => s.GLProfile == o, () => s.GLProfile = o); var label = o.ToString(); item.Get <LabelWidget>("LABEL").GetText = () => label; return(item); }; var profiles = new[] { GLProfile.Automatic }.Concat(Game.Renderer.SupportedGLProfiles); dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, profiles, setupItem); }
static bool ShowRendererDropdown(DropDownButtonWidget dropdown, GraphicSettings s) { var options = new Dictionary <string, string>() { { "OpenGL", "Gl" }, { "Cg Toolkit", "Cg" }, }; Func <string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, () => s.Renderer == options[o], () => s.Renderer = options[o]); item.Get <LabelWidget>("LABEL").GetText = () => o; return(item); }; dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem); return(true); }
private void OnEnable() { graphicSettings = new GraphicSettings(); fullscreenToggle.onValueChanged.AddListener(delegate { OnFullscreenToggle(); }); //resolutionsDropdown.onValueChanged.AddListener(delegate { OnResolutionChange(); }); textureDropdown.onValueChanged.AddListener(delegate { OnTextureChange(); }); antiAliasingDropdown.onValueChanged.AddListener(delegate { OnAntiAliasingChange(); }); vSyncDropdown.onValueChanged.AddListener(delegate { OnVSyncChange(); }); /* * resolutions = Screen.resolutions; * * foreach (Resolution resolution in resolutions) * resolutionsDropdown.options.Add(new Dropdown.OptionData(resolution.ToString())); */ LoadSettings(); }
public static bool ShowWindowModeDropdown(DropDownButtonWidget dropdown, GraphicSettings s) { var options = new Dictionary <string, WindowMode>() { { "Pseudo-Fullscreen", WindowMode.PseudoFullscreen }, { "Fullscreen", WindowMode.Fullscreen }, { "Windowed", WindowMode.Windowed }, }; Func <string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, () => s.Mode == options[o], () => s.Mode = options[o]); item.Get <LabelWidget>("LABEL").GetText = () => o; return(item); }; dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem); return(true); }
Action ResetDisplayPanel(Widget panel) { var ds = Game.Settings.Graphics; var gs = Game.Settings.Game; var dds = new GraphicSettings(); var dgs = new GameSettings(); return(() => { gs.ShowShellmap = dgs.ShowShellmap; ds.CapFramerate = dds.CapFramerate; Game.SetIdealFrameTime(ds.MaxFramerate); ds.MaxFramerate = dds.MaxFramerate; ds.Language = dds.Language; ds.Mode = dds.Mode; ds.WindowedSize = dds.WindowedSize; ds.PixelDouble = dds.PixelDouble; worldRenderer.Viewport.Zoom = ds.PixelDouble ? 2 : 1; }); }
private void DoNothing(GraphicSettings settings) { var condition = toggle.isOn; switch (settings) { case GraphicSettings.Minimum: { } break; case GraphicSettings.Deafult: break; case GraphicSettings.Middle: break; case GraphicSettings.High: break; default: break; } }
public ModRectangle(List <double> lowerCorner, List <double> upperCorner, GraphicSettings settings = null) { this.lowerCorner = lowerCorner; this.upperCorner = upperCorner; settings?.Handle(lowerCorner, upperCorner); }
public void SetGraphicSettings(GraphicSettings level) { QualitySettings.SetQualityLevel((int)level, true); }
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); }
static bool ShowWindowModeDropdown(DropDownButtonWidget dropdown, GraphicSettings s) { var options = new Dictionary<string, WindowMode>() { { "Pseudo-Fullscreen", WindowMode.PseudoFullscreen }, { "Fullscreen", WindowMode.Fullscreen }, { "Windowed", WindowMode.Windowed }, }; Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, () => s.Mode == options[o], () => s.Mode = options[o]); item.Get<LabelWidget>("LABEL").GetText = () => o; return item; }; dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem); return true; }
Action ResetDisplayPanel(Widget panel) { var ds = Game.Settings.Graphics; var gs = Game.Settings.Game; var ps = Game.Settings.Player; var dds = new GraphicSettings(); var dgs = new GameSettings(); var dps = new PlayerSettings(); return () => { gs.ShowShellmap = dgs.ShowShellmap; ds.CapFramerate = dds.CapFramerate; ds.MaxFramerate = dds.MaxFramerate; ds.Language = dds.Language; ds.Mode = dds.Mode; ds.WindowedSize = dds.WindowedSize; ds.PixelDouble = dds.PixelDouble; ds.CursorDouble = dds.CursorDouble; worldRenderer.Viewport.Zoom = ds.PixelDouble ? 2 : 1; ps.Color = dps.Color; ps.Name = dps.Name; }; }
public TooltipContainerWidget() { graphicSettings = Game.Settings.Graphics; IsVisible = () => Game.RunTime > Viewport.LastMoveRunTime + TooltipDelayMilliseconds; }
Action ResetDisplayPanel(Widget panel) { var ds = Game.Settings.Graphics; var gs = Game.Settings.Game; var dds = new GraphicSettings(); var dgs = new GameSettings(); return () => { gs.ShowShellmap = dgs.ShowShellmap; ds.CapFramerate = dds.CapFramerate; Game.SetIdealFrameTime(ds.MaxFramerate); ds.MaxFramerate = dds.MaxFramerate; ds.Language = dds.Language; ds.Mode = dds.Mode; ds.WindowedSize = dds.WindowedSize; ds.PixelDouble = dds.PixelDouble; worldRenderer.Viewport.Zoom = ds.PixelDouble ? 2 : 1; }; }
public MouseAttachmentWidget(ModData modData, WorldRenderer worldRenderer) { this.worldRenderer = worldRenderer; graphicSettings = Game.Settings.Graphics; }