From 497c474fee214b902256e9d6caabb144edb01c88 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 5 Oct 2020 00:03:00 +0200 Subject: [PATCH] - transform mouse coordinates for menu with fullscreen scale --- wadsrc/static/zscript/ui/menu/listmenu.zs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/wadsrc/static/zscript/ui/menu/listmenu.zs b/wadsrc/static/zscript/ui/menu/listmenu.zs index 76b384ba6..f17a66274 100644 --- a/wadsrc/static/zscript/ui/menu/listmenu.zs +++ b/wadsrc/static/zscript/ui/menu/listmenu.zs @@ -191,9 +191,25 @@ class ListMenu : Menu { int sel = -1; - // convert x/y from screen to virtual coordinates, according to CleanX/Yfac use in DrawTexture - x = ((x - (screen.GetWidth() / 2)) / CleanXfac) + 160; - y = ((y - (screen.GetHeight() / 2)) / CleanYfac) + 100; + int w = desc.DisplayWidth(); + double sx, sy; + if (w == ListMenuDescriptor.CleanScale) + { + // convert x/y from screen to virtual coordinates, according to CleanX/Yfac use in DrawTexture + x = ((x - (screen.GetWidth() / 2)) / CleanXfac) + 160; + y = ((y - (screen.GetHeight() / 2)) / CleanYfac) + 100; + } + else + { + // for fullscreen scale, transform coordinates so that for the given rect the coordinates are within (0, 0, w, h) + int h = desc.DisplayHeight(); + double fx, fy, fw, fh; + [fx, fy, fw, fh] = Screen.GetFullscreenRect(w, h, FSMode_ScaleToFit43); + + x = int((x - fx) * w / fw); + y = int((y - fy) * h / fh); + } + if (mFocusControl != NULL) {