Instances - necessary?

daviiadams

Prince
Joined
Jul 7, 2011
Messages
369
Location
London
Hi all,

I've been improving the layout off a ToolTip within one of my mods, purely to make it clearer/easier on the eyes, but have become bogged down with displaying all the info.

The difficulty I'm having now, is that only the last set of info is being displayed, whereas before everything from the loop would be there.

Having a look at similar examples of code, I added in the instance aspect, but can't get passed either a root control error, or a failure to index issue.

If deliberately laying out info on the xml side, is it actually necessary to involve instances, or could I be looking at the wrong thing?

I'm assuming it is required, considering the last-in-the-loop result mentioned above and they're there for similar things, but a bit :confused:
 
The answer is "it depends" - if the XML contains a control for every piece of information you need to display, then no. However, if your information is repetitive then it depends on how you are displaying it. If you're building up a long text string for a tooltip, then again no. But if you're adding combinations of controls (say image + label) then yes. And then what type of instance (the instance manager or direct via BuildInstanceForControl() - or whatever it's actually called) affects how it needs to be coded.

Chapters 2 and 3 of the UI Component Guide may help as they deal with instances, otherwise we'll need to see the code and the log files

W
 
The answer is "it depends" - if the XML contains a control for every piece of information you need to display, then no. However, if your information is repetitive then it depends on how you are displaying it. If you're building up a long text string for a tooltip, then again no. But if you're adding combinations of controls (say image + label) then yes. And then what type of instance (the instance manager or direct via BuildInstanceForControl() - or whatever it's actually called) affects how it needs to be coded.

Chapters 2 and 3 of the UI Component Guide may help as they deal with instances, otherwise we'll need to see the code and the log files

W

As it's a combination of image/labels, then it would appear necessary from what you've said. I'd been mimmicking the scenario whereby instance manager is involved, from things like Diplo screens (as the image involved is the Civ's colour icon), with varying combinations involved on the xml side, without success.

I'll read up in the guide, thanks for posting the link for that :)
 
As it's a combination of image/labels, then it would appear necessary from what you've said.
Yep, you'll need to use instances - is this in a stack/menu control or in a tooltip?


as the image involved is the Civ's colour icon
CivIconHookup() from IconSupport is your friend here ;)
 
An example of where Firaxis did not use instances (but should have) is the policy branches. Each one is separately coded in the xml file with "hard links" back to textures and help texts. It's perhaps easier to understand at first glance (for a novice), but it really makes things harder to mod.
 
Yep, and the Tech Tree is an excellent example of how not to code pipe connections and the Civilopedia is an excellent example of why "copy-and-paste" coders should be taken out and left in the wilderness for several week with nothing but a pair of scissors!

Unfortunately, Firaxis seem to have employed several interns to implement what were probably good designs and as a result have left us with lots of examples of how not to do things, which unfortunately get picked up by modders as "good practice, as that's what the core code does".

If you want a good laugh/cry one day look at the function assigned to "CivilopediaCategory[CategoryHomePage].SelectArticle" in Civilopedia.lua (if you can find it in the almost 6500 lines in that file!)
 
Yep, you'll need to use instances - is this in a stack/menu control or in a tooltip?



CivIconHookup() from IconSupport is your friend here ;)

It's all happening within a ToolTip, that I've got in my Government Buildings mod, in the bottom center of the screen. It shows your CS influence, attitudes etc and I had just created strings that change with the data.

The data, logic used and so on, appear fine, but I feel the layout becomes tiring on the eyes very quickly.

I've made use of stacks within the ToolTip, which doesn't appear to be an issue, along with CivIconHookup(), no issue there, it's just that I'll only get the last civ or city state in the loop being displayed.
 
An example of where Firaxis did not use instances (but should have) is the policy branches. Each one is separately coded in the xml file with "hard links" back to textures and help texts. It's perhaps easier to understand at first glance (for a novice), but it really makes things harder to mod.

I'd looked at the policy branch stuff a little while back and found it a bit :confused:
 
I've made use of stacks within the ToolTip, which doesn't appear to be an issue, along with CivIconHookup(), no issue there, it's just that I'll only get the last civ or city state in the loop being displayed.

Are you calling Controls.Stack:CalculateSize() to force the stack to resize itself after you've added all the instances to it?
 
Are you calling Controls.Stack:CalculateSize() to force the stack to resize itself after you've added all the instances to it?

I have that there, although if I remember rightly, I've had to use "tipControlTable" due to it being within a ToolTip.

I did create an additional index at one point, which didn't result in the Tuner complaining about anything, but resulted in no data being displayed.
 
without seeing the code (xml context and lua) it will be hard to make any more guesses as to what could be wrong
 
without seeing the code (xml context and lua) it will be hard to make any more guesses as to what could be wrong

I'm going to work through the info from your tutorial, see where that takes me and hopefully it'll be a case of just reporting back where I'd gone wrong :)
 
Back
Top Bottom