Skip to content

Commit

Permalink
fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ramseyball authored Oct 10, 2023
1 parent 924a291 commit 16ef711
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 36 deletions.
6 changes: 1 addition & 5 deletions button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace microcode {
return borderTop(style) + borderBottom(style)
}

export class Button extends Component implements ISizable, IPlaceable {
export class Button implements IComponent, ISizable, IPlaceable {
private xfrm_: Affine
private icon: Sprite
//private text: TextSprite;
Expand Down Expand Up @@ -132,7 +132,6 @@ namespace microcode {
y: number
onClick?: (button: Button) => void
}) {
super("button")
this.xfrm_ = new Affine()
this.xfrm.parent = opts.parent && opts.parent.xfrm
this.style = opts.style || ButtonStyles.Transparent
Expand All @@ -148,10 +147,7 @@ namespace microcode {
if (this.icon) {
this.icon.destroy()
}
//if (this.text) { this.text.destroy(); }
this.icon = undefined
//this.text = undefined;
super.destroy()
}

public getIcon() {
Expand Down
14 changes: 5 additions & 9 deletions component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
namespace microcode {
export interface IKindable {
kind: string
}

export abstract class Component implements IKindable {
/* abstract */ destroy() { }
/* abstract */ update() {}
/* abstract */ draw() {}
export interface IComponent {
destroy: () => void
update: () => void
draw: () => void
}

export interface IPlaceable {
Expand All @@ -18,14 +15,13 @@ namespace microcode {
height: number
}

export class Placeable extends Component implements IPlaceable {
export class Placeable implements IComponent, IPlaceable {
private xfrm_: Affine
//% blockCombine block="xfrm" callInDebugger
public get xfrm() {
return this.xfrm_
}
constructor(parent?: IPlaceable) {
super("placeable")
this.xfrm_ = new Affine()
this.xfrm_.parent = parent && parent.xfrm
}
Expand Down
3 changes: 1 addition & 2 deletions cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace microcode {
size: Bounds
}

export class Cursor extends Component implements IPlaceable {
export class Cursor implements IComponent, IPlaceable {
xfrm: Affine
navigator: INavigator
cancelHandlerStack: CursorCancelHandler[]
Expand All @@ -29,7 +29,6 @@ namespace microcode {
visible = true

constructor() {
super("cursor")
this.xfrm = new Affine()
this.cancelHandlerStack = []
this.moveDest = new Vec2()
Expand Down
16 changes: 3 additions & 13 deletions editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,6 @@ namespace microcode {
return
}

if (target.destroyed) {
console.warn(
`scroll/move destroyed sprite '${target.id} ${target.ariaId}'`
)
return
}

if (target.rootXfrm.tag === "hud") {
this.moveTo(target)
return
Expand Down Expand Up @@ -461,8 +454,7 @@ namespace microcode {
this.cursor.navigator = this.navigator
}

/* override */ update() {
super.update()
update() {

if (this.pageEditor) {
this.pageEditor.update()
Expand Down Expand Up @@ -534,7 +526,7 @@ namespace microcode {
}
}

export class PageEditor extends Component implements IPlaceable {
export class PageEditor implements IComponent, IPlaceable {
private xfrm_: Affine
public ruleEditors: RuleEditor[]

Expand All @@ -548,7 +540,6 @@ namespace microcode {
parent: IPlaceable,
private pagedef: PageDefn
) {
super("page_editor")
this.xfrm_ = new Affine()
this.xfrm_.parent = parent.xfrm
this.ruleEditors = pagedef.rules.map(
Expand All @@ -558,10 +549,9 @@ namespace microcode {
this.layout()
}

/* override */ destroy() {
destroy() {
this.ruleEditors.forEach(rule => rule.destroy())
this.ruleEditors = undefined
super.destroy()
}

private ensureFinalEmptyRule() {
Expand Down
3 changes: 1 addition & 2 deletions picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace microcode {
}
}

export class Picker extends Component implements IPlaceable {
export class Picker implements IComponent, IPlaceable {
public groups: PickerGroup[]
public navigator: INavigator
public visible: boolean
Expand All @@ -90,7 +90,6 @@ namespace microcode {
}

constructor(private cursor: Cursor) {
super("picker")
this.xfrm_ = new Affine()
this.groups = []
this.navigator = new RowNavigator()
Expand Down
4 changes: 1 addition & 3 deletions ruleeditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace microcode {

const repNames = ["sensors", "filters", "actuators", "modifiers"]

export class RuleEditor extends Component implements IPlaceable {
export class RuleEditor implements IComponent, IPlaceable {
private xfrm_: Affine
innerWidth: number
handleBtn: Button
Expand All @@ -26,7 +26,6 @@ namespace microcode {
public ruledef: RuleDefn,
public index: number
) {
super("rule_editor")
this.xfrm_ = new Affine()
this.xfrm_.parent = page.xfrm
this.handleBtn = new EditorButton(editor, {
Expand Down Expand Up @@ -117,7 +116,6 @@ namespace microcode {
this.handleBtn = undefined
this.whenInsertBtn = undefined
this.doInsertBtn = undefined
super.destroy()
}

private destroyProgramTiles() {
Expand Down
3 changes: 1 addition & 2 deletions sprite.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace microcode {
export class Sprite extends Component implements IPlaceable, ISizable {
export class Sprite implements IComponent, IPlaceable, ISizable {
private xfrm_: Affine
image: Image
invisible: boolean
Expand Down Expand Up @@ -30,7 +30,6 @@ namespace microcode {
}

constructor(opts: { parent?: IPlaceable; img: Image }) {
super("sprite")
this.xfrm_ = new Affine()
this.xfrm_.parent = opts.parent && opts.parent.xfrm
this.image = opts.img
Expand Down

0 comments on commit 16ef711

Please sign in to comment.