From acf8be530d432ffb869d43487c063c337b9ace3e Mon Sep 17 00:00:00 2001 From: tertu marybig Date: Thu, 15 Feb 2024 14:37:56 -0600 Subject: [PATCH] Allow setting and getting beat bar status per NoteField from Lua --- Docs/Luadoc/LuaDocumentation.xml | 23 +++++++++++++++-------- src/NoteField.cpp | 27 ++++++++++++++++++++++++++- src/NoteField.h | 5 +++++ 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml index 74f7e29db3..05a4c536ae 100644 --- a/Docs/Luadoc/LuaDocumentation.xml +++ b/Docs/Luadoc/LuaDocumentation.xml @@ -1475,16 +1475,16 @@ end

 Def.ActorFrame{
 	Name="AF",
-	
+
 	Def.Sprite{ Name="sun", Texture="sun.png" },
-	
+
 	Def.ActorFrame{
 		Name="AF2",
 		InitCommand=function(self)
 			-- bounce() will be applied to AF2, airhorn, and catchphrase
 			self:RunCommandsRecursively( function(actor) actor:bounce() end )
 		end,
-		
+
 		Def.Sprite{ Name="airhorn", Texture="airhorn.png" },
 		Def.BitmapText{ Name="catchphrase", Font="Common Normal", Text="Yo!" }
 	}
@@ -1788,9 +1788,9 @@ Def.ActorFrame{
 		-- bounce() will be applied to sun and AF2
 		self:RunCommandsOnChildren( function(child) child:bounce() end )
 	end,
-	
+
 	Def.Sprite{ Name="sun", Texture="sun.png" },
-	
+
 	Def.ActorFrame{
 		Name="AF2",
 		Def.Sprite{ Name="airhorn", Texture="airhorn.png" },
@@ -1810,9 +1810,9 @@ Def.ActorFrame{
 		-- bounce() will be applied to sun, airhorn, and catchphrase
 		self:runcommandsonleaves( function(leaf) leaf:bounce() end )
 	end,
-	
+
 	Def.Sprite{ Name="sun", Texture="sun.png" },
-	
+
 	Def.ActorFrame{
 		Name="AF2",
 		Def.Sprite{ Name="airhorn", Texture="airhorn.png" },
@@ -3877,6 +3877,7 @@ NETWORK:WebSocket{
 
 	
 		All functions in this class have camel case equivalents, use whichever naming style you prefer.
+ Camel case functions do not have snake case equivalents, though.
Makes the NoteField act as if a hold note was hit in the column, with the given score and bright setting.
@@ -3886,9 +3887,15 @@ NETWORK:WebSocket{ Makes the NoteField act as if a tap note was hit in the column, with the given score and bright setting.
The callback for did_tap_note will not be called.
+ + Returns whether beat bars are enabled on this NoteField. + Returns a table of the actors for the columns. This means that each column is an actor, so you can move it around or animate it like an actor. See the NoteColumnRenderer class for a list of special functions for the column's actor. + + Sets whether beat bars are enabled on this NoteField. + Same as SetDidTapNoteCallback, but for hold notes. Uses HoldNoteScore instead of TapNoteScore. @@ -6845,7 +6852,7 @@ for i, diff in ipairs(Difficulty) do local filename = diff .. ".png" -- load files like "Difficulty_Beginner.png", - -- "Difficulty_Easy.png", etc. from the directory + -- "Difficulty_Easy.png", etc. from the directory -- where this code is run, and offset each vertically af[#af+1] = LoadActor( filename )..{ InitCommand=function(self) self:y( i * 100 ) end diff --git a/src/NoteField.cpp b/src/NoteField.cpp index 0d9899e4cb..28939fdbda 100644 --- a/src/NoteField.cpp +++ b/src/NoteField.cpp @@ -46,6 +46,7 @@ NoteField::NoteField() m_pNoteData = nullptr; m_pCurDisplay = nullptr; m_drawing_board_primitive= false; + m_bShowBeatBars = SHOW_BEAT_BARS; m_textMeasureNumber.LoadFromFont( THEME->GetPathF("NoteField","MeasureNumber") ); m_textMeasureNumber.SetZoom( 1.0f ); @@ -96,6 +97,16 @@ void NoteField::Unload() memset( m_pDisplays, 0, sizeof(m_pDisplays) ); } +void NoteField::SetBeatBars(bool active) +{ + m_bShowBeatBars = active; +} + +bool NoteField::GetBeatBars() +{ + return m_bShowBeatBars; +} + void NoteField::CacheNoteSkin( const RString &sNoteSkin_ ) { RString sNoteSkinLower = sNoteSkin_; @@ -800,7 +811,7 @@ void NoteField::DrawPrimitives() segs[tst] = &(pTiming->GetTimingSegments(tst)); // Draw beat bars - if( ( GAMESTATE->IsEditing() || SHOW_BEAT_BARS ) && pTiming != nullptr ) + if( ( GAMESTATE->IsEditing() || m_bShowBeatBars ) && pTiming != nullptr ) { const std::vector &tSigs = *segs[SEGMENT_TIME_SIG]; int iMeasureIndex = 0; @@ -1267,6 +1278,18 @@ public: return 1; } + static int GetBeatBars(T* p, lua_State* L) + { + LuaHelpers::Push(L, p->GetBeatBars()); + return 1; + }; + + static int SetBeatBars(T* p, lua_State* L) + { + p->SetBeatBars(BArg(1)); + return 0; + } + LunaNoteField() { ADD_METHOD(set_step_callback); @@ -1278,6 +1301,8 @@ public: ADD_METHOD(did_tap_note); ADD_METHOD(did_hold_note); ADD_METHOD(get_column_actors); + ADD_METHOD(GetBeatBars); + ADD_METHOD(SetBeatBars); } }; diff --git a/src/NoteField.h b/src/NoteField.h index 8ba56a23d0..51c89630d5 100644 --- a/src/NoteField.h +++ b/src/NoteField.h @@ -67,6 +67,9 @@ public: // public so that the Lua API can access it. -Kyz std::vector m_ColumnRenderers; + void SetBeatBars(bool active); + bool GetBeatBars(); + protected: void CacheNoteSkin( const RString &sNoteSkin ); void UncacheNoteSkin( const RString &sNoteSkin ); @@ -126,6 +129,8 @@ protected: BitmapText m_textMeasureNumber; Quad m_rectMarkerBar; Quad m_rectAreaHighlight; + + bool m_bShowBeatBars; }; #endif