View Full Version : [MODCOMP] Advisor Menu


Dale
Oct 24, 2008, 07:27 AM
With the ability to add our own advisors via python, it is easy to see how the UI will become very cluttered in the advisor bar. With the space to only add a couple of new advisor buttons, or move into the ilogical menu buttons (menu, pedia, etc) the matter of UI clutter becomes an issue.

If we were to add the current new advisors such as Jeckels Trade Route advisor, Melinko's Finance Advisor, Dom Pedro II's Triangle Trade Advisor, and Melinko's Tech Advisor, we would overflow the advisor area on screen by two icons.

This mod addresses that issue and resolves it cleanly, easily and logically. :)

The Advisor Menu is a new segment of the UI dedicated to advisor buttons. One simple button (left-hand button where domestic advisor used to be) is used to turn the Advisor Menu on or off. This allows for the retention of a clean UI and the ability to access all of a mod's advisors fast and easily in one area on the screen.

This is a very simple ModComp to implement (only affecting one python file, plus the single new text key) and simple to add new advisors to. Once you have your advisor working, simply add your advisor in two locations and presto, all the rest is taken care of. :)

Location 1: Define the button in the menu

# Advisor menu START
if (ADVISOR_MENU_PANEL_UP):
iBtnX = (xResolution / 2) + (TOP_CENTER_HUD_WIDTH / 2) - (self.ADVISOR_BUTTON_SIZE / 3)
iBtnY = ((TOP_CENTER_HUD_HEIGHT - self.ADVISOR_BUTTON_SIZE) / 2) + self.ADVISOR_BUTTON_SIZE

screen.setImageButton("DomesticAdvisorButton", ArtFileMgr.getInterfaceArtInfo("INTERFACE_DOMESTIC_ADVISOR").getPath(), iBtnX, iBtnY, self.ADVISOR_BUTTON_SIZE, self.ADVISOR_BUTTON_SIZE, WidgetTypes.WIDGET_ACTION, gc.getControlInfo(ControlTypes.CONTROL_DOMESTIC_SC REEN).getActionInfoIndex(), -1 )
screen.setImageShape("DomesticAdvisorButton", ImageShapes.IMAGE_SHAPE_ELLIPSE, -1)
screen.setHitMargins("DomesticAdvisorButton", self.ADVISOR_BUTTON_SIZE / 6, self.ADVISOR_BUTTON_SIZE / 6)
self.appendtoHideState(screen, "DomesticAdvisorButton", HIDE_TYPE_MAP, HIDE_LEVEL_HIDE)
iBtnX += self.ADVISOR_BUTTON_SPACING

screen.setImageButton("RevolutionAdvisorButton", ArtFileMgr.getInterfaceArtInfo("INTERFACE_REVOLUTION_ADVISOR").getPath(), iBtnX, iBtnY, self.ADVISOR_BUTTON_SIZE, self.ADVISOR_BUTTON_SIZE, WidgetTypes.WIDGET_ACTION, gc.getControlInfo(ControlTypes.CONTROL_REVOLUTION_ SCREEN).getActionInfoIndex(), -1 )
screen.setImageShape("RevolutionAdvisorButton", ImageShapes.IMAGE_SHAPE_ELLIPSE, -1)
screen.setHitMargins("RevolutionAdvisorButton", self.ADVISOR_BUTTON_SIZE / 6, self.ADVISOR_BUTTON_SIZE / 6)
self.appendtoHideState(screen, "RevolutionAdvisorButton", HIDE_TYPE_MAP, HIDE_LEVEL_HIDE)
iBtnX += self.ADVISOR_BUTTON_SPACING

screen.setImageButton("ForeignAdvisorButton", ArtFileMgr.getInterfaceArtInfo("INTERFACE_FOREIGN_ADVISOR").getPath(), iBtnX, iBtnY, self.ADVISOR_BUTTON_SIZE, self.ADVISOR_BUTTON_SIZE, WidgetTypes.WIDGET_ACTION, gc.getControlInfo(ControlTypes.CONTROL_FOREIGN_SCR EEN).getActionInfoIndex(), -1 )
screen.setImageShape("ForeignAdvisorButton", ImageShapes.IMAGE_SHAPE_ELLIPSE, -1)
screen.setHitMargins("ForeignAdvisorButton", self.ADVISOR_BUTTON_SIZE / 6, self.ADVISOR_BUTTON_SIZE / 6)
self.appendtoHideState(screen, "ForeignAdvisorButton", HIDE_TYPE_MAP, HIDE_LEVEL_HIDE)
iBtnX += self.ADVISOR_BUTTON_SPACING

screen.setImageButton("MilitaryAdvisorButton", ArtFileMgr.getInterfaceArtInfo("INTERFACE_MILITARY_ADVISOR").getPath(), iBtnX, iBtnY, self.ADVISOR_BUTTON_SIZE, self.ADVISOR_BUTTON_SIZE, WidgetTypes.WIDGET_ACTION, gc.getControlInfo(ControlTypes.CONTROL_MILITARY_SC REEN).getActionInfoIndex(), -1 )
screen.setImageShape("MilitaryAdvisorButton", ImageShapes.IMAGE_SHAPE_ELLIPSE, -1)
screen.setHitMargins("MilitaryAdvisorButton", self.ADVISOR_BUTTON_SIZE / 6, self.ADVISOR_BUTTON_SIZE / 6)
self.appendtoHideState(screen, "MilitaryAdvisorButton", HIDE_TYPE_MAP, HIDE_LEVEL_HIDE)
iBtnX += self.ADVISOR_BUTTON_SPACING
# Advisor menu END


Location 2: Show/hide the button

# Advisor menu START
elif (inputClass.getButtonType() == WidgetTypes.WIDGET_GENERAL and inputClass.getData1() == ADVISOR_MENU_PANEL):
screen = CyGInterfaceScreen("MainInterface", CvScreenEnums.MAIN_INTERFACE )
if (ADVISOR_MENU_PANEL_UP):
ADVISOR_MENU_PANEL_UP = False
screen.hide("DomesticAdvisorButton")
screen.hide("RevolutionAdvisorButton")
screen.hide("ForeignAdvisorButton")
screen.hide("MilitaryAdvisorButton")
else:
ADVISOR_MENU_PANEL_UP = True
screen.show("DomesticAdvisorButton")
screen.show("RevolutionAdvisorButton")
screen.show("ForeignAdvisorButton")
screen.show("MilitaryAdvisorButton")
# Advisor menu END


The attached screenshots show the menu on and off showing the simple ease of use this ModComp brings. I have also attached the ModComp.

I hope this is useful. :)

Melinko
Oct 24, 2008, 03:47 PM
Awesome ModComp and good idea, even good placement (On the X).. Although it is down a bit far. Other then that little bit it is very cool.:thumbsup:

Jeckel
Oct 24, 2008, 04:19 PM
Nice Dale, glad to see you went with the second row idea, and nice addition with button to make them go away. However I don't like how far down the second row is.

EDIT: Removed code blocks.

Dale
Oct 24, 2008, 04:28 PM
Cool! Even better. :)

Jeckel
Oct 24, 2008, 04:55 PM
I was talking with Melinko and he mentioned that it would look better also if the second row of Advisor Buttons was offset one button space to the right. I tryed it and it looks pretty good as the Screen Shot shows.

EDIT: Removed Screen Shot.

Dom Pedro II
Oct 24, 2008, 05:16 PM
I concur. It looks good offset.

Great little modcomp, Dale!

Dale
Oct 24, 2008, 11:48 PM
I've updated the first post with a new screenshot showing the amendments, and also updated the zip file containing the code. :)