def __init__(self, state_stack, message, width=settings.MINIMUM_WIDTH * 0.8, max_height=settings.MINIMUM_HEIGHT * 0.8): self.message = message self._width = width self.max_height = max_height self._state_stack = state_stack margin = style.interface_theme.margin self.text_stack_panel = gui.StackPanelVertical((-1, -1), vertical_space=1) self.text_stack_panel.append( gui.TextBoxWrap(message, (0, 0), colors.GRAY, self.width, max_height)) self.text_stack_panel.append( gui.TextBoxWrap(messenger.PRESS_ENTER_TO_ACCEPT, (0, 0), colors.LIGHT_ORANGE, self.width, max_height)) self.text_stack_panel.update() rect = rectfactory.ratio_of_screen_rect( self.text_stack_panel.width + margin[0] * 2, self.text_stack_panel.height + margin[1] * 2, 0.5, 0.3) self.text_stack_panel.offset = geo.add_2d(rect.top_left, (2, 2)) self.bg_rectangle = gui.StyledRectangle( rect, style.interface_theme.rect_style) self.result = False
def _get_item_menu_composition(item_description_card, menu_stack_panel): inventory_menu_bg = gui.StyledRectangle(rectfactory.right_side_menu_rect(), style.MinimalChestStyle()) inventory_gui = gui.UIElementList([inventory_menu_bg, menu_stack_panel]) inventory_stack_panel = gui.StackPanelHorizontal((0, 0), alignment=gui.StackPanelHorizontal.ALIGN_BOTTOM) inventory_stack_panel.append(item_description_card) inventory_stack_panel.append(inventory_gui) dock = gui.UIDock(rectfactory.full_screen_rect()) dock.bottom_right = inventory_stack_panel return state.UIState(dock)
def item_actions_menu(item, player, state_stack): menu_stack_panel = gui.StackPanelVertical((2, 2), vertical_space=1) heading_stack = gui.StackPanelHorizontal((0, 1), horizontal_space=1) heading_stack.append(gui.SymbolUIElement((0, 0), item.graphic_char)) heading = gui.TextBox(item.description.name, (0, 0), colors.INVENTORY_HEADING) heading_stack.append(heading) menu_stack_panel.append(heading_stack) item_actions_menu = menu.ItemActionsMenu((0, 0), item, player, state_stack, margin=(2, 2)) menu_stack_panel.append(item_actions_menu) inventory_menu_bg = gui.StyledRectangle(rectfactory.right_side_menu_rect(), style.rogue_classic_theme.rect_style) dock = gui.UIDock(rectfactory.full_screen_rect()) ui_elements = [inventory_menu_bg, menu_stack_panel] dock.bottom_right = gui.UIElementList(ui_elements) ui_state = state.UIState(dock) return ui_state
def equipment_menu(player, state_stack): menu_stack_panel = gui.StackPanelVertical((0, 0), margin=(0, 0)) heading = gui.TextBox("Equipment", (2, 1), colors.INVENTORY_HEADING, (2, 2)) menu_stack_panel.append(heading) equipment_menu_bg = gui.StyledRectangle(rectfactory.right_side_menu_rect(), style.rogue_classic_theme.rect_style) item_description_card = gui.new_item_description_card() resulting_menu = menu.EquipmentMenu((0, 0), player, state_stack, selected_payload_callback=(lambda item: item_description_card.set_item(item)), margin=(2, 1)) menu_stack_panel.append(resulting_menu) equipment_gui = gui.UIElementList([equipment_menu_bg, menu_stack_panel]) equipment_stack_panel = gui.StackPanelHorizontal((0, 0), alignment=gui.StackPanelHorizontal.ALIGN_BOTTOM) equipment_stack_panel.append(item_description_card) equipment_stack_panel.append(equipment_gui) dock = gui.UIDock(rectfactory.full_screen_rect()) dock.bottom_right = equipment_stack_panel return state.UIState(dock)
def equipment_slot_menu(player, equipment_slot, state_stack): """ Creates a menu which shows the possible actions that can be taken on a given equipment_slot. """ menu_stack_panel = gui.StackPanelVertical((0, 0), margin=(0, 0)) heading = gui.TextBox("Change " + equipment_slot.name, (2, 1), colors.INVENTORY_HEADING, (2, 2)) menu_stack_panel.append(heading) item_description_card = gui.new_item_description_card() resulting_menu = menu.EquipSlotMenu((0, 0), player, equipment_slot, state_stack, (lambda item: item_description_card.set_item(item)), (2, 1)) menu_stack_panel.append(resulting_menu) equipment_menu_bg = gui.StyledRectangle(rectfactory.right_side_menu_rect(), style.rogue_classic_theme.rect_style) equipment_slot_gui = gui.UIElementList([equipment_menu_bg, menu_stack_panel]) equipment_slot_stack_panel = gui.StackPanelHorizontal((0, 0), alignment=gui.StackPanelHorizontal.ALIGN_BOTTOM) equipment_slot_stack_panel.append(item_description_card) equipment_slot_stack_panel.append(equipment_slot_gui) dock = gui.UIDock(rectfactory.full_screen_rect()) dock.bottom_right = equipment_slot_stack_panel return state.UIState(dock)
def get_menu_background(rectangle, rect_style=style.menu_theme.rect_style, h_split=[], v_split=[]): return gui.StyledRectangle(rectangle, rect_style, h_split=h_split, v_split=v_split)