mirror of
https://github.com/isledecomp/LEGOIslandRebuilder.git
synced 2025-02-17 00:20:40 -05:00
add d3d device support
This commit is contained in:
parent
08c3ac2f54
commit
5dd42f30c6
4 changed files with 73 additions and 1 deletions
|
@ -49,7 +49,7 @@ add_executable(Rebuilder WIN32
|
|||
src/window.h
|
||||
)
|
||||
|
||||
target_link_libraries(Rebuilder PRIVATE shlwapi.lib PropertyGrid)
|
||||
target_link_libraries(Rebuilder PRIVATE shlwapi.lib ddraw.lib dxguid.lib PropertyGrid)
|
||||
|
||||
# Ensure DLL is compiled before resource is built into executable
|
||||
set_source_files_properties(res/res.rc PROPERTIES OBJECT_DEPENDS Rebld)
|
||||
|
|
|
@ -159,6 +159,18 @@ LONG WINAPI InterceptRegQueryValueExA(HKEY hKey, LPCSTR lpValueName, LPDWORD lpR
|
|||
ReturnRegistryYESNOFromBool(lpData, config.GetInt(_T("DrawCursor"), 1));
|
||||
return ERROR_SUCCESS;
|
||||
|
||||
} else if (!strcmp(lpValueName, "3D Device ID")) {
|
||||
|
||||
std::string dev_id = config.GetString("D3DDeviceID");
|
||||
strcpy((char*)lpData, dev_id.c_str());
|
||||
return ERROR_SUCCESS;
|
||||
|
||||
} else if (!strcmp(lpValueName, "3D Device Name")) {
|
||||
|
||||
std::string dev_name = config.GetString("D3DDevice");
|
||||
strcpy((char*)lpData, dev_name.c_str());
|
||||
return ERROR_SUCCESS;
|
||||
|
||||
} else if (!strcmp(lpValueName, "savepath")) {
|
||||
|
||||
// If enabled, return a safe %APPDATA% based save location rather than its default
|
||||
|
|
|
@ -1,10 +1,44 @@
|
|||
#include "patchgrid.h"
|
||||
|
||||
#include <D3DRM.H>
|
||||
#include <DDRAW.H>
|
||||
#include <SHLWAPI.H>
|
||||
#include <SSTREAM>
|
||||
|
||||
#include "../cmn/path.h"
|
||||
|
||||
HRESULT CALLBACK ReceiveD3DDevice(GUID *lpGuid, LPSTR szDeviceDescription, LPSTR szDeviceName, LPD3DDEVICEDESC pD3DDD1, LPD3DDEVICEDESC pD3DDD2, LPVOID lpContext)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
// NOTE: Not really sure where the "0" comes from. I'm guessing it's the index of the ddraw
|
||||
// device, but I don't have any hardware that has a second one (I only have "Primary
|
||||
// Display Driver") so I can't experiment.
|
||||
sprintf(buf, "0 0x%lx 0x%x%x 0x%lx 0x%lx", lpGuid->Data1, lpGuid->Data3, lpGuid->Data2,
|
||||
*((DWORD*)&lpGuid->Data4), *((DWORD*)&lpGuid->Data4[4]));
|
||||
|
||||
PatchGrid *p = (PatchGrid*)lpContext;
|
||||
p->AddD3DDevice(szDeviceName, buf);
|
||||
|
||||
return DDENUMRET_OK;
|
||||
}
|
||||
|
||||
BOOL CALLBACK ReceiveDDrawDevice(GUID *lpGuid, LPSTR szDesc, LPSTR szName, LPVOID lpContext)
|
||||
{
|
||||
LPDIRECTDRAW dd;
|
||||
LPDIRECT3D2 d3d2;
|
||||
|
||||
DirectDrawCreate(lpGuid, &dd, NULL);
|
||||
|
||||
dd->QueryInterface(IID_IDirect3D2, (void**)&d3d2);
|
||||
d3d2->EnumDevices(ReceiveD3DDevice, lpContext);
|
||||
|
||||
d3d2->Release();
|
||||
dd->Release();
|
||||
|
||||
return DDENUMRET_OK;
|
||||
}
|
||||
|
||||
PatchGrid::PatchGrid()
|
||||
{
|
||||
SetBoldModified(true);
|
||||
|
@ -98,6 +132,13 @@ PatchGrid::PatchGrid()
|
|||
// Graphics Section
|
||||
HSECTION sectionGraphics = AddSection(_T("Graphics"));
|
||||
|
||||
DirectDrawEnumerateA(ReceiveDDrawDevice, this);
|
||||
m_d3dDeviceItem = AddComboItem(sectionGraphics, _T("Direct3D Device"), m_d3dDeviceNames, 0);
|
||||
|
||||
AddPatch("D3DDevice",
|
||||
_T("Set which Direct3D device to use with LEGO Island."),
|
||||
m_d3dDeviceItem);
|
||||
|
||||
AddPatch("FullScreen",
|
||||
_T("Allows you to change modes without administrator privileges and registry editing. NOTE: Windowed mode is NOT compatible with \"Flip Video Memory Pages\"."),
|
||||
AddBoolItem(sectionGraphics, _T("Run in Full Screen"), true));
|
||||
|
@ -257,11 +298,23 @@ BOOL PatchGrid::SaveConfiguration(LPCTSTR filename)
|
|||
if (!WritePrivateProfileString(appName, it->first.c_str(), value.c_str(), filename)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (it->second == m_d3dDeviceItem) {
|
||||
int device_index;
|
||||
GetItemValue(it->second, device_index);
|
||||
WritePrivateProfileString(appName, "D3DDeviceID", m_d3dDeviceIDs.at(device_index).c_str(), filename);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void PatchGrid::AddD3DDevice(const string &name, const string &id)
|
||||
{
|
||||
m_d3dDeviceNames.push_back(name);
|
||||
m_d3dDeviceIDs.push_back(id);
|
||||
}
|
||||
|
||||
void PatchGrid::AddPatch(const string &id, const CString &description, HITEM item)
|
||||
{
|
||||
m_mPatchItems[id] = item;
|
||||
|
|
|
@ -12,12 +12,19 @@ public:
|
|||
void LoadConfiguration(LPCTSTR filename);
|
||||
BOOL SaveConfiguration(LPCTSTR filename);
|
||||
|
||||
void AddD3DDevice(const std::string &name, const std::string &id);
|
||||
|
||||
private:
|
||||
void AddPatch(const std::string &id, const CString &description, HITEM item);
|
||||
|
||||
std::map<std::string, HITEM> m_mPatchItems;
|
||||
std::map<std::string, CString> m_mPatchDescriptions;
|
||||
|
||||
HITEM m_d3dDeviceItem;
|
||||
|
||||
std::vector<std::string> m_d3dDeviceNames;
|
||||
std::vector<std::string> m_d3dDeviceIDs;
|
||||
|
||||
};
|
||||
|
||||
#endif // PATCHGRID_H
|
||||
|
|
Loading…
Reference in a new issue