Skip to content

Commit

Permalink
Updated to spright 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
houmain committed May 7, 2023
1 parent 243ed6b commit cc51e8b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
{
"viewType": "spright.editor",
"displayName": "Spright Editor",
"priority": "option",
"priority": "default",
"selector": [
{
"filenamePattern": "*.conf"
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SprightEditorProvider } from "./sprightEditorProvider";
import { SprightDocumentSymbolProvider } from "./sprightDocumentSymbolProvider";
import { SprightCompletionItemProvider } from "./sprightCompletionItemProvider";

const sprightVersion = "2.3.1";
const sprightVersion = "3.0.0";

export function activate(context: vscode.ExtensionContext) {
const sprightEditor = new SprightEditorProvider(context, sprightVersion);
Expand Down
10 changes: 8 additions & 2 deletions src/web/Description.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@

export type InputSource = {
index: number;
spriteIndices: number[];
};

export type Input = {
filename: string;
sourceIndices: number[];
sources: InputSource[];
};

export type Source = {
Expand All @@ -9,7 +15,6 @@ export type Source = {
path: string;
width: number;
height: number;
spriteIndices: number[];
uri: string;
};

Expand All @@ -28,6 +33,7 @@ export type Rect = {
export type Sprite = {
index: number;
id: string;
inputIndex: number;
inputSpriteIndex: number;
sourceIndex: number;
sourceRect: Rect;
Expand Down
6 changes: 3 additions & 3 deletions src/web/sprightEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ export class SprightEditor {

let spriteIndex = 0;
const sourcesDiv = appendElement(inputDiv, "div", "sources");
for (const index of input.sourceIndices) {
const source = this.description.sources[index];
for (const inputSource of input.sources) {
const source = this.description.sources[inputSource.index];
const sourceDiv = appendElement(sourcesDiv, "div", "source");

if (source.filename !== input.filename) {
Expand All @@ -161,7 +161,7 @@ export class SprightEditor {
spritesDiv.style.setProperty("--width", source.width + "px");
spritesDiv.style.setProperty("--height", source.height + "px");

for (const index of source.spriteIndices) {
for (const index of inputSource.spriteIndices) {
const sprite = this.description.sprites[index];
const configSprite = configInput?.sprites[spriteIndex++];
const spriteDiv = appendElement(spritesDiv, "div", "sprite");
Expand Down

0 comments on commit cc51e8b

Please sign in to comment.