[DLL] Gotcha's in the DLLUI methods

whoward69

DLL Minion
Joined
May 30, 2011
Messages
8,727
Location
Near Portsmouth, UK
Why do I do this? It seemed so simple! All I wanted to do was open the City View screen in Buy Plot mode from within the DLL/C++ code.

In theory, 4 lines of code, taken from the "Select Next City" and "Open City View" keyboard short-cuts code, plus one line to select the mode (same as clicking the Buy Plots button)

Code:
DLLUI->selectCity(GC.WrapCityPointer(pCity).get());
DLLUI->setInterfaceMode(INTERFACEMODE_PURCHASE_PLOT);
DLLUI->selectLookAtCity();
DLLUI->lookAtSelectionPlot();

There appear to be internal sequencing issues within those calls caused by the camera moving and zooming. Most of the time you'll get the capital, regardless of what pCity is, some times the correct city, never the buy plots screen - although it may flash on and off as if taunting you as the camera pans across the map!

None of this is helped by not having the DLLUI source code :(

11 hours later I have a C++/Lua solution (that involves the C++ code "opening" a Lua dialog pop-up which opens the City View screen and fakes the Buy Plots button) - did I mention the sequencing issues in the Lua UI methods caused by the camera panning/zooming ...

So the moral of the tail. Avoid DLLUI-> like the plague (unless you have a lot of free time on your hands!) Or if you don't, don't try and do something that the devs didn't need themselves :mad:


EDIT: The answer to the question "Why?" is in the spoiler/thumbnail :D

Spoiler :
attachment.php
 

Attachments

  • UI - City Expansion.jpg
    UI - City Expansion.jpg
    177.8 KB · Views: 111
Does it send a notification now instead of doing an auto expand at 0? I think that is what you just said it does, with all that talk about camera panning. Sounds pretty cool! I really need to get a front end on this DLL so it can be moved from just a component to an actual stand alone mod that people understand how to use. (As well as used the way it is now).
 
Does it send a notification now instead of doing an auto expand at 0?
Yes. And there's also (when polished and published) a front end for it, watch out for "UI - City Expansion"

really need to get a front end on this DLL so it can be moved from just a component to an actual stand alone mod that people understand how to use. (As well as used the way it is now).

It already has (multiple) front-ends, in the various mods that depend on it. As someone else has pointed out, I just need to update the options file to indicate which ones they are
 
Back
Top Bottom