Negator_UK
King
- Joined
- Nov 14, 2007
- Messages
- 758
I'm trying to develop a little information mod, no python experience, but I've done OK so far pulling some code from jeckel & baldyr to make some small progress.
I am trying to build a menu out of a vertical of stack panels, similar to the info screen in Civ4 BTS.
I am using addPanel() but I have a problem.
I can create a background panel, or a single foreground panel, but not multiple panels.
Is there a rule against this ? there seems to be multiple addPanel() calls in the screens in the main game python code, but I am befuddled.
help ! (see comments in code, about 3/4 down).
I am trying to build a menu out of a vertical of stack panels, similar to the info screen in Civ4 BTS.
I am using addPanel() but I have a problem.
I can create a background panel, or a single foreground panel, but not multiple panels.
Is there a rule against this ? there seems to be multiple addPanel() calls in the screens in the main game python code, but I am befuddled.
help ! (see comments in code, about 3/4 down).
Code:
#
# SMUG Mod AI Information Screen.
# By Negator, with help from Jeckel
#
#
from CvPythonExtensions import *
import CvScreenEnums
############################################################################
# globals
gc = CyGlobalContext()
ArtFileMgr = CyArtFileMgr()
localText = CyTranslator()
class CvAIInfoScreen:
def __init__(self):
self.sWidgetPrefix = "smugAIInfoScreen"
self.MANAGER_SCREEN_ID = self.sWidgetPrefix + "MainWindow"
self.BACKGROUND_ID = self.sWidgetPrefix + "BackgroundImage"
self.EXIT_ID = self.sWidgetPrefix + "ExitWidget"
# private class data - needs to match background bitmap
self.X_SCREEN = 0
self.Y_SCREEN = 0
self.W_SCREEN = 1024
self.H_SCREEN = 512
#############################################################################################################
def getScreen(self):
return CyGInterfaceScreen(self.MANAGER_SCREEN_ID, CvScreenEnums.SMUG_AI_INFO_SCREEN)
def hideScreen(self):
screen = self.getScreen()
screen.hideScreen()
return None
def update(self, fDelta):
return None
# handle the input for this screen...
def handleInput(self, inputClass):
screen = self.getScreen()
iNotifyCode = inputClass.getNotifyCode()
iNotifyClicked = NotifyCode.NOTIFY_CLICKED
iNotifyChar = NotifyCode.NOTIFY_CHARACTER
if(iNotifyCode == iNotifyClicked):
sInputName = inputClass.getFunctionName()
return 0
#############################################################################################################
# Screen construction function
def interfaceScreen(self):
screen = self.getScreen()
if (screen.isActive()):
return None
# Find out our resolution
xResolution = screen.getXResolution()
yResolution = screen.getYResolution()
# set screen size
x0 = (xResolution-self.W_SCREEN) / 2
y0 = (yResolution-self.H_SCREEN) / 2;
screen.setDimensions(x0, y0, self.W_SCREEN, self.H_SCREEN)
# set background
myTitle = "AI Info Screen"
myHelp = "Get your AI info here !"
isVertical = 0
isScrollable = 1
# Draw a big red rectangle as background to menu.
# This works.
myP = "Bkg"
x = 0
y = 0
w = self.W_SCREEN
h = self.H_SCREEN
myStyle = PanelStyles.PANEL_STYLE_BLUE50
#screen.addPanel(myP, myTitle, myHelp, isVertical, isScrollable, x, y, w, h, myStyle)
#screen.setPanelColor (myP, 150, 0, 0)
#screen.Hide(myP)
# Draw a vertical stack of smaller rectangles in the big one
# This does not work, although the first one will draw OK if
# I comment out the big red one above - wtf ?
mainBorder = 10
y = 40
x = x + mainBorder
w = w - mainBorder
h = 40
isScrollable = 0
myStyle = PanelStyles.PANEL_STYLE_BLUE50
i = 1
while i < 5:
myTag = "x" * i
myP = "panel" + myTag
myTitle = "AI No " + myTag
myHelp = "Help for AI No " + myTag
screen.addPanel(myP, myTitle, myHelp, isVertical, isScrollable, x, y, w, h, myStyle)
screen.setPanelColor (myP, 0, 0, 100)
screen.Hide(myP)
y = y + 100
i = i + 1
# End of problem code (I think)
# set render info
screen.setRenderInterfaceOnly(True);
screen.showScreen(PopupStates.POPUPSTATE_IMMEDIATE, False)
screen.showWindowBackground(True)
#############################################################################################################