private TextButton AddButton(int y, string text) { var btn = new TextButton(); btn.Font = Root.Singleton.Font("fonts/JustinFont12Bold.ttf"); btn.Scale = 0.475f; btn.X = 25; btn.Y = y; btn.Text = text; btn.Parent = Window; btn.Init(); return btn; }
public override void OnActivate(params object[] args) { // Load settings currentres = new ResolutionSetting( Root.Singleton.Settings.ReadInt("Video", "ResX"), Root.Singleton.Settings.ReadInt("Video", "ResY") ); currentfs = Root.Singleton.Settings.ReadInt("Video", "Fullscreen") == 1; hotkeys = Root.Singleton.Settings.ReadInt("Video", "Hotkeys") == 1; backgrounds = Root.Singleton.Settings.ReadInt("Video", "Backgrounds") == 1; achievementPopups = Root.Singleton.Settings.ReadInt("Video", "AchievementPopups") == 1; autoPause = Root.Singleton.Settings.ReadInt("Video", "AutoPause") == 1; BackgroundImage = Root.Singleton.Material("img/box_text1.png"); base.OnActivate(); var lblTitle = new Label(); lblTitle.Colour = Color.White; lblTitle.Text = "Options: (ESCAPE when done)"; lblTitle.Font = Root.Singleton.Font("fonts/JustinFont12Bold.ttf"); lblTitle.Scale = 0.475f; lblTitle.X = 22; lblTitle.Y = 35; lblTitle.Parent = Window; lblTitle.Init(); btnResolution = AddButton(70); btnResolution.OnClick += (sender) => { int i = resolutions.IndexOf(currentres); i++; if (i >= resolutions.Count) i = 0; currentres = resolutions[i]; UpdateButtons(); windowresetneeded = true; }; btnFullscreen = AddButton(96); btnFullscreen.OnClick += (sender) => { currentfs = !currentfs; UpdateButtons(); windowresetneeded = true; }; btnHotkeys = AddButton(122); btnHotkeys.OnClick += (sender) => { hotkeys = !hotkeys; UpdateButtons(); }; btnDynamicBackgrounds = AddButton(148); btnDynamicBackgrounds.OnClick += (sender) => { backgrounds = !backgrounds; UpdateButtons(); }; btnAchievePopups = AddButton(174); btnAchievePopups.OnClick += (sender) => { achievementPopups = !achievementPopups; UpdateButtons(); }; btnWindowFocusPause = AddButton(200); btnWindowFocusPause.OnClick += (sender) => { autoPause = !autoPause; UpdateButtons(); }; UpdateButtons(); }
public void OnActivate() { // Store window window = Root.Singleton.Window; rctScreen = Util.ScreenRect(window.Size.X, window.Size.Y, 1.7778f); windowresetneeded = false; finishnow = false; window.KeyPressed += new EventHandler<KeyEventArgs>(window_KeyPressed); // Load settings currentres = new ResolutionSetting( Root.Singleton.Settings.ReadInt("Video", "ResX"), Root.Singleton.Settings.ReadInt("Video", "ResY") ); currentfs = Root.Singleton.Settings.ReadInt("Video", "Fullscreen") == 1; hotkeys = Root.Singleton.Settings.ReadInt("Video", "Hotkeys") == 1; backgrounds = Root.Singleton.Settings.ReadInt("Video", "Backgrounds") == 1; achievementPopups = Root.Singleton.Settings.ReadInt("Video", "AchievementPopups") == 1; autoPause = Root.Singleton.Settings.ReadInt("Video", "AutoPause") == 1; // Create UI pnObscure = new Panel(); pnObscure.Colour = new Color(0, 0, 0, 192); Util.LayoutControl(pnObscure, 0, 0, 1280, 720, rctScreen); pnObscure.Parent = Root.Singleton.Canvas; pnObscure.Init(); pnWindow = new ImagePanel(); pnWindow.Image = Root.Singleton.Material("img/box_text1.png"); Util.LayoutControl(pnWindow, (1280 / 2) - (616 / 2), (720 / 2) - (384 / 2), 616, 384, rctScreen); pnWindow.Parent = Root.Singleton.Canvas; pnWindow.Init(); var lblTitle = new Label(); lblTitle.Colour = Color.White; lblTitle.Text = "Options: (ESCAPE when done)"; lblTitle.Font = Root.Singleton.Font("fonts/JustinFont12Bold.ttf"); lblTitle.Scale = 0.475f; lblTitle.X = 22; lblTitle.Y = 35; lblTitle.Parent = pnWindow; lblTitle.Init(); btnResolution = AddButton(70); btnResolution.OnClick += (sender) => { int i = resolutions.IndexOf(currentres); i++; if (i >= resolutions.Count) i = 0; currentres = resolutions[i]; updateButtons(); windowresetneeded = true; }; btnFullscreen = AddButton(96); btnFullscreen.OnClick += (sender) => { currentfs = !currentfs; updateButtons(); windowresetneeded = true; }; btnHotkeys = AddButton(122); btnHotkeys.OnClick += (sender) => { hotkeys = !hotkeys; updateButtons(); }; btnDynamicBackgrounds = AddButton(148); btnDynamicBackgrounds.OnClick += (sender) => { backgrounds = !backgrounds; updateButtons(); }; btnAchievePopups = AddButton(174); btnAchievePopups.OnClick += (sender) => { achievementPopups = !achievementPopups; updateButtons(); }; btnWindowFocusPause = AddButton(200); btnWindowFocusPause.OnClick += (sender) => { autoPause = !autoPause; updateButtons(); }; updateButtons(); // Modal screen Root.Singleton.Canvas.ModalFocus = pnWindow; }