def __init__(self):
     self.number_of_siders = 0
     self.ladspa_sink_update = datetime.datetime.now()
     self.ladspa_values = None
     self.ladspa_timer_running = False
     self.module_info = None
     self.timer = None
     SliderWidget.__init__(self)
     self.init_layout()
Example #2
0
    def __init__(self, page):
        OptionsCategory.__init__(self, page)

        self.gagKey = ChoiceWidget(page,
                                   None,
                                   pos=(0, 0.47, 0.47),
                                   widgetName="Use Gag",
                                   settingKeyName='gagkey',
                                   mode=MULTICHOICE)

        self.bpov = ChoiceWidget(page,
                                 None,
                                 pos=(0, 0.25, 0.25),
                                 widgetName="Battle POV",
                                 settingKeyName='bpov',
                                 mode=INDEX,
                                 choiceTextScale=0.053)

        self.fpmsSlider = SliderWidget(page,
                                       "Mouse Sensitivity\n(First Person)",
                                       (0.05, 0.3), self.__setFPMS,
                                       (0, 0, 0.1))
        self.fpfovSlider = SliderWidget(page, "Field of View\n(First Person)",
                                        (54.0, 70.0), self.__setFPFov,
                                        (0, 0, -0.15))
        self.genFovSlider = SliderWidget(page,
                                         "Field of View\n(General Gameplay)",
                                         (40.0, 70.0), self.__setGenFov,
                                         (0, 0, -0.4))

        self.keysChanged = 0

        self.discardChanges()
Example #3
0
 def _create_slider(self):
     self.slider = SliderWidget()
Example #4
0
class Channel(Gtk.Alignment):

    ICON_HEIGHT = 36

    def __init__(self):
        Gtk.Alignment.__init__(self)
        #self.set_homogeneous(False)
        self._init()
        self.set_size_request(self.ICON_HEIGHT, self.ICON_HEIGHT)

    def _init(self):
        self.frame = Gtk.Frame()
        self.hbox = Gtk.HBox()
        self._create()
        self._pack_contents()
        self._pack_frame()

    def _pack_contents(self):
        self.mute_box.pack_start(self.mute, False, True, 2)
        self.mute_box.pack_start(Gtk.HBox(), True, True, 0)
        self.menu_box.pack_start(self.menu_button, False, True, 2)
        self.menu_box.pack_start(Gtk.HBox(), True, True, 0)

        self.hbox.pack_start(self.mute_box, False, True, 2)
        self.hbox.pack_start(self.slider,True,True,5)
        self.hbox.pack_start(self.menu_box,False,False, 2)

    def _pack_frame(self):
        self.frame.add(self.hbox)
        self.add(self.frame)
        self.connect("button-press-event", self.on_button_press_event)

    def _create(self):
        self._create_mute()
        self._create_slider()
        self._create_menu_button()

    def _create_menu_button(self):
        self.menu_box=Gtk.VBox()
        self.menu_button = Gtk.ToggleButton()
        self.menu_button.set_relief(Gtk.ReliefStyle.NONE)
        self.menu_button.set_can_focus(False)
        self.menu_button.add(Gtk.Arrow(Gtk.ArrowType.DOWN, Gtk.ShadowType.NONE))
        self.menu_button.connect("released", self.show_popupmenu)
        self.menu_button.set_size_request(-1, self.ICON_HEIGHT)

    def on_menu_button_released(self, widget):
        self.menu_button.set_active(False)

    def _create_mute(self):
        self.mute_box = Gtk.VBox()
        self.mute = MuteButton()
        self.mute.connect_clicked(self.on_mute_clicked)

    def _create_slider(self):
        self.slider = SliderWidget()

    def show_popupmenu(self, widget, button=0, time=0):
        self.menu = Gtk.Menu()
        self.menu.connect("selection-done", self.on_menu_button_released)
        instance = ContextMenu.get_instance()
        instance.populate_menu(self.pa_sink_proxy(), self.menu, self.slider)
        self.menu.show_all()
        self.menu.popup(None, None, None, None, 0, 0)
        return False

    def on_button_press_event(self, widget, event):
        if (event.type == Gdk.EventType.BUTTON_PRESS and event.button == 3):
            self.show_popupmenu(event.button, event.time)
            return True # event has been handled

    def on_mute_clicked(self, button, event):
        # catch drag and drop:
        if (Gdk.EventType.BUTTON_RELEASE and (event.x != 0.0 and event.y != 0.0)):
            self.pa_sink_proxy().toggle_mute()
            return True
        return False

    def pa_sink_proxy(self):
        return self._pa_sink

    def on_pa_data_updated(self, data):
        self._pa_sink = data

        self.slider.set_volume(data)
        self.mute.set_active(data.isMuted())
        self.mute.set_image_name(data.get_nice_icon())

    def step_volume(self, up):
        self.slider.step_volume(up)

    def toggle_mute(self):
        self.pa_sink_proxy().toggle_mute()

    def on_pa_module_data_updated(self, data):
        pass
Example #5
0
class ControlsCategory(OptionsCategory):
    Name = "Controls"

    def __init__(self, page):
        OptionsCategory.__init__(self, page)

        self.gagKey = ChoiceWidget(page,
                                   None,
                                   pos=(0, 0.47, 0.47),
                                   widgetName="Use Gag",
                                   settingKeyName='gagkey',
                                   mode=MULTICHOICE)

        self.bpov = ChoiceWidget(page,
                                 None,
                                 pos=(0, 0.25, 0.25),
                                 widgetName="Battle POV",
                                 settingKeyName='bpov',
                                 mode=INDEX,
                                 choiceTextScale=0.053)

        self.fpmsSlider = SliderWidget(page,
                                       "Mouse Sensitivity\n(First Person)",
                                       (0.05, 0.3), self.__setFPMS,
                                       (0, 0, 0.1))
        self.fpfovSlider = SliderWidget(page, "Field of View\n(First Person)",
                                        (54.0, 70.0), self.__setFPFov,
                                        (0, 0, -0.15))
        self.genFovSlider = SliderWidget(page,
                                         "Field of View\n(General Gameplay)",
                                         (40.0, 70.0), self.__setGenFov,
                                         (0, 0, -0.4))

        self.keysChanged = 0

        self.discardChanges()

    def _setDefaults(self):
        self.origFPms = float(
            CIGlobals.getSettingsMgr().getSetting("fpmgms").getValue())
        self.origFPfov = float(
            CIGlobals.getSettingsMgr().getSetting("fpmgfov").getValue())
        self.origGenFov = float(
            CIGlobals.getSettingsMgr().getSetting("genfov").getValue())

        self.fpFov = self.origFPfov
        self.fpMs = self.origFPms
        self.genFov = self.origGenFov

        self.keysChanged = 0
        self.gagKey.reset()
        self.bpov.reset()

    def __updateGagKey(self, _):
        self.keysChanged += 1

    def __setFPMS(self):
        val = self.fpmsSlider.getSliderVal()
        self.fpmsSlider.setValText("{:.2f}".format(val * 10.0))
        self.fpMs = val

    def __setFPFov(self):
        val = self.fpfovSlider.getSliderVal()
        self.fpfovSlider.setValText("{:.0f}".format(val))
        self.fpFov = val

    def __setGenFov(self):
        val = self.genFovSlider.getSliderVal()
        self.genFovSlider.setValText("{:.0f}".format(val))
        self.genFov = val

    def applyChanges(self):
        self._showApplying()

        self.gagKey.saveSetting()
        self.bpov.saveSetting()

        if (self.fpFov != self.origFPfov):
            # They changed the first person fov!
            self.settingsMgr.getSetting("fpmgfov").setValue(self.fpFov)

        if (self.fpMs != self.origFPms):
            self.settingsMgr.getSetting("fpmgms").setValue(self.fpMs)

        if (self.genFov != self.origGenFov):
            self.settingsMgr.getSetting("genfov").setValue(self.genFov)

        # We need to let the chat input know when we updated keys.
        if self.keysChanged > 0:
            base.localAvatar.chatInput.setKeyList()

        self.settingsMgr.saveFile()

        self._setDefaults()
        self._hideApplying()

    def discardChanges(self):
        self._setDefaults()

        self.fpmsSlider.setSliderVal(self.origFPms)
        self.fpmsSlider.setValText("{:.2f}".format(self.origFPms * 10.0))

        self.fpfovSlider.setSliderVal(self.origFPfov)
        self.fpfovSlider.setValText("{:.0f}".format(self.origFPfov))

        self.genFovSlider.setSliderVal(self.origGenFov)
        self.genFovSlider.setValText("{:.0f}".format(self.origGenFov))

    def cleanup(self):
        self.discardChanges()
        OptionsCategory.cleanup(self)

        for widget in [
                self.gagKey, self.fpmsSlider, self.fpfovSlider,
                self.genFovSlider, self.bpov
        ]:
            widget.cleanup()

        del self.gagKey
        del self.bpov
        del self.fpmsSlider
        del self.fpfovSlider
        del self.genFovSlider
        del self.origFPms
        del self.origFPfov
        del self.origGenFov

        del self.fpFov
        del self.fpMs
        del self.genFov
        del self.keysChanged