Esempio n. 1
0
    def __init__(self):
        QMainWindow.__init__(self)

        self.resize(1280, 720)
        self.setWindowIcon(QIcon(here('resources', 'editor.ico')))
        
        self.scene = Scene()

        self.view = View(self.scene)
        self.setCentralWidget(self.view)
Esempio n. 2
0
    def __init__(self, playtest=False):
        QMainWindow.__init__(self)

        if not playtest:
            self.resize(1280, 720)
        self.setWindowIcon(QIcon(here('resources', 'player.ico')))

        self.scene = Scene()

        self.central_widget = QWidget()
        self.setCentralWidget(self.central_widget)
        layout = QVBoxLayout()
        layout.setContentsMargins(QMargins())
        layout.setSpacing(0)
        self.central_widget.setLayout(layout)

        top_layout = QHBoxLayout()
        layout.addLayout(top_layout)

        self.author_align_label = QLabel()
        self.author_align_label.setStyleSheet('color: rgba(0,0,0,0%)')
        top_layout.addWidget(self.author_align_label, 0)

        self.title_label = QLabel()
        self.title_label.setAlignment(qt.AlignHCenter)
        font = self.title_label.font()
        multiply_font_size(font, 1.8)
        self.title_label.setFont(font)
        top_layout.addWidget(self.title_label, 1)

        self.author_label = QLabel()
        self.author_label.setAlignment(qt.AlignRight)
        top_layout.addWidget(self.author_label, 0)

        self.view = View(self.scene)
        layout.addWidget(self.view, 1)

        self.information_label = QLabel()
        self.information_label.setAlignment(qt.AlignHCenter)
        self.information_label.setWordWrap(True)
        self.information_label.setContentsMargins(5, 5, 5, 5)
        font = self.information_label.font()
        multiply_font_size(font, 1.5)
        self.information_label.setFont(font)
        layout.addWidget(self.information_label)

        self.scene.playtest = self.playtest = playtest

        menu = self.menuBar().addMenu("&File")

        if not playtest:
            action = menu.addAction("&Open...", self.load_file,
                                    QKeySequence.Open)
            menu.addSeparator()
            action = menu.addAction("&Paste from Clipboard", self.paste,
                                    QKeySequence('Ctrl+V'))
            menu.addSeparator()

        action = menu.addAction(
            "&Quit", self.close,
            QKeySequence('Tab') if playtest else QKeySequence.Quit)
        if playtest:
            QShortcut(QKeySequence.Quit, self, action.trigger)
        else:
            QShortcut(QKeySequence.Close, self, action.trigger)

        menu = self.menuBar().addMenu("&Preferences")

        self.swap_buttons_action = action = make_check_action(
            "&Swap Buttons", self, self.scene, 'swap_buttons')
        menu.addAction(action)

        menu = self.menuBar().addMenu("&Solve")
        menu.setEnabled(solve is not None)

        menu.addAction("&One Step", self.scene.solve_step, QKeySequence("S"))

        menu.addAction("Confirm &Revealed", self.scene.confirm_proven,
                       QKeySequence("C"))

        menu.addAction("&Clear Revealed", self.scene.clear_proven,
                       QKeySequence("X"))

        menu.addSeparator()

        menu.addAction("&Solve Completely", self.scene.solve_complete,
                       QKeySequence("Shift+S"))

        menu = self.menuBar().addMenu("&Help")

        action = menu.addAction("&Instructions", help,
                                QKeySequence.HelpContents)

        action = menu.addAction("&About", lambda: about(self.title))

        self.last_used_folder = None

        self.reset()

        try:
            with open(here('player.cfg')) as cfg_file:
                cfg = cfg_file.read()
        except IOError:
            pass
        else:
            load_config(self, self.config_format, cfg)
Esempio n. 3
0
    def __init__(self):
        QMainWindow.__init__(self)

        self.resize(1280, 720)
        self.setWindowIcon(QIcon(here('resources', 'editor.ico')))
        
        self.scene = Scene()

        self.view = View(self.scene)
        self.setCentralWidget(self.view)
        
        self.statusBar()
        
        menu = self.menuBar().addMenu("&File")
        action = menu.addAction("&New", self.close_file, QKeySequence.New)
        action.setStatusTip("Close the current level and start with an empty one.")
        action = menu.addAction("&Open...", self.load_file, QKeySequence.Open)
        action.setStatusTip("Close the current level and load one from a file.")
        action = menu.addAction("Open from &Web page...", self.open_from_web_page, QKeySequence('Ctrl+W'))
        action.setStatusTip("Close the current level and load one from a web page.")
        action = menu.addAction("&Save", lambda: self.save_file(self.current_file), QKeySequence.Save)
        action.setStatusTip("Save the level, overwriting the current file.")
        action = menu.addAction("Save &As...", self.save_file, QKeySequence('Ctrl+Shift+S'))
        action.setStatusTip("Save the level into a different file.")
        menu.addSeparator()
        action = menu.addAction("Set Level &Information", self.set_information, QKeySequence('Ctrl+D'))
        action.setStatusTip("Add or change the level's title, author's name and custom text hints.")
        menu.addSeparator()
        action = menu.addAction("&Copy to Clipboard", self.copy, QKeySequence('Ctrl+C'))
        action.setStatusTip("Copy the current level into clipboard, in a text-based .hexcells format, padded with tab characters.")
        menu.addSeparator()
        action = menu.addAction("&Quit", self.close, QKeySequence.Quit)
        action.setStatusTip("Close SixCells Editor.")


        menu = self.menuBar().addMenu("&Preferences")
        
        self.swap_buttons_group = make_action_group(self, menu, self.scene, 'swap_buttons', [
            ("&Left Click Places Blue", False, "A blue cell will be placed when left mouse button is clicked. Black will then be the secondary color."),
            ("&Left Click Places Black", True, "A black cell will be placed when left mouse button is clicked. Blue will then be the secondary color."),
        ])
        self.swap_buttons_group[False].setChecked(True)
        
        menu.addSeparator()
        
        self.secondary_action_group = make_action_group(self, menu, self.scene, 'use_rightclick', [
            ("&Right Click Places Secondary", True, "A cell with color opposite to the above choice will be placed when right mouse button is clicked."),
            ("&Double Click Places Secondary", False, "A cell with color opposite to the above choice will be placed when left mouse button is double-clicked."),
        ])
        self.secondary_action_group[True].setChecked(True)
        
        menu.addSeparator()
        
        states = [
            ("&Blank", 0, "When placed, these cells will not contain a number."),
            ("With &Number", 1, "When placed, these cells will contain a number, for example, \"2\"."),
            ("With &Connection Info", 2, "When placed, these cells will contain a number and connection information, for example, \"{2}\" or \"-3-\"."),
        ]
        submenu = menu.addMenu("Place Blac&ks")
        submenu.setStatusTip("Black cells, when placed, will be...")
        self.black_show_info_group = make_action_group(self, submenu, self.scene, 'black_show_info', states)
        self.black_show_info_group[1].setChecked(True)
        submenu = menu.addMenu("Place &Blues")
        submenu.setStatusTip("Blue cells, when placed, will be...")
        self.blue_show_info_group = make_action_group(self, submenu, self.scene, 'blue_show_info', states[:-1])
        self.blue_show_info_group[0].setChecked(True)
        self.blue_show_info_group[2] = self.blue_show_info_group[0] # for config backwards compatibility

        menu.addSeparator()
        
        self.enable_statusbar_action = action = make_check_action("Show &Status Bar", self, 'statusbar_visible')
        action.setChecked(True)
        menu.addAction(action)


        menu = self.menuBar().addMenu("&Play")
        action = menu.addAction("From &Start", self.play, QKeySequence('Shift+Tab'))
        QShortcut(QKeySequence('Ctrl+Tab'), self, action.trigger)
        action.setStatusTip("Playtest this level from the beginning (discarding all progress).")
        action = menu.addAction("&Resume", lambda: self.play(resume=True), QKeySequence('Tab'))
        action.setStatusTip("Continue playtesting this level from where you left off.")
        
        
        menu = self.menuBar().addMenu("&Help")
        action = menu.addAction("&Instructions", help, QKeySequence.HelpContents)
        action.setStatusTip("View README on the project's webpage.")
        action = menu.addAction("&About", lambda: about(self.title))
        action.setStatusTip("About SixCells Editor.")
        

        self.current_file = None
        self.any_changes = False
        self.scene.changed.connect(self.changed)

        self.last_used_folder = None
        self.swap_buttons = False
        self.default_author = None
        
        try:
            with open(here('editor.cfg')) as cfg_file:
                cfg = cfg_file.read()
        except IOError:
            pass
        else:
            load_config(self, self.config_format, cfg)
Esempio n. 4
0
    def __init__(self, playtest=False):
        QMainWindow.__init__(self)
        
        if not playtest:
            self.resize(1280, 720)
        self.setWindowIcon(QIcon(here('resources', 'player.ico')))

        self.scene = Scene()

        self.central_widget = QWidget()
        self.setCentralWidget(self.central_widget)
        layout = QVBoxLayout()
        layout.setContentsMargins(QMargins())
        layout.setSpacing(0)
        self.central_widget.setLayout(layout)
        
        top_layout = QHBoxLayout()
        layout.addLayout(top_layout)
        
        self.author_align_label = QLabel()
        self.author_align_label.setStyleSheet('color: rgba(0,0,0,0%)')
        top_layout.addWidget(self.author_align_label, 0)
        
        self.title_label = QLabel()
        self.title_label.setAlignment(qt.AlignHCenter)
        font = self.title_label.font()
        multiply_font_size(font, 1.8)
        self.title_label.setFont(font)
        top_layout.addWidget(self.title_label, 1)

        self.author_label = QLabel()
        self.author_label.setAlignment(qt.AlignRight)
        top_layout.addWidget(self.author_label, 0)
        
        
        self.view = View(self.scene)
        layout.addWidget(self.view, 1)

        self.information_label = QLabel()
        self.information_label.setAlignment(qt.AlignHCenter)
        self.information_label.setWordWrap(True)
        self.information_label.setContentsMargins(5, 5, 5, 5)
        font = self.information_label.font()
        multiply_font_size(font, 1.5)
        self.information_label.setFont(font)
        layout.addWidget(self.information_label)

        self.scene.playtest = self.playtest = playtest
        
        
        menu = self.menuBar().addMenu("&File")
        
        if not playtest:
            action = menu.addAction("&Open...", self.load_file, QKeySequence.Open)
            menu.addSeparator()
            action = menu.addAction("&Paste from Clipboard", self.paste, QKeySequence('Ctrl+V'))
            menu.addSeparator()

        
        action = menu.addAction("&Quit", self.close, QKeySequence('Tab') if playtest else QKeySequence.Quit)
        if playtest:
            QShortcut(QKeySequence.Quit, self, action.trigger)
        else:
            QShortcut(QKeySequence.Close, self, action.trigger)
        
        
        menu = self.menuBar().addMenu("&Preferences")
        
        self.swap_buttons_action = action = make_check_action("&Swap Buttons", self, self.scene, 'swap_buttons')
        menu.addAction(action)

        
        menu = self.menuBar().addMenu("&Solve")
        menu.setEnabled(solve is not None)
        
        menu.addAction("&One Step", self.scene.solve_step, QKeySequence("S"))
        
        menu.addAction("Confirm &Revealed", self.scene.confirm_proven, QKeySequence("C"))
        
        menu.addAction("&Clear Revealed", self.scene.clear_proven, QKeySequence("X"))
        
        menu.addSeparator()
        
        menu.addAction("&Solve Completely", self.scene.solve_complete, QKeySequence("Shift+S"))

        
        menu = self.menuBar().addMenu("&Help")
        
        action = menu.addAction("&Instructions", help, QKeySequence.HelpContents)
        
        action = menu.addAction("&About", lambda: about(self.title))
        
        
        self.last_used_folder = None
        
        self.reset()
        
        try:
            with open(here('player.cfg')) as cfg_file:
                cfg = cfg_file.read()
        except IOError:
            pass
        else:
            load_config(self, self.config_format, cfg)
Esempio n. 5
0
    def __init__(self):
        QMainWindow.__init__(self)

        self.resize(1280, 720)
        self.setWindowIcon(QIcon(here('resources', 'editor.ico')))

        self.scene = Scene()

        self.view = View(self.scene)
        self.setCentralWidget(self.view)

        self.statusBar()

        menu = self.menuBar().addMenu("&File")
        action = menu.addAction("&New", self.close_file, QKeySequence.New)
        action.setStatusTip(
            "Close the current level and start with an empty one.")
        action = menu.addAction("&Open...", self.load_file, QKeySequence.Open)
        action.setStatusTip(
            "Close the current level and load one from a file.")
        action = menu.addAction("Open from &Web page...",
                                self.open_from_web_page,
                                QKeySequence('Ctrl+W'))
        action.setStatusTip(
            "Close the current level and load one from a web page.")
        action = menu.addAction("&Save",
                                lambda: self.save_file(self.current_file),
                                QKeySequence.Save)
        action.setStatusTip("Save the level, overwriting the current file.")
        action = menu.addAction("Save &As...", self.save_file,
                                QKeySequence('Ctrl+Shift+S'))
        action.setStatusTip("Save the level into a different file.")
        menu.addSeparator()
        action = menu.addAction("Set Level &Information", self.set_information,
                                QKeySequence('Ctrl+D'))
        action.setStatusTip(
            "Add or change the level's title, author's name and custom text hints."
        )
        menu.addSeparator()
        action = menu.addAction("&Copy to Clipboard", self.copy,
                                QKeySequence('Ctrl+C'))
        action.setStatusTip(
            "Copy the current level into clipboard, in a text-based .hexcells format, padded with tab characters."
        )
        menu.addSeparator()
        action = menu.addAction("&Quit", self.close, QKeySequence.Quit)
        action.setStatusTip("Close SixCells Editor.")

        menu = self.menuBar().addMenu("&Preferences")

        self.swap_buttons_group = make_action_group(
            self, menu, self.scene, 'swap_buttons', [
                ("&Left Click Places Blue", False,
                 "A blue cell will be placed when left mouse button is clicked. Black will then be the secondary color."
                 ),
                ("&Left Click Places Black", True,
                 "A black cell will be placed when left mouse button is clicked. Blue will then be the secondary color."
                 ),
            ])
        self.swap_buttons_group[False].setChecked(True)

        menu.addSeparator()

        self.secondary_action_group = make_action_group(
            self, menu, self.scene, 'use_rightclick', [
                ("&Right Click Places Secondary", True,
                 "A cell with color opposite to the above choice will be placed when right mouse button is clicked."
                 ),
                ("&Double Click Places Secondary", False,
                 "A cell with color opposite to the above choice will be placed when left mouse button is double-clicked."
                 ),
            ])
        self.secondary_action_group[True].setChecked(True)

        menu.addSeparator()

        states = [
            ("&Blank", 0,
             "When placed, these cells will not contain a number."),
            ("With &Number", 1,
             "When placed, these cells will contain a number, for example, \"2\"."
             ),
            ("With &Connection Info", 2,
             "When placed, these cells will contain a number and connection information, for example, \"{2}\" or \"-3-\"."
             ),
        ]
        submenu = menu.addMenu("Place Blac&ks")
        submenu.setStatusTip("Black cells, when placed, will be...")
        self.black_show_info_group = make_action_group(self, submenu,
                                                       self.scene,
                                                       'black_show_info',
                                                       states)
        self.black_show_info_group[1].setChecked(True)
        submenu = menu.addMenu("Place &Blues")
        submenu.setStatusTip("Blue cells, when placed, will be...")
        self.blue_show_info_group = make_action_group(self, submenu,
                                                      self.scene,
                                                      'blue_show_info',
                                                      states[:-1])
        self.blue_show_info_group[0].setChecked(True)
        self.blue_show_info_group[2] = self.blue_show_info_group[
            0]  # for config backwards compatibility

        menu.addSeparator()

        self.enable_statusbar_action = action = make_check_action(
            "Show &Status Bar", self, 'statusbar_visible')
        action.setChecked(True)
        menu.addAction(action)

        menu = self.menuBar().addMenu("&Play")
        action = menu.addAction("From &Start", self.play,
                                QKeySequence('Shift+Tab'))
        QShortcut(QKeySequence('Ctrl+Tab'), self, action.trigger)
        action.setStatusTip(
            "Playtest this level from the beginning (discarding all progress)."
        )
        action = menu.addAction("&Resume", lambda: self.play(resume=True),
                                QKeySequence('Tab'))
        action.setStatusTip(
            "Continue playtesting this level from where you left off.")

        menu = self.menuBar().addMenu("&Help")
        action = menu.addAction("&Instructions", help,
                                QKeySequence.HelpContents)
        action.setStatusTip("View README on the project's webpage.")
        action = menu.addAction("&About", lambda: about(self.title))
        action.setStatusTip("About SixCells Editor.")

        self.current_file = None
        self.any_changes = False
        self.scene.changed.connect(self.changed)

        self.last_used_folder = None
        self.swap_buttons = False
        self.default_author = None

        try:
            with open(here('editor.cfg')) as cfg_file:
                cfg = cfg_file.read()
        except IOError:
            pass
        else:
            load_config(self, self.config_format, cfg)