-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Patcher] Support onLoad, and eventually onUnload
- Loading branch information
Showing
8 changed files
with
205 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
export default { | ||
patches: [ | ||
{ | ||
find: /Windows 96 main<br>/, | ||
replace: (match) => `${match}ropeswing ${ROPESWING_COMMIT}<br>`, | ||
}, | ||
{ | ||
find: /Other trademarks and logos are property of their respective owners\./, | ||
replace: (match) => `${match}\n\nropeswing ${ROPESWING_COMMIT}, an <a href="https://github.com/uwu/ropeswing">uwunet project</a>.`, | ||
executable: "C:/system/local/bin/about-ui", | ||
} | ||
], | ||
onLoad() { | ||
if (localStorage["ropeswing-welcome"] !== "true") { | ||
localStorage["ropeswing-welcome"] = "true"; | ||
w96.WApplication.execAsync(this.dialog(w96.WApplication), []); | ||
} | ||
}, | ||
manifest: { | ||
name: "housekeeper", | ||
description: "basic ropeswing info, e.g. welcome dialog, version listing", | ||
authors: ["redstonekasi", "Beef"], | ||
}, | ||
core: true, | ||
dialog: (WApplication: typeof w96.WApplication) => new (class WelcomeDialog extends WApplication { | ||
async main(argv: string[]) { | ||
super.main(argv); | ||
// @ts-expect-error | ||
const popup = this.createWindow({ | ||
title: "ropeswing", | ||
initialHeight: 120, | ||
initialWidth: 260, | ||
resizable: false, | ||
bodyClass: "dlg-run-box", | ||
controlBoxStyle: "WS_CBX_CLOSE", | ||
}); | ||
const body = popup.getBodyContainer(); | ||
body.innerHTML = `<div class="text exp">ropeswing has been installed!<br>Check your system settings in order to configure it.</div><button class="w96-button">OK</button>`; | ||
body.querySelector("button")?.addEventListener("click", () => popup.close(false)); | ||
|
||
popup.setPosition(window.innerWidth / 2 - 130, window.innerHeight / 2 - 60); | ||
popup.show(); | ||
} | ||
})(), | ||
} as Extension; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,135 @@ | ||
// adapted from https://git.sys36.net/windows-96/utilities/api-typings/-/blob/master/win96.d.ts | ||
|
||
interface EmitterEvent { | ||
name: string; | ||
callback: Function; | ||
type: "recurring" | "single"; | ||
} | ||
|
||
interface EventEmitter { | ||
eventQueue: EmitterEvent[]; | ||
on(evtName: string, callback: Function): void; | ||
once(evtName: string, callback: Function): void; | ||
emit(evtName: string, ...args: any): void; | ||
} | ||
|
||
interface WindowParams { | ||
initialX?: number; | ||
initialY?: number; | ||
minHeight?: number; | ||
minWidth?: number; | ||
initialHeight?: number; | ||
initialWidth?: number; | ||
title?: string; | ||
resizable?: boolean; | ||
draggable?: boolean; | ||
taskbar?: boolean; | ||
icon?: string; | ||
center?: boolean; | ||
body?: string; | ||
bodyClass?: string; | ||
windowClass?: string; | ||
controlBoxStyle?: "WS_CBX_MINMAXCLOSE" | "WS_CBX_CLOSE" | "WS_CBX_MINCLOSE" | "WS_CBX_NONE"; | ||
mobResize?: boolean; | ||
iframeFix?: boolean; | ||
animations?: { | ||
windowOpen: string; | ||
windowClose: string; | ||
}; | ||
wndContainer?: HTMLDivElement; | ||
} | ||
|
||
declare class StandardWindow { | ||
readonly id: string; | ||
readonly useIcon: boolean; | ||
readonly wndObject: HTMLDivElement; | ||
readonly animations: {}; | ||
readonly params: WindowParams; | ||
readonly isRegistered: boolean; | ||
readonly appbarRegistered: boolean; | ||
readonly shown: boolean; | ||
readonly _wmStylingAllowed: boolean; | ||
readonly maximized: boolean; | ||
readonly minimized: boolean; | ||
readonly uiUpdating: boolean; | ||
readonly windowIcon: string; | ||
readonly title: string; | ||
readonly maximizeInfo: { | ||
x: string; | ||
y: string; | ||
h: string; | ||
w: string; | ||
}; | ||
|
||
onclose: (e: { canceled: boolean }) => void; | ||
onload: () => void; | ||
ondarkenelements: () => void; | ||
onlightenelements: () => void; | ||
_ext: { | ||
windowSnap: { | ||
snapped: boolean; | ||
originalSize: null; | ||
}; | ||
}; | ||
showTitlebarMenu(e: MouseEvent): void; | ||
registerWindow(): void; | ||
registerAppBar(): void; | ||
setTitle(text: string): void; | ||
setHtml(text: string): void; | ||
randomizePosition(): void; | ||
show(): void; | ||
center(current: boolean): void; | ||
activate(): void; | ||
toggleMinimize(): void; | ||
toggleMaximize(): void; | ||
close(ignoreEvents: boolean): void; | ||
darkenElements(): void; | ||
lightenElements(): void; | ||
setWindowIcon(icon_url: string): HTMLDivElement; | ||
setControlBoxStyle(cbstyle: "WS_CBX_CLOSE" | "WS_CBX_MINCLOSE" | "WS_CBX_MINMAXCLOSE" | "WS_CBX_NONE"): void; | ||
setSize(w: number, h: number, ignoreThemeOffsets?: boolean): void; | ||
setPosition(x: number, y: number): void; | ||
getBounds(): { | ||
x: number; | ||
y: number; | ||
height: number; | ||
width: number; | ||
}; | ||
getComputedBounds(): DOMRect; | ||
getBodyContainer(): HTMLDivElement; | ||
constructor(params: WindowParams); | ||
} | ||
|
||
declare class WApplication { | ||
readonly appId: number; | ||
readonly appWindow: StandardWindow; | ||
readonly windows: StandardWindow[]; | ||
onterminated: (result: any) => void; | ||
_running: boolean; | ||
_terminating: boolean; | ||
_appResult: any; | ||
setAppResult(v: any): void; | ||
terminate(): void; | ||
createWindow(params: WindowParams, isAppWindow: boolean): StandardWindow; | ||
main(argv: string[]): Promise<any>; | ||
ontermination(): void; | ||
} | ||
|
||
interface W96API { | ||
FS: { | ||
readstr(path: string): Promise<string>; | ||
}; | ||
evt: { | ||
fs: EventEmitter; | ||
sys: EventEmitter; | ||
wm: EventEmitter; | ||
ui: EventEmitter; | ||
}; | ||
WApplication: { | ||
new(): WApplication; | ||
prototype: WApplication; | ||
|
||
kill(app_id: number, force: boolean): void; | ||
execAsync(instance: WApplication, args: string[]): Promise<any>; | ||
}; | ||
} |