void tBiasSliderAction::SetSliderBias(int bias) { QString biasString; if( bias != 0 ) { biasString = QString( tr("A", "ABBREV for Auto mode, MAX(1)") ); if( bias > 0 ) { biasString += "+"; } biasString += QString( "%1" ).arg( bias ); } else { biasString = QString( tr("Auto", "ABBREV for Auto mode, MAX(4)") ); } SetSliderTextFormat( biasString ); SetSliderText( biasString ); if(m_Bias != bias) { m_Bias = bias; emit NewBias( m_Bias ); } }
UISliderWithText::UISliderWithText() : UISlider() { sliderText = new UIStaticText(Rect(0, -40, 100, 40)); sliderText->SetFont(ControlsFactory::GetFontLight()); sliderText->SetAlign(ALIGN_HCENTER | ALIGN_BOTTOM); sliderText->SetInputEnabled(false); AddControl(sliderText); SetSliderText(oldValue = 0.f); }
void UISliderWithText::Draw( const UIGeometricData &geometricData ) { UISlider::Draw(geometricData); if(oldValue != this->GetValue()) { SetSliderText(oldValue = this->GetValue()); //Draw text const Rect & tRect = thumbButton->GetRect(); Rect r = sliderText->GetRect(); float32 x = tRect.x + (tRect.dx / 2.0f) - (r.dx / 2.0f); sliderText->SetRect(Rect(x, r.y, r.dx, r.dy)); } }
INT_PTR CALLBACK ConfigureDialogProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: { ConfigDialogData *info = (ConfigDialogData*)lParam; XElement *data = info->data; SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam); LocalizeWindow(hwnd); //-------------------------------------------- SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_REFRESH, BN_CLICKED), (LPARAM)GetDlgItem(hwnd, IDC_APPLIST)); //-------------------------------------------- BOOL bCaptureMouse = data->GetInt(TEXT("captureMouse"), 1); BOOL bStretchImage = data->GetInt(TEXT("stretchImage")); SendMessage(GetDlgItem(hwnd, IDC_STRETCHTOSCREEN), BM_SETCHECK, bStretchImage ? BST_CHECKED : BST_UNCHECKED, 0); SendMessage(GetDlgItem(hwnd, IDC_IGNOREASPECT), BM_SETCHECK, data->GetInt(TEXT("ignoreAspect")) ? BST_CHECKED : BST_UNCHECKED, 0); SendMessage(GetDlgItem(hwnd, IDC_CAPTUREMOUSE), BM_SETCHECK, bCaptureMouse ? BST_CHECKED : BST_UNCHECKED, 0); SendMessage(GetDlgItem(hwnd, IDC_INVERTMOUSEONCLICK), BM_SETCHECK, data->GetInt(TEXT("invertMouse")) ? BST_CHECKED : BST_UNCHECKED, 0); SendMessage(GetDlgItem(hwnd, IDC_USESAFEHOOK), BM_SETCHECK, data->GetInt(TEXT("safeHook")) ? BST_CHECKED : BST_UNCHECKED, 0); EnableWindow(GetDlgItem(hwnd, IDC_INVERTMOUSEONCLICK), bCaptureMouse); EnableWindow(GetDlgItem(hwnd, IDC_IGNOREASPECT), bStretchImage); //------------------------------------------ bool bUseHotkey = data->GetInt(TEXT("useHotkey"), 0) != 0; EnableWindow(GetDlgItem(hwnd, IDC_APPLIST), !bUseHotkey); EnableWindow(GetDlgItem(hwnd, IDC_REFRESH), !bUseHotkey); EnableWindow(GetDlgItem(hwnd, IDC_HOTKEY), bUseHotkey); DWORD hotkey = data->GetInt(TEXT("hotkey"), VK_F12); SendMessage(GetDlgItem(hwnd, IDC_HOTKEY), HKM_SETHOTKEY, hotkey, 0); SendMessage(GetDlgItem(hwnd, IDC_SELECTAPP), BM_SETCHECK, bUseHotkey ? BST_UNCHECKED : BST_CHECKED, 0); SendMessage(GetDlgItem(hwnd, IDC_USEHOTKEY), BM_SETCHECK, bUseHotkey ? BST_CHECKED : BST_UNCHECKED, 0); //------------------------------------------ int gammaVal = data->GetInt(TEXT("gamma"), 100); HWND hwndTemp = GetDlgItem(hwnd, IDC_GAMMA); SendMessage(hwndTemp, TBM_CLEARTICS, FALSE, 0); SendMessage(hwndTemp, TBM_SETRANGE, FALSE, MAKELPARAM(50, 175)); SendMessage(hwndTemp, TBM_SETTIC, 0, 100); SendMessage(hwndTemp, TBM_SETPOS, TRUE, gammaVal); SetSliderText(hwnd, IDC_GAMMA, IDC_GAMMAVAL); return TRUE; } case WM_HSCROLL: { if(GetDlgCtrlID((HWND)lParam) == IDC_GAMMA) { int gamma = SetSliderText(hwnd, IDC_GAMMA, IDC_GAMMAVAL); ConfigDialogData *info = (ConfigDialogData*)GetWindowLongPtr(hwnd, DWLP_USER); ImageSource *source = API->GetSceneImageSource(info->lpName); if(source) source->SetInt(TEXT("gamma"), gamma); } } break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_CAPTUREMOUSE: { BOOL bCaptureMouse = SendMessage(GetDlgItem(hwnd, IDC_CAPTUREMOUSE), BM_GETCHECK, 0, 0) == BST_CHECKED; EnableWindow(GetDlgItem(hwnd, IDC_INVERTMOUSEONCLICK), bCaptureMouse); } break; case IDC_SELECTAPP: case IDC_USEHOTKEY: if (HIWORD(wParam) == BN_CLICKED) { bool bUseHotkey = LOWORD(wParam) == IDC_USEHOTKEY; EnableWindow(GetDlgItem(hwnd, IDC_APPLIST), !bUseHotkey); EnableWindow(GetDlgItem(hwnd, IDC_REFRESH), !bUseHotkey); EnableWindow(GetDlgItem(hwnd, IDC_HOTKEY), bUseHotkey); } break; case IDC_STRETCHTOSCREEN: { BOOL bStretchToScreen = SendMessage(GetDlgItem(hwnd, IDC_STRETCHTOSCREEN), BM_GETCHECK, 0, 0) == BST_CHECKED; EnableWindow(GetDlgItem(hwnd, IDC_IGNOREASPECT), bStretchToScreen); } break; case IDC_REFRESH: { ConfigDialogData *info = (ConfigDialogData*)GetWindowLongPtr(hwnd, DWLP_USER); XElement *data = info->data; CTSTR lpWindowName = data->GetString(TEXT("window")); HWND hwndWindowList = GetDlgItem(hwnd, IDC_APPLIST); RefreshWindowList(hwndWindowList, *info); UINT windowID = 0; if(lpWindowName) windowID = (UINT)SendMessage(hwndWindowList, CB_FINDSTRINGEXACT, -1, (LPARAM)lpWindowName); if(windowID != CB_ERR) SendMessage(hwndWindowList, CB_SETCURSEL, windowID, 0); else SendMessage(hwndWindowList, CB_SETCURSEL, 0, 0); String strInfoText; if(info->adminWindows.Num()) { strInfoText << Str("Sources.GameCaptureSource.RequiresAdmin") << TEXT("\r\n"); for(UINT i=0; i<info->adminWindows.Num(); i++) strInfoText << info->adminWindows[i] << TEXT("\r\n"); } SetWindowText(GetDlgItem(hwnd, IDC_INFO), strInfoText); } break; case IDOK: { UINT windowID = (UINT)SendMessage(GetDlgItem(hwnd, IDC_APPLIST), CB_GETCURSEL, 0, 0); if(windowID == CB_ERR) windowID = 0; ConfigDialogData *info = (ConfigDialogData*)GetWindowLongPtr(hwnd, DWLP_USER); XElement *data = info->data; if(!info->windowData.Num()) return 0; String strWindow = GetCBText(GetDlgItem(hwnd, IDC_APPLIST), windowID); data->SetString(TEXT("window"), strWindow); data->SetString(TEXT("windowClass"), info->windowData[windowID].strClass); data->SetString(TEXT("executable"), info->windowData[windowID].strExecutable); data->SetInt(TEXT("stretchImage"), SendMessage(GetDlgItem(hwnd, IDC_STRETCHTOSCREEN), BM_GETCHECK, 0, 0) == BST_CHECKED); data->SetInt(TEXT("ignoreAspect"), SendMessage(GetDlgItem(hwnd, IDC_IGNOREASPECT), BM_GETCHECK, 0, 0) == BST_CHECKED); data->SetInt(TEXT("captureMouse"), SendMessage(GetDlgItem(hwnd, IDC_CAPTUREMOUSE), BM_GETCHECK, 0, 0) == BST_CHECKED); data->SetInt(TEXT("invertMouse"), SendMessage(GetDlgItem(hwnd, IDC_INVERTMOUSEONCLICK), BM_GETCHECK, 0, 0) == BST_CHECKED); data->SetInt(TEXT("safeHook"), SendMessage(GetDlgItem(hwnd, IDC_USESAFEHOOK), BM_GETCHECK, 0, 0) == BST_CHECKED); data->SetInt(TEXT("useHotkey"), SendMessage(GetDlgItem(hwnd, IDC_USEHOTKEY), BM_GETCHECK, 0, 0) == BST_CHECKED); data->SetInt(TEXT("hotkey"), (DWORD)SendMessage(GetDlgItem(hwnd, IDC_HOTKEY), HKM_GETHOTKEY, 0, 0)); data->SetInt(TEXT("gamma"), (int)SendMessage(GetDlgItem(hwnd, IDC_GAMMA), TBM_GETPOS, 0, 0)); EndDialog(hwnd, LOWORD(wParam)); } break; case IDCANCEL: { ConfigDialogData *info = (ConfigDialogData*)GetWindowLongPtr(hwnd, DWLP_USER); ImageSource *source = API->GetSceneImageSource(info->lpName); XElement *data = info->data; if(source) { source->SetInt(TEXT("gamma"), data->GetInt(TEXT("gamma"), 100)); } EndDialog(hwnd, LOWORD(wParam)); } } break; case WM_CLOSE: EndDialog(hwnd, IDCANCEL); } return 0; }
LRESULT CALLBACK Settings( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { #define TIMER_ID_S (UINT) 'S' static LONG lSlider[ 3 ]; static int iPathId[ 3 ] = { IDC_EDIT_TARGET1, IDC_EDIT_TARGET2, IDC_EDIT_TARGET3 }; static int iButtonId[ 3 ] = { IDC_BUTTON_STOP1, IDC_BUTTON_STOP2, IDC_BUTTON_STOP3 }; static int iTextId[ 3 ] = { IDC_TEXT_TARGET1, IDC_TEXT_TARGET2, IDC_TEXT_TARGET3 }; static int iSliderId[ 3 ] = { IDC_SLIDER1, IDC_SLIDER2, IDC_SLIDER3 }; static HWND hWnd; static int iMyId; static LPTSTR * lpszStatus; static TCHAR lpszWindowText[ 1024 ]; static HFONT hMyFont = NULL; switch (message) { case WM_INITDIALOG: { hWnd = ( ( LPHACK_PARAMS ) lParam ) -> myHwnd; iMyId = ( ( LPHACK_PARAMS ) lParam ) -> iMyId; lpszStatus = ( ( LPHACK_PARAMS ) lParam ) -> lpszStatus; HDC hDC = GetDC( hDlg ); hMyFont = MyCreateFont( hDC, TEXT( "Verdana" ), 12, TRUE, FALSE ); ReleaseDC( hDlg, hDC ); #ifdef _UNICODE if( IS_JAPANESE ) { MultiByteToWideChar( CP_UTF8, MB_CUTE, IS_JAPANESEo ? S_JPNo_1002 : S_JPN_1002, -1, lpszWindowText, 1023 ); SetWindowText( hDlg, lpszWindowText ); } else if( IS_FRENCH ) { MultiByteToWideChar( CP_UTF8, MB_CUTE, S_FRE_1002, -1, lpszWindowText, 1023 ); SetWindowText( hDlg, lpszWindowText ); } else if( IS_SPANISH ) { MultiByteToWideChar( CP_UTF8, MB_CUTE, S_SPA_1002, -1, lpszWindowText, 1023 ); SetWindowText( hDlg, lpszWindowText ); } else #endif { lstrcpy( lpszWindowText, _T( "Limiter control" ) ); SetWindowText( hDlg, lpszWindowText ); } for( int i = 0; i < 3; i++ ) { lSlider[ i ] = (long) g_Slider[ i ]; SetDlgItemText( hDlg, iPathId[ i ], g_szTarget[ i ] ); TCHAR tmpstr[ 100 ]; wsprintf( tmpstr, TEXT( "%s #&%d" ), ( ( g_bHack[ i ] )? TEXT( "Unlimit" ) : TEXT( "Limit" ) ), i + 1 ); SetDlgItemText( hDlg, iButtonId[ i ], tmpstr ); EnableWindow( GetDlgItem( hDlg, iButtonId[ i ] ), ( g_dwTargetProcessId[ i ] != TARGET_PID_NOT_SET ) ); EnableWindow( GetDlgItem( hDlg, iSliderId[ i ] ), ( g_dwTargetProcessId[ i ] != TARGET_PID_NOT_SET ) ); EnableWindow( GetDlgItem( hDlg, iTextId[ i ] ), ( g_dwTargetProcessId[ i ] != TARGET_PID_NOT_SET ) ); SendDlgItemMessage( hDlg, iSliderId[ i ], TBM_SETRANGE, TRUE, MAKELONG( 1, 99 ) ); SendDlgItemMessage( hDlg, iSliderId[ i ], TBM_SETPOS, TRUE, lSlider[ i ] ); for( long lPos = 10L; lPos <= 90L; lPos += 10L ) { SendDlgItemMessage( hDlg, iSliderId[ i ], TBM_SETTIC, 0U, lPos ); } SendDlgItemMessage( hDlg, iTextId[ i ], WM_SETFONT, ( WPARAM ) hMyFont, 0L ); SetSliderText( hDlg, iTextId[ i ] , lSlider[ i ] ); } if( g_dwTargetProcessId[ 2 ] == (DWORD) -1 || g_bHack[ 3 ] ) { SetDlgItemText( hDlg, iButtonId[ 2 ], TEXT( "(Watching)" ) ); EnableWindow( GetDlgItem( hDlg, iButtonId[ 2 ] ), FALSE ); EnableWindow( GetDlgItem( hDlg, iTextId[ 2 ] ), TRUE ); } // Anti-Ukagaka SetTimer( hDlg, TIMER_ID_S, 500U, (TIMERPROC) NULL ); break; } case WM_CTLCOLORSTATIC: { for( int i = 0; i < 3; i++ ) { HWND hEdit = GetDlgItem( hDlg, iTextId[ i ] ); if( (HWND) lParam == hEdit ) { HDC hDC = (HDC) wParam; SetBkMode( hDC, TRANSPARENT ); SetBkColor( hDC, GetSysColor( COLOR_3DFACE ) ); SetTextColor( hDC, RGB( 0,0,0xaa ) ); return (BOOL) (HBRUSH) GetSysColorBrush( COLOR_3DFACE ); } } return 0L; } case WM_HSCROLL: { if( GetDlgItem( hDlg, IDC_SLIDER1 ) == (HWND) lParam && SliderMoved( wParam ) ) { const RECT minirect = { 20L, 20L + 90L * 0L, 479L, 40L + 90L * 0L }; lSlider[ 0 ] = SendDlgItemMessage( hDlg, IDC_SLIDER1, TBM_GETPOS, 0U, 0L ); SetSliderText( hDlg, IDC_TEXT_TARGET1, lSlider[ 0 ] ); g_Slider[ 0 ] = GetSliderParam( lSlider[ 0 ] ); if( g_bHack[ 0 ] ) { wsprintf( lpszStatus[ 0 ], TEXT( "Target #1 [ -%d%% ]" ), g_Slider[ 0 ] ); InvalidateRect( hWnd, &minirect, 0 ); } } else if( GetDlgItem( hDlg, IDC_SLIDER2 ) == (HWND) lParam && SliderMoved( wParam ) ) { const RECT minirect = { 20L, 20L + 90L * 1L, 479L, 40L + 90L * 1L }; lSlider[ 1 ] = SendDlgItemMessage( hDlg, IDC_SLIDER2, TBM_GETPOS, 0U, 0L ); SetSliderText( hDlg, IDC_TEXT_TARGET2, lSlider[ 1 ] ); g_Slider[ 1 ] = GetSliderParam( lSlider[ 1 ] ); if( g_bHack[ 1 ] ) { wsprintf( lpszStatus[ 0 + 4 * 1 ], TEXT( "Target #2 [ -%d%% ]" ), g_Slider[ 1 ] ); InvalidateRect( hWnd, &minirect, 0 ); } } else if( GetDlgItem( hDlg, IDC_SLIDER3 ) == (HWND) lParam && SliderMoved( wParam ) ) { const RECT minirect = { 20L, 20L + 90L * 2L, 479L, 40L + 90L * 2L }; lSlider[ 2 ] = SendDlgItemMessage( hDlg, IDC_SLIDER3, TBM_GETPOS, 0U, 0L ); SetSliderText( hDlg, IDC_TEXT_TARGET3, lSlider[ 2 ] ); g_Slider[ 2 ] = GetSliderParam( lSlider[ 2 ] ); if( g_bHack[ 2 ] ) { wsprintf( lpszStatus[ 0 + 4 * 2 ], TEXT( "Target #3 [ -%d%% ]" ), g_Slider[ 2 ] ); InvalidateRect( hWnd, &minirect, 0 ); } } break; } case WM_COMMAND: { switch( LOWORD( wParam ) ) { case IDOK: { TCHAR msg[ 4096 ]; int i; for( i = 0; i < 3; i++ ) { if( g_dwTargetProcessId[ i ] != 0UL ) { wsprintf( msg, TEXT( "g_Slider[ %d ] = %d : %s" ), i, (int) g_Slider[ i ], g_szTarget[ i ] ); WriteDebugLog( msg ); SetSliderIni( g_szTarget[ i ], (int) g_Slider[ i ] ); } } EndDialog( hDlg, TRUE ); break; } case IDCANCEL: { EndDialog( hDlg, FALSE ); break; } case IDC_BUTTON_STOP1: { if( g_bHack[ 0 ] ) { SendMessage( hWnd, WM_USER_STOP, 0U, 0L ); SetDlgItemText( hDlg, iButtonId[ 0 ], TEXT( "Limit #&1" ) ); } else { SendMessage( hWnd, WM_USER_RESTART, 0U, 0L ); SetDlgItemText( hDlg, iButtonId[ 0 ], TEXT( "Unlimit #&1" ) ); } break; } case IDC_BUTTON_STOP2: { if( g_bHack[ 1 ] ) { SendMessage( hWnd, WM_USER_STOP, 1U, 0L ); SetDlgItemText( hDlg, iButtonId[ 1 ], TEXT( "Limit #&2" ) ); } else { SendMessage( hWnd, WM_USER_RESTART, 1U, 0L ); SetDlgItemText( hDlg, iButtonId[ 1 ], TEXT( "Unlimit #&2" ) ); } break; } case IDC_BUTTON_STOP3: { if( g_bHack[ 2 ] ) { SendMessage( hWnd, WM_USER_STOP, 2U, 0L ); SetDlgItemText( hDlg, iButtonId[ 2 ], TEXT( "Limit #&3" ) ); } else { SendMessage( hWnd, WM_USER_RESTART, 2U, 0L ); SetDlgItemText( hDlg, iButtonId[ 2 ], TEXT( "Unlimit #&3" ) ); } break; } default: { break; } } break; // <-- fixed @ 1.1 beta3 } case WM_TIMER: { SetWindowText( hDlg, lpszWindowText ); break; } case WM_DESTROY: { DeleteFont( hMyFont ); hMyFont = NULL; KillTimer( hDlg, TIMER_ID_S ); break; } default: return 0L;//FALSE; } return 1L;//TRUE; }