Etterna 0.74.4
Loading...
Searching...
No Matches
NoteField.h
1#ifndef NOTE_FIELD_H
2#define NOTE_FIELD_H
3
4#include "Etterna/Actor/Base/ActorFrame.h"
5#include "Etterna/Actor/Base/BitmapText.h"
6#include "Etterna/Actor/Gameplay/GhostArrowRow.h"
7#include "Etterna/Actor/Gameplay/NoteDisplay.h"
8#include "Etterna/Actor/Base/Quad.h"
9#include "Etterna/Actor/Gameplay/ReceptorArrowRow.h"
10#include "Etterna/Actor/Base/Sprite.h"
11
12class NoteData;
14class NoteField : public ActorFrame
15{
16 public:
17 NoteField();
18 ~NoteField() override;
19 void Update(float fDeltaTime) override;
20 void DrawPrimitives() override;
21 void CalcPixelsBeforeAndAfterTargets();
22 void DrawBoardPrimitive();
23
24 void Init(PlayerState* pPlayerState,
25 float fYReverseOffsetPixels,
26 bool use_states_zoom = true);
27 void Load(const NoteData* pNoteData,
28 int iDrawDistanceAfterTargetsPixels,
29 int iDrawDistanceBeforeTargetsPixels);
30 void Unload();
31
32 virtual void ensure_note_displays_have_skin();
33 void InitColumnRenderers();
34
35 void HandleMessage(const Message& msg) override;
36
37 // This is done automatically by Init(), but can be re-called explicitly if
38 // the note skin changes.
39 void CacheAllUsedNoteSkins();
40 void FadeToFail();
41
42 void Step(int col, TapNoteScore score, bool from_lua = false) const;
43 void SetPressed(int col, bool from_lua = false) const;
44 void DidTapNote(int col,
45 TapNoteScore score,
46 bool bright,
47 bool from_lua = false) const;
48 void DidHoldNote(int col,
49 HoldNoteScore score,
50 bool bright,
51 bool from_lua = false) const;
52
53 void PushSelf(lua_State* L) override;
54
55 void SetShowBeatBars(bool b) { showBeatBars = b; }
56 void SetShowIntervalBars(bool b) { showCalcBars = b; }
57
58 // Allows the theme to modify the parameters to Step, SetPressed,
59 // DidTapNote, and DidHoldNote before they pass on to the ghost arrows or
60 // receptors. -Kyz
61 LuaReference m_StepCallback;
62 LuaReference m_SetPressedCallback;
63 LuaReference m_DidTapNoteCallback;
64 LuaReference m_DidHoldNoteCallback;
65
66 [[nodiscard]] auto GetPlayerState() const -> const PlayerState*
67 {
68 return m_pPlayerState;
69 }
70
71 int m_iBeginMarker, m_iEndMarker; // only used with MODE_EDIT
72
73 // m_ColumnRenderers belongs in the protected section, but it's here in
74 // public so that the Lua API can access it. -Kyz
75 std::vector<NoteColumnRenderer> m_ColumnRenderers;
76
77 protected:
78 void CacheNoteSkin(const std::string& sNoteSkin);
79 void UncacheNoteSkin(const std::string& sNoteSkin);
80
81 void DrawBoard(int iDrawDistanceAfterTargetsPixels,
82 int iDrawDistanceBeforeTargetsPixels);
83
84 enum BeatBarType
85 {
86 measure,
87 beat,
88 half_beat,
89 quarter_beat
90 };
91 void DrawBeatBar(float fBeat, BeatBarType type, int iMeasureIndex);
92 void DrawCalcIntervalBar(const float fBeat);
93 void DrawMarkerBar(int fBeat);
94 void DrawAreaHighlight(int iStartBeat, int iEndBeat);
95 void set_text_measure_number_for_draw(float beat,
96 float side_sign,
97 float x_offset,
98 float horiz_align,
99 const RageColor& color,
100 const RageColor& glow);
101 void draw_timing_segment_text(const std::string& text,
102 float beat,
103 float side_sign,
104 float x_offset,
105 float horiz_align,
106 const RageColor& color,
107 const RageColor& glow);
108 void DrawBGChangeText(float beat,
109 const std::string& new_bg_name,
110 const RageColor& glow);
111 [[nodiscard]] auto GetWidth() const -> float;
112
113 const NoteData* m_pNoteData;
114
115 PlayerState* m_pPlayerState;
116 int m_iDrawDistanceAfterTargetsPixels; // this should be a negative number
117 int m_iDrawDistanceBeforeTargetsPixels; // this should be a positive number
118 float m_fYReverseOffsetPixels;
119 bool showCalcBars = false;
120 bool showBeatBars = false;
121
122 // This exists so that the board can be drawn underneath combo/judge. -Kyz
123 bool m_drawing_board_primitive;
124
125 // color arrows
127 {
128 NoteDisplay* display;
129 ReceptorArrowRow m_ReceptorArrowRow;
130 GhostArrowRow m_GhostArrowRow;
131 explicit NoteDisplayCols(int iNumCols)
132 {
133 display = new NoteDisplay[iNumCols];
134 }
135
136 ~NoteDisplayCols() { delete[] display; }
137 };
138
139 NoteFieldRenderArgs m_FieldRenderArgs;
140
141 /* All loaded note displays, mapped by their name. */
142 std::map<std::string, NoteDisplayCols*> m_NoteDisplays;
143 NoteDisplayCols* m_pCurDisplay;
144 // leaving this here in case we want to vectorize this in the future
145 // the purpose is to have a display for each player
146 // this pointer does not get deleted
147 // why: it points to a member of m_NoteDisplays which is managed
148 // (same for m_pCurDisplay)
149 NoteDisplayCols* m_pDisplays;
150
151 // decorations, mostly used in MODE_EDIT
152 AutoActor m_sprBoard; // "underlay"
153 AutoActor m_sprCover; // "overlay"
154 float m_fBoardOffsetPixels;
155 float m_fCurrentBeatLastUpdate; // -1 on first update
156 float m_fYPosCurrentBeatLastUpdate; // -1 on first update
157
158 Sprite m_sprBeatBars; // 4 frames: Measure, 4th, 8th, 16th
159 BitmapText m_textMeasureNumber;
160 Quad m_rectMarkerBar;
161 Quad m_rectAreaHighlight;
162};
163
164#endif
A container for other Actors.
Definition ActorFrame.h:8
A smart pointer for Actor.
Definition AutoActor.h:13
An actor that holds a Font and draws text to the screen.
Definition BitmapText.h:11
Row of GhostArrow Actors.
Definition GhostArrowRow.h:11
A self-cleaning Lua reference.
Definition LuaReference.h:10
Holds data about the notes that the player is supposed to hit.
Definition NoteData.h:43
Draws TapNotes and HoldNotes.
Definition NoteDisplay.h:205
An Actor that renders NoteData.
Definition NoteField.h:15
void DrawPrimitives() override
Draw the primitives of the Actor.
Definition NoteField.cpp:720
The player's indivdual state.
Definition PlayerState.h:30
A rectangular shaped Actor with color.
Definition Quad.h:8
A row of ReceptorArrow objects.
Definition ReceptorArrowRow.h:12
A bitmap Actor that animates and moves around.
Definition Sprite.h:13
Definition MessageManager.h:96
Definition NoteDisplay.h:120
Definition NoteField.h:127
Definition RageTypes.h:332