static void SaveColorFile(HWND hWnd,TSTR &name) { MaxSDK::Util::TextFile::Writer file; Interface14 *iface = GetCOREInterface14(); UINT codepage = iface-> DefaultTextSaveCodePage(true); //dll\PaintLayerMod\ColorPaletteTool.cpp :: SaveColorFile, UTF8 allowed, keep to same. if(!file.Open(fname, false, MaxSDK::Util::TextFile::Writer::WRITE_BOM | codepage )){ TSTR buf2 = GetString(IDS_RB_COLORCLIPBOARD); TSTR buf1; buf1.printf(GetString(IDS_RB_CANTOPENFILE),fname); MessageBox(hWnd,buf1,buf2,MB_ICONEXCLAMATION); return; } for (int i=0; i<12; i++) { int r, g, b; IColorSwatch *cs = GetIColorSwatch(GetDlgItem(hWnd,csIDs[i])); COLORREF col = cs->GetColor(); ReleaseIColorSwatch(cs); r = GetRValue(col); g = GetGValue(col); b = GetBValue(col); file.Printf(_T("%d %d %d\n"), r, g, b); } for (int i=0; i<12; i++) { IColorSwatch *cs = GetIColorSwatch(GetDlgItem(hWnd,csIDs[i])); AColor col = cs->GetAColor(); ReleaseIColorSwatch(cs); file.Printf(_T("%f %f %f %f\n"), col.r, col.g, col.b, col.a); } SetupTitle(hWnd,name); file.Close(); }
static INT_PTR CALLBACK ExportOptionsDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: CenterWindow(hWnd, GetParent(hWnd)); SetupDialog(hWnd); break; case CC_COLOR_CHANGE: switch (LOWORD(wParam)) { case IDC_PICKAMBIENTCOLOR: { HWND hwnd = GetDlgItem(hWnd, IDC_PICKAMBIENTCOLOR); if (hwnd) { IColorSwatch *pColorSwatch = GetIColorSwatch(hwnd); if (pColorSwatch) { AColor cAmbientColor = pColorSwatch->GetAColor(); g_SEOptions.fOverwrittenAmbientColor[0] = cAmbientColor.r; g_SEOptions.fOverwrittenAmbientColor[1] = cAmbientColor.g; g_SEOptions.fOverwrittenAmbientColor[2] = cAmbientColor.b; ReleaseIColorSwatch(pColorSwatch); } } break; } } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_PLDIRECTORIES: g_SEOptions.bPLDirectories = SendDlgItemMessage(hWnd, IDC_PLDIRECTORIES, BM_GETCHECK, 0, 0) != 0; UpdateDialog(hWnd); break; case IDC_OVERWRITEAMBIENTCOLOR: g_SEOptions.bOverwriteAmbientColor = SendDlgItemMessage(hWnd, IDC_OVERWRITEAMBIENTCOLOR, BM_GETCHECK, 0, 0) != 0; UpdateDialog(hWnd); break; case IDC_SCENECONTAINER: { int i = static_cast<int>(SendDlgItemMessage(hWnd, IDC_SCENECONTAINER, CB_GETCURSEL, 0, 0L)); if (i >= 0 && i < static_cast<int>(g_SEOptions.m_lstSceneContainers.size())) { String *psString = g_SEOptions.m_lstSceneContainers[i]; if (psString) g_SEOptions.sSceneContainer = *psString; } break; } case IDC_SCENERENDERER: { int i = static_cast<int>(SendDlgItemMessage(hWnd, IDC_SCENERENDERER, CB_GETCURSEL, 0, 0L)); if (i >= 0 && i < static_cast<int>(g_SEOptions.m_lstSceneRenderers.size())) { String *psString = g_SEOptions.m_lstSceneRenderers[i]; if (psString) g_SEOptions.sSceneRenderer = *psString; } break; } case IDC_EXPORTMATERIALS: g_SEOptions.bExportMaterials = SendDlgItemMessage(hWnd, IDC_EXPORTMATERIALS, BM_GETCHECK, 0, 0) != 0; UpdateDialog(hWnd); break; case IDC_EXPORTMESHES: g_SEOptions.bExportMeshes = SendDlgItemMessage(hWnd, IDC_EXPORTMESHES, BM_GETCHECK, 0, 0) != 0; UpdateDialog(hWnd); break; case IDC_TEXCOORDLAYER: { int i = static_cast<int>(SendDlgItemMessage(hWnd, IDC_TEXCOORDLAYER, CB_GETCURSEL, 0, 0L)); if (i >= 0 && i < PLSceneExportOptions::MaxTexCoords) SendDlgItemMessage(hWnd, IDC_TEXCOORDCOMPONENTS, CB_SETCURSEL, g_SEOptions.nTexCoordComponents[i], 0L); break; } case IDC_TEXCOORDCOMPONENTS: { int i = static_cast<int>(SendDlgItemMessage(hWnd, IDC_TEXCOORDLAYER, CB_GETCURSEL, 0, 0L)); if (i >= 0 && i < PLSceneExportOptions::MaxTexCoords) { int j = static_cast<int>(SendDlgItemMessage(hWnd, IDC_TEXCOORDCOMPONENTS, CB_GETCURSEL, 0, 0L)); if (j >= 0 && j < 4) g_SEOptions.nTexCoordComponents[i] = j; } break; } case IDC_CHOOSESCENEVIEWER: { char szFilename[_MAX_PATH] = ""; char szFilters[] = "Executable (*.exe)" "\0" "*.exe" "\0" "All files (*.*)" "\0" "*.*" "\0" "\0"; OPENFILENAMEA of; memset(&of, 0, sizeof(OPENFILENAME)); of.lStructSize = sizeof(OPENFILENAME); of.hwndOwner = hWnd; of.lpstrFilter = szFilters; of.nFilterIndex = 1; of.lpstrFile = szFilename; of.nMaxFile = 256; of.lpstrTitle = "Select viewer"; of.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; of.lpstrDefExt = "exe"; if (GetOpenFileNameA(&of)) { SetDlgItemTextA(hWnd, IDC_SCENEVIEWER, szFilename); g_SEOptions.sViewer = szFilename; } break; } case IDC_OK: GetSettings(hWnd); EndDialog(hWnd, 1); break; case IDC_CANCEL: EndDialog(hWnd, 0); break; case IDC_DEFAULT: g_SEOptions.SetDefaultSettings(); SetupDialog(hWnd); break; case IDC_LOAD: { char szFilename[_MAX_PATH] = ""; char szFilters[] = "Settings (*.ini)" "\0" "*.ini" "\0" "All files (*.*)" "\0" "*.*" "\0" "\0"; OPENFILENAMEA of; memset(&of, 0, sizeof(OPENFILENAME)); of.lStructSize = sizeof(OPENFILENAME); of.hwndOwner = hWnd; of.lpstrFilter = szFilters; of.nFilterIndex = 1; of.lpstrFile = szFilename; of.nMaxFile = 256; of.lpstrInitialDir = String(IPathConfigMgr::GetPathConfigMgr()->GetDir(APP_PLUGCFG_DIR)).GetASCII(); of.lpstrTitle = "Load exporter settings"; of.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; of.lpstrDefExt = "ini"; if (GetOpenFileNameA(&of)) { g_SEOptions.Load(szFilename); UpdateDialog(hWnd); } break; } case IDC_SAVE: { char szFilename[_MAX_PATH] = ""; char szFilters[] = "Settings (*.ini)" "\0" "*.ini" "\0" "All files (*.*)" "\0" "*.*" "\0" "\0"; OPENFILENAMEA of; memset(&of, 0, sizeof(OPENFILENAME)); of.lStructSize = sizeof(OPENFILENAME); of.hwndOwner = hWnd; of.lpstrFilter = szFilters; of.nFilterIndex = 1; of.lpstrFile = szFilename; of.nMaxFile = 256; of.lpstrInitialDir = String(IPathConfigMgr::GetPathConfigMgr()->GetDir(APP_PLUGCFG_DIR)).GetASCII(); of.lpstrTitle = "Save exporter settings"; of.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST; of.lpstrDefExt = "ini"; if (GetOpenFileNameA(&of)) g_SEOptions.Save(szFilename); break; } case IDC_HELPDOCUMENT: { // Get get runtime directory char *pszBuffer = PLTools::GetPixelLightRuntimeDirectory(); if (pszBuffer) { // Is there a '\' or '//' at the end? size_t nLength = strlen(pszBuffer); if (pszBuffer[nLength-1] == '\\' || pszBuffer[nLength-1] == '/') { pszBuffer[nLength-1] = '\0'; nLength--; } // Document file String sDocumentFile; // There MUST be a 'Runtime' at the end (first, we check for the public SDK structure) size_t nRuntimeLength = strlen("Runtime"); if (nLength > nRuntimeLength && !_stricmp(&pszBuffer[nLength-nRuntimeLength], "Runtime")) { // Remove the 'Runtime' nLength -= nRuntimeLength; pszBuffer[nLength] = '\0'; // Construct the absolute filename sDocumentFile = String(pszBuffer) + "Docs\\PixelLight3dsMaxSceneExport.pdf"; } // Cleanup delete [] pszBuffer; // Open the help document if (sDocumentFile.GetLength()) ShellExecuteW(0, L"open", sDocumentFile.GetUnicode(), 0, 0, SW_SHOW); } break; } case IDC_ABOUT: DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, AboutBoxDlgProc, 0); break; } break; case WM_CLOSE: EndDialog(hWnd, 0); return true; default: return false; } return true; }