Exemple #1
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 #2
0
    def __init__(self, engine, x, y, width, height):
        super().__init__(engine, x, y, width, height)

        self.animated_tiles = list()
        for i in range(0, 3):
            if os.path.isfile(completion_panel_xp_file + str(i + 1) + '.xp'):
                xp_file = gzip.open(completion_panel_xp_file + str(i + 1) +
                                    '.xp')
                raw_data = xp_file.read()
                xp_file.close()

                xp_data = xp_loader.load_xp_string(raw_data)

                self.animated_tiles.append(
                    np.full((self.width, self.height),
                            fill_value=tile_types.blank,
                            order="F"))

                for h in range(0, self.height):
                    for w in range(0, self.width):
                        self.animated_tiles[i][w, h]['graphic'] = xp_data[
                            'layer_data'][0]['cells'][w][h]

        self.ui = CompleteUI(self, x, y, self.animated_tiles[0]["graphic"])
        self.selected_tiles = 0
        self.frame_length = 30
        self.time_on_frame = 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 __init__(self, engine, x, y, width, height):
        super().__init__(engine, x, y, width, height)

        xp_file = gzip.open(remote_xp_file)
        raw_data = xp_file.read()
        xp_file.close()

        xp_data = xp_loader.load_xp_string(raw_data)

        self.tiles = np.full((self.width, self.height),
                             fill_value=tile_types.blank,
                             order="F")

        for h in range(0, self.height):
            for w in range(0, self.width):
                self.tiles[
                    w, h]['graphic'] = xp_data['layer_data'][0]['cells'][w][h]

        self.first_digit_pos = [10, 5]
        self.error_message_pos = [4, 21]
        self.num_digits = 0
        self.selected_number = [0, 0, 0]

        self.ui = RemoteUI(self, x, y, self.tiles["graphic"])
        self.remote_error = RemoteErrors.NONE
Exemple #5
0
    def __init__(self, file: str):
        xp_file = gzip.open(get_app_path() + file)
        raw_data = xp_file.read()
        xp_file.close()

        self.tiles = np.full((40, 24), fill_value=tile_types.blank, order="F")

        xp_data = xp_loader.load_xp_string(raw_data)
        for h in range(0, 40):
            for w in range(0, 24):
                self.tiles[
                    h, w]['graphic'] = xp_data['layer_data'][0]['cells'][h][w]
Exemple #6
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 #7
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 #8
0
    def __init__(self, engine, x, y, width, height, image):
        super().__init__(engine, x, y, width, height)

        xp_file = gzip.open(image)
        raw_data = xp_file.read()
        xp_file.close()

        xp_data = xp_loader.load_xp_string(raw_data)

        self.tiles = np.full((self.width, self.height),
                             fill_value=tile_types.blank,
                             order="F")

        for h in range(0, self.height):
            for w in range(0, self.width):
                self.tiles[
                    w, h]['graphic'] = xp_data['layer_data'][0]['cells'][w][h]

        self.invisible = True
Exemple #9
0
    def __init__(self, engine, x,y,width, height):
        super().__init__(engine, x, y, width, height)

        xp_file = gzip.open(answer_panel_xp_file)
        raw_data = xp_file.read()
        xp_file.close()

        xp_data = xp_loader.load_xp_string(raw_data)

        self.tiles = np.full((self.width, self.height), fill_value=tile_types.blank, order="F")

        for h in range(0,self.height):
            for w in range(0,self.width):
                self.tiles[w,h]['graphic']=  xp_data['layer_data'][0]['cells'][w][h]

        self.correct_colour = (0,255,0)

        self.ui = AnswersUI(self, x,y, self.tiles["graphic"], self.correct_colour)
        self.all_answers_correct = False
Exemple #10
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 #11
0
import tcod as libtcod
import xp_loader
import gzip

####################
# load in and read the .xp file - this is done out-of-library in case you have some other means to produce an uncompressed .xp data string
####################

xp_file = gzip.open('xptest.xp')
raw_data = xp_file.read()
xp_file.close()

xp_data = xp_loader.load_xp_string(raw_data)

screen_width = xp_data['width']
screen_height = xp_data['height']
limit_fps = 20

####################
# 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)

####################
Exemple #12
0
import libtcodpy as libtcod
import xp_loader
import gzip

####################
# load in and read the .xp file - this is done out-of-library in case you have some other means to produce an uncompressed .xp data string
####################

xp_file = gzip.open("xptest.xp")
raw_data = xp_file.read()
xp_file.close()

xp_data = xp_loader.load_xp_string(raw_data)

screen_width = xp_data["width"]
screen_height = xp_data["height"]
limit_fps = 20

####################
# 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
####################