summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/ResolutionSlider.cs
blob: 088854a338e6344fc504483ec2c2534fec734379 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Linq;
using UnityEngine;

public class ResolutionSlider : MonoBehaviour
{
	private int targetIdx;

	private Resolution targetResolution;

	private bool targetFullscreen;

	private Resolution[] allResolutions;

	public SlideBar slider;

	public ToggleButtonBehaviour Fullscreen;

	public ToggleButtonBehaviour VSync;

	public TextRenderer Display;

	public void OnEnable()
	{
		this.allResolutions = (from r in Screen.resolutions
		where r.height > 480
		select r).ToArray<Resolution>();
		this.targetResolution = Screen.currentResolution;
		this.targetFullscreen = Screen.fullScreen;
		this.targetIdx = this.allResolutions.IndexOf((Resolution e) => e.width == this.targetResolution.width && e.height == this.targetResolution.height);
		this.slider.Value = (float)this.targetIdx / ((float)this.allResolutions.Length - 1f);
		this.Display.Text = string.Format("{0}x{1}", this.targetResolution.width, this.targetResolution.height);
		this.Fullscreen.UpdateText(this.targetFullscreen);
		this.VSync.UpdateText(QualitySettings.vSyncCount != 0);
	}

	public void ToggleVSync()
	{
		bool flag = QualitySettings.vSyncCount != 0;
		if (flag)
		{
			QualitySettings.vSyncCount = 0;
		}
		else
		{
			QualitySettings.vSyncCount = 1;
		}
		this.VSync.UpdateText(!flag);
	}

	public void ToggleFullscreen()
	{
		this.targetFullscreen = !this.targetFullscreen;
		this.Fullscreen.UpdateText(this.targetFullscreen);
	}

	public void OnResChange(SlideBar slider)
	{
		int num = Mathf.RoundToInt((float)(this.allResolutions.Length - 1) * slider.Value);
		if (num != this.targetIdx)
		{
			this.targetIdx = num;
			this.targetResolution = this.allResolutions[num];
			this.Display.Text = string.Format("{0}x{1}", this.targetResolution.width, this.targetResolution.height);
		}
		slider.Value = (float)this.targetIdx / ((float)this.allResolutions.Length - 1f);
	}

	public void SaveChange()
	{
		ResolutionManager.SetResolution(this.targetResolution.width, this.targetResolution.height, this.targetFullscreen);
	}
}