HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.
Pages: 1 2 [3] 4

Author Topic: Basic SpecOracle setup  (Read 16451 times)

ToY-Krun

  • General Accounts
  • *
  • Posts: 677
  • Support Volunteer
    • View Profile
Re: Basic SpecOracle setup
« Reply #30 on: Mar 23, 16, 11:35:37 AM »

I've posted the missing class and its script here:

http://wiki.anvilofhonor.com/wiki/index.php/AbilitySpecEditor#Creating_the_Base_GUI_for_the_Spec_Editor

Take care to notice that the Class setup for *Ability*SpecEditorGUI in the next step following, has changed.
You'll need to change the parent (not add, but replace).

Had to remove alot so I hope I got it all sorted okay.

let me know if you run into further issues with it.

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
Re: Basic SpecOracle setup
« Reply #31 on: Mar 23, 16, 07:53:07 PM »

Added missing class and script. Changed parent class.

It looks like it tried to show something with a few errors:

Code: [Select]
ERROR:HeroScript::HeroMachine::ScriptError:GOM::getVariableReferenceFromNode (10823): requested node ID (0) not found
ERROR:System:SCRIPT ERROR: GOM::getVariableReferenceFromNode (10823): requested node ID (0) not found
Time:03/23/2016 19:19:26
Call trace:
  Script EO_GUINodeCollectionInterfaceWindowClassMethods line 5 me[1000002646]
  Script _GUIBaseWindowClassMethods line 3 me[1000002646]
starting method/function ONCONTROLBUILD
starting me[id=1000002646 class=EO_ItemSpecEditorGUI]
ERROR:HeroScript::HeroMachine::ScriptError:The method GETMYSPECKEY was not found on any of the classes on the node [id=9223372098298021571 class=EO_itemSpec].
ERROR:System:SCRIPT ERROR: The method GETMYSPECKEY was not found on any of the classes on the node [id=9223372098298021571 class=EO_itemSpec].
Time:03/23/2016 19:19:26
Call trace:
  Script EO_ItemSpecEditorMainPanelClassMethods line 9 me[id=1000002772 class=EO_ItemSpecEditorMainPanel]
  Script EO_itemSpecClassMethods line 78 me[id=1000002646 class=EO_ItemSpecEditorGUI]
  Script EO_GUINodeCollectionInterfaceWindowClassMethods line 123 me[1000002646]
  Script EO_itemSpecClassMethods line 40 me[id=9223372098298021571 class=EO_itemSpec]
  Script _GUISpecOracleSpecSelectorClassMethods line 302 me[id=1000002364 class=_GUISpecOracleSpecSelector]
  Script obsSubjectClassMethods line 209 me[id=1000001215 class=_SpecOracleUtils,EO_SpecOracleUtils]
  Script _SpecOracleUtilsClassMethods line 317 me[0]
starting method/function _GOTSPECFOREDIT
starting me[id=0 invalid]
ERROR:System:GUIThunk::GetClass(): Couldn't find inherited controlType named '"window_noresize" on controlType "EO_IconChooserGUI".
ERROR:System:GUIThunk::GetGUIControlTypes(): Couldn't determin the class of controlType: EO_IconChooserGUI
ERROR:HeroScript::HeroMachine::ScriptError:Exception DefinitionNotFoundException in function 'createNodeFromPrototype' definition not found: ItemIconChooser
ERROR:System:SCRIPT ERROR: Exception DefinitionNotFoundException in function 'createNodeFromPrototype' definition not found: ItemIconChooser
Time:03/23/2016 19:28:26
Call trace:
  Script EO_ItemSpecEditorMainPanelClassMethods line 514 me[id=1000002772 class=EO_ItemSpecEditorMainPanel]
  Script _GUIButtonClassMethods line 10 me[1000002778]
starting method/function ONMOUSECLICK
starting me[id=1000002778 class=_GUIButton]

Where there used to be a red button in upper right to close it, now nothing shows. Also note I have a skinny screen, not the wide ones.

Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

ToY-Krun

  • General Accounts
  • *
  • Posts: 677
  • Support Volunteer
    • View Profile
Re: Basic SpecOracle setup
« Reply #32 on: Mar 23, 16, 08:25:34 PM »

okay :

I have a suspicion as to what caused this first error, but if you dont mind, would you post the code from
line 5 of your EO_GUINodeCollectionInterfaceWindowClassMethods?
Just so i can be sure what is being called.

Code: [Select]
ERROR:HeroScript::HeroMachine::ScriptError:GOM::getVariableReferenceFromNode (10823): requested node ID (0) not found
ERROR:System:SCRIPT ERROR: GOM::getVariableReferenceFromNode (10823): requested node ID (0) not found
Time:03/23/2016 19:19:26
Call trace:
  Script EO_GUINodeCollectionInterfaceWindowClassMethods line 5 me[1000002646]
  Script _GUIBaseWindowClassMethods line 3 me[1000002646]
starting method/function ONCONTROLBUILD
starting me[id=1000002646 class=EO_ItemSpecEditorGUI

Above: hrm not sure which line of code this is (line 5) possibly looking for the client area.
Possibly a null return from me.GetClientArea()
I'll look at that and see if something needs added to the specClass


Code: [Select]
ERROR:HeroScript::HeroMachine::ScriptError:The method GETMYSPECKEY was not found on any of the classes on the node [id=9223372098298021571 class=EO_itemSpec].
ERROR:System:SCRIPT ERROR: The method GETMYSPECKEY was not found on any of the classes on the node [id=9223372098298021571 class=EO_itemSpec].
Time:03/23/2016 19:19:26
Call trace:
  Script EO_ItemSpecEditorMainPanelClassMethods line 9 me[id=1000002772 class=EO_ItemSpecEditorMainPanel]
  Script EO_itemSpecClassMethods line 78 me[id=1000002646 class=EO_ItemSpecEditorGUI]
  Script EO_GUINodeCollectionInterfaceWindowClassMethods line 123 me[1000002646]
  Script EO_itemSpecClassMethods line 40 me[id=9223372098298021571 class=EO_itemSpec]
  Script _GUISpecOracleSpecSelectorClassMethods line 302 me[id=1000002364 class=_GUISpecOracleSpecSelector]
  Script obsSubjectClassMethods line 209 me[id=1000001215 class=_SpecOracleUtils,EO_SpecOracleUtils]
  Script _SpecOracleUtilsClassMethods line 317 me[0]
starting method/function _GOTSPECFOREDIT

Above: Add method called GetMySpecKey() as id to EO_ItemSpecClassMethods and return specKey


Code: [Select]
starting me[id=0 invalid]
ERROR:System:GUIThunk::GetClass(): Couldn't find inherited controlType named '"window_noresize" on controlType "EO_IconChooserGUI".

Theres a new version of the IconChooserGUI here http://wiki.anvilofhonor.com/wiki/index.php/ItemIconChooser_XML
removing the window_noresize type.


Code: [Select]
ERROR:System:SCRIPT ERROR: Exception DefinitionNotFoundException in function 'createNodeFromPrototype' definition not found: ItemIconChooser
Time:03/23/2016 19:28:26
Call trace:
  Script EO_ItemSpecEditorMainPanelClassMethods line 514 me[id=1000002772 class=EO_ItemSpecEditorMainPanel]
  Script _GUIButtonClassMethods line 10 me[1000002778]
starting method/function ONMOUSECLICK
starting me[id=1000002778 class=_GUIButton]

Fixing the xml above should solve this one as it will be invalid with the window_noresize option in it.


See if that helps


EDIT: yeah you may need to open the abilityspeceditormainpanel  in the gui editor and downsize it. i try to set them to work on 1024x768 but that one i may not have, it was an earlier project.

Actually i removed code that turns off all gui controls on screen while that panel is open but that would have to be customized based on your own gui setup.

once the gui loads without error, you should be able to see everything as the entire panel scrolls.  but wont until it loads successfully.  you dont want a red box for an exit in a spec editor... well.. you could, but the preferred method is the cancel button at the very bottom which notifies the nodecollection interface (you cant see) to close as well.  also the Okay button at the very bottom is used to save the spec.  these wont appear if there were errors loading either.
« Last Edit: Mar 23, 16, 08:37:08 PM by ToY-Krun »
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
Re: Basic SpecOracle setup
« Reply #33 on: Mar 23, 16, 09:45:01 PM »

Line 5 is the insert buttons

Code: [Select]
method HE_OnControlBuild()
  var buttons = FindGUIControlByName(me, "buttonSpacer")
  insert buttons to me.children at me.getClientarea().parent.findChildPosition()
.

Added GetMySpecKey() with return specKey. Replaced IconChooserGU.xml


fewer errors:
Code: [Select]
ERROR:HeroScript::HeroMachine::ScriptError:The method GETMYNAME was not found on any of the classes on the node [id=9223372098298021571 class=EO_itemSpec].
ERROR:System:SCRIPT ERROR: The method GETMYNAME was not found on any of the classes on the node [id=9223372098298021571 class=EO_itemSpec].
Time:03/23/2016 21:39:19
Call trace:
  Script EO_ItemSpecEditorMainPanelClassMethods line 10 me[id=1000002531 class=EO_ItemSpecEditorMainPanel]
  Script EO_itemSpecClassMethods line 82 me[id=1000002357 class=EO_ItemSpecEditorGUI]
  Script EO_GUINodeCollectionInterfaceWindowClassMethods line 123 me[1000002357]
  Script EO_itemSpecClassMethods line 44 me[id=9223372098298021571 class=EO_itemSpec]
  Script _GUISpecOracleSpecSelectorClassMethods line 302 me[id=1000002178 class=_GUISpecOracleSpecSelector]
  Script obsSubjectClassMethods line 209 me[id=1000001259 class=_SpecOracleUtils,EO_SpecOracleUtils]
  Script _SpecOracleUtilsClassMethods line 317 me[0]
starting method/function _GOTSPECFOREDIT
starting me[id=0 invalid]


line 10 is me.SetMyName( spec.GetMyName())


Code: [Select]
//called from AbilitySpecClassMethods:InvokeGUIEditor
method PopulateSpecEditorFields(spec as NodeRef)
  //set the classification textbox as multiline
  me.GetClassificationList().isMultiLine = true
 
  //populate all the fields with appropriate stored data or initial new data
  //spec points to the AbilitySpecClass, and is a noderef of that class
  me.SetMySpecKey( spec.GetMySpecKey())
  me.SetMyName( spec.GetMyName())
  me.SetMyDescription( spec.GetMyDescription())
  me.SetMyIconID( spec.GetMyIconID() )
  me.SetIcon(spec.GetMyIconID())

Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

ToY-Krun

  • General Accounts
  • *
  • Posts: 677
  • Support Volunteer
    • View Profile
Re: Basic SpecOracle setup
« Reply #34 on: Mar 24, 16, 08:40:38 AM »

ahh , yeah there are a few methods to add, i put them in a separate link on the wiki...

my apologies for the layout, now that the content is o the wiki, I know i need to better organize it to make it more linear in fashion.


here is the link for those methods that you'll need to add:

http://wiki.anvilofhonor.com/wiki/index.php/PreRequisite_SpecClass_Methods

I should also add that the return should be :

return me.specKey etc
and the setMethods should be :
me.specKey = key etc

I've had a death in the family this morning, so i wont be super active on the forums the next few days, but
I will be somewhat active to have something to do.

I really appreciate you trying this out and reporting the issues Thaz (and anyone else following this).

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
Re: Basic SpecOracle setup
« Reply #35 on: Mar 24, 16, 07:50:44 PM »

Added methods into *Ability*Spec class, following the same procedure as below, I did not find a field for GetMyIconID().  Without an ID and something setting it, it gets an error about not finding it.

SCRIPT ERROR: Node 0 not found to call method _SETICONID

     return me.specKey etc
     and the setMethods should be :
     me.specKey = key etc


method GetMyIconID() as Integer
  return me.??
.
method SetMyIconID(i as Integer)
  me.?? = i
.

Code: [Select]
method GetMyName() as String
  return me.displayName
.
method SetMyName(name as String)
  me.displayName = name
.
method GetMyDescription() as String
  return me.DisplayDescription
.
method SetMyDescription(desc as String )
  me.DisplayDescription = desc
.
method GetMySpecKey() as ID
  return me.SpecKey
.
method SetMySpecKey(key as ID)
  me.SpecKey = key
.
Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

ToY-Krun

  • General Accounts
  • *
  • Posts: 677
  • Support Volunteer
    • View Profile
Re: Basic SpecOracle setup
« Reply #36 on: Mar 24, 16, 09:19:18 PM »

SCRIPT ERROR: Node 0 not found to call method _SETICONID

means the spec isnt loaded or was null at the point _setIconID() was called.
This "COULD" be due to the load getting interrupted by the iconID field not being found.
Try adding the field and see what it does.

And for the field its iconID and should be added to both client and server versions of
the SPEC Class (abilitySpec/itemSpec etc).

I need to add that to the tut for the base spec editor.

If it still doesnt work, need to see what line is calling the _SetIconID method.

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
Re: Basic SpecOracle setup
« Reply #37 on: Mar 24, 16, 10:08:11 PM »

The node 0 seems to point at a GUI which might not have been created.

Code: [Select]
//returns the noderef of our Icon represented in the editor panel
method GetIcon() as NodeRef of Class GUIControl
  return FindGUIControlByName(me, "infopanel.icon")
.

method SetIcon(iconID as Integer)
  var icon = me.GetIcon()
  icon._SetIconID(iconID)
...

method PopulateSpecEditorFields(spec as NodeRef)
  //set the classification textbox as multiline
  me.GetClassificationList().isMultiLine = true
 
  //populate all the fields with appropriate stored data or initial new data
  //spec points to the AbilitySpecClass, and is a noderef of that class
  me.SetMySpecKey( spec.GetMySpecKey())
  me.SetMyName( spec.GetMyName())
  me.SetMyDescription( spec.GetMyDescription())
  me.SetMyIconID( spec.GetMyIconID() )
  me.SetIcon(spec.GetMyIconID())            //<-----
 
...

« Last Edit: Mar 24, 16, 10:09:42 PM by Thazager »
Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

ToY-Krun

  • General Accounts
  • *
  • Posts: 677
  • Support Volunteer
    • View Profile
Re: Basic SpecOracle setup
« Reply #38 on: Mar 24, 16, 10:13:24 PM »


method SetIcon(iconID as Integer)
  var icon = me.GetIcon()
  icon._SetIconID(iconID)
...


okay i think i see now, this method is in the editor script right?

if so then yes, the ICON gui isnt created yet and is throwing the error.

If thats the case (and i'll be able to tell when i can look at the script) then I believe i know the cause.
I do seem to remember removing some controls from the xml that I thought were inactive, and one of them
may have involved the "default" icon panel.

I'll try to have you an answer tomorrow.

Thanks for posting the code, that helps me know where to look.

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
Re: Basic SpecOracle setup
« Reply #39 on: Mar 24, 16, 10:42:06 PM »

Yes,  *Ability*SpecEditorMainPanelClassMethods
Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

ToY-Krun

  • General Accounts
  • *
  • Posts: 677
  • Support Volunteer
    • View Profile
Re: Basic SpecOracle setup
« Reply #40 on: Mar 25, 16, 11:46:04 AM »

right... okay, yet another piece(s) missing... lol
As I mentioned early on this is a huge amount of content so bear with me :)

Okay the current roadblock:

Quote
SCRIPT ERROR: Node 0 not found to call method _SETICONID

Stems from line 1 of the following method in *Ability*SpecEditorMainPanelClassMethods

Quote
//first gets our icon noderef, and then
//sets it to display our stored icon (if any) by its ID
method SetIcon(iconID as Integer)
1  var icon = me.GetIcon()
2  icon._SetIconID(iconID)

4  var textures = icon._GetIconTextures()
5  var iconSize = icon._GetIconGridInfo()
6  //sets the appropriate icon texture from the texture map
7  icon._SetIconTexture(textures, iconsize, iconID)
.

Caused when that line calls the following Method in the same script:

Quote
//returns the noderef of our Icon represented in the editor panel
method GetIcon() as NodeRef of Class GUIControl
  return FindGUIControlByName(me, "infopanel.icon")
.

Reason: the infopanel control exists, but the control named icon does NOT exist...
It doesnt exist because it isnt being created due to the fact that we have a class
still missing, along with a simple xml for the gui control.

I mention all that just for the sake of explanation if you're interested :)

that icon control is of the class ItemIcon

(this control is instantiated at line 53 in the *Ability*SpecEditorMainPanel)
The control itself is merely a default icon image, and a placeholder for the Icon which you
will choose when you select your chosen icon image via the IconChooserGUI.

If all that makes sense...

Now, on to the solution.

we need to add 3 classes and 1 xml

First we need to create a Base Icon class which will be the base of all of the
various types of icons you might create.

(for reference in HJREF this class is called HJ_Icon)
So give your base icon class a name like.. AoH_Icon
I advise simplicity in the name, you'll likely use it more times than any other
name in client scripting... :)

First a few preliminaries:

1- Open the CLIENT DoM and create a new FIELD named allowIconInfoPanel (type = boolean)
    IF it does not exist already.
2- Create a new Class named IconInfoPanelInterface (Archetype = DATA)
3- Add the FIELD allowIconInfoPanel to the new class IconInfoPanelInterface
Save
(NO SCRIPT)(NO XML)

*Now the Base Icon Class
4- In the CLIENT DoM create a new class called YourAbrev_Icon (Archetype = GUIControl)
5 - add _GUIIcon as a parent class to YourAbrev_Icon
6- add IconInfoPanelInterface as a parent class to YourAbrev_Icon class
SAVE

7- Click Open Script and create empty script.
8- Copy/paste the following Code into the new script

NOTE: Most of the script is commented out as it deals with the Icons and that is a system
you likely do not have in place yet and will require a tutorial entirely separate from this tutorial
I will try to do that next as I get time.


Code: [Select]
//#define debug
//---------------------------------------
// Gives common funcionality to Base Icons
//---------------------------------------


method _AllowIconDragAway(icon as NodeRef of Class _GUIIcon) as Boolean
  #if debug
  println("_AllowIconDragAway")
  #endif
  return true
.



method HE_onMouseClick(args references Class GUIMouseEvent)
  //-------------
  // Icon clicked
  //-------------
  #if debug
  str as String = "Icon " + me
  if args.leftButton
    str = str + " left clicked."
  .
  if args.rightButton
    str = str + " right clicked."
  .
  println(str)
  #endif
  //these commented calls left for examples from HJREF
  //me._DetachIcon()
  //me.allowMove = true
  //me.positionControlAtMouse()
  //args.handled = true
  //return
  //  newControl as NodeRef of Class GUIControl = me._CloneControl( false )
  //  newControl.positionControlAtMouse()
  subj as NodeRef = me._iconSubject
  //println(me.rootParent().name)
 
  //return
  if subj != None
    where subj is kindof Ability
     
    .
    //where subj is kindof Macro
     
    //.   
    if args.rightButton and not $GUI._ShiftIsPressed()
      subject as NodeRef = me._iconSubject
     
      #if debug
      println("Subject: " + subject)
      #endif
    .
  .

  var parentControl = me.parent
  while parentControl != None and args.handled != true
    if hasMethod(parentControl, "_onIconMouseClick")
      parentControl._onIconMouseClick(args)
      if args.source == None
        args.handled = true
        return
      .
    .
    parentControl = parentControl.parent
  .
.
method onMouseEnter(args references Class GUIMouseEvent)
  #if debug
  println("onMouseEnter " + me.name + " " + me)
  #endif
  if me.allowIconInfoPanel = true
    var container = me._GetIconContainer()
    if container != None
      // not all icons are in containers...like node property editor ones
     
    .
  .
  //TUTORIAL NOTE: for tutorial be sure to change ItemIcon if you used a different name
  where me is kindof ItemIcon
    //KRUN: invItem references an inventory item, change as you need.
    invItem as NodeRef of Class Item = me._GetIconSubject()
//KRUN: Ive left the following in comments for reference, it would require an additional class
//to set up, but the ExpandedInfoItemContainer is a class and GUI to display information
//when hovering the mouse over an icon
    if (invItem <> None)
      //f as NodeRef of Class ExpandedInfoItemContainer = FindGUIControlByName(0, "item info panel")
      //c as NodeRef of Class ExpandedInfoItemContainer
      //if f != None
      //  destroynode(f)
      //.
      //c = CreateNodeFromPrototype("expandedInfoItemContainer")
      //c.build = true
      //c.name = "item info panel"
      //c.ignoreMouseEvents = true
      //c.positionControlAtMouse()
      //c.radioButtonStyle = true
      //c.ExpandedInfoItem_AdoptSubject(invItem)
    .
  .
  parentClass::onMouseEnter(args)
.
method onMouseLeave(args references Class GUIMouseEvent)
  #if debug
  println("onMouseLeave " + me.name + " " + me)
  #endif
  ////TUTORIAL NOTE: Again, change ItemIcon if you used another name
  where me is kindof ItemIcon
    f as NodeRef of Class ExpandedInfoItemContainer = FindGUIControlByName(0, "item info panel")
 
    if f != None
      destroynode(f)
    .
  .
  parentClass::onMouseLeave(args)
.
method onMouseDown(args references Class GUIMouseEvent)
  #if debug
  println("onMouseDown " + me.name + " " + me)
  #endif
  //TUTORIAL NOTE: Again, change ItemIcon if you used another name
  where me is kindof ItemIcon
    f as NodeRef of Class ExpandedInfoItemContainer = FindGUIControlByName(0, "item info panel")
 
    if f != None
      destroynode(f)
    .
  .
 
 
  //Krun: if shift pressed destroy the item and icon by calling icondroppedintooblivion
  if args.rightButton == true and $GUI._ShiftIsPressed()
    var subj = me._iconSubject
    var ctnr = me._GetIconContainer()
   
 
   
    //where ctnr
    //  is kindof inventoryIconContainer
       
        ////        warning as NodeRef of Class PER_confirmDialog
        ////        if (warning == None)
        ////          warning = createNodeFromPrototype("PER_confirmDialog")
        ////          warning.build = true
        ////          warning.CenterControlOver( None )
        ////          warning.parentCntrl = me
        ////          warning._changeWindowTitleText("Delete Item?") // change titlebar warning
        ////          warning._SetAcceptButtonText("Yes") // change the acceptance button text
        ////          warning._SetDeclineButtonText("No") // change the decline button text
        ////          //warning._DisableDeclineButton() // removes decline button from warning and centers acceptance button if it exists
        ////          //warning._DisableAcceptButton()  // removes acceptance button from warning and centers decline button if it exists
        ////        .
    //    ctnr.IconDroppedIntoOblivion(me)
    //  .
    //.
    args.handled = true
    return
  .
 
  //this activates the item in the ability bar when clicked
  subj as NodeRef = me._iconSubject
  //println(me.rootParent().name)
  //parentCheck as String = SubString(me.parent.name, 1, 4)
  //if ToLower(parentCheck) == "slot"
  //  if subj != None
  //    where subj
  //      is kindof Ability
  //        usestr as String = "/ability use " + subj.abName
  //        SendCommand(usestr)
  //        args.handled = true
  //        return
  //      .
  //      is kindof Macro
  //        usestr as String = subj.macroscript
  //        //println(usestr)
  //        SendCommand(usestr)
   //       args.handled = true
   //       return
  //      .
  //    .
  //   
  //  .
  //.
  parentClass::onMouseDown(args)
.

method HE_ConfirmDialogAccepted()
  // Used by the dialog created from $ALERT._ConfirmDialag() to permit activity when the dialog accepted.
  #if debug
  println("Accept")
  #endif
  //alert as NodeRef of Class PER_confirmDialog = FindGUIControlByName(None,"PER_confirmDialog")
  //if (alert <> None)
  //  var icon = alert.parentCntrl
  //  var cntr = icon._GetIconContainer()
  //  cntr.IconDroppedIntoOblivion(icon)
  //.
.

method HE_ConfirmDialogDeclined()
  // Used by the dialog created from $ALERT._ConfirmDialag() to permit activity when the dialog declined.
  #if debug
  println("Decline")
  #endif
  //alert as NodeRef of Class PER_confirmDialog = FindGUIControlByName(None,"PER_confirmDialog")
  //if (alert <> None)
  //  destroynode(alert)     
  //.
.

method _OnIconDragStart()//ed()
  //
  // Overridden from _GUIIcon
  //
 
  //println("on icon drag start")
  //var cntnr = me._GetIconContainer()
  //var subject = me._iconSubject
 
  //if me.isInert
  //  if subject != None
  //    var icon = subject._CreateIcon()
  //    icon._SetIconInert(true)
  //    cntnr._PutIconInContainer(icon)
  //    cntnr._SetIconAppearanceForContainer(icon)
  //  .
  //else 
  //  if cntnr != None and cntnr._NeedGhostIcon(me)
  //    var ghostIcon = me._iconSubject._CreateGhostIcon()
  //    cntnr._PutIconInContainer(ghostIcon)
  //    cntnr._SetGhostIconAppearanceForContainer(ghostIcon)
  //  .
  //.
     
  //if subject != None
  //  subject._OnIconDraggedAway(me)
  //.
 
  //if cntnr != None
  //  cntnr._OnIconDraggedAway(me)
  //.
 
  //me.ignoreMouseEvents = true
 
  //me._DetachIcon()
 
  //DragDelay:AdjustToOffset(me)
  //DragNDrop:StartDragging(me)
 
  //if HasMethod(me, "HJIcon_SetDragApperanceOn")
  //  me.HJIcon_SetDragApperanceOn()
  //.
.

method _OnIconDragDropped()
  //-------------------------
  // Overridden from _GUIIcon
  //-------------------------
  println("_OnIconDragDropped()")
  //if HasMethod(me, "HJIcon_SetDragApperanceOff")
  //  me.ignoreMouseEvents = false
  //  me.HJIcon_SetDragApperanceOff()
  //  return
  //.
  //me.ignoreMouseEvents = false
.

method HJIcon_SetDragApperanceOn()
  // override this method to change the appearance of your icon while dragging
.
method HJIcon_SetDragApperanceOff()
  // override this method to change the appearance of your icon when done dragging
.


ToY-Krun

  • General Accounts
  • *
  • Posts: 677
  • Support Volunteer
    • View Profile
Re: Basic SpecOracle setup
« Reply #41 on: Mar 25, 16, 11:46:21 AM »

Next Create our Specific Icon type, This will reference the ItemIcon type as that is the
Icon Type i use for all icons in our game (thus the same scripts and icon types work in all windows
for all purposes).
 
However you can create a new type for various icons if you wish.
This code provided uses ItemIcon, if you wish to use (for example) AbilityIcon
then you will need to go through the XML and the scripts and change all references of
ItemIcon.




1- In the CLIENT DoM create a new Class called ItemIcon (Archetype = GUIControl)
2- Add YourAbrev_Icon(the base icon class you created) as a parent class to ItemIcon class
3- Create Field (if non existent) named beingDeleted (Type = boolean)
4- Add FIELD beingDeleted to ItemIcon Class

Save

5- Click Open Script and then Create Empty Script
6- Copy / paste the following code to new script

Again much of this script is commented out as it deals with the icon system itself and
inventory etc, and other actions taken when icons are clicked etc.
This I will try to deal with in another tutorial.
this script in particular can be found in HJREF if you wish to look further into it.
Some has been removed, some added (and all custom content for the most part removed as it
deals with many other custom systems not involved here)

Code: [Select]
//#define debug
//#define debugswap

method GetIconGridInfo() as Class xy
  iconSize as Class xy
  iconSize.x = 50 // SIZE X
  iconSize.y = 70  // SIZE Y
  return IconSize
.
method _GetIconTextures() as List of String
  textures as List of String
  //MyIconSheet.dds refers to the Icon texture atlas you downloaded/created
  //during the IconChooserGUI tutorial.
  add back "/gui/MyIconSheet.dds" to textures // 1
 
  return textures
.

method _GetIconGridInfo() as Class xy
  iconSize as Class xy
  // **********************************
  iconSize.x = 96 // SIZE X
  iconSize.y = 128  // SIZE Y
  return IconSize
.

method DestroyMySubject()
 
  var subject = me._GetIconSubject()
  if subject == None
    destroynode(me)
    return
  .
  me.BeingDeleted = true
  oracle as NodeRef of Class SpecOracle = subject.getMySpecOracle()
  oracle.requestSpecByKey(subject.GetSpecKey(), me)
.

method ConfirmDestroy()
  println("ConfirmDestroy called by " + SYSTEM.EXEC.CALLEDBYSCRIPT + ":" + SYSTEM.EXEC.CALLEDBYFUNCTION)
  // open a confirm dialogue
  var subject = me._GetIconSubject()
  if subject == None
    destroynode(me)
    return
  .
  me.BeingDeleted = true
  oracle as NodeRef of Class SpecOracle = subject.getMySpecOracle()
  oracle.requestSpecByKey(subject.GetSpecKey(), me)
  //  println("request spec " + SYSTEM.TIME.NOW)
.
method _OnIconDropped(icon as NodeRef of Class _GUIIcon)
  println("testing icon drop")
  mysubj as NodeRef = me._iconSubject
  othersubj as NodeRef = icon._iconSubject
 
 
  //var lastCntr = icon.IconLastContainer
  //where lastCntr
   
  //  is kindof inventoryIconContainer
  //    inv as NodeRef of Class HJInventory
  //    myroot as NodeRef = me.rootParent()
  //    if myroot != None
  //      where myroot
  //        is kindof HJCharacterEquipmentWindow
  //          inv = myroot.GetMyInventory()
  //        .
  //        is kindof HJCharacterInventoryWindow
  //          inv = myroot.GetMyInventory()
  //        .
  //        is kindof MerchantWindow
  //          inv = myroot.GetMyInventory()
   //       .
   //     .
  //    .
  //    //println(char)
  //    inv.RequestSwapItems(otherSubj, mysubj)
  //  .
  //.
.
//Krun: any info needed from the items Spec can be loaded here before the icon is created in inventory
method EventRaised(obsSubject as NodeRef, data as NodeRef)
 
  //Krun: here we get any Spec info we need for the item to update fields etc
  where subject
    is kindof Ability
      // println(subject)
      //println(spec)
    .
  .
.

method _SetIconAppearanceToDefault()
  #if debug
  println("_SetIconAppearanceToDefault()")
  #endif
  me.defaultStatePresentation.color.a = 1.0
  me.size.x = 48
  me.size.y = 64
  me.isInert = false
.

method _SetIconAppearanceToGhost()
  me.defaultStatePresentation.color.a = 0.5
  me.isInert = true
.

method _SetIconAppearanceToDefaultDragged()
  me.defaultStatePresentation.color.a = .50
  me.size.x = 48
  me.size.y = 64
.
method _SetIconAppearanceToDragging()
  me.defaultStatePresentation.color.a = .75
  me.size.x = 48
  me.size.y = 64
.
method SetLocked(isUnlocked as Boolean)
  //kruntemp commented here is Lock/unlock code
  //  lock as NodeRef of Class LockedIconInsert = FindGUIControlByName(me,"locked")
  //  if lock = None
  //    lock = CreateNodeFromPrototype("LockedIconInsert")
  //    lock.build = true
  //    lock.ignoreMouseEvents = true
  //    lock.name = "locked"
  //    lock.position.x = 0
  //    lock.position.y = 0
  //    lock.scale = .8
  //    add back lock to me.children
  //  .
  //  lock.setLockState(isUnlocked)
.
method SetCurrentStackLabel(size as Integer)
  sizeText as String = size
  if size = 0 or size = 1
    sizeText = ""
  .
  //lbl as NodeRef of Class GUILabel = FindGUIControlByName(me, "stack")
  //if lbl = None
  //  lbl = CreateNodeFromPrototype("GUILabel")
  //  lbl.build = true
  //  lbl.name = "stack"
  //  lbl.dockMode = BOTTOM
  //  lbl.scale = 1.2
  //  lbl.displayfont = GAMETEXT
  //  add back lbl to me.children
  //.
  //lbl.text = "{b:#0,0,0,1}" + sizeText + "{/}"
.
method SetCurrentChargesLabel(charges as Integer)
  //sizeText as String = charges
  //lbl as NodeRef of Class GUILabel = FindGUIControlByName(me, "charges")
  //if lbl = None
  //  lbl = CreateNodeFromPrototype("GUILabel")
  //  lbl.build = true
  //  lbl.name = "charges"
  //  lbl.dockMode = BOTTOM
  //  lbl.scale = 1.2
  //  lbl.justification = TOPRIGHT
  //  lbl.displayfont = GAMETEXT
  //  add back lbl to me.children
  //.
  //lbl.text = "{b:#0,0,0,1}" + sizeText + "{/}"
.
method _SetupIcon()
  //krun: code here for checking/updating an items info from Spec
  str as String
 
  var subj = me._iconSubject
  if subj != None
    where subj is kindof Item
     
      str = str + " " +subj.displayName
      str = str + "  " + subj.DisplayDescription
    .
  .
  //println("info set")
  me.tooltip = str
  parentClass::_SetupIcon()
.
method HE_onMouseDblClick(args references Class GUIMouseEvent)
  //Krun: Im disabling this for the merchant window for now
  //at some point we can re add it, and set it to buy or whatever.
  println("double click")
  myroot as NodeRef = me.rootParent()
  //if myroot is kindof MerchantWindow
  //  println("dbl click not available in merchant window yet")
    //return
  //.
 
  if args.leftButton
    //println("activate icon")
    //-------------------------
    // Double click left button
    //-------------------------
    me.ActivateIcon(args)
  .
.
method ActivateIcon(args references Class GUIMouseEvent)
  //fancy stuff here when icon activated
 
.

function Debug(msg as String)
  #if debug
  println(SYSTEM.EXEC.CALLEDBYFUNCTION + " (" + me + ") -> " + msg)
  #endif
.
method ItemIcon_IndicateOn()
  //these prototypes would need to be created/added for the tutorial
  //left as reference
  //kruntemp commented itemiconGlowpanel
  //c as NodeRef of Class ItemIconGlowPanel
  //c = CreateNodeFromPrototype("ItemIconGlowPanel")
  //c.build = true
  //add back c to me.children
  //c.ItemIconGlowPanel_StartGlowing()
.
method ItemIcon_IndicateOff()
  //kruntemp commented itemiconglowpanel
  //c as NodeRef of Class ItemIconGlowPanel
  //c = FindGUIControlByName(me, "ItemIconGlowPanel")
  //if c <> None
  //  c.ItemIconGlowPanel_StopGlowing()
  //  destroynode(c)
  //.
.
//method ItemIcon_GetIndicator() as NodeRef of Class GUIControl
//  return FindGUIControlByName(me, "ItemIconGlowPanel")
//.
method InventoryEventRaised(eventName as String, eventObject as NodeRef, data as String)
 
  when eventName
    is "stacksizeupdated"     
     
    .
    is "itemplacedinbackpack"
     
    .
  .
.
method HJIcon_SetDragApperanceOn()
 
.
method HJIcon_SetDragApperanceOff()
 
.


Compile and Submit

Now for the XML for the ItemIcon itself

in the Script editor create a New CLIENT XML called ItemIcon

Copy / Paste the following xml to your new file:

Where you see "MyIconAtlas.dds" below, replace that with the name of the icon texture atlas you
downloaded/created during the IconChooserGUI tutorial on the wiki HERE:

http://wiki.anvilofhonor.com/wiki/index.php/IconChooserGUI_Tutorial

Code: [Select]
<createControlType class='ItemIcon' type='itemIcon' description='base icon for items' treePath='' name="itemIcon" texture="\GUI\MyIconAtlas.dds" inheritDisabledState="false" inheritSelectedState="false" inheritHoveringState="false" owner="0" skipTextureAlphaTest="true" layer="game" _isIconSticky="true" allowIconInfoPanel="true">
  <size x="48" y="64"/>
  <maximumSize x="2048" y="2048"/>
  <defaultStatePresentation>
    <position x="96" y="133"/>
    <size x="98" y="126"/>
  </defaultStatePresentation>
  <selectedHoverStatePresentation>
    <size x="0" y="0"/>
  </selectedHoverStatePresentation>
</createControlType>

compile and submit.


ToY-Krun

  • General Accounts
  • *
  • Posts: 677
  • Support Volunteer
    • View Profile
Re: Basic SpecOracle setup
« Reply #42 on: Mar 25, 16, 11:53:36 AM »

NOTE: I purposely commented out/removed alot of code from the previous scripts related to Icons...

That system is almost as large (if not larger) as the spec system itself, depending on your game
design, it might wind up even more complex...

I will attempt to put together a comprehensive tutorial on setting up a basic, but fully functional
Icon system as I get time in the coming week. (right after I better organize the Spec Oracle tutorial)

I'll focus on getting this tut finished and you should at least when finished with it be able to select
an icon of choice for your specs.

What you can do with icons falls into a completely different category :)
but if you want to dive into that, note the references i left in the scripts and take a look at the
scripts by the same names on the HJREF world.

I personally took that system, and adapted the ItemIcon, as well as the HJIcon classes to my own
use.  To simplify the work flow on my end (and because it suits my design) all of our icons are of the
ItemIcon type and there is no other... when i need something different i simply glom on a new decorator
to the Icon itself :)

Anyway, thats a subject for another Tut. (and if someone else wants to cover that , thats perfectly fine with me!)

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
Re: Basic SpecOracle setup
« Reply #43 on: Mar 25, 16, 07:59:13 PM »

a few compile errors in script YourAbrev_IconClassMethods :


in method HE_onMouseClick(args references Class GUIMouseEvent)
  if subj != None
    where subj is kindof Ability                  //<------ Ability class undefined (in a few places)
     
    .

----------------------------------------------------------------------------------------------
IN class YourAbrev_Icon with IconInfoPanelInterface class as a parent

method onMouseEnter(args references Class GUIMouseEvent)
  if me.allowIconInfoPanel = true              //<------------ field allowIconInfoPanel not found in DataBase:GOM lookup


-----------------------------------------------------------------------------------------------
method onMouseLeave(args references Class GUIMouseEvent)

    f as NodeRef of Class ExpandedInfoItemContainer = FindGUIControlByName(0, "item info panel")    //<------ ExpandedInfoItemContainer class undefined (few places)



-----------------------------------------------------------------------------------------------

a few compile errors in script ItemIconClassMethods :


method EventRaised(obsSubject as NodeRef, data as NodeRef)

  where subject                           //<------------- variable not defined
    is kindof Ability                       //<------------- class not defined


-----------------------------------------------------------------------------------------------
method _SetupIcon()

  if subj != None
    where subj is kindof Item            //<-------- what replaces Item?  is this "ItemIcon" or "YourAbrev_Icon" (not getting either to work)
     
      str = str + " " +subj.displayName
« Last Edit: Mar 25, 16, 08:00:46 PM by Thazager »
Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

ToY-Krun

  • General Accounts
  • *
  • Posts: 677
  • Support Volunteer
    • View Profile
Re: Basic SpecOracle setup
« Reply #44 on: Mar 25, 16, 09:23:39 PM »

Quote
a few compile errors in script YourAbrev_IconClassMethods :


in method HE_onMouseClick(args references Class GUIMouseEvent)
  if subj != None
    //where subj is kindof Ability                  //<------ Ability class undefined (in a few places)
     
    //.

Left for reference as an example of use, should have been commented out

Quote
----------------------------------------------------------------------------------------------
IN class YourAbrev_Icon with IconInfoPanelInterface class as a parent

method onMouseEnter(args references Class GUIMouseEvent)
  if me.allowIconInfoPanel = true              //<------------ field allowIconInfoPanel not found in DataBase:GOM lookup


Quote
1- Open the CLIENT DoM and create a new FIELD named allowIconInfoPanel (type = boolean)
    IF it does not exist already.
2- Create a new Class named IconInfoPanelInterface (Archetype = DATA)
3- Add the FIELD allowIconInfoPanel to the new class IconInfoPanelInterface


if the parenting took, the field should exist.. odd.  check the YourAbrev_Icon class in the dom and see if the field appears in the
field list in the Parent Class section.
Quote
-----------------------------------------------------------------------------------------------
method onMouseLeave(args references Class GUIMouseEvent)

   // f as NodeRef of Class ExpandedInfoItemContainer = FindGUIControlByName(0, "item info panel")    //<------ ExpandedInfoItemContainer class undefined (few places)


Yeah, should all be commented out, this all relates to icons.

Quote
-----------------------------------------------------------------------------------------------

a few compile errors in script ItemIconClassMethods :


method EventRaised(obsSubject as NodeRef, data as NodeRef)

  where subject                           //<------------- variable not defined
    is kindof Ability                       //<------------- class not defined


Same.  Needs commented.

Quote
-----------------------------------------------------------------------------------------------
method _SetupIcon()

  if subj != None
    where subj is kindof Item            //<-------- what replaces Item?  is this "ItemIcon" or "YourAbrev_Icon" (not getting either to work)
     
      str = str + " " +subj.displayName

Item is a SpecDerivedObject class, which hasnt been gotten to yet.
For now it should be commented out as well.


My main goal in this tut was to :
1 create the spec oracle system
2 create the base editor
3 have them function to the point of adding/editing specs.

the SpecDerivedObjects and Icons fall outside that, but I'll do what I can to explain those in detail as well.
You may have setup the SpecDerivedObject during the SpecOracle system tut, if so, "Item" would be replaced with
whatever you worked with (ability/item/quest etc) whatever the SDO class is.

Following is the above scripts with the comments made:

YourAbrev_IconClassMethods:

Code: [Select]
//#define debug
//---------------------------------------
// Gives common funcionality to Base Icons
//---------------------------------------


method _AllowIconDragAway(icon as NodeRef of Class _GUIIcon) as Boolean
  #if debug
  println("_AllowIconDragAway")
  #endif
  return true
.



method HE_onMouseClick(args references Class GUIMouseEvent)
  //-------------
  // Icon clicked
  //-------------
  #if debug
  str as String = "Icon " + me
  if args.leftButton
    str = str + " left clicked."
  .
  if args.rightButton
    str = str + " right clicked."
  .
  println(str)
  #endif
  //these commented calls left for examples from HJREF
  //me._DetachIcon()
  //me.allowMove = true
  //me.positionControlAtMouse()
  //args.handled = true
  //return
  //  newControl as NodeRef of Class GUIControl = me._CloneControl( false )
  //  newControl.positionControlAtMouse()
  subj as NodeRef = me._iconSubject
  //println(me.rootParent().name)
 
  //return
  if subj != None
    //where subj is kindof Ability
     
    //.
    //where subj is kindof Macro
     
    //.   
    if args.rightButton and not $GUI._ShiftIsPressed()
      subject as NodeRef = me._iconSubject
     
      #if debug
      println("Subject: " + subject)
      #endif
    .
  .

  var parentControl = me.parent
  while parentControl != None and args.handled != true
    if hasMethod(parentControl, "_onIconMouseClick")
      parentControl._onIconMouseClick(args)
      if args.source == None
        args.handled = true
        return
      .
    .
    parentControl = parentControl.parent
  .
.
method onMouseEnter(args references Class GUIMouseEvent)
  #if debug
  println("onMouseEnter " + me.name + " " + me)
  #endif
  if me.allowIconInfoPanel = true
    var container = me._GetIconContainer()
    if container != None
      // not all icons are in containers...like node property editor ones
     
    .
  .
  //TUTORIAL NOTE: for tutorial be sure to change ItemIcon if you used a different name
  where me is kindof ItemIcon
    //KRUN: invItem references an inventory item, change as you need.
    invItem as NodeRef of Class Item = me._GetIconSubject()
//KRUN: Ive left the following in comments for reference, it would require an additional class
//to set up, but the ExpandedInfoItemContainer is a class and GUI to display information
//when hovering the mouse over an icon
    if (invItem <> None)
      //f as NodeRef of Class ExpandedInfoItemContainer = FindGUIControlByName(0, "item info panel")
      //c as NodeRef of Class ExpandedInfoItemContainer
      //if f != None
      //  destroynode(f)
      //.
      //c = CreateNodeFromPrototype("expandedInfoItemContainer")
      //c.build = true
      //c.name = "item info panel"
      //c.ignoreMouseEvents = true
      //c.positionControlAtMouse()
      //c.radioButtonStyle = true
      //c.ExpandedInfoItem_AdoptSubject(invItem)
    .
  .
  parentClass::onMouseEnter(args)
.
method onMouseLeave(args references Class GUIMouseEvent)
  #if debug
  println("onMouseLeave " + me.name + " " + me)
  #endif
  ////TUTORIAL NOTE: Again, change ItemIcon if you used another name
  where me is kindof ItemIcon
    //f as NodeRef of Class ExpandedInfoItemContainer = FindGUIControlByName(0, "item info panel")
 
   // if f != None
   //   destroynode(f)
   // .
  .
  parentClass::onMouseLeave(args)
.
method onMouseDown(args references Class GUIMouseEvent)
  #if debug
  println("onMouseDown " + me.name + " " + me)
  #endif
  //TUTORIAL NOTE: Again, change ItemIcon if you used another name
  where me is kindof ItemIcon
    //f as NodeRef of Class ExpandedInfoItemContainer = FindGUIControlByName(0, "item info panel")
    //
    //if f != None
    //  destroynode(f)
    //.
  .
 
 
  //Krun: if shift pressed destroy the item and icon by calling icondroppedintooblivion
  if args.rightButton == true and $GUI._ShiftIsPressed()
    var subj = me._iconSubject
    var ctnr = me._GetIconContainer()
   
 
   
    //where ctnr
    //  is kindof inventoryIconContainer
       
        ////        warning as NodeRef of Class PER_confirmDialog
        ////        if (warning == None)
        ////          warning = createNodeFromPrototype("PER_confirmDialog")
        ////          warning.build = true
        ////          warning.CenterControlOver( None )
        ////          warning.parentCntrl = me
        ////          warning._changeWindowTitleText("Delete Item?") // change titlebar warning
        ////          warning._SetAcceptButtonText("Yes") // change the acceptance button text
        ////          warning._SetDeclineButtonText("No") // change the decline button text
        ////          //warning._DisableDeclineButton() // removes decline button from warning and centers acceptance button if it exists
        ////          //warning._DisableAcceptButton()  // removes acceptance button from warning and centers decline button if it exists
        ////        .
    //    ctnr.IconDroppedIntoOblivion(me)
    //  .
    //.
    args.handled = true
    return
  .
 
  //this activates the item in the ability bar when clicked
  subj as NodeRef = me._iconSubject
  //println(me.rootParent().name)
  //parentCheck as String = SubString(me.parent.name, 1, 4)
  //if ToLower(parentCheck) == "slot"
  //  if subj != None
  //    where subj
  //      is kindof Ability
  //        usestr as String = "/ability use " + subj.abName
  //        SendCommand(usestr)
  //        args.handled = true
  //        return
  //      .
  //      is kindof Macro
  //        usestr as String = subj.macroscript
  //        //println(usestr)
  //        SendCommand(usestr)
   //       args.handled = true
   //       return
  //      .
  //    .
  //   
  //  .
  //.
  parentClass::onMouseDown(args)
.

method HE_ConfirmDialogAccepted()
  // Used by the dialog created from $ALERT._ConfirmDialag() to permit activity when the dialog accepted.
  #if debug
  println("Accept")
  #endif
  //alert as NodeRef of Class PER_confirmDialog = FindGUIControlByName(None,"PER_confirmDialog")
  //if (alert <> None)
  //  var icon = alert.parentCntrl
  //  var cntr = icon._GetIconContainer()
  //  cntr.IconDroppedIntoOblivion(icon)
  //.
.

method HE_ConfirmDialogDeclined()
  // Used by the dialog created from $ALERT._ConfirmDialag() to permit activity when the dialog declined.
  #if debug
  println("Decline")
  #endif
  //alert as NodeRef of Class PER_confirmDialog = FindGUIControlByName(None,"PER_confirmDialog")
  //if (alert <> None)
  //  destroynode(alert)     
  //.
.

method _OnIconDragStart()//ed()
  //
  // Overridden from _GUIIcon
  //
 
  //println("on icon drag start")
  //var cntnr = me._GetIconContainer()
  //var subject = me._iconSubject
 
  //if me.isInert
  //  if subject != None
  //    var icon = subject._CreateIcon()
  //    icon._SetIconInert(true)
  //    cntnr._PutIconInContainer(icon)
  //    cntnr._SetIconAppearanceForContainer(icon)
  //  .
  //else
  //  if cntnr != None and cntnr._NeedGhostIcon(me)
  //    var ghostIcon = me._iconSubject._CreateGhostIcon()
  //    cntnr._PutIconInContainer(ghostIcon)
  //    cntnr._SetGhostIconAppearanceForContainer(ghostIcon)
  //  .
  //.
     
  //if subject != None
  //  subject._OnIconDraggedAway(me)
  //.
 
  //if cntnr != None
  //  cntnr._OnIconDraggedAway(me)
  //.
 
  //me.ignoreMouseEvents = true
 
  //me._DetachIcon()
 
  //DragDelay:AdjustToOffset(me)
  //DragNDrop:StartDragging(me)
 
  //if HasMethod(me, "HJIcon_SetDragApperanceOn")
  //  me.HJIcon_SetDragApperanceOn()
  //.
.

method _OnIconDragDropped()
  //-------------------------
  // Overridden from _GUIIcon
  //-------------------------
  println("_OnIconDragDropped()")
  //if HasMethod(me, "HJIcon_SetDragApperanceOff")
  //  me.ignoreMouseEvents = false
  //  me.HJIcon_SetDragApperanceOff()
  //  return
  //.
  //me.ignoreMouseEvents = false
.

method HJIcon_SetDragApperanceOn()
  // override this method to change the appearance of your icon while dragging
.
method HJIcon_SetDragApperanceOff()
  // override this method to change the appearance of your icon when done dragging
.



ItemIconClassMethods:

Code: [Select]
//#define debug
//#define debugswap

method GetIconGridInfo() as Class xy
  iconSize as Class xy
  iconSize.x = 50 // SIZE X
  iconSize.y = 70  // SIZE Y
  return IconSize
.
method _GetIconTextures() as List of String
  textures as List of String
  //MyIconSheet.dds refers to the Icon texture atlas you downloaded/created
  //during the IconChooserGUI tutorial.
  add back "/gui/MyIconSheet.dds" to textures // 1
 
  return textures
.

method _GetIconGridInfo() as Class xy
  iconSize as Class xy
  // **********************************
  iconSize.x = 96 // SIZE X
  iconSize.y = 128  // SIZE Y
  return IconSize
.

method DestroyMySubject()
 
  var subject = me._GetIconSubject()
  if subject == None
    destroynode(me)
    return
  .
  me.BeingDeleted = true
  oracle as NodeRef of Class SpecOracle = subject.getMySpecOracle()
  oracle.requestSpecByKey(subject.GetSpecKey(), me)
.

method ConfirmDestroy()
  println("ConfirmDestroy called by " + SYSTEM.EXEC.CALLEDBYSCRIPT + ":" + SYSTEM.EXEC.CALLEDBYFUNCTION)
  // open a confirm dialogue
  var subject = me._GetIconSubject()
  if subject == None
    destroynode(me)
    return
  .
  me.BeingDeleted = true
  oracle as NodeRef of Class SpecOracle = subject.getMySpecOracle()
  oracle.requestSpecByKey(subject.GetSpecKey(), me)
  //  println("request spec " + SYSTEM.TIME.NOW)
.
method _OnIconDropped(icon as NodeRef of Class _GUIIcon)
  println("testing icon drop")
  mysubj as NodeRef = me._iconSubject
  othersubj as NodeRef = icon._iconSubject
 
 
  //var lastCntr = icon.IconLastContainer
  //where lastCntr
   
  //  is kindof inventoryIconContainer
  //    inv as NodeRef of Class HJInventory
  //    myroot as NodeRef = me.rootParent()
  //    if myroot != None
  //      where myroot
  //        is kindof HJCharacterEquipmentWindow
  //          inv = myroot.GetMyInventory()
  //        .
  //        is kindof HJCharacterInventoryWindow
  //          inv = myroot.GetMyInventory()
  //        .
  //        is kindof MerchantWindow
  //          inv = myroot.GetMyInventory()
   //       .
   //     .
  //    .
  //    //println(char)
  //    inv.RequestSwapItems(otherSubj, mysubj)
  //  .
  //.
.
//Krun: any info needed from the items Spec can be loaded here before the icon is created in inventory
method EventRaised(obsSubject as NodeRef, data as NodeRef)
 
  //Krun: here we get any Spec info we need for the item to update fields etc
  where subject
   // is kindof Ability
      // println(subject)
      //println(spec)
   // .
  .
.

method _SetIconAppearanceToDefault()
  #if debug
  println("_SetIconAppearanceToDefault()")
  #endif
  me.defaultStatePresentation.color.a = 1.0
  me.size.x = 48
  me.size.y = 64
  me.isInert = false
.

method _SetIconAppearanceToGhost()
  me.defaultStatePresentation.color.a = 0.5
  me.isInert = true
.

method _SetIconAppearanceToDefaultDragged()
  me.defaultStatePresentation.color.a = .50
  me.size.x = 48
  me.size.y = 64
.
method _SetIconAppearanceToDragging()
  me.defaultStatePresentation.color.a = .75
  me.size.x = 48
  me.size.y = 64
.
method SetLocked(isUnlocked as Boolean)
  //kruntemp commented here is Lock/unlock code
  //  lock as NodeRef of Class LockedIconInsert = FindGUIControlByName(me,"locked")
  //  if lock = None
  //    lock = CreateNodeFromPrototype("LockedIconInsert")
  //    lock.build = true
  //    lock.ignoreMouseEvents = true
  //    lock.name = "locked"
  //    lock.position.x = 0
  //    lock.position.y = 0
  //    lock.scale = .8
  //    add back lock to me.children
  //  .
  //  lock.setLockState(isUnlocked)
.
method SetCurrentStackLabel(size as Integer)
  sizeText as String = size
  if size = 0 or size = 1
    sizeText = ""
  .
  //lbl as NodeRef of Class GUILabel = FindGUIControlByName(me, "stack")
  //if lbl = None
  //  lbl = CreateNodeFromPrototype("GUILabel")
  //  lbl.build = true
  //  lbl.name = "stack"
  //  lbl.dockMode = BOTTOM
  //  lbl.scale = 1.2
  //  lbl.displayfont = GAMETEXT
  //  add back lbl to me.children
  //.
  //lbl.text = "{b:#0,0,0,1}" + sizeText + "{/}"
.
method SetCurrentChargesLabel(charges as Integer)
  //sizeText as String = charges
  //lbl as NodeRef of Class GUILabel = FindGUIControlByName(me, "charges")
  //if lbl = None
  //  lbl = CreateNodeFromPrototype("GUILabel")
  //  lbl.build = true
  //  lbl.name = "charges"
  //  lbl.dockMode = BOTTOM
  //  lbl.scale = 1.2
  //  lbl.justification = TOPRIGHT
  //  lbl.displayfont = GAMETEXT
  //  add back lbl to me.children
  //.
  //lbl.text = "{b:#0,0,0,1}" + sizeText + "{/}"
.
method _SetupIcon()
  //krun: code here for checking/updating an items info from Spec
  str as String
 
  var subj = me._iconSubject
  if subj != None
    //where subj is kindof Item
     
    //  str = str + " " +subj.displayName
   //   str = str + "  " + subj.DisplayDescription
   // .
  .
  //println("info set")
  me.tooltip = str
  parentClass::_SetupIcon()
.
method HE_onMouseDblClick(args references Class GUIMouseEvent)
  //Krun: Im disabling this for the merchant window for now
  //at some point we can re add it, and set it to buy or whatever.
  println("double click")
  myroot as NodeRef = me.rootParent()
  //if myroot is kindof MerchantWindow
  //  println("dbl click not available in merchant window yet")
    //return
  //.
 
  if args.leftButton
    //println("activate icon")
    //-------------------------
    // Double click left button
    //-------------------------
    me.ActivateIcon(args)
  .
.
method ActivateIcon(args references Class GUIMouseEvent)
  //fancy stuff here when icon activated
 
.

function Debug(msg as String)
  #if debug
  println(SYSTEM.EXEC.CALLEDBYFUNCTION + " (" + me + ") -> " + msg)
  #endif
.
method ItemIcon_IndicateOn()
  //these prototypes would need to be created/added for the tutorial
  //left as reference
  //kruntemp commented itemiconGlowpanel
  //c as NodeRef of Class ItemIconGlowPanel
  //c = CreateNodeFromPrototype("ItemIconGlowPanel")
  //c.build = true
  //add back c to me.children
  //c.ItemIconGlowPanel_StartGlowing()
.
method ItemIcon_IndicateOff()
  //kruntemp commented itemiconglowpanel
  //c as NodeRef of Class ItemIconGlowPanel
  //c = FindGUIControlByName(me, "ItemIconGlowPanel")
  //if c <> None
  //  c.ItemIconGlowPanel_StopGlowing()
  //  destroynode(c)
  //.
.
//method ItemIcon_GetIndicator() as NodeRef of Class GUIControl
//  return FindGUIControlByName(me, "ItemIconGlowPanel")
//.
method InventoryEventRaised(eventName as String, eventObject as NodeRef, data as String)
 
  when eventName
    is "stacksizeupdated"     
     
    .
    is "itemplacedinbackpack"
     
    .
  .
.
method HJIcon_SetDragApperanceOn()
 
.
method HJIcon_SetDragApperanceOff()
 
.


Also if you feel the commented sections are confusing rather than helpful, I will remove them.
The only thing currently needed from these classes is the implementation of a couple methods and the xml for the
default icon control.

Hope this helps.

I'll be less busy after tomorrow and can devote more time to it.
Pages: 1 2 [3] 4