View Issue Details

IDProjectCategoryView StatusLast Update
0006103The Dark ModGUIpublic21.09.2022 17:43
ReporterGeep Assigned To 
Status newResolutionopen 
Product VersionTDM 2.10 
Summary0006103: WindowDef debug property "showcoords" half-broken
DescriptionIn a .gui file, there are 2 boolean properties you can add to a windowDef (or other guiDef) for debugging: showcoords and showtime. These paint white text onto the HUD near the upper left of the screen.

Showcoords SHOULD show the guiDef's rect relative-origin values and current mouse cursor coordinates, e.g.:

x: 35 y: 35 cursorx: 622 cursory: 388

Instead, the text appears truncated, such as:

x: 35 y: 35 cursorx

This is because it is clipped to a DrawText field of width 100, presumably to allow both showcoords and showtime to be displayed side by side, which is desirable.

A suggested fix is to retain the width 100 but make showcoords multiline, e.g.:

x: 35 y: 35
cursorx: 622
cursory: 388

This could be done with 3 separate DrawText fields, or perhaps with the existing field make 3x taller and either wordwrap or forced newlines added.
Steps To Reproduce- Use any test FM with a Desktop-style .gui you can alter
- Within that, choose any windowDef/guiDef that can be easily made active, and add showcoords (and optionally showtime), e.g.:

windowDef SomeChildRect
     visible 1
     rect 35, 35, 50, 50
     // Not shown: various other properties here, like "background"
     //showtime 1
     showcoords 1

- Exercise FM to make that guiDef active.
Additional InformationRelevant cpp code is in Windows.cpp

    if ( flags & WIN_SHOWTIME ) {
        dc->DrawText(va(" %0.1f seconds\n%s", (float)(time - timeLine) / 1000, gui->State().GetString("name")), 0.35f, 0, dc->colorWhite, idRectangle(100, 0, 80, 80), false);

    if ( flags & WIN_SHOWCOORDS ) {
        sprintf(str, "x: %i y: %i cursorx: %i cursory: %i", (int)rect.x(), (int)rect.y(), (int)gui->CursorX(), (int)gui->CursorY());
        dc->DrawText(str, 0.25f, 0, dc->colorWhite, idRectangle(0, 0, 100, 20), false);

These debug properties are mentioned in my wiki articles "GUI Scripting: Properties in Common" and (in more detail and to be posted soon) "GUI Scripting: Debugging". The latter has this draft description:

The outputs of showtime and showcoords are displayed when their guiDef is active. They can be used simultaneously, with showtime info to the right. In an HUD context, the text will be placed near the upper left screen corner. Showtime’s format is, for instance, “0.4 seconds” (usually changing rapidly). Showcoords displays the guiDef’s “rect” first 2 coordinates (upper-left corner origin x & y). Recall these values are relative to a parent guiDef’s origin, NOT the absolute screen location. [Also, an attempt to include mouse cursor position fails due to clipping; bug report filed.]
TagsNo tags attached.


There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
21.09.2022 17:43 Geep New Issue