mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
0.4 = added delete button
This commit is contained in:
parent
e097932ac9
commit
3f2a8ccfc5
@ -70,6 +70,9 @@ public:
|
|||||||
inline int updatePosition( Stats* points ) {
|
inline int updatePosition( Stats* points ) {
|
||||||
return parent->updatePos( this , points );
|
return parent->updatePos( this , points );
|
||||||
}
|
}
|
||||||
|
inline void MarkToDelete() {
|
||||||
|
this->score = (1<<31);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
#define IDC_BUTTON_ABOUT 1029
|
#define IDC_BUTTON_ABOUT 1029
|
||||||
#define IDC_ABOUT 1029
|
#define IDC_ABOUT 1029
|
||||||
#define IDC_BUTTON_SAVECHANGES 1030
|
#define IDC_BUTTON_SAVECHANGES 1030
|
||||||
#define IDC_BUTTON1 1031
|
|
||||||
#define IDC_BUTTON_CLEARSTATS 1031
|
#define IDC_BUTTON_CLEARSTATS 1031
|
||||||
|
#define IDC_BUTTON_DELETE 1032
|
||||||
#define IDC_EDIT_NAME 1100
|
#define IDC_EDIT_NAME 1100
|
||||||
#define IDC_EDIT_POSITION 1101
|
#define IDC_EDIT_POSITION 1101
|
||||||
#define IDC_EDIT_AUTHID 1102
|
#define IDC_EDIT_AUTHID 1102
|
||||||
@ -44,9 +44,9 @@
|
|||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
#define _APS_NO_MFC 1
|
#define _APS_NO_MFC 1
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 130
|
#define _APS_NEXT_RESOURCE_VALUE 131
|
||||||
#define _APS_NEXT_COMMAND_VALUE 32775
|
#define _APS_NEXT_COMMAND_VALUE 32775
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1032
|
#define _APS_NEXT_CONTROL_VALUE 1033
|
||||||
#define _APS_NEXT_SYMED_VALUE 110
|
#define _APS_NEXT_SYMED_VALUE 110
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -219,7 +219,9 @@ void ListboxItemSelected(HWND hDlg) {
|
|||||||
// Retrieve complete stats record of this position. Position in listbox should be same as rank in our records!
|
// Retrieve complete stats record of this position. Position in listbox should be same as rank in our records!
|
||||||
RankSystem::RankStats* stats = g_rank.findEntryInRankByPos((int)nItem + 1);
|
RankSystem::RankStats* stats = g_rank.findEntryInRankByPos((int)nItem + 1);
|
||||||
if (stats == NULL) {
|
if (stats == NULL) {
|
||||||
MessageBox(hDlg, "Error: Couldn't find the record by position!", "Oh fiddlesticks!", MB_OK);
|
char msg[] = "Error: Couldn't find the record by position! (nItem = %d)";
|
||||||
|
sprintf(msg, msg, nItem);
|
||||||
|
MessageBox(hDlg, msg, "Oh fiddlesticks!", MB_OK);
|
||||||
ClearStatsfields(hDlg);
|
ClearStatsfields(hDlg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -345,6 +347,50 @@ void ClearStats(HWND hDlg) {
|
|||||||
ListboxItemSelected(hDlg);
|
ListboxItemSelected(hDlg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeleteRecord(HWND hDlg) {
|
||||||
|
if (MessageBox(hDlg, "Are you sure?", "Omg!", MB_OKCANCEL | MB_DEFBUTTON2 | MB_ICONWARNING) != IDOK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
BOOL success;
|
||||||
|
int position = GetDlgItemInt(hDlg, IDC_EDIT_POSITION, &success, false);
|
||||||
|
if (!success)
|
||||||
|
goto BadEnd;
|
||||||
|
|
||||||
|
char authid[32]; // "primary key"
|
||||||
|
GetDlgItemText(hDlg, IDC_EDIT_AUTHID, authid, sizeof(authid));
|
||||||
|
RankSystem::RankStats* entry = g_rank.findEntryInRankByUnique(authid);
|
||||||
|
if (!entry) {
|
||||||
|
char buffer[256];
|
||||||
|
sprintf(buffer, "Authid %s not found!", authid);
|
||||||
|
MessageBox(hDlg, buffer, "Update failed", MB_OK);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark this record to delete it.
|
||||||
|
entry->MarkToDelete();
|
||||||
|
|
||||||
|
// Save ranks from memory to disk.
|
||||||
|
g_rank.saveRank(STATS_FILENAME); // Save changes to file
|
||||||
|
|
||||||
|
// Clear memory.
|
||||||
|
g_rank.clear();
|
||||||
|
|
||||||
|
// Reload from disk into memory.
|
||||||
|
LoadRankFromFile(hDlg);
|
||||||
|
|
||||||
|
// Update list box.
|
||||||
|
UpdateListBox(hDlg);
|
||||||
|
|
||||||
|
MessageBox(hDlg, "Deleted record", "Delete succeeded", MB_OK);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
BadEnd:
|
||||||
|
MessageBox(hDlg, "Delete failed", "Oh fiddlesticks!", MB_OK);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Message handler for WinCSXBox.
|
// Message handler for WinCSXBox.
|
||||||
LRESULT CALLBACK WinCSXBox(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK WinCSXBox(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
@ -381,6 +427,10 @@ LRESULT CALLBACK WinCSXBox(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
|
|||||||
case IDC_BUTTON_CLEARSTATS:
|
case IDC_BUTTON_CLEARSTATS:
|
||||||
ClearStats(hDlg);
|
ClearStats(hDlg);
|
||||||
break;
|
break;
|
||||||
|
case IDC_BUTTON_DELETE:
|
||||||
|
DeleteRecord(hDlg);
|
||||||
|
//DialogBox(hInst, (LPCTSTR)IDD_DELETEBOX, hDlg, (DLGPROC)DeleteBox);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -408,4 +458,3 @@ LRESULT CALLBACK AboutBox(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,29 +65,29 @@ END
|
|||||||
// Dialog
|
// Dialog
|
||||||
//
|
//
|
||||||
|
|
||||||
IDD_WINCSXBOX DIALOGEX 22, 17, 256, 203
|
IDD_WINCSXBOX DIALOGEX 22, 17, 253, 204
|
||||||
STYLE DS_ABSALIGN | DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION |
|
STYLE DS_ABSALIGN | DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION |
|
||||||
WS_SYSMENU
|
WS_SYSMENU
|
||||||
CAPTION "WinCSX"
|
CAPTION "WinCSX"
|
||||||
FONT 8, "System", 0, 0, 0x0
|
FONT 8, "System", 0, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
DEFPUSHBUTTON "Close",IDOK,206,168,39,26,WS_GROUP
|
DEFPUSHBUTTON "Close",IDOK,206,168,39,27,WS_GROUP
|
||||||
LISTBOX IDC_LIST,4,5,94,189,LBS_HASSTRINGS |
|
LISTBOX IDC_LIST,4,5,94,190,LBS_HASSTRINGS |
|
||||||
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||||
EDITTEXT IDC_EDIT_NAME,109,18,87,12,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT_NAME,109,18,87,12,ES_AUTOHSCROLL
|
||||||
EDITTEXT IDC_EDIT_POSITION,206,18,40,12,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT_POSITION,206,18,39,12,ES_AUTOHSCROLL
|
||||||
EDITTEXT IDC_EDIT_AUTHID,109,48,87,12,ES_AUTOHSCROLL |
|
EDITTEXT IDC_EDIT_AUTHID,109,48,87,12,ES_AUTOHSCROLL |
|
||||||
ES_READONLY
|
ES_READONLY
|
||||||
EDITTEXT IDC_EDIT_DAMAGE,206,48,40,12,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT_DAMAGE,206,48,39,12,ES_AUTOHSCROLL
|
||||||
EDITTEXT IDC_EDIT_FRAGS,109,78,40,12,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT_FRAGS,109,78,40,12,ES_AUTOHSCROLL
|
||||||
EDITTEXT IDC_EDIT_DEATHS,157,78,40,12,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT_DEATHS,157,78,40,12,ES_AUTOHSCROLL
|
||||||
EDITTEXT IDC_EDIT_TKS,206,78,40,12,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT_TKS,206,78,39,12,ES_AUTOHSCROLL
|
||||||
EDITTEXT IDC_EDIT_SHOTS,109,108,40,12,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT_SHOTS,109,108,40,12,ES_AUTOHSCROLL
|
||||||
EDITTEXT IDC_EDIT_HITS,157,108,40,12,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT_HITS,157,108,40,12,ES_AUTOHSCROLL
|
||||||
EDITTEXT IDC_EDIT_HS,206,108,40,12,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT_HS,206,108,39,12,ES_AUTOHSCROLL
|
||||||
EDITTEXT IDC_EDIT_PLANTS,109,138,40,12,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT_PLANTS,109,138,40,12,ES_AUTOHSCROLL
|
||||||
EDITTEXT IDC_EDIT_EXPLOSIONS,157,137,40,12,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT_EXPLOSIONS,157,137,40,12,ES_AUTOHSCROLL
|
||||||
EDITTEXT IDC_EDIT_DEFUSIONS,206,137,40,12,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT_DEFUSIONS,206,137,39,12,ES_AUTOHSCROLL
|
||||||
EDITTEXT IDC_EDIT_DEFUSED,109,168,40,12,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT_DEFUSED,109,168,40,12,ES_AUTOHSCROLL
|
||||||
LTEXT "Name (last used)",IDC_STATIC,109,5,56,8
|
LTEXT "Name (last used)",IDC_STATIC,109,5,56,8
|
||||||
LTEXT "Damage",IDC_STATIC,206,35,28,8
|
LTEXT "Damage",IDC_STATIC,206,35,28,8
|
||||||
@ -103,10 +103,10 @@ BEGIN
|
|||||||
LTEXT "Explosions",IDC_STATIC,157,125,38,8
|
LTEXT "Explosions",IDC_STATIC,157,125,38,8
|
||||||
LTEXT "Defused",IDC_STATIC,109,155,28,8
|
LTEXT "Defused",IDC_STATIC,109,155,28,8
|
||||||
LTEXT "Defusions",IDC_STATIC,206,125,34,8
|
LTEXT "Defusions",IDC_STATIC,206,125,34,8
|
||||||
PUSHBUTTON "About",IDC_ABOUT,109,184,40,10
|
PUSHBUTTON "About",IDC_ABOUT,109,185,40,10
|
||||||
PUSHBUTTON "Save record changes",IDC_BUTTON_SAVECHANGES,156,155,89,
|
PUSHBUTTON "Save",IDC_BUTTON_SAVECHANGES,157,155,39,8
|
||||||
10
|
PUSHBUTTON "Clear stats",IDC_BUTTON_CLEARSTATS,157,168,39,27
|
||||||
PUSHBUTTON "Clear stats",IDC_BUTTON_CLEARSTATS,157,168,39,26
|
PUSHBUTTON "Delete",IDC_BUTTON_DELETE,206,155,39,8
|
||||||
END
|
END
|
||||||
|
|
||||||
IDD_ABOUTBOX DIALOGEX 0, 0, 186, 95
|
IDD_ABOUTBOX DIALOGEX 0, 0, 186, 95
|
||||||
@ -162,7 +162,7 @@ BEGIN
|
|||||||
IDD_WINCSXBOX, DIALOG
|
IDD_WINCSXBOX, DIALOG
|
||||||
BEGIN
|
BEGIN
|
||||||
LEFTMARGIN, 4
|
LEFTMARGIN, 4
|
||||||
RIGHTMARGIN, 251
|
RIGHTMARGIN, 248
|
||||||
VERTGUIDE, 98
|
VERTGUIDE, 98
|
||||||
VERTGUIDE, 109
|
VERTGUIDE, 109
|
||||||
VERTGUIDE, 157
|
VERTGUIDE, 157
|
||||||
@ -170,7 +170,7 @@ BEGIN
|
|||||||
VERTGUIDE, 206
|
VERTGUIDE, 206
|
||||||
VERTGUIDE, 245
|
VERTGUIDE, 245
|
||||||
TOPMARGIN, 5
|
TOPMARGIN, 5
|
||||||
BOTTOMMARGIN, 194
|
BOTTOMMARGIN, 195
|
||||||
HORZGUIDE, 18
|
HORZGUIDE, 18
|
||||||
HORZGUIDE, 35
|
HORZGUIDE, 35
|
||||||
HORZGUIDE, 48
|
HORZGUIDE, 48
|
||||||
@ -181,6 +181,7 @@ BEGIN
|
|||||||
HORZGUIDE, 125
|
HORZGUIDE, 125
|
||||||
HORZGUIDE, 137
|
HORZGUIDE, 137
|
||||||
HORZGUIDE, 155
|
HORZGUIDE, 155
|
||||||
|
HORZGUIDE, 163
|
||||||
HORZGUIDE, 168
|
HORZGUIDE, 168
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
Loading…
Reference in New Issue
Block a user