So I’m working on a project and I’m running into conceptual problems in creating my user interface. It’s for a DirectX11 multi-monitor game I’m writing.
I’ve got a prototype working, with entity menus popping up and more entities inside those menus. All is well and good, except it’s a coding fuster-cluck. I’m doing it wrong, so I’ve been spending the past couple weeks on learning & deciding how to refactor it to be better.
So far, I’ve decided to separate it into three parts, similar to MVC: One is the Event Listener, or the Controller, which will contain the bounding boxes, the base class, and the GUID for the entity. And a bunch of virtual methods, that each act towards a single type of input. I’m planning in arranging the memory structure of the entities in a Quad-Tree, with objects that span multiple quad’s to be allocated to both, and for the quads to be broken down until no more than 8 items are in a quad, whereupon a linear search will be made, from highest GUID item to lowest. Input is run through the Event Listener, and it runs the virtual functions on a entity.
The next part is the Entity Class, or Model, which holds the type for all entities. Units, menus, etc, etc. The base Entity class has virtual functions for all the click-types, as well as Scrolling, Hovering, and Keyboard input. By running final virtual functions in derived classes, I update my Gamestate,
Lastly, in my Gamestate or View, I’m recording what Entities are active on the screen, as well as the state of all other entities. Here is also where I register/unregister things from the event listener. It also contains methods that direct what is shown to the user.
Now, my problem is like this. For stationary entities, or ones that move rarely, like menu items and scroll-bars, the cost for recalculating the quad-tree for them is fairly low cost. Menu objects don’t always need to be added or removed every frame. The problem comes in when I’m dealing with the viewing of multiple unit entities (there could be up to several hundred on screen at a time). They are moving on a 2d plane, and can be moving between bounding boxes fairly rapidly. Assembling the quad tree is something like nlog^2n in the worst case scenario, where everything is clustered or large enough to span multiple bounding boxes. So I don’t think that rebuilding it each frame is the best solution.
Unregistering items also looks to be a pain, as I’ll have to traverse the entire tree to find the particular GUID, unless I make second tree of GUID entities and use it to point to the particular node on a tree which will contain pointers to the node(s) on the other tree that contain that entities GUID. Or I could just rebuild the entire tree each gamestate update. Which, again, would be expensive.
Is there a better design pattern to set up my user interface, or at least the Event Listener part of it, and if so, what is it?
✓ Extra quality
ExtraProxies brings the best proxy quality for you with our private and reliable proxies
✓ Extra anonymity
Top level of anonymity and 100% safe proxies – this is what you get with every proxy package
✓ Extra speed
1,ooo mb/s proxy servers speed – we are way better than others – just enjoy our proxies!
USA proxy location
We offer premium quality USA private proxies – the most essential proxies you can ever want from USA
Our proxies have TOP level of anonymity + Elite quality, so you are always safe and secure with your proxies
Use your proxies as much as you want – we have no limits for data transfer and bandwidth, unlimited usage!
Superb fast proxy servers with 1,000 mb/s speed – sit back and enjoy your lightning fast private proxies!
99,9% servers uptime
Alive and working proxies all the time – we are taking care of our servers so you can use them without any problems
No usage restrictions
You have freedom to use your proxies with every software, browser or website you want without restrictions
Perfect for SEO
We are 100% friendly with all SEO tasks as well as internet marketing – feel the power with our proxies
Buy more proxies and get better price – we offer various proxy packages with great deals and discounts
We are working 24/7 to bring the best proxy experience for you – we are glad to help and assist you!