"""The Camera speed row (host/prompts.c build_camera, nx2/prompt_assets.py CAMERA). The game's five camera sensitivities are five floats in a BYML file inside its camera pack. Setup's Update writes the pack decompressed and a table of where the floats are; at the start the host serves the pack with each one times the row's factor. Checked here, without the game: - The table: each float of the StickSensitivity array, at its place in the pack, with the game's value; other arrays and other files of the pack are left out. - A pack that is not the one known gives no table: no such file, no such array, an array of something else than floats, a value that is no speed. - The host's and the menu's ends are wired: the pack's path, the row, its key in the options file, the mouse. python -I -B tests/test_camera_speed.py """ import struct import sys import tempfile import unittest from pathlib import Path ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT / "nx2")) import prompt_assets # noqa: E402 RATES = (1.2, 1.6, 2.0, 2.4, 3.0) def byml(entries): """a little-endian BYML whose root dictionary holds entries: [(key, value)], a value a float, or a list of floats (an array), or a list of ints (an array of ints)""" names = sorted(k for k, _ in entries) keys = bytearray(struct.pack(" 300 ? 300 : v;", prompts) menu = (ROOT / "gpu/vk/vk_menu.cpp").read_text(encoding="utf-8") self.assertIn('{TAB_CONTROLS, "Camera speed", &opts.camera_speed, 25, 300, 5, tx_sens,', menu) hid = (ROOT / "host/nn_hid.c").read_text(encoding="utf-8") self.assertIn("ox /= cam, oy /= cam;", hid) if __name__ == "__main__": unittest.main()