Esempio n. 1
0
    def interact(self, game, coords, room):
        form = npyscreen.Popup(name="Control Rod", color=self.get_color(), lines=6)
        forms.add_standard_handlers(form)
        max_val = 100
        slider: npyscreen.Slider = form.add_widget(
            npyscreen.Slider,
            lowest=0,
            out_of=max_val,
            value=game.reactor.control_rod_depth * max_val,
            step=0.25,
            label="Control Rod",
        )
        old_inc = slider.h_increase

        def inc(ch):
            old_inc(ch)
            game.reactor.control_rod_depth = slider.value / max_val
            game.minor_action_time()
            game.update()
            game.current_form.display()

        for key, handler in slider.handlers.items():
            if handler == old_inc:
                slider.handlers[key] = inc
        slider.h_increase = inc

        form.edit()
        game.reactor.control_rod_depth = slider.value / max_val
Esempio n. 2
0
    def deauth(self, args):
        try:
            bssid = self.grid.selected_row()[1]
            assert bssid in self.wifi_instance.bssids.keys(
            ), 'Could not find AP with BSSID: ' + bssid
            if len(self.wifi_instance.bssids[bssid]['clients']) > 0:
                clients_list: List[str] = self.make_client_list(
                    self.wifi_instance.bssids[bssid]['clients'])

                popup_columns: int = len(max(clients_list, key=len)) + len(
                    self.deauth_multi_select_name) + 22
                popup_lines: int = len(clients_list) + 4

                if popup_columns > int(3 * self.x // 4):
                    popup_columns = int(3 * self.x // 4)
                if popup_lines > int(3 * self.y // 4):
                    popup_lines = int(3 * self.y // 4)
                if popup_lines < 6:
                    popup_lines = 6

                popup = npyscreen.Popup(name=self.deauth_popup_name,
                                        columns=popup_columns,
                                        lines=popup_lines)
                deauth_clients = popup.add(npyscreen.TitleMultiSelect,
                                           name=self.deauth_multi_select_name,
                                           scroll_exit=True,
                                           values=clients_list)
                popup.edit()
                if len(deauth_clients.get_selected_objects()) > 0:
                    if self.wifi_channel != self.wifi_instance.bssids[bssid][
                            'channel']:
                        self.wifi_channel = self.wifi_instance.bssids[bssid][
                            'channel']
                        self.wifi_instance.set_wifi_channel(
                            channel=self.wifi_instance.bssids[bssid]
                            ['channel'])
                    for client in deauth_clients.get_selected_objects():
                        self.tm_instance.add_task(
                            self.wifi_instance.send_deauth, bssid,
                            client[0:17], 50)
            else:
                npyscreen.notify_confirm(
                    'Not found clients for AP: ' +
                    self.wifi_instance.bssids[bssid]['essid'] + ' (' + bssid +
                    ')',
                    title="Deauth Error")
                self.parentApp.switchFormPrevious()

        except AssertionError as Error:
            npyscreen.notify_confirm(Error.args[0], title="Assertion Error")
            self.parentApp.switchFormPrevious()

        except IndexError:
            pass

        except TypeError:
            pass
Esempio n. 3
0
    def main(self):
        #First page of Form
        F1 = np.Popup(name="Welcome to the Orienteering Calculator")
        NAME = F1.add(np.TitleText, name='Name')
        RANK = F1.add(np.TitleSelectOne,
                      name='Rank',
                      max_height=len(self.options),
                      values=self.options,
                      scroll_exit=True)
        F1.edit()
        self.return_name = NAME.value
        self.return_rank = RANK.get_selected_objects()

        #Second page of Form
        F2 = np.Popup()
        STARTPOINT = F2.add(np.TitleText,
                            name="What is your starting point? >")
        F2.edit()
        self.return_startpoint = STARTPOINT.value

        #Third page of Form
        F3 = np.Popup()
        BEARING1 = F3.add(np.TitleText, name="bearing  1 >")
        DISTANCE1 = F3.add(np.TitleText, name="distance 1 >")
        F3.edit()
        self.return_bearing1 = BEARING1.value
        self.return_distance1 = DISTANCE1.value

        #Fourth page of Form
        F4 = np.Popup()
        BEARING2 = F4.add(np.TitleText, name="bearing  2 >")
        DISTANCE2 = F4.add(np.TitleText, name="distance 2 >")
        F4.edit()
        self.return_bearing2 = BEARING2.value
        self.return_distance2 = DISTANCE2.value

        #Fifth page of Form
        F5 = np.Popup()
        BEARING3 = F5.add(np.TitleText, name="bearing  3 >")
        DISTANCE3 = F5.add(np.TitleText, name="distance 3 >")
        F5.edit()
        self.return_bearing3 = BEARING3.value
        self.return_distance3 = DISTANCE3.value
Esempio n. 4
0
    def interact(self, game, coords, room):
        def on_press():
            game.reactor.f_change = 0
            npyscreen.notify_confirm("TODO flavour text", title="Flux Moderator", editw=1)
            form.editing = False

        form = npyscreen.Popup(name="Flux Panel", color=self.get_color(), lines=6)
        forms.add_standard_handlers(form)
        form.add_widget(
            npyscreen.ButtonPress, when_pressed_function=on_press, name="Dump Boron Moderator (Reduce flux)"
        )
        form.edit()
Esempio n. 5
0
    def interact(self, game, coords, room):
        def vent_max():
            game.reactor.v_change = 10
            npyscreen.notify_confirm(
                "You hear a loud wind in the ductwork above you.\n" "(v_change = 10, Venting temporarily increased!)",
                title="Vent",
                editw=1,
            )
            form.editing = False

        form = npyscreen.Popup(name="Vent Panel", color=self.get_color(), lines=6)
        forms.add_standard_handlers(form)
        reactor.v_change = form.add_widget(npyscreen.ButtonPress, when_pressed_function=vent_max, name="Vent")
        form.edit()
Esempio n. 6
0
 def interact(self, game, coords, room):
     form = npyscreen.Popup(name="Dunk Panel", color=self.get_color(), lines=6)
     forms.add_standard_handlers(form)
     temp = form.add_widget(
         npyscreen.Slider,
         out_of=10,
         step=1,
         lowest=1,
         label=True,
         name="Dunk Slider",
         value=int(game.reactor.d_change),
     )
     form.edit()
     game.reactor.d_change = temp.value
Esempio n. 7
0
 def h_change_value(self, input):
     "Pop up a window in which to select the values for the field"
     self.on_popup_open_callback(self)
     F = npys.Popup(name=self.name)
     l = F.add(npys.wgmultiline.MultiLine,
               values=[self.display_value(x) for x in self.values],
               return_exit=True,
               select_exit=True,
               value=self.value)
     l.cursor_line = self.value
     F.display()
     l.edit()
     self.value = l.value
     self.on_popup_close_callback(self)
Esempio n. 8
0
 def main(self):
     F = np.Popup(name="Choose an option")
     if self.multi:
         opt = F.add(np.TitleMultiSelect,
                     name=self.title,
                     max_height=self.height,
                     values=self.options,
                     scroll_exit=True)
     else:
         opt = F.add(np.TitleSelectOne,
                     name=self.title,
                     max_height=self.height,
                     values=self.options,
                     scroll_exit=True)
     F.edit()
     self._values = opt.get_selected_objects()
     self.result = (self._values if self.multi and len(self._values) > 1
                    else self._values[0])
Esempio n. 9
0
    def switch_wifi_channel(self, args):
        popup_columns: int = len(self.channel_one_select_name) + 25
        popup_lines: int = len(self.wifi_instance.available_wifi_channels) + 4
        if popup_lines > int(3 * self.y // 4):
            popup_lines = int(3 * self.y // 4)

        popup = npyscreen.Popup(name=self.channel_popup_name,
                                columns=popup_columns,
                                lines=popup_lines)
        channels = popup.add(npyscreen.TitleSelectOne,
                             name=self.channel_one_select_name,
                             scroll_exit=True,
                             values=self.wifi_instance.available_wifi_channels)
        popup.edit()
        if len(channels.get_selected_objects()) > 0:
            current_wifi_channel: int = channels.get_selected_objects()[0]
            self.wifi_channel = current_wifi_channel
            self.tm_instance.add_task(self.wifi_instance.set_wifi_channel,
                                      current_wifi_channel)
Esempio n. 10
0
def create_key_lock():
    import npyscreen

    form = npyscreen.Popup(name="code lock")
    cbs = []
    for y in range(0, 3):
        for x in range(0, 3):
            cbs.append(
                form.add_widget(SimpleCheckbox,
                                relx=(x + 1) * 3,
                                rely=(y + 1) * 2,
                                width=3,
                                height=2,
                                editable=True))

    def get_results():
        return [cb.value for cb in cbs]

    return form, get_results