Beispiel #1
0
/*
 * SendMailInitialize:  Initialize dialog to reflect settings in "reply" variable.
 */
void SendMailInitialize(HWND hDlg, MailInfo *reply)
{
   HWND hRecipients;
   int i;

   /* Set recipients, separated by commas in list box */
   hRecipients = GetDlgItem(hDlg, IDC_RECIPIENTS);
   WindowBeginUpdate(hRecipients);
   for (i=0; i < reply->num_recipients; i++)
   {
      if (i != 0)
      {
	 Edit_SetSel(hRecipients, -1, -1);
	 Edit_ReplaceSel(hRecipients, ", ");
      }
      Edit_SetSel(hRecipients, -1, -1);
      Edit_ReplaceSel(hRecipients, reply->recipients[i]);
   }
   WindowEndUpdate(hRecipients);

   /* Set subject */
   SetDlgItemText(hDlg, IDC_SUBJECT, reply->subject);

   // Free memory for reply info
   SafeFree(reply);
}
Beispiel #2
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();
}
Beispiel #3
0
/*
 * StatsListChangeStat:  Redisplay current statistic, whose value has changed.
 *   Requires that s is a list type stat in the current group.
 */
void StatsListChangeStat(Statistic *s)
{
   int index, top;

   if (s->num < 0 || s->num > ListBox_GetCount(hList))
   {
      debug(("StatListChangeList got illegal stat #%d\n", (int) s->num));
      return;
   }

   top = ListBox_GetTopIndex(hList);

   index = StatListFindItem(s->num);   
   if (index == -1)
   {
      debug(("StatListChangeList got illegal stat #%d\n", (int) s->num));
      return;
   }

   WindowBeginUpdate(hList);
   ListBox_DeleteString(hList, index);

   index = ListBox_AddString(hList, LookupNameRsc(s->name_res));
   ListBox_SetItemData(hList, index, s);

   ListBox_SetTopIndex(hList, top);
   WindowEndUpdate(hList);
}
Beispiel #4
0
/* 
 * LookListSetContents: Set contents & highlight of list box in Look dialog.
 */
void LookListSetContents(HWND hwndListBox, list_type contents, int flags)
{
   list_type l;
   object_node *obj;
   
   WindowBeginUpdate(hwndListBox);
   ListBox_ResetContent(hwndListBox);
   
   /* Fill in list box with stuff from passed-in list */
   for (l = contents; l != NULL; l = l->next)
   {
      /* We need to make a copy of this object, because the original object
         might be freed by the game before this dialog ends */
      obj = ObjectCopy((object_node *) (l->data));
      ItemListAddItem(hwndListBox, obj, -1, !(flags & LD_AMOUNTS));  /* Add to end */
   }
   WindowEndUpdate(hwndListBox);
   
   /* In single selection box, make 1st item default.  In multiple selection,
    * only highlight 1st item if there is just 1 item AND item doesn't need an amount */
   if ((flags & LD_MULTIPLESEL) && contents->next == NULL)
   {
      obj = (object_node *) contents->data;
      if (!(info->flags & LD_AMOUNTS) || !IsNumberObj(obj->id))
      {
         ListBox_SetSel(hwndListBox, TRUE, 0);
         info->selected[0] = True;
      }
   }
   else ListBox_SetCurSel(hwndListBox, 0); 
}
Beispiel #5
0
/*
 * StatsListVScroll:  User did something with stats list scroll bar.
 */
void StatsListVScroll(HWND hwnd, HWND hwndCtl, UINT code, int pos)
{
   int old_top;  // Current top row index
   int new_top;  // New top row index
   int num_items;

   old_top = ListBox_GetTopIndex(hwnd);
   num_items = ListBox_GetCount(hwnd);

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

   case SB_LINEDOWN:
      new_top = old_top + 1;
      break;

   case SB_PAGEUP:
      new_top = old_top - num_visible;
      break;

   case SB_PAGEDOWN:
      new_top = old_top + num_visible;
      break;

   case SB_THUMBPOSITION:
      new_top = pos;
      break;

   case SB_THUMBTRACK:
      new_top = pos;
      break;

   case SB_BOTTOM:
      new_top = num_items - num_visible;
      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 - num_visible);

   if (new_top != old_top)
   {
      SetScrollPos(hwnd, SB_VERT, new_top, TRUE); 

      WindowBeginUpdate(hwnd);
      ListBox_SetTopIndex(hwnd, new_top);
      WindowEndUpdate(hwnd);
   }
}
Beispiel #6
0
/*
 * AdminStartResponse:  We've just started a new response of the given type.
 */
void AdminStartResponse(int type)
{
   num_lines = 0;
   switch (type)
   {
   case ADMIN_OBJECT:
      WindowBeginUpdate(hObjectList);
      ListBox_ResetContent(hObjectList);
      break;
   }
}
Beispiel #7
0
void DisplayInventory(list_type inventory)
{
    list_type l;

    WindowBeginUpdate(hwndInv);

    num_items = 0;

    InventoryResetData();

    cursor_row = 0;
    cursor_col = 0;

    for (l = inventory; l != NULL; l = l->next)
    {
        object_node *inv_object = (object_node *) (l->data);
        InventoryAddItem(inv_object);
    }

    InventoryScrollRange();
    if (num_items > rows * cols)
        InventoryDisplayScrollbar();
    WindowEndUpdate(hwndInv);
}
Beispiel #8
0
/*
 * StatListKey:  User pressed a key on stat list box.
 *   Return True iff key should NOT be passed on to Windows for default processing.
 */
Bool StatListKey(HWND hwnd, UINT key, Bool fDown, int cRepeat, UINT flags)
{
   Bool held_down = (flags & 0x4000) ? True : False;  /* Is key being held down? */
   int old_top, new_top, old_pos, new_pos;

   UserDidSomething();

   old_pos = ListBox_GetCurSel(hwnd);
   new_top = old_top = ListBox_GetTopIndex(hwnd);

   // Handle keys manually to prevent Windows from copying list box background, which would
   // cause background to flash when it's redrawn in the correct location.
   switch (key)
   {
   case VK_UP:
     WindowBeginUpdate(hwnd);
     new_pos = max(0, old_pos - 1);
     if (new_pos < old_top)
       new_top = new_pos;
     ListBox_SetTopIndex(hwnd, new_top);
     ListBox_SetCurSel(hwnd, new_pos);
     SetScrollPos(hwnd, SB_VERT, new_top, TRUE); 
     WindowEndUpdate(hwnd);
     return True;

   case VK_DOWN:
     WindowBeginUpdate(hwnd);
     new_pos = min(old_pos + 1, ListBox_GetCount(hwnd) - 1);
     if (new_pos > old_top + num_visible)
       new_top = new_pos - num_visible;
     ListBox_SetTopIndex(hwnd, new_top);
     ListBox_SetCurSel(hwnd, new_pos);
     SetScrollPos(hwnd, SB_VERT, new_top, TRUE); 
     WindowEndUpdate(hwnd);
     return True;

   case VK_PRIOR:
     WindowBeginUpdate(hwnd);
     new_pos = max(0, old_pos - num_visible);
     new_top = new_pos;
     ListBox_SetTopIndex(hwnd, new_top);
     ListBox_SetCurSel(hwnd, new_pos);
     SetScrollPos(hwnd, SB_VERT, new_top, TRUE); 
     WindowEndUpdate(hwnd);
     return True;

   case VK_NEXT:
     WindowBeginUpdate(hwnd);
     new_pos = min(old_pos + num_visible, ListBox_GetCount(hwnd) - 1);
     new_top = new_pos - num_visible;
     ListBox_SetTopIndex(hwnd, new_top);
     ListBox_SetCurSel(hwnd, new_pos);
     SetScrollPos(hwnd, SB_VERT, new_top, TRUE); 
     WindowEndUpdate(hwnd);
     return True;

	case VK_RETURN:	//	ajw
		{
			int iLabelLen = ListBox_GetTextLen( hwnd, old_pos );
			char* pszLabel = (char*)SafeMalloc( ( iLabelLen + 1 ) * sizeof( char ) );
			if( ListBox_GetText( hwnd, old_pos, pszLabel ) != LB_ERR )
			{
				//	ajwxxx Hard-coded group number constants for spells list. There may be a var that could be used instead.
				char* pszCommand;
				if( StatsGetCurrentGroup() == STATS_SPELLS )
				{
					pszCommand = (char*)SafeMalloc( ( iLabelLen + 6 ) * sizeof( char ) );
					strcpy( pszCommand, "zaubern " );
				}
				else
				{
					pszCommand = (char*)SafeMalloc( ( iLabelLen + 9 ) * sizeof( char ) );
					strcpy( pszCommand, "perform " );
				}
				strcat( pszCommand, pszLabel );
				PerformAction( A_GOTOMAIN, NULL );	//	For targeting icon to appear, focus must be on main view window.
				PerformAction( A_TEXTCOMMAND, pszCommand );
				SafeFree( pszCommand );
			}
			SafeFree( pszLabel );
		}
		return True;
   }

   return StatInputKey(hwnd, key, fDown, cRepeat, flags);
}
Beispiel #9
0
/*
 * LookCommand:  Handle WM_COMMAND messages.
 */ 
void LookCommand(HWND hDlg, int ctrl_id, HWND hwndCtl, UINT codeNotify) 
{
   int index, num_entries, i, amount, currentAmount;
   list_type selection;
   object_node *obj;
   char buf[MAXNAME + 1], temp[16];

   switch(ctrl_id)
   {
   case IDC_ITEMFIND:
      if (codeNotify == EN_UPDATE)
      {
	 /* Go to object in list that user has named */
	 Edit_GetText(info->hwndFind, buf, MAXNAME);
	 index = ListBox_FindString(info->hwndListBox, -1, buf);

	 if (index != LB_ERR)
	    if (info->flags & LD_MULTIPLESEL)
	       ListBox_SetCaretIndex(info->hwndListBox, index);
	    else ListBox_SetCurSel(info->hwndListBox, index);
      }
      break;

   case IDC_ALL:
      /* In multiple selection box only, select all objects.  If we require that
       * user give amounts, don't select amount objects */
      num_entries = ListBox_GetCount(info->hwndListBox);

      ListBox_SetSel(info->hwndListBox, TRUE, -1);

      WindowBeginUpdate(info->hwndQuanList);
      // Select all for number items
      for (i=0; i < num_entries; i++)
      {
	 info->selected[i] = True;
	 obj = (object_node *) ListBox_GetItemData(info->hwndListBox, i);
	 if (IsNumberObj(obj->id))
	    amount = obj->amount;
	 else
	    amount = 1;
	 obj->temp_amount = amount;
	 ListBox_DeleteString(info->hwndQuanList,i);
	 sprintf(temp, "%d", amount);
	 ListBox_InsertString(info->hwndQuanList,i,temp);
	 ListBox_SetItemData(info->hwndQuanList,i,amount);
      }
      WindowEndUpdate(info->hwndQuanList);
      break;

   case IDC_ITEMLIST:
      switch (codeNotify)
      {
      case LBN_DBLCLK:
	 /* Look at item */
	 index = ListBox_GetCaretIndex(info->hwndListBox);
	 if (index != LB_ERR)
	 {
	    obj = (object_node *) ListBox_GetItemData(info->hwndListBox, index);
	    RequestLook(obj->id);
	    SetDescParams(hDlg, DESC_NONE);
	    ListBox_SetSel(info->hwndListBox, FALSE, index);
	    info->selected[index] = False;
	 }
	 break;

      case LBN_SELCHANGE:
#if 0
	 LookSelChange(hwndCtl);
#else
	 index = ListBox_GetCurSel(info->hwndListBox);
	 obj = (object_node *) ListBox_GetItemData(info->hwndListBox, index);
	 WindowBeginUpdate(info->hwndQuanList);
	 ListBox_DeleteString(info->hwndQuanList,index);
	 if (ListBox_GetSel(info->hwndListBox,index))
	 {
	    if (IsNumberObj(obj->id))
	       amount = obj->amount;
	    else
	       amount = 1;
	    sprintf(temp, "%d", amount);
	 }
	 else
	 {
	    amount = 0;
	    strcpy(temp," ");
	 }
	 ListBox_InsertString(info->hwndQuanList,index,temp);
	 ListBox_SetItemData(info->hwndQuanList,index,amount);
	 ListBox_SetSel(info->hwndListBox,amount > 0,index);
	 info->selected[index] = (amount > 0);
	 obj->temp_amount = amount;
	 ListBox_SetSel(info->hwndQuanList,FALSE,index);
	 WindowEndUpdate(info->hwndQuanList);

#endif
	 break;
      }
      break;

   case IDC_QUANLIST:
      if (codeNotify == LBN_SELCHANGE)
      {
	 char temp[16];
	 index = (int)ListBox_GetCurSel(info->hwndQuanList);
	 obj = (object_node *) ListBox_GetItemData(info->hwndListBox, index);
	 currentAmount = (int)ListBox_GetItemData(info->hwndQuanList, index);
	 amount = currentAmount;
	 if (ListBox_GetItemData(info->hwndQuanList, index) > 0)
	 {
	    if (IsNumberObj(obj->id))
	    {
	       MEASUREITEMSTRUCT m;
	       int startAmount = currentAmount;
	       if (currentAmount == 0)
		  startAmount = obj->amount;
	       /* Place amount dialog just beneath selected item */
	       ItemListMeasureItem(info->hwndQuanList, &m);
	       // Force highlight on (we are editing it)
	       ListBox_SetSel(info->hwndListBox,TRUE,index);
	       if(InputNumber(hDlg,info->hwndQuanList,
		  0,(index - ListBox_GetTopIndex(info->hwndQuanList) + 1) * (m.itemHeight - 1),
		  &amount,startAmount,1,obj->amount))
	       {
		  ListBox_DeleteString(info->hwndQuanList,index);
		  if (amount > 0)
		  {
		     sprintf(temp, "%d", amount);
		     ListBox_InsertString(info->hwndQuanList, index, temp);
		  }
		  else
		  {
		     ListBox_InsertString(info->hwndQuanList,index," ");
		  }
		  ListBox_SetItemData(info->hwndQuanList, index, amount);
	       }
	       else
		  amount = currentAmount;
	       // reset highlight based on quantity - off if zero, on otherwise
	       ListBox_SetSel(info->hwndListBox,
		  (ListBox_GetItemData(info->hwndQuanList,index) > 0),
		  index);
	    }
	    else
	    {
	       ListBox_DeleteString(info->hwndQuanList,index);
	       if (currentAmount == 0)
	       {
		  amount = 1;
		  strcpy(temp,"1");
	       }
	       else
	       {
		  amount = 0;
		  strcpy(temp," ");
	       }
	       ListBox_InsertString(info->hwndQuanList,index,temp);
	       ListBox_SetItemData(info->hwndQuanList,index,amount);
	    }
	 }
	 ListBox_SetSel(info->hwndListBox,amount > 0,index);
	 info->selected[index] = (amount > 0);
	 obj->temp_amount = amount;
	 ListBox_SetCurSel(info->hwndQuanList,-1);
      }
      break;

   case IDOK:
      /* Get user's selection(s) */
      num_entries = ListBox_GetCount(info->hwndListBox);
      selection = NULL;
      
      for (i = 0; i < num_entries; i++)
      {
	 /* If item is selected, add to selection list, else free */
	 obj = (object_node *) ListBox_GetItemData(info->hwndListBox, i);
	 if (ListBox_GetSel(info->hwndListBox, i) > 0)
	    selection = list_add_item(selection, obj);
	 else 
	    ObjectDestroyAndFree(obj);
      }

      LookDialogRetval = selection;
      EndDialog(hDlg, IDOK);
      break;
      
   case IDCANCEL:
      LookListFreeContents(info->hwndListBox);
      
      LookDialogRetval = NULL;
      EndDialog(hDlg, IDCANCEL);
      break;
   }
}
Beispiel #10
0
/*
 * AdminValueDialogProc:  Dialog procedure for editing a property's value.
 *   lParam of INITDIALOG message is index of property in object list box.
 */
BOOL CALLBACK AdminValueDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
   static int index;
   int type, i;
   char *value, line[MAX_PROPERTYLEN], *str, property[MAX_PROPERTYLEN];
   static HWND hEdit;

   switch (message)
   {
   case WM_INITDIALOG:
      index = lParam;
      hEdit = GetDlgItem(hDlg, IDC_EDITVALUE);
      Edit_LimitText(hEdit, MAX_PROPERTYLEN - 1);

      ListBox_GetText(hObjectList, index, line);

      value = AdminPropertyValue(line, &type);
      if (value != NULL)
      {
	 // Initialize dialog with current value
	 for (i = 0; type_table[i].word != NULL; i++)
	    if (type == type_table[i].type)
	       CheckDlgButton(hDlg, type_table[i].control, 1);

	 Edit_SetText(hEdit, value);
	 Edit_SetSel(hEdit, 0, -1);

	 strcpy(property, AdminNthToken(line, 1));
	 str = strchr(property, ' ');
	 if (str != NULL)
	    *str = 0;
	 SetDlgItemText(hDlg, IDC_PROPERTY, property);
      }

      sprintf(line, "%d", current_obj);
      SetDlgItemText(hDlg, IDC_OBJECTNUM, line);

      CenterWindow(hDlg, GetParent(hDlg));
      SetWindowFont(hEdit, GetFont(FONT_INPUT), TRUE);
      SetFocus(hEdit);
      return FALSE;

   case WM_COMMAND:
      switch (GET_WM_COMMAND_ID(wParam, lParam))
      {
      case IDOK:
	 // Get type and value
	 str = NULL;
	 for (i = 0; type_table[i].word != NULL; i++)
	    if (IsDlgButtonChecked(hDlg, type_table[i].control))
	    {
	       str = type_table[i].word;
	       break;
	    }
	 if (str != NULL)
	 {
	    Edit_GetText(hEdit, line, MAX_PROPERTYLEN);
	    GetDlgItemText(hDlg, IDC_PROPERTY, property, MAX_PROPERTYLEN);
	    
	    // Special case for NIL:  value must be zero
	    if (type_table[i].type == TAG_NIL)
	       strcpy(line, "0");
	    
	    sprintf(command, "set object %d %s %s %s", current_obj, property, str, line);
	    
	    SendMessage(hAdminDlg, BK_SENDCMD, 0, (LPARAM) command);
	    
	    // Change value in object list box
	    sprintf(command, "%s = %s %s", property, str, line);
	    WindowBeginUpdate(hObjectList);
	    ListBox_DeleteString(hObjectList, index);
	    ListBox_InsertString(hObjectList, index, command);
	    WindowEndUpdate(hObjectList);
	 }
	    
	 EndDialog(hDlg, IDOK);
	 return TRUE;

      case IDCANCEL:
	 EndDialog(hDlg, IDCANCEL);
	 return TRUE;
      }
      break;
   }

   return FALSE;
}