Monday, March 3, 2025
spot_img

Adventures in Map Zooming, Half 3: Implementation


Time to get critical! Final time I advised you about my engine improve and the brand new “quads,” now it’s to place them to make use of.

If you happen to recall, for my preliminary Cogmind map zoom demo upon including Quad assist to REX, all I did was change one factor within the sport: the map font dimension.

The sport doesn’t care in regards to the engine facet of issues so it merely labored, or not less than didn’t crash and we may simply see the way it’d seem, regardless of after all quite a few enter and secondary show points in another home windows. By simply tweaking a couple of extra variables it will be straightforward to unravel all these issues with the intention to purely have a constantly bigger map view. Issues get lots extra advanced if we wish to assist each the common map font and quads, to not point out the power to swap them dynamically whereas the sport is operating.

However with the engine fundamentals stable and behind us, we’re able to deal with these challenges.

Usually with UI characteristic implementation I’ll begin by writing out a complete listing of every little thing that must be executed, and another parts I can consider which is likely to be affected and due to this fact want testing and affirmation. Whereas I drew up not less than a part of such a listing like dev, that is a kind of rarer circumstances the place making an attempt to jot down a whole listing forward of time might be not all that possible or useful, because it’s principally… all the interface 😛

With a change like this I would wish to check just about every little thing, so as an alternative of attempting to be full about it, I simply famous areas of the code to be adjusted as I thought of them whereas engaged on fixing high-priority options, attempting my greatest to complete off complete teams of associated interface parts to hurry up the method.

I began in crucial place, restoring the essential performance required to hurry up the remainder of the implementation, like fixing map panning and cursor-map interactions. And realtime zoom toggling with the intention to simply examine and ensure that every little thing features correctly in each states.

And it was shortly after getting these bits operational that I found I wasn’t fairly executed with the engine xD

When inspecting the main points of what nonetheless wanted to be executed within the map space itself, I noticed that whereas zoomed in we’d in all probability additionally wish to improve the font dimension of many varieties of textual content that seem over the map, particularly object labels that are already built-in fairly tightly into the map coordinate and orientation techniques.

cogmind_map_zoom_wip_map labels_small

Yeah these labels should not nice like this, utilizing the common textual content dimension (ignore the truth that they’re not even pointing on the proper objects right here :P).

To take care of the proportionality of map-related textual content when zoomed in, we’d want… zoomed textual content. Oh no.

Again to REX

Final time I launched the engine’s base cell dimension that matches particular person textual content characters, huge glyphs for sq. map tiles, and the brand new “quad,” or 4 map tiles with the intention to allow a zoomed impact. To zoom textual content we’d want yet one more kind of glyph dimension, one which just like the doubling of map tiles for quads (2×1 to 4×2) as an alternative doubles textual content/base cell dimension (1×1 to 2×2!).

For me one of many first annoyances was what to name this new kind, and I made a decision they’re in all probability greatest named after the variety of base cells they occupy, that means I needed to go in and retroactively rename all of the quad stuff to oct. Now our zoomed textual content glyphs can assume the title “quad.”

rex_terminal_grid_demo_quad_and_oct

A brand new member joins the REX glyph kind household!

As a result of I had constructed a generalized system to simplify dealing with of each huge glyphs and octs (beforehand quads), inserting this new kind was really pretty straightforward (whew!).

rex_testing_console_quads_and_octs

REX once more displaying operation of the newly renamed octs, and the brand new quads (the primary new space of curiosity being the big olive-colored field).

Nicely, the preliminary implementation was quick, however on returning to Cogmind to use it to map labels I discovered a problem…

cogmind_map_zoom_wip_label_text_shearing_bug

The textual content quads labored properly in most locations, however typically this occurred. Maybe we’ll simply say this Recalibrator is corrupted and go away it at that? 😛

It took some time to determine this one out, since I couldn’t fairly inform if it was a Cogmind drawback or a REX drawback. This was notably difficult to trace down as a result of it seemed like an engine bug but additionally had a property that recommended it couldn’t be an engine bug, but its different conduct pointed to it to being unimaginable to be a bug brought on by the sport itself… Anyway, a very bizarre confluence of conditions managed to cover the actual purpose for hour. It needed to do with a selected kind of partial transparency of the brand new quads/octs, and naturally it was brought on by only one line of code within the engine.

Zoom Textual content Functions

Yay now we are able to have some massive textual content on the map, too!

cogmind_map_zoom_wip_map labels_large

Revisiting the scene from earlier, this time with bigger labels.

Past labels, I additionally enabled the on-map mode indicators to utilize quad textual content. To facilitate this (and by necessity for architectural causes), I additionally refactored that a part of the UI–they was once drawn on to the map on the finish of its rendering course of, however now they’re an actual window.

cogmind_map_zoom_item_large_text_label_category_mode_indicator

Biking by means of merchandise label classes, with the mode indicator seen on the prime of the map view.

On-map popup alerts like low matter/core/and so forth. additionally received the zoomed textual content remedy, for one as a result of they in any other case seems to be pretty small in comparison with every little thing else and can be much more prone to go unnoticed.

“ALERT” bulletins are additionally bigger now, nearly too massive once they embrace longer strings, however once more having them stay at regular textual content dimension doesn’t appear supreme for getting observed among the many bigger map cells. I’d tweak these later when the UI undergoes extra adjustments down the road, however for now they’re massive.

I additionally determined to transform this system shutdown animation to the zoomed textual content, and in contrast to its different makes use of described above, that is the one occasion wherein it’s used no matter map zoom state.

cogmind_close_animation_new_strip_size_2

Cogmind’s program shutdown animation with bigger central bar.

The MegaTODO

The UI is far more than only a handful of short-term popups although! Again to that rising listing of challenges… effectively, technically most should not particularly difficult, it was only a case of placing in all the mandatory hours to scour the supply for something affected by the arrival of latest glyph varieties.

There have been heaps and much (and much) of alignment points as a result of years of relative coordinate assumptions behind the truth that map areas had been at all times twice as huge as textual content, and each textual content and map areas had the identical top. Now map cells may very well be 4 instances as huge as textual content, and twice as tall!

Most popup home windows relative to one thing on the map wanted to have their dynamic coordinates bear in mind further calculations.

cogmind_cursor_hover_detection_debug_visualization

The outdated REX debugging visualization for inspecting UI z-depth and cursor hover focus got here in fairly useful for fixing a number of the extra mysterious points.

cogmind_debugging_console_index_structure_output

I additionally lastly constructed an exporter for Cogmind’s window index construction to assist observe down some points associated to cursor enter. In actual fact it additionally helped me discover and resolve an unreported and difficult-to-notice bug in Cogmind’s UI that’s been in there because the very first model!

A piece of the variation work really required bigger architectural rewrites, just like the challenge of splitting the map interface right into a trio of courses.

The primary new class was purely to carry interface knowledge that have to be preserved throughout zoom occasions. Every time a zoom happens, all the map interface is definitely destroyed and recreated from scratch (far less complicated than attempting to transform every little thing over), however doing so would additionally lose some vital information wanted to facilitate varied QoL options comparable to focusing on historical past and useful resource alarm data. So knowledge of that nature was moved to an exterior class to protect it no matter any zooming.

The second class is extra attention-grabbing, a form of container for different home windows, these which are positioned over the map itself.

Various home windows comparable to on-map dialogue traces, fight logs, and achievement popups could have to be positioned on any UI row throughout the map space, and these being organized below that window itself was by no means a problem earlier than. However what occurs when the map is zoomed such {that a} single “oct” occupies two rows? The map window’s grid coordinate system now not has any values corresponding to each odd row of the primary interface, that means its little one home windows can’t be positioned on these rows.

So all of these map-related home windows wherein vertical alignment is vital down the sub-row degree wanted a brand new mum or dad window, form of a pretend alternate map window that at all times has a finer coordinate system whatever the viewable map’s zoom state.

None of those informational home windows are interactive, both, so this “finer map” window doesn’t have to seize mouse enter and solely has to occupy a 1×1 spot within the top-left nook of the map. It’s a good instance of an “unhidden but clear and due to this fact invisible” management window, permitting it to replace usually and its kids can each seem seen and use their mum or dad as a coordinate reference (inserting subwindows outdoors of a mum or dad is okay).

The rationale it will need to have an unhidden state is as a result of that’s a prerequisite for really updating itself and updating kids, however is on the similar time clear as a result of the window doesn’t really wish to show something of its personal.

cogmind_debugging_window_zlayer_data

One other helpful debugging characteristic, the power to indicate all home windows that exist below a given cursor location and their z-depth. With the cursor within the top-left nook of the map there, it exhibits that there are two map courses overlapping at that location, the single-cell window container CMapFine, and the common CMap class. The opposite values can present issues like coordinates, indices, present colours, tile values, and any energetic animations at that time.

So yeah, lengthy story quick, this course of wasn’t nearly altering font settings and recalculating coordinates.

At this level all of the heaviest lifting was executed, however there was nonetheless an terrible lot of residual work earlier than map zooming may very well be referred to as characteristic full. I’ll share extra on that subsequent time.

That is the third in a five-part journey by means of the method of placing all this collectively:

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest Articles