void plResponderProc::AddCommand()
{
    RECT rect;
    GetWindowRect(GetDlgItem(fhDlg, IDC_ADD_CMD), &rect);

    // Create the popup menu and get the option the user selects
    SetForegroundWindow(fhDlg);
    int type = TrackPopupMenu(fhMenu, TPM_RIGHTALIGN | TPM_NONOTIFY | TPM_RETURNCMD, rect.left, rect.top, 0, fhDlg, NULL);
    PostMessage(fhDlg, WM_USER, 0, 0);

    if (type == 0)
        return;

    CmdID& cmdID = fMenuCmds[type];
    plResponderCmd *cmd = cmdID.first;
    int cmdIdx = cmdID.second;

    IParamBlock2 *cmdPB = cmd->CreatePB(cmdIdx);
    fStatePB->Append(kStateCmdParams, 1, (ReferenceTarget**)&cmdPB);

    IParamBlock2 *waitPB = ResponderWait::CreatePB();
    fStatePB->Append(kStateCmdWait, 1, (ReferenceTarget**)&waitPB);

    BOOL enabled = TRUE;
    fStatePB->Append(kStateCmdEnabled, 1, &enabled);

    const char* name = GetCommandName(fStatePB->Count(kStateCmdParams)-1);
    int idx = ListBox_AddString(fhList, name);
    ListBox_SetCurSel(fhList, idx);

    ICreateCmdRollups();
}
BOOL OrientConstRotation::AppendTarget(INode *target, float weight){

	if (target == NULL){
		float var = 50.0f;
		int ct = pblock->Count(orientation_target_list);
		int ctf = pblock->Count(orientation_target_weight);
		theHold.Begin();
		pblock->SetCount(orientation_target_list, ct + 1);
		pblock->SetValue(orientation_target_list, GetCOREInterface()->GetTime(), target, ct);
		pblock->Append(orientation_target_weight, 1, &var, 1);
		theHold.Accept(GetString(IDS_AG_ORIENTATION_LIST));
		return TRUE;
	}
	else if (!(target->TestForLoop(FOREVER,(ReferenceMaker *) this)!=REF_SUCCEED)) 
	{
		for (int i = 0; i < pblock->Count(orientation_target_list); i++){
			if (target == pblock->GetINode(orientation_target_list, GetCOREInterface()->GetTime(), i)){
				return FALSE; // the target is already in the targetlist
			}
		}
			
		theHold.Begin();
		pblock->Append(orientation_target_list, 1, &target, 1);
		pblock->Append(orientation_target_weight, 1, &weight, 1);
		theHold.Accept(GetString(IDS_AG_ORIENTATION_LIST));
		return TRUE;
	}
	return FALSE;


}
int plResponderProc::AddState(IParamBlock2 *pb)
{
    int idx = fPB->Append(kResponderState, 1, (ReferenceTarget**)&pb);
    pb->SetValue(kStateCmdSwitch, 0, idx);

    char *name = "";
    fPB->Append(kResponderStateName, 1, &name);

    HWND hCombo = GetDlgItem(fhDlg, IDC_STATE_COMBO);
    char buf[128];
    sprintf(buf, "State %d", idx+1);
    ComboBox_InsertString(hCombo, idx, buf);
    ComboBox_SetCurSel(hCombo, idx);

    HWND hSwitch = GetDlgItem(fhDlg, IDC_SWITCH_COMBO);
    ComboBox_AddString(hSwitch, buf);

    return idx;
}
Beispiel #4
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;
}