BUG Military Adviser

Hi, I'm working on putting tabbed screens on the military adviser and I have a question. How did you do it? I tried redrawing a tabbed screen when it was selected and it worked nicely until I went to the default screen. It would not redraw the minimap. It wasn't there is actually more correct, but when I exited the screen by pressing EXIT or by using the ESC key and then re-opened it the minimap was there. My final solution was to list all widget names used on the tabs and when the default screen is loaded I delete those widgets. Its a pain so I was wondering if you knew how to do it differently. I haven't used BUG MOD or this screen so i can't check for my self. Thanks. ;)
 
Hi, I'm working on putting tabbed screens on the military adviser and I have a question. How did you do it? I tried redrawing a tabbed screen when it was selected and it worked nicely until I went to the default screen. It would not redraw the minimap. It wasn't there is actually more correct, but when I exited the screen by pressing EXIT or by using the ESC key and then re-opened it the minimap was there. My final solution was to list all widget names used on the tabs and when the default screen is loaded I delete those widgets. Its a pain so I was wondering if you knew how to do it differently. I haven't used BUG MOD or this screen so i can't check for my self. Thanks. ;)
I pickup up the victory options screen and ported the existing MA to that. The standard MA doesn't have tabs and I was having a very hard time introducing it. I Looked at the screens that do have tabs and found at least 2 methods of putting in the tabs and controlling what gets shown. I selected the victory screen as my template because it was the easiest to understand.

That said, I had trouble with the mini-map too. There is a function 'minimap.visible' (or similar) that didn't seem to work when I set it to True or False. I think I ended up noting all the widgets that are created and deleting them (as per your outline).

Or, I could have added a panel on my second tab that covers the minimap and left the minimap as always visible and trusted the panel to cover it when it isn't required. I cannot remember which I did now.
 
I'm not sure I should say since it is for DPII's Conqueror's Delight.

How dare you mention it in public! :trouble:

;) It's for a promotions screen that will allow you to swap out promotions for individual units.
 
Wow, are we letting just anyone post in our forum now? Even admitted BUG non-users and Brazilians?! :p

I remember fixing this, but I don't remember exactly what I did. Luckily, Big Brother Subversion keeps track of such things for us.


Check out the differences made in revision 710. Okay, I just did, and I don't see any glaring differences short of an unused variable.

In any case, when switching tabs, all widgets are deleted. When switching back to the deployment tab, the minimap is reinitialized using these functions:

Code:
	def UL_initMinimap(self, screen):
		# Minimap initialization
		iMap_W = CyMap().getGridWidth()
		iMap_H = CyMap().getGridHeight()
		self.H_MAP = (self.W_MAP * iMap_H) / iMap_W
		if (self.H_MAP > self.H_MAP_MAX):
			self.W_MAP = (self.H_MAP_MAX * iMap_W) / iMap_H
			self.H_MAP = self.H_MAP_MAX

		szPanel_ID = self.MINIMAP_PANEL
		screen.addPanel(szPanel_ID, u"", "", False, False, self.X_MAP, self.Y_MAP, self.W_MAP, self.H_MAP, PanelStyles.PANEL_STYLE_MAIN)
		screen.initMinimap(self.X_MAP + self.MAP_MARGIN, self.X_MAP + self.W_MAP - self.MAP_MARGIN, self.Y_MAP + self.MAP_MARGIN, self.Y_MAP + self.H_MAP - self.MAP_MARGIN, self.Z_CONTROLS)
		screen.updateMinimapSection(False, False)
		screen.updateMinimapColorFromMap(MinimapModeTypes.MINIMAPMODE_TERRITORY, 0.3)
		screen.setMinimapMode(MinimapModeTypes.MINIMAPMODE_MILITARY)

		self.UL_SetMinimapVisibility(screen, True)
		screen.bringMinimapToFront()

	def UL_SetMinimapVisibility(self, screen, bVisibile):
		iOldMode = CyInterface().getShowInterface()

		if bVisibile:
			CyInterface().setShowInterface(InterfaceVisibility.INTERFACE_MINIMAP_ONLY)
		else:
			CyInterface().setShowInterface(InterfaceVisibility.INTERFACE_HIDE)
			
		screen.updateMinimapVisibility()
		CyInterface().setShowInterface(iOldMode)

If your screen runs without any other files, you could send it to me and I'll take a look if you can't get it working.
 
@EF - now you are just showing off. And, for the record, I'm pretty sure that I added those two functions. Sure - they didn't work but I added them :D.

Spoiler :
no doubt EF is going to dredge up the change log showing that he added them, but then my memory is much more reliable than any stupid change log. Well, more entertaining anyway. Would you believe more flattering to me?
 
I most definitely did not create functions called "UL_blahblah". :rolleyes: It took all my willpower not to rename them all.

The commit for 710 says that I fixed the minimap redraw problem, but I just don't have the energy to read the full diff. It's linked in my previous post if anyone cares to figure out the key difference.
 
I know - honestly ... who calls a function 'blahblah' - about as descriptive as 'how long is a piece of string?'

I'm assuming you know what the UL stands for.
 
1. Different units of the same class are displayed because not every unique unit is obviously better than the stock unit. Sure, the Praetorian beats the Swordsman, but what about Monty's poor excuse for an Axeman?

Maybe we could add it as an option:

x Unique Units Always Better Than Those They Replace

You certainly don't want to consider unique units to be equal to stock units and hide them both, right?

2. The selection behavior is due to the half-finished deployment tab. The code I modified only stores the unit types selected without regard to where they are. I will finish this screen after I complete the core rewrite. This is high priority.

Besides, there's an actual functionality bug (versus a display issue) on that tab: some units simply are not shown! :eek: I know the reason and will fix this very soon.

If you read back in this thread, you will see that the design has two dropdowns for selecting the grouping/sorting. The code can currently group by location, combat type, unit type, level, and promotions. And if you edit the Python, you can change the groupings yourself (very easy, search for "loc" with the quotes.

Code:
grouping1 = self.stats.getGrouping("loc")
grouping2 = self.stats.getGrouping("type")

The other valid values are "combat", "level", and "promo" if you'd like to play around with them. They can appear in any order, but you only get two groupings so far, and I don't know what will happen if you use the same value for each. I doubt there will be very many casualties. :p

Mmmmm, the version I have doesn't have any dropdown to select the unit grouping; I've also downloaded BUG 3.0 and replaced my CvBUGMilitaryAdvisor.py, but there're no evident differences.
Is there a newer version of this screen? Could you post it here, updating the download link in this thread? Thanks.
 
Mmmmm, the version I have doesn't have any dropdown to select the unit grouping.

It's still just a design in my head. You can change the grouping by modifying the Python code manually in the meantime. I got interrupted by the 3.0 release and now the core rewrite. I'll get back to the MA soon.
 
Cool. :o I've been looking for a better alternative than going through all the leaders every turn to find out who will declare war on whom.

Anyone tried to implement this with Rhye's And Fall of Civilization yet?
 
I've found and (hopefully) corrected a little bug, that occurs when both vassals and defensive pacts are in the game; when it happens, an error messagebox shows displaying an "Index outside the bounds of the array" error.

In the CvBUGMilitaryAdvisor.py, function initGrid(self, screen, bVassals, bDefPacts).
When you create the array of columns, there's a section:

Code:
 if (not bVassals and not bDefPacts):
......
 if (bVassals and bDefPacts):
......
 else:
......

I think the second "if" should be an "elif", and in the final "else" (when only one between "bVassals" and "bDefPacts" is true) you should set their column indexes to the same value (otherwise, you create 8 columns, and use index values up to 8, so the error).

I did that:

Code:
if (not bVassals and not bDefPacts):
[INDENT]......[/INDENT]
#byFra
#if (bVassals and bDefPacts):
elif (bVassals and bDefPacts):
[INDENT]......[/INDENT]
 else:
[INDENT]
......
#byFra
self.Col_DefPacts = 7
[/INDENT]

It seems to work!
 
@ViterboKnight - That looks correct. I'll add it to the SVN version when I've finished my current MA work.

Speaking of current MA work, I am 99% of the way done with the Strategic Advantages stuff. There is one issue remaining regarding upgrades and unique units.

Here's an example from a recent game: I don't have Military Tradition, but my rival does (along with horses and Rifling which I do have). It shows Cavalry (correct), but it also shows Cataphract and Cuirasier (both incorrect).

The reason is that Cataphract -> Cuirasier and Cuirasier -> Cavalry, but we leave the older units in in case I cannot see Cavalry because I don't know and cannot research Rifling or Military Tradition. But I need to have it remove those older units since I can see that he can build Cavalry.

I think part of the problem is UUs, so I just need to make the code to detect upgrades more generic.

However, before I do that I want to make sure that in the above case we really do want Cataphract and Cuirasier hidden. He certainly cannot build them anymore, and we know that, so it seems wrong to show them as advantages when he has a far better advantage available.
 
Back
Top Bottom