Issues190nsTests.inc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // Round 190ns: GitHub issues #231 (Project info › Created), #233 (offline), #234 (Manage shortcuts link), #235 (linked
  2. // track and mixer track colours).
  3. #include "core/PlaylistOps.h"
  4. namespace issues190ns
  5. {
  6. // Song::makeDefault with an audio track linked to a new mixer track (FL's Track mode › Audio track)
  7. inline lynx::Song songWithAudioTrack (int& track, int& mixer)
  8. {
  9. using namespace lynx;
  10. auto song = Song::makeDefault();
  11. song.playlistTracks.resize (4);
  12. track = 2;
  13. song.playlistTracks[2].name = "Vocals";
  14. song.playlistTracks[2].colour = 0xff8040c0;
  15. CHECK (trackmodes::makeAudioTrack (song, track));
  16. mixer = song.playlistTracks[2].mixerTrack;
  17. return song;
  18. }
  19. } // namespace issues190ns
  20. // #235 (FL 2026 [DECOMP] FUN_012e60f0 → FUN_012e6010): the Playlist track's Rename / color gives its mixer track the same
  21. // name and colour
  22. TEST (issues190ns_recoloured_audio_track_recolours_its_mixer_track)
  23. {
  24. using namespace lynx;
  25. int track = -1, mixer = -1;
  26. auto song = issues190ns::songWithAudioTrack (track, mixer);
  27. CHECK (mixer > 0);
  28. // the link itself: one name and colour
  29. CHECK (song.mixer[(std::size_t) mixer].colour == 0xff8040c0 && song.mixer[(std::size_t) mixer].name == "Vocals");
  30. auto before = trackmodes::linkedNames (song);
  31. song.playlistTracks[(std::size_t) track].colour = 0xff20a050;
  32. song.playlistTracks[(std::size_t) track].name = "Lead vox";
  33. CHECK (trackmodes::followLinkedNames (song, before) == 1);
  34. CHECK (song.mixer[(std::size_t) mixer].colour == 0xff20a050);
  35. CHECK (song.mixer[(std::size_t) mixer].name == "Lead vox");
  36. // a track back to the default colour and no name: the mixer track's default colour, "Insert N"
  37. before = trackmodes::linkedNames (song);
  38. song.playlistTracks[(std::size_t) track].colour = 0;
  39. song.playlistTracks[(std::size_t) track].name.clear();
  40. trackmodes::followLinkedNames (song, before);
  41. CHECK (song.mixer[(std::size_t) mixer].colour == 0u);
  42. CHECK (song.mixer[(std::size_t) mixer].name == "Insert " + std::to_string (mixer));
  43. }
  44. // #235 (FUN_012be6f0 → FUN_012a7810): the mixer track's Rename / color reaches the Playlist track linked to it
  45. TEST (issues190ns_recoloured_mixer_track_recolours_its_audio_track)
  46. {
  47. using namespace lynx;
  48. int track = -1, mixer = -1;
  49. auto song = issues190ns::songWithAudioTrack (track, mixer);
  50. const auto before = trackmodes::linkedNames (song);
  51. song.mixer[(std::size_t) mixer].colour = 0xffc03030;
  52. song.mixer[(std::size_t) mixer].name = "Bus";
  53. CHECK (trackmodes::followLinkedNames (song, before) == 1);
  54. CHECK (song.playlistTracks[(std::size_t) track].colour == 0xffc03030);
  55. CHECK (song.playlistTracks[(std::size_t) track].name == "Bus");
  56. // an edit that sets both sides (a new link) and other inserts / unassigned tracks are left alone
  57. auto again = trackmodes::linkedNames (song);
  58. song.mixer[(std::size_t) mixer].colour = 0xff111111;
  59. song.playlistTracks[(std::size_t) track].colour = 0xff222222;
  60. const auto otherColour = song.mixer[1].colour;
  61. song.playlistTracks[0].colour = 0xff333333; // unassigned
  62. CHECK (trackmodes::followLinkedNames (song, again) == 0);
  63. CHECK (song.mixer[(std::size_t) mixer].colour == 0xff111111 && song.playlistTracks[(std::size_t) track].colour == 0xff222222);
  64. CHECK (song.mixer[1].colour == otherColour);
  65. // instrument tracks are not FL-synced (FUN_012e6010 checks for an audio track)
  66. auto inst = Song::makeDefault();
  67. inst.playlistTracks.resize (2);
  68. CHECK (trackmodes::makeInstrumentTrack (inst, 1, 0));
  69. CHECK (trackmodes::linkedNames (inst).pairs.empty());
  70. }
  71. // #235: LYNX's "Link Playlist tracks to mixer tracks": after switching it on every linked pair carries one colour
  72. TEST (issues190ns_switching_the_link_on_leaves_one_colour_per_pair)
  73. {
  74. using namespace lynx;
  75. auto song = Song::makeDefault();
  76. for (int c = 0; c < (int) song.channels.size(); ++c)
  77. song.channels[(std::size_t) c].colour = 0xff000000u | (std::uint32_t) (0x203040 * (c + 1));
  78. for (int c = 0; c < 3 && c < (int) song.patterns.size(); ++c)
  79. {
  80. Clip p;
  81. p.track = c;
  82. p.pattern = c;
  83. p.length = 384;
  84. song.playlist.push_back (p);
  85. }
  86. for (int m = 1; m < (int) song.mixer.size(); ++m) // inserts with colours of their own, tracks with the default
  87. song.mixer[(std::size_t) m].colour = 0xff000000u | (std::uint32_t) (0x102030 * m);
  88. autolink::setOn (song, true);
  89. int pairs = 0;
  90. for (int t = 0; t < (int) song.playlistTracks.size(); ++t)
  91. if (const auto m = autolink::linkedInsertOf (song, t); m > 0 && m < (int) song.mixer.size())
  92. {
  93. std::printf (" track %d -> insert %d: %08x / %08x\n", t, m, song.playlistTracks[(std::size_t) t].colour, song.mixer[(std::size_t) m].colour);
  94. CHECK (song.playlistTracks[(std::size_t) t].colour == song.mixer[(std::size_t) m].colour);
  95. CHECK (song.mixer[(std::size_t) m].colour != 0u);
  96. ++pairs;
  97. }
  98. CHECK (pairs > 0);
  99. }
  100. // #235: a project saved with the switch on whose linked track has the default colour and its insert a colour (the
  101. // reporter's purple insert under a grey header) shows one colour when opened; switch off or two own colours: untouched
  102. TEST (issues190ns_open_matches_linked_colours_while_the_switch_is_on)
  103. {
  104. using namespace lynx;
  105. int track = -1, mixer = -1;
  106. auto song = issues190ns::songWithAudioTrack (track, mixer);
  107. song.playlistTracks[(std::size_t) track].colour = 0;
  108. song.mixer[(std::size_t) mixer].colour = 0xff7a4bd1;
  109. auto off = song;
  110. CHECK (autolink::matchLinkedColours (off) == 0 && off.playlistTracks[(std::size_t) track].colour == 0);
  111. song.linkTracksToMixer = true;
  112. CHECK (autolink::matchLinkedColours (song) == 1);
  113. CHECK (song.playlistTracks[(std::size_t) track].colour == 0xff7a4bd1);
  114. // the other way: the track's colour reaches an insert with the default one
  115. song.mixer[(std::size_t) mixer].colour = 0;
  116. song.playlistTracks[(std::size_t) track].colour = 0xff3fa66b;
  117. CHECK (autolink::matchLinkedColours (song) == 1 && song.mixer[(std::size_t) mixer].colour == 0xff3fa66b);
  118. // two colours of their own: left alone
  119. song.mixer[(std::size_t) mixer].colour = 0xff112233;
  120. CHECK (autolink::matchLinkedColours (song) == 0 && song.playlistTracks[(std::size_t) track].colour == 0xff3fa66b);
  121. }