From 85bd008c039eb1d93894e94fba9d158a42a71a12 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 11 Aug 2015 13:33:42 +0000 Subject: massive code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@14910 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Xfire/src/addgamedialog.cpp | 489 +++++++++++++++------------------- 1 file changed, 208 insertions(+), 281 deletions(-) (limited to 'protocols/Xfire/src/addgamedialog.cpp') diff --git a/protocols/Xfire/src/addgamedialog.cpp b/protocols/Xfire/src/addgamedialog.cpp index 2783d38c13..ea257308ca 100644 --- a/protocols/Xfire/src/addgamedialog.cpp +++ b/protocols/Xfire/src/addgamedialog.cpp @@ -15,7 +15,8 @@ Xfire_game* editgame = NULL; HWND hwndTab, hPage; -void AddGameDialog(HWND hwndDlg, Xfire_game* game) { +void AddGameDialog(HWND hwndDlg, Xfire_game* game) +{ //übergebendes game, dem editgame zuordnen, damit wechselt es in den editmodus editgame = game; if (DialogBox(hinstance, MAKEINTRESOURCE(IDD_ADDGAMEMAIN), hwndDlg, DlgAddGameProcMain)) { @@ -24,7 +25,8 @@ void AddGameDialog(HWND hwndDlg, Xfire_game* game) { editgame = NULL; } -static void FillGameList(LPVOID hwndDlg) { +static void FillGameList(LPVOID hwndDlg) +{ //liste.,suche und suchlabel unsichtbar machen ShowWindow(GetDlgItem((HWND)hwndDlg, IDC_GAMELIST), SW_HIDE); ShowWindow(GetDlgItem((HWND)hwndDlg, IDC_SEARCH), SW_HIDE); @@ -36,8 +38,7 @@ static void FillGameList(LPVOID hwndDlg) { //das schließen des dialogs verhindern dontClose = TRUE; - if (Inicache.size() == 0) - { + if (Inicache.size() == 0) { //temp xfirebaseob für strlower Xfire_base tempxfire; //vector für doppelfilter @@ -87,15 +88,12 @@ static void FillGameList(LPVOID hwndDlg) { //solange bis wir bei 0 angekommen sind if (*p != 0) p++; - while (*p != 0) - { - if (*p == '['&&*(p - 1) == '\n') - { + while (*p != 0) { + if (*p == '['&&*(p - 1) == '\n') { z = zahlbuffer; z2 = zahlbuffer2; p++; - while (*p >= '0'&&*p <= '9'&&p != 0) - { + while (*p >= '0'&&*p <= '9'&&p != 0) { *z = *p; p++; z++; @@ -103,8 +101,7 @@ static void FillGameList(LPVOID hwndDlg) { *z = 0; if (*p == '_') { p++; - while (*p >= '0'&&*p <= '9'&&p != 0) - { + while (*p >= '0'&&*p <= '9'&&p != 0) { *z2 = *p; p++; z2++; @@ -113,12 +110,10 @@ static void FillGameList(LPVOID hwndDlg) { } //erste zahl gefunden - if (z != zahlbuffer) - { + if (z != zahlbuffer) { int gameid = atoi(zahlbuffer); //prüfe ob das game schon in der gameliste ist - if (!xgamelist.Gameinlist(gameid)) - { + if (!xgamelist.Gameinlist(gameid)) { char*name = p; lbInicache listentry; char gameidtemp[10] = ""; @@ -141,13 +136,11 @@ static void FillGameList(LPVOID hwndDlg) { //spielnamen in den listentry einfügen strcpy_s(listentry.name, 255, name); - if (z2 != zahlbuffer2) - { + if (z2 != zahlbuffer2) { listentry.gameid = MAKELONG(gameid, atoi(zahlbuffer2)); mir_snprintf(gameidtemp, _countof(gameidtemp), "%d_%d", gameid, atoi(zahlbuffer2)); } - else - { + else { listentry.gameid = gameid; mir_snprintf(gameidtemp, _countof(gameidtemp), "%d", gameid); } @@ -157,8 +150,7 @@ static void FillGameList(LPVOID hwndDlg) { //lower launchstring tempxfire.strtolower(ret); //einzelnen ziechen zusammenrechnen - if (z2 != zahlbuffer2) - { + if (z2 != zahlbuffer2) { //wenn pfad, dann exe vorher rausziehen if (strrchr(ret, '\\')) accLaunch = tempxfire.accStringByte(strrchr(ret, '\\')); @@ -174,8 +166,7 @@ static void FillGameList(LPVOID hwndDlg) { ret[5] == '.'&& ret[6] == 'e'&& ret[7] == 'x'&& - ret[8] == 'e') - { + ret[8] == 'e') { strcat_s(listentry.name, 255, " (Steam)"); } } @@ -201,8 +192,7 @@ static void FillGameList(LPVOID hwndDlg) { //uniq id zusammen bauen aus spielid sowie zusammengerechneten launchstring und detectstring uniqid = MAKELONG(gameid, MAKEWORD(accLaunch, accDetect)); for (uint i = 0; i < dublBuffer.size(); i++) { - if (dublBuffer.at(i) == uniqid) - { + if (dublBuffer.at(i) == uniqid) { addtolist = FALSE; break; } @@ -227,13 +217,11 @@ static void FillGameList(LPVOID hwndDlg) { p++; } } - else - { + else { //liste mit dem cache aufbauen for (uint i = 0; i < Inicache.size(); i++) { //spielid in der liste spielliste? - if (!xgamelist.Gameinlist(LOWORD(Inicache.at(i).gameid))) - { + if (!xgamelist.Gameinlist(LOWORD(Inicache.at(i).gameid))) { //eintrag in die listeeinfügen int idx = SendDlgItemMessageA((HWND)hwndDlg, IDC_GAMELIST, LB_ADDSTRING, 0, (LPARAM)Inicache.at(i).name); //gameid zuweisen @@ -253,7 +241,8 @@ static void FillGameList(LPVOID hwndDlg) { dontClose = FALSE; } -BOOL OpenFileDialog(HWND hwndDlg, OPENFILENAMEA*ofn, char*exe) { +BOOL OpenFileDialog(HWND hwndDlg, OPENFILENAMEA*ofn, char*exe) +{ //pointer zum exenamen char* exename = NULL; //buffer vom pfad @@ -286,40 +275,33 @@ BOOL OpenFileDialog(HWND hwndDlg, OPENFILENAMEA*ofn, char*exe) { return GetOpenFileNameA(ofn); } -INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam - ) +INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) { switch (uMsg) { case WM_INITDIALOG: - { - //übersetzen lassen - TranslateDialogDefault(hwndDlg); + { + //übersetzen lassen + TranslateDialogDefault(hwndDlg); - //per thread liste füllen - mir_forkthread(FillGameList, hwndDlg); - } + //per thread liste füllen + mir_forkthread(FillGameList, hwndDlg); + } break; case WM_COMMAND: - if (LOWORD(wParam) == IDC_SEARCH && HIWORD(wParam) == EN_CHANGE) - { + if (LOWORD(wParam) == IDC_SEARCH && HIWORD(wParam) == EN_CHANGE) { char temp[256]; //eingabe bei der suche auslesen GetDlgItemTextA(hwndDlg, IDC_SEARCH, temp, _countof(temp)); //eingabe in der liste suchen int idx = SendDlgItemMessageA(hwndDlg, IDC_GAMELIST, LB_FINDSTRING, 0, (LPARAM)temp); //gefunden? - if (idx != LB_ERR) - { + if (idx != LB_ERR) { //als aktiv setzen SendDlgItemMessage(hwndDlg, IDC_GAMELIST, LB_SETCURSEL, idx, 0); } } - else if (LOWORD(wParam) == IDCANCEL) - { + else if (LOWORD(wParam) == IDCANCEL) { //nicht schließen, wenn noch der thread läuft if (dontClose) { MessageBox(hwndDlg, TranslateT("Please wait, game.ini will be currently parsed..."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); @@ -327,15 +309,13 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, } return SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0); } - else if (LOWORD(wParam) == IDC_CUSTOM) - { + else if (LOWORD(wParam) == IDC_CUSTOM) { int idx = SendDlgItemMessage(hwndDlg, IDC_GAMELIST, LB_GETCURSEL, 0, 0); //es wurde was ausgewählt? if (idx == LB_ERR) { MessageBox(hwndDlg, TranslateT("Please choose one game in the list!"), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); } - else - { + else { char ret[512] = ""; char gameidtemp[10] = ""; @@ -369,15 +349,13 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, } } } - else if (LOWORD(wParam) == IDOK) - { + else if (LOWORD(wParam) == IDOK) { int idx = SendDlgItemMessage(hwndDlg, IDC_GAMELIST, LB_GETCURSEL, 0, 0); //es wurde was ausgewählt? if (idx == LB_ERR) { MessageBox(hwndDlg, TranslateT("Please choose one game in the list!"), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); } - else - { + else { //datei öffnen dialog OPENFILENAMEA ofn; //listdata auslesen, wo die gameid gespeihcert ist @@ -404,15 +382,13 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, //launcherexe abfragen if (xfire_GetPrivateProfileString(gameidtemp, "LauncherExe", "", ret, 512, inipath)) { //datei vom user öffnen lassen - if (OpenFileDialog(hwndDlg, &ofn, ret)) - { + if (OpenFileDialog(hwndDlg, &ofn, ret)) { //lowercase pfad newgame->strtolower(ofn.lpstrFile); //pfad dem spiel zuordnen newgame->setString(ofn.lpstrFile, &newgame->launchparams); } - else - { + else { //speicher freigeben delete newgame; return FALSE; @@ -422,15 +398,13 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, //detectexe abfragen if (xfire_GetPrivateProfileString(gameidtemp, "DetectExe", "", ret, 512, inipath)) { //datei vom user öffnen lassen - if (OpenFileDialog(hwndDlg, &ofn, ret)) - { + if (OpenFileDialog(hwndDlg, &ofn, ret)) { //lowercase pfad newgame->strtolower(ofn.lpstrFile); //pfad dem spiel zuordnen newgame->setString(ofn.lpstrFile, &newgame->path); } - else - { + else { //speicher freigeben delete newgame; return FALSE; @@ -438,15 +412,13 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, } //MatchExe abfragen else if (xfire_GetPrivateProfileString(gameidtemp, "MatchExe", "", ret, 512, inipath)) { //datei vom user öffnen lassen - if (OpenFileDialog(hwndDlg, &ofn, ret)) - { + if (OpenFileDialog(hwndDlg, &ofn, ret)) { //lowercase pfad newgame->strtolower(ofn.lpstrFile); //pfad dem spiel zuordnen newgame->setString(ofn.lpstrFile, &newgame->path); } - else - { + else { //speicher freigeben delete newgame; return FALSE; @@ -520,10 +492,9 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, } -INT_PTR CALLBACK DlgAddGameProc2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK DlgAddGameProc2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) { - switch (uMsg) - { + switch (uMsg) { case WM_INITDIALOG: //ein spiel wurde zum editieren geöffnet, felder alle vorbelegen if (editgame) { @@ -543,8 +514,7 @@ INT_PTR CALLBACK DlgAddGameProc2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM EnableWindow(GetDlgItem(hwndDlg, IDC_ADD_ID), FALSE); //sendgameid setzen, bei -1 leer lassen - if (editgame->send_gameid != -1) - { + if (editgame->send_gameid != -1) { _itoa_s(editgame->send_gameid, gameid, 10, 10); SetDlgItemTextA(hwndDlg, IDC_ADD_SENDID, gameid); } @@ -575,290 +545,247 @@ INT_PTR CALLBACK DlgAddGameProc2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM return TRUE; case WM_COMMAND: - { - if (LOWORD(wParam) == IDC_SENDIDHELP) - { - MessageBox(hwndDlg, TranslateT("If you add a mod of an Xfire supported game, then you can specify what game ID will be sent to Xfire. So if you add a Half-Life mod, you can set the Half-Life game ID and if you start the game, your Xfire buddies will see the Half-Life game icon next to your name and the game time will be tracked."), TranslateT("XFire Options"), MB_OK | MB_ICONASTERISK); - } - else if (LOWORD(wParam) == IDC_GAMEIDHELP) { - MessageBox(hwndDlg, TranslateT("Every game in Xfire needs an ID. Use a number above the last used ID to avoid problems with used IDs. Every number above 10000 should be save. This ID will not be sent to Xfire, when you start a game."), TranslateT("XFire Options"), MB_OK | MB_ICONASTERISK); - } - else if (LOWORD(wParam) == IDC_ADD_BROWSEDETECT) - { - OPENFILENAMEA ofn; - if (OpenFileDialog(hwndDlg, &ofn, "*.exe")) - { - SetDlgItemTextA(hwndDlg, IDC_ADD_DETECTEXE, ofn.lpstrFile); + if (LOWORD(wParam) == IDC_SENDIDHELP) { + MessageBox(hwndDlg, TranslateT("If you add a mod of an Xfire supported game, then you can specify what game ID will be sent to Xfire. So if you add a Half-Life mod, you can set the Half-Life game ID and if you start the game, your Xfire buddies will see the Half-Life game icon next to your name and the game time will be tracked."), TranslateT("XFire Options"), MB_OK | MB_ICONASTERISK); } - } - else if (LOWORD(wParam) == IDC_ADD_BROWSELAUNCHER) - { - OPENFILENAMEA ofn; - if (OpenFileDialog(hwndDlg, &ofn, "*.exe")) - { - SetDlgItemTextA(hwndDlg, IDC_ADD_LAUNCHEREXE, ofn.lpstrFile); + else if (LOWORD(wParam) == IDC_GAMEIDHELP) { + MessageBox(hwndDlg, TranslateT("Every game in Xfire needs an ID. Use a number above the last used ID to avoid problems with used IDs. Every number above 10000 should be save. This ID will not be sent to Xfire, when you start a game."), TranslateT("XFire Options"), MB_OK | MB_ICONASTERISK); } - } - else if (LOWORD(wParam) == IDCANCEL) - { - //nicht schließen, wenn noch der thread läuft - if (dontClose) { - MessageBox(hwndDlg, TranslateT("Please wait, game.ini will be currently parsed..."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); - return FALSE; + else if (LOWORD(wParam) == IDC_ADD_BROWSEDETECT) { + OPENFILENAMEA ofn; + if (OpenFileDialog(hwndDlg, &ofn, "*.exe")) { + SetDlgItemTextA(hwndDlg, IDC_ADD_DETECTEXE, ofn.lpstrFile); + } } - return SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0); - } - else if (LOWORD(wParam) == IDOK) - { - char temp[256]; - - //fillgames sucht noch - if (dontClose) { - MessageBox(hwndDlg, TranslateT("Please wait, game.ini will be currently parsed..."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); - return FALSE; + else if (LOWORD(wParam) == IDC_ADD_BROWSELAUNCHER) { + OPENFILENAMEA ofn; + if (OpenFileDialog(hwndDlg, &ofn, "*.exe")) { + SetDlgItemTextA(hwndDlg, IDC_ADD_LAUNCHEREXE, ofn.lpstrFile); + } } + else if (LOWORD(wParam) == IDCANCEL) { + //nicht schließen, wenn noch der thread läuft + if (dontClose) { + MessageBox(hwndDlg, TranslateT("Please wait, game.ini will be currently parsed..."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); + return FALSE; + } + return SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0); + } + else if (LOWORD(wParam) == IDOK) { + char temp[256]; - //neuen gameeintrag anlegen - Xfire_game* newgame = NULL; + //fillgames sucht noch + if (dontClose) { + MessageBox(hwndDlg, TranslateT("Please wait, game.ini will be currently parsed..."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); + return FALSE; + } - if (editgame) - newgame = editgame; - else - newgame = new Xfire_game(); - - //Spielname - GetDlgItemTextA(hwndDlg, IDC_ADD_NAME, temp, _countof(temp)); - if (!mir_strlen(temp)) - { - if (!editgame) delete newgame; - return MessageBox(hwndDlg, TranslateT("Please enter a game name."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); - } - else - { - //spielname zuordnen - newgame->setString(temp, &newgame->customgamename); - //spielnamen fürs menü - newgame->setString(temp, &newgame->name); - } - //spielid nur setzen/prüfen, wenn kein editgame - if (!editgame) { - GetDlgItemTextA(hwndDlg, IDC_ADD_ID, temp, _countof(temp)); - if (!mir_strlen(temp)) - { + //neuen gameeintrag anlegen + Xfire_game* newgame = NULL; + + if (editgame) + newgame = editgame; + else + newgame = new Xfire_game(); + + //Spielname + GetDlgItemTextA(hwndDlg, IDC_ADD_NAME, temp, _countof(temp)); + if (!mir_strlen(temp)) { if (!editgame) delete newgame; - return MessageBox(hwndDlg, TranslateT("Please enter a game ID."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); + return MessageBox(hwndDlg, TranslateT("Please enter a game name."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); } - else - { - int gameid = atoi(temp); - //negative gameid blocken - if (gameid < 1) - { + else { + //spielname zuordnen + newgame->setString(temp, &newgame->customgamename); + //spielnamen fürs menü + newgame->setString(temp, &newgame->name); + } + //spielid nur setzen/prüfen, wenn kein editgame + if (!editgame) { + GetDlgItemTextA(hwndDlg, IDC_ADD_ID, temp, _countof(temp)); + if (!mir_strlen(temp)) { if (!editgame) delete newgame; - return MessageBox(hwndDlg, TranslateT("Please enter a game ID above 1."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); + return MessageBox(hwndDlg, TranslateT("Please enter a game ID."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); } - //gameid auf uniq prüfen - else if (xgamelist.getGamebyGameid(gameid)) - { - if (!editgame) delete newgame; - return MessageBox(hwndDlg, TranslateT("This game ID is already in use."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); + else { + int gameid = atoi(temp); + //negative gameid blocken + if (gameid < 1) { + if (!editgame) delete newgame; + return MessageBox(hwndDlg, TranslateT("Please enter a game ID above 1."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); + } + //gameid auf uniq prüfen + else if (xgamelist.getGamebyGameid(gameid)) { + if (!editgame) delete newgame; + return MessageBox(hwndDlg, TranslateT("This game ID is already in use."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); + } + //gameid zuordnen + newgame->id = gameid; + //standardmäßig wird bei einem customeintrag keine id versendet + newgame->send_gameid = -1; } - //gameid zuordnen - newgame->id = gameid; + } + //zu sendene spielid + GetDlgItemTextA(hwndDlg, IDC_ADD_SENDID, temp, _countof(temp)); + if (mir_strlen(temp)) { //standardmäßig wird bei einem customeintrag keine id versendet - newgame->send_gameid = -1; + int sendid = atoi(temp); + if (sendid > 0) + newgame->send_gameid = sendid; } - } - //zu sendene spielid - GetDlgItemTextA(hwndDlg, IDC_ADD_SENDID, temp, _countof(temp)); - if (mir_strlen(temp)) - { - //standardmäßig wird bei einem customeintrag keine id versendet - int sendid = atoi(temp); - if (sendid > 0) - newgame->send_gameid = sendid; - } - //launcher exe - GetDlgItemTextA(hwndDlg, IDC_ADD_LAUNCHEREXE, temp, _countof(temp)); - if (mir_strlen(temp)) - { - //lowercase pfad - newgame->strtolower(temp); - //detect exe - newgame->setString(temp, &newgame->launchparams); - } - //detectexe - GetDlgItemTextA(hwndDlg, IDC_ADD_DETECTEXE, temp, _countof(temp)); - if (!mir_strlen(temp)) - { - if (!editgame) delete newgame; - return MessageBox(hwndDlg, TranslateT("Please select a game exe. Note: If you don't select a launcher exe, the game exe will be used in the game start menu."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); - } - else - { - //lowercase pfad - newgame->strtolower(temp); - //detect exe - newgame->setString(temp, &newgame->path); - //wenn kein launcher exe/pfad angeben wurde, dann den gamepath nehmen - if (!newgame->launchparams) + //launcher exe + GetDlgItemTextA(hwndDlg, IDC_ADD_LAUNCHEREXE, temp, _countof(temp)); + if (mir_strlen(temp)) { + //lowercase pfad + newgame->strtolower(temp); + //detect exe newgame->setString(temp, &newgame->launchparams); + } + //detectexe + GetDlgItemTextA(hwndDlg, IDC_ADD_DETECTEXE, temp, _countof(temp)); + if (!mir_strlen(temp)) { + if (!editgame) delete newgame; + return MessageBox(hwndDlg, TranslateT("Please select a game exe. Note: If you don't select a launcher exe, the game exe will be used in the game start menu."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); + } + else { + //lowercase pfad + newgame->strtolower(temp); + //detect exe + newgame->setString(temp, &newgame->path); + //wenn kein launcher exe/pfad angeben wurde, dann den gamepath nehmen + if (!newgame->launchparams) + newgame->setString(temp, &newgame->launchparams); - } - //mustcontain parameter - GetDlgItemTextA(hwndDlg, IDC_ADD_CUSTOMPARAMS, temp, _countof(temp)); - if (mir_strlen(temp)) - { - newgame->setString(temp, &newgame->mustcontain); - } - //statusmsg speichern - GetDlgItemTextA(hwndDlg, IDC_ADD_STATUSMSG, temp, _countof(temp)); - if (mir_strlen(temp)) - { - newgame->setString(temp, &newgame->statusmsg); - newgame->setstatusmsg = 1; - } - //custom eintrag aktivieren - newgame->custom = 1; - //spiel in die gameliste einfügen, aber nur im nicht editmodus - if (!editgame) - xgamelist.Addgame(newgame); - //derzeitige gameliste in die datenbank eintragen - xgamelist.writeDatabase(); - //startmenu leeren - xgamelist.clearStartmenu(); - //startmenu neuerzeugen - xgamelist.createStartmenu(); + } + //mustcontain parameter + GetDlgItemTextA(hwndDlg, IDC_ADD_CUSTOMPARAMS, temp, _countof(temp)); + if (mir_strlen(temp)) { + newgame->setString(temp, &newgame->mustcontain); + } + //statusmsg speichern + GetDlgItemTextA(hwndDlg, IDC_ADD_STATUSMSG, temp, _countof(temp)); + if (mir_strlen(temp)) { + newgame->setString(temp, &newgame->statusmsg); + newgame->setstatusmsg = 1; + } + //custom eintrag aktivieren + newgame->custom = 1; + //spiel in die gameliste einfügen, aber nur im nicht editmodus + if (!editgame) + xgamelist.Addgame(newgame); + //derzeitige gameliste in die datenbank eintragen + xgamelist.writeDatabase(); + //startmenu leeren + xgamelist.clearStartmenu(); + //startmenu neuerzeugen + xgamelist.createStartmenu(); - return SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0); + return SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0); + } + break; } - break; - } } return FALSE; } - -INT_PTR CALLBACK DlgAddGameProcMain(HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam - ) +INT_PTR CALLBACK DlgAddGameProcMain(HWND hwndDlg, UINT uMsg, WPARAM, LPARAM lParam) { - switch (uMsg) - { + TCITEM tci; + + switch (uMsg) { case WM_INITDIALOG: - { - TCITEMA tci = { 0 }; - int iTotal; - RECT rcClient; + { + TCITEMA tci = { 0 }; + int iTotal; + RECT rcClient; - //icon des dialogs setzen - SendMessage(hwndDlg, WM_SETICON, (WPARAM)false, (LPARAM)LoadIcon(hinstance, MAKEINTRESOURCE(IDI_TM))); + //icon des dialogs setzen + SendMessage(hwndDlg, WM_SETICON, (WPARAM)false, (LPARAM)LoadIcon(hinstance, MAKEINTRESOURCE(IDI_TM))); - hwndTab = GetDlgItem(hwndDlg, IDC_OPTIONSTAB); - TabCtrl_DeleteAllItems(hwndTab); - GetClientRect(GetParent(hwndTab), &rcClient); + hwndTab = GetDlgItem(hwndDlg, IDC_OPTIONSTAB); + TabCtrl_DeleteAllItems(hwndTab); + GetClientRect(GetParent(hwndTab), &rcClient); - hPage = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDGAME), hwndDlg, DlgAddGameProc); + hPage = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDGAME), hwndDlg, DlgAddGameProc); - //bei editgame keine spiellisteauswahl - if (!editgame) - { + //bei editgame keine spiellisteauswahl + if (!editgame) { + iTotal = TabCtrl_GetItemCount(hwndTab); + tci.mask = TCIF_PARAM | TCIF_TEXT; + tci.lParam = (LPARAM)hPage; + tci.pszText = Translate("Supported Games"); + SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci); + MoveWindow(hPage, 3, 24, rcClient.right - 10, rcClient.bottom - 28, 1); + iTotal++; + } + else + ShowWindow(hPage, FALSE); + + hPage = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDGAME2), hwndDlg, DlgAddGameProc2); iTotal = TabCtrl_GetItemCount(hwndTab); tci.mask = TCIF_PARAM | TCIF_TEXT; tci.lParam = (LPARAM)hPage; - tci.pszText = Translate("Supported Games"); + tci.pszText = Translate("Custom game"); SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci); MoveWindow(hPage, 3, 24, rcClient.right - 10, rcClient.bottom - 28, 1); iTotal++; - } - else - ShowWindow(hPage, FALSE); - - hPage = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDGAME2), hwndDlg, DlgAddGameProc2); - iTotal = TabCtrl_GetItemCount(hwndTab); - tci.mask = TCIF_PARAM | TCIF_TEXT; - tci.lParam = (LPARAM)hPage; - tci.pszText = Translate("Custom game"); - SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci); - MoveWindow(hPage, 3, 24, rcClient.right - 10, rcClient.bottom - 28, 1); - iTotal++; - - //bei editgame 2. registerkarte aktiv schalten - if (!editgame) { - ShowWindow(hPage, FALSE); - TabCtrl_SetCurSel(hwndTab, 0); - } + //bei editgame 2. registerkarte aktiv schalten + if (!editgame) { + ShowWindow(hPage, FALSE); + TabCtrl_SetCurSel(hwndTab, 0); + } + } return TRUE; - } + case WM_CLOSE: //nicht schließen, wenn noch der thread läuft if (dontClose) return FALSE; //buffer leeren - if (buffer) - { + if (buffer) { delete[] buffer; buffer = NULL; } EndDialog(hwndDlg, 0); break; + case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) - { + switch (((LPNMHDR)lParam)->idFrom) { case 0: - switch (((LPNMHDR)lParam)->code) - { + switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: - { - TCITEM tci; int i, count; - tci.mask = TCIF_PARAM; count = TabCtrl_GetItemCount(GetDlgItem(hwndDlg, IDC_OPTIONSTAB)); - for (i = 0; i < count; i++) - { + for (i = 0; i < count; i++) { TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_OPTIONSTAB), i, &tci); SendMessage((HWND)tci.lParam, WM_NOTIFY, 0, lParam); } break; } - } break; case IDC_OPTIONSTAB: - { HWND hTabCtrl = GetDlgItem(hwndDlg, IDC_OPTIONSTAB); - switch (((LPNMHDR)lParam)->code) - { + switch (((LPNMHDR)lParam)->code) { case TCN_SELCHANGING: - { - TCITEM tci; - tci.mask = TCIF_PARAM; TabCtrl_GetItem(hTabCtrl, TabCtrl_GetCurSel(hTabCtrl), &tci); ShowWindow((HWND)tci.lParam, SW_HIDE); - } break; case TCN_SELCHANGE: - { - TCITEM tci; - tci.mask = TCIF_PARAM; TabCtrl_GetItem(hTabCtrl, TabCtrl_GetCurSel(hTabCtrl), &tci); ShowWindow((HWND)tci.lParam, SW_SHOW); - } break; } break; } - } break; } return FALSE; -} \ No newline at end of file +} -- cgit v1.2.3