Exemplo n.º 1
0
def render_pos_y_slider(
    id: str,
    pos_y: float,
    mario_pos_y: float,
) -> Tuple[Optional[float], bool]:
    ig.push_id(id)

    ig.text('max y = %.f' % pos_y)
    ig.set_cursor_pos((ig.get_window_width() - 30, ig.get_cursor_pos().y))

    slider_pos = ig.get_cursor_pos()
    slider_width = 20
    slider_height = ig.get_content_region_available().y
    slider_range = range(-8191, 8192)

    mario_icon_x = ig.get_cursor_pos().x
    t = (mario_pos_y - slider_range.start) / len(slider_range)
    mario_icon_y = ig.get_cursor_pos().y + (1 - t) * slider_height
    ig.set_cursor_pos((mario_icon_x, mario_icon_y))
    reset = ig.button('M', width=slider_width)

    ig.set_cursor_pos(slider_pos)
    changed, value = ig.v_slider_float(
        '##slider',
        width=slider_width,
        height=slider_height,
        value=pos_y,
        min_value=slider_range.start,
        max_value=slider_range.stop - 1,
        format='',
    )
    new_y = value if changed else None

    ig.pop_id()
    return new_y, reset
Exemplo n.º 2
0
    def render_right_column(self) -> None:
        total_height = ig.get_window_height()

        if self.show_debug_pane:
            ig.push_id('debug-pane')
            ig.begin_child('##pane', height=int(ig.get_window_height() * 0.15))
            ig.columns(2)
            ig.set_column_width(-1, ig.get_window_width() - 300)

            ig.begin_child('##log')

            def init_log() -> List[str]:
                messages = []
                log.subscribe(lambda msg: messages.append(str(msg)))
                return messages

            messages = use_state_with('messages', init_log).value
            prev_length = use_state('prev-length', 0)
            total_height -= ig.get_window_height()
            if prev_length.value != len(messages):
                prev_length.value = len(messages)
                ig.set_scroll_y(ig.get_scroll_max_y() + ig.get_window_height())
            for message in messages:
                ig.text(message)
            ig.end_child()

            ig.next_column()

            for line in log.timer.format(log.timer.get_summaries()):
                ig.text(line)

            ig.columns(1)
            ig.end_child()
            ig.pop_id()

        log.timer.begin('fsheet')
        frame_sheet = self.frame_sheets[0]
        ig.set_next_window_content_size(frame_sheet.get_content_width(), 0)
        ig.begin_child(
            'Frame Sheet##' + str(epoch) + '-0',
            height=int(total_height * 0.7),
            flags=ig.WINDOW_HORIZONTAL_SCROLLING_BAR,
        )
        frame_sheet.render()
        ig.end_child()

        if ig.begin_drag_drop_target():
            payload = ig.accept_drag_drop_payload('ve-var')
            if payload is not None:
                frame_sheet.append_variable(Variable.from_bytes(payload))
            ig.end_drag_drop_target()
        log.timer.end()

        log.timer.begin('varexp')
        ig.begin_child('Variable Explorer', border=True)
        self.variable_explorer.render('variable-explorer')
        ig.end_child()
        log.timer.end()
Exemplo n.º 3
0
def render_labeled_variable(
    id: str,
    label: str,
    variable: Variable,
    value: T,
    formatter: VariableFormatter,
    is_edited: bool,
    label_width=80,
    value_width=80,
) -> Tuple[Maybe[T], bool]:
    ig.push_id(id)

    ig.selectable(label + '##label', width=label_width)

    if ig.begin_drag_drop_source():
        ig.text(label)
        ig.set_drag_drop_payload('ve-var', variable.to_bytes())
        ig.end_drag_drop_source()

    ig.same_line()

    cell_width = value_width
    cell_height = ig.get_text_line_height(
    ) + 2 * ig.get_style().frame_padding[1]

    cell_cursor_pos = ig.get_cursor_pos()
    cell_cursor_pos = (
        cell_cursor_pos[0] + ig.get_window_position()[0] - ig.get_scroll_x(),
        cell_cursor_pos[1] + ig.get_window_position()[1] - ig.get_scroll_y(),
    )

    changed_data, _, _ = render_variable_value(
        'value',
        value,
        formatter,
        (cell_width, cell_height),
    )

    clear_edit = is_edited and ig.is_item_hovered() and ig.is_mouse_down(2)

    if is_edited:
        dl = ig.get_window_draw_list()
        spacing = ig.get_style().item_spacing
        spacing = (spacing[0] / 2, spacing[1] / 2)
        dl.add_rect(
            cell_cursor_pos[0] - spacing[0],
            cell_cursor_pos[1] - spacing[1],
            cell_cursor_pos[0] + cell_width + spacing[0] - 1,
            cell_cursor_pos[1] + cell_height + spacing[1] - 1,
            ig.get_color_u32_rgba(0.8, 0.6, 0, 1),
        )

    ig.pop_id()
    return changed_data, clear_edit
Exemplo n.º 4
0
def binding_button(name: str, label: str, width=0) -> None:
    listening_for: Ref[Optional[str]] = use_state('listening-for', None)

    controls: Ref[List[str]] = use_state('controls', [])
    controls.value.append(name)

    value = check_input(bindings.get(name))
    color = (0.26 + value * 0.7, 0.59 + value * 0.41, 0.98, 0.4)
    if listening_for.value == name:
        color = (0.86, 0.59, 0.98, 0.4)

    ig.push_style_color(ig.COLOR_BUTTON, *color)
    if ig.button(label, width=width):
        listening_for.value = name
    ig.pop_style_color()

    if ig.begin_popup_context_item('##btn-ctx-' + name):
        if ig.menu_item('Clear')[0] and name in bindings:
            del bindings[name]
        if ig.menu_item('Default')[0] and name in DEFAULT_BINDINGS:
            bindings[name] = DEFAULT_BINDINGS[name]
        ig.end_popup_context_item()

    ig.same_line()
    if name in bindings:
        text = str(bindings[name])
    else:
        text = 'Unbound'
    if listening_for.value == name:
        text = '(' + text + ')'

    if name in bindings:
        overlapping = find_overlapping_bindings().get(bindings[name])
    else:
        overlapping = None

    if overlapping is None:
        ig.text(text)
    else:
        ig.text_colored(text, 1.0, 0.8, 0.0, 1.0)
        if ig.is_item_hovered():

            def control_name(name: str) -> str:
                return name.replace('-', ' ').replace('n64', 'N64')

            overlapping = [c for c in overlapping if c != name]
            ig.set_tooltip('Also bound to ' +
                           ', '.join(map(control_name, overlapping)))
Exemplo n.º 5
0
    def render(id: str) -> None:
        nonlocal error

        if error is not None:
            message = error.strip()
            ig.text('Wafel has crashed. Cause:')
            lines = message.split('\n')
            ig.input_text_multiline(
                '##error-msg',
                message,
                len(message) + 1,
                max(map(len, lines)) * 10,
                (len(lines) + 1) * ig.get_text_line_height() + 6,
            )

            ig.dummy(10, 10)

            if ig.button('Exit'):
                log.info('Aborted')
                sys.exit(1)
            ig.same_line()
            if ig.button('Try to save'):
                if view.ask_save_filename():
                    view.save()
            # ig.same_line()
            # if view is not None and ig.button('Try to continue (mad lads only)'):
            #   view.reload_ui()
            #   error = None
            return

        try:
            if hasattr(model, 'pipeline'):
                log.timer.get_num_copies = lambda: model.pipeline.num_copies(
                ) if config.dev_mode else 0
                log.timer.get_num_updates = lambda: model.pipeline.num_advances(
                ) if config.dev_mode else 0

            log.timer.begin_frame()
            ig.try_render(lambda: do_render(id))
        except:
            error = traceback.format_exc()
            log.error('Caught: ' + error)
        finally:
            log.timer.end_frame()
Exemplo n.º 6
0
    def render_headers(self) -> None:
        header_labels = [
            self.displayer.column_header(column.variable)
            for column in self.columns
        ]
        header_lines = max((len(label.split('\n')) for label in header_labels),
                           default=1)

        ig.columns(len(self.columns) + 1)
        if len(self.columns) > 0:
            ig.set_column_width(-1, self.frame_column_width)
        ig.text('')
        ig.next_column()

        for index, column in enumerate(self.columns):
            initial_cursor_pos = ig.get_cursor_pos()
            ig.selectable(
                '##fs-col-' + str(id(self)) + '-' + str(id(column)),
                height=header_lines * ig.get_text_line_height(),
            )

            # TODO: Width adjusting
            ig.set_column_width(-1, column.width)

            if ig.begin_drag_drop_source():
                ig.text(header_labels[index])
                ig.set_drag_drop_payload('fs-col', str(index).encode('utf-8'))
                ig.end_drag_drop_source()

            if ig.begin_drag_drop_target():
                payload = ig.accept_drag_drop_payload('fs-col')
                if payload is not None:
                    source = int(payload.decode('utf-8'))
                    self._move_column(source, index)

                payload = ig.accept_drag_drop_payload('ve-var')
                if payload is not None:
                    self._insert_variable(index, Variable.from_bytes(payload))

                ig.end_drag_drop_target()

            if ig.is_item_hovered() and ig.is_mouse_clicked(2):
                self._remove_column(index)

            if ig.begin_popup_context_item('##fs-colctx-' + str(id(self)) +
                                           '-' + str(id(column))):
                if ig.selectable('Close')[0]:
                    self._remove_column(index)
                ig.end_popup_context_item()

            ig.set_cursor_pos(initial_cursor_pos)
            ig.text(header_labels[index])

            ig.next_column()
        ig.separator()
        ig.columns(1)
Exemplo n.º 7
0
def render_key_binding_settings(id: str) -> None:
    ig.push_id(id)
    begin_binding_form()

    ig.text('Frame advance:')
    button_width = 0
    binding_button('frame-prev-fast', '-10', button_width)
    binding_button('frame-prev', '-1', button_width)
    binding_button('frame-prev-alt', '-1', button_width)
    binding_button('frame-next', '+1', button_width)
    binding_button('frame-next-alt', '+1', button_width)
    binding_button('frame-next-fast', '+10', button_width)

    ig.dummy(1, 5)

    ig.text('3D movement:')
    button_width = 70
    binding_button('3d-camera-move-f', 'Forward', button_width)
    binding_button('3d-camera-move-b', 'Back', button_width)
    binding_button('3d-camera-move-l', 'Left', button_width)
    binding_button('3d-camera-move-r', 'Right', button_width)
    binding_button('3d-camera-move-u', 'Up', button_width)
    binding_button('3d-camera-move-d', 'Down', button_width)

    ig.dummy(1, 5)

    ig.text('Playback:')
    button_width = 90
    binding_button('playback-play', 'Play', button_width)
    binding_button('playback-rewind', 'Rewind', button_width)
    binding_button('playback-speed-up', 'Speed up', button_width)
    binding_button('playback-slow-down', 'Slow down', button_width)
    ig.text_colored(
        'Tip: Use the frame advance keys\nduring playback to change speed\ntemporarily.',
        1.0,
        1.0,
        1.0,
        0.5,
    )

    ig.dummy(200, 1)
    ig.pop_id()
Exemplo n.º 8
0
  def render_left_column(self, framebuffer_size: Tuple[int, int]) -> None:
    total_height = ig.get_window_height() - ig.get_frame_height() # subtract menu bar
    slider_space = 45

    wall_hitbox_radius = use_state('wall-hitbox-radius', 50)
    wall_hitbox_options = [0, 24, 50, 110]

    hovered_surface: Ref[Optional[int]] = use_state('hovered-surface', None)
    new_hovered_surface: Optional[int] = None
    hidden_surfaces_by_area = \
      use_state('hidden-surfaces', cast(Dict[Tuple[int, int], Set[int]], {})).value

    current_area = (
      dcast(int, self.model.get(Variable('level-num').with_frame(self.model.selected_frame))),
      dcast(int, self.model.get(Variable('area-index').with_frame(self.model.selected_frame))),
    )
    hidden_surfaces = hidden_surfaces_by_area.setdefault(current_area, set())

    log.timer.begin('gview1')
    ig.begin_child(
      'Game View 1',
      height=int(total_height // 2) - slider_space // 2,
      border=True,
    )
    hovered_surface_1 = ui.render_game_view_rotate(
      'game-view-1',
      framebuffer_size,
      self.model,
      wall_hitbox_radius.value,
      hovered_surface.value,
      hidden_surfaces,
    )

    ig.set_cursor_pos((10.0, ig.get_window_height() - 30))
    ig.text('wall radius')
    ig.same_line()
    ig.push_item_width(50)
    _, index = ig.combo(
      '##wall-hitbox-radius',
      wall_hitbox_options.index(wall_hitbox_radius.value),
      list(map(str, wall_hitbox_options)),
    )
    wall_hitbox_radius.value = wall_hitbox_options[index]
    ig.pop_item_width()

    ig.end_child()
    log.timer.end()

    log.timer.begin('gview2')
    ig.begin_child(
      'Game View 2',
      height=int(total_height // 2) - slider_space // 2,
      border=True,
    )
    hovered_surface_2 = ui.render_game_view_birds_eye(
      'game-view-2',
      framebuffer_size,
      self.model,
      wall_hitbox_radius.value,
      hovered_surface.value,
      hidden_surfaces,
    )
    ig.end_child()
    log.timer.end()

    new_hovered_surface = hovered_surface_1 or hovered_surface_2
    if new_hovered_surface is not None and ig.is_mouse_clicked(1):
      ig.open_popup('surface-ctx')
      hovered_surface.value = new_hovered_surface

    if ig.begin_popup('surface-ctx'):
      if hovered_surface.value is not None:
        if hovered_surface.value in hidden_surfaces:
          if ig.menu_item('Show')[0]:
            hidden_surfaces.remove(hovered_surface.value)
        else:
          if ig.menu_item('Hide')[0]:
            hidden_surfaces.add(hovered_surface.value)
        if ig.menu_item('Properties')[0]:
          self.variable_explorer.open_surface_tab(hovered_surface.value)
      ig.end_popup()
    else:
      hovered_surface.value = new_hovered_surface

    if hovered_surface.value is not None and ig.is_mouse_clicked(2):
      if hovered_surface.value in hidden_surfaces:
        hidden_surfaces.remove(hovered_surface.value)
      else:
        hidden_surfaces.add(hovered_surface.value)


    speed_options = [0.05, 0.25, 0.5, 1, 2, 4]
    saved_play_direction = use_state('saved-play-direction', 0)
    saved_speed_index = use_state('saved-speed-index', 3)

    play_direction = saved_play_direction.value
    speed_index = saved_speed_index.value

    if play_direction == 0:
      frame_advance = 0
      play_override = 0

      def control(name: str, speed: int) -> None:
        nonlocal frame_advance, play_override
        x = input_down_gradual(name, 0.25)
        if x == 1.0:
          play_override = speed
        elif input_pressed(name):
          frame_advance += speed
      control('frame-next', 1)
      control('frame-next-alt', 1)
      control('frame-prev', -1)
      control('frame-prev-alt', -1)
      control('frame-next-fast', 10)
      control('frame-prev-fast', -10)

      if play_override != 0:
        if abs(play_override) in speed_options:
          speed_index = speed_options.index(abs(play_override))
        else:
          speed_index = len(speed_options) - 1
        play_direction = 1 if play_override > 0 else -1
      else:
        self.model.selected_frame += frame_advance

    else:
      if input_down('frame-next') or input_down('frame-next-alt'):
        if play_direction == 1:
          speed_index += 1
        else:
          play_direction = -play_direction
      elif input_down('frame-prev') or input_down('frame-prev-alt'):
        if play_direction == -1:
          speed_index += 1
        else:
          play_direction = -play_direction
      elif input_down('frame-next-fast'):
        if play_direction == 1:
          speed_index += 2
        else:
          play_direction = -play_direction
          speed_index += 1
      elif input_down('frame-prev-fast'):
        if play_direction == -1:
          speed_index += 2
        else:
          play_direction = -play_direction
          speed_index += 1
      speed_index = min(max(speed_index, 0), len(speed_options) - 1)

    self.model.play_speed = play_direction * speed_options[speed_index]
    self.model.playback_mode = saved_play_direction.value != 0

    def play_button(label: str, direction: int) -> None:
      disabled = play_direction == direction
      if ig.disableable_button(label, enabled=play_direction != direction):
        saved_play_direction.value = direction

    play_button('<|', -1)
    ig.same_line()
    play_button('||', 0)
    ig.same_line()
    play_button('|>', 1)
    ig.same_line()

    ig.push_item_width(63)
    changed, new_index = ig.combo(
      '##speed-option',
      speed_index,
      [str(s) + 'x' for s in speed_options],
    )
    ig.pop_item_width()
    if changed:
      saved_speed_index.value = new_index

    if input_pressed('playback-play'):
      if saved_play_direction.value == 0:
        saved_play_direction.value = 1
      else:
        saved_play_direction.value = 0
    if input_pressed('playback-rewind'):
      if saved_play_direction.value == 0:
        saved_play_direction.value = -1
      else:
        saved_play_direction.value = 0
    if input_pressed('playback-speed-up'):
      saved_speed_index.value = min(saved_speed_index.value + 1, len(speed_options) - 1)
    if input_pressed('playback-slow-down'):
      saved_speed_index.value = max(saved_speed_index.value - 1, 0)


    ig.same_line()
    new_frame = ui.render_frame_slider(
      'frame-slider',
      self.model.selected_frame,
      self.model.max_frame - 1,
      self.model.pipeline.cached_frames() if self.show_debug_pane else [],
    )
    if new_frame is not None:
      self.model.selected_frame = new_frame.value
Exemplo n.º 9
0
def render_game_view_birds_eye(
    id: str,
    framebuffer_size: Tuple[int, int],
    model: Model,
    wall_hitbox_radius: float,
    hovered_surface: Optional[int],
    hidden_surfaces: Set[int],
) -> Optional[int]:
    ig.push_id(id)

    # TODO: Should zoom in on mouse when uncentered
    mouse_state = use_state('mouse-state', MouseTracker()).value
    zoom = use_state('zoom', -4.5)
    target: Ref[Optional[Tuple[float, float]]] = use_state('target', None)
    pos_y: Ref[Optional[float]] = use_state('pos-y', None)

    drag_amount = mouse_state.get_drag_amount()
    zoom.value += mouse_state.get_wheel_amount() / 5
    world_span_x = 200 / math.pow(2, zoom.value)

    viewport = get_viewport(framebuffer_size)

    mario_pos = get_mario_pos(model)

    # Camera xz

    camera_xz = (mario_pos[0], mario_pos[2])
    if target.value is not None:
        camera_xz = target.value

    if drag_amount != (0.0, 0.0):
        world_span_z = world_span_x * viewport.width / viewport.height
        if target.value is None:
            target.value = (mario_pos[0], mario_pos[2])
        target.value = (
            camera_xz[0] + drag_amount[1] * world_span_x / viewport.height,
            camera_xz[1] - drag_amount[0] * world_span_z / viewport.width,
        )
        camera_xz = target.value

    if ig.disableable_button('Lock to Mario', enabled=target.value
                             is not None):
        target.value = None

    # Camera y

    camera_y = mario_pos[1] + 500 if pos_y.value is None else pos_y.value

    ig.set_cursor_pos((viewport.width - 100, 10))
    ig.begin_child('##y-slider')
    new_y, reset = render_pos_y_slider('y-slider', camera_y, mario_pos[1])
    if reset:
        pos_y.value = None
    elif new_y is not None:
        pos_y.value = new_y
        camera_y = pos_y.value
    ig.end_child()

    camera = core.BirdsEyeCamera()
    camera.pos = (camera_xz[0], camera_y, camera_xz[1])
    camera.span_y = world_span_x

    # Mouse xz
    mouse_world_pos = get_mouse_world_pos_birds_eye(camera)
    mouse_ray: Optional[Tuple[Vec3f, Vec3f]]
    if mouse_world_pos is not None:
        ig.set_cursor_pos((10, viewport.height - 25))
        ig.text('(x, z) = (%.3f, %.3f)' % mouse_world_pos)
        mouse_ray = ((mouse_world_pos[0], camera.pos[1], mouse_world_pos[1]),
                     (0, -1, 0))
    else:
        mouse_ray = None

    if mouse_ray is None:
        new_hovered_surface = None
    else:
        new_hovered_surface = trace_ray(model, mouse_ray)

    render_game(
        model,
        viewport,
        camera,
        False,
        wall_hitbox_radius,
        hovered_surface=hovered_surface,
        hidden_surfaces=hidden_surfaces,
    )

    ig.pop_id()
    return new_hovered_surface
Exemplo n.º 10
0
 def show_text(text: str) -> None:
     ig.text('    ' * indent + text)
Exemplo n.º 11
0
    def render_intended_stick_control(self, id: str) -> None:
        up_options = ['3d view', 'mario yaw', 'stick y', 'world x']
        up_option = use_state('up-option', 0)

        ig.text('up =')
        ig.same_line()
        ig.push_item_width(100)
        _, up_option.value = ig.combo('##up-option', up_option.value,
                                      up_options)
        ig.pop_item_width()
        ig.dummy(1, 10)

        stick_x_var = Variable('input-stick-x').with_frame(
            self.model.selected_frame)
        stick_y_var = Variable('input-stick-y').with_frame(
            self.model.selected_frame)

        face_yaw = dcast(
            int,
            self.model.get(
                Variable('mario-face-yaw').with_frame(
                    self.model.selected_frame)))
        camera_yaw = dcast(
            int,
            self.model.get(
                Variable('camera-yaw').with_frame(self.model.selected_frame))
            or 0)
        squish_timer = dcast(
            int,
            self.model.get(self.model.selected_frame,
                           'gMarioState->squishTimer'))
        active_face_yaw = face_yaw

        events = self.model.pipeline.frame_log(self.model.selected_frame + 1)

        active_face_yaw_action = None
        for event in events:
            if event['type'] == 'FLT_EXECUTE_ACTION':
                action_name = self.model.action_names[event['action']]
                active_face_yaw = event['faceAngle'][1]
                active_face_yaw_action = action_name
                if action_name == 'idle':
                    break

        up_angle = {
            'mario yaw': active_face_yaw,
            'stick y': camera_yaw + 0x8000,
            'world x': 0x4000,
            '3d view': self.model.rotational_camera_yaw,
        }[up_options[up_option.value]]
        self.model.input_up_yaw = up_angle

        raw_stick_x = dcast(int, self.model.get(stick_x_var))
        raw_stick_y = dcast(int, self.model.get(stick_y_var))

        adjusted = stick_raw_to_adjusted(raw_stick_x, raw_stick_y)
        intended = stick_adjusted_to_intended(
            adjusted,
            face_yaw,
            camera_yaw,
            squish_timer != 0,
        )

        def render_value(label: str, value: object,
                         formatter: VariableFormatter) -> Optional[Any]:
            label_width = 60
            value_size = (
                60 if label == 'dyaw' else 80,
                ig.get_text_line_height() +
                2 * ig.get_style().frame_padding[1],
            )
            ig.push_item_width(label_width)
            ig.selectable(label, width=label_width)
            ig.pop_item_width()
            ig.same_line()
            new_value, _, _ = ui.render_variable_value('value-' + label, value,
                                                       formatter, value_size)
            return None if new_value is None else new_value.value

        target_yaw: Optional[int] = None
        target_dyaw: Optional[int] = None
        target_mag: Optional[float] = None

        target_mag = render_value('int mag', intended.mag, FloatFormatter())
        target_yaw = render_value('int yaw', intended.yaw,
                                  DecimalIntFormatter())
        dyaw = intended.yaw - active_face_yaw
        target_dyaw = render_value('dyaw', dyaw, DecimalIntFormatter())

        ig.same_line()
        if ig.button('?'):
            ig.open_popup('active-yaw-expl')
        if ig.begin_popup('active-yaw-expl'):
            ig.text(f'{intended.yaw} - {active_face_yaw} = {dyaw}')
            ig.text(f'intended yaw = {intended.yaw}')
            if active_face_yaw == face_yaw:
                ig.text(f'face yaw = {face_yaw}')
            if active_face_yaw != face_yaw:
                ig.text(
                    f'face yaw = {active_face_yaw} at start of {active_face_yaw_action} action'
                )
                ig.text(f'(face yaw = {face_yaw} at start of frame)')
            ig.end_popup()

        if dyaw not in range(0, 16):
            if ig.button('dyaw = 0'):
                target_dyaw = 0

        if target_yaw is not None or target_dyaw is not None or target_mag is not None:
            relative_to = 0 if target_yaw is not None else active_face_yaw
            if target_dyaw is not None:
                target_yaw = active_face_yaw + target_dyaw
            if target_yaw is None:
                target_yaw = intended.yaw
            if target_mag is None:
                target_mag = intended.mag

            new_raw_stick_x, new_raw_stick_y = intended_to_raw(
                face_yaw, camera_yaw, squish_timer, target_yaw, target_mag,
                relative_to)

            self.model.set(stick_x_var, new_raw_stick_x)
            self.model.set(stick_y_var, new_raw_stick_y)

        n_a = intended.yaw - up_angle
        n_x = intended.mag / 32 * math.sin(-n_a * math.pi / 0x8000)
        n_y = intended.mag / 32 * math.cos(n_a * math.pi / 0x8000)

        ig.set_cursor_pos((ig.get_cursor_pos().x + 155, 0))
        new_n = ui.render_joystick_control(id, n_x, n_y, 'circle')

        if new_n is not None:
            new_n_a = int(math.atan2(-new_n[0], new_n[1]) * 0x8000 / math.pi)
            new_intended_yaw = up_angle + new_n_a
            new_intended_mag = 32 * math.sqrt(new_n[0]**2 + new_n[1]**2)

            new_raw_stick_x, new_raw_stick_y = intended_to_raw(
                face_yaw,
                camera_yaw,
                squish_timer,
                new_intended_yaw,
                new_intended_mag,
                relative_to=0)

            self.model.set(stick_x_var, new_raw_stick_x)
            self.model.set(stick_y_var, new_raw_stick_y)