Thread: Item Dragging [Edit]

Results 1 to 9 of 9
  1. #1 Item Dragging [Edit] 
    Registered Member
    Deku's Avatar
    Join Date
    May 2016
    Posts
    151
    Thanks given
    37
    Thanks received
    123
    Rep Power
    165
    Just keeps the item in bounds while dragging instead of it clipping outside the raster



    Code:
    if (child.inventoryItemId[item] > 0) {
    	int drag_offset_x = 0;
    	int drag_offset_y = 0;
    	int bind_x = 0;
    	int bind_y = 0;
    	int itemId = child.inventoryItemId[item] - 1;
    
    	if (tileX > Raster.topX - 32 && tileX < Raster.bottomX
    		&& tileY > Raster.topY - 32 && tileY < Raster.bottomY || activeInterfaceType != 0 && anInt1085 == item) {
    			int outlineColor = 0;
    			if (itemSelected == 1 && anInt1283 == item && anInt1284 == child.id)
    				outlineColor = 0xffffff;
    
    			Sprite item_icon = ItemDefinition.getSprite(itemId, child.inventoryAmounts[item], outlineColor);
    			if (item_icon != null) {
    				if (activeInterfaceType != 0 && anInt1085 == item && anInt1084 == child.id) {
    					//dragging
    					drag_offset_x = super.mouseX - anInt1087;
    					drag_offset_y = super.mouseY - anInt1088;
    					if (drag_offset_x < 5 && drag_offset_x > -5)
    						drag_offset_x = 0;
    					if (drag_offset_y < 5 && drag_offset_y > -5)
    						drag_offset_y = 0;
    					
    					if (dragItemDelay < 10) {
    						drag_offset_x = 0;
    						drag_offset_y = 0;
    					}
    					
    					bind_x = tileX + drag_offset_x;
    					if(bind_x < Raster.topX) {
    						bind_x = Raster.topX - (drag_offset_x);
    						if(drag_offset_x < Raster.topX)
    							bind_x = Raster.topX;
    					}
    					if(bind_x > Raster.bottomX - 32) {
    						bind_x = Raster.bottomX - 32;
    					}
    					bind_y = tileY + drag_offset_y;
    					if(bind_y < Raster.topY && main.scrollPosition == 0) {
    						bind_y = Raster.topY - (drag_offset_y);
    						if(drag_offset_y < Raster.topY)
    							bind_y = Raster.topY;
    					}
    					if(bind_y > Raster.bottomY - 32)
    						bind_y = Raster.bottomY - 32;
    					
    					if (tileY + drag_offset_y < Raster.topY && main.scrollPosition > 0) {
    						int notch = (anInt945 * (Raster.topY - tileY - drag_offset_y)) / 3;
    						if (notch > anInt945 * 10)
    							notch = anInt945 * 10;
    						
    						if (notch > main.scrollPosition)
    							notch = main.scrollPosition;
    						
    						main.scrollPosition -= notch;
    						anInt1088 += notch;
    						bind_y = Raster.topY;//was left out, if you're item disappears while dragging up in a scrollbar this is the fix :-)
    					}
    					
    					if (tileY + drag_offset_y + 32 > Raster.bottomY && main.scrollPosition < main.scrollMax - main.height) {
    						int notch = (anInt945 * ((tileY + drag_offset_y + 32) - Raster.bottomY)) / 3;
    						if (notch > anInt945 * 10)
    							notch = anInt945 * 10;
    						
    						if (notch > main.scrollMax - main.height - main.scrollPosition)
    							notch = main.scrollMax - main.height - main.scrollPosition;
    						
    						main.scrollPosition += notch;
    						anInt1088 -= notch;
    					}
    					item_icon.drawSprite1(bind_x, bind_y);
    					
    				} else if (atInventoryInterfaceType != 0 && atInventoryIndex == item && atInventoryInterface == child.id) {
    					bind_x = tileX + drag_offset_x;
    					bind_y = tileY;
    					item_icon.drawSprite1(tileX, tileY);
    				} else {
    					if(!child.scrollModels) {
    						bind_x = tileX + drag_offset_x;
    						bind_y = tileY;
    						item_icon.drawSprite(tileX, tileY);
    					} else {
    						bind_x = tileX + drag_offset_x;
    						bind_y = tileY + drag_offset_y;
    					}
    				}
    				if (child.showItemAmount && (item_icon.maxWidth == 33 || child.inventoryAmounts[item] != 1)) {
    					int k10 = child.inventoryAmounts[item];
    					smallText.render(0, intToKOrMil(k10), bind_y + 10, bind_x + 1);//shadow
    					if (k10 >= 1)
    						smallText.render(0xFFFF00, intToKOrMil(k10), bind_y + 9, bind_x);
    					
    					if (k10 >= 100000)
    						smallText.render(0xFFFFFF, intToKOrMil(k10), bind_y + 9, bind_x);
    					
    					if (k10 >= 10000000)
    						smallText.render(0x00FF80, intToKOrMil(k10), bind_y + 9, bind_x);
    				}
    wut
    Reply With Quote  
     


  2. #2  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    28
    Posts
    4,421
    Thanks given
    891
    Thanks received
    1,527
    Rep Power
    3285
    Thanks man
    Reply With Quote  
     

  3. #3  
    Registered Member

    Join Date
    Oct 2011
    Posts
    2,084
    Thanks given
    0
    Thanks received
    1,043
    Rep Power
    3608
    nice one, thanks.
    Reply With Quote  
     

  4. #4  
    Banned

    Join Date
    Mar 2017
    Posts
    293
    Thanks given
    200
    Thanks received
    192
    Rep Power
    0
    thanks for this
    Reply With Quote  
     

  5. #5  
    Donator


    Join Date
    Jan 2012
    Posts
    1,288
    Thanks given
    491
    Thanks received
    229
    Rep Power
    127
    :O Using Exigence lol, thanks for this though



    Developer of Valor, Exigence, & Mystic.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Deku's Avatar
    Join Date
    May 2016
    Posts
    151
    Thanks given
    37
    Thanks received
    123
    Rep Power
    165
    Quote Originally Posted by Zivik View Post
    Thanks man
    Quote Originally Posted by Arlo View Post
    thanks for this
    Quote Originally Posted by Omelete View Post
    nice one, thanks.
    Quote Originally Posted by Thrasher View Post
    :O Using Exigence lol, thanks for this though
    No problem haha
    wut
    Reply With Quote  
     

  7. #7  
    Donator


    Join Date
    Sep 2016
    Posts
    131
    Thanks given
    115
    Thanks received
    52
    Rep Power
    77
    great snippet! thanks
    If a man does not have the sauce, then he is lost. But the same man can be lost in the sauce.
    Reply With Quote  
     

  8. Thankful user:


  9. #8  
    Banned
    Join Date
    Aug 2015
    Posts
    248
    Thanks given
    129
    Thanks received
    56
    Rep Power
    0
    releasing a ton of small aesthetic enhancements, thank you
    Reply With Quote  
     

  10. #9  
    Banned

    Join Date
    May 2016
    Age
    55
    Posts
    1,137
    Thanks given
    565
    Thanks received
    600
    Rep Power
    0
    thanks for the share!
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Item Drag Tweak
    By Jesse in forum Snippets
    Replies: 25
    Last Post: 01-02-2014, 04:04 AM
  2. Replies: 0
    Last Post: 07-25-2013, 09:47 PM
  3. How to add custom Items and edit their stats
    By dragonmage in forum Help
    Replies: 5
    Last Post: 07-24-2013, 07:19 AM
  4. [PI] Item Dragging Fix [PI]
    By Tiggy in forum Help
    Replies: 10
    Last Post: 04-24-2013, 02:30 AM
  5. Replies: 2
    Last Post: 03-26-2012, 06:27 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •