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

Author Topic: Pattern for an Editor GUI?  (Read 1361 times)

Hiro_Protagonist

  • World Owners
  • ****
  • Posts: 30
    • View Profile
Pattern for an Editor GUI?
« on: Mar 11, 14, 12:19:51 PM »

Hey, I'm hoping somebody can point me in the right direction a bit.

I have some nodes on one particular server that hold some dynamic data- they have to be normal nodes, not prototypes. Ordinarily, these nodes sit around and only the server and some other servers know about them- they are not replicated to the client.

I need to make a GUI that allows you to edit these nodes, and I'd like to know what the general pattern for this is?

I think what I need to do is set the nodes up to be replicated to the client (when I am in that particular area). I can then build a GUI based on the proxies. Changes to the data in the client proxy nodes should be replicated directly to the Server nodes. For some reason, it seems like there are complications involved here, though. I appreciate any guidance you can give me!
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1155
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Pattern for an Editor GUI?
« Reply #1 on: Mar 11, 14, 08:41:30 PM »

What I set up was a call to change the values in a GUI on client side. Then save them to the server on server side. These particular values are saved on the character node. You could probably add some checks on server side to see if they are in the max range.

Code: [Select]
// client side code
method _OnButtonMouseClick(button as NodeRef of Class _GUIButton, args references Class GUIMouseEvent)

  when button.name
    is "AlignButton"
      setAlignButton(value)
      call server E_playerAccountClassMethods:SetAlignmentServer(value)
    .
  .
.

// server side code
untrusted function SetAlignmentServer(align as String)
  acct as NodeRef of Class E_playerAccount = SYSTEM.REMOTE.client
  char as NodeRef of Class E_playerCharacter = acct.GetMyChar()
  char.Align = align
.


Logged

Hiro_Protagonist

  • World Owners
  • ****
  • Posts: 30
    • View Profile
Re: Pattern for an Editor GUI?
« Reply #2 on: Mar 11, 14, 11:46:10 PM »

RPC would definitely work, it just seems like more work than necessary when you have Replication available. The only way I can think of to get the data to the client in order to edit it is via an extra set of server->client RPC calls with a big parameter list. What are you doing to get the data to the client when you need it?
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1155
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Pattern for an Editor GUI?
« Reply #3 on: Mar 12, 14, 02:56:37 AM »

I use a combination of both replication and call client from some scripts. It depends on what is needed. When the character zones, I call replication and have some send back the info for setting up some GUIs.

Code: [Select]
//client side code
// init area for player to join in
method HE_OnReplicationNodeAdded(addedNode as NodeRef) as Boolean
  where addedNode
    is kindof E_playerCharacter
      if me = GetAccountID()
        if $BASECLIENT._AreaID = 93383990054    // create char area
          return false
        .
        CharBarClassMethods:Update(addedNode)
        miniMapClassMethods:start()
        ChatWindowClassMethods:start()

        call server E_playerAccountClassMethods:LoadCharacterServer(addedNode.name)
    .
  .
.

//server side code
untrusted function LoadCharacterServer(name as String)
  acct as NodeRef of Class E_playerAccount = SYSTEM.REMOTE.client
  char as NodeRef of Class E_playerCharacter = acct.GetMyChar()
  info as LookupList indexed by String of Class CharInfo = acct.CharInfoList

  char.Alignment = info[name].Alignment

  call reply E_playerAccountClassMethods:AlignmentGiven(char.Alignment)
.

// client side code - receive the alignment to send to character
remote function AlignmentGiven(align as String)
  acct as NodeRef of Class E_playerAccount = GetAccountID()
  char as NodeRef of Class E_playerCharacter = acct.GetMyCharacter()
  char.Alignment = align
.
Logged