unblock

package
v0.24.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package unblock decodes blockly style story files into tapestry commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(dst typeinfo.Instance, topBlock string, reg Creator, msg json.RawMessage) (err error)

read blockly data into the passed tapestry command (tree). where topBlock is the expected topblock type in the file.... ex. story_file

func DecodeBlock

func DecodeBlock(dst typeinfo.Instance, reg Creator, top *BlockInfo) (err error)

decode a generic block public for testing.

Types

type BlockInfo

type BlockInfo struct {
	Id         string         `json:"id"`
	Type       string         `json:"type"`
	ExtraState map[string]int `json:"extraState"`
	Icons      Icons          `json:"icons"`
	Inputs     js.MapSlice    `json:"inputs"`
	Fields     js.MapSlice    `json:"fields"`
	Next       *Input         `json:"next"`
}

a stored blockly block recursive in the sense that inputs can contain other blocks note while in shape definitions fields are stored inside of inputs; in block data fields get stored separate from inputs, keyed by field name.

func (*BlockInfo) CountFields

func (bi *BlockInfo) CountFields(term string) (retStart, retCnt int)

func (*BlockInfo) CountInputs

func (bi *BlockInfo) CountInputs(term string) (retStart, retCnt int)

return the number of term# formatted inputs

func (*BlockInfo) ReadInput

func (bi *BlockInfo) ReadInput(idx int) (ret Input, err error)

return the number of term# formatted fields

func (*BlockInfo) SliceFields

func (bi *BlockInfo) SliceFields(term string) js.MapSlice

return the number of term# formatted fields

func (*BlockInfo) SliceInputs

func (bi *BlockInfo) SliceInputs(term string) js.MapSlice

return the number of term# formatted inputs

type Comment

type Comment struct {
	Text   string `json:"text"`
	Pinned bool   `json:"pinned"`
	Height int    `json:"height"`
	Width  int    `json:"width"`
}

this is how blockly handles comments fix? move to make part of the mutation ( as extra data )

type Creator

type Creator interface {
	NewType(string) (any, bool)
}

func MakeBlockCreator

func MakeBlockCreator(blocks []*typeinfo.TypeSet) Creator

type File

type File struct {
	TopBlocks `json:"blocks"`
}

describes a blockly file https://developers.google.com/blockly/guides/configure/web/serialization?hl=en

type Icons

type Icons struct {
	Comment *Comment `json:"comment"`
}

blockly stores comments inside of the icon representing the comment

type Input

type Input struct {
	*BlockInfo `json:"block"`
}

a blockly input contains a blockly block.

func (*Input) CountNext

func (bi *Input) CountNext() (ret int)

return the depth of the linked list starting in next.

func (*Input) GetNext

func (bi *Input) GetNext() (ret Input)

return the next input as a concrete object if there was no next input, the returned object's BlockInfo will be nil

type TopBlocks

type TopBlocks struct {
	LanguageVersion float64     `json:"languageVersion"`
	Blocks          []BlockInfo `json:"blocks"`
}

file formatting info inside every blockly json file

func (*TopBlocks) FindFirst

func (tb *TopBlocks) FindFirst(typeName string) (ret *BlockInfo, okay bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL