Window Scores Caption Cleanup

Reporter: RobertBColton  |  Status: open  |  Last Modified: July 04, 2020, 10:09:30 AM

This comment in the Win32 window caption has pissed me off ever since I first saw it and every time I look at it because I know it not be true.

I devised another little test to prove it as well. The score caption is shown by default in GM8.1, yes, but it is only appended to the regular room_caption and its logic was clearly never contained in window_set_caption at all.

// caption_score is "Score: " by default
// yes with a space at the end
caption_score = "Score: ";
// show_score is true by default
// but health and lives are NOT!
show_score = true;
score = 5;

// doesn't persist beyond keyboard wait
// and does NOT append score!
window_set_caption("lol");
keyboard_wait();

// persists but will append score, health, & lives
room_caption = "lol";

// persists until you press a key 
// but does NOT append score!
window_set_caption("lol");
keyboard_wait();

Another thing I realized from the step event is that the score is in fact not shown when it's 0, but health and lives are!

if (score != 0) score = 0;
else score = 5;

Finally, the variables appear not to be reflexive with respect to setting the caption. Again, score, lives, & health do not effect window_set_caption at all.

show_score = true; show_lives = true; show_health = true;

// caption persists throughout the loop
// score/health/lives must NOT be reflexive
window_set_caption("lol");
while (true) {
    io_handle();
    if (score != 0) score = 0;
    else score = 5;
    if (health != 0) health = 0;
    else health = 5;
    if (lives != 0) lives = 0;
    else lives = 5;
}

The captions are always in the order room, score, lives, health with spaces between the captions but not between the captions and the values (though the default captions contain spaces for the values as I said above).

show_score = true; show_lives = true; show_health = true;

room_caption = "lol";
score = 5;
health = 10;
lives = 14;

The caption values are all displayed rounded in GM8.1 I saw 6 for all of the below.

show_score = true; show_lives = true; show_health = true;
score = 5.5; lives = 5.5; health = 5.5;
// GM8.1 does NOT cache room caption, even though it may cache window caption!
// this should be the same as what is actually on the damn window
draw_text(0,0,window_get_caption());
RobertBColton  
@time-killer-games you mind giving this a test? I'm not sure if it's behavior you cared about or not.
RobertBColton  

I devised a little test to really throw this thing against the wall to see if it could be bad, and it seems to have no effect on the performance. Even when we randomly change the room caption every single draw event the slow performance of the window caption functions doesn't take more than one or two frames in GM8.1 and ENIGMA both.

room_caption = chr(random(255));

repeat (5000) {
	draw_circle(100 + random(500), 100+ random(500), 10, false);
}
draw_text(0,0,string(fps));

codecov[bot]  

Codecov Report

Merging #2063 into master will increase coverage by 0.02%.
The diff coverage is 78.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2063      +/-   ##
==========================================
+ Coverage   30.93%   30.96%   +0.02%     
==========================================
  Files         197      196       -1     
  Lines       19102    19113      +11     
==========================================
+ Hits         5910     5918       +8     
- Misses      13192    13195       +3     
Impacted Files Coverage Δ
ENIGMAsystem/SHELL/Platforms/General/PFmain.cpp 73.33% <78.57%> (+0.41%) ⬆️
ENIGMAsystem/SHELL/Platforms/General/PFwindow.h

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cbea4ac...11dfaad. Read the comment docs.

Please sign in to post comments, or you can view this issue on GitHub.