forked from AerysBat/XNALara
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSkyDomeParamsDialog.cs
77 lines (65 loc) · 2.61 KB
/
SkyDomeParamsDialog.cs
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
74
75
76
77
using System;
using System.Windows.Forms;
using Microsoft.Xna.Framework;
namespace XNALara
{
public partial class SkyDomeParamsDialog : Form
{
private Game game;
public SkyDomeParamsDialog(Game game) {
this.game = game;
InitializeComponent();
SetTrackBarRotation(MathHelper.ToDegrees(game.SkyDomeRotation));
SetTrackBarElevation(game.SkyDomeElevation);
checkBoxDisplay.Checked = game.DisplaySkyDome;
}
private void SetTrackBarRotation(float rotation) {
int rotationInt = (int)Math.Round(rotation);
if (rotationInt < trackBarRotation.Minimum) {
rotationInt = trackBarRotation.Minimum;
}
if (rotationInt > trackBarRotation.Maximum) {
rotationInt = trackBarRotation.Maximum;
}
trackBarRotation.Value = rotationInt;
textBoxRotation.Text = string.Format("{0}", rotationInt);
game.SkyDomeRotation = MathHelper.ToRadians(rotationInt);
}
private void SetTrackBarElevation(float elevation) {
int elevationInt = (int)Math.Round(elevation * 10.0f);
if (elevationInt < trackBarElevation.Minimum) {
elevationInt = trackBarElevation.Minimum;
}
if (elevationInt > trackBarElevation.Maximum) {
elevationInt = trackBarElevation.Maximum;
}
elevation = elevationInt * 0.1f;
trackBarElevation.Value = elevationInt;
textBoxElevation.Text = string.Format("{0:0.0}", elevation);
game.SkyDomeElevation = elevation;
}
private void TrackBarRotationScroll(object sender, EventArgs e) {
int rotation = trackBarRotation.Value;
SetTrackBarRotation(rotation);
}
private void TrackBarElevationScroll(object sender, EventArgs e) {
float elevation = trackBarElevation.Value * 0.1f;
SetTrackBarElevation(elevation);
}
private void CheckBoxDisplayCheckedChanged(object sender, EventArgs e) {
game.DisplaySkyDome = checkBoxDisplay.Checked;
}
private void ButtonCloseClick(object sender, EventArgs e) {
this.Close();
}
protected override void OnActivated(EventArgs e) {
game.HasFocus = false;
}
protected override void OnDeactivate(EventArgs e) {
game.HasFocus = true;
}
protected override void OnClosed(EventArgs e) {
game.ControlGUI.HandleSkyDomeParamsDialogClosed();
}
}
}