Exemplo n.º 1
0
    def __init__(self, parent, path, import_type):
        if import_type == self.AMIGA_FOREVER:
            title = gettext("Import From Amiga Forever CD/DVD")
        else:
            title = gettext("Import Kickstarts and ROMs")
        super().__init__(parent, title, maximizable=False)
        self.theme = LauncherTheme.get()
        self.layout = fsui.VerticalLayout()
        self.layout.padding_left = 20
        self.layout.padding_top = 20
        self.layout.padding_right = 20
        self.layout.padding_bottom = 20

        self.text_area = fsui.TextArea(self, read_only=True)
        self.text_area.set_min_width(600)
        self.text_area.set_min_height(300)
        self.layout.add(self.text_area)

        self.close_button = CloseButton.add_to_layout(
            self, self.layout, margin_top=20
        )
        if self.close_button:
            self.close_button.disable()

        self.line_count = 0
        self.task = ImportTask(path, import_type)
        self.task.start()

        self.set_size(self.layout.get_min_size())
        self.center_on_parent()
        fsui.call_later(TIMER_INTERVAL, self.on_timer)
Exemplo n.º 2
0
    def __init__(self, parent, path, import_type):
        if import_type == self.AMIGA_FOREVER:
            title = gettext("Import From Amiga Forever CD/DVD")
        else:
            title = gettext("Import Kickstarts and ROMs")
        super().__init__(parent, title, maximizable=False)
        self.layout = fsui.VerticalLayout()
        self.layout.padding_left = 20
        self.layout.padding_top = 20
        self.layout.padding_right = 20
        self.layout.padding_bottom = 20

        self.text_area = fsui.TextArea(self, read_only=True)
        self.text_area.set_min_width(600)
        self.text_area.set_min_height(300)
        self.layout.add(self.text_area)

        hori_layout = fsui.HorizontalLayout()
        self.layout.add(hori_layout, fill=True, margin_top=20)
        hori_layout.add_spacer(0, expand=True)
        self.close_button = fsui.Button(self, gettext("Close"))
        self.close_button.activated.connect(self.on_close_button)
        self.close_button.disable()
        hori_layout.add(self.close_button)

        self.line_count = 0
        self.task = ImportTask(path, import_type)
        self.task.start()

        self.set_size(self.layout.get_min_size())
        self.center_on_parent()
        fsui.call_later(TIMER_INTERVAL, self.on_timer)
    def __init__(self, parent, path, import_type):
        if import_type == self.AMIGA_FOREVER:
            title = gettext("Import From Amiga Forever CD/DVD")
        else:
            title = gettext("Import Kickstarts and ROMs")
        super().__init__(parent, title, maximizable=False)
        self.theme = LauncherTheme.get()
        self.layout = fsui.VerticalLayout()
        self.layout.padding_left = 20
        self.layout.padding_top = 20
        self.layout.padding_right = 20
        self.layout.padding_bottom = 20

        self.text_area = fsui.TextArea(self, read_only=True)
        self.text_area.set_min_width(600)
        self.text_area.set_min_height(300)
        self.layout.add(self.text_area)

        self.close_button = CloseButton.add_to_layout(self,
                                                      self.layout,
                                                      margin_top=20)
        if self.close_button:
            self.close_button.set_enabled(False)

        self.line_count = 0
        self.task = ImportTask(path, import_type)
        self.task.start()

        self.set_size(self.layout.get_min_size())
        self.center_on_parent()
        fsui.call_later(TIMER_INTERVAL, self.on_timer)
Exemplo n.º 4
0
 def on_timer(self):
     if self.task.done:
         LauncherSignal.broadcast("scan_done")
         self.close_button.enable()
     else:
         fsui.call_later(TIMER_INTERVAL, self.on_timer)
     lines = self.task.get_new_log_lines(self.line_count)
     for line in lines:
         self.text_area.append_text(line + "\n")
     self.line_count += len(lines)
Exemplo n.º 5
0
 def on_timer_callback(self):
     if self.map_key_name:
         state = self.get_state()
         for key, value in self.initial_state.items():
             # we check initial state because some axes may have non-zero
             # rest values... (i.e. full negative)
             if state[key] and state[key] != self.initial_state[key]:
                 self.set_result(key)
     if self.stopped:
         return
     # continue timer
     fsui.call_later(100, self.on_timer_callback)
 def on_timer_callback(self):
     if self.map_key_name:
         state = self.get_state()
         for key, value in self.initial_state.items():
             # we check initial state because some axes may have non-zero
             # rest values... (i.e. full negative)
             if state[key] and state[key] != self.initial_state[key]:
                 self.set_result(key)
     if self.stopped:
         return
     # continue timer
     fsui.call_later(100, self.on_timer_callback)
Exemplo n.º 7
0
def check_refs(r):
    import gc

    import fsui

    gc.collect()
    obj = r()
    if obj:
        for i, referrer in enumerate(gc.get_referrers(obj)):
            print("")
            print("REF", i, referrer)
    fsui.call_later(1000, check_refs, r)
Exemplo n.º 8
0
 def function():
     if progress == "__run__":
         self.cancel_button.disable()
         # Hide dialog after 1.5 seconds. The reason for delaying it
         # is to avoid "confusing" flickering if/when the dialog is
         # only shown for a split second.
         if self.is_shown():
             fsui.call_later(1500, hide_function)
         LauncherConfig.set("__progress", gettext("Running: Emulator"))
     else:
         if self.no_gui:
             print("[PROGRESS]", progress)
         else:
             self.sub_title_label.set_text(progress)
         LauncherConfig.set("__progress",
                            "Preparing: {}".format(progress))
Exemplo n.º 9
0
 def function():
     if progress == "__run__":
         self.cancel_button.disable()
         # Hide dialog after 1.5 seconds. The reason for delaying it
         # is to avoid "confusing" flickering if/when the dialog is
         # only shown for a split second.
         if self.is_shown():
             fsui.call_later(1500, hide_function)
         LauncherConfig.set(
             "__progress", gettext("Running: Emulator"))
     else:
         if self.no_gui:
             print("[PROGRESS]", progress)
         else:
             self.sub_title_label.set_text(progress)
         LauncherConfig.set(
             "__progress", "Preparing: {}".format(progress))
Exemplo n.º 10
0
 def on_timer_callback(self):
     if self.map_key_name:
         state = self.get_state()
         if state != self.previous_timer_state:
             # Wait until the state settles, we might want to check if both
             # an axis and a button is pressed.
             self.previous_timer_state = state.copy()
         else:
             for key in self.sorted_input_keys():
                 # we check initial state because some axes may have non-zero
                 # rest values... (i.e. full negative)
                 if state[key] and state[key] != self.initial_state[key]:
                     self.set_result(key)
     if self.stopped:
         return
     # continue timer
     fsui.call_later(100, self.on_timer_callback)
Exemplo n.º 11
0
    def __init__(self, parent, device_name):
        title = gettext("Configure {device_name}").format(
            device_name=device_name)
        super().__init__(parent,
                         title=title,
                         minimizable=False,
                         maximizable=False,
                         separator=False)

        self.layout = fsui.VerticalLayout()

        self.image = fsui.Image("workspace:res/gamepad-config.png")
        self.joystick_panel = fsui.ImageView(self, self.image)
        self.layout.add(self.joystick_panel)

        if Skin.fws():
            from workspace.ui import TitleSeparator
            separator = TitleSeparator(self)
            self.layout.add(separator, fill=True)

        panel = fsui.Panel(self)
        self.layout.add(panel, fill=True)

        panel.layout = fsui.HorizontalLayout()
        panel.layout.padding = 20

        self.device_type_ids = [
            "",
            "gamepad",
            "joystick",
            # "flightstick",
            "other",
        ]
        self.device_type_labels = [
            gettext("Choose Type"),
            gettext("Gamepad"),
            gettext("Digital Joystick"),
            # gettext("Flight Stick"),
            gettext("Other Device"),
        ]

        self.type_field = fsui.Choice(panel, self.device_type_labels)
        self.type_field.changed.connect(self.on_change)
        panel.layout.add(self.type_field)

        panel.layout.add(fsui.PlainLabel(panel, gettext("Make:")),
                         margin_left=20)
        self.make_field = fsui.TextField(panel)
        self.make_field.set_min_width(140)
        self.make_field.changed.connect(self.on_change)
        panel.layout.add(self.make_field, margin_left=10)

        panel.layout.add(fsui.PlainLabel(panel, gettext("Model:")),
                         margin_left=20)
        self.model_field = fsui.TextField(panel)
        self.model_field.changed.connect(self.on_change)
        panel.layout.add(self.model_field, expand=True, margin_left=10)

        self.save_button = fsui.Button(panel, gettext("Save"))
        self.save_button.activated.connect(self.on_save_button)
        panel.layout.add(self.save_button, margin_left=20)

        # self.close_button = fsui.Button(panel, gettext("Close"))
        # self.close_button.activated.connect(self.on_close_button)
        # panel.layout.add(self.close_button, margin_left=10)

        self.device_name = device_name
        existing_config = self.read_existing_config()

        self.button_panels = []
        for x, y, direction, name in BUTTONS:
            b = MappingButton(self.joystick_panel, (x, y + 4), direction, name)
            self.button_panels.append(b)
            if name in existing_config:
                b.event_name = existing_config[name]

        self.save_button.disable()
        self.set_size(self.layout.get_min_size())
        self.center_on_parent()

        self.stopped = False
        self.current_state = {}
        self.initial_state = {}
        self.map_key_name = None

        fsui.call_later(100, self.on_timer_callback)
        thread = threading.Thread(target=event_thread,
                                  name="JoystickConfigEventThread",
                                  args=(
                                      self.device_name,
                                      weakref.ref(self),
                                  ))
        thread.start()
    def __init__(self, parent, device_name):
        title = gettext("Configure {device_name}").format(
            device_name=device_name)
        super().__init__(parent, title=title, minimizable=False,
                         maximizable=False, separator=False)

        self.layout = fsui.VerticalLayout()

        self.image = fsui.Image("workspace:res/gamepad-config.png")
        self.joystick_panel = fsui.ImageView(self, self.image)
        self.layout.add(self.joystick_panel)

        if Skin.fws():
            from workspace.ui import TitleSeparator
            separator = TitleSeparator(self)
            self.layout.add(separator, fill=True)

        panel = fsui.Panel(self)
        self.layout.add(panel, fill=True)

        panel.layout = fsui.HorizontalLayout()
        panel.layout.padding = 20

        self.device_type_ids = [
            "",
            "gamepad",
            "joystick",
            # "flightstick",
            "other",
        ]
        self.device_type_labels = [
            gettext("Choose Type"),
            gettext("Gamepad"),
            gettext("Digital Joystick"),
            # gettext("Flight Stick"),
            gettext("Other Device"),
        ]

        self.type_field = fsui.Choice(panel, self.device_type_labels)
        self.type_field.changed.connect(self.on_change)
        panel.layout.add(self.type_field)

        panel.layout.add(fsui.PlainLabel(
            panel, gettext("Make:")), margin_left=20)
        self.make_field = fsui.TextField(panel)
        self.make_field.set_min_width(140)
        self.make_field.changed.connect(self.on_change)
        panel.layout.add(self.make_field, margin_left=10)

        panel.layout.add(fsui.PlainLabel(
            panel, gettext("Model:")), margin_left=20)
        self.model_field = fsui.TextField(panel)
        self.model_field.changed.connect(self.on_change)
        panel.layout.add(self.model_field, expand=True, margin_left=10)

        self.save_button = fsui.Button(panel, gettext("Save"))
        self.save_button.activated.connect(self.on_save_button)
        panel.layout.add(self.save_button, margin_left=20)

        # self.close_button = fsui.Button(panel, gettext("Close"))
        # self.close_button.activated.connect(self.on_close_button)
        # panel.layout.add(self.close_button, margin_left=10)

        self.device_name = device_name
        existing_config = self.read_existing_config()

        self.button_panels = []
        for x, y, direction, name in BUTTONS:
            b = MappingButton(self.joystick_panel, (x, y + 4), direction, name)
            self.button_panels.append(b)
            if name in existing_config:
                b.event_name = existing_config[name]

        self.save_button.disable()
        self.set_size(self.layout.get_min_size())
        self.center_on_parent()

        self.stopped = False
        self.current_state = {}
        self.initial_state = {}
        self.map_key_name = None

        fsui.call_later(100, self.on_timer_callback)
        thread = threading.Thread(
            target=event_thread, name="JoystickConfigEventThread",
            args=(self.device_name, weakref.ref(self),))
        thread.start()