Ejemplo n.º 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])
Ejemplo n.º 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])
Ejemplo n.º 3
0
 def __init__(self, root_console_width, root_console_height, start_x,
              frame_height, frame_manager):
     #TODO make and load .XP file with background, and arrange it to have an autoextending background
     Frame.__init__(self, root_console_width, root_console_height,
                    root_console_width - start_x, frame_height,
                    frame_manager)
     self.start_x = start_x
Ejemplo n.º 4
0
 def __init__(self, root_console_width, root_console_height, world_x_start,
              world_y_start, frame_manager):
     Frame.__init__(self, root_console_width, root_console_height,
                    root_console_width - world_x_start,
                    root_console_height - world_y_start, frame_manager)
     self.entity_manager = frame_manager.parent_menu.entity_manager
     self.world_x_start = world_x_start
     self.world_y_start = world_y_start
Ejemplo n.º 5
0
	def __init__(self, root_console_width, root_console_height, world_x_start, world_y_start, frame_manager):
		#TODO manage offset of code
		Frame.__init__(self, root_console_width, root_console_height, root_console_width - world_x_start, root_console_height - world_y_start, frame_manager)
		self.world_x_start = world_x_start
		self.world_y_start = world_y_start
		self.entity_manager = frame_manager.parent_menu.entity_manager
		self.actions = []
		libtcod.console_set_default_background(self.console, libtcod.Color(255, 0, 255))
		libtcod.console_set_key_color(self.console, libtcod.Color(255, 0, 255))
Ejemplo n.º 6
0
 def __init__(self, root_console_width, root_console_height, world_x_start,
              world_y_start, frame_manager):
     #TODO manage offset of code
     Frame.__init__(self, root_console_width, root_console_height,
                    root_console_width - world_x_start,
                    root_console_height - world_y_start, frame_manager)
     self.world_x_start = world_x_start
     self.world_y_start = world_y_start
     self.entity_manager = frame_manager.parent_menu.entity_manager
     self.actions = []
     libtcod.console_set_default_background(self.console,
                                            libtcod.Color(255, 0, 255))
     libtcod.console_set_key_color(self.console, libtcod.Color(255, 0, 255))
Ejemplo n.º 7
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]
Ejemplo n.º 8
0
	def __init__(self, root_console_width, root_console_height, terminal_width, terminal_height, frame_manager):
		# constants and initialization
		self.prompt_string = "X:\\>"
		self.input_command = ""
		self.blinking_cursor = "_"
		self.cursor_blink_delay = 500
		self.cursor_timer = 0
		self.console_command_history = []
		self.console_max_history_length = terminal_height - 2
		self.input_enabled = True

		Frame.__init__(self, root_console_width, root_console_height, terminal_width, terminal_height, frame_manager)
		#-1 to account for border tile
		self.max_command_size = self.width - len(self.prompt_string) - 1 

		libtcod.console_set_key_color(self.console, libtcod.Color(255, 0, 255))
Ejemplo n.º 9
0
    def __init__(self, root_console_width, root_console_height, terminal_width,
                 terminal_height, frame_manager):
        # constants and initialization
        self.prompt_string = "X:\\>"
        self.input_command = ""
        self.blinking_cursor = "_"
        self.cursor_blink_delay = 500
        self.cursor_timer = 0
        self.console_command_history = []
        self.console_max_history_length = terminal_height - 2
        self.input_enabled = True

        Frame.__init__(self, root_console_width, root_console_height,
                       terminal_width, terminal_height, frame_manager)
        #-1 to account for border tile
        self.max_command_size = self.width - len(self.prompt_string) - 1

        libtcod.console_set_key_color(self.console, libtcod.Color(255, 0, 255))
Ejemplo n.º 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]
Ejemplo n.º 11
0
 def __init__(self, root_console_width, root_console_height, start_x, frame_height, frame_manager):
     # TODO make and load .XP file with background, and arrange it to have an autoextending background
     Frame.__init__(
         self, root_console_width, root_console_height, root_console_width - start_x, frame_height, frame_manager
     )
     self.start_x = start_x
Ejemplo n.º 12
0
	def __init__(self, root_console_width, root_console_height, world_x_start, world_y_start, frame_manager):
		Frame.__init__(self, root_console_width, root_console_height, root_console_width - world_x_start, root_console_height - world_y_start, frame_manager)
		self.entity_manager = frame_manager.parent_menu.entity_manager
		self.world_x_start = world_x_start
		self.world_y_start = world_y_start
Ejemplo n.º 13
0
from ui.frame import Frame
from ui.menu import Menu

frame = Frame()  # init frame

frame.clear_window()  # clear console/terminal window

print(frame)  # prints frame (logo and horizontal line)

frame.boot_system()  # boot system. Progress bar from 0-100%

menu = Menu()  # init menu

menu.authenticate()  # authenticate

menu.init_menu()  # after authentication, show main menu
Ejemplo n.º 14
0
class NoccoList:
    def __init__(self):
        self.nocco_key = NoccoKey()
        self.color = Color()
        self.frame = Frame()

    def print_alternatives(self, question, alternatives, alternative_index):
        print("[{}] {}: {}".format(
            self.color.return_colored("!", "yellow"), question,
            self.color.return_colored(alternatives[alternative_index],
                                      "bold")))
        for i, alternative in enumerate(alternatives):
            if i == alternative_index:
                if alternative == alternatives[-1]:
                    print()
                    print("   {}".format(
                        self.color.return_colored("> " + alternative, "red")))
                else:
                    print("   {}".format(
                        self.color.return_colored("> " + alternative, "cyan")))
            else:
                if alternative == alternatives[-1]:
                    print()
                print("     {}".format(alternative))

    def choose_one(self,
                   question,
                   alternatives,
                   answer_key,
                   get_chosen_index=False):
        """ from a list of alternatives, let user choose one of them """

        alternative_index = 0
        answer_from_user = ""
        #print the alternatives
        self.print_alternatives(question, alternatives, alternative_index)
        while not answer_from_user:  # run until the user chooses an alternative
            key = self.nocco_key.getKey()
            if key == "up":
                if alternative_index != 0:
                    alternative_index -= 1
            elif key == "down":
                if alternative_index != len(alternatives) - 1:
                    alternative_index += 1
            elif key == "right":
                if get_chosen_index:
                    answer_from_user = {
                        answer_key: alternatives[alternative_index],
                        "index": alternative_index
                    }
                else:
                    answer_from_user = {
                        answer_key: alternatives[alternative_index]
                    }
            elif key == "left":
                pass
            else:
                if os.name == "nt":  # for Windows
                    key = key.decode("utf-8")
                if key not in string.digits and key not in string.ascii_letters and key not in string.punctuation:
                    if get_chosen_index:
                        answer_from_user = {
                            answer_key: alternatives[alternative_index],
                            "index": alternative_index
                        }
                    else:
                        answer_from_user = {
                            answer_key: alternatives[alternative_index]
                        }
            self.frame.delete_last_lines(len(alternatives) + 2)
            self.print_alternatives(question, alternatives, alternative_index)

        # return answer
        return answer_from_user

    def single_list(self, alternative):
        """ 
            Only one alternative. Useful when for instance only giving 
            "Go back" alternative to the user 
        """
        print()
        print(" {}".format(self.color.return_colored("> " + alternative,
                                                     "red")))

        pressed = False

        while not pressed:
            key = self.nocco_key.getKey()  # get key_press from user
            enter_key = string.digits + string.ascii_letters + string.punctuation
            if key not in enter_key and key != "down" and key != "up":
                pressed = True
            self.frame.delete_last_lines(1)
            print(" {}".format(
                self.color.return_colored("> " + alternative, "red")))
Ejemplo n.º 15
0
 def __init__(self):
     self.nocco_key = NoccoKey()
     self.color = Color()
     self.frame = Frame()