示例#1
0
    def __init__(self,
                 text,
                 position,
                 dimensions,
                 font,
                 fontColor,
                 backgroundColor,
                 buttonColor,
                 buttonDimensions,
                 buttonFont,
                 buttonFontColor,
                 confirmationText="YES",
                 denialText="NO",
                 buttonBorderWidth=1,
                 buttonBorderColor=(0, 0, 0),
                 borderWidth=0,
                 borderColor=(0, 0, 0)):
        """Initializes the widget with a variety of parameters"""
        Drawable.__init__(self, "", position, worldBound=False)
        Window.__init__(self)
        self._height = dimensions[1]
        self._width = dimensions[0]
        self._text = text
        self._font = font
        self._fontColor = fontColor
        self._backgroundColor = backgroundColor
        self._borderWidth = borderWidth
        self._borderColor = borderColor

        self._offset = position

        # Create the textbox
        self._t = makeMultiLineTextBox(self._text, (0, 0), self._font,
                                       self._fontColor, self._backgroundColor)
        y_pos = (self._height // 4) - (self._t.getHeight() // 2)
        x_pos = (self._width // 2) - (self._t.getWidth() // 2)
        self._t.setPosition((x_pos, y_pos))

        # Create the buttons
        self._b1 = Button(confirmationText, (0, 0), buttonFont,
                          buttonFontColor, buttonColor, buttonDimensions[1],
                          buttonDimensions[0], buttonBorderColor,
                          buttonBorderWidth)
        y_pos = (3 * (self._height // 4)) - (self._b1.getHeight() // 2)
        x_pos = (self._width // 3) - (self._b1.getWidth() // 2)
        self._b1.setPosition((x_pos, y_pos))

        self._b2 = Button(denialText, (0, 0), buttonFont, buttonFontColor,
                          buttonColor, buttonDimensions[1],
                          buttonDimensions[0], buttonBorderColor,
                          buttonBorderWidth)
        y_pos = (3 * (self._height // 4)) - (self._b2.getHeight() // 2)
        x_pos = (2 * (self._width // 3)) - (self._b2.getWidth() // 2)
        self._b2.setPosition((x_pos, y_pos))

        self._sel = None

        self.updateWindow()
示例#2
0
    def __init__(self, pos, dimensions, menuType="Load"):

        Drawable.__init__(self, "", pos, worldBound=False)
        Window.__init__(self)

        self._type = menuType

        self._offset = (pos[0], pos[1])

        self._width = dimensions[0]
        self._height = dimensions[1]

        self._font = pygame.font.SysFont("Times New Roman", 24)
        self._smallFont = pygame.font.SysFont("Times New Roman", 14)
        self._borderColor = (0, 0, 0)
        self._borderWidth = 2
        self._backgroundColor = (80, 80, 80)

        buttonWidth = 3 * (self._width // 4)
        buttonHeight = (self._height - 30) // 5

        buttonXpos = self._width // 2 - buttonWidth // 2
        buttonYpos = (self._height - buttonHeight) - 15

        self._tabs = Tabs(["Maps", "Templates"], (0, 0), self._font, (0, 0, 0),
                          (120, 120, 120), (self._width, 35), (0, 0, 0),
                          (255, 255, 255))

        self._loadButton = Button(menuType, (buttonXpos, buttonYpos),
                                  self._font, (0, 0, 0), (0, 255, 0),
                                  buttonHeight, buttonWidth // 2, (0, 0, 0), 2)

        self._cancelButton = Button(
            "Cancel", (buttonXpos + buttonWidth // 2, buttonYpos), self._font,
            (0, 0, 0), (120, 120, 150), buttonHeight, buttonWidth // 2,
            (0, 0, 0), 2)

        self._options = [{
            "text": x[11:][:-8],
            "func": self.updateSelection,
            "args": x[11:][:-8]
        } for x in glob.glob("maps/*")]
        self._levelSelect = ScrollSelector(
            (pos[0] + 3 + buttonXpos, pos[1] + 45),
            (buttonWidth, buttonHeight * 2.75), 30, self._options, (0, 0, 0))

        self._textbox = TextInput((buttonXpos, buttonYpos - (25 + 10)),
                                  self._smallFont, (buttonWidth, 25),
                                  maxLen=25)
        self._selection = None

        self.updateMenu()
示例#3
0
 def __init__(self, pos):
     """Initialize the emoticon object"""
     Drawable.__init__(self, "face_0.png", pos, worldBound=False)