예제 #1
0
파일: tcodui.py 프로젝트: svk/harmless7drl
 def __init__(self, debug = False):
     from harmless7drl import getCfg
     self.width = getCfg( "tcod", "width", 80, int )
     self.height = getCfg( "tcod", "height", 25, int )
     self.fps_limit = 20
     self.font_name = getCfg( "tcod", "font", "fonts/harmless-font-13x23.png" )
     self.font_layout = {
         "tcod":  libtcod.FONT_LAYOUT_TCOD,
         "ascii_incol":  libtcod.FONT_LAYOUT_ASCII_INCOL,
         "ascii_inrow":  libtcod.FONT_LAYOUT_ASCII_INROW,
     }[getCfg( "tcod", "fontlayout", "tcod" )]
     self.title = 'Harmless7DRL'
     self.colours = {
         'white': libtcod.white,
         'black': libtcod.black,
         'red': libtcod.red,
         'blue': libtcod.blue,
         'cyan': libtcod.cyan,
         'green': libtcod.green,
         'magenta': libtcod.magenta,
         'yellow': libtcod.yellow,
     }
     for key in self.colours.keys():
         self.colours["bold-"+key] = self.colours[key]
     for key in self.colours:
         if "bold" not in key:
             c = self.colours[key]
             self.colours[key] = libtcod.Color( c.r & 0x80, c.g & 0x80, c.b & 0x80 )
     from widgets import PrimaryColourRGB, SecondaryColourRGB, BorderColourRGB, HighlightPrimaryColourRGB, HighlightSecondaryColourRGB
     self.colours[ "tcod-primary" ] = libtcod.Color( *PrimaryColourRGB )
     self.colours[ "tcod-secondary" ] = libtcod.Color( *SecondaryColourRGB )
     self.colours[ "tcod-primary-hl" ] = libtcod.Color( *HighlightPrimaryColourRGB )
     self.colours[ "tcod-secondary-hl" ] = libtcod.Color( *HighlightSecondaryColourRGB )
     self.colours[ "tcod-border" ] = libtcod.Color( *BorderColourRGB )
     self.colours["bold-black"] = libtcod.Color( 0x80, 0x80, 0x80 )
     self.keymap = {
         libtcod.KEY_BACKSPACE: 'backspace',
         libtcod.KEY_KP1: 'southwest',
         libtcod.KEY_KP2: 'south',
         libtcod.KEY_KP3: 'southeast',
         libtcod.KEY_KP4: 'west',
         libtcod.KEY_KP6: 'east',
         libtcod.KEY_KP7: 'northwest',
         libtcod.KEY_KP8: 'north',
         libtcod.KEY_KP9: 'northeast',
         libtcod.KEY_END: 'southwest',
         libtcod.KEY_DOWN: 'south',
         libtcod.KEY_PAGEDOWN: 'southeast',
         libtcod.KEY_LEFT: 'west',
         libtcod.KEY_RIGHT: 'east',
         libtcod.KEY_HOME: 'northwest',
         libtcod.KEY_UP: 'north',
         libtcod.KEY_PAGEUP: 'northeast',
         libtcod.KEY_ENTER: '\n',
         libtcod.KEY_ESCAPE: 'escape',
     }
     libtcod.console_set_custom_font( self.font_name,
                                      libtcod.FONT_TYPE_GREYSCALE | self.font_layout)
     libtcod.console_init_root(self.width, self.height, self.title, False)
     libtcod.sys_set_fps( self.fps_limit )
예제 #2
0
파일: widgets.py 프로젝트: svk/harmless7drl
    'east': (1, 0),
    'south': (0, 1),
    'north': (0, -1),
    'northwest': (-1, -1),
    'northeast': (1, -1),
    'southwest': (-1, 1),
    'southeast': (1, 1),
}

def blinkphase(n = 2, phaselength = 0.5):
    import time
    return int( (time.time() % (n * phaselength)) / phaselength )

from harmless7drl import getCfg

prettymenu = getCfg( "tcod", "prettymenu" ) == "yes"
if prettymenu:
    PrimaryColour = 'tcod-primary'
    SecondaryColour = 'tcod-secondary'
    BorderColour = 'tcod-border'
    HighlightPrimaryColour = 'tcod-primary-hl'
    HighlightSecondaryColour = 'tcod-secondary-hl'
else:
    PrimaryColour = 'white'
    SecondaryColour = 'blue'
    BorderColour = SecondaryColour
    HighlightPrimaryColour, HighlightSecondaryColour = SecondaryColour, PrimaryColour

PrimaryColourRGB = 158, 0, 156
BorderColourRGB = 106, 0, 105
SecondaryColourRGB = 182,151,91