diff --git a/src/backend/document/document.go b/src/backend/document/document.go index c541147..790162e 100644 --- a/src/backend/document/document.go +++ b/src/backend/document/document.go @@ -72,6 +72,14 @@ func (d *documentElement) ClientHeight() js.Value { return js.Global().Get("document").Get("documentElement").Get("clientHeight") } +func (d *documentElement) ClientIntWidth() int { + return js.Global().Get("document").Get("documentElement").Get("clientWidth").Int() +} + +func (d *documentElement) ClientIntHeight() int { + return js.Global().Get("document").Get("documentElement").Get("clientHeight").Int() +} + func (d *styleDocument) Set(key string, value interface{}) { js.Global().Get("document").Get("documentElement").Get("style").Set(key, value) } diff --git a/src/webzen/init.go b/src/webzen/init.go index 1333463..f187bc7 100644 --- a/src/webzen/init.go +++ b/src/webzen/init.go @@ -47,7 +47,32 @@ func Init() { keys.SetupEventListeners() } +func CustomInit(width, height int) { + canvas := document.GetElementById("webzen") + if canvas.IsNull() { + canvas = document.CreateCanvasElement() + canvas.Set("id", "canvas") + document.Body.AppendCanvasChild(canvas) + } + + canvas.Set("width", width) + canvas.Set("height", height) + + document.DocumentElement.Style.Set("overflow", "hidden") + document.Body.Style.Set("overflow", "hidden") + + keys.SetupEventListeners() +} + func Update() { time.Sleep(time.Millisecond * 16) clearCanvas() } + +func GetWidth() int { + return document.DocumentElement.ClientIntWidth() +} + +func GetHeight() int { + return document.DocumentElement.ClientIntHeight() +}