I added a search function

One of my annoyances with The Nightfall Incident is the way that the program selection menu ends up getting cluttered. All your programs are listed in an arbitrary order, and you always have to scroll through it to find the one you’re looking for. To mitigate this in my game, I’ve added a search bar to the program menu:

As a side note, I had some trouble with the cursor. It was sometimes displaying and sometimes not, and I couldn’t work out why. I eventually worked it out, thanks to this post. Because I want the game to look good at high resolutions, I’ve set the window size to 4K. The cursor is one pixel wide, so when it scales down to run on my 1080p screen, the cursor is half a pixel wide. That meant it would sometimes round up to one pixel, and sometimes round down to 0 pixels.

For future reference (this is as much for me as it is for anyone else) I made the cursor wider and fixed it by doing the following:

Downloaded and extracted the Godot source code from the releases page on GitHub

Opened godot<version>/scene/gui/line_edit.cpp

Found where the caret_height variable is assigned on line 768:

int caret_height = font->get_height() > y_area ? y_area : font->get_height();

Made my own variable underneath it called caret_width, with a value of 4:

int caret_width = 4;

Found the other lines that refer to caret_height, and anywhere it was in brackets with either 1 or Math::round(EDSCALE), replaced that with caret_width. For example this line:

VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(Math::round(EDSCALE), caret_height)), cursor_color);

Turned into this line:

VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(caret_width, caret_height)), cursor_color);

Compiled it using the instructions in the Godot documentation

The cursor is now four pixels wide in the game’s native 4K, which makes it a comfortable 2 pixels wide on my screen. It should be one or two pixels wide on 1366×768 screens, and really, who has a screen smaller than that in 2020? It also applies to the text boxes in the Godot menus. It might be possible to fix that, but I couldn’t be bothered to compile it again.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s