Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broadcast vars #42

Merged
merged 7 commits into from
May 28, 2017
Merged

Broadcast vars #42

merged 7 commits into from
May 28, 2017

Commits on Feb 16, 2017

  1. Implement 'magic' library blocks

    These are basically custom blocks with a special prefix ("$$SCRAP:")
    that get disguised as different blocks. Their procedure definitions
    don't appear in the scripting area or script explorer.
    
    Fun fact/misfeature: you can right-click on library blocks and get
    access to the usual "define" block, letting you access the block's
    code from your normal project! This is kind of interesting and does
    inspire things like real modules (..ha..ha..). In order to consider
    this a real feature I'll need to prevent those custom blocks from
    being edited.
    
    Also, this commit is S U P E R  C O N T R O V E R S I A L, because
    the current only langauge block dynamically sets a variable using a
    HACKED BLOCK! Which is somewhat against the idea of Scrap entirely.
    But that's why this is on a different branch.
    
    PS, of course, language blocks work in normal Scratch. They're only
    *displayed* differently, they're not actual new blocks.
    
    ----
    
    Scratch code changes:
    
    * New constants, Specs.MAGIC_PROC_PREFIX ("$$SCRAP") and
      Specs.MAGIC_PROC_HUMAN ("(Scrap)")
    
    * If the start of a block label is MAGIC_PROC_PREFIX, it will be
      replaced with MAGIC_PROC_HUMAN.
    
    * Converted PaletteBuilder.as into normal whitespace instead of
      tabs, for convenience
    
    * Added new "add library" button to More Blocks palette
      * Placed after normal custom blocks, before extensions
      * Adds blocks from the "Scrap library", through a new
        addJSONScripts ScratchObj method
    
    * Added new "visibleScripts" method to ScratchObj
      * Returns scripts that should be visible for editing
      * "Visible" means all scripts, excluding procedures whose
        definitions start with MAGIC_PROC_PREFIX
      * Used anywhere obj.scripts would be looped through in
        relation to displaying blocks (i.e. script browser, script
        pane)
    
    * Added new "magicProcedureDefinitions" method to ScratchObj
      * Returns the procedure definitions for library blocks
      * Includes only procedure definitions whose definitions start
        with MAGIC_PROC_PREFIX
    
    * Edited procedureDefinitions method to not include library block
      procedure defintions
    
    * Made variables that start with the text '$$broadcast' hidden
      in the block palette
      * To be continued further
    
    * Added new addJSONScripts to ScratchObj
      * Adds scripts from script entries, following the format found in
        project.json files
        * [x, y, stack]
      * Used by instantiateFromJSON and PaletteBuilder's addScrapLibrary
    towerofnix committed Feb 16, 2017
    Configuration menu
    Copy the full SHA
    9f9abba View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f2c166d View commit details
    Browse the repository at this point in the history

Commits on Feb 17, 2017

  1. Finish block-side of broadcast variables

    This commit finishes the broadcast variables UI/blocks part of
    broadcast variables. (Well, I guess that's all of it, since this
    mod doesn't change anything in the runtime..)
    
    -----
    
    * Added new broadcastVar menu
      * Gets all the broadcast variables of a specific broadcast message
        * Message gotten from block's first input
      * Has 'new variable' option
        * Opens a broadcast variable maker dialog, similar to the
          variable maker dialog
      * Used in 'set broadcast var' block, part of Scrap library
    
    * Updated 'set broadcast var' library block
      * Block spec now uses broadcast-specific menus instead of text
        inputs
    
    * Added new collectBroadcastVarNames method to ScratchStage
      * Gets global/stage variables that have a name following format
        BROADCAST_VAR_PREFIX + msg + '>' + (some name)
      * Used in broadcastVar menu
      * Should be used in PaletteBuilder (TODO)
    
    * Fixed duplicate variable 'b:Block' warning
    * Added missing semicolon
    towerofnix committed Feb 17, 2017
    Configuration menu
    Copy the full SHA
    48bf951 View commit details
    Browse the repository at this point in the history
  2. Fix palette update bug

    When you open a sprite, the palette was updated *before* its scripts
    were viewed, making the palette still think another script was viewed.
    
    This fixes the issue by updating the palette *after* the scripts are
    viewed in the script pane, rather than before.
    towerofnix committed Feb 17, 2017
    Configuration menu
    Copy the full SHA
    8fd41ab View commit details
    Browse the repository at this point in the history
  3. Use collectBroadcastVarNames in PaletteBuilder

    This simplifies PaletteBuilder's broadcast variable code quite
    significantly, removing redundant code.
    
    It also updates collectBroadcastVarName's return format, and
    changes the code in the broadcast variable menu accordingly.
    towerofnix committed Feb 17, 2017
    Configuration menu
    Copy the full SHA
    00bb337 View commit details
    Browse the repository at this point in the history
  4. Update palette on broadcast variable creation

    This is just so that a new broadcast variable will appear in
    the data palette as soon as you make it.
    towerofnix committed Feb 17, 2017
    Configuration menu
    Copy the full SHA
    d251d23 View commit details
    Browse the repository at this point in the history

Commits on Feb 18, 2017

  1. Configuration menu
    Copy the full SHA
    ed374ca View commit details
    Browse the repository at this point in the history