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

Author Topic: [Resolved] Spec GUI customization  (Read 2800 times)

TGSRofar

  • General Accounts
  • *
  • Posts: 153
    • View Profile
[Resolved] Spec GUI customization
« on: Nov 27, 10, 10:00:19 AM »

I have been fumbling through extending the Spec Oracle Editor for a SpecOracle I created.  I used HJ reference as a guide for this and managed to customize the Spec Editor Control as needed.  However, I struggled to figure out how to customize the Spec Selector control to display the columns I wanted to display.

Using the HJ implementation for RaceSpecOracle as an example, the Spec Selector control shows columns SpecKey and Race Name.  Mine was showing the defaults (SpecKey and PrototypeName).  I do understand that these columns are defined in the collectionHeaders list and there is a list mapping header name to display name.  I also found reference in the wiki on how to add columns by calling method AddCollectionHeader.

I spent a good deal of effort exploring the scripts in HJ for the RaceSpecOracle, but never could find where the column headers are being defined/customized.  I also looked at implemenation for other Spec Oracles in HJ and could not find anything that provided the custom headers for their Spec Selector Controls.

Finally, I just figured out a way I could accomplish this.  So I was able to customize the columns and add other columns I wanted.  Still, I would really like to know how this is being done in HJ.  Just because I found a way to do it, doesn't necessarily mean I am doing it the best/correct way.

Does anyone know how this is being done in HJ?
« Last Edit: Nov 03, 12, 08:27:03 PM by HE-Cooper »
Logged
Ron Farrell
Lead Programmer
Triad Game Studios

JoshHalls

  • Founding Professional
  • *****
  • Posts: 335
    • View Profile
    • The Repopulation
Re: Spec GUI customization
« Reply #1 on: Nov 28, 10, 02:13:48 PM »

A variety of ways.  I merged together the object/npc spec oracles and created a new class that takes care of most of the routines and then all new specs on the client side use that.  The nice thing about it, is the columns are auto created for most fields (integer, float, boolean, etc) and then of course you can create your own for special setups.  Saves a lot of time as most of the fields can be handled automatically and the rest you take the time to setup for your needs.  I believe it also supports calling other spec oracles to populated dropdowns.

I believe it is the object spec oracle you have to hold shift down to get it to work that way (or I might have it backwards and it is the NPC one).  They should look somewhat similar to the Wyr oracle as it uses a similar setup.

Also, if you don't create a custom gui it should use the standard one that does create controls as well for the common variables.  Did you get that far? 
Logged
Co-Owner/Programmer - The Repopulation

TGSRofar

  • General Accounts
  • *
  • Posts: 153
    • View Profile
Re: Spec GUI customization
« Reply #2 on: Nov 29, 10, 05:14:24 PM »

Thanks for the response.

Yes, I was able to customize the editor gui by created custom cells just fine.  I was able to create dropdown cells and numeric up/down cells also. So that isn't the issue.  The question is related to the Spec Selector window, not the editor window.  The distinction between these 2 windows can be seen in the wiki page "Spec Gui".  In the Spec Selector, there are rows for each spec that is created and the columns that are displayed in this window is what I was trying to customize.  Like I said, I figured out a way to do it so I don't necessarily need a solution at this point.  I would still like to know how this is being done in HJ though.  I can't find anything in the HJ scripts that indicate how it's being done there.
Logged
Ron Farrell
Lead Programmer
Triad Game Studios

HE-CHRISTOPHER

  • HeroEngine
  • *****
  • Posts: 424
    • View Profile
Re: Spec GUI customization
« Reply #3 on: Nov 30, 10, 10:58:47 AM »


Ultimately, I intend to support this via the UI itself via a right-click on the column or something of that nature. 

In the meantime, its a few lines of code to add what are called "headers" to a spec oracle's display.  The fields specified must be fields that are common to all specs within a spec oracle (e.g. you can not use fields that are in decorators that are not present on all specs.  I do not recall whether a field not shared by all specs will  simply not display...or might cause a script error.).

Code: [Select]
var oracle = getPrototype( "_seamlessAreaLinkSpecOracle" )
oracle.AddCollectionHeader( "displayName", "Name", true )
oracle.AddCollectionHeader( "displayDescription", "Description", true )

Logged
Christopher Larsen
CTO
HeroEngine

JoshHalls

  • Founding Professional
  • *****
  • Posts: 335
    • View Profile
    • The Repopulation
Re: Spec GUI customization
« Reply #4 on: Nov 30, 10, 12:21:48 PM »

We added a command to add collection headers, might want to add it is a core part of the system until the GUI is taken care of.  Had to dig around for that one as well.  It doesn't support Enums either, that would be nice to see as well.

Here is the code, drop this on the server.
Code: [Select]
shared function HE_ProcessCommandInput( account as NodeRef, input as String )
// The Command Handler calls this shared function based on a mapping stored on the COMMANDHANDLER prototype
//   which maps a /command to a script to call
//
  args as List of String
  Tokenize( input, args )
  if args.length < 2
    HE_CommandUsage( account, input )
    return
  .

  partialMatch toLower( args[2] )
    to "addcollectionheader"
      //Going to check to see if the Oracle is a valid one real quick so we can send back info if it is not.
      validOracle as NodeRef of Class SpecOracle
      temp as NodeRef
      temp = getPrototype(args[3])
      if temp != None
        if temp is kindof SpecOracle
          validOracle = temp
        .
      .
      if validOracle == None
        Msg(account, "Invalid Oracle name/type provided.")
      .
      var oracle = $SPECORACLEUTILS._GetOracleFromType( args[3] )
      //Check if the header field is in use
      if oracle.IsHeaderFieldInList(args[4]) or oracle.IsHeaderDisplayNameInUse( args[5] )
        Msg(account, "Header Field or Display is already in use for that Spec.")
      .     
      oracle.AddCollectionHeader( args[4], args[5], args[6] )
      Msg(account, "Collection Header added for " + args[3] + ".")
    .
    to "removecollectionheader"
      validOracle as NodeRef of Class SpecOracle
      temp as NodeRef
      temp = getPrototype(args[3])
      if temp != None
        if temp is kindof SpecOracle
          validOracle = temp
        .
      .
      if validOracle == None
        Msg(account, "Invalid Oracle name/type provided.")
      .
      var oracle = $SPECORACLEUTILS._GetOracleFromType( args[3] )
      oracle.RemoveCollectionHeader(args[4])
      Msg(account, "Collection Header removed for " + args[3] + ".")
    .
    default
      HE_CommandUsage( account, input )
      return
    .
  .
.

shared function HE_CommandUsage( account as NodeRef, input as String )
  // NOTE, this style is much more efficient on the client than doing a seperate Msg() for each line.
  // This is because only a single label gets created in chat, rather than one per line.
  msg as String = "/OracleCmd AddCollectionHeader <oracle Name> <fieldname> <displayname> <At The End>$R"
  msg = msg +     " - ....... RemoveCollectionHeader <oracle Name> <fieldname>$R"
  msg = msg + " - <At the End> - Place at the end of the header (compared to the beginner).  true/false$R"
  Msg( account, msg )
.

function Msg( account as NodeRef, msg as String )
  $CHAT.CHATPLAYER( account, "", msg )
.

« Last Edit: Nov 30, 10, 12:25:39 PM by joshhalls »
Logged
Co-Owner/Programmer - The Repopulation

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Spec GUI customization
« Reply #5 on: Dec 08, 10, 02:51:50 PM »

@joshhalls:
That is a very interesting command script.  It seems, however, that it requires more than 2 arguments as is checked for at the beginning?
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

JoshHalls

  • Founding Professional
  • *****
  • Posts: 335
    • View Profile
    • The Repopulation
Re: Spec GUI customization
« Reply #6 on: Dec 09, 10, 01:30:10 PM »

/OracleCmd AddCollectionHeader <oracle Name> <fieldname> <displayname> <At The End>

so (sorry that was more for me remembering than being descriptive)

/oracleCmd AddCollectionHeader MyOracleName displayName displayName true
Logged
Co-Owner/Programmer - The Repopulation