Skip to content

Commit fcd48cd

Browse files
committed
Match other functions
1 parent 5f9ae4f commit fcd48cd

3 files changed

Lines changed: 70 additions & 97 deletions

File tree

GolDP/include/goldevicelist.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef GOL_DEVICELIST_H
22
#define GOL_DEVICELIST_H
33

4-
#include "golvector.h"
54
#include "types.h"
65

76
#include <d3d.h>

GolDP/include/golvector.h

Lines changed: 0 additions & 28 deletions
This file was deleted.

GolDP/src/goldevicelist.cpp

Lines changed: 70 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -133,69 +133,71 @@ GolDeviceList::GolD3DDeviceInfo* GolDeviceList::SelectDevice(
133133
if (p_flags & GolDrawState::c_flagBit15) {
134134
HINSTANCE hInstance = reinterpret_cast<HINSTANCE>(GetWindowLongPtrA_COMPAT(p_hWnd, GWLP_HINSTANCE_COMPAT));
135135
LPDLGTEMPLATE dialogTemplate = reinterpret_cast<LPDLGTEMPLATE>(new LegoChar[TEMPLATE_SIZE]);
136-
::memset(dialogTemplate, 0, TEMPLATE_SIZE);
137-
dialogTemplate->style = WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER | DS_SETFOREGROUND |
138-
DS_NOIDLEMSG | DS_MODALFRAME | DS_SETFONT | DS_3DLOOK;
139-
dialogTemplate->dwExtendedStyle = 0x0;
140-
dialogTemplate->cdit = 6;
141-
dialogTemplate->x = 0;
142-
dialogTemplate->y = 0;
143-
dialogTemplate->cx = 179;
144-
dialogTemplate->cy = 84;
145-
146-
LegoU8* writePtr = reinterpret_cast<LegoU8*>(dialogTemplate + 1);
147-
// No menu
148-
*reinterpret_cast<wchar_t*>(writePtr) = L'\0';
149-
writePtr += 2;
150-
// Default window class
151-
*reinterpret_cast<wchar_t*>(writePtr) = L'\0';
152-
writePtr += 2;
153-
// Title
154-
STORE_DIALOG_ITEM_TEXT(&writePtr, "Select Direct3D Device");
155-
156-
*reinterpret_cast<LegoU16*>(writePtr) = 8;
157-
writePtr += 2;
158-
159-
STORE_DIALOG_ITEM_TEXT(&writePtr, "Arial");
160-
STORE_DIALOG_ITEM(&writePtr, WS_TABSTOP, 65, 65, 51, 14, IDOK, "BUTTON", "OK");
161-
STORE_DIALOG_ITEM(&writePtr, WS_TABSTOP, 123, 65, 51, 14, IDCANCEL, "BUTTON", "Cancel");
162-
STORE_DIALOG_ITEM(
163-
&writePtr,
164-
WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWNLIST,
165-
36,
166-
5,
167-
138,
168-
45,
169-
IDC_DRIVERS_COMBOBOX,
170-
"COMBOBOX",
171-
""
172-
);
173-
STORE_DIALOG_ITEM(
174-
&writePtr,
175-
WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWNLIST,
176-
36,
177-
24,
178-
138,
179-
45,
180-
IDC_DEVICES_COMBOBOX,
181-
"COMBOBOX",
182-
""
183-
);
184-
185-
StoreDialogItem(&writePtr, SS_LEFT, 5, 5, 22, 13, -1, "STATIC", "Driver:");
186-
StoreDialogItem(&writePtr, SS_LEFT, 5, 24, 29, 13, -1, "STATIC", "Device:");
187-
int result = DialogBoxIndirectParamA(
188-
hInstance,
189-
dialogTemplate,
190-
p_hWnd,
191-
SelectDeviceDlgProc,
192-
reinterpret_cast<LPARAM>(this)
193-
);
194-
195-
delete[] dialogTemplate;
196-
197-
if (result == IDOK) {
198-
device = &m_drivers[m_driverIndex].m_devices[m_deviceIndex];
136+
if (dialogTemplate != NULL) {
137+
::memset(dialogTemplate, 0, TEMPLATE_SIZE);
138+
dialogTemplate->style = WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER | DS_SETFOREGROUND |
139+
DS_NOIDLEMSG | DS_MODALFRAME | DS_SETFONT | DS_3DLOOK;
140+
dialogTemplate->dwExtendedStyle = 0x0;
141+
dialogTemplate->cdit = 6;
142+
dialogTemplate->x = 0;
143+
dialogTemplate->y = 0;
144+
dialogTemplate->cx = 179;
145+
dialogTemplate->cy = 84;
146+
147+
LegoU8* writePtr = reinterpret_cast<LegoU8*>(dialogTemplate + 1);
148+
// No menu
149+
*reinterpret_cast<wchar_t*>(writePtr) = L'\0';
150+
writePtr += 2;
151+
// Default window class
152+
*reinterpret_cast<wchar_t*>(writePtr) = L'\0';
153+
writePtr += 2;
154+
// Title
155+
STORE_DIALOG_ITEM_TEXT(&writePtr, "Select Direct3D Device");
156+
157+
*reinterpret_cast<LegoU16*>(writePtr) = 8;
158+
writePtr += 2;
159+
160+
STORE_DIALOG_ITEM_TEXT(&writePtr, "Arial");
161+
STORE_DIALOG_ITEM(&writePtr, WS_TABSTOP, 65, 65, 51, 14, IDOK, "BUTTON", "OK");
162+
STORE_DIALOG_ITEM(&writePtr, WS_TABSTOP, 123, 65, 51, 14, IDCANCEL, "BUTTON", "Cancel");
163+
STORE_DIALOG_ITEM(
164+
&writePtr,
165+
WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWNLIST,
166+
36,
167+
5,
168+
138,
169+
45,
170+
IDC_DRIVERS_COMBOBOX,
171+
"COMBOBOX",
172+
""
173+
);
174+
STORE_DIALOG_ITEM(
175+
&writePtr,
176+
WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWNLIST,
177+
36,
178+
24,
179+
138,
180+
45,
181+
IDC_DEVICES_COMBOBOX,
182+
"COMBOBOX",
183+
""
184+
);
185+
186+
StoreDialogItem(&writePtr, SS_LEFT, 5, 5, 22, 13, -1, "STATIC", "Driver:");
187+
StoreDialogItem(&writePtr, SS_LEFT, 5, 24, 25, 13, -1, "STATIC", "Device:");
188+
int result = DialogBoxIndirectParamA(
189+
hInstance,
190+
dialogTemplate,
191+
p_hWnd,
192+
SelectDeviceDlgProc,
193+
reinterpret_cast<LPARAM>(this)
194+
);
195+
196+
delete[] dialogTemplate;
197+
198+
if (result == IDOK) {
199+
device = &m_drivers[m_driverIndex].m_devices[m_deviceIndex];
200+
}
199201
}
200202
}
201203

@@ -336,8 +338,8 @@ void GolDeviceList::UpdateDialog(HWND p_hWnd)
336338
}
337339
}
338340

339-
for (LegoU32 deviceIndex = 0; deviceIndex < m_drivers[m_driverIndex].m_countDevices; deviceIndex++) {
340-
GolD3DDeviceInfo* device = &m_drivers[m_driverIndex].m_devices[deviceIndex];
341+
GolD3DDeviceInfo* device = m_drivers[m_driverIndex].m_devices;
342+
for (LegoU32 deviceIndex = 0; deviceIndex < m_drivers[m_driverIndex].m_countDevices; deviceIndex++, device++) {
341343
LegoU32 comboBoxIndex = SendDlgItemMessageA(
342344
p_hWnd,
343345
IDC_DEVICES_COMBOBOX,
@@ -346,7 +348,7 @@ void GolDeviceList::UpdateDialog(HWND p_hWnd)
346348
reinterpret_cast<LPARAM>(device->m_description)
347349
);
348350

349-
if (deviceIndex == m_driverIndex) { // FIXME: should compare against m_deviceIndex
351+
if (deviceIndex == m_driverIndex) {
350352
SendDlgItemMessageA(p_hWnd, IDC_DEVICES_COMBOBOX, CB_SETCURSEL, comboBoxIndex, 0);
351353
}
352354
}
@@ -578,8 +580,8 @@ INT_PTR_COMPAT GolDeviceList::SelectDeviceDlgProc(HWND p_hWnd, UINT p_uMsg, WPAR
578580
return 1;
579581
}
580582

581-
LegoS16 hiWord = HIWORD(p_wParam);
582-
if (hiWord == CBN_SELENDOK) {
583+
LegoS16 notificationCode = HIWORD(p_wParam);
584+
if (notificationCode == CBN_SELENDOK) {
583585
int index = SendMessage(reinterpret_cast<HWND>(p_lParam), CB_GETCURSEL, 0, 0);
584586

585587
if (index == -1) {

0 commit comments

Comments
 (0)