Giter Site home page Giter Site logo

bastianblokland / typedtree-editor Goto Github PK

View Code? Open in Web Editor NEW
23.0 2.0 5.0 1.15 MB

Web editor for typed tree structures. (like decision / behaviour trees)

Home Page: https://www.bastian.tech/tree

License: MIT License

Makefile 0.20% HTML 1.55% CSS 2.75% Shell 3.84% JavaScript 1.31% TypeScript 90.35%
tree-editor behaviour-tree descision-tree json-tree webapp

typedtree-editor's Introduction

TypedTree-Editor

Website Build Tests CodeCov License: MIT

Web editor for typed tree structures


Preview image


Generators

To avoid having to hand write the scheme you can use one of the following generators:

Environment Generator
dotnet typedtree-generator-dotnet
unity typedtree-generator-unity

Description

This editor is designed to be able to build tree structures according to a scheme and then output it to json. You create a simple scheme file describing the possible node types, load it up in the editor and then create tree's in a visual (and type safe) way.

Both the scheme and the tree formats are designed to be both hand-editable and easy to generate / parse. You could for example generate a scheme based on a class structure from the language you wish to load tree into.

This editor runs purely client-side and any content you load into it stays purely on your machine.

Tiny electron wrapper to ease in saving until native-file-system has become mainstream: electron-wrapper.

Example of the scheme format

{
  "rootAlias": "AI.Item",
  "aliases": [
    {
      "identifier": "AI.Item",
      "values": [
        "AI.Items.Selector",
        "AI.Conditions.OutOfHealth"
      ]
    }
  ],
  "enums": [
    {
      "identifier": "AI.Target",
      "values": [
        { "value": 1, "name": "Ground" }
        { "value": 2, "name": "Air" }
      ]
    }
  ],
  "nodes": [
    {
      "nodeType": "AI.Items.Selector",
      "fields": [
        {
          "name": "children",
          "valueType": "AI.Item",
          "isArray": true
        }
      ]
    },
    {
      "nodeType": "AI.Conditions.OutOfHealth",
      "fields": [
        {
          "name": "minHealth",
          "valueType": "number"
        }
      ]
    }
  ],
  "featureNodeNames": true
}

Elements in the scheme:

  • rootAlias: Alias that the root-node has to be part of.
  • aliases: Definition of all the aliases in the scheme. An alias is a named group of node types.
  • enums: Definition of all the enums in the scheme. An enum is a named set of numbers.
  • nodes: Definition of all the node-types in the scheme. Each node defines a type-name and a set of fields that this node can have.

Possible field value types are:

  • boolean
  • number
  • string
  • Alias (Alias has to be defined in the aliases section of the scheme)
  • Enum (Enum has to be defined in the enums section of the scheme)

Enums are a special type as they only live in the scheme, in the actual tree data they are represented by numbers. The fact that the field is an enum in the scheme will make the editor validate the number and show it as a dropdown in the ui.

Example of the tree output format

{
  "$type": "AI.Items.Selector",
  "$name": "My selector",
  "children": [
    {
      "$type": "AI.Conditions.OutOfHealth",
      "minHealth": 10
    }
  ]
}

Format is plain json with some well-known fields:

  • $type: Indicates the node-type in the scheme this node was created from.
  • $name: Optional name for the node.

Example of the tree-pack format

{
  "scheme": ...,
  "tree": ...
}

TreePack is a single file containing both a scheme and a tree, can be useful for sharing purposes.

Project setup

This project is written in TypeScript and is transpiled into es6 JavaScript. Tree is rendered with a combination of plain html and svg.

For dependency management Npm is used. Rollup is used for creating the output bundle, and deployments are minified using uglify-js and css-combine.

Any ide can be used of course but configuration files for vscode are included. Ci scripts are written in bash so windows users should use the wsl for running them.

Building

Installing node (at least version 10 of node required) and executing: make should be enough, build-output can be found in the ./build directory.

Development

For local development execute: make watch which will start a local server with hot-reloading.

Run linter

For running the tslint linter you can execute: make lint but when using vscode the tslint plugin should provide warnings for non-compliant code already.

Unit tests

Unit tests can be found in ./tests/unit and are using the Jest framework. Run unit-tests by executing: make test.unit.

Code coverage for unit-tests is tracked with codecov.io.

Integration tests

Integration tests can be found in ./tests/integration. Integration test are also written with Jest and are run in the puppeteer environment (which is a headless chromium api) using jest-puppeteer. Run integration-tests by executing: make test.integration.

To make debugging easier screenshots are exported during integration test execution, they can be found in the ./screenshots directory. Actually the image in this readme also comes from there.

Continuous integration

Builds are run in azure-devops and output is deployed to a azure blob-storage bucket. Output can be found here: https://www.bastian.tech/typedtree-editor/refs/pull/[PULL_REQUEST_NUMBER]/merge/ or www.bastian.tech/typedtree-editor/refs/heads/[BRANCH_NAME]/

www.bastian.tech/tree is a alias to www.bastian.tech/typedtree-editor/refs/heads/master/

Dependencies

  • NodeJs: At least version 10 is required.
  • FileSaver: Library for saving files that works consistently in almost all browsers.
  • lz-string: Library for compressing text.

Troubleshooting

  • If verify-tooling.sh fails try removing the ./node_modules directory.

Known issues

  • Running the integration tests in the windows linux subsystem fails with Error: Failed to launch chrome! This is a known puppeteer issue

typedtree-editor's People

Contributors

bastianblokland avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.