예제 #1
0
    def __init__(self,
                 autoHide=None,
                 modal=True,
                 centered=False,
                 caption=None,
                 minimize=None,
                 maximize=None,
                 close=None,
                 captionStyle=None,
                 **kwargs):
        # Init section
        DialogBox.__init__(self, autoHide, modal, centered, **kwargs)
        self._dialogListeners = []
        self._minimized = None
        self._maximized = None

        # Arguments section
        if isinstance(caption, basestring):
            self.caption.setText(caption)
        elif caption is not None:
            self.caption = caption
            self.caption.addMouseListener(self)
        if captionStyle is not None:
            self.caption.setStyleName(captionStyle)
        else:
            self.caption.addStyleName('WindowCaption')
        self.setControls(minimize, maximize, close)
예제 #2
0
파일: GUI.py 프로젝트: Maor2871/CodeDup
    def create_dialog_box(self):
        """
            The function creates a dialog box at the bottom of the application.
        """

        self.dialog_box = DialogBox(self)
        self.sizer.Add(self.dialog_box, pos=(97, 0), span=(1, 193), flag=wx.EXPAND)
        self.dialog_box.update_text("Hello, I'm here to notify you about the current status of the system.")
예제 #3
0
    def __init__(self):
        super().__init__()
        self.time = 0
        self.last_click = -1
        self.last_start = -1

        self.player = Player()
        self.enemy = Enemy()
        self.dialog_box = DialogBox()
        self.background = load_texture(MAIN_PIC)
        self.sprite_manager = SpriteManager()
        self.set_buttons()
        self.sprite_manager.setup()
        self.enemy.setup()
    def __init__(self, autoHide=None, modal=True, centered=False,
                 caption=None, minimize=None, maximize=None, close=None,
                 captionStyle=None,
                 **kwargs):
        # Init section
        DialogBox.__init__(self, autoHide, modal, centered, **kwargs)
        self._dialogListeners = []
        self._minimized = None
        self._maximized = None

        # Arguments section
        if isinstance(caption, basestring):
            self.caption.setText(caption)
        elif caption is not None:
            self.caption = caption
            self.caption.addMouseListener(self)
        if captionStyle is not None:
            self.caption.setStyleName(captionStyle)
        else:
            self.caption.addStyleName('WindowCaption')
        self.setControls(minimize, maximize, close)
예제 #5
0
def show_cut_scene_1():

    pygame.event.clear()
    screen.blit(cs1_image, cs1_rect)
    pygame.display.flip()

    showing_dialog_box = False
    dialogBox = DialogBox()

    waiting = True
    while waiting:
        clock.tick(FPS)

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_t:
                    if showing_dialog_box == False:
                        all_sprites.add(dialogBox)
                        showing_dialog_box = True
                    else:
                        dialogBox.kill(
                        )  #REMOVES SPRITE FROM ALL SPRITE GROUPS
                        dialogBox.set_message_count(0)
                        showing_dialog_box = False
                if event.key == pygame.K_s:
                    print("pressed key")
                    waiting = False
    def __importKeys(self, path_p):
        keys = []
        path_f = ''
        with open(path_p, 'r') as f:
            for line in f:
                for letter in line:
                    path_f = path_f + letter
                    if letter == '\\':
                        path_f = path_f + '\\'

        try:
            with open(path_f, 'r') as g:
                for line in g:
                    line = line[:-1]
                    keys.append(line)
            return keys
        except IOError:
            # not elegant of signalising the error
            dlg = wx.App()
            DialogBox()
            dlg.MainLoop()
예제 #7
0
screen = pygame.display.set_mode((600, 400),
                                 pygame.RESIZABLE)

menu1 = Menu((0, 0), "Menu", 
             ["New game", "Load", "Save", "Quit"], font, 
             100)

menu2 = Menu((menu1.dim[0]+1, 0), "Menu", 
             ["New game", "Load", "Save", "Help", "Quit"], font, 
             100)

button1 = Button((100, 100), "OK", font, 70)
button2 = Button((200, 100), "Quit", font, 70)

dialog_box = DialogBox((100, 150), "Useless text that could be in a " +
                       "dialog box.",["OK", "Cancel", "Quit"], font, 300)

text_lines = TextLines((300, 300), 
                       "This is a pretty long line that won't fit in 200 px. "+
                       "Hence, it's going to be split.",
                       font, 
                       200,
                       0)

radio_buttons = RadioButtonList((450, 50), ["English",
                                            "French",
                                            "Spanish"],
                                font)

menu1.activate()
menu2.activate()
예제 #8
0
 def onMouseUp(self, sender, x, y):
     if self.dragStartX != x or self.dragStartY != y:
         self.onActivate()
     DialogBox.endDragging(self)
예제 #9
0
파일: GUI.py 프로젝트: Maor2871/CodeDup
class Frame(wx.Frame):
    """
        This class represents the main window of the application.
    """

    def __init__(self, parent, id_, title, general_):

        super(Frame, self).__init__(parent=parent, id=id_, title=title, pos=(0, 0))

        self.Maximize()

        # With this parameter the GUI can communicate with the client.
        self.general = general_

        self.Bind(wx.EVT_CLOSE, self.on_quit)

        # The main panel of the frame.
        self.sizer = wx.GridBagSizer(0, 0)

        # Set the size of each cell in the sizer.
        self.sizer.SetEmptyCellSize((10, 10))

        # The Main menu bar, where the file, windows etc. menus are located.
        self.menu_bar = None

        # The file menu, located inside the menu bar.
        self.file_menu = None

        # The windows menu, located inside the menu bar.
        self.windows_menu = None

        # The quit label inside the file menu.
        self.quit_label = None

        # Set up the panel of the first tab: Request window.
        self.request_window = None

        # Set up the panel of the second tab: Monitor window.
        self.monitor_window = None

        # Set up the panel of the third tab: Preferences window.
        self.preferences_window = None

        # The main main windows and notebook panel.
        self.notebook_panel = None

        # The notebook of the main windows.
        self.notebook = None

        # The dialog box of the system.
        self.dialog_box = None

        # True if the gui has closed.
        self.quit = False

        # Build the user interface.
        self.init_ui()

        self.Layout()

        self.Refresh()

        self.Show()

    def init_ui(self):
        """
            The function sets the user interface.
        """

        self.create_menu_bar()

        self.create_dialog_box()

        self.create_main_windows_notebook()

        self.SetSizer(self.sizer)

    def create_menu_bar(self):
        """
            The function creates the menu bar.
        """

        # Create the menu bar.
        self.menu_bar = wx.MenuBar()

        # Create the file menu and insert it into the menu bar.
        self.create_file_menu()

        # Create the windows menu and insert it into the menu bar.
        self.create_windows_menu()

        # Set up the menu bar.
        self.SetMenuBar(self.menu_bar)

    def create_main_windows_notebook(self):
        """
            The function creates the main windows tabs and the main windows themselves..
        """

        # Create the notebook and main windows panel.
        self.notebook_panel = wx.Panel(self)

        # Set up the notebook of the main windows.
        self.notebook = NoteBook(self.notebook_panel, self)

        sizer = wx.BoxSizer(wx.HORIZONTAL)

        sizer.Add(self.notebook, 1, wx.EXPAND)

        self.notebook_panel.SetSizer(sizer)

        self.sizer.Add(self.notebook_panel, pos=(0, 0), span=(97, 193), flag=wx.EXPAND)

    def create_dialog_box(self):
        """
            The function creates a dialog box at the bottom of the application.
        """

        self.dialog_box = DialogBox(self)
        self.sizer.Add(self.dialog_box, pos=(97, 0), span=(1, 193), flag=wx.EXPAND)
        self.dialog_box.update_text("Hello, I'm here to notify you about the current status of the system.")

    def create_file_menu(self):
        """
            The function creates the file menu and inserts it into the menu bar.
        """

        # Create the file menu.
        self.file_menu = wx.Menu()

        # Create the quit label to the file menu.
        self.quit_label = self.file_menu.Append(wx.ID_EXIT, 'Quit', 'Quit application')

        # Insert the file menu to the menu bar.
        self.menu_bar.Append(self.file_menu, '&file')

        # When the quit label is being pressed, call on_quit.
        self.Bind(wx.EVT_MENU, self.on_quit, self.quit_label)

    def create_windows_menu(self):
        """
            The function creates the windows menu and inserts it into the menu bar.
        """

        # Create the windows menu.
        self.windows_menu = wx.Menu()

        # Insert the Request floating window.
        self.windows_menu.Append(wx.ID_ANY, "&Request")

        # Insert the Monitor floating window.
        self.windows_menu.Append(wx.ID_ANY, "&Monitor")

        # Insert the Preferences floating window.
        self.windows_menu.Append(wx.ID_ANY, "&Preferences")

        self.menu_bar.Append(self.windows_menu, "&Windows")

        self.Layout()

        self.Show()

    def on_quit(self, e):
        """
            Close the application.
        """

        self.quit = True
        self.general.gui_closed = True
        self.general.shutdown = True
        self.Destroy()
예제 #10
0
#!/usr/bin/env python3
#This is just to get us started, before we get structure worked out.
import sge
#This implementation detail frustrates programmers from low-level languages...
from Game import Game
from Menu import Menu
from DialogBox import DialogBox

#defaults
game_width	=  1280
game_height	=  720

Game(width= game_width, height= game_height)
font = sge.gfx.Font("assets/Fonts/PressStart2P.ttf",size=24)
b = DialogBox(font=font, text="hello world", char_sprite=None)
b.render()
objects = [b]
#Move this to the menu class
background = sge.gfx.Background([], sge.gfx.Color("white"))



sge.game.start_room = Menu(background=background, objects=objects)

if __name__ == '__main__':
    sge.game.start()
예제 #11
0
class MainView(View):

    def __init__(self):
        super().__init__()
        self.time = 0
        self.last_click = -1
        self.last_start = -1

        self.player = Player()
        self.enemy = Enemy()
        self.dialog_box = DialogBox()
        self.background = load_texture(MAIN_PIC)
        self.sprite_manager = SpriteManager()
        self.set_buttons()
        self.sprite_manager.setup()
        self.enemy.setup()

    def set_buttons(self):
        for i in range(SHIPS_COUNT):
            button = Button(BUTTON_X, BUTTON_Y[i], BUTTON_WIDTH[i], BUTTON_HEIGHT,
                            SHIPS_NAME[i] + '\n' + str(SHIPS_COST[i]) + '$', SHIPS_NAME[i], BUTTON_FONT_SIZE)
            self.button_list.append(button)
        self.button_list.append(self.dialog_box.supply_button)
        self.button_list.append(self.dialog_box.weapon_button)
        self.button_list.append(self.dialog_box.go_button)

    def on_draw(self):
        start_render()
        draw_lrwh_rectangle_textured(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, self.background)

        for button in self.button_list:
            button.draw()
        self.dialog_box.draw()
        self.sprite_manager.draw_sprites()
        self.player.draw()

    def on_update(self, delta_time):
        new_ship = self.enemy.on_update(delta_time, self.sprite_manager.game_state())
        if new_ship is not None:
            self.sprite_manager.add_enemy_ship(new_ship)
        self.sprite_manager.update(delta_time)
        self.player.money_increase(self.sprite_manager.player_fight_benefit())
        self.enemy.money_increase(self.sprite_manager.enemy_fight_benefit())
        for i in range(SHIPS_COUNT):
            if self.button_list[i].pressed:
                self.dialog_box.curr = i
                self.dialog_box.update()
        self.update_buttons(delta_time)
        self.time += delta_time

        status = self.sprite_manager.check_end_game()
        if status != 0:
            final_view = DefeatView() if status == 1 else WinView()
            self.window.show_view(final_view)

    def clone(self, number: int):
        self.player.set_builder(number)
        fighter = self.player.clone()
        if self.dialog_box.weapon_button.checked:
            fighter = WeaponDecorator(fighter)
        if self.dialog_box.supply_button.checked:
            fighter = SupplyDecorator(fighter)
        if self.player.money < fighter.get_cost():
            return
        fighter.center_x = PLAYER_LOCATION_X
        fighter.center_y = PLAYER_LOCATION_Y
        fighter.change_x = FIGHTERS_SPEED
        fighter.side = 'player'
        self.sprite_manager.add_ship(fighter)
        self.player.money_decrease(fighter.cost)

    def lock_buttons(self, button):
        button.locked = True
        self.last_click = self.time

    def update_buttons(self, delta_time):
        if self.dialog_box.supply_button.pressed and self.time > self.last_click + TIME_DELAY * delta_time:
            self.last_click = self.time
            self.dialog_box.supply_button.checked = not self.dialog_box.supply_button.checked
        if self.dialog_box.weapon_button.pressed and self.time > self.last_click + TIME_DELAY * delta_time:
            self.last_click = self.time
            self.dialog_box.weapon_button.checked = not self.dialog_box.weapon_button.checked
        if self.dialog_box.go_button.pressed and not self.dialog_box.go_button.checked:
            self.clone(self.dialog_box.curr)
            self.dialog_box.go_button.checked = True
            self.dialog_box.supply_button.checked = False
            self.dialog_box.weapon_button.checked = False
            self.last_start = self.time
        if self.time > self.last_start + BUTTON_DELAY:
            self.dialog_box.go_button.checked = False
        if SHIPS_COST[self.dialog_box.curr] > self.player.money:
            self.dialog_box.go_button.locked = True
        else:
            self.dialog_box.go_button.locked = False

        if SHIPS_COST[self.dialog_box.curr] + EXTRA_SUPPLY_COST > self.player.money or \
                self.dialog_box.weapon_button.checked and \
                SHIPS_COST[self.dialog_box.curr] + EXTRA_WEAPON_COST + EXTRA_SUPPLY_COST > self.player.money:
            self.dialog_box.supply_button.locked = True
        else:
            self.dialog_box.supply_button.locked = False

        if SHIPS_COST[self.dialog_box.curr] + EXTRA_WEAPON_COST > self.player.money or \
                self.dialog_box.supply_button.checked and \
                SHIPS_COST[self.dialog_box.curr] + EXTRA_WEAPON_COST + EXTRA_SUPPLY_COST > self.player.money:
            self.dialog_box.weapon_button.locked = True
        else:
            self.dialog_box.weapon_button.locked = False