Skip to content

Commit

Permalink
Merge branch 'visualizer_muted'
Browse files Browse the repository at this point in the history
* Added sequence usage count info to text bar, whenever a sequence is being edited
* Fixed an issue in the driver utils for when sequence usage count is deduced
* Fixed a mutex lock issue in the emulation memory module
  • Loading branch information
RawPowerLaxity committed Dec 5, 2023
2 parents da25199 + 876107d commit fb639fd
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 50 deletions.
4 changes: 2 additions & 2 deletions SIDFactoryII/SIDFactoryII.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ namespace Editor
void ComponentOrderListOverview::PullDataFromSource(const bool inFromUndo)
{
m_TableText->PullDataFromSource();
m_RequireRefresh |= inFromUndo;
}


Expand Down
28 changes: 14 additions & 14 deletions SIDFactoryII/source/runtime/editor/components/component_track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,12 @@ namespace Editor
UpdateSequenceStatusReport();
}

{
const unsigned int order_list_index = m_EventPosDetails.OrderListIndex();
const auto& order_list_entry = (*m_DataSourceOrderList)[order_list_index];
if (order_list_entry.m_Transposition >= 0xfe)
m_OrderListIndexChangedEvent.Execute(m_HasControl, order_list_index, 0xff);
else
m_OrderListIndexChangedEvent.Execute(m_HasControl, order_list_index, order_list_entry.m_SequenceIndex);
}
const unsigned int order_list_index = m_EventPosDetails.OrderListIndex();
const auto& order_list_entry = (*m_DataSourceOrderList)[order_list_index];
if (order_list_entry.m_Transposition >= 0xfe)
m_OrderListIndexChangedEvent.Execute(m_HasControl, order_list_index, 0xff);
else
m_OrderListIndexChangedEvent.Execute(m_HasControl, order_list_index, order_list_entry.m_SequenceIndex);
}


Expand Down Expand Up @@ -572,6 +570,8 @@ namespace Editor
{
if (m_DataSourceOrderList->PushDataToSource())
m_HasDataChangeOrderList = false;

SetEventPosDetails(m_EventPosDetails.OrderListIndex(), m_EventPosDetails.SequenceIndex(), true);
}

if (!m_DataChangeSequenceIndexList.empty())
Expand Down Expand Up @@ -657,7 +657,7 @@ namespace Editor
}


void ComponentTrack::SetEventPosition(int inEventPos)
void ComponentTrack::SetEventPosition(int inEventPos, bool inForceOrderListIndexChangeEvent)
{
FOUNDATION_ASSERT(inEventPos >= 0);

Expand Down Expand Up @@ -702,7 +702,7 @@ namespace Editor
if (!found_event_pos && m_EventPos >= event_pos && m_EventPos < next_event_pos)
{
found_event_pos = true;
SetEventPosDetails(i, m_EventPos - event_pos);
SetEventPosDetails(i, m_EventPos - event_pos, inForceOrderListIndexChangeEvent);

break;
}
Expand Down Expand Up @@ -772,7 +772,7 @@ namespace Editor
if (m_HasControl && m_FocusModeOrderList)
{
int event_pos = GetEventPositionAtTopOfCurrentSequence();
SetEventPosition(event_pos);
SetEventPosition(event_pos, true);
}

UpdateOrderListStatusReport();
Expand Down Expand Up @@ -1842,13 +1842,13 @@ namespace Editor
}


void ComponentTrack::SetEventPosDetails(unsigned int inOrderListIndex, unsigned int inSequenceIndex)
void ComponentTrack::SetEventPosDetails(unsigned int inOrderListIndex, unsigned int inSequenceIndex, bool inForceOrderListIndexChangeEvent)
{
unsigned int previous_order_list_index = m_EventPosDetails.OrderListIndex();

m_EventPosDetails.Set(inOrderListIndex, inSequenceIndex);

if (inOrderListIndex != previous_order_list_index)
if (inOrderListIndex != previous_order_list_index || inForceOrderListIndexChangeEvent)
{
const auto& order_list_entry = (*m_DataSourceOrderList)[inOrderListIndex];
if (order_list_entry.m_Transposition >= 0xfe)
Expand Down Expand Up @@ -2209,7 +2209,7 @@ namespace Editor
}

int event_pos = DoKeyUp();
SetEventPosDetails(m_EventPosDetails.OrderListIndex(), m_EventPosDetails.SequenceIndex() - 1);
SetEventPosDetails(m_EventPosDetails.OrderListIndex(), m_EventPosDetails.SequenceIndex() - 1, true);
DoDelete(inIsControlDown);

return event_pos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ namespace Editor
void SetCursorPosition(int inCursorPosition);

int GetMaxEventPosition() const;
void SetEventPosition(int inEventPos);
void SetEventPosition(int inEventPos, bool inForceOrderListIndexChangeEvent = false);
int GetEventPosition() const;
int GetEventPositionAtTopOfCurrentSequence() const;

Expand Down Expand Up @@ -218,7 +218,7 @@ namespace Editor
void UpdateMaxEventPos();

private:
void SetEventPosDetails(unsigned int inOrderListIndex, unsigned int inSequenceIndex);
void SetEventPosDetails(unsigned int inOrderListIndex, unsigned int inSequenceIndex, bool inForceOrderListIndexChangeEvent = false);

// Status report
void UpdateSequenceStatusReport();
Expand Down
14 changes: 14 additions & 0 deletions SIDFactoryII/source/runtime/editor/components/component_tracks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ namespace Editor
(*m_DataSource)[i]->UpdateMaxEventPos();
}
}));

// Set orderlist index changed event
(*m_DataSource)[i]->GetOrderListIndexChangedEvent().Add(
this,
Utility::TDelegate<void(bool, unsigned int, unsigned char)>([this](bool inHasControl, unsigned int inIndex, unsigned char inValue)
{
this->m_OrderListIndexChangedEvent.Execute(inHasControl, inIndex, inValue);
}));
}

// Set the event position on each track
Expand Down Expand Up @@ -600,6 +608,12 @@ namespace Editor
}


ComponentTrack::OrderListIndexChangedEvent& ComponentTracks::GetOrderListIndexChangedEvent()
{
return m_OrderListIndexChangedEvent;
}


void ComponentTracks::AlignTracks()
{
m_RequireRefresh = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ namespace Editor

void OnOrderListChanged(int inChannel);

ComponentTrack::OrderListIndexChangedEvent& GetOrderListIndexChangedEvent();

private:
void AlignTracks();
void HandleSequenceSplit(unsigned char inSequence, unsigned char inSequenceToAdd);
Expand Down Expand Up @@ -107,6 +109,8 @@ namespace Editor
const AuxilaryDataCollection& m_AuxilaryData;
ComponentTrackUtils::FocusRow m_FocusRow;

ComponentTrack::OrderListIndexChangedEvent m_OrderListIndexChangedEvent;

std::shared_ptr<DataSourceTrackComponents> m_DataSource;
std::vector<std::shared_ptr<DataSourceOrderList>> m_OtherOrderListDataSources;
};
Expand Down
8 changes: 3 additions & 5 deletions SIDFactoryII/source/runtime/editor/driver/driver_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,11 @@ namespace Editor
for (unsigned short j = 0; j < music_data.m_OrderListSize; ++j)
{
unsigned char value = inMemoryReader[order_list_address + j];
if (value < SequenceCount)
{
if (value == 0x7e)
break;

if (value < SequenceCount)
usage_count[value]++;
}
else if (value >= 0xfe)
break;
}
}

Expand Down
32 changes: 29 additions & 3 deletions SIDFactoryII/source/runtime/editor/screens/screen_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ namespace Editor
: song_name;

m_StatusBar = std::make_unique<StatusBarEdit>(m_MainTextField, m_EditState, m_DriverState, m_DriverInfo->GetAuxilaryDataCollection(), mouse_button_octave, mouse_button_flat_sharp, mouse_button_sid_model, mouse_button_context_highlight, mouse_button_follow_play);
m_StatusBar->SetText(m_ActivationMessage.length() > 0 ? m_ActivationMessage : " SID Factory II [Selected song: " + song_selection_text + "]", 2500);
m_StatusBar->SetText(m_ActivationMessage.length() > 0 ? m_ActivationMessage : " SID Factory II [Selected song: " + song_selection_text + "]", 2500, false);
m_ActivationMessage = "";

// Create flight recorder overlay
Expand Down Expand Up @@ -1460,8 +1460,22 @@ namespace Editor
Utility::TDelegate<void(int)>([&](int inChannel) { m_TracksComponent->OnOrderListChanged(inChannel); })
);

// Hook up tracks for when order list index changes
m_TracksComponent->GetOrderListIndexChangedEvent().Add(
nullptr,
Utility::TDelegate<void(bool, unsigned int, unsigned char)>([this](bool InHasFocus, unsigned int InOrderlistIndex, unsigned char InSequenceIndex)
{
const bool is_playing = m_DriverState.GetPlayState() == Editor::DriverState::PlayState::Playing;

if(m_EditState.IsFollowPlayMode() && is_playing)
return;

if(InHasFocus)
this->ShowSequenceUsageCount(InSequenceIndex);
})
);

// Enable groups
//m_ComponentsManager->SetGroupEnabledForTabbing(0);
m_ComponentsManager->SetGroupEnabledForInput(0, true);

if (m_ActivationFocusOnComponent)
Expand Down Expand Up @@ -1745,7 +1759,6 @@ namespace Editor

EditorUtils::SetNoteInputValueKeys(note_keys_octave1, note_keys_octave2);
}

}


Expand Down Expand Up @@ -2150,5 +2163,18 @@ namespace Editor
}
}
}

void ScreenEdit::ShowSequenceUsageCount(unsigned char inSequenceIndex)
{
if(inSequenceIndex < 0x80)
{
m_CPUMemory->Lock();
std::vector<int> sequence_index_use_count = DriverUtils::GetSequenceUsageCount(*m_DriverInfo, *m_CPUMemory);
m_CPUMemory->Unlock();
std::string text = " Sequence index: " + EditorUtils::ConvertToHexValue(inSequenceIndex, m_DisplayState.IsHexUppercase()) + " use count: " + std::to_string(sequence_index_use_count[inSequenceIndex]);

SetStatusBarMessage(text, 5000);
}
}
}

4 changes: 3 additions & 1 deletion SIDFactoryII/source/runtime/editor/screens/screen_edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,13 @@ namespace Editor
void ConfigureNoteKeys();
void ConfigurePlaybackOptions();

void ShowSequenceUsageCount(unsigned char inSequenceIndex);

template<typename EXECUTION_CALLBACK>
void StartSongsDialogWithSelectionExecution(const std::string& headline, EXECUTION_CALLBACK&& inExecutionCallback);
template<typename EXECUTION_CALLBACK>
void StartMoveSongDialogWithSelectionExecution(const std::string& inCaption, EXECUTION_CALLBACK&& inExecutionCallback);

// Load/save requests
std::function<void(void)> m_LoadRequestCallback;
std::function<void(void)> m_SaveRequestCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Editor
{
StatusBar::StatusBar(Foundation::TextField* inTextField)
: m_TextField(inTextField)
, m_CanBeOverwritten(true)
, m_NeedRefresh(true)
, m_TextColor(ToColor(UserColor::StatusBarText))
, m_BackgroundColor(ToColor(UserColor::StatusBarBackgroundStopped))
Expand Down Expand Up @@ -55,15 +56,19 @@ namespace Editor

void StatusBar::SetText(const std::string& inText)
{
SetText(inText, 0);
SetText(inText, 0, true);
}


void StatusBar::SetText(const std::string& inText, int inDuration)
void StatusBar::SetText(const std::string& inText, int inDuration, bool inCanBeOverwritten)
{
m_Text = inText;
m_TextClearTimer = inDuration;
m_NeedRefresh = true;
if(!inCanBeOverwritten || m_CanBeOverwritten)
{
m_Text = inText;
m_TextClearTimer = inDuration;
m_NeedRefresh = true;
m_CanBeOverwritten = inCanBeOverwritten;
}
}

bool StatusBar::IsDisplayingTimedText() const
Expand Down Expand Up @@ -149,6 +154,7 @@ namespace Editor
{
m_Text = "";
m_NeedRefresh = true;
m_CanBeOverwritten = true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Editor

void SetColors(const Foundation::Color& inTextColor, const Foundation::Color& inBackgroundColor, const Foundation::Color& inBackgroundMouseOverColor);
void SetText(const std::string& inText);
void SetText(const std::string& inText, int inDuration);
void SetText(const std::string& inText, int inDuration, bool inCanBeOverwritten = true);
bool IsDisplayingTimedText() const;
void Refresh();

Expand Down Expand Up @@ -60,6 +60,7 @@ namespace Editor
std::function<void(Foundation::Mouse::Button, int)> m_MouseButtonCallback;
};

bool m_CanBeOverwritten;
bool m_NeedRefresh;
bool m_NeedUpdate;

Expand Down
Loading

0 comments on commit fb639fd

Please sign in to comment.