Skip to content

Commit

Permalink
Cleanup for public release
Browse files Browse the repository at this point in the history
  • Loading branch information
meisZWFLZ committed Mar 23, 2023
1 parent dec4eb5 commit a5a7de1
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 44 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules
/out
exampleFiles/SPINUPfield.pawdraw
*.vsix
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Andrew Curtis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
83 changes: 58 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,58 @@
# Cat Customs - Custom Editor API Samples

![Paw draw editor ](documentation/example.png)

Demonstrates VS Code's [custom editor API](https://code.visualstudio.com/api/extension-guides/custom-editors) using two custom editors:

- Cat Scratch — Uses the finalized custom text editor api to provide a custom editor for `.cscratch` files (which are just json files)
- Paw Draw - Uses the binary custom editor api to provide a custom editor for `.pawdraw` files (which are just png files with a different file extension).

## VS Code API

### `vscode` module

- [`window.registerCustomEditorProvider`](https://code.visualstudio.com/api/references/vscode-api#window.registerCustomEditorProvider)
- [`CustomTextEditor`](https://code.visualstudio.com/api/references/vscode-api#CustomTextEditor)
- [`CustomEditor`](https://code.visualstudio.com/api/references/vscode-api#CustomEditor)

## Running the example

- Open this example in VS Code 1.46+
- `npm install`
- `npm run watch` or `npm run compile`
- `F5` to start debugging

Open the example files from the `exampleFiles` directory.
# Auton Builder for Vex Robotics Competition
A graphical editor for vrc autons.
![Auton Editor Example](documentation/example.png)
## What it does
This extension allows programmers to easily create and modify autons in the form of a .vauton (json) file. This file can then be downloaded onto an Micro SD card and interpreted by the program on the robot.

> _**Note:**_ This extension does not handle how the auton will be performed, it only provides the information that comprises the auton.
## Use
- Interface
- Robot - Represents state of the robot at the current auton node
- Margin of error (red circle) - indicates the range robot will try to get to before moving onto the next node
- Field - VRC Spin Up Field
- Action Bar - Represents actions that robot will perform at the current auton node
- Intake
- Shoot
- Piston Shoot
- Roller
- Expand
- Node Index - shows index of current node (top right)
- Controls
- Movement
- Left Click & Drag - Move the robot around
- Arrow Keys / WASD - Move the robot around
- Left Click + Alt - Rotate robot towards mouse pointer
- R - Rotate robot 90 degrees (can be modified with shift)
- C - Rotate robot to a heading of 0
- Margin Of Error
- Left Click & Drag - Modify margin of error
- Node Management
- J - Go to previous node
- L - Go to next node
- N - Create new node after this node
- Delete - remove current note
> _**Note:**_ Keybindings cannot be modified
## Installation
1. Go To the desired release ([0.0.2-pre-alpha](https://github.com/meisZWFLZ/AutonGUI/releases/tag/v0.0.2-pre-alpha)) and download the .vsix file
2. Install using any of the below methods
- Open the folder containing the .vsix file in VS Code. Then right click on the .vsix and select `Install Extension VSIX`.
- In VS Code run the `Extensions: Install from VSIX...` command.
- In a terminal, run the following command
`code --install-extension /path/to/file/vrc-auton-0.0.1.vsix`
## Auton Data Structure
The .vauton file that this extension creates is just a .json file. This json is an array of auton nodes each containing an position value and an array of actions
- Auton Node
- `"position": Position & HasMarginOfError` - Represents the position the robot will go to.
- `"x": number` - x coordinate in inches, 0 to 144. 0 being closest to the blue driver station and 144 being closest to the red driver station.
- `"y": number` - y coordinate in inches, 0 to 144. 0 being closest to the audience and 144 being closest to the referees.
- `"heading": number` - heading in degrees, 0 to 360. 0 being facing towards the audience and 90 facing the red driver station
- `"marginOfError": number` - margin of error in inches, positive float. Acceptable distance from target point for robot to go onto the next node.
- `"actions": ACTION[]` - unique array of enumerators representing the actions to be performed when the robot reaches `position`.
- `ACTION.SHOOT = 0`
- `ACTION.PISTON_SHOOT = 1`
- `ACTION.INTAKE = 2`
- `ACTION.ROLLER = 3`
- `ACTION.EXPAND = 4`
## Known Bugs
- Creating an empty .vauton file doesn't work
- Fix: copy an existing, working .vauton file and rename it
Binary file modified documentation/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions exampleFiles/AWP.vauto
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"position":{"x":49,"y":101,"heading":53,"marginOfError":4.349546658950447},"actions":[0]},{"position":{"x":72,"y":72,"heading":0,"marginOfError":6}},{"position":{"x":83,"y":101,"heading":0,"marginOfError":20.256234283143364}},{"position":{"x":134,"y":58,"heading":97,"marginOfError":9.326487700546172},"actions":[0]}]
1 change: 0 additions & 1 deletion exampleFiles/SPINUPfield.vauto

This file was deleted.

8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"name": "cat-customs",
"displayName": "Cat Customs",
"description": "Custom Editor API Samples",
"version": "0.0.1",
"publisher": "vscode-samples",
"private": true,
"license": "MIT",
"name": "vrc-auton",
"displayName": "VRC Auton Builder",
"description": "Autonomous builder for the Vex Robotics Competition",
"version": "0.0.2",
"publisher": "AndrewCurtis",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/vscode-extension-samples"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/common/message.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ListAction } from "../webview/eventList.js";
import { ListAction } from "./eventList.js";
import { Node } from "./node.js";

export enum MSG_TARGET {
Expand Down
6 changes: 3 additions & 3 deletions src/server/pawDrawEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as vscode from "vscode";
import { Disposable, disposeAll } from "./dispose";
import { getNonce } from "./util";
import Message from "../common/message";
import { ListAction } from "../webview/eventList";
import { ListAction } from "../common/eventList";
import { Node } from "../common/node";

/**
Expand Down Expand Up @@ -222,7 +222,7 @@ export class PawDrawEditorProvider
private static newPawDrawFileId = 1;

public static register(context: vscode.ExtensionContext): vscode.Disposable {
vscode.commands.registerCommand("catCustoms.pawDraw.new", () => {
vscode.commands.registerCommand("vrc-auton.builder.new", () => {
const workspaceFolders = vscode.workspace.workspaceFolders;
if (!workspaceFolders) {
vscode.window.showErrorMessage(
Expand Down Expand Up @@ -258,7 +258,7 @@ export class PawDrawEditorProvider
);
}

private static readonly viewType = "catCustoms.pawDraw";
private static readonly viewType = "vrc-auton.builder";

/**
* Tracks all known webviews
Expand Down
2 changes: 1 addition & 1 deletion src/webview/listManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { ACTION, Node } from "../common/node.js";
import ActionsManager from "./actionsManager.js";
import ErrorManager from "./errorManager.js";
import { ListAction } from "./eventList.js";
import { ListAction } from "../common/eventList.js";
import NodeList from "./nodeList.js";
import { Robot } from "./robot.js";

Expand Down
2 changes: 1 addition & 1 deletion src/webview/nodeList.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import EventList, { ListAction } from "./eventList.js";
import EventList, { ListAction } from "../common/eventList.js";
// import Message from "../common/message.js";
import { Node as MyNode } from "../common/node.js";
import { HasMarginOfError, Position } from "../common/coordinates";
Expand Down
2 changes: 1 addition & 1 deletion src/webview/pawDraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Message from "../common/message.js";
import NodeList from "./nodeList.js";
import type { ACTION, Node as MyNode } from "../common/node.js";
import ListManager from "./listManager.js";
import { ListAction, LIST_ACTION_TYPE } from "./eventList.js";
import { ListAction, LIST_ACTION_TYPE } from "../common/eventList.js";

// @ts-ignore
const vscode = acquireVsCodeApi();
Expand Down

0 comments on commit a5a7de1

Please sign in to comment.