Example #1
0
void plStealthDlgProc::SetThing(ReferenceTarget *m)
{
    plAnimStealthNode *stealth = (plAnimStealthNode *)m;
    IParamBlock2 *pb = stealth->GetParamBlockByID( plAnimStealthNode::kBlockPB );

    IInitControls( stealth, pb );
}
Example #2
0
BOOL plStealthDlgProc::DlgProc(TimeValue t, IParamMap2 *map, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    IParamBlock2 *pb = map->GetParamBlock();
    plAnimStealthNode *stealth = (plAnimStealthNode *)pb->GetOwner();

    switch (msg)
    {
        case WM_INITDIALOG:
        {
            // Install our override proc so we can capture mouse messages ourselves.
            // Note that the first time, we grab the old proc so we can restore with that
            // one every time after, since they should always be the same proc
            WNDPROC old = (WNDPROC)SetWindowLongPtr( hWnd, DWLP_DLGPROC, (LONG_PTR)plStealthMouseOverrideProc );
            if( sOldStealthDlgProc == nil )
                sOldStealthDlgProc = old;

            fhWnd = hWnd;
            IInitControls( stealth, pb );

            return TRUE;
        }

        case WM_DESTROY:
            // Restore our old proc
            SetWindowLongPtr( hWnd, DWLP_DLGPROC, (LONG_PTR)sOldStealthDlgProc );
            break;

        case WM_ENABLE:
            // The entire dialog was either enabled or disabled. 
            break;

    case WM_COMMAND:
        // Loop selection changed
        if( LOWORD( wParam ) == IDC_LOOPS && HIWORD( wParam ) == CBN_SELCHANGE )
        {
            // If a loop is selected, save it
            HWND hCombo = (HWND)lParam;
            int sel = SendMessage( hCombo, CB_GETCURSEL, 0, 0 );
            if( sel != CB_ERR )
            {
                if( SendMessage( hCombo, CB_GETITEMDATA, sel, 0 ) == kName )
                {
                    char buf[256];
                    SendMessage( hCombo, CB_GETLBTEXT, sel, (LPARAM)buf );
                    pb->SetValue( (ParamID)plAnimStealthNode::kPBLoopName, 0, buf );
                }
                else
                    pb->SetValue( (ParamID)plAnimStealthNode::kPBLoopName, 0, "" );
            }

            return TRUE;
        }

        // Auto-start or loop checkbox checked
        if( LOWORD( wParam ) == IDC_LOOP && HIWORD( wParam ) == BN_CLICKED )
        {
            BOOL checked = ( SendMessage( (HWND)lParam, BM_GETCHECK, 0, 0 ) == BST_CHECKED );

            pb->SetValue( plAnimStealthNode::kPBLoop, 0, checked );
            EnableWindow( GetDlgItem( hWnd, IDC_LOOPS ), checked );
            return TRUE;
        }

        // Refresh clicked
        else if( LOWORD( wParam ) == IDC_REFRESH_ANIMS && HIWORD( wParam ) == BN_CLICKED )
        {
            IInitControls( stealth, pb );
            return TRUE;
        }

        break;
    }

    return FALSE;
}
Example #3
0
BOOL plAgeDescInterface::DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
    case WM_INITDIALOG:
        fhDlg = hDlg;

#ifdef MAXASS_AVAILABLE
        if( fAssetManIface == nil )
            fAssetManIface = new MaxAssBranchAccess();
#endif

        // Make our bold font by getting the normal font and bolding
        if( fBoldFont == nil )
        {
            HFONT origFont = (HFONT)SendMessage( hDlg, WM_GETFONT, 0, 0 );
            LOGFONT origInfo, newInfo;
            GetObject( origFont, sizeof( origInfo ), &origInfo );
            memcpy( &newInfo, &origInfo, sizeof( newInfo ) );
            newInfo.lfWeight = FW_BOLD;

            fBoldFont = CreateFontIndirect( &newInfo );
        }

        if( fHiliteBrush == nil )
            fHiliteBrush = CreateSolidBrush( RGB( 255, 0, 0 ) );

        IInitControls();
        IFillAgeTree();
        return TRUE;

    case WM_DESTROY:
#ifdef MAXASS_AVAILABLE
        delete fAssetManIface;
        fAssetManIface = nil;
#endif
        return TRUE;

    // Day length spinner changed
    case CC_SPINNER_CHANGE:
        if (LOWORD(wParam) == IDC_DAYLEN_SPINNER ||
            LOWORD(wParam) == IDC_CAP_SPINNER ||
            LOWORD(wParam) == IDC_SEQPREFIX_SPIN )
        {
            fDirty = true;
            return TRUE;
        }
        break;

    case WM_CLOSE:
        ::SendMessage( fhDlg, WM_COMMAND, IDOK, 0 );
        return true;

    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDOK:
        case IDCANCEL:
            if( IMakeSureCheckedIn() )
            {
#ifdef MAXASS_AVAILABLE
                IUpdateCurAge();
#endif
                DestroyWindow(fhDlg);
                fhDlg = nil;
                fDirty = false;
                fCurAge = -1;
                fSpin = nil;
            }
            return TRUE;

//      case IDC_AGE_LIST:
//          if (HIWORD(wParam) == LBN_SELCHANGE)
//          {
//              IUpdateCurAge();
//              return TRUE;
//          }
//          break;
        
        case IDC_AGE_CHECKOUT:
            ICheckOutCurrentAge();
            return TRUE;

        case IDC_AGE_CHECKIN:
            ICheckInCurrentAge();
            return TRUE;

        case IDC_AGE_UNDOCHECKOUT:
            IUndoCheckOutCurrentAge();
            return TRUE;

        case IDC_AGE_NEW:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                INewAge();
                return TRUE;
            }
            break;

        case IDC_PAGE_NEW:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                INewPage();
                return TRUE;
            }
            break;

        case IDC_PAGE_DEL:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                HWND hPage = GetDlgItem(hDlg, IDC_PAGE_LIST);
                int sel = ListBox_GetCurSel(hPage);
                if (sel != LB_ERR)
                {
                    RemovePageItem( hPage, sel );
                    fDirty = true;
                }
                return TRUE;
            }
            break;

        case IDC_PAGE_LIST:
            if( HIWORD( wParam ) == LBN_SELCHANGE )
            {
                // Sel change
                HWND list = GetDlgItem( hDlg, IDC_PAGE_LIST );
                int sel = ListBox_GetCurSel( list );
                if( sel != LB_ERR )
                {
                    IEnablePageControls(true);

                    plAgePage *page = (plAgePage *)ListBox_GetItemData( list, sel );
                    CheckDlgButton( hDlg, IDC_ADM_DONTLOAD, ( page->GetFlags() & plAgePage::kPreventAutoLoad ) ? TRUE : FALSE );
                    CheckDlgButton( hDlg, IDC_ADM_LOADSDL, ( page->GetFlags() & plAgePage::kLoadIfSDLPresent ) ? TRUE : FALSE );
                    CheckDlgButton( hDlg, IDC_ADM_LOCAL_ONLY, ( page->GetFlags() & plAgePage::kIsLocalOnly ) ? TRUE : FALSE );
                    CheckDlgButton( hDlg, IDC_ADM_VOLATILE, ( page->GetFlags() & plAgePage::kIsVolatile ) ? TRUE : FALSE );
                }
                else
                    IEnablePageControls(false);
            }
            break;

        case IDC_ADM_DONTLOAD:
        case IDC_ADM_LOADSDL:
        case IDC_ADM_LOCAL_ONLY:
        case IDC_ADM_VOLATILE:
            ICheckedPageFlag(LOWORD(wParam));
            break;

        case IDC_EDITREG:
            // Ask the user to make sure they really want to do this
            if( GetAsyncKeyState( VK_SHIFT ) & (~1) )
            {
                if( MessageBox( hDlg, "Are you sure you wish to reassign the sequence prefix for this age?", "WARNING", MB_YESNO | MB_ICONEXCLAMATION ) == IDYES )
                {
                    int32_t prefix = (int32_t)IGetNextFreeSequencePrefix( IsDlgButtonChecked( hDlg, IDC_RSVDCHECK ) );
                    fSeqPrefixSpin->SetValue( ( prefix >= 0 ) ? prefix : -prefix, false );
                    fDirty = true;
                }
            }
            else
            {
                if( MessageBox( hDlg, "Editing the registry data for an age can be extremely dangerous and "
                                    "can cause instabilities and crashes, particularly with multiplayer. "
                                    "Are you sure you want to do this?", "WARNING", MB_YESNO | MB_ICONEXCLAMATION ) == IDYES )
                {
                    // Enable the controls
                    EnableWindow( GetDlgItem( hDlg, IDC_RSVDCHECK ), TRUE );
                    EnableWindow( GetDlgItem( hDlg, IDC_SEQPREFIX_EDIT ), TRUE );
                    EnableWindow( GetDlgItem( hDlg, IDC_SEQPREFIX_SPIN ), TRUE );
                }
            }
            return TRUE;

        case IDC_RSVDCHECK:
            fDirty = true;
            return FALSE;   // Still process as normal

        case IDC_BRANCHCOMBO:
            if( HIWORD( wParam ) == CBN_SELCHANGE )
            {
                int idx = SendDlgItemMessage( hDlg, IDC_BRANCHCOMBO, CB_GETCURSEL, 0, 0 );
                if( idx != CB_ERR )
                {
                    int id = SendDlgItemMessage( hDlg, IDC_BRANCHCOMBO, CB_GETITEMDATA, idx, 0 );

#ifdef MAXASS_AVAILABLE
                    fAssetManIface->SetCurrBranch( id );
#endif
                    IFillAgeTree();
                }
            }
            return TRUE;
        }
        break;

    case WM_PAINT:
        PAINTSTRUCT paintInfo;

        BeginPaint( hDlg, &paintInfo );

        if( fCurrAgeCheckedOut )
        {
            RECT    r;
            HWND    dummy = GetDlgItem( hDlg, IDC_AGEDESC );
            GetClientRect( dummy, &r );
            MapWindowPoints( dummy, hDlg, (POINT *)&r, 2 );

            for( int i = 0; i < 3; i++ )
            {
                InflateRect( &r, -1, -1 );
                FrameRect( paintInfo.hdc, &r, fHiliteBrush );
            }
        }

        EndPaint( hDlg, &paintInfo );
        return TRUE;

    case WM_NOTIFY:
        {
            NMHDR *hdr = (NMHDR*)lParam;

            // Message from the start date/time controls
            if (hdr->idFrom == IDC_DATE || hdr->idFrom == IDC_TIME)
            {
                if (hdr->code == NM_KILLFOCUS)
                {
                    plMaxAccelerators::Enable();
                    return TRUE;
                }
                else if (hdr->code == NM_SETFOCUS)
                {
                    plMaxAccelerators::Disable();
                    return TRUE;
                }
                // Time or date changed, set dirty
                else if (hdr->code == DTN_DATETIMECHANGE)
                {
                    fDirty = true;
                    return TRUE;
                }   
            }
            else if( hdr->idFrom == IDC_AGE_LIST )
            {
                if( hdr->code == NM_CUSTOMDRAW )
                {
                    // Custom draw notifications for our treeView control
                    LPNMTVCUSTOMDRAW    treeNotify = (LPNMTVCUSTOMDRAW)lParam;

                    if( treeNotify->nmcd.dwDrawStage == CDDS_PREPAINT )
                    {
                        // Sent at the start of redraw, lets us request more specific notifys
                        SetWindowLong( hDlg, DWL_MSGRESULT, CDRF_NOTIFYITEMDRAW );
                        return TRUE;
                    }
                    else if( treeNotify->nmcd.dwDrawStage == CDDS_ITEMPREPAINT )
                    {
                        // Prepaint on an item. We get to change item font and color here
                        int idx = SGetTreeData( hdr->hwndFrom, (HTREEITEM)treeNotify->nmcd.dwItemSpec );
/*                      if( item == nil || item->fType != plAgeFile::kBranch )
                        {
                            // Default drawing, with default font and such
                            SetWindowLong( hDlg, DWL_MSGRESULT, CDRF_DODEFAULT );
                            return TRUE;
                        }       
*/
                        // Color change (only if the item isn't selected)
                        if( (HTREEITEM)treeNotify->nmcd.dwItemSpec != TreeView_GetSelection( hdr->hwndFrom ) )
                        {
                            treeNotify->clrText = GetColorManager()->GetColor( kText );
                            treeNotify->clrTextBk = GetColorManager()->GetColor( kWindow );
                        }

                        if (idx == -1)
                        {
                            // Set a bold font for the branch headers
                            if( fBoldFont != nil )
                                SelectObject( treeNotify->nmcd.hdc, fBoldFont );
                        }

                        // Let Windows know we changed the font
                        SetWindowLong( hDlg, DWL_MSGRESULT, CDRF_NEWFONT );
                        return TRUE;
                    }
                    else
                        // Let the default handle it
                        return FALSE;
                }
                else if( hdr->code == TVN_SELCHANGING )
                {
                    SetWindowLong( hDlg, DWL_MSGRESULT, !IMakeSureCheckedIn() );
                    return TRUE;
                }
                else if( hdr->code == TVN_SELCHANGED )
                {
                    // Update the viewing age
                    IUpdateCurAge();
                    return TRUE;
                }
            }
        }
        break;
    }

    return FALSE;
}