1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
...
INT_PTR CALLBACK STLProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
switch (message)
{
case WM_INITDIALOG:
for(int iii = 0;iii < nCfgsNum;iii++)
{
SendMessageA(GetDlgItem(hDlg,IDCONFIGLIST),LB_ADDSTRING,0,(LPARAM)wsCfgs[iii].c_str());
}
return (INT_PTR)TRUE;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hDlg, About);
return (INT_PTR)TRUE;
case IDM_EXIT:
EndDialog(hDlg, IDM_EXIT);
return (INT_PTR)TRUE;
case IDPLAYGAME:
Data.LaunchGame();
return (INT_PTR)TRUE;
case IDLAUNCHHAMMER:
Data.LaunchHammer();
return (INT_PTR)TRUE;
case IDLAUNCHMODELVIEWER:
Data.LaunchModelViewer();
return (INT_PTR)TRUE;
case IDLAUNCHFACEPOSER:
Data.LaunchFacePoser();
return (INT_PTR)TRUE;
case IDLAUNCHSTUDIOCOMPILER:
Data.LaunchStudioCompiler();
return (INT_PTR)TRUE;
case IDCONFIGLIST:
switch(wmEvent)
{
case LBN_SELCHANGE:
{
EnableWindow(GetDlgItem(hDlg,IDPLAYGAME),TRUE);
EnableWindow(GetDlgItem(hDlg,IDLAUNCHHAMMER),TRUE);
EnableWindow(GetDlgItem(hDlg,IDLAUNCHMODELVIEWER),TRUE);
EnableWindow(GetDlgItem(hDlg,IDLAUNCHFACEPOSER),TRUE);
EnableWindow(GetDlgItem(hDlg,IDLAUNCHSTUDIOCOMPILER),TRUE);
EnableWindow(GetDlgItem(hDlg,IDOTHERPROGRAMS),TRUE);
EnableWindow(GetDlgItem(hDlg,IDEDITCONFIG),TRUE);
Data.LoadCfg(SendMessageA(GetDlgItem(hDlg,IDCONFIGLIST),LB_GETCURSEL,0,0));
return (INT_PTR)TRUE;
}
case LBN_SELCANCEL:
{
EnableWindow(GetDlgItem(hDlg,IDPLAYGAME),FALSE);
EnableWindow(GetDlgItem(hDlg,IDLAUNCHHAMMER),FALSE);
EnableWindow(GetDlgItem(hDlg,IDLAUNCHMODELVIEWER),FALSE);
EnableWindow(GetDlgItem(hDlg,IDLAUNCHFACEPOSER),FALSE);
EnableWindow(GetDlgItem(hDlg,IDLAUNCHSTUDIOCOMPILER),FALSE);
EnableWindow(GetDlgItem(hDlg,IDOTHERPROGRAMS),FALSE);
EnableWindow(GetDlgItem(hDlg,IDEDITCONFIG),FALSE);
return (INT_PTR)TRUE;
}
return (INT_PTR)TRUE;
}
return (INT_PTR)TRUE;
case IDNEWCONFIG:
if(DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_NCONFIG1),hDlg,CfgProc1) != IDCONTINUE)
return (INT_PTR)TRUE;
if(DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_NCONFIG2),hDlg,CfgProc2) != IDCONTINUE)
return (INT_PTR)TRUE;
if(DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_NCONFIG3),hDlg,CfgProc3) != IDCONTINUE)
return (INT_PTR)TRUE;
int MesHold = DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_NCONFIGA1),hDlg,CfgProcA1);
if(MesHold == IDADVANCED)
{
if(DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_NCONFIGA2),hDlg,CfgProcA2) != IDFINISH)
return (INT_PTR)TRUE;
}
else if(MesHold == IDFINISH)
{
LoadDefaultAData(hDlg);
}
else
return (INT_PTR)TRUE;
BuildCfgFile(); //Here is where the problem occurs, in these three functions
AddCfgsManifest(GetCfgName());
GetCfgs();
for(int iii = 0;iii < nCfgsNum;iii++)
{
SendMessageA(GetDlgItem(hDlg,IDCONFIGLIST),LB_ADDSTRING,0,(LPARAM)wsCfgs[iii].c_str());
}
return (INT_PTR)TRUE;
}
return (INT_PTR)TRUE;
case WM_CLOSE:
EndDialog(hDlg, WM_CLOSE);
return (INT_PTR)TRUE;
case WM_DESTROY:
PostQuitMessage(0);
return (INT_PTR)TRUE;
break;
}
return (INT_PTR)FALSE;
}
void GetCfgs() Here are some of the functions;
{
File.flush();
File.open("Cfg\\CfgManifest.dat",ios_base::_Nocreate | ios_base::in);
if(!File)
{
MessageBoxA(NULL,"CfgManifest.dat file could not be found. Creating Default.","File Missing!",MB_OK);
File.clear();
File.open("CfgManifest.dat",ios_base::out);
File << '0';
File.close();
File.clear();
File.open("CfgManifest.dat",ios_base::_Nocreate | ios_base::in);
}
string wsHold;
getline(File,wsHold);
nCfgsNum = stoi(wsHold);
if(nCfgsNum > 0)
{
delete[] wsCfgs;
wsCfgs = new string[nCfgsNum];
for(int iii = 0;iii < nCfgsNum;iii++)
{
getline(File,wsCfgs[iii]);
}
}
File.close();
return;
}
void BuildCfgsManifest()
{
File.clear();
File.open("Cfg\\CfgManifest.dat",ios::trunc | ios::out);
File << nCfgsNum << endl;
for(int iii = 0;iii < nCfgsNum;iii++)
{
File << wsCfgs[iii] << endl;
}
File.close();
return;
}
void AddCfgsManifest(string Name)
{
File.sync();
File.open("Cfg\\CfgManifest.dat",ios::trunc | ios::out);
if(!File)
{
MessageBoxA(NULL,"AddCfgManifest()",NULL,MB_OK);
File.close();
return;
}
File << ++nCfgsNum << endl;
for(int iii = 0;iii < nCfgsNum;iii++)
{
File << wsCfgs[iii] << endl;
}
File << Name << endl;
File.close();
return;
}
void DeleteCfg(int Index)
{
File.clear();
File.open("Cfg\\CfgManifest.dat",ios::trunc | ios::out);
File << --nCfgsNum << endl;
for(int iii = 0;iii < nCfgsNum+1;iii++)
{
if(iii == Index)
continue;
File << wsCfgs[iii] << endl;
}
remove(("Cfg\\" + wsCfgs[Index]).c_str());
File.close();
return;
}
|