Exemple #1
0
/*
 * SendOfferEndDialog:  Perform appropriate cleanup when Send Offer dialog ends.
 */
void SendOfferEndDialog(HWND hDlg)
{
    /* Destroy SendInfo->items, and receive_items, since both came from server.
     */
    SendInfo->items = ObjectListDestroy(SendInfo->items);
    receive_items = ObjectListDestroy(receive_items);

    DestroyWindow(hDlg);
    hSendOfferDlg = NULL;
}
Exemple #2
0
/*
 * RcvOfferEndDialog:  Perform appropriate cleanup when Receive Offer dialog ends.
 */
void RcvOfferEndDialog(HWND hDlg)
{
    /* Destroy RcvInfo->items, since it comes from server.
     * Delete send_items, since it came from inventory.
     */
    RcvInfo->items = ObjectListDestroy(RcvInfo->items);
    send_items = ObjectListDestroy(send_items);

    DestroyWindow(hDlg);
    hRcvOfferDlg = NULL;
}
Exemple #3
0
/*
 * UserStartDrag:  User wants to drag object under mouse pointer.  If there is no
 *   object there, do nothing.  If there is more than one object, ask user which
 *   one to pick up.  If there is exactly one, begin dragging object.
 */
void UserStartDrag(void)
{
   list_type objects, sel_list, l;
   int x, y;
   object_node *obj;

   /* Find out where in the the room the user clicked on, if anywhere */
   if (!MouseToRoom(&x, &y))
      return;

   objects = GetObjects3D(x, y, CLOSE_DISTANCE, OF_GETTABLE | OF_CONTAINER, 0);
   if (objects == NULL)
      return;

   if (objects->next == NULL)
   {
      SetCapture(hMain);
      capture = True;
      obj = (object_node *) objects->data;
      drag_object = obj->id;
      SetMainCursor(LoadCursor(hInst, MAKEINTRESOURCE(IDC_GETCURSOR)));
   }
   else
   {
      sel_list = DisplayLookList(hMain, GetString(hInst, IDS_GET), objects, LD_SINGLEAUTO);
      
      for (l = sel_list; l != NULL; l = l->next)
	 RequestPickup(((room_contents_node *) (l->data))->obj.id);

      ObjectListDestroy(sel_list);
   }

   list_delete(objects);
}
Exemple #4
0
/*
 * Counteroffered:  Player made a counteroffer; now display list of items
 *   in Receive Offer dialog.
 */
void Counteroffered(list_type items)
{
    if (hRcvOfferDlg == NULL)
    {
        ObjectListDestroy(items);
        return;
    }
    SendMessage(hRcvOfferDlg, BK_COUNTEROFFERED, 0, (LPARAM) items);
}
Exemple #5
0
void FreeSpells(void)
{
   list_type l;

   for (l = spells; l != NULL; l = l->next)
      MenuRemoveSpell( (spell *) (l->data));

   spells = ObjectListDestroy(spells);
   temp_list = list_delete(temp_list);
}
Exemple #6
0
BOOL CALLBACK RcvOfferDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    static HWND hwndSend, hwndReceive;

    switch (message)
    {
    case WM_INITDIALOG:
        CenterWindow(hDlg, hMain);

        hwndSend = GetDlgItem(hDlg, IDC_OFFERSEND);
        hwndReceive = GetDlgItem(hDlg, IDC_OFFERRECEIVE);
        SendMessage(hDlg, BK_SETDLGFONTS, 0, 0);

        // Set up owner drawn boxes
        SetWindowLong(hwndSend, GWL_USERDATA, OD_DRAWOBJ);
        SetWindowLong(hwndReceive, GWL_USERDATA, OD_DRAWOBJ);

        RcvInfo = (RcvOfferDialogStruct *) lParam;

        /* Display offered items in list */
        ItemListSetContents(hwndReceive, RcvInfo->items, True);

        /* Subclass list boxes */
        lpfnDefListProc = (WNDPROC) GetWindowLong(hwndSend, GWL_WNDPROC);
        SubclassWindow(hwndSend, OfferListProc);
        SubclassWindow(hwndReceive, OfferListProc);

        /* Display receiver's name */
        Edit_SetText(GetDlgItem(hDlg, IDC_OFFEREDIT),
                     LookupNameRsc(RcvInfo->sender_name));

        ShowWindow(hDlg, SW_HIDE);

        hRcvOfferDlg = hDlg;
        return TRUE;

    case WM_ACTIVATE:
        if (wParam == 0)
            hCurrentDlg = NULL;
        else hCurrentDlg = hDlg;
        return TRUE;

    case BK_SETDLGFONTS:
        SetWindowFont(GetDlgItem(hDlg, IDC_OFFEREDIT), GetFont(FONT_LIST), TRUE);
        return TRUE;

    case BK_SETDLGCOLORS:
        InvalidateRect(hDlg, NULL, TRUE);
        return TRUE;

    case WM_COMPAREITEM:
        return ItemListCompareItem(hDlg, (const COMPAREITEMSTRUCT *) lParam);
    case WM_MEASUREITEM:
        ItemListMeasureItem(hDlg, (MEASUREITEMSTRUCT *) lParam);
        return TRUE;
    case WM_DRAWITEM:
        return ItemListDrawItemNoSelect(hDlg, (const DRAWITEMSTRUCT *)(lParam));

        HANDLE_MSG(hDlg, WM_CTLCOLOREDIT, DialogCtlColor);
        HANDLE_MSG(hDlg, WM_CTLCOLORLISTBOX, DialogCtlColor);
        HANDLE_MSG(hDlg, WM_CTLCOLORSTATIC, DialogCtlColor);
        HANDLE_MSG(hDlg, WM_CTLCOLORDLG, DialogCtlColor);

        HANDLE_MSG(hDlg, WM_INITMENUPOPUP, InitMenuPopupHandler);

    case WM_CLOSE:
        SendCancelOffer();
    /* fall through */

    case BK_OFFERDONE:
        RcvOfferEndDialog(hDlg);
        return TRUE;

    case BK_COUNTEROFFERED:
        /* Display items we counteroffered */
        send_items = (list_type) lParam;
        ItemListSetContents(hwndSend, send_items, True);
        return TRUE;

    case WM_COMMAND:
        switch(GET_WM_COMMAND_ID(wParam, lParam))
        {
        case IDC_OFFERSEND:
        case IDC_OFFERRECEIVE:
            /* Double click ==> look at item */
            if (GET_WM_COMMAND_CMD(wParam, lParam) == LBN_DBLCLK)
            {
                RequestLook(ItemListGetId(GET_WM_COMMAND_HWND(wParam, lParam)));
                SetDescParams(hDlg, DESC_NONE);
            }
            return TRUE;

        case IDC_SETITEMS:
            /* Close any other look dialogs that are up */
            AbortLookList();

            /* Get list of items from inventory & tell server */
            send_items = UserInventoryList(hDlg, GetString(hInst, IDS_OFFERITEMS));

        /* fall through */

        case IDOK:
            /* Send counteroffer */
            RequestCounteroffer(send_items);
            send_items = ObjectListDestroy(send_items);

            EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
            EnableWindow(GetDlgItem(hDlg, IDC_SETITEMS), FALSE);

            SetWindowText(GetDlgItem(hDlg, IDC_MESSAGE), GetString(hInst, IDS_WAITRESPONSE));
            return TRUE;

        case IDCANCEL:
            SendCancelOffer();
            RcvOfferEndDialog(hDlg);
            return TRUE;
        }
        break;
    }
    return FALSE;
}