HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: icon not draggable - not changing values  (Read 2834 times)

Tarra2012

  • General Accounts
  • *
  • Posts: 113
    • View Profile
icon not draggable - not changing values
« on: Dec 26, 12, 03:10:33 AM »

I have a small script that creates icons. It will show them correctly and even doubleclick events are beeing processed normally. But values likes "allowMove" and dependet "_IsDraggable()"  do not change.

Anyone got an idea, why the values "isInert,allowMove,IconSubject" wont change to parameters?
There is no hint in any console. Println directly after setting them shows they are not changed.


myicon as NodeRef of Class _GUIIcon = CreateNodeFromPrototype("myicon")
 
myicon._iconSubject=item.EO_CItem_itemnode
 myicon.isInert = true
 myicon.allowMove = true
 myicon._SetIconID(item.EO_CItem_item2dimage)
 myicon._SetIconSubject(item.EO_CItem_itemnode)
 myicon.OnControlBuild()
 myicon.build=true
 
  //Connect the icon to the slot
  slot._PutIconInContainer(myicon)
 
  println("Icon subj:"+myicon._GetIconSubject())
  println("Icon ID:"+myicon._GetIconID())
  println("Icon image:"+myicon._GetIconImage())
  println("Icon container:"+myicon._GetIconContainer())
  println("Item is draggable:"+myicon._IsDraggable())
 

Println Output
10:07:49: SCRIPT:[PopUpClassMethods]:Icon subj:0
10:07:49: SCRIPT:[PopUpClassMethods]:Icon ID:0
10:07:49: SCRIPT:[PopUpClassMethods]:Icon image:1000003645
10:07:49: SCRIPT:[PopUpClassMethods]:Icon container:1000003623
10:07:49: SCRIPT:[PopUpClassMethods]:Item is draggable:false

Logged

Jrome90

  • General Accounts
  • *
  • Posts: 330
    • View Profile
Re: icon not draggable - not changing values
« Reply #1 on: Dec 26, 12, 05:31:30 PM »

I am not sure why it isn't working.

What is the value of "item.EO_CItem_itemnode"?

If your Item Class has a parent class of "_IconSubjectInterface". You can use:
Code: [Select]
item._CreateIcon
You will need to add:

Code: [Select]
method _GetIconPrototypeName() as String
  return "<Your Item Icon Prototype>"
.

To your Item Class
-------------------------------------------
Or you can just use this in the Item Class:

Code: [Select]
method _CreateIcon() as NodeRef of Class GUIControl
 
  icon as NodeRef of Class GUIControl = CreateNodeFromPrototype("<Your Item Icon Prototype>")
  icon.build = true
  AddAssociation(me, "SubjectAndIcon", icon)
  icon._OnIconCreate(me)
  return icon
.

Then "_OnIconCreate()" will do this:

Code: [Select]
////
//  Called after the _IconSubject has created the icon
//  Default: Sets _IconSubject and calls _SetupIcon()
////
method _OnIconCreate(subj as NodeRef of Class _IconSubjectInterface)
  me._iconSubject = subj
  me._SetupIcon()
.

The "_iconSubject" field is the Type of: NodeRef of Class _IconSubjectInterface
Is "item.EO_CItem_itemnode" pointing to a node of the same Type?
« Last Edit: Dec 26, 12, 05:54:19 PM by Jrome90 »
Logged

Tarra2012

  • General Accounts
  • *
  • Posts: 113
    • View Profile
Re: icon not draggable - not changing values
« Reply #2 on: Dec 27, 12, 02:53:02 AM »

>>value of "item.EO_CItem_itemnode"?
Its a noderef to the item of the ITEMSYSTEM.

To explain my approach. In the beginning i browse items in the ITEMSYSTEM and use the async callback for oracle specs to get the values like name,category, image. I store these values in objects of class EO_CITEM. C meaning Cached.

Afterwards i use all important item information via these "cached" objects.
This way i have access to the instanced itemnode and functions like requestEquip() and I have access to unmutable descriptive attributes from oracle specs (name, value, itemimage) all in one place.

I cant judge if this way is optimal, but for now it works. On Creating / Destroying items i need to update the CItems as well. But not if i add something to an item. Because i ve only stored the noderef to the item.



With your explanation i could modify the _Item class, but its an engine script. I dislike changing them thats why i will go with EO_CITEM. I will report back.







Logged

Tarra2012

  • General Accounts
  • *
  • Posts: 113
    • View Profile
Re: icon not draggable - not changing values
« Reply #3 on: Dec 27, 12, 04:03:36 AM »

Even if the parent class _IconSubjectInterface is set I cant create the method as described:

me._iconSubject does not exist.


method _OnIconCreate(subj as NodeRef of Class _IconSubjectInterface)
  me._iconSubject = subj
  me._SetupIcon()
.

See attached my EO_CITEM Class that derives from _IconSubjectInterface.
The _OnIconcreate cant be compiled. _iconSubject is not a valid Var.



Logged

Tarra2012

  • General Accounts
  • *
  • Posts: 113
    • View Profile
Re: icon not draggable - not changing values
« Reply #4 on: Dec 27, 12, 04:47:32 AM »

I have dug to the core. The check, weather an icon is draggable or not, is devided into 2 parts.
You have to verfiy that

1. ICONSubject     has a method _AllowIconDragAway
2. ICONContainer has a method _AllowIconDragAway

Overriding both methods will activate draggable Icons:
method _AllowIconDragAway(icon as NodeRef of Class _GUIIcon) as Boolean
  return true
.

1 YourITEMContainer  parentClass _GUIIconContainer       must override the method
2 YourITEM                  parentClass _IconSubjectInterface  must override the method





..
Original Source from _GUIIconClassMethods
..

////
//  Returns whether or not the icon should be allowed to be dragged.
//  Both subject and container must allow drag
//  Default is false
////
method _IsDraggable() as Boolean
  if me._iconSubject != None
    if me._iconSubject._AllowIconDragAway(me)
      var ctnr = me._GetIconContainer()
      if ctnr != None
        return ctnr._AllowIconDragAway(me)
      else
        return false 
      .
    else
      return false
    .
  else
    return false
  .
.
Logged

Jrome90

  • General Accounts
  • *
  • Posts: 330
    • View Profile
Re: icon not draggable - not changing values
« Reply #5 on: Dec 27, 12, 03:35:07 PM »

See attached my EO_CITEM Class that derives from _IconSubjectInterface.
The _OnIconcreate cant be compiled. _iconSubject is not a valid Var.

Code: [Select]
me._iconSubject
Is a field in the "_GUIIcon" class, and the method "_OnIconcreate " is in that class.
Assuming your class that is for your item icon has a parent of "_GUIIcon"

Then everything should work.

I am sorry, I see where I created confusion.
Logged