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

Author Topic: (resolved) list of integer - wont save?  (Read 724 times)

Thazager

  • General Accounts
  • *
  • Posts: 1149
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
(resolved) list of integer - wont save?
« on: Apr 04, 16, 09:27:44 PM »

Working with the new tutorial on specs, I was able to set up a few values for input using textboxes. I was trying to group a few textbox values together (not the GUI itself), into a list of integer.

I can see the initial values being 0'ed, while the size is set. I can add in the values, and when I click "OK", it prints out the values that get saved. Then opening the spec again, it gets reinitialized not loading the values. I'm thinking a simple fix (that I might be overlooking). Or does the spec system just not like saving Lists?

field ReqStats is List of Integer
added to class AbilitySpec

GUI is setup correctly as it gets the numbers entered.


In AbilitySpecEditorMainPanelClassMethods

Code: [Select]
// get values and set in text boxes
method PopulateSpecEditorFields(spec as NodeRef)
  me.SetMySpecKey(spec.GetMySpecKey())                      // working

  me.SetMyReqStats(spec.GetMyReqStats())                     // new
.

// get values form text boxes and save
method OnGUINodePropertyEditorSubmit(node as NodeRef)
  node.SetMySpecKey(me.GetMySpecKey())                     // working

  node.SetMyReqStats(me.GetMyReqStats())                    // new
.


// working sample
method GetSpecKeyBox() as NodeRef of Class GUITextInputBox
  return FindGUIControlByName(me, "infopanel.speckey")
.

method GetMySpecKey() as ID
  return me.GetSpecKeyBox().value                // get value in textbox
.

method SetMySpecKey(key as ID)
  me.GetSpecKeyBox().value = key               // set value in textbox
.

//-----------------------------------------------------------------------------------
// new code
method GetReqStatsBox(i as Integer) as NodeRef of Class GUITextInputBox
  return FindGUIControlByName(me, "infopanel.reqstat"+i)
.

method GetMyReqStats() as List of Integer
  statList as List of Integer
  stat as Integer

  loop i from 1 to 4
    stat = me.GetReqStatsBox(i).value      // pull value from text box
    println("get "+i+" "+stat)           // display it
    add back stat to statList             // get value to send
  .
  return statList
.

// set values in text boxes
method SetMyReqStats(statList as List of Integer)
  loop i from 1 to 4
    println("set "+i+" "+statList[i])             // show value

    me.GetReqStatsBox(i).value = statList[i]   // set in text box
  .
.


and in AbilitySpecClassMethods

Code: [Select]
// working sample
method GetMySpecKey() as ID
  return me.SpecKey
.

method SetMySpecKey(key as ID)
  me.SpecKey = key
.

//--------------------------------------------------------------------------
// new code
method GetMyReqStats() as List of Integer
  println("load "+me.ReqStats.length)    // shows 0

  if me.ReqStats.length < 4   // check for initialize
    stats as List of Integer
    loop i from 1 to 4
      add back 0 to stats
    .
    me.ReqStats = stats        // save initialize
  .

  return me.ReqStats
.

method SetMyReqStats(stats as List of Integer)
  me.ReqStats = stats

  // just prints info
  loop i from 1 to 4
    println("save "+i+" "+me.ReqStats[i])   // show value loaded
  .
  println("save size "+me.ReqStats.length)  // show size
.

« Last Edit: Apr 05, 16, 10:46:13 AM by Thazager »
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1149
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: list of integer - wont save?
« Reply #1 on: Apr 05, 16, 10:45:51 AM »

Yes, it was something simple. I missed adding the field to the server side classes.
Logged