コード例 #1
0
void plResponderProc::MoveCommand(int oldIdx, int newIdx)
{
    // Move data
    int insertIdx = (newIdx > oldIdx) ? newIdx+1 : newIdx;
    int deleteIdx = (newIdx < oldIdx) ? oldIdx+1 : oldIdx;

    ReferenceTarget *targ = fStatePB->GetReferenceTarget(kStateCmdParams, 0, oldIdx);
    fStatePB->Insert(kStateCmdParams, insertIdx, 1, &targ);
    fStatePB->Delete(kStateCmdParams, deleteIdx, 1);

    ReferenceTarget *wait = fStatePB->GetReferenceTarget(kStateCmdWait, 0, oldIdx);
    fStatePB->Insert(kStateCmdWait, insertIdx, 1, &wait);
    fStatePB->Delete(kStateCmdWait, deleteIdx, 1);

    BOOL oldEnabled = fStatePB->GetInt(kStateCmdEnabled, 0, oldIdx);
    BOOL newEnabled = fStatePB->GetInt(kStateCmdEnabled, 0, newIdx);
    fStatePB->SetValue(kStateCmdEnabled, 0, oldEnabled, newIdx);
    fStatePB->SetValue(kStateCmdEnabled, 0, newEnabled, oldIdx);

    ResponderWait::CmdMoved(fStatePB, oldIdx, newIdx);

    LoadList();

    // Reselect item
    // (This doesn't send the LBN_SELCHANGE message so we do that manually)
    ListBox_SetCurSel(fhList, newIdx);
    ICreateCmdRollups();
}
コード例 #2
0
BOOL OrientConstRotation::DeleteTarget(int selection){
	int ct = pblock->Count(orientation_target_list);
	if (selection >= 0 && selection < pblock->Count(orientation_target_list)){
//		theHold.Begin();
		pblock->Delete(orientation_target_weight, selection, 1);
		pblock->Delete(orientation_target_list, selection, 1);
//		theHold.Accept(GetString(IDS_AG_ORIENTATION_LIST));
		return TRUE;
	}
	else
		return FALSE;

}
コード例 #3
0
void plResponderProc::RemoveCurCommand()
{
    int idx = ListBox_GetCurSel(fhList);
    if (idx == LB_ERR)
        return;

    // Destroy the current rollup, since it's this guy
    IRemoveCmdRollups();

    // Delete all traces of this command
    fStatePB->Delete(kStateCmdParams, idx, 1);
    fStatePB->Delete(kStateCmdWait, idx, 1);
    fStatePB->Delete(kStateCmdEnabled, idx, 1);
    ListBox_DeleteString(fhList, idx);

    // Patch the wait commands
    ResponderWait::CmdRemoved(fStatePB, idx);
    
    fCmdIdx = -1;
}
コード例 #4
0
BOOL plResponderProc::DlgProc(TimeValue t, IParamMap2 *pm, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    static UINT dragListMsg = 0;

    if (dragListMsg != 0 && msg == dragListMsg)
        if (DragListProc(hWnd, (DRAGLISTINFO*)lParam))
            return TRUE;

    switch (msg)
    {
    case WM_INITDIALOG:
        {
            if (!fhMenu)
                ICreateMenu();

            fhDlg = hWnd;
            fhList = GetDlgItem(fhDlg, IDC_CMD_LIST);
            fCurState = 0;
            fCmdIdx = -1;
            
            fPB = pm->GetParamBlock();
            fComp = (plResponderComponent*)fPB->GetOwner();

            fComp->IFixOldPB();

            LoadState();
            
            // Make it so the user can drag commands to different positions
            dragListMsg = RegisterWindowMessage(DRAGLISTMSGSTRING);
            MakeDragList(GetDlgItem(hWnd, IDC_CMD_LIST));

            // Setup the State Name combo
            HWND hStateName = GetDlgItem(hWnd, IDC_STATE_COMBO);
            ComboBox_LimitText(hStateName, 256);

// I give up, Windows doesn't want to tell me the real font size
#if 0//def CUSTOM_DRAW
            // TEMP
            HDC hDC = GetDC(hStateName);
            HFONT sysFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
            HFONT oldFont = SelectFont(hDC, sysFont);

            TEXTMETRIC tm;
            GetTextMetrics(hDC, &tm);
            ComboBox_SetItemHeight(hStateName, 0, tm.tmHeight+2);

            DeleteFont(SelectFont(hDC, oldFont));
            ReleaseDC(hStateName, hDC);
#endif

            // Add the commands
            int idx = ComboBox_AddString(hStateName, "Add State");
            ComboBox_SetItemData(hStateName, idx, kStateAdd);
            idx = ComboBox_AddString(hStateName, "Remove Current State");
            ComboBox_SetItemData(hStateName, idx, kStateRemove);
            idx = ComboBox_AddString(hStateName, "Set Current as Default");
            ComboBox_SetItemData(hStateName, idx, kStateDefault);
            idx = ComboBox_AddString(hStateName, "Copy Current State");
            ComboBox_SetItemData(hStateName, idx, kStateCopy);

            HWND hSwitchCombo = GetDlgItem(hWnd, IDC_SWITCH_COMBO);

            int numStates = fPB->Count(kResponderStateName);
            for (int i = 0; i < numStates; i++)
            {
                const char *stateName = fPB->GetStr(kResponderStateName, 0, i);
                char buf[128];
                if (!stateName || *stateName == '\0')
                {
                    sprintf(buf, "State %d", i+1);
                    stateName = buf;
                }
                ComboBox_InsertString(hStateName, i, stateName);
                ComboBox_AddString(hSwitchCombo, stateName);
            }

            ComboBox_SetCurSel(hStateName, fCurState);

            ComboBox_SetCurSel(hSwitchCombo, fStatePB->GetInt(kStateCmdSwitch));
        }
        return TRUE;

#ifdef CUSTOM_DRAW
    case WM_DRAWITEM:
        if (wParam == IDC_STATE_COMBO)
        {
            IDrawComboItem((DRAWITEMSTRUCT*)lParam);
            return TRUE;
        }
        break;
#endif

    case WM_SETCURSOR:
        {
            if (HIWORD(lParam) == WM_RBUTTONDOWN && HWND(wParam) == GetDlgItem(hWnd, IDC_CMD_LIST))
            {
                ICmdRightClick(HWND(wParam));
                return TRUE;
            }
        }
        break;
    
    case WM_COMMAND:
        if (HIWORD(wParam) == BN_CLICKED)
        {
            if (LOWORD(wParam) == IDC_ADD_ACTIVATOR)
            {
                // Adding an activator.  Set it and refresh the UI to show it in our list.
                plPick::Activator(fPB, kResponderActivators, false);
                pm->Invalidate(kResponderActivators);
                return TRUE;
            }
            else if (LOWORD(wParam) == IDC_ADD_CMD)
            {
                AddCommand();
                return TRUE;
            }
            // Remove the currently selected condition
            else if (LOWORD(wParam) == IDC_REMOVE_CMD)
            {
                RemoveCurCommand();
                return TRUE;
            }
        }
        else if (HIWORD(wParam) == LBN_SELCHANGE && LOWORD(wParam) == IDC_CMD_LIST)
        {
            ICreateCmdRollups();
            return TRUE;
        }
        else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_SWITCH_COMBO)
        {
            int sel = ComboBox_GetCurSel((HWND)lParam);
            if (sel != CB_ERR)
                fStatePB->SetValue(kStateCmdSwitch, 0, sel);
        }
        else if (LOWORD(wParam) == IDC_STATE_COMBO)
        {
            HWND hCombo = (HWND)lParam;
            int code = HIWORD(wParam);

            // Disable accelerators when the combo has focus, so that new names can be typed in
            if (code == CBN_SETFOCUS)
            {
                plMaxAccelerators::Disable();
                return TRUE;
            }
            else if (code == CBN_KILLFOCUS)
            {
                plMaxAccelerators::Enable();
                return TRUE;
            }
            // State name changed, save it in the PB
            else if (code == CBN_EDITCHANGE)
            {
                char buf[256];
                ComboBox_GetText(hCombo, buf, sizeof(buf));
                const char *curName = fPB->GetStr(kResponderStateName, 0, fCurState);
                if (!curName || strcmp(buf, curName))
                {
                    HWND hSwitch = GetDlgItem(hWnd, IDC_SWITCH_COMBO);
                    int sel = ComboBox_GetCurSel(hSwitch);
                    ComboBox_DeleteString(hSwitch, fCurState);
                    ComboBox_InsertString(hSwitch, fCurState, buf);
                    ComboBox_SetCurSel(hSwitch, sel);
                    
                    fPB->SetValue(kResponderStateName, 0, buf, fCurState);
                    ComboBox_DeleteString(hCombo, fCurState);
                    ComboBox_InsertString(hCombo, fCurState, buf);
//                  ComboBox_SetCurSel(hCombo, fCurState);
                }

                return TRUE;
            }
            else if (code == CBN_SELCHANGE)
            {
                int sel = ComboBox_GetCurSel(hCombo);
                int type = ComboBox_GetItemData(hCombo, sel);

                if (type == kStateAdd)
                {
                    IParamBlock2 *pb = CreateParameterBlock2(&gStateBlock, nil);
                    fCurState = AddState(pb);
                    fCmdIdx = -1;
                }
                else if (type == kStateRemove)
                {
                    int count = fPB->Count(kResponderState);
                    // Don't let the user remove the last state
                    if (count == 1)
                    {
                        hsMessageBox("You must have at least one state.", "Error", hsMessageBoxNormal);
                        ComboBox_SetCurSel(hCombo, fCurState);
                        return TRUE;
                    }
                    // Verify that the user really wants to delete the state
                    else
                    {
                        int ret = hsMessageBox("Are you sure you want to remove this state?", "Verify Remove", hsMessageBoxYesNo);
                        if (ret == hsMBoxNo)
                        {
                            ComboBox_SetCurSel(hCombo, fCurState);
                            return TRUE;
                        }
                    }

                    fPB->Delete(kResponderState, fCurState, 1);
                    fPB->Delete(kResponderStateName, fCurState, 1);

                    ComboBox_DeleteString(hCombo, fCurState);
                    ComboBox_SetCurSel(hCombo, 0);

                    HWND hSwitch = GetDlgItem(hWnd, IDC_SWITCH_COMBO);
                    ComboBox_DeleteString(hSwitch, fCurState);

                    // If the deleted state was the default, set the default to the first
                    int defState = fPB->GetInt(kResponderStateDef);
                    if (fCurState == defState)
                        fPB->SetValue(kResponderStateDef, 0, 0);
                    else if (fCurState < defState)
                        fPB->SetValue(kResponderStateDef, 0, defState-1);

                    // Patch up the switch commands
                    for (int i = fCurState; i < fPB->Count(kResponderState); i++)
                    {
                        IParamBlock2 *pb = (IParamBlock2*)fPB->GetReferenceTarget(kResponderState, 0, i);

                        int switchState = pb->GetInt(kStateCmdSwitch);
                        // TODO: might want to warn about this
                        if (switchState == fCurState)
                            pb->SetValue(kStateCmdSwitch, 0, 0);
                        else if (switchState > fCurState)
                            pb->SetValue(kStateCmdSwitch, 0, switchState-1);
                    }

                    fCurState = 0;
                    fCmdIdx = -1;
                }
                else if (type == kStateDefault)
                {
                    // Set the current state as the default
                    fPB->SetValue(kResponderStateDef, 0, fCurState);
                    ComboBox_SetCurSel(hCombo, fCurState);
                }
                else if (type == kStateCopy)
                {
                    // Clone the state PB
                    IParamBlock2 *origPB = (IParamBlock2*)fPB->GetReferenceTarget(kResponderState, 0, fCurState);
                    IParamBlock2 *copyPB = (IParamBlock2*)origPB->Clone(gMyRemapDir);
                    fCurState = AddState(copyPB);
                    fCmdIdx = -1;
                }
                else
                {
                    fCurState = sel;
                    fCmdIdx = -1;
                }

                LoadState();

                return TRUE;
            }
        }
    }

    return FALSE;
}
コード例 #5
0
BOOL plClothingComponentProc::DlgProc(TimeValue t, IParamMap2 *pm, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    IParamBlock2 *pb = pm->GetParamBlock();
    HWND hList = GetDlgItem(hWnd, IDC_CLOTHING_LIST);
    HWND hGroup = GetDlgItem(hWnd, IDC_CLOTHING_GROUP);
    HWND hType = GetDlgItem(hWnd, IDC_CLOTHING_TYPE);
    HWND hLOD = GetDlgItem(hWnd, IDC_COMP_LOD_CLOTHING_STATE);
    switch (msg)
    {
    case WM_INITDIALOG:
        {
            ListBox_ResetContent(hList);
            int i;
            for (i = 0; i < pb->Count(plClothingComponent::kMaterials); i++)
                ListBox_AddString(hList, pb->GetMtl(ParamID(plClothingComponent::kMaterials), 0, i)->GetName());

            ListBox_SetCurSel(hList, -1);

            for (i = 0; i < plClothingMgr::kMaxGroup; i++)
                ComboBox_AddString(hGroup, plClothingMgr::GroupStrings[i]);
            ComboBox_SetCurSel(hGroup, pb->GetInt(plClothingComponent::kGroup));

            for (i = 0; i < plClothingMgr::kMaxType; i++)
                ComboBox_AddString(hType, plClothingMgr::TypeStrings[i]);
            ComboBox_SetCurSel(hType, pb->GetInt(plClothingComponent::kType));

            ComboBox_AddString(hLOD, "High");
            ComboBox_AddString(hLOD, "Medium");
            ComboBox_AddString(hLOD, "Low");
            ComboBox_SetCurSel(hLOD, pb->GetInt(plClothingComponent::kLODState));
        }
        return TRUE;


    case WM_COMMAND:
        if (HIWORD(wParam) == BN_CLICKED)
        {
            if (LOWORD(wParam) == IDC_CLOTHING_ADD)
            {
                Mtl *pickedMtl = plPickMaterialMap::PickMaterial(plMtlCollector::kClothingMtlOnly);
                if (pickedMtl != nil)
                {
                    LRESULT stringIdx = ListBox_FindStringExact(hList, -1, pickedMtl->GetName());
                    if (stringIdx == LB_ERR) // It's not already there, go and add it
                    {
                        pb->Append(ParamID(plClothingComponent::kMaterials), 1, &pickedMtl, 0);
                        ListBox_AddString(hList, pickedMtl->GetName());
                    }
                }
                return TRUE;
            }
            // Remove the currently selected material
            else if (LOWORD(wParam) == IDC_CLOTHING_REMOVE)
            {
                int sel = ListBox_GetCurSel(hList);
                if (sel != LB_ERR)
                {
                    pb->Delete(plClothingComponent::kMaterials, sel, 1);
                    ListBox_DeleteString(hList, sel);
                }
                return TRUE;
            }
            else if( LOWORD( wParam ) == IDC_CLOTHING_CLEARMESH )
            {
                int state = pb->GetInt(plClothingComponent::kLODState);
                pb->SetValue(plClothingComponent::kMeshNodeTab, 0, (INode*)nil, state );
                pb->Reset(plClothingComponent::kMeshNodeAddBtn);
            }
        }
        else if (LOWORD(wParam) == IDC_CLOTHING_GROUP)
        {
            int setIdx = ComboBox_GetCurSel(hGroup);
            pb->SetValue(plClothingComponent::kGroup, 0, setIdx);

            return TRUE;
        }
        else if (LOWORD(wParam) == IDC_CLOTHING_TYPE)
        {
            int setIdx = ComboBox_GetCurSel(hType);
            pb->SetValue(plClothingComponent::kType, 0, setIdx);

            return TRUE;
        }
        else
        {
            int state = pb->GetInt(plClothingComponent::kLODState);
                
            INode *node = pb->GetINode(plClothingComponent::kMeshNodeAddBtn);
            if (node)
                pb->SetValue(plClothingComponent::kMeshNodeTab, 0, node, state);

            if(LOWORD(wParam) == IDC_COMP_LOD_CLOTHING_STATE && HIWORD(wParam) == CBN_SELCHANGE)
            {
                int idx = SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0);
                pb->SetValue(plClothingComponent::kLODState, 0, idx);
            
                node = pb->GetINode(plClothingComponent::kMeshNodeTab, 0, idx);
                if (node)
                    pb->SetValue(plClothingComponent::kMeshNodeAddBtn, 0, node);
                else
                    pb->Reset(plClothingComponent::kMeshNodeAddBtn);

                return TRUE;
            }
        }
    }

    return FALSE;
}