// Purpose: called by the default context menu. Gives an option to merge // extra commands into the menu. HRESULT OnDfmMergeContextMenu(IDataObject* pdataobject, UINT /*uFlags*/, QCMINFO& qcminfo) { CCfShellIdList itemlist(pdataobject); if (itemlist.GetItemCount() == 1 && !CVVVItem(itemlist.GetItem(0)).IsFolder()) { // Add 'open' if only 1 item is selected. CMenu menu(true); menu.AddDefaultItem(ID_DFM_CMD_OPEN, L"&Open"); MergeMenus(qcminfo, menu); // Note: XP will automatic make first menu item the default. // Win98, ME and 2k don't do this, so must add as default item. } return S_OK; }
/* gain for an item */ void acquire(int blessing) { char otype; int index,id = ABORT; pob newthing; if (blessing < 0) { index = random_item(); if (index == ABORT) mprint("You feel fortunate."); else { print1("Smoke drifts out of your pack.... "); print2("Destroyed: "); nprint2(itemid(Player.possessions[index])); morewait(); dispose_lost_objects(1,Player.possessions[index]); } } else { newthing = ((pob) checkmalloc(sizeof(objtype))); /* DAG this assignment looks unneccessary */ newthing->id = -1; if (gamestatusp(CHEATED)) print1("Acquire which kind of item: !?][}{)/=%%\\& "); else print1("Acquire which kind of item: !?][}{)/=%%\\ "); otype = mgetc(); switch (otype) { case (POTION&0xff): if (blessing > 0) id = itemlist(POTIONID,NUMPOTIONS); else id = random_range(NUMPOTIONS); if (id < 0) print2("You feel stupid."); else make_potion(newthing,id); break; case (SCROLL&0xff): if (blessing > 0) id = itemlist(SCROLLID,NUMSCROLLS); else id = random_range(NUMSCROLLS); if (id < 0) print2("You feel stupid."); else make_scroll(newthing,id); break; case (RING&0xff): if (blessing > 0) id = itemlist(RINGID,NUMRINGS); else id = random_range(NUMRINGS); if (id < 0) print2("You feel stupid."); else make_ring(newthing,id); break; case (STICK&0xff): if (blessing > 0) id = itemlist(STICKID,NUMSTICKS); else id = random_range(NUMSTICKS); if (id < 0) print2("You feel stupid."); else make_stick(newthing,id); break; case (ARMOR&0xff): if (blessing > 0) id = itemlist(ARMORID,NUMARMOR); else id = random_range(NUMARMOR); if (id < 0) print2("You feel stupid."); else make_armor(newthing,id); break; case (SHIELD&0xff): if (blessing > 0) id = itemlist(SHIELDID,NUMSHIELDS); else id = random_range(NUMSHIELDS); if (id < 0) print2("You feel stupid."); else make_shield(newthing,id); break; case (WEAPON&0xff): if (blessing > 0) id = itemlist(WEAPONID,NUMWEAPONS); else id = random_range(NUMWEAPONS); if (id < 0) print2("You feel stupid."); else make_weapon(newthing,id); break; case (BOOTS&0xff): if (blessing > 0) id = itemlist(BOOTID,NUMBOOTS); else id = random_range(NUMBOOTS); if (id < 0) print2("You feel stupid."); else make_boots(newthing,id); break; case (CLOAK&0xff): if (blessing > 0) id = itemlist(CLOAKID,NUMCLOAKS); else id = random_range(NUMCLOAKS); if (id < 0) print2("You feel stupid."); else make_cloak(newthing,id); break; case (FOOD&0xff): if (blessing > 0) id = itemlist(FOODID,NUMFOODS); else id = random_range(NUMFOODS); if (id < 0) print2("You feel stupid."); else make_food(newthing,id); break; case (THING&0xff): if (blessing > 0) id = itemlist(THINGID,NUMTHINGS); else id = random_range(NUMTHINGS); if (id < 0) print2("You feel stupid."); else make_thing(newthing,id); break; case (ARTIFACT&0xff): if (gamestatusp(CHEATED)) id = itemlist(ARTIFACTID,NUMARTIFACTS); else id = -1; if (id < 0) print2("You feel stupid."); else make_artifact(newthing,id); break; default: print2("You feel stupid."); } xredraw(); if (id != ABORT) { if (blessing > 0) { newthing->known = 2; Objects[id].known = 1; } newthing->used = FALSE; gain_item(newthing); } else { /* DAG newthing allocated but was not freed... was YA memory leak */ /* use free() rather than free_obj() since newthing not initialized */ free( (char *) newthing ); } } }