Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-03-2008, 05:44 AM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Drag and Drop

For Valikorlia's trading GUI, I'm wanting to implement dragging and dropping. So far, I've gotten dragging down. However, I can't seem to figure out dropping. The "3" is arbitrary; I just copied another NAT's method (which obviously isn't working in this case ).

This is how I'm doing it. First, we have onRecordSelection(obj), which is just obj.onSelect(). This triggers onDragIcon(obj). (I do it this way to prevent a different icon from being selected when dragging the mouse over it.) From there, a GuiShowImgCtrl is created, which is the floating icon that the user's dragging around. The problem I'm having is detecting when the mouse is over TradeOfferScroll.
PHP Code:
function onDragIcon(obj) {
  if(
this.dragging) {
    return;
  }
  new 
GuiShowImgCtrl("TradeInventoryFloater") {
    
this.width 32;
    
this.height 32;
    
System.parseimage(thisstaticdata.tradeitems[(@ obj).itemid].icon);
    
this.mousescreenx;
    
this.mousescreeny;
  }
  
setTimer(0.05);

PHP Code:
function onTimeout() {
  if(
leftmousebuttonglobal) {
    
with(TradeInventoryFloater) {
      
this.mousescreenx;
      
this.mousescreeny;
    }
    
this.dragging true;
    
setTimer(0.05);
  }
  else {
    if(
mousescreenx in  |TradeOfferScroll.xTradeOfferScroll.3|) {
      if(
mousescreeny in |TradeOfferScroll.yTradeOfferScroll.3|) {
        echo(
"Added to offer");
      }
    }
    else {
      echo(
"Destroyed");
    }
    
this.dragging false;
    
System.destroyobject("TradeInventoryFloater");
    
setTimer(0);
  }

Another NAT on Valikorlia suggested using showimg() instead of a GuiShowImgCtrl. Is there any benefit with doing this, as opposed to using a GUI control?
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
 

Tags
drag, drag & drop, drag and drop, drag'n'drop, drag-&-drop, drag-and-drop, drop


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:18 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.