Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Pages/StreamPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
Loaded="Page_Loaded">

<SwapChainPanel x:Name="swapChainPanel" Margin="{x:Bind State.ScreenMargin}">
<StackPanel x:Name="StatsPanel" Background="#CC000000" Margin="10,10,0,0" HorizontalAlignment="Left" Padding="10,10,10,10" Canvas.ZIndex="10" VerticalAlignment="Top" Visibility="Collapsed">
<TextBlock x:Name="StatsTextBlock" HorizontalAlignment="Center" Text="Loading Stats.." FontFamily="Consolas" IsHitTestVisible="False" FontSize="11" AllowFocusOnInteraction="False" Foreground="White" VerticalAlignment="Center" IsTapEnabled="False" IsRightTapEnabled="False" IsHoldingEnabled="False" IsDoubleTapEnabled="False" ScrollViewer.VerticalScrollBarVisibility="Disabled" LineHeight="2"/>
</StackPanel>
<StackPanel x:Name="LogsPanel" Background="#CC000000" Margin="0,10,30,38" Width="300" HorizontalAlignment="Right" Padding="10,10,10,10" Canvas.ZIndex="10" Visibility="Collapsed">
<TextBlock x:Name="LogsTextBlock" HorizontalAlignment="Left" Text="Loading Logs..." FontFamily="Consolas" IsHitTestVisible="False" FontSize="9" AllowFocusOnInteraction="False" Foreground="White" VerticalAlignment="Bottom" IsDoubleTapEnabled="False" IsHoldingEnabled="False" IsRightTapEnabled="False" IsTapEnabled="False" ScrollViewer.VerticalScrollBarVisibility="Disabled" TextWrapping="Wrap"/>
</StackPanel>
<StackPanel x:Name="ProgressView" HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical">
<muxc:ProgressRing Width="64" Height="64" IsActive="True" Margin="0,0,0,16" ></muxc:ProgressRing>
<TextBlock x:Name="StatusText">Initializing Moonlight...</TextBlock>
Expand Down
69 changes: 67 additions & 2 deletions Pages/StreamPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ StreamPage::StreamPage():

this->Loaded += ref new Windows::UI::Xaml::RoutedEventHandler(this, &StreamPage::OnLoaded);
this->Unloaded += ref new Windows::UI::Xaml::RoutedEventHandler(this, &StreamPage::OnUnloaded);

m_logsTimer = ref new Windows::UI::Xaml::DispatcherTimer();
m_logsTimer->Interval = Windows::Foundation::TimeSpan{ 10000000 }; // 1 second
m_logsTimer->Tick += ref new Windows::Foundation::EventHandler<Object^>(this, &StreamPage::UpdateLogsText);

m_statsTimer = ref new Windows::UI::Xaml::DispatcherTimer();
m_statsTimer->Interval = Windows::Foundation::TimeSpan{ 10000000 }; // 1 second
m_statsTimer->Tick += ref new Windows::Foundation::EventHandler<Object^>(this, &StreamPage::UpdateStatsText);
}


Expand Down Expand Up @@ -136,7 +144,14 @@ void StreamPage::toggleLogsButton_Click(Platform::Object^ sender, Windows::UI::X
{
Utils::showLogs = !Utils::showLogs;
this->toggleLogsButton->Text = Utils::showLogs ? "Hide Logs" : "Show Logs";
m_main->SetShowLogs(Utils::showLogs);
m_logsPanel->Visibility = Utils::showLogs ? Windows::UI::Xaml::Visibility::Visible : Windows::UI::Xaml::Visibility::Collapsed;

if (Utils::showLogs) {
m_logsTimer->Start();
UpdateLogsText(sender, e);
} else {
m_logsTimer->Stop();
}
}

void StreamPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) {
Expand All @@ -149,7 +164,16 @@ void StreamPage::toggleStatsButton_Click(Platform::Object^ sender, Windows::UI::
{
Utils::showStats = !Utils::showStats;
this->toggleStatsButton->Text = Utils::showStats ? "Hide Stats" : "Show Stats";
m_main->SetShowStats(Utils::showStats);

m_statsPanel->Visibility = Utils::showStats ? Windows::UI::Xaml::Visibility::Visible : Windows::UI::Xaml::Visibility::Collapsed;

if (Utils::showStats) {
m_statsTimer->Start();
UpdateStatsText(sender, e);
}
else {
m_statsTimer->Stop();
}
}


Expand Down Expand Up @@ -242,3 +266,44 @@ void StreamPage::OnUnloaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedE
auto navigation = Windows::UI::Core::SystemNavigationManager::GetForCurrentView();
navigation->BackRequested -= m_back_cookie;
}

void StreamPage::UpdateLogsText(Platform::Object^ sender, Platform::Object^ args)
{
Utils::logMutex.lock();
std::vector<std::wstring> lines = Utils::GetLogLines();
std::wstring combinedText;
for (const auto& line : lines) {
combinedText += line;
}
Utils::logMutex.unlock();

m_logsTextBlock->Text = ref new Platform::String(combinedText.c_str());
}

void StreamPage::UpdateStatsText(Platform::Object^ sender, Platform::Object^ args)
{
if (m_main != nullptr && m_main->GetStats() != nullptr) {
char statsOutput[1024];
DX::StepTimer timer = m_main->GetTimer();

if (m_main->GetStats()->ShouldUpdateDisplay(timer, Utils::showStats, statsOutput, sizeof(statsOutput))) {
// Remove trailing newline if it exists
size_t len = strlen(statsOutput);
if (len > 0 && statsOutput[len - 1] == '\n') {
statsOutput[len - 1] = '\0';
}

// Convert from char* to Platform::String^
size_t size = strlen(statsOutput) + 1;
wchar_t* wideText = new wchar_t[size];
size_t convertedChars = 0;
mbstowcs_s(&convertedChars, wideText, size, statsOutput, _TRUNCATE);
Platform::String^ statsText = ref new Platform::String(wideText);
delete[] wideText;

m_statsTextBlock->Text = statsText;
}
}

}

29 changes: 29 additions & 0 deletions Pages/StreamPage.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,42 @@ namespace moonlight_xbox_dx
}
}

property TextBlock^ m_logsTextBlock {
TextBlock^ get() {
return this->LogsTextBlock;
}
}

property StackPanel^ m_logsPanel {
StackPanel^ get() {
return this->LogsPanel;
}
}

property TextBlock^ m_statsTextBlock {
TextBlock^ get() {
return this->StatsTextBlock;
}
}

property StackPanel^ m_statsPanel {
StackPanel^ get() {
return this->StatsPanel;
}
}

void UpdateLogsText(Platform::Object^ sender, Platform::Object^ args);
void UpdateStatsText(Platform::Object^ sender, Platform::Object^ args);

protected:
virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
private:
// Track our independent input on a background worker thread.
Windows::Foundation::IAsyncAction^ m_inputLoopWorker;
Windows::UI::Core::CoreIndependentInputSource^ m_coreInput;
Windows::Foundation::EventRegistrationToken m_back_cookie;
Windows::UI::Xaml::DispatcherTimer^ m_logsTimer;
Windows::UI::Xaml::DispatcherTimer^ m_statsTimer;

// Resources used to render the DirectX content in the XAML page background.
std::shared_ptr<DX::DeviceResources> m_deviceResources;
Expand Down
1 change: 0 additions & 1 deletion Streaming/FFmpegDecoder.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "pch.h"
#include "FFMpegDecoder.h"
#include "StatsRenderer.h"

#include <Common\DirectXHelper.h>
#include <d3d11_1.h>
Expand Down
80 changes: 0 additions & 80 deletions Streaming/LogRenderer.cpp

This file was deleted.

27 changes: 0 additions & 27 deletions Streaming/LogRenderer.h

This file was deleted.

79 changes: 0 additions & 79 deletions Streaming/StatsRenderer.cpp

This file was deleted.

32 changes: 0 additions & 32 deletions Streaming/StatsRenderer.h

This file was deleted.

Loading