This commit is contained in:
Gvidas Juknevičius 2024-08-23 03:00:21 +03:00
parent 652e0d27a0
commit 9ef462c104
Signed by: MCorange
GPG Key ID: 12B1346D720B7FBB
6 changed files with 3249 additions and 233 deletions

View File

@ -1,229 +0,0 @@
declare module basalt {
interface Theme {
BaseFrameBG: number,
BaseFrameText: number,
FrameBG: number,
FrameText: number,
ButtonBG: number,
ButtonText: number,
CheckboxBG: number,
CheckboxText: number,
InputBG: number,
InputText: number,
TextfieldBG: number,
TextfieldText: number,
ListBG: number,
ListText: number,
MenubarBG: number,
MenubarText: number,
DropdownBG: number,
DropdownText: number,
RadioBG: number,
RadioText: number,
SelectionBG: number,
SelectionText: number,
GraphicBG: number,
ImageBG: number,
PaneBG: number,
ProgramBG: number,
ProgressbarBG: number,
ProgressbarText: number,
ProgressbarActiveBG: number,
ScrollbarBG: number,
ScrollbarText: number,
ScrollbarSymbolColor: number,
SliderBG: boolean,
SliderText: number,
SliderSymbolColor: number,
SwitchBG: number,
SwitchText: number,
LabelBG: boolean,
LabelText: number,
GraphBG: number,
GraphText: number,
}
function debug(...txt: string[]): void;
function autoUpdate(enabled: boolean): void;
function stop(): void;
function stopUpdate(): void;
function createFrame<T extends BaseFrame>(id?: string): T;
function setActiveFrame<T extends BaseFrame>(f: T): void;
function getFrame<T extends BaseFrame>(id: string): T;
function getActiveFrame<T extends BaseFrame>(): T;
function removeFrame(id: string): void;
function setTheme(theme: Theme): void;
function getTheme(s: string): number;
function setVariable<T>(k: string, v: T): void;
function getVariable<T>(k: string): T;
function getVersion(): string;
function isKeyDown(key: number): boolean;
function log(msg: string, prefix: "ERROR" | "WARN" | "INFO" | "DEBUG" | string): void;
function memory(): number;
function onEvent(fn: (event: string) => boolean): void;
function schedule(fn: <T>(v: T) => void): void;
function setMouseDragThrottle(throttle: number): void;
function setMouseMoveThrottle(throttle: number): void;
function setRenderingThrottle(throttle: number): void;
class Object {
enable(): void;
disable(): void;
getType(): string;
isType(t: string): boolean;
getName(): string;
getParent<T extends Object>(): T | null;
setParent<T extends Object, O extends Object>(p: T): O;
getZIndex(): number;
}
class VisualObject extends Object {
show<T extends VisualObject>(): T;
hide<T extends VisualObject>(): T;
setVisible(vis: boolean): boolean;
isVisible(): boolean;
setPosition<T extends VisualObject>(x: number|string, y: number|string, add?: boolean): T;
getPosition(): [number, number];
getX(): number;
getY(): number;
setSize<T extends VisualObject>(w: number|string, h: number|string): T;
getSize(): [number, number];
getWidth(): number;
getHeight(): number;
setBackground<T extends VisualObject>(color: number|false, symbol?: string, symbol_color?: number): T;
getBackground(): number|false;
setForeground<T extends VisualObject>(color: number|false): T;
getForeground(): number|false;
setTransparency<T extends VisualObject>(v: boolean): T;
setZIndex<T extends VisualObject>(i: number): T;
getAbsolutePosition(x?: number, y?: number): [number, number];
ignoreOffset<T extends VisualObject>(v: boolean): T;
isFocused(): boolean;
setShadow<T extends VisualObject>(v: number): T;
getShadow(): number|false;
setBorder<T extends VisualObject>(c: number, ...sides: string[]): T;
animatePosition<T extends VisualObject>(x: number, y: number, dur: number, offset?: number, mode?: string, fn?: () => void): T;
animateSize<T extends VisualObject>(w: number, h: number, dur: number, offset?: number, mode?: string, fn?: () => void): T;
animateOffset<T extends VisualObject>(x: number, y: number, dur: number, offset?: number, mode?: string, fn?: () => void): T;
addTexture<T extends VisualObject>(path: string, isAnimated: boolean): T;
setTextureMode<T extends VisualObject>(mode: string): T;
setInfiniteMode<T extends VisualObject>(v: boolean): T;
addDraw<T extends VisualObject>(id: string, fn: () => void, pos: number, where: number, imm: boolean): T;
addPreDraw<T extends VisualObject>(id: string, fn: () => void, pos: number, imm: boolean): T;
addPostDraw<T extends VisualObject>(id: string, fn: () => void, pos: number, imm: boolean): T;
setDrawState<T extends VisualObject>(id: string, state: boolean): T;
getDrawId(id: string): number;
addText<T extends VisualObject>(x: number, y: number, s: string): T;
addBg<T extends VisualObject>(x: number, y: number, c: string): T;
addFg<T extends VisualObject>(x: number, y: number, c: string): T;
addBlit<T extends VisualObject>(x: number, y: number, s: string, fg: string, bg: string): T;
addBox<T extends VisualObject>(x: number, y: number, w: number, h: number, s: string): T;
addBackgroundBox<T extends VisualObject>(x: number, y: number, w: number, h: number, c: number): T;
addForegroundBox<T extends VisualObject>(x: number, y: number, w: number, h: number, c: number): T;
}
class ChangeableObject extends VisualObject {
setValue<T extends VisualObject>(v: any): T;
getValue<T>(): T;
}
class Container extends VisualObject {
addChild<T>(c: T): T;
getChild<T extends Container>(id: string): T;
getDeepChild<T extends Container>(id: string): T;
removeChild(id: string): boolean;
removeChildren<T extends Container>(): T;
updateZIndex<T extends Container, O extends Container>(which: O, idx: number): T;
setImportant<T extends Container>(id: string): T;
clearFocusedChild<T extends Container>(): T;
setFocusedObject<T extends Container, O extends Container>(o: O): T;
}
class BaseFrame extends Container {
getOffset(): [number, number];
setOffset<T extends BaseFrame>(x: number, y: number): T;
}
class MonitorFrame extends BaseFrame {
setMonitor<T extends MonitorFrame>(mon: string|Monitor): T;
setMonitorGroup<T extends MonitorFrame>(mon: (string|Monitor)[][]): T;
}
class Frame extends Container {
getOffset(): [number, number];
setOffset<T extends Frame>(x: number, y: number): T;
}
class ScrollableFrame extends Frame {
setDirection<T extends ScrollableFrame>(d: string): T;
}
type Justify = "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly";
type Direction = "row" | "column";
class Flexbox extends ScrollableFrame {
setSpacing<T extends Flexbox>(s?: number): T;
getSpacing(): number;
setDirection<T extends Flexbox | ScrollableFrame>(d: Direction): T;
getDirection(): Direction;
setJustifyContent<T extends Flexbox>(s?: Justify): T;
getJustifyContent(): Justify;
setWrap<T extends Flexbox>(w: "wrap" | "nowrap"): T;
getWrap(): "wrap" | "nowrap";
updateLayout<T extends Flexbox>(): T;
addBreak<T extends Flexbox>(): T;
getFlexGrow(): number;
setFlexGrow<T extends Flexbox>(g: number): T;
getFlexShrink(): number;
setFlexShrink<T extends Flexbox>(g: number): T;
getFlexBasis(): number;
setFlexBasis<T extends Flexbox>(g: number): T;
}
type DraggingMap = [number, number, number, number];
class MovableFrame extends Frame {
setDraggingMap<T extends MovableFrame>(m: DraggingMap): T;
getDraggingMap(): DraggingMap;
}
class Button extends VisualObject {
setText<T extends VisualObject>(t: string): T;
setHorizontalAlign<T extends VisualObject>(a: "left" | "center" | "right"): T;
setVerticalAlign<T extends VisualObject>(a: "top" | "center" | "bottom"): T;
}
class Checkbox extends ChangeableObject {
setSymbol<T extends Checkbox>(s: string): T;
}
class Graph extends ChangeableObject {
setGraphColor<T extends Graph>(c: number): T;
setGraphSymbol<T extends Graph>(s: string): T;
getGraphSymbol(): string;
addDataPoint<T extends Graph>(v: number): T;
setMaxValue<T extends Graph>(v: number): T;
getMaxValue(): number;
setMinValue<T extends Graph>(v: number): T;
getMinValue(): number;
setGraphType<T extends Graph>(t: "scatter" | "line" | "bar"): T;
setMaxEntries<T extends Graph>(v: number): T;
getMaxEntries(): number;
}
class Image extends VisualObject {
loadImage<T extends Image>(p: string): T;
setImage(img: any, fmt: "nfp" | "bimg"): void;
usePalette<T extends Image>(change: boolean): T;
play<T extends Image>(p: boolean): T;
selectFrame<T extends Image>(idx: number): T;
loadImage<T extends Image>(p: string): T;
getMetadata(k: string): unknown;
setImageSize<T extends Image>(w: number, h: number): T;
getImageSize(): [number, number];
}
}

2996
rOSs.lua

File diff suppressed because one or more lines are too long

View File

@ -1,11 +1,16 @@
import * as basalt from "./libs/basalt/basalt";
function main() {
const d: peripheral = peripheral.wrap("disk") as peripheral;
const d: Monitor = peripheral.find("monitor")[0] as Monitor;
const main = basalt.addMonitor();
main.setMonitor(d);
main.addLabel().setText("uwu");
main.addButton().setText("meow");
basalt.autoUpdate();
}
main()

244
src/libs/basalt/basalt.d.ts vendored Normal file
View File

@ -0,0 +1,244 @@
export interface Theme {
BaseFrameBG: number,
BaseFrameText: number,
FrameBG: number,
FrameText: number,
ButtonBG: number,
ButtonText: number,
CheckboxBG: number,
CheckboxText: number,
InputBG: number,
InputText: number,
TextfieldBG: number,
TextfieldText: number,
ListBG: number,
ListText: number,
MenubarBG: number,
MenubarText: number,
DropdownBG: number,
DropdownText: number,
RadioBG: number,
RadioText: number,
SelectionBG: number,
SelectionText: number,
GraphicBG: number,
ImageBG: number,
PaneBG: number,
ProgramBG: number,
ProgressbarBG: number,
ProgressbarText: number,
ProgressbarActiveBG: number,
ScrollbarBG: number,
ScrollbarText: number,
ScrollbarSymbolColor: number,
SliderBG: boolean,
SliderText: number,
SliderSymbolColor: number,
SwitchBG: number,
SwitchText: number,
LabelBG: boolean,
LabelText: number,
GraphBG: number,
GraphText: number,
}
export function debug(...txt: string[]): void;
export function autoUpdate(enabled?: boolean): void;
export function stop(): void;
export function stopUpdate(): void;
export function addMonitor<T extends MonitorFrame>(): T;
export function createFrame<T extends BaseFrame>(id?: string): T;
export function setActiveFrame<T extends BaseFrame>(f: T): void;
export function getFrame<T extends BaseFrame>(id: string): T;
export function getActiveFrame<T extends BaseFrame>(): T;
export function removeFrame(id: string): void;
export function setTheme(theme: Theme): void;
export function getTheme(s: string): number;
export function setVariable<T>(k: string, v: T): void;
export function getVariable<T>(k: string): T;
export function getVersion(): string;
export function isKeyDown(key: number): boolean;
export function log(msg: string, prefix: "ERROR" | "WARN" | "INFO" | "DEBUG" | string): void;
export function memory(): number;
export function onEvent(fn: (event: string) => boolean): void;
export function schedule(fn: <T>(v: T) => void): void;
export function setMouseDragThrottle(throttle: number): void;
export function setMouseMoveThrottle(throttle: number): void;
export function setRenderingThrottle(throttle: number): void;
export class Object {
enable(): void;
disable(): void;
getType(): string;
isType(t: string): boolean;
getName(): string;
getParent<T extends Object>(): T | null;
setParent<T extends Object, O extends Object>(p: T): O;
getZIndex(): number;
}
export class VisualObject extends Object {
show<T extends VisualObject>(): T;
hide<T extends VisualObject>(): T;
setVisible(vis: boolean): boolean;
isVisible(): boolean;
setPosition<T extends VisualObject>(x: number|string, y: number|string, add?: boolean): T;
getPosition(): [number, number];
getX(): number;
getY(): number;
setSize<T extends VisualObject>(w: number|string, h: number|string): T;
getSize(): [number, number];
getWidth(): number;
getHeight(): number;
setBackground<T extends VisualObject>(color: number|false, symbol?: string, symbol_color?: number): T;
getBackground(): number|false;
setForeground<T extends VisualObject>(color: number|false): T;
getForeground(): number|false;
setTransparency<T extends VisualObject>(v: boolean): T;
setZIndex<T extends VisualObject>(i: number): T;
getAbsolutePosition(x?: number, y?: number): [number, number];
ignoreOffset<T extends VisualObject>(v: boolean): T;
isFocused(): boolean;
setShadow<T extends VisualObject>(v: number): T;
getShadow(): number|false;
setBorder<T extends VisualObject>(c: number, ...sides: string[]): T;
animatePosition<T extends VisualObject>(x: number, y: number, dur: number, offset?: number, mode?: string, fn?: () => void): T;
animateSize<T extends VisualObject>(w: number, h: number, dur: number, offset?: number, mode?: string, fn?: () => void): T;
animateOffset<T extends VisualObject>(x: number, y: number, dur: number, offset?: number, mode?: string, fn?: () => void): T;
addTexture<T extends VisualObject>(path: string, isAnimated: boolean): T;
setTextureMode<T extends VisualObject>(mode: string): T;
setInfiniteMode<T extends VisualObject>(v: boolean): T;
addDraw<T extends VisualObject>(id: string, fn: () => void, pos: number, where: number, imm: boolean): T;
addPreDraw<T extends VisualObject>(id: string, fn: () => void, pos: number, imm: boolean): T;
addPostDraw<T extends VisualObject>(id: string, fn: () => void, pos: number, imm: boolean): T;
setDrawState<T extends VisualObject>(id: string, state: boolean): T;
getDrawId(id: string): number;
addText<T extends VisualObject>(x: number, y: number, s: string): T;
addBg<T extends VisualObject>(x: number, y: number, c: string): T;
addFg<T extends VisualObject>(x: number, y: number, c: string): T;
addBlit<T extends VisualObject>(x: number, y: number, s: string, fg: string, bg: string): T;
addBox<T extends VisualObject>(x: number, y: number, w: number, h: number, s: string): T;
addBackgroundBox<T extends VisualObject>(x: number, y: number, w: number, h: number, c: number): T;
addForegroundBox<T extends VisualObject>(x: number, y: number, w: number, h: number, c: number): T;
addLabel<T extends Label>(): T;
addButton<T extends Button>(): T;
addGraph<T extends Graph>(): T;
// addScrollbar<T extends Scrollbar>(): T;
addImage<T extends Image>(): T;
addFrame<T extends Frame>(): T;
// addScrollableFrame<T extends ScrollableFrame>(): T;
// addInput<T extends Input>(): T;
// addDropdown<T extends Dropdown>(): T;
}
export class ChangeableObject extends VisualObject {
setValue<T extends VisualObject>(v: any): T;
getValue<T>(): T;
}
export class Container extends VisualObject {
addChild<T>(c: T): T;
getChild<T extends Container>(id: string): T;
getDeepChild<T extends Container>(id: string): T;
removeChild(id: string): boolean;
removeChildren<T extends Container>(): T;
updateZIndex<T extends Container, O extends Container>(which: O, idx: number): T;
setImportant<T extends Container>(id: string): T;
clearFocusedChild<T extends Container>(): T;
setFocusedObject<T extends Container, O extends Container>(o: O): T;
}
export class BaseFrame extends Container {
getOffset(): [number, number];
setOffset<T extends BaseFrame>(x: number, y: number): T;
}
export class MonitorFrame extends BaseFrame {
setMonitor<T extends MonitorFrame>(mon: string|Monitor): T;
setMonitorGroup<T extends MonitorFrame>(mon: (string|Monitor)[][]): T;
}
export class Frame extends Container {
getOffset(): [number, number];
setOffset<T extends Frame>(x: number, y: number): T;
}
export class ScrollableFrame extends Frame {
setDirection<T extends ScrollableFrame>(d: string): T;
}
export type Justify = "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly";
export type Direction = "row" | "column";
export class Flexbox extends ScrollableFrame {
setSpacing<T extends Flexbox>(s?: number): T;
getSpacing(): number;
setDirection<T extends Flexbox | ScrollableFrame>(d: Direction): T;
getDirection(): Direction;
setJustifyContent<T extends Flexbox>(s?: Justify): T;
getJustifyContent(): Justify;
setWrap<T extends Flexbox>(w: "wrap" | "nowrap"): T;
getWrap(): "wrap" | "nowrap";
updateLayout<T extends Flexbox>(): T;
addBreak<T extends Flexbox>(): T;
getFlexGrow(): number;
setFlexGrow<T extends Flexbox>(g: number): T;
getFlexShrink(): number;
setFlexShrink<T extends Flexbox>(g: number): T;
getFlexBasis(): number;
setFlexBasis<T extends Flexbox>(g: number): T;
}
export type DraggingMap = [number, number, number, number];
export class MovableFrame extends Frame {
setDraggingMap<T extends MovableFrame>(m: DraggingMap): T;
getDraggingMap(): DraggingMap;
}
export class Button extends VisualObject {
setText<T extends VisualObject>(t: string): T;
setHorizontalAlign<T extends VisualObject>(a: "left" | "center" | "right"): T;
setVerticalAlign<T extends VisualObject>(a: "top" | "center" | "bottom"): T;
}
export class Checkbox extends ChangeableObject {
setSymbol<T extends Checkbox>(s: string): T;
}
export class Graph extends ChangeableObject {
setGraphColor<T extends Graph>(c: number): T;
setGraphSymbol<T extends Graph>(s: string): T;
getGraphSymbol(): string;
addDataPoint<T extends Graph>(v: number): T;
setMaxValue<T extends Graph>(v: number): T;
getMaxValue(): number;
setMinValue<T extends Graph>(v: number): T;
getMinValue(): number;
setGraphType<T extends Graph>(t: "scatter" | "line" | "bar"): T;
setMaxEntries<T extends Graph>(v: number): T;
getMaxEntries(): number;
}
export class Image extends VisualObject {
loadImage<T extends Image>(p: string): T;
setImage(img: any, fmt: "nfp" | "bimg"): void;
usePalette<T extends Image>(change: boolean): T;
play<T extends Image>(p: boolean): T;
selectFrame<T extends Image>(idx: number): T;
loadImage<T extends Image>(p: string): T;
getMetadata(k: string): unknown;
setImageSize<T extends Image>(w: number, h: number): T;
getImageSize(): [number, number];
// TODO: finish this
}
export class Label extends VisualObject {
setText<T extends Label>(t: string): T;
setFontSize<T extends Label>(s: number): T;
getFontSize(): number;
setTextAlign<T extends Label>(a: "left" | "center" | "right"): T;
}

2
src/types/cct.d.ts vendored
View File

@ -124,7 +124,7 @@ declare class peripheral {
static wrap(name: string): peripheral| null;
static find(ty: string,
filter: (name: string, wrapped: peripheral) => boolean
filter?: (name: string, wrapped: peripheral) => boolean
): [peripheral, peripheral|null, peripheral|null, peripheral|null];
}