예제 #1
0
/*
 * InventoryDialogProc:  Dialog procedure for inventory modeless dialog.
 */
BOOL CALLBACK InventoryDialogProc(HWND hwnd, UINT message, UINT wParam, LONG lParam)
{
    switch (message)
    {
    case WM_INITDIALOG:
        ShowWindow(hwnd, SW_HIDE);
        return FALSE;

    case WM_ERASEBKGND:
        return 1;

        HANDLE_MSG(hwnd, WM_VSCROLL, InventoryVScroll);

    case WM_DRAWITEM:
        InventoryRedraw();
        return TRUE;

    case WM_ACTIVATE:
        if (wParam == 0)
            *cinfo->hCurrentDlg = NULL;
        else *cinfo->hCurrentDlg = hwnd;
        return TRUE;

//	case WM_CTLCOLORSCROLLBAR:						// ajw
//		return (BOOL)hbrushScrollBack;
    }

    return FALSE;
}
예제 #2
0
/*
 * InventoryMoveCurrentItem:  Move the item with the inventory cursor, if any.
 *   Return True iff item moved.
 */
Bool InventoryMoveCurrentItem(int x, int y)
{
    int row, col;
    InvItem *item, *drop_position;

    item = InventoryGetCurrentItem();
    if (item == NULL)
        return False;

    // Find row and col in absolute coordinates
    col = x / INVENTORY_BOX_WIDTH;
    row = top_row + y / INVENTORY_BOX_HEIGHT;

    drop_position = (InvItem *) list_nth_item(items, row * cols + col);
    if (drop_position == NULL)
        return False;

    if (item->obj->id == drop_position->obj->id)
        return False;

    items = list_move_to_nth(items,(void *)item->obj->id,(void *)drop_position->obj->id,InventoryCompareIdItem);
    InventoryRedraw();

    RequestInventoryMove(item->obj->id, drop_position->obj->id);

    return True;
}
예제 #3
0
/*
 * InventoryRemoveItem:  Remove the object with the given id from the
 *   inventory display.
 */
void InventoryRemoveItem(ID id)
{
    InvItem *item;

    WindowBeginUpdate(hwndInv);

    item = (InvItem *) list_find_item(items, (void *) id, InventoryCompareIdItem);
    if (item == NULL)
    {
        debug(("Tried to remove nonexistent object %ld from inventory list", id));
        return;
    }

    items = list_delete_item(items, (void *) id, InventoryCompareIdItem);
    // Object itself freed elsewhere
    SafeFree(item);

    num_items--;
    InventoryScrollRange();
    /* See if we should remove scroll bar */
    if (num_items == rows * cols)
    {
        InventoryDisplayScrollbar();
        top_row = 0;
    }

    WindowEndUpdate(hwndInv);

    InventoryRedraw();
}
예제 #4
0
/*
 * InventoryVScroll:  User did something with inventory scroll bar.
 */
void InventoryVScroll(HWND hwnd, HWND hwndCtl, UINT code, int pos)
{
    int new_top;  // New top row index

    switch (code)
    {
    case SB_LINEUP:
        new_top = top_row - 1;
        break;

    case SB_LINEDOWN:
        new_top = top_row + 1;
        break;

    case SB_PAGEUP:
        new_top = top_row - rows;
        break;

    case SB_PAGEDOWN:
        new_top = top_row + rows;
        break;

    case SB_THUMBPOSITION:
        new_top = pos;
        break;

    case SB_THUMBTRACK:
        new_top = pos;
        break;

    case SB_BOTTOM:
        new_top = (num_items + cols - 1) / cols - rows;
        break;

    case SB_TOP:
        new_top = 0;
        break;

    default:
        // Pointless "SB_ENDSCROLL" added recently
        return;
    }
    new_top = max(new_top, 0);
    new_top = min(new_top, (num_items + cols - 1) / cols - rows);

    if (new_top != top_row)
    {
        top_row = new_top;
        InventoryRedraw();
        SetScrollPos(hwndInvScroll, SB_CTL, top_row, TRUE);
    }
}
예제 #5
0
/*
 * InterfaceRedrawModule:  Called when main window needs to be redrawn.
 */
void InterfaceRedrawModule(HDC hdc)
{
	UserAreaRedraw();
  InterfaceDrawElements(hdc);
  StatsDrawBorder();
  StatsMainRedraw();
  StatsDraw();
  if( StatsGetCurrentGroup() == STATS_INVENTORY )
  {
    InvalidateRect( GetHwndInv(), NULL, FALSE );
    ShowInventory(TRUE);
    InventoryRedraw();
  }
}
예제 #6
0
/*
 * InventoryCursorMove:  User requests the given cursor movement action.
 *   Move cursor.
 */
void InventoryCursorMove(int action)
{
    int dx = 0, dy = 0;
    int old_row, old_col, new_row, new_col;
    InvItem *item;

    switch (action)
    {
    case A_CURSORUP:
        dy = -1;
        break;
    case A_CURSORDOWN:
        dy = +1;
        break;
    case A_CURSORLEFT:
        dx = -1;
        break;
    case A_CURSORRIGHT:
        dx = +1;
        break;
    case A_CURSORUPLEFT:
        dx = -1;
        dy = -1;
        break;
    case A_CURSORUPRIGHT:
        dx = +1;
        dy = -1;
        break;
    case A_CURSORDOWNLEFT:
        dx = -1;
        dy = +1;
        break;
    case A_CURSORDOWNRIGHT:
        dx = +1;
        dy = +1;
        break;
    default:
        return;
    }

    new_col = (cursor_col + dx) % cols;
    if (new_col < 0)
        new_col += cols;

    new_row = max(0, cursor_row + dy);

    // See if we're going off end of inventory
    if (new_row * cols + new_col >= num_items)
        return;

    old_row = cursor_row;
    old_col = cursor_col;

    cursor_col = new_col;
    cursor_row = new_row;

    // Scroll inventory if necessary
    if (!InventoryItemVisible(cursor_row, cursor_col))
    {
        top_row += dy;
        InventoryRedraw();
        SetScrollPos(hwndInvScroll, SB_CTL, top_row, TRUE);
    }
    else // Otherwise, redraw cursor to show movement
    {
        item = (InvItem *) list_nth_item(items, old_row * cols + old_col);
        if (item != NULL)
            InventoryDrawSingleItem(item, old_row - top_row, old_col);
        item = (InvItem *) list_nth_item(items, cursor_row * cols + cursor_col);
        if (item != NULL)
            InventoryDrawSingleItem(item, cursor_row - top_row, cursor_col);
    }
}
예제 #7
0
/*
 * InventoryDrawItem:  Handle WM_DRAWITEM messages for inventory.
 */
Bool InventoryDrawItem(HWND hwnd, const DRAWITEMSTRUCT *lpdis)
{
    InventoryRedraw();
    return True;
}