Isle
Loading...
Searching...
No Matches
MainDlg.cpp
Go to the documentation of this file.
1#include "MainDlg.h"
2
3#include "AboutDlg.h"
4#include "config.h"
5#include "res/resource.h"
6
8
9DECOMP_SIZE_ASSERT(CDialog, 0x60)
11
12// FUNCTION: CONFIG 0x00403d50
13CMainDialog::CMainDialog(CWnd* pParent) : CDialog(IDD, pParent)
14{
15 afxCurrentWinApp;
16 m_icon = LoadIconA(AfxFindResourceHandle(MAKEINTRESOURCE(IDI_CONFIG), RT_GROUP_ICON), MAKEINTRESOURCE(IDI_CONFIG));
17}
18
19// FUNCTION: CONFIG 0x00403e50
20void CMainDialog::DoDataExchange(CDataExchange* pDX)
21{
22}
23
24BEGIN_MESSAGE_MAP(CMainDialog, CDialog)
25ON_WM_SYSCOMMAND()
26ON_WM_PAINT()
27ON_WM_QUERYDRAGICON()
28ON_COMMAND(IDC_CHK_FLIP_VIDEO_MEM_PAGES, OnCheckboxFlipVideoMemPages)
29ON_LBN_SELCHANGE(IDC_LIST_3DDEVICES, OnList3DevicesSelectionChanged)
30ON_COMMAND(IDC_RAD_PALETTE_16BIT, OnRadiobuttonPalette16bit)
31ON_COMMAND(IDC_RAD_PALETTE_256, OnRadiobuttonPalette256)
32ON_COMMAND(IDC_CHK_3D_VIDEO_MEMORY, OnCheckbox3DVideoMemory)
33ON_WM_DESTROY() // FIXME: CONFIG.EXE calls Default
34ON_COMMAND(IDABORT, OnButtonCancel)
35ON_COMMAND(IDC_CHK_3DSOUND, OnCheckbox3DSound)
36ON_COMMAND(IDC_RAD_MODEL_QUALITY_LOW, OnRadiobuttonModelLowQuality)
37ON_COMMAND(IDC_RAD_MODEL_QUALITY_HIGH, OnRadiobuttonModelHighQuality)
38ON_COMMAND(IDC_RAD_TEXTURE_QUALITY_LOW, OnRadiobuttonTextureLowQuality)
39ON_COMMAND(IDC_RAD_TEXTURE_QUALITY_HIGH, OnRadiobuttonTextureHighQuality)
40ON_COMMAND(IDC_CHK_JOYSTICK, OnCheckboxJoystick)
41ON_COMMAND(IDC_BTN_ADVANCED, OnButtonAdvanced)
42ON_COMMAND(IDC_CHK_DRAW_CURSOR, OnCheckboxDrawCursor)
43ON_COMMAND(IDC_CHK_MUSIC, OnCheckboxMusic)
44END_MESSAGE_MAP()
45
46// FUNCTION: CONFIG 0x00403e80
47BOOL CMainDialog::OnInitDialog()
48{
49 CDialog::OnInitDialog();
50 SwitchToAdvanced(FALSE);
51 CMenu* system_menu = CMenu::FromHandle(::GetSystemMenu(m_hWnd, FALSE));
52 CString about_text;
53 about_text.LoadString(IDS_ABOUT);
54 if (system_menu) {
55 AppendMenuA(system_menu->m_hMenu, MF_SEPARATOR, 0, NULL);
56 AppendMenuA(system_menu->m_hMenu, MF_STRING, 16, (LPCTSTR) about_text);
57 }
58 SendMessage(WM_SETICON, ICON_BIG, (LPARAM) m_icon);
59 SendMessage(WM_SETICON, ICON_SMALL, (LPARAM) m_icon);
60 LegoDeviceEnumerate* enumerator = currentConfigApp->m_device_enumerator;
61 enumerator->FUN_1009d210();
62 m_modified = currentConfigApp->ReadRegisterSettings();
63 CWnd* list_3d_devices = GetDlgItem(IDC_LIST_3DDEVICES);
64 int driver_i = 0;
65 int device_i = 0;
66 int selected = 0;
67 char device_name[256];
68 const list<MxDriver>& driver_list = enumerator->GetDriverList();
69 for (list<MxDriver>::const_iterator it_driver = driver_list.begin(); it_driver != driver_list.end(); it_driver++) {
70 const MxDriver& driver = *it_driver;
71 for (list<Direct3DDeviceInfo>::const_iterator it_device = driver.m_devices.begin();
72 it_device != driver.m_devices.end();
73 it_device++) {
74 const Direct3DDeviceInfo& device = *it_device;
75 if (&device == currentConfigApp->m_device) {
76 selected = device_i;
77 }
78 device_i += 1;
79 sprintf(
80 device_name,
81 driver_i == 0 ? "%s ( Primary Device )" : "%s ( Secondary Device )",
82 device.m_deviceName
83 );
84 ::SendMessage(list_3d_devices->m_hWnd, LB_ADDSTRING, 0, (LPARAM) device_name);
85 }
86 driver_i += 1;
87 }
88 ::SendMessage(list_3d_devices->m_hWnd, LB_SETCURSEL, selected, 0);
89 UpdateInterface();
90 return TRUE;
91}
92
93// FUNCTION: CONFIG 0x00404080
94void CMainDialog::OnSysCommand(UINT nID, LPARAM lParam)
95{
96 if ((nID & 0xfff0) == 0x10) {
97 CAboutDialog about_dialog;
98 about_dialog.DoModal();
99 }
100 else {
101 Default();
102 }
103}
104
105// FUNCTION: CONFIG 0x00404150
107{
108 if (IsIconic()) {
109 CPaintDC painter(this);
110 ::SendMessage(m_hWnd, WM_ICONERASEBKGND, (WPARAM) painter.m_hDC, 0);
111 RECT dim;
112 GetClientRect(&dim);
113 DrawIcon(
114 painter.m_hDC,
115 (dim.right - dim.left - GetSystemMetrics(SM_CXICON) + 1) / 2,
116 (dim.bottom - dim.top - GetSystemMetrics(SM_CYICON) + 1) / 2,
117 m_icon
118 );
119 }
120 else {
121 Default();
122 }
123}
124
125// FUNCTION: CONFIG 0x00404230
127{
128 return m_icon;
129}
130
131// FUNCTION: CONFIG 0x00404240
133{
134 LegoDeviceEnumerate* device_enumerator = currentConfigApp->m_device_enumerator;
135 int selected = ::SendMessage(GetDlgItem(IDC_LIST_3DDEVICES)->m_hWnd, LB_GETCURSEL, 0, 0);
136 device_enumerator->GetDevice(selected, currentConfigApp->m_driver, currentConfigApp->m_device);
137 if (currentConfigApp->GetHardwareDeviceColorModel()) {
138 GetDlgItem(IDC_CHK_DRAW_CURSOR)->EnableWindow(TRUE);
139 }
140 else {
141 currentConfigApp->m_3d_video_ram = FALSE;
142 currentConfigApp->m_flip_surfaces = FALSE;
143 CheckDlgButton(IDC_CHK_3D_VIDEO_MEMORY, currentConfigApp->m_3d_video_ram);
144 CheckDlgButton(IDC_CHK_FLIP_VIDEO_MEM_PAGES, currentConfigApp->m_flip_surfaces);
145 }
148}
149
150// FUNCTION: CONFIG 0x00404320
152{
153 CDialog::OnCancel();
154}
155
156// FUNCTION: CONFIG 0x00404330
158{
159 CDialog::Default();
160}
161
162// FUNCTION: CONFIG 0x00404340
164{
165 if (m_modified) {
166 currentConfigApp->WriteRegisterSettings();
167 }
168 OnCancel();
169}
170
171// FUNCTION: CONFIG 0x00404360
173{
174 currentConfigApp->ValidateSettings();
175 GetDlgItem(IDC_CHK_3D_VIDEO_MEMORY)
176 ->EnableWindow(!currentConfigApp->m_flip_surfaces && !currentConfigApp->GetHardwareDeviceColorModel());
177 CheckDlgButton(IDC_CHK_FLIP_VIDEO_MEM_PAGES, currentConfigApp->m_flip_surfaces);
178 CheckDlgButton(IDC_CHK_3D_VIDEO_MEMORY, currentConfigApp->m_3d_video_ram);
179 BOOL full_screen = currentConfigApp->m_full_screen;
180 currentConfigApp->AdjustDisplayBitDepthBasedOnRenderStatus();
181 if (currentConfigApp->GetHardwareDeviceColorModel()) {
182 CheckDlgButton(IDC_CHK_DRAW_CURSOR, TRUE);
183 }
184 else {
185 CheckDlgButton(IDC_CHK_DRAW_CURSOR, FALSE);
186 currentConfigApp->m_draw_cursor = FALSE;
187 GetDlgItem(IDC_CHK_DRAW_CURSOR)->EnableWindow(FALSE);
188 }
189 if (full_screen) {
190 CheckRadioButton(
194 );
195 }
196 else {
197 CheckDlgButton(IDC_RAD_PALETTE_256, 0);
198 CheckDlgButton(IDC_RAD_PALETTE_16BIT, 0);
199 currentConfigApp->m_display_bit_depth = 0;
200 }
201 GetDlgItem(IDC_RAD_PALETTE_256)
202 ->EnableWindow(full_screen && currentConfigApp->GetConditionalDeviceRenderBitDepth());
203 GetDlgItem(IDC_RAD_PALETTE_16BIT)->EnableWindow(full_screen && currentConfigApp->GetDeviceRenderBitStatus());
204 CheckDlgButton(IDC_CHK_3DSOUND, currentConfigApp->m_3d_sound);
205 CheckDlgButton(IDC_CHK_DRAW_CURSOR, currentConfigApp->m_draw_cursor);
206 switch (currentConfigApp->m_model_quality) {
207 case 1:
209 break;
210 case 2:
212 break;
213 }
214 CheckRadioButton(
218 );
219 CheckDlgButton(IDC_CHK_JOYSTICK, currentConfigApp->m_use_joystick);
220 CheckDlgButton(IDC_CHK_MUSIC, currentConfigApp->m_music);
221}
222
223// FUNCTION: CONFIG 0x004045e0
225{
226 currentConfigApp->m_3d_sound = IsDlgButtonChecked(IDC_CHK_3DSOUND);
229}
230
231// FUNCTION: CONFIG 0x00404610
233{
234 currentConfigApp->m_3d_video_ram = IsDlgButtonChecked(IDC_CHK_3D_VIDEO_MEMORY);
237}
238
239// FUNCTION: CONFIG 0x00404640
241{
242 currentConfigApp->m_display_bit_depth = 16;
245}
246
247// FUNCTION: CONFIG 0x00404670
249{
250 currentConfigApp->m_display_bit_depth = 8;
253}
254
255// FUNCTION: CONFIG 0x004046a0
257{
258 currentConfigApp->m_flip_surfaces = IsDlgButtonChecked(IDC_CHK_FLIP_VIDEO_MEM_PAGES);
261}
262
263// FUNCTION: CONFIG 0x004046d0
265{
266 currentConfigApp->m_model_quality = 1;
269}
270
271// FUNCTION: CONFIG 0x00404700
273{
274 currentConfigApp->m_model_quality = 2;
277}
278
279// FUNCTION: CONFIG 0x00404730
281{
282 currentConfigApp->m_texture_quality = 0;
285}
286
287// FUNCTION: CONFIG 0x00404760
289{
290 currentConfigApp->m_texture_quality = 1;
293}
294
295// FUNCTION: CONFIG 0x00404790
297{
298 currentConfigApp->m_use_joystick = IsDlgButtonChecked(IDC_CHK_JOYSTICK);
301}
302
303// FUNCTION: CONFIG 0x004047c0
305{
307}
308
309// FUNCTION: CONFIG 0x004047d0
311{
312 RECT dialog_rect;
313 RECT grp_advanced_rect;
314 ::GetWindowRect(m_hWnd, &dialog_rect);
315 ::GetWindowRect(GetDlgItem(IDC_GRP_ADVANCED)->m_hWnd, &grp_advanced_rect);
316 CWnd* button_advanced = GetDlgItem(IDC_BTN_ADVANCED);
317 m_advanced = p_advanced;
318 int height;
319 if (p_advanced) {
320 height = grp_advanced_rect.bottom - dialog_rect.top + 10;
321 GetDlgItem(IDC_BMP_SHARK)->EnableWindow(TRUE);
322 button_advanced->SetWindowText("Basic");
323 }
324 else {
325 height = grp_advanced_rect.top - dialog_rect.top;
326 GetDlgItem(IDC_BMP_SHARK)->EnableWindow(FALSE);
327 button_advanced->SetWindowText("Advanced");
328 }
329 SetWindowPos(&wndTop, 0, 0, dialog_rect.right - dialog_rect.left, height, SWP_NOMOVE);
330}
331
332// FUNCTION: CONFIG 0x00404890
334{
335 currentConfigApp->m_draw_cursor = IsDlgButtonChecked(IDC_CHK_DRAW_CURSOR);
338}
339
340// FUNCTION: CONFIG 0x004048c0
342{
343 currentConfigApp->m_music = IsDlgButtonChecked(IDC_CHK_MUSIC);
346}
#define IDC_CHK_DRAW_CURSOR
[AI] Checkbox for toggling hardware/software cursor drawing. [AI]
#define IDC_CHK_FLIP_VIDEO_MEM_PAGES
[AI] Checkbox for enabling video memory page flipping. [AI]
#define IDC_CHK_3DSOUND
[AI] Checkbox for enabling or disabling 3D sound effects. [AI]
#define IDC_CHK_MUSIC
[AI] Checkbox for enabling/disabling background music. [AI]
#define IDC_BTN_ADVANCED
[AI] Button ID for launching the advanced options dialog. [AI]
#define IDC_RAD_TEXTURE_QUALITY_LOW
[AI] Radio button for low texture quality setting. [AI]
#define IDC_RAD_PALETTE_256
[AI] Radio button ID for selecting 256-color palette. [AI]
#define IDC_LIST_3DDEVICES
[AI] Control ID for the list box of available 3D devices. [AI]
#define IDC_CHK_JOYSTICK
[AI] Checkbox for enabling joystick support. [AI]
#define IDC_BMP_SHARK
[AI] Bitmap control displaying the shark image/animation. [AI]
#define IDC_GRP_ADVANCED
[AI] Group box for "Advanced" options section. [AI]
#define IDI_CONFIG
[AI] Icon resource identifier for configuration dialog. [AI]
#define IDC_RAD_PALETTE_16BIT
[AI] Radio button ID for selecting 16-bit palette. [AI]
#define IDC_CHK_3D_VIDEO_MEMORY
[AI] Checkbox for enabling 3D video memory usage. [AI]
#define IDC_RAD_TEXTURE_QUALITY_HIGH
[AI] Radio button for high texture quality setting. [AI]
#define IDC_RAD_MODEL_QUALITY_LOW
[AI] Radio button for low model quality option. [AI]
#define IDS_ABOUT
[AI] String resource identifier for the "About" box text. [AI]
#define IDC_RAD_MODEL_QUALITY_HIGH
[AI] Radio button for high model quality option. [AI]
[AI] Dialog for the application's About box.
Definition: AboutDlg.h:15
The main dialog window for the LEGO Island configuration program (config.exe).
Definition: MainDlg.h:18
BOOL m_advanced
Whether the dialog is in advanced mode. [AI].
Definition: MainDlg.h:61
void OnCheckboxFlipVideoMemPages()
Handler for 'Flip video memory pages' checkbox.
Definition: MainDlg.cpp:256
void OnCheckbox3DVideoMemory()
Handler for '3D video memory' checkbox toggle.
Definition: MainDlg.cpp:232
void OnList3DevicesSelectionChanged()
Handles selection changes in the list of 3D devices.
Definition: MainDlg.cpp:132
void OnPaint()
Handles dialog paint (redraw).
Definition: MainDlg.cpp:106
void OnRadiobuttonTextureLowQuality()
Handler for 'Low quality texture' radio button.
Definition: MainDlg.cpp:280
void OnCheckbox3DSound()
Handler for '3D sound' checkbox toggle.
Definition: MainDlg.cpp:224
HCURSOR m_icon
Handle to the dialog's icon (used for window/taskbar and drag). [AI].
Definition: MainDlg.h:55
void OnRadiobuttonModelLowQuality()
Handler for 'Low quality model' radio button.
Definition: MainDlg.cpp:264
void SwitchToAdvanced(BOOL p_advanced)
Switches UI layout between basic and advanced configuration.
Definition: MainDlg.cpp:310
void UpdateInterface()
Refreshes the dialog interface according to current configuration settings.
Definition: MainDlg.cpp:172
void OnCheckboxJoystick()
Handler for 'Joystick' checkbox toggle.
Definition: MainDlg.cpp:296
void DoDataExchange(CDataExchange *pDX) override
DDX (Dialog Data Exchange) for MFC controls.
Definition: MainDlg.cpp:20
void OnCheckboxMusic()
Handler for 'Music' checkbox toggle.
Definition: MainDlg.cpp:341
void OnSysCommand(UINT nID, LPARAM lParam)
MFC handler for system commands (such as About box invocation).
Definition: MainDlg.cpp:94
void OnCancel()
Handles dialog cancellation and executes clean-up (if needed).
Definition: MainDlg.cpp:151
void OnRadiobuttonPalette16bit()
Handler for '16-bit palette' radio button.
Definition: MainDlg.cpp:240
void OnDestroy()
Handles destruction/closing of the dialog window (WM_DESTROY handler).
Definition: MainDlg.cpp:157
void OnRadiobuttonTextureHighQuality()
Handler for 'High quality texture' radio button.
Definition: MainDlg.cpp:288
HCURSOR OnQueryDragIcon()
Returns handle to drag icon when dragging minimized window.
Definition: MainDlg.cpp:126
void OnRadiobuttonModelHighQuality()
Handler for 'High quality model' radio button.
Definition: MainDlg.cpp:272
void OnRadiobuttonPalette256()
Handler for '256-color palette' radio button.
Definition: MainDlg.cpp:248
BOOL m_modified
Whether any configuration setting has been modified and needs to be saved. [AI].
Definition: MainDlg.h:58
void OnCheckboxDrawCursor()
Handler for 'Draw cursor' checkbox toggle.
Definition: MainDlg.cpp:333
void OnButtonAdvanced()
Handler for 'Advanced' button.
Definition: MainDlg.cpp:304
void OnButtonCancel()
Processes 'Cancel' button press (IDABORT), optionally writes settings before exit.
Definition: MainDlg.cpp:163
[AI] Enumerates and manages Direct3D devices and drivers for the LEGO Island engine.
Definition: legodxinfo.h:24
int GetDevice(int p_deviceNum, MxDriver *&p_driver, Direct3DDeviceInfo *&p_device)
[AI] Outputs pointers to the MxDriver and Direct3DDeviceInfo for the given device index.
Definition: legodxinfo.cpp:85
int FUN_1009d210()
[AI] Prunes the enumeration to only include devices/drivers that support the required display mode an...
Definition: legodxinfo.cpp:294
const list< MxDriver > & GetDriverList() const
[AI] Returns a const reference to the list of enumerated drivers/devices/modes.
#define currentConfigApp
[AI] Macro to access the currently running configuration application instance (cast from afxCurrentWi...
Definition: config.h:15
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
typedef BOOL(FAR PASCAL *LPDIENUMDEVICEOBJECTSCALLBACKA)(LPCDIDEVICEOBJECTINSTANCEA
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
[AI] Encapsulates Direct3D device enumeration information and capability structures.
char * m_deviceName
[AI] Unlocalized device name/identifier (owned string).
[AI] Holds data about a DirectDraw driver including devices and supported display modes.
list< Direct3DDeviceInfo > m_devices
[AI] List of all Direct3D devices provided by this driver.