Etterna 0.74.4
Loading...
Searching...
No Matches
MusicWheel.h
1/* MusicWheel - A wheel with song names used in the Select Music screen. */
2
3#ifndef MUSIC_WHEEL_H
4#define MUSIC_WHEEL_H
5
6#include "Etterna/Models/Misc/GameConstantsAndTypes.h"
7#include "MusicWheelItem.h"
8#include "RageUtil/Sound/RageSound.h"
9#include "Etterna/Models/Misc/ThemeMetric.h"
10#include "WheelBase.h"
11
12class Song;
13
14struct CompareSongPointerArrayBySectionName;
15
16class MusicWheel : public WheelBase
17{
18 friend struct CompareSongPointerArrayBySectionName;
19
20 public:
21 MusicWheel();
22 ~MusicWheel() override = default;
23 void Load(const std::string& sType) override;
24 void BeginScreen();
25
26 auto ChangeSort(SortOrder new_so,
27 bool allowSameSort = false)
28 -> bool; // return true if change successful
29 auto NextSort() -> bool; // return true if change successful
30 auto IsRouletting() const -> bool;
31
32 auto Select()
33 -> bool override; // return true if this selection ends the screen
34 auto GetSelectedType() -> WheelItemDataType
35 {
36 return GetCurWheelItemData(m_iSelection)->m_Type;
37 }
38 auto GetSelectedSong() -> Song*;
39 auto GetSelectedSection() -> std::string
40 {
41 return GetCurWheelItemData(m_iSelection)->m_sText;
42 }
43
44 auto GetPreferredSelectionForRandomOrPortal() -> Song*;
45
46 auto SelectSong(const Song* p) -> bool;
47 auto SelectSection(const std::string& SectionName) -> bool;
48 void SetOpenSection(const std::string& group) override;
49 void ChangeMusic(int dist) override; /* +1 or -1 */ // CHECK THIS
50 void FinishChangingSorts();
51 void PlayerJoined();
52 // sm-ssc additions
53 auto JumpToNextGroup() -> std::string;
54 auto JumpToPrevGroup() -> std::string;
55 auto GetCurWheelItemData(int i) -> const MusicWheelItemData*
56 {
57 return dynamic_cast<const MusicWheelItemData*>(m_CurWheelItemData[i]);
58 }
59
60 void ReloadSongList(bool searching, const std::string& findme) override;
61 void SetHashList(const std::vector<std::string>& newHashList);
62 void SetOutHashList(const std::vector<std::string>& newOutHashList);
63
64 // multiplayer common pack filtering
65 bool packlistFiltering{ false };
66
67 std::vector<Song*> allSongsFiltered;
68 // all songs by sort order by group also filtered
69 std::vector<std::map<std::string, std::vector<Song*>>>
70 allSongsByGroupFiltered{ NUM_SortOrder };
71 // song grade progress by group
72 std::vector<std::map<std::string, int>> packProgressByGroup{
73 NUM_SortOrder
74 };
75 auto SelectSongOrCourse() -> bool;
76 void SelectSongAfterSearch();
77
78 // Lua
79 void PushSelf(lua_State* L) override;
80
81 protected:
82 auto MakeItem() -> MusicWheelItem* override;
83
84 std::vector<std::string> hashList;
85 std::vector<std::string> outHashList;
86
87 void GetSongList(std::vector<Song*>& arraySongs, SortOrder so) const;
88 auto SelectModeMenuItem() -> bool;
89
90 void FilterByAndAgainstStepKeys(std::vector<Song*>& inv);
91 void FilterBySearch(std::vector<Song*>& inv, std::string findme_);
92 auto SearchGroupNames(const std::string& findme) -> bool;
93 static void FilterBySkillsets(std::vector<Song*>& inv);
94 std::string lastvalidsearch;
95 std::string groupnamesearchmatch;
96
97 void UpdateSwitch() override;
98
99 auto getWheelItemsData(SortOrder so) -> std::vector<MusicWheelItemData*>&;
100 void readyWheelItemsData(SortOrder so,
101 bool searching,
102 const std::string& findme);
103
104 std::string m_sLastModeMenuItem;
105 RageSound m_soundChangeSort;
106
107 auto WheelItemIsVisible(int n) -> bool;
108
109 ThemeMetric<int> ROULETTE_SLOW_DOWN_SWITCHES;
110 ThemeMetric<int> NUM_SECTION_COLORS;
111 ThemeMetric<RageColor> SORT_MENU_COLOR;
112 ThemeMetric<std::string> MODE_MENU_CHOICE_NAMES;
114 ThemeMetric1D<RageColor> SECTION_COLORS;
115 ThemeMetric<LuaReference> SORT_ORDERS;
116 // sm-ssc additions:
117 ThemeMetric<bool> USE_SECTIONS_WITH_PREFERRED_GROUP;
118 ThemeMetric<bool> HIDE_INACTIVE_SECTIONS;
119 ThemeMetric<bool> HIDE_ACTIVE_SECTION_TITLE;
120 ThemeMetric<bool> REMIND_WHEEL_POSITIONS;
121 ThemeMetric<RageColor> EMPTY_COLOR;
122 std::vector<int> m_viWheelPositions;
123 ThemeMetric<std::string> CUSTOM_WHEEL_ITEM_NAMES;
124 ThemeMetricMap<std::string> CUSTOM_CHOICES;
125 ThemeMetricMap<RageColor> CUSTOM_CHOICE_COLORS;
126
127 private:
128 // use getWheelItemsData instead of touching this one
129 enum
130 {
131 INVALID,
132 NEEDREFILTER,
133 VALID
134 } m_WheelItemDatasStatus[NUM_SortOrder]{};
135 // Stores pointers owned by m__UnFilteredWheelItemDatas
136 // This is fine because whenever m__UnFilteredWheelItemDatas is updated we
137 // then also update m__WheelItemDatas
138 std::vector<MusicWheelItemData*> m__WheelItemDatas[NUM_SortOrder];
139 std::vector<std::unique_ptr<MusicWheelItemData>> m__UnFilteredWheelItemDatas[NUM_SortOrder];
140
141 // this should be freed automatically because it is owned by m__UnFilteredWheelItemDatas
142 MusicWheelItemData* m_nearestCompatibleWheelItemData = nullptr;
143
144 void BuildWheelItemDatas(
145 std::vector<std::unique_ptr<MusicWheelItemData>>& arrayWheelItemDatas,
146 SortOrder so,
147 bool searching,
148 const std::string& findme);
149
150 // filter the wheel item data
151 // returns the new pointer to the previously selected wheel item data
152 // if the previously selected one doesnt exist, dont care
153 MusicWheelItemData* FilterWheelItemDatas(
154 std::vector<std::unique_ptr<MusicWheelItemData>>& aUnFilteredDatas,
155 std::vector<MusicWheelItemData*>& aFilteredData,
156 const Song* currentSong,
157 const std::string& currentText,
158 const WheelItemDataType& currentType) const;
159};
160
161#endif
An item on the MusicWheel.
Definition MusicWheelItem.h:33
Definition MusicWheel.h:17
Definition RageSound.h:130
Holds all music metadata and steps for one song.
Definition Song.h:65
Definition ThemeMetric.h:192
Definition ThemeMetric.h:276
The theme specific data.
Definition ThemeMetric.h:52
A wheel with data elements.
Definition WheelBase.h:35
Definition MusicWheelItem.h:62