Beispiel #1
0
// I'm sure there's a better way to do this but I can't find it in the docs
static void ShutdownMax()
{
    // If we're auto-exporting, write out a file to let the build scripts know
    // we're done writing to disk, and if we don't exit soon we probably crashed
    if (plExportDlg::Instance().IsAutoExporting())
    {
        hsUNIXStream s;
        s.Open("log\\AutoExportDone.txt", "wb");
        s.Close();
    }
    GetCOREInterface()->FlushUndoBuffer();
    SetSaveRequiredFlag(FALSE);
    PostMessage(GetCOREInterface()->GetMAXHWnd(), WM_CLOSE, 0, 0);
}
Beispiel #2
0
// Write a chunk of app data on the sound object
void
WriteAppData(Interface* ip, int id, const TCHAR* val)
{
	SoundObj *node = ip->GetSoundObject();
	node->RemoveAppDataChunk(POLYGON_COUNTER_CLASS_ID, UTILITY_CLASS_ID, id);

	if (val == NULL)
		return;

	CStr the_val = CStr::FromMCHAR(val);
	int len = the_val.Length()+1; 
	char* buf = (char*)MAX_malloc(len);
	strcpy(buf, the_val);
	node->AddAppDataChunk(POLYGON_COUNTER_CLASS_ID, UTILITY_CLASS_ID, id, (DWORD)len, buf);
	SetSaveRequiredFlag(TRUE);
}
BOOL plMultistageBehComponent::IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
    case WM_COMMAND:
        if (HIWORD(wParam) == BN_CLICKED)
        {
            // Adding a new stage
            if (LOWORD(wParam) == IDC_ADD)
            {
                // Create the new stage and give it a default name.
                plBaseStage* stage = new plStandardStage;
                int count = fStages.size();
                fStages.push_back(stage);
                char buf[64];
                sprintf(buf, "Stage %d", count);
                stage->SetName(buf);

                // Add the new stage to the list and make sure the list is wide enough
                HWND hList = GetDlgItem(fDlg, IDC_STAGE_LIST);
                int idx = ListView_AddString(hList, stage->GetName().c_str());
                ListView_SetColumnWidth(hList, 0, LVSCW_AUTOSIZE);
                ListView_SetItemState(hList, idx, LVIS_SELECTED, LVIS_SELECTED);

                // Put up the new stages dialog
                IDestroyStageDlg();
                fCurStage = idx;
                ICreateStageDlg();

                SetSaveRequiredFlag();
            }
            // Removing the selected stage
            else if (LOWORD(wParam) == IDC_REMOVE)
            {
                HWND hList = GetDlgItem(fDlg, IDC_STAGE_LIST);

                int sel = ListView_GetNextItem(hList, -1, LVNI_SELECTED);
                if (sel != -1)
                {
                    IDestroyStageDlg();

                    plBaseStage* stage = fStages[sel];
                    fStages.erase(fStages.begin()+sel);
                    delete stage;
                    ListView_DeleteItem(hList, sel);

                    SetSaveRequiredFlag();
                }
            }
            else if (LOWORD(wParam) == IDC_FREEZE_PHYS)
            {
                fFreezePhys = (Button_GetCheck((HWND)lParam) == BST_CHECKED);
                SetSaveRequiredFlag();
            }
            else if (LOWORD(wParam) == IDC_SMART_SEEK)
            {
                fSmartSeek = (Button_GetCheck((HWND)lParam) == BST_CHECKED);
                SetSaveRequiredFlag();
            }
            else if (LOWORD(wParam) == IDC_MULTI_REVERSE_CTL)
            {
                fReverseFBOnRelease = (Button_GetCheck((HWND)lParam) == BST_CHECKED);
                SetSaveRequiredFlag();
            }
            return TRUE;
        }
        break;

    case WM_NOTIFY:
        {
            NMHDR *nmhdr = (NMHDR*)lParam;
            if (nmhdr->idFrom == IDC_STAGE_LIST)
            {
                switch (nmhdr->code)
                {
                // Stop Max from reading keypresses while the list has focus
                case NM_SETFOCUS:
                    plMaxAccelerators::Disable();
                    return TRUE;
                case NM_KILLFOCUS:
                    plMaxAccelerators::Enable();
                    return TRUE;

                // The edit box this creates kills the focus on the listbox,
                // so add an extra disable to ignore it
                case LVN_BEGINLABELEDIT:
                    plMaxAccelerators::Disable();
                    return TRUE;

                // Finishing changing the name of a stage
                case LVN_ENDLABELEDIT:
                    {
                        NMLVDISPINFO *di = (NMLVDISPINFO*)lParam;
                        const char *name = di->item.pszText;

                        // If the name was changed...
                        if (name && *name != '\0')
                        {
                            plBaseStage* stage = fStages[fCurStage];
                            stage->SetName(name);

                            // Make sure the column is wide enough
                            int width = ListView_GetStringWidth(nmhdr->hwndFrom, name)+10;
                            if (width > ListView_GetColumnWidth(nmhdr->hwndFrom, 0))
                            {
                                ListView_SetColumnWidth(nmhdr->hwndFrom, 0, width);
                            }

                            // Return true to keep the changes
                            SetWindowLong(hDlg, DWL_MSGRESULT, TRUE);
                        }
                        
                        plMaxAccelerators::Enable();
                    }
                    return TRUE;

                case LVN_ITEMCHANGED:
                    {
                        int sel = ListView_GetNextItem(nmhdr->hwndFrom, -1, LVNI_SELECTED);
                        IDestroyStageDlg();
                        if (sel != -1 && sel != fCurStage)
                        {
                            fCurStage = sel;
                            ICreateStageDlg();
                        }
                    }
                    return TRUE;
                }
            }
        }
        break;
    }

    return FALSE;
}
Beispiel #4
0
BOOL plComponentDlg::DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
    case WM_INITDIALOG:
        fhDlg = hDlg;
        IAddComponentsRecur(GetDlgItem(hDlg, IDC_TREE), (plMaxNode*)GetCOREInterface()->GetRootNode());

        ICreateMenu();
        ICreateRightClickMenu();
        return TRUE;

    case WM_SIZING:
        IPositionControls((RECT*)lParam, wParam);
        return TRUE;

    case WM_ACTIVATE:
        if (LOWORD(wParam) == WA_INACTIVE)
            plMaxAccelerators::Enable();
        else
            plMaxAccelerators::Disable();
        return TRUE;

    case WM_COMMAND:
        if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDCANCEL)
        {
            ShowWindow(hDlg, SW_HIDE);
            fInterface->UnRegisterDlgWnd(hDlg);
            return TRUE;
        }
        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_ATTACH)
        {
            IAttachTreeSelection();
            return TRUE;
        }
        else if (HIWORD(wParam) == EN_KILLFOCUS && LOWORD(wParam) == IDC_COMMENTS)
        {
            IGetComment();
            return TRUE;
        }
        // "Refresh" menu item
        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == ID_REFRESH)
        {
            IRefreshTree();
            return TRUE;
        }
        // "Remove unused components" menu item
        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == ID_REMOVE_UNUSED)
        {
            IRemoveUnusedComps();
            return TRUE;
        }
        // Item selected from 'New' menu
        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) >= MENU_ID_START)
        {
            ClassDesc *desc = plComponentMgr::Inst().Get(LOWORD(wParam)-MENU_ID_START);
            // If this is a component type (not a category)
            if (desc)
            {
                // Create an object of that type and a node to reference it
                Object *obj = (Object*)GetCOREInterface()->CreateInstance(desc->SuperClassID(), desc->ClassID());
                INode *node = GetCOREInterface()->CreateObjectNode(obj);

                plComponentBase *comp = (plComponentBase*)obj;
                node->Hide(!comp->AllowUnhide());
                node->Freeze(TRUE);

                // Add the new component to the tree
                HWND hTree = GetDlgItem(hDlg, IDC_TREE);
                HTREEITEM item = IAddComponent(hTree, (plMaxNode*)node);
                TreeView_SelectItem(hTree, item);
                TreeView_EnsureVisible(hTree, item);
            }
        }
        break;

    case WM_NOTIFY:
        NMHDR *nmhdr = (NMHDR*)lParam;
        if (nmhdr->idFrom == IDC_TREE)
        {
            switch (nmhdr->code)
            {
            case TVN_SELCHANGED:
                {
                    NMTREEVIEW *tv = (NMTREEVIEW*)lParam;

                    IGetComment();

                    bool isComponent = IIsComponent(tv->itemNew.lParam);

                    // If the new selection is a component, enable the attach button and comment field
                    EnableWindow(GetDlgItem(hDlg, IDC_ATTACH), isComponent);
                    SendDlgItemMessage(hDlg, IDC_COMMENTS, EM_SETREADONLY, !isComponent, 0);

                    if (isComponent)
                    {
                        fCommentNode = (plMaxNode*)tv->itemNew.lParam;
                        
                        TSTR buf;
                        fCommentNode->GetUserPropBuffer(buf);
                        SetDlgItemText(hDlg, IDC_COMMENTS, buf);
                    }
                    else
                    {
                        fCommentNode = nil;
                        SetDlgItemText(hDlg, IDC_COMMENTS, "");
                    }

                    return TRUE;
                }
                break;

            case TVN_BEGINLABELEDIT:
                // If this isn't a component, don't allow the edit
                if (!IIsComponent(((NMTVDISPINFO*)lParam)->item.lParam))
                {
                    SetWindowLong(hDlg, DWL_MSGRESULT, TRUE);
                    return TRUE;
                }

                // The edit box this creates kills the focus on our window, causing
                // accelerators to be enabled.  Add an extra disable to counteract that.
                plMaxAccelerators::Disable();

                return TRUE;

            // Finishing changing the name of a component
            case TVN_ENDLABELEDIT:
                {
                    NMTVDISPINFO *di = (NMTVDISPINFO*)lParam;
                    char* text = di->item.pszText;
                    // If the name was changed...
                    if (text && *text != '\0')
                    {
                        // Update the name of the node
                        plMaxNode *node = IGetTreeSelection();
                        node->SetName(text);

                        // Update the name in the panel too
                        if (plComponentUtil::Instance().IsOpen())
                            plComponentUtil::Instance().IUpdateNodeName(node);

                        // Make sure Max knows the file was changed
                        SetSaveRequiredFlag();

                        // Return true to keep the changes
                        SetWindowLong(hDlg, DWL_MSGRESULT, TRUE);
                    }

                    plMaxAccelerators::Enable();
                }
                return TRUE;

            // User double-clicked.  Select the objects the selected component is attached to.
            case NM_DBLCLK:
                ISelectTreeSelection();
                return TRUE;

            case NM_RCLICK:
                IOpenRightClickMenu();
                return TRUE;
                
            case TVN_KEYDOWN:
                // User pressed delete
                if (((NMTVKEYDOWN*)lParam)->wVKey == VK_DELETE)
                {
                    IDeleteComponent(IGetTreeSelection());
                    return TRUE;
                }
                break;
            }
        }
        break;
    }

    return FALSE;
}
Beispiel #5
0
void ResetXForm::ResetNodes(const INodeTab& nodesToReset)
{
	Interface *ip = GetCOREInterface();
	for (int i = 0; i < nodesToReset.Count(); i++) {
		INode *node = nodesToReset[i];
		if (!node || node->IsGroupMember() || node->IsGroupHead()) 
			continue;
		if (SelectedAncestor(node)) 
			continue;

		Matrix3 ntm, ptm, rtm(1), piv(1), tm;
		
		// Get Parent and Node TMs
		ntm = node->GetNodeTM(ip->GetTime());
		ptm = node->GetParentTM(ip->GetTime());
		
		// Compute the relative TM
		ntm = ntm * Inverse(ptm);
		
		// The reset TM only inherits position
		rtm.SetTrans(ntm.GetTrans());
		
		// Set the node TM to the reset TM		
		tm = rtm*ptm;
		node->SetNodeTM(ip->GetTime(), tm);

		// Compute the pivot TM
		piv.SetTrans(node->GetObjOffsetPos());
		PreRotateMatrix(piv,node->GetObjOffsetRot());
		ApplyScaling(piv,node->GetObjOffsetScale());
		
		// Reset the offset to 0
		node->SetObjOffsetPos(Point3(0,0,0));
		node->SetObjOffsetRot(IdentQuat());
		node->SetObjOffsetScale(ScaleValue(Point3(1,1,1)));

		// Take the position out of the matrix since we don't reset position
		ntm.NoTrans();

		// Apply the offset to the TM
		ntm = piv * ntm;

		// Apply a derived object to the node's object
		Object *obj = node->GetObjectRef();
		IDerivedObject *dobj = CreateDerivedObject(obj);
		
		// Create an XForm mod
		SimpleMod *mod = (SimpleMod*)ip->CreateInstance(
			OSM_CLASS_ID,
			Class_ID(CLUSTOSM_CLASS_ID,0));

		// Apply the transformation to the mod.
		SetXFormPacket pckt(ntm);
		mod->tmControl->SetValue(ip->GetTime(),&pckt);

		// Add the modifier to the derived object.
		dobj->SetAFlag(A_LOCK_TARGET); // RB 3/11/99: When the macro recorder is on the derived object will get deleted unless it is locked.
		dobj->AddModifier(mod);
		dobj->ClearAFlag(A_LOCK_TARGET);

		// Replace the node's object
		node->SetObjectRef(dobj);
	}
	
//	Why on earth were we clearing the undo stack?
//	GetSystemSetting(SYSSET_CLEAR_UNDO);
	ip->RedrawViews(ip->GetTime());
	SetSaveRequiredFlag(TRUE);
}