예제 #1
0
파일: dialog.py 프로젝트: bitcraft/lpc1
 def activate(self):
     from lib2d.gui import GraphicBox
     self.border = GraphicBox("dialog2.png")
예제 #2
0
파일: dialog.py 프로젝트: MacLeek/mh
 def activate(self):
     from lib2d.gui import GraphicBox
     self.border = GraphicBox("dialog2.png")
예제 #3
0
파일: dialog.py 프로젝트: bitcraft/lpc1
class TextDialog(GameState):
    """
    State that takes focus and waits for player to press a key
    after displaying some some text.
    """

    # works well for the defualt font and size 
    wrap_width = 44 
 
    wait_sound = res.loadSound("select0.wav")
    wait_sound.set_volume(0.40)


    def __init__(self, text, title=None):
        GameState.__init__(self)
        self.font = "dpcomic.ttf"
        self.text = text
        self.title = title
        self.blank = True


    # when given focus for first time
    def activate(self):
        from lib2d.gui import GraphicBox
        self.border = GraphicBox("dialog2.png")


    def draw(self, surface):
        if self.blank:
            self.blank = False

            sw, sh = surface.get_size()
            fontSize = int(0.0667 * sh)

            # draw the border
            x, y = 0.0313 * sw, 0.6667 * sh
            w, h = 0.9375 * sw, 0.2917 * sh
            self.border.draw(surface, (x, y, w, h))
           
            fullpath = res.fontPath("dpcomic.ttf")
            font = pygame.font.Font(fullpath, fontSize)

            # adjust the margins of text if there is a title
            if self.title:
                x = 0.0625 * sw
                y = 0.7 * sh

            gui.drawText(surface, self.text, (0,0,0), (x+10,y+8,w-18,h-12),
                         font, aa=1, bkg=self.border.background)
            
            # print the title
            if self.title != None:
                banner = OutlineTextBanner(self.title, (200,200,200),
                                           int(fontSize*1.25), font=self.font)
                title_image = banner.render()
                x, y = 0.4688 * sw, 0.625 * sh
                surface.blit(title_image, (x, y))

            # show arrow
            #x, y = 0.0625 * sw, 0.9167 * sh
            #arrow = res.loadImage("wait_arrow.png", colorkey=1)
            #surface.blit(arrow, (x, y))

            # play a nice sound 
            self.wait_sound.stop()
            self.wait_sound.play()


    def handle_commandlist(self, cmdlist):
        for cls, cmd, arg in cmdlist:
            if arg == BUTTONDOWN and cmd == P1_ACTION1 and not self.blank:
                sd.done()   
예제 #4
0
파일: dialog.py 프로젝트: MacLeek/mh
class TextDialog(GameState):
    """
    State that takes focus and waits for player to press a key
    after displaying some some text.
    """

    # works well for the defualt font and size
    wrap_width = 44

    wait_sound = res.loadSound("select0.wav")
    wait_sound.set_volume(0.40)

    def __init__(self, text, title=None):
        GameState.__init__(self)
        self.font = "dpcomic.ttf"
        self.text = text
        self.title = title
        self.blank = True

    # when given focus for first time
    def activate(self):
        from lib2d.gui import GraphicBox
        self.border = GraphicBox("dialog2.png")

    def draw(self, surface):
        if self.blank:
            self.blank = False

            sw, sh = surface.get_size()
            fontSize = int(0.0667 * sh)

            # draw the border
            x, y = 0.0313 * sw, 0.6667 * sh
            w, h = 0.9375 * sw, 0.2917 * sh
            self.border.draw(surface, (x, y, w, h))

            fullpath = res.fontPath("dpcomic.ttf")
            font = pygame.font.Font(fullpath, fontSize)

            # adjust the margins of text if there is a title
            if self.title:
                x = 0.0625 * sw
                y = 0.7 * sh

            gui.drawText(surface,
                         self.text, (0, 0, 0), (x + 10, y + 8, w - 18, h - 12),
                         font,
                         aa=1,
                         bkg=self.border.background)

            # print the title
            if self.title != None:
                banner = OutlineTextBanner(self.title, (200, 200, 200),
                                           int(fontSize * 1.25),
                                           font=self.font)
                title_image = banner.render()
                x, y = 0.4688 * sw, 0.625 * sh
                surface.blit(title_image, (x, y))

            # show arrow
            #x, y = 0.0625 * sw, 0.9167 * sh
            #arrow = res.loadImage("wait_arrow.png", colorkey=1)
            #surface.blit(arrow, (x, y))

            # play a nice sound
            self.wait_sound.stop()
            self.wait_sound.play()

    def handle_commandlist(self, cmdlist):
        for cls, cmd, arg in cmdlist:
            if arg == BUTTONDOWN and cmd == P1_ACTION1 and not self.blank:
                sd.done()