Announcement

Collapse

Forum Rules

  • No flaming or derogatory remarks, directly or through insinuation.
  • No discussion, sharing or referencing illegal software such as hacks, keygen, cracks and pirated software.
  • No offensive contents, including but not limited to, racism, gore or pornography.
  • No excessive spam/meme, i.e. copious one liners in a short period of time, typing with all caps or posting meme responses (text/image).
  • No trolling, including but not limited to, flame incitation, user provocation or false information distribution.
  • No link spamming or signature advertisements for content not specific to Dota 2.
  • No Dota 2 key requests, sell, trade etc.
  • You may not create multiple accounts for any purpose, including ban evasion, unless expressly permitted by a moderator.

  • Please search before posting. One thread per issue. Do not create another thread if there is an existing one already.
  • Before posting anything, make sure you check out all sticky threads (e.g., this). Do not create new threads about closed ones.
  • It is extremely important that you post in correct forum section.

  • Balance discussion only in Misc.
  • All art related (such as hero model) feedbacks go to Art Feedback Forum.
  • All matchmaking feedback should go here: Matchmaking Feedback
  • All report/low priority issues should go here: Commend/Report/Ban Feedback
  • No specific workshop item feedback. These should go to workshop page of that item.
  • When posting in non-bugs section (such as this), use [Bugs], [Discussion] or [Suggestion] prefix in your thread name.



In case you object some action by a moderator, please contact him directly through PM and explain your concerns politely. If you are still unable to resolve the issue, contact an administrator. Do not drag these issues in public.



All rules are meant to augment common sense, please use them when not conflicted with aforementioned policies.
See more
See less

[Bug/Suggestion? Not sure] GetAttribute/SetAttribute API Call

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Bug/Suggestion? Not sure] GetAttribute/SetAttribute API Call

    What's the intended behaviour for these?
    Code:
    GetAttributeInt	Panel.GetAttributeInt( cstring cstring_1, integer integer_2 )	
    GetAttributeString	Panel.GetAttributeString( cstring cstring_1, cstring cstring_2 )	
    GetAttributeUInt32	Panel.GetAttributeUInt32( cstring cstring_1, unsigned unsigned_2 )	
    SetAttributeInt	Panel.SetAttributeInt( cstring cstring_1, integer integer_2 )	
    SetAttributeString	Panel.SetAttributeString( cstring cstring_1, cstring cstring_2 )	
    SetAttributeUInt32	Panel.SetAttributeUInt32( cstring cstring_1, unsigned unsigned_2 )
    It seems to be separate from 'default' properties/attributes. I can SetAttribute 'text' to something, and GetAttribute properly returns what I set, but the text itself is unchanged.
    If that is not the intended behaviour, then I guess a fix is expected, but if it is, it would be nice to get the ability to change default props/atts like 'text', 'placeholder', etc.

  • #2
    The GetAttribute*/SetAttribute* functions seem to be a way to just keep internal state for an element. But their names' are deceiving when in the context of XML. By the name of these functions, it would make sense that they would set an attribute (as in the element) for the given panel, instead they set internal state. While this is useful, it still doesn't provide a way to set an actual attribute on an element other than the ones that are supported by the element (text, maxchars, etc.)

    Comment


    • #3
      Originally posted by zedor View Post
      What's the intended behaviour for these?
      Code:
      GetAttributeInt	Panel.GetAttributeInt( cstring cstring_1, integer integer_2 )	
      GetAttributeString	Panel.GetAttributeString( cstring cstring_1, cstring cstring_2 )	
      GetAttributeUInt32	Panel.GetAttributeUInt32( cstring cstring_1, unsigned unsigned_2 )	
      SetAttributeInt	Panel.SetAttributeInt( cstring cstring_1, integer integer_2 )	
      SetAttributeString	Panel.SetAttributeString( cstring cstring_1, cstring cstring_2 )	
      SetAttributeUInt32	Panel.SetAttributeUInt32( cstring cstring_1, unsigned unsigned_2 )
      It seems to be separate from 'default' properties/attributes. I can SetAttribute 'text' to something, and GetAttribute properly returns what I set, but the text itself is unchanged.
      If that is not the intended behaviour, then I guess a fix is expected, but if it is, it would be nice to get the ability to change default props/atts like 'text', 'placeholder', etc.
      A good example use of this at the moment is to pass values to loaded elements. E.g:

      Code:
      for (var playerId of Game.GetAllPlayerIDs()) {
        var playerInfo = Game.GetPlayerInfo(playerId);
        if (playerInfo["player_team_id"] === teamId) {
          var playerPanel = $.CreatePanel("Panel", playersPanel, "player" + playerId);
          playerPanel.SetAttributeInt("id", playerId);
          playerPanel.SetAttributeString("steamId", playerInfo["player_steamid"]);
          playerPanel.BLoadLayout("file://{resources}/layout/custom_game/draft/player.xml", false, false);
        }
      }
      player.xml can then load the attributes and act as a modularized component, with many loaded, each with different behaviour (in this case, one per player).

      Comment


      • #4
        Yep, but that's not really what this topic is about

        Comment


        • #5
          Originally posted by zedor View Post
          Yep, but that's not really what this topic is about
          Your post appeared to be expecting SetAttribute() to modify the elements, I was giving what I assume is the intended use - what you are talking about is something we'd want alongside the Get/SetAttribute() functionality (which is useful as it stands, as shown above).

          Given there are different types for the types of element in JS, it would seem odd (to me) to have a generic function passing in a name - instead just have attributes on the object to represent those on the element, and set them directly - that feels like a more natural interface.
          Last edited by Lattyware; 06-24-2015, 03:23 PM.

          Comment


          • #6
            Originally posted by Lattyware View Post
            Your post appeared to be expecting SetAttribute() to modify the elements, I was giving what I assume is the intended use - what you are talking about is something we'd want alongside the Get/SetAttribute() functionality (which is useful as it stands, as shown above).
            Yep, it did, but I did state what the current behaviour is and added
            If that is not the intended behaviour, then I guess a fix is expected, but if it is, it would be nice to get the ability to change default props/atts like 'text', 'placeholder', etc.
            Your example/explanation stands well on its own but I just thought it strange that you're directing it at me

            Comment

            Working...
            X