Test unique code

This commit is contained in:
zilmar 2020-12-30 11:17:25 +10:30
parent 4d28cf6bc3
commit c4160785e9
5 changed files with 32 additions and 19 deletions

View File

@ -38,6 +38,3 @@ Directory=..\..\Lang
[Texture Directory]
Directory=..\..\Textures\
Use Selected=1
[Support Project64]
Run Count=-1

View File

@ -14,6 +14,10 @@ CProjectSupport::CProjectSupport() :
bool CProjectSupport::RequestCode(const char * Email)
{
if (Email == nullptr || strlen(Email) == 0 || stricmp(Email, "thank you from project64") == 0)
{
return false;
}
stdstr_f PostData("task=RequestCode&email=%s&machine=%s", Email, MachineID());
std::vector<std::string> Headers;
DWORD StatusCode;

View File

@ -18,6 +18,7 @@ public:
enum { IDD = IDD_Support_RequestCode };
CRequestCode(CProjectSupport & Support);
void ShowOldCodeMsg();
private:
CRequestCode(void);
@ -31,6 +32,7 @@ private:
LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
CProjectSupport & m_Support;
bool m_ShowOldCodeMsg;
};
CSupportEnterCode::CSupportEnterCode(CProjectSupport & Support) :
@ -157,9 +159,13 @@ LRESULT CSupportEnterCode::OnOkCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCt
bool ValidCode = false;
if (_wcsicmp(code,L"thank you from project64") == 0)
{
UISettingsSaveDword(SupportWindows_RunCount, (uint32_t)-1);
CSettingTypeApplication::Flush();
ValidCode = true;
SetDlgItemText(IDC_CODE, L"");
CRequestCode RequestWindow(m_Support);
RequestWindow.ShowOldCodeMsg();
RequestWindow.DoModal(m_hWnd);
GetDlgItem(IDOK).EnableWindow(TRUE);
GetDlgItem(IDCANCEL).EnableWindow(TRUE);
return TRUE;
}
else if (m_Support.ValidateCode(stdstr().FromUTF16(code).c_str()))
{
@ -180,10 +186,16 @@ LRESULT CSupportEnterCode::OnOkCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCt
}
CRequestCode::CRequestCode(CProjectSupport & Support) :
m_Support(Support)
m_Support(Support),
m_ShowOldCodeMsg(false)
{
}
void CRequestCode::ShowOldCodeMsg()
{
m_ShowOldCodeMsg = true;
}
LRESULT CSupportEnterCode::OnRequestCode(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
CRequestCode RequestWindow(m_Support);
@ -193,6 +205,10 @@ LRESULT CSupportEnterCode::OnRequestCode(WORD /*wNotifyCode*/, WORD /*wID*/, HWN
LRESULT CRequestCode::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
if (m_ShowOldCodeMsg)
{
SetDlgItemText(IDC_DESCRIPTION, L"We have changed the code to be unique to a machine, please enter the email you used to support Project64 with.");
}
return TRUE;
}

View File

@ -27,7 +27,7 @@ void CSupportWindow::Show(HWND hParent, bool Delay)
m_Delay = Delay;
if (Delay)
{
if (UISettingsLoadDword(SupportWindows_RunCount) == -1 || m_Support.Validated())
if (m_Support.Validated())
{
return;
}
@ -184,10 +184,6 @@ LRESULT CSupportWindow::OnEnterCode(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndC
{
CSupportEnterCode EnterCodeWindow(m_Support);
EnterCodeWindow.DoModal(m_hWnd);
if (UISettingsLoadDword(SupportWindows_RunCount) == -1)
{
EndDialog(wID);
}
if (m_Support.Validated())
{
EndDialog(wID);

View File

@ -1378,15 +1378,15 @@ BEGIN
COMBOBOX IDC_DISKSAVETYPE,95,104,115,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
END
IDD_Support_RequestCode DIALOGEX 0, 0, 165, 96
IDD_Support_RequestCode DIALOGEX 0, 0, 166, 83
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Request Code"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
LTEXT "Please enter the email used to support Project64",IDC_DESCRIPTION,8,8,148,15
EDITTEXT IDC_EMAIL,8,34,148,12,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,55,75,50,14
PUSHBUTTON "Cancel",IDCANCEL,108,75,50,14
LTEXT "Please enter the email used to support Project64",IDC_DESCRIPTION,8,8,148,32
EDITTEXT IDC_EMAIL,9,44,150,12,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,55,62,50,14
PUSHBUTTON "Cancel",IDCANCEL,109,62,50,14
END
@ -1844,9 +1844,9 @@ BEGIN
IDD_Support_RequestCode, DIALOG
BEGIN
RIGHTMARGIN, 155
RIGHTMARGIN, 159
TOPMARGIN, 7
BOTTOMMARGIN, 89
BOTTOMMARGIN, 76
END
END
#endif // APSTUDIO_INVOKED