BOOL CALLBACK AddCommandDlgProc( HWND hwndDlg, // handle to dialog box UINT uMsg, // message WPARAM wParam, // first message parameter LPARAM lParam // second message parameter ) { char key[64]; char value[128]; switch( uMsg ) { case WM_COMMAND: switch( LOWORD( wParam ) ) { case IDOK: if( !GetDlgItemText( hwndDlg, IDC_CMDMENUTEXT, key, 64 ) ) { common->Printf( "Command not added\n" ); return FALSE; } if( !GetDlgItemText( hwndDlg, IDC_CMDCOMMAND, value, 64 ) ) { common->Printf( "Command not added\n" ); return FALSE; } if( key[0] == 'b' && key[1] == 's' && key[2] == 'p' ) { SetKeyValue( g_qeglobals.d_project_entity, key, value ); FillBSPMenu(); } else { common->Printf( "BSP commands must be preceded by \"bsp\"" ); } EndDialog( hwndDlg, 1 ); return TRUE; case IDCANCEL: EndDialog( hwndDlg, 0 ); return TRUE; } } return FALSE; }
BOOL CALLBACK EditCommandDlgProc( HWND hwndDlg, // handle to dialog box UINT uMsg, // message WPARAM wParam, // first message parameter LPARAM lParam // second message parameter ) { char key[1024]; char value[1024]; const char *temp; int index; HWND hOwner; hOwner = GetParent( hwndDlg ); switch( uMsg ) { case WM_INITDIALOG: index = SendDlgItemMessage( hOwner, IDC_CMD_LIST, LB_GETCURSEL, 0, 0 ); if( index >= 0 ) { SendDlgItemMessage( hOwner, IDC_CMD_LIST, LB_GETTEXT, index, ( LPARAM )( LPCTSTR ) key ); temp = ValueForKey( g_qeglobals.d_project_entity, key ); strcpy( value, temp ); SetDlgItemText( hwndDlg, IDC_CMDMENUTEXT, key ); SetDlgItemText( hwndDlg, IDC_CMDCOMMAND, value ); } return FALSE; break; case WM_COMMAND: switch( LOWORD( wParam ) ) { case IDOK: if( !GetDlgItemText( hwndDlg, IDC_CMDMENUTEXT, key, 64 ) ) { common->Printf( "Command not added\n" ); return FALSE; } if( !GetDlgItemText( hwndDlg, IDC_CMDCOMMAND, value, 64 ) ) { common->Printf( "Command not added\n" ); return FALSE; } SetKeyValue( g_qeglobals.d_project_entity, key, value ); FillBSPMenu(); EndDialog( hwndDlg, 1 ); return TRUE; case IDCANCEL: EndDialog( hwndDlg, 0 ); return TRUE; } } return FALSE; }
/* ======================================================================================================================= QE_LoadProject ======================================================================================================================= */ bool QE_LoadProject(char *projectfile) { char *data; ID_TIME_T time; common->Printf("QE_LoadProject (%s)\n", projectfile); if ( fileSystem->ReadFile( projectfile, reinterpret_cast < void ** > (&data), &time) <= 0 ) { return false; } g_strProject = projectfile; g_PrefsDlg.m_strLastProject = projectfile; g_PrefsDlg.SavePrefs(); CString strData = data; fileSystem->FreeFile( data ); StartTokenParsing(strData.GetBuffer(0)); g_qeglobals.d_project_entity = Entity_Parse(true); if (!g_qeglobals.d_project_entity) { Error("Couldn't parse %s", projectfile); } // set here some default project settings you need if (strlen(ValueForKey(g_qeglobals.d_project_entity, "brush_primit")) == 0) { SetKeyValue(g_qeglobals.d_project_entity, "brush_primit", "0"); } g_qeglobals.m_bBrushPrimitMode = IntForKey(g_qeglobals.d_project_entity, "brush_primit"); Eclass_InitForSourceDirectory(ValueForKey(g_qeglobals.d_project_entity, "entitypath")); g_Inspectors->FillClassList(); // list in entity window Map_New(); // FillTextureMenu(); FillBSPMenu(); return true; }
void QE_Init( void ){ /* ** initialize variables */ g_qeglobals.d_gridsize = 8; g_qeglobals.d_showgrid = true; QE_InitVFS(); Eclass_Init(); FillClassList(); // list in entity window Map_Init(); FillTextureMenu(); FillBSPMenu(); /* ** other stuff */ Z_Init(); }
/* =========== QE_LoadProject FIXME: the BuildShortPathName calls should be removed, it would get much more cleaner I don't have time to modify something so deep in the system, but this lead to a bug when loading .md3 see Win_ent.cpp AssignModel =========== */ qboolean QE_LoadProject (char *projectfile) { char *data; Sys_Printf ("QE_LoadProject (%s)\n", projectfile); if ( LoadFileNoCrash (projectfile, (void **)&data) == -1) return false; g_strProject = projectfile; CString strData = data; free(data); CString strQ2Path = g_PrefsDlg.m_strQuake2; CString strQ2File; ExtractPath_and_Filename(g_PrefsDlg.m_strQuake2, strQ2Path, strQ2File); AddSlash(strQ2Path); char* pBuff = new char[1024]; //BuildShortPathName(strQ2Path, pBuff, 1024); strcpy_s(pBuff, 1024,strQ2Path); // Jonathan: strcpy_s replaces BuildShortPathName FindReplace(strData, "__Q2PATH", pBuff); //BuildShortPathName(g_strAppPath, pBuff, 1024); strcpy_s(pBuff, 1024,g_strAppPath); // Jonathan: strcpy_s replaces BuildShortPathName FindReplace(strData, "__QERPATH", pBuff); char* pFile; if (GetFullPathName(projectfile, 1024, pBuff, &pFile)) { g_PrefsDlg.m_strLastProject = pBuff; //BuildShortPathName(g_PrefsDlg.m_strLastProject, pBuff, 1024); g_PrefsDlg.m_strLastProject = pBuff; g_PrefsDlg.SavePrefs(); ExtractPath_and_Filename(pBuff, strQ2Path, strQ2File); int nLen = strQ2Path.GetLength(); if (nLen > 0) { if (strQ2Path[nLen - 1] == '\\') strQ2Path.SetAt(nLen-1,'\0'); char* pBuffer = strQ2Path.GetBufferSetLength(_MAX_PATH + 1); int n = strQ2Path.ReverseFind('\\'); if (n >=0 ) pBuffer[n + 1] = '\0'; strQ2Path.ReleaseBuffer(); FindReplace(strData, "__QEPROJPATH", strQ2Path); } } StartTokenParsing (strData.GetBuffer(0)); g_qeglobals.d_project_entity = Entity_Parse (true); if (!g_qeglobals.d_project_entity) Error ("Couldn't parse project file: %s", projectfile); // add a version checking to avoid people loading later versions of the project file and bitching against me int ver = IntForKey( g_qeglobals.d_project_entity, "version" ); if (ver != 0) { char strMsg[1024]; sprintf( strMsg, "This is a version %d project file. This build only supports <=0 project files.\n" "Please choose another project file or upgrade your version of Radiant.", ver ); MessageBox( NULL, strMsg, "Can't load project file", MB_ICONERROR | MB_OK ); return false; } for (int i = 0; i < g_nPathFixupCount; i++) { char *pPath = ValueForKey (g_qeglobals.d_project_entity, g_pPathFixups[i]); if (pPath[0] != '\\' && pPath[0] != '/') { if (GetFullPathName(pPath, 1024, pBuff, &pFile)) { SetKeyValue(g_qeglobals.d_project_entity, g_pPathFixups[i], pBuff); } } } delete []pBuff; // set here some default project settings you need if ( strlen( ValueForKey( g_qeglobals.d_project_entity, "brush_primit" ) ) == 0 ) { SetKeyValue( g_qeglobals.d_project_entity, "brush_primit", "0" ); } g_qeglobals.m_bBrushPrimitMode = IntForKey( g_qeglobals.d_project_entity, "brush_primit" ); // usefull for the log file and debuggin f****d up configurations from users: // output the basic information of the .qe4 project file Sys_Printf("basepath : %s\n", ValueForKey( g_qeglobals.d_project_entity, "basepath") ); Sys_Printf("mapspath : %s\n", ValueForKey( g_qeglobals.d_project_entity, "mapspath") ); // the rsh command code is probably broken in these builds .. I would need ppl that actually use it .. // Sys_Printf("rshcmd : %s\n", ValueForKey( g_qeglobals.d_project_entity, "rshcmd" ) ); // Sys_Printf("remotebasepath : %s\n", ValueForKey( g_qeglobals.d_project_entity, "remotebasepath" ) ); Sys_Printf("entitypath : %s\n", ValueForKey( g_qeglobals.d_project_entity, "entitypath" ) ); Sys_Printf("texturepath : %s\n", ValueForKey( g_qeglobals.d_project_entity, "texturepath" ) ); Eclass_InitForSourceDirectory (ValueForKey (g_qeglobals.d_project_entity, "entitypath")); FillClassList(); // list in entity window Map_New(); FillTextureMenu(); FillBSPMenu(); return true; }