Exemple #1
0
    def draw(self):

        libtcod.console_clear(self.console)
        xp_loader.load_layer_to_console(self.console,
                                        self.bg_data['layer_data'][0])

        player_libraries = self.entity_manager.get_entity_by_id(
            self.entity_manager.player_id).get_attribute(
                AttributeTag.Libraries).data['value']

        for lib in range(4):
            #+1 here because range will go up to but not including the final screen tile needed
            for x in range(self.library_line_extent[0] -
                           self.library_start_xy[0] + 1):
                libtcod.console_put_char_ex(self.console,
                                            self.library_start_xy[0] + x,
                                            self.library_start_xy[1] + lib,
                                            self.line_char, self.line_fg,
                                            self.line_bg)
            libname_xy = Vec2d(self.library_start_xy[0],
                               self.library_start_xy[1] + lib)
            #TODO: move to config strings
            libname = 'lib_missing'
            print_color = self.line_fg

            if len(player_libraries) > lib:
                print_color = self.libname_fg
                libname = player_libraries[lib].name

            libtcod.console_set_default_foreground(self.console, print_color)
            libtcod.console_print(self.console, libname_xy[0], libname_xy[1],
                                  libname)

        libtcod.console_blit(self.console, 0, 0, self.width, self.height, 0, 0,
                             0)
Exemple #2
0
	def __init__(self, root_console_width, root_console_height, frame_manager):
		self.entity_manager = frame_manager.parent_menu.entity_manager

		# load xp for bg
		console_bg_xp = gzip.open('assets\\ui\\ui_frame_libraries_bg.xp')
		self.bg_data = xp_loader.load_xp_string(console_bg_xp.read())

		Frame.__init__(self, root_console_width, root_console_height, self.bg_data['width'], self.bg_data['height'], frame_manager)

		library_start_xy = xp_loader.get_position_key_xy(self.bg_data['layer_data'][1], xp_loader.poskey_color_red)

		self.library_start_xy = Vec2d(library_start_xy[0], library_start_xy[1])
		self.library_line_extent = xp_loader.get_position_key_xy(self.bg_data['layer_data'][1], xp_loader.poskey_color_green)

		#TODO put these in config somewhere
		self.line_char = chr(196)
		self.line_bg = libtcod.Color(2, 22, 12)
		self.line_fg = libtcod.Color(6, 130, 60)
		self.libname_fg = libtcod.Color(102, 255, 178)

		libtcod.console_set_default_background(self.console,self.line_bg)
		libtcod.console_set_default_foreground(self.console,self.libname_fg)
		libtcod.console_set_alignment(self.console, libtcod.LEFT)

		xp_loader.load_layer_to_console(self.console, self.bg_data['layer_data'][0])
Exemple #3
0
    def __init__(self, root_console_width, root_console_height, frame_manager):
        self.entity_manager = frame_manager.parent_menu.entity_manager

        # load xp for bg
        console_bg_xp = gzip.open('assets\\ui\\ui_frame_libraries_bg.xp')
        self.bg_data = xp_loader.load_xp_string(console_bg_xp.read())

        Frame.__init__(self, root_console_width, root_console_height,
                       self.bg_data['width'], self.bg_data['height'],
                       frame_manager)

        library_start_xy = xp_loader.get_position_key_xy(
            self.bg_data['layer_data'][1], xp_loader.poskey_color_red)

        self.library_start_xy = Vec2d(library_start_xy[0], library_start_xy[1])
        self.library_line_extent = xp_loader.get_position_key_xy(
            self.bg_data['layer_data'][1], xp_loader.poskey_color_green)

        #TODO put these in config somewhere
        self.line_char = chr(196)
        self.line_bg = libtcod.Color(2, 22, 12)
        self.line_fg = libtcod.Color(6, 130, 60)
        self.libname_fg = libtcod.Color(102, 255, 178)

        libtcod.console_set_default_background(self.console, self.line_bg)
        libtcod.console_set_default_foreground(self.console, self.libname_fg)
        libtcod.console_set_alignment(self.console, libtcod.LEFT)

        xp_loader.load_layer_to_console(self.console,
                                        self.bg_data['layer_data'][0])
Exemple #4
0
    def draw(self):

        libtcod.console_clear(self.console)
        xp_loader.load_layer_to_console(self.console,
                                        self.bg_data['layer_data'][0])

        libtcod.console_set_alignment(self.console, libtcod.LEFT)
        libtcod.console_print(
            self.console, self.remaining_actions_display_position[0],
            self.remaining_actions_display_position[1],
            str(self.max_actions - self.current_action_count))
        libtcod.console_print(self.console,
                              self.max_actions_display_position[0],
                              self.max_actions_display_position[1],
                              str(self.max_actions))

        for x in range(self.queued_actions_bar_width + 1):
            if x <= self.highlighted_tile_count and self.highlighted_tile_count > 0:
                libtcod.console_put_char(
                    self.console, self.queued_actions_display_start[0] + x,
                    self.queued_actions_display_start[1], chr(178))
            else:
                libtcod.console_put_char(
                    self.console, self.queued_actions_display_start[0] + x,
                    self.queued_actions_display_start[1], chr(176))

        libtcod.console_blit(self.console, 0, 0, self.width, self.height, 0, 0,
                             self.y_blit_offset)
Exemple #5
0
    def __init__(self, root_console_width, root_console_height, start_y,
                 frame_manager):
        # constants and initialization
        self.current_action_count = 0
        self.max_actions = 0
        self.highlighted_tile_count = 0
        self.y_blit_offset = start_y
        self.entity_manager = frame_manager.parent_menu.entity_manager

        # load xp for bg
        console_bg_xp = gzip.open('assets\\ui\\ui_frame_actionclock_bg.xp')
        self.bg_data = xp_loader.load_xp_string(console_bg_xp.read())

        Frame.__init__(self, root_console_width, root_console_height,
                       self.bg_data['width'], self.bg_data['height'],
                       frame_manager)

        xp_loader.load_layer_to_console(self.console,
                                        self.bg_data['layer_data'][0])

        queued_actions_display_start = None
        queued_actions_display_end = None

        #scrape the xp file for position markers for action clock bar and text for actions remaining
        x = 0
        for row in self.bg_data['layer_data'][1]['cells']:
            y = 0
            for cell in row:
                if cell['fore_r'] == 255 and cell['fore_g'] == 0 and cell[
                        'fore_b'] == 0:
                    self.remaining_actions_display_position = Vec2d(x, y)
                if cell['fore_r'] == 0 and cell['fore_g'] == 0 and cell[
                        'fore_b'] == 255:
                    self.max_actions_display_position = Vec2d(x, y)
                elif cell['fore_r'] == 255 and cell['fore_g'] == 255 and cell[
                        'fore_b'] == 0:
                    queued_actions_display_start = Vec2d(x, y)
                elif cell['fore_r'] == 0 and cell['fore_g'] == 255 and cell[
                        'fore_b'] == 0:
                    queued_actions_display_end = Vec2d(x, y)
                elif cell['fore_r'] == 0 and cell['fore_g'] == 255 and cell[
                        'fore_b'] == 0:
                    queued_actions_display_end = Vec2d(x, y)
                y += 1
            x += 1

        self.queued_actions_display_start = queued_actions_display_start
        self.queued_actions_bar_width = queued_actions_display_end[
            0] - queued_actions_display_start[0]
Exemple #6
0
def foregroundLayer(screen_width, screen_height):
    xp_file = gzip.open('Title.xp')
    raw_data = xp_file.read()
    xp_file.close()

    xp_data = xp_loader.load_xp_string(raw_data)

    console_width = xp_data['width']
    console_height = xp_data['height']

    layer_0_console = libtcod.console_new(xp_data['layer_data'][0]['width'], xp_data['layer_data'][0]['height'])

    xp_loader.load_layer_to_console(layer_0_console, xp_data['layer_data'][0])

    libtcod.console_blit(layer_0_console, -10, 16, console_width, console_height, 0, 0, 0)
Exemple #7
0
	def draw(self):

		libtcod.console_clear(self.console)
		xp_loader.load_layer_to_console(self.console, self.bg_data['layer_data'][0])

		libtcod.console_set_alignment(self.console, libtcod.LEFT)
		libtcod.console_print(self.console, self.remaining_actions_display_position[0], self.remaining_actions_display_position[1], str(self.max_actions - self.current_action_count))
		libtcod.console_print(self.console, self.max_actions_display_position[0], self.max_actions_display_position[1], str(self.max_actions))

		for x in range(self.queued_actions_bar_width + 1):
			if x <= self.highlighted_tile_count and self.highlighted_tile_count > 0:
				libtcod.console_put_char(self.console, self.queued_actions_display_start[0] + x, self.queued_actions_display_start[1], chr(178))
			else:
				libtcod.console_put_char(self.console, self.queued_actions_display_start[0] + x, self.queued_actions_display_start[1], chr(176))

		libtcod.console_blit(self.console, 0, 0, self.width, self.height, 0, 0, self.y_blit_offset)
Exemple #8
0
	def __init__(self, root_console_width, root_console_height, start_y, frame_manager):
		# constants and initialization
		self.current_action_count = 0
		self.max_actions = 0
		self.highlighted_tile_count = 0
		self.y_blit_offset = start_y
		self.entity_manager = frame_manager.parent_menu.entity_manager

		# load xp for bg
		console_bg_xp = gzip.open('assets\\ui\\ui_frame_actionclock_bg.xp')
		self.bg_data = xp_loader.load_xp_string(console_bg_xp.read())

		Frame.__init__(self, root_console_width, root_console_height, self.bg_data['width'], self.bg_data['height'], frame_manager)


		xp_loader.load_layer_to_console(self.console, self.bg_data['layer_data'][0])

		queued_actions_display_start = None
		queued_actions_display_end = None

		#scrape the xp file for position markers for action clock bar and text for actions remaining
		x = 0
		for row in self.bg_data['layer_data'][1]['cells']:
			y = 0
			for cell in row:
				if cell['fore_r'] == 255 and cell['fore_g'] == 0 and cell['fore_b'] == 0:
					self.remaining_actions_display_position = Vec2d(x, y)
				if cell['fore_r'] == 0 and cell['fore_g'] == 0 and cell['fore_b'] == 255:
					self.max_actions_display_position = Vec2d(x, y)
				elif cell['fore_r'] == 255 and cell['fore_g'] == 255 and cell['fore_b'] == 0:
					queued_actions_display_start = Vec2d(x, y)
				elif cell['fore_r'] == 0 and cell['fore_g'] == 255 and cell['fore_b'] == 0:
					queued_actions_display_end = Vec2d(x, y)
				elif cell['fore_r'] == 0 and cell['fore_g'] == 255 and cell['fore_b'] == 0:
					queued_actions_display_end = Vec2d(x, y)
				y += 1
			x += 1

		self.queued_actions_display_start = queued_actions_display_start
		self.queued_actions_bar_width = queued_actions_display_end[0] - queued_actions_display_start[0]
Exemple #9
0
	def draw(self):

		libtcod.console_clear(self.console)
		xp_loader.load_layer_to_console(self.console, self.bg_data['layer_data'][0])

		player_libraries = self.entity_manager.get_entity_by_id(self.entity_manager.player_id).get_attribute(AttributeTag.Libraries).data['value']

		for lib in range(4):
			#+1 here because range will go up to but not including the final screen tile needed
			for x in range(self.library_line_extent[0] - self.library_start_xy[0] + 1):
				libtcod.console_put_char_ex(self.console, self.library_start_xy[0] + x, self.library_start_xy[1] + lib, self.line_char, self.line_fg, self.line_bg)
			libname_xy = Vec2d(self.library_start_xy[0], self.library_start_xy[1] + lib)
			#TODO: move to config strings
			libname = 'lib_missing'
			print_color = self.line_fg

			if len(player_libraries) > lib:
				print_color = self.libname_fg
				libname = player_libraries[lib].name

			libtcod.console_set_default_foreground(self.console, print_color)
			libtcod.console_print(self.console, libname_xy[0], libname_xy[1], libname)

		libtcod.console_blit(self.console, 0, 0, self.width, self.height, 0, 0, 0)
Exemple #10
0
    'cp437_10x10.png',
    libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW)
libtcod.console_init_root(screen_width, screen_height, 'REXPaint Import Demo',
                          False)
libtcod.sys_set_fps(limit_fps)

####################
# Loads the layer data to offscreen consoles. You can load a layer to the main console by passing in 0 instead of a console
####################

layer_0_console = libtcod.console_new(xp_data['layer_data'][0]['width'],
                                      xp_data['layer_data'][0]['height'])
layer_1_console = libtcod.console_new(xp_data['layer_data'][1]['width'],
                                      xp_data['layer_data'][1]['height'])

xp_loader.load_layer_to_console(layer_0_console, xp_data['layer_data'][0])
xp_loader.load_layer_to_console(layer_1_console, xp_data['layer_data'][1])

####################
# Sets the overlay layer transparency key to REXPaint's background transparency key. For completeness purposes, load_layer_to_console always writes every cell to the console -
# REXPaint format note - layer 0 background is written out as 0,0,0. If you're making .xp files for UI overlays or whatever, be absolutely sure to
####################

libtcod.console_set_key_color(
    layer_1_console,
    libtcod.Color(xp_loader.transparent_cell_back_r,
                  xp_loader.transparent_cell_back_g,
                  xp_loader.transparent_cell_back_b))

####################
# libtcod piping to actually put the console layers on screen. This will probably change quite a bit for your actual usage of libtcod
Exemple #11
0
# The default libtcod font sheet format is missing quite a few codepage 437 characters - if you want to use REXPaint, you'll need to find or make make a sprite sheet with those characters
# Currently using the 10x10 default REXPaint sheet courtesy of Kyzrati
####################

libtcod.console_set_custom_font("cp437_10x10.png", libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW)
libtcod.console_init_root(screen_width, screen_height, "REXPaint Import Demo", False)
libtcod.sys_set_fps(limit_fps)

####################
# Loads the layer data to offscreen consoles. You can load a layer to the main console by passing in 0 instead of a console
####################

layer_0_console = libtcod.console_new(xp_data["layer_data"][0]["width"], xp_data["layer_data"][0]["height"])
layer_1_console = libtcod.console_new(xp_data["layer_data"][1]["width"], xp_data["layer_data"][1]["height"])

xp_loader.load_layer_to_console(layer_0_console, xp_data["layer_data"][0])
xp_loader.load_layer_to_console(layer_1_console, xp_data["layer_data"][1])

####################
# Sets the overlay layer transparency key to REXPaint's background transparency key. For completeness purposes, load_layer_to_console always writes every cell to the console -
# REXPaint format note - layer 0 background is written out as 0,0,0. If you're making .xp files for UI overlays or whatever, be absolutely sure to
####################

libtcod.console_set_key_color(
    layer_1_console,
    libtcod.Color(
        xp_loader.transparent_cell_back_r, xp_loader.transparent_cell_back_g, xp_loader.transparent_cell_back_b
    ),
)