Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-25-2014, 02:35 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,057
Torankusu has a spectacular aura aboutTorankusu has a spectacular aura about
Need some advice on this approach..

I am making a mock up of an inventory system, and I want to have grid alignment.

Ex:
0 0 0 0
0 0 0 0

Not:
00 0 0
0 0 00

At the moment, I am using a frames control, And showimg for the icons (32x32 pix), and that works fine.

What I want to do, is, say for example I have an icon that id 32 pix wide, and 64 pixels in height. I need that to take up grid space like this:

0 0 X 0
0 0 X 0

Without allowing anything else To display in that slot (X's refer to 32x64 item.)

I have thought of checking for the width/height of the image and basically chopping it in two and displaying two halves (one half in each corresponding frame) but that seems messy.
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #2  
Old 01-27-2014, 01:14 PM
Chompy Chompy is offline
»\(║_o)/»
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
So, an inventory system like Diablo, Torchlight, Neverwinter Nights, Path of Exile, etc? Items take up different spaces but basically as a different sized square?
__________________

Last edited by Chompy; 01-27-2014 at 01:58 PM..
Reply With Quote
  #3  
Old 01-27-2014, 05:41 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,057
Torankusu has a spectacular aura aboutTorankusu has a spectacular aura about
Quote:
Originally Posted by Chompy View Post
So, an inventory system like Diablo, Torchlight, Neverwinter Nights, Path of Exile, etc? Items take up different spaces but basically as a different sized square?
Haven't played those games, but yeah, I think you get what I mean. I want some items to be restricted to taking up VISIBLE / physical space in the inventory window.

Here's What I have so far (not much at all, mind you...)...
I've actually gotten stuck on the dragging part. :[

Everything I try it just shows the image UNDER the GUI, and doesn't seem to move with the mouse.

http://pastebin.com/9u8Bxa75
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #4  
Old 01-27-2014, 06:36 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Quote:
Originally Posted by Torankusu View Post
I am making a mock up of an inventory system, and I want to have grid alignment.

Ex:
0 0 0 0
0 0 0 0

Not:
00 0 0
0 0 00

At the moment, I am using a frames control, And showimg for the icons (32x32 pix), and that works fine.

What I want to do, is, say for example I have an icon that id 32 pix wide, and 64 pixels in height. I need that to take up grid space like this:

0 0 X 0
0 0 X 0

Without allowing anything else To display in that slot (X's refer to 32x64 item.)

I have thought of checking for the width/height of the image and basically chopping it in two and displaying two halves (one half in each corresponding frame) but that seems messy.
If you already have a way to check the width/height of the images, when you set the amount per line to show read each one its putting in as it comes in a loop, and check the width/height there, set a temp.var in the order, then on the next line (i'd imagine also in your loop) do checks to see, and if it the temp.var is set, on that next line when the loop comes to it, make it null on that spot for the image, erase the temp.var, and if there are anymore the set above for the temp.var will reset it to the next one.

e.g.
PHP Code:
for (temp.0temp.< array.size(); temp.i++) {
 
// set up a checker for what position in the line it is (#1 - 6 in each line)
  
if (!temp.itemPos) {
    
temp.itemPos 0;
    
temp.line 0;
  }
  
// since this is for the line, if it's past the 6 max for the line, reset
  
if (itemPos 6) {
    
itemPos 0;
    
line++;
  }

  new 
GuiImgCtrl("whatever"@someID/Name) {
    
set x's
    y = line + adjustment space here
    // set everything else, including where you read for your width/height
  }
  
  // see if the width or height (or both) is more than 32
  if (getimgwidth(whaterver.image) > 32) {
    temp.checkW = true;
    temp.checkWID = itemPos + 1;
  }
  if (getimgheight(whaterver.image) > 32) {
    temp.checkH = true;
    temp.checkHID = itemPos + 6;
  }

  // now check the width/height
  if (checkW && itemPos == checkWID) {
    this.checkW = false;
    // set the next image to move over
    (@"whatever"@someID/Name).x = adjust over to next;

    itemPos += 2;
  }else if (checkH && itemPos == checkHID) {
    this.checkH = false;
    // set the image under to move over when you get there
    (@"whatever"@someID/Name).x = adjusted over 1 however u wanna do it;
   
    itemPos += 2;
  }else itemPos++;

  // make sure to add the img ctrl to a parent, either a scroll or window.

I haven't tested the above, just going off how I would start. It may not be the best; I'm not the best scripter. Someone might have a better way.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...



Last edited by sssssssssss; 01-27-2014 at 07:50 PM..
Reply With Quote
  #5  
Old 01-28-2014, 02:57 AM
100Zero100 100Zero100 is offline
Registered User
Join Date: Jul 2006
Posts: 31
100Zero100 is on a distinguished road
You could opt to just make a grid of indices that correlates to the image grid. When an item is placed into the grid, it would set indices of the array to 1 where it's blocking.

Should be pretty simple using standard grid algorithms (ie, mod and int division)
__________________
Hi. I'm NaS!
Reply With Quote
  #6  
Old 02-01-2014, 06:14 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by sssssssssss View Post
If you already have a way....
Your loop is very sloppy... if you learn maths you can optimize it a substantial amount.
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 10:54 AM.


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