14aec2f2bcabffecad7d93cc72bad4e8029fc271
[sdk] / samples / 3D / ModelViewer / engineSettings.ec
1 import "ecere"
2
3 class EngineSettings : Window
4 {
5    text = "ECERE 3D Engine Settings";
6    borderStyle = fixed;
7    hasClose = true;
8    tabCycle = true;
9    font = { "Tahoma", 10 };
10    size = { 606, 346 };
11
12    bool fullScreen;
13    Resolution resolution;
14    PixelFormat colorDepth;
15    int refreshRate;
16    char * driver;
17    driver = "OpenGL";
18
19    Picture ecereLogo { this, image = BitmapResource { ":ecere.png", alphaBlend = true }, anchor = { left = 30, top = 10 } };
20
21    // Driver
22    DropBox driverBox
23    {
24       this, text = "3D API", hotKey = d, size = { 112, 24 }, anchor = { horz = 204, top = 40 };
25
26       bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
27       {
28          driver = (char *)row.tag;
29          return true;
30       }
31    };
32    Label { this, labeledWindow = driverBox, anchor = { horz = 204, top = 16 } };
33
34    // Resolution
35    DropBox resBox
36    {
37       this, text = "Resolution", hotKey = r, size = { 112, 24 }, anchor = { horz = 204, top = 96 }, disabled = !fullScreen;
38
39       bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
40       {
41          resolution = (Resolution)row.tag;
42          return true;
43       }
44    };
45    Label { this, labeledWindow = resBox, anchor = { horz = 205, top = 72 } };
46
47    // Color Depth
48    DropBox bppBox
49    {
50       this, text = "Color Depth", hotKey = c, size = { 112, 24 }, anchor = { horz = 204, top = 152 }, disabled = !fullScreen;
51
52       bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
53       {
54          colorDepth = (PixelFormat)row.tag;
55          return true;
56       }
57    };
58    Label { this, labeledWindow = bppBox, anchor = { horz = 208, top = 128 } };
59
60    // Refresh Rate
61    DropBox refBox
62    {
63       this, text = "Refresh Rate", hotKey = t, size = { 112, 24 }, anchor = { horz = 204, top = 208 }, disabled = !fullScreen;
64
65       bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
66       {
67          refreshRate = (int)row.tag;
68          return true;
69       }
70    };
71    Label { labeledWindow = refBox, parent = this, anchor = { horz = 204, top = 184 } };
72    Button btnFullScreen
73    {
74       this, isCheckbox = true, text = "Full Screen", hotKey = f, anchor = { horz = 203, top = 248 }, checked = fullScreen;
75
76       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
77       {
78          fullScreen = button.checked;
79          resBox.disabled = !fullScreen;
80          refBox.disabled = !fullScreen;
81          bppBox.disabled = !fullScreen;
82          Update(null);
83          return true;
84       }
85    };
86    Button exitBtn
87    {
88       this, text = "Exit", size = { 80, 24 }, anchor = { horz = 69, top = 168 }, NotifyClicked = ButtonCloseDialog;
89    };
90    Button run
91    {
92       this, text = "Start", isDefault = true, size = { 80, 24 }, anchor = { horz = 69, top = 96 };
93
94       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
95       {
96          Destroy(1);
97          ((GuiApplication)__thisModule).SwitchMode(fullScreen, driver, resolution, colorDepth, refreshRate, null, true);
98          return false;
99       }
100    };
101
102    EngineSettings()
103    {
104       driverBox.AddString("OpenGL").tag = (int64)"OpenGL";
105       driverBox.AddString("Direct3D 9").tag = (int64)"Direct3D";
106       driverBox.AddString("Direct3D 8").tag = (int64)"Direct3D8";
107       driverBox.currentRow = driverBox.firstRow;
108
109       resBox.AddString("Current");
110       resBox.AddString("640x480").tag = Resolution::res640x480;
111       resBox.AddString("800x600").tag = Resolution::res800x600;
112       resBox.AddString("1024x768").tag = Resolution::res1024x768;
113       resBox.AddString("1280x1024").tag = Resolution::res1280x1024;
114       resBox.AddString("1600x1200").tag = Resolution::res1600x1200;
115       resBox.currentRow = resBox.FindRow(resolution);
116
117       bppBox.AddString("Current");
118       bppBox.AddString("16 bpp").tag = PixelFormat::pixelFormat565;
119       bppBox.AddString("24 bpp").tag = PixelFormat::pixelFormat888;
120       bppBox.currentRow = bppBox.FindRow(colorDepth);
121
122       refBox.AddString("Current");
123       refBox.AddString("60 Hz").tag = 60;
124       refBox.AddString("75 Hz").tag = 75;
125       refBox.AddString("85 Hz").tag = 85;
126       refBox.AddString("100 Hz").tag = 100;
127       refBox.AddString("120 Hz").tag = 120;
128       refBox.currentRow = refBox.FindRow(refreshRate);
129    }
130 }