//
#include "pch.h"
-#include "MainPage.xaml.h"
#include "App.xaml.h"
using namespace ShootingGame;
// Window::Current->Content = rootFrame;
// Window::Current->Activate();
+
+ //state_;
+ gameMain_ = ref new GameMain();
+
// フレームを現在のウィンドウに配置し、アクティブであることを確認します
- mainPage_ = ref new MainPage();
+ mainPage_ = ref new MainPage(gameMain_);
+ gameMain_->Initialize(Window::Current->CoreWindow,mainPage_->SwapChainBackgroundPanel(),DisplayProperties::LogicalDpi);
// Place the frame in the current Window and ensure that it is active
Window::Current->Content = mainPage_;
Window::Current->Activated += ref new WindowActivatedEventHandler(this, &App::OnWindowActivationChanged);
Window::Current->Activate();
- //state_;
- gameMain_ = ref new GameMain();
- gameMain_->Initialize(Window::Current->CoreWindow,mainPage_->SwapChainBackgroundPanel(),DisplayProperties::LogicalDpi);
-
eventToken_ =
CompositionTarget::Rendering::add
(ref new EventHandler<Object^>(this, &App::OnRendering));
#include "App.g.h"
#include "MainPage.xaml.h"
-#include "SoundDriver.h"
#include "GameMain.h"
+#include "SoundDriver.h"
#include "BasicTimer.h"
namespace ShootingGame
return mainPage_->SwapChainBackgroundPanel();
}
- private:
+ private:
MainPage^ mainPage_;
GameMain^ gameMain_;
BasicTimer^ timer_;
mc:Ignorable="d" Height="212.667" Width="453.667">
<Grid>
- <Slider HorizontalAlignment="Left" Margin="13.333,13,0,0" VerticalAlignment="Top" Width="310" Height="43" UseLayoutRounding="True" ScrollViewer.VerticalScrollBarVisibility="Auto"/>
+ <Slider HorizontalAlignment="Left" Margin="13.333,13,0,0" VerticalAlignment="Top" Width="310" Height="43" UseLayoutRounding="True" ScrollViewer.VerticalScrollBarVisibility="Auto" Maximum="100" Value="10" Minimum="0"/>
<Slider HorizontalAlignment="Left" Margin="13.333,61,0,0" VerticalAlignment="Top" Width="310" Height="44"/>
<Slider HorizontalAlignment="Left" Margin="13.333,110,0,0" VerticalAlignment="Top" Width="310" Height="43"/>
<Slider HorizontalAlignment="Left" Margin="13.333,158,0,0" VerticalAlignment="Top" Width="310" Height="45.333"/>
//// Copyright (c) Microsoft Corporation. All rights reserved
#include "pch.h"
-#include "SoundDriver.h"
+//#include "MainPage.xaml.h"
#include "GameMain.h"
-#include "windows.ui.xaml.media.dxinterop.h"
-#include "GameStateMachine.h"
using namespace Microsoft::WRL;
-using namespace Windows::Foundation;
-using namespace Windows::Foundation::Collections;
-using namespace Windows::UI::Core;
-using namespace Windows::UI::ViewManagement;
-
-using namespace Windows::UI::ApplicationSettings;
-using namespace Windows::UI::Popups;
-using namespace Windows::UI::Xaml::Controls;
-using namespace Windows::Graphics::Display;
+//using namespace Windows::Foundation;
+//using namespace Windows::Foundation::Collections;
+//using namespace Windows::UI::Core;
+//using namespace Windows::UI::ViewManagement;
+//
+//using namespace Windows::UI::ApplicationSettings;
+//using namespace Windows::UI::Popups;
+//using namespace Windows::UI::Xaml::Controls;
+//using namespace Windows::Graphics::Display;
using namespace DirectX;
using namespace D2D1;
using namespace concurrency;
-
-
using namespace BasicSprites;
-using namespace boost;
+
namespace ShootingGame {
+
const float GameMain::BACKBUFFER_WIDTH = 320.0f;
const float GameMain::BACKBUFFER_HEIGHT = 240.0f;
-GameMain::GameMain() : backBufferViewPort_(0.0f,0.0f,BACKBUFFER_WIDTH,BACKBUFFER_HEIGHT) , isDestroy_(true),state_(this)
+GameMain::GameMain()
+ :backBufferViewPort_(0.0f,0.0f,BACKBUFFER_WIDTH,BACKBUFFER_HEIGHT) , isDestroy_(true),state_(this),
+ eventHolder_(::CreateEventEx(NULL, NULL, 0, EVENT_MODIFY_STATE | SYNCHRONIZE))
{
-// GameStateMachine machine;
+ // GameStateMachine machine;
soundDriver_.reset(new sf::SoundDriver());
soundManager_.reset(new sf::SoundManager(*soundDriver_.get()));
-
-
+
//soundThread_ = std::thread(
// [this]() -> void
// {
GameMain::~GameMain()
{
StopSound();
-
+ eventHolder_.reset();
//if(soundThread_.joinable())
//{
// soundThread_.join();
void GameMain::ExecuteSoundThread()
{
//sf::com_init comInit;
-// InitSound();
+ // InitSound();
soundManager_->Sequencer().Play();
while(!isDestroy_)
{
// soundDriver_->Update();
// soundDriver_->Render();
}
+ ::SetEvent(eventHolder_.get());
+ //isDestroy_ = false;
}
void GameMain::StartSound()
// \83T\83E\83\93\83h\8dÄ\90¶\83X\83\8c\83b\83h\82Ì\92â\8e~
if(!isDestroy_){
isDestroy_ = true;
- soundTask_.wait();
+ WaitForSingleObjectEx(eventHolder_.get(),INFINITE,FALSE);
}
}
);
}
+
}
#include "AutoThrottle.h"
#include "BasicSprites.h"
#include "BasicLoader.h"
-#include "SoundManager.h"
#include "GameStateMachine.h"
+#include "SoundManager.h"
namespace ShootingGame {
-struct CharacterData
-{
- float2 pos;
- float2 vel;
- float rot;
- float rotVel;
- float scale;
-};
-
-ref class GameMain : public DirectXBase
-{
-internal:
- GameMain();
- ~GameMain();
- virtual void CreateDeviceIndependentResources() override;
- virtual void CreateDeviceResources() override;
- virtual void CreateWindowSizeDependentResources() override;
- virtual void Render() override;
-
- void Initialize(
- _In_ Windows::UI::Core::CoreWindow^ window,
- _In_ Windows::UI::Xaml::Controls::SwapChainBackgroundPanel^ swapChainPanel,
- _In_ float dpi
- ) ;
-
- void Update(float timeTotal, float timeDelta);
-
- static const float BACKBUFFER_WIDTH;
- static const float BACKBUFFER_HEIGHT;
-
- sf::SoundManager& GameMain::SoundManager()
- {
- return *soundManager_;
- }
+
- sf::SoundDriver& GameMain::SoundDriver()
+ struct CharacterData
{
- return *soundDriver_;
- }
+ float2 pos;
+ float2 vel;
+ float rot;
+ float rotVel;
+ float scale;
+ };
- BasicSprites::SpriteBatch^ GameMain::SpriteBatch()
+// ref class MainPage;
+
+ ref class GameMain : public DirectXBase
{
- return spriteBatch_;
- }
-
- ::AutoThrottle^ GameMain::AutoThrottle() {return autoThrottle_;}
- ::SampleOverlay^ GameMain::SampleOverlay() {return sampleOverlay_;}
-
-// void InitSound();
- float RandFloat(float min, float max);
- void StartSound();
- void StopSound();
- void ClearScreen();
- void RenderScreen();
-
- void LoadTexture(const std::wstring& filename,ID3D11Texture2D** texPtrAddr);
-private:
- GameStateMachine state_;
- void ExecuteSoundThread();
- ::SampleOverlay^ sampleOverlay_;
- ::AutoThrottle^ autoThrottle_;
- BasicSprites::SpriteBatch^ spriteBatch_;
- Microsoft::WRL::ComPtr<ID3D11Texture2D> backBuffer_;
- Microsoft::WRL::ComPtr<ID3D11RenderTargetView> backBufferRenderTargetView_;
- // Microsoft::WRL::ComPtr<ID3D11DepthStencilView> backBufferDepthStencilView_;
- // Microsoft::WRL::ComPtr<ID3D11DepthStencilState> backBufferDepthStencilState_;
- float scale_;
- CD3D11_VIEWPORT backBufferViewPort_;
- CD3D11_VIEWPORT swapChainViewPort_;
- std::vector<CharacterData> characters_;
- bool isDestroy_;
- Windows::UI::Xaml::Controls::SwapChainBackgroundPanel^ panel_;
- std::unique_ptr<sf::SoundManager> soundManager_;
- std::unique_ptr<sf::SoundDriver> soundDriver_;
- //std::thread soundThread_;
- concurrency::task<void> soundTask_;
-};
+ internal:
+
+ delegate void SubFrameFuncDelegate(Windows::UI::Xaml::Controls::Page^ p);
+ delegate void IsBackButtonEnabledDelgate(bool v);
+
+ explicit GameMain();
+ ~GameMain();
+ virtual void CreateDeviceIndependentResources() override;
+ virtual void CreateDeviceResources() override;
+ virtual void CreateWindowSizeDependentResources() override;
+ virtual void Render() override;
+
+ void Initialize(
+ _In_ Windows::UI::Core::CoreWindow^ window,
+ _In_ Windows::UI::Xaml::Controls::SwapChainBackgroundPanel^ swapChainPanel,
+ _In_ float dpi
+ ) ;
+
+ void Update(float timeTotal, float timeDelta);
+
+ static const float BACKBUFFER_WIDTH;
+ static const float BACKBUFFER_HEIGHT;
+
+ sf::SoundManager& GameMain::SoundManager()
+ {
+ return *soundManager_;
+ }
+
+ sf::SoundDriver& GameMain::SoundDriver()
+ {
+ return *soundDriver_;
+ }
+
+ BasicSprites::SpriteBatch^ GameMain::SpriteBatch()
+ {
+ return spriteBatch_;
+ }
+
+ ::AutoThrottle^ GameMain::AutoThrottle() {return autoThrottle_;}
+ ::SampleOverlay^ GameMain::SampleOverlay() {return sampleOverlay_;}
+
+ // void InitSound();
+ float RandFloat(float min, float max);
+ void StartSound();
+ void StopSound();
+ void ClearScreen();
+ void RenderScreen();
+
+ void LoadTexture(const std::wstring& filename,ID3D11Texture2D** texPtrAddr);
+
+ void Subframe(Windows::UI::Xaml::Controls::Page^ p)
+ {
+ subFrameFunction_(p);
+ }
+
+ void SetSubFrameFunc(SubFrameFuncDelegate^ func)
+ {
+ subFrameFunction_ = func;
+ }
+
+ ShootingGame::GameStateMachine& GameMain::GameStateMachine()
+ {
+ return state_;
+ }
+
+ void SetIsBackButtonEnabledDelgate(IsBackButtonEnabledDelgate^ d)
+ {
+ isBackButtonEnabledDelgate_ = d;
+ }
+
+ void IsBackButtonEnabled(bool v)
+ {
+ isBackButtonEnabledDelgate_(v);
+ }
+
+ private:
+// std::function<void(Windows::UI::Xaml::Controls::Page^ p)> subFrameFunction_;
+ SubFrameFuncDelegate^ subFrameFunction_;
+ IsBackButtonEnabledDelgate^ isBackButtonEnabledDelgate_;
+ ShootingGame::GameStateMachine state_;
+ void ExecuteSoundThread();
+ ::SampleOverlay^ sampleOverlay_;
+ ::AutoThrottle^ autoThrottle_;
+ BasicSprites::SpriteBatch^ spriteBatch_;
+ Microsoft::WRL::ComPtr<ID3D11Texture2D> backBuffer_;
+ Microsoft::WRL::ComPtr<ID3D11RenderTargetView> backBufferRenderTargetView_;
+ // Microsoft::WRL::ComPtr<ID3D11DepthStencilView> backBufferDepthStencilView_;
+ // Microsoft::WRL::ComPtr<ID3D11DepthStencilState> backBufferDepthStencilState_;
+ float scale_;
+ CD3D11_VIEWPORT backBufferViewPort_;
+ CD3D11_VIEWPORT swapChainViewPort_;
+ std::vector<CharacterData> characters_;
+ bool isDestroy_;
+ Windows::UI::Xaml::Controls::SwapChainBackgroundPanel^ panel_;
+ std::unique_ptr<sf::SoundManager> soundManager_;
+ std::unique_ptr<sf::SoundDriver> soundDriver_;
+ concurrency::task<void> soundTask_;
+ sf::handle_holder eventHolder_;
+ };
}
//#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
//#define BOOST_MPL_LIMIT_VECTOR_SIZE 30 //or whatever you need
//#define BOOST_MPL_LIMIT_MAP_SIZE 30 //or whatever you need
+
+//#include "MainPage.xaml.h"
+#include "GameMain.h"
+#include "SoundDriver.h"
+#include "MenuPage.xaml.h"
+
+#pragma hdrstop
+
#include <boost/msm/back/state_machine.hpp>
#include <boost/msm/front/state_machine_def.hpp>
#include <boost/msm/front/functor_row.hpp>
-#include "GameStateMachine.h"
-#include "GameMain.h"
-#include "SoundDriver.h"
using namespace Microsoft::WRL;
using namespace Windows::Foundation;
using namespace Windows::UI::ApplicationSettings;
using namespace Windows::UI::Popups;
+using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
+using namespace Windows::UI::Xaml::Controls::Primitives;
+using namespace Windows::UI::Xaml::Data;
+using namespace Windows::UI::Xaml::Input;
+using namespace Windows::UI::Xaml::Media;
+using namespace Windows::UI::Xaml::Interop;
+using namespace Windows::UI::Xaml::Navigation;
+
using namespace Windows::Graphics::Display;
using namespace DirectX;
using namespace D2D1;
using namespace BasicSprites;
-namespace msmf = boost::msm::front;
-namespace msmb = boost::msm::back;
+namespace msmf = boost::msm::front;
+namespace msmb = boost::msm::back;
+
+#include "SoundEditor.h"
namespace ShootingGame
{
namespace State
{
- struct Init : boost::msm::front::state<>
+ struct Init : msmf::state<>
{
template <class Event, class Fsm>
void on_entry(Event const& e, Fsm& f )
GameMain^ gameMain_;
};
- struct Title : boost::msm::front::state<>
+ struct Title : msmf::state<>
{
template <class Event, class Fsm>
void on_entry(Event const&, Fsm& ) {};
void on_exit(Event const&, Fsm& ) {};
};
- struct Demo : boost::msm::front::state<>
+ struct Demo : msmf::state<>
{
template <class Event, class Fsm>
void on_entry(Event const&, Fsm& ) {};
void on_exit(Event const&, Fsm& ) {};
};
- struct Menu : boost::msm::front::state<>
- {
- template <class Event, class Fsm>
- void on_entry(Event const&, Fsm& ) {};
- template <class Event, class Fsm>
- void on_exit(Event const&, Fsm& ) {};
- };
- struct Running_ : boost::msm::front::state_machine_def<Running_>
+ struct Running_ : msmf::state_machine_def<Running_>
{
struct Update
{
- template <class Fsm,class Evt,class SourceState,class TargetState>
- void operator()(Evt const& e, Fsm& fsm, SourceState&,TargetState& )
+ template <class Fsm,class Evt,class SourceState,class TargetState>
+ void operator()(Evt const& e, Fsm& fsm, SourceState&,TargetState& )
{
}
struct Render
{
- template <class Fsm,class Evt,class SourceState,class TargetState>
- void operator()(Evt const& e, Fsm& fsm, SourceState&,TargetState& )
+ template <class Fsm,class Evt,class SourceState,class TargetState>
+ void operator()(Evt const& e, Fsm& fsm, SourceState&,TargetState& )
{
ShootingGame::GameMain^ gameMain = fsm.GameMain();
BasicSprites::SpriteBatch^ spriteBatch = fsm.GameMain()->SpriteBatch();
void on_entry(Event const& evt, Fsm& fsm)
{
gameMain_ = fsm.GameMain();
+ gameMain_->IsBackButtonEnabled(true);
gameMain_->StopSound();
InitSound();
gameMain_->StartSound();
};
typedef boost::mpl::vector<Action> initial_state;
- template <class FSM,class Event>
- void no_transition(Event const& ,FSM&, int state)
- {
- BOOST_ASSERT(false);
- }
+
+ struct Exit : msmf::exit_pseudo_state<msmf::none> {};
template <class Event, class Fsm>
- void on_exit(Event const&, Fsm& ) {};
+ void on_exit(Event const& e, Fsm& fsm)
+ {
+ gameMain_->StopSound();
+ test_.Reset();
+
+ gameMain_->ClearScreen();
+
+ gameMain_->RenderScreen();
+ gameMain_->Present();
+
+ gameMain_->RenderScreen();
+ gameMain_->Present();
+
+ };
+
struct transition_table
: boost::mpl::vector<
msmf::Row<Action,Event::Update,msmf::none,Update,msmf::none>,
- msmf::Row<Action,Event::Render,msmf::none,Render,msmf::none>
+ msmf::Row<Action,Event::Render,msmf::none,Render,msmf::none>,
+ msmf::Row<Action,Event::Back,Exit>
>
{};
+ // No handled event handler
+ template <class Fsm,class Event>
+ void no_transition(Event const& e, Fsm& ,int state) {
+ std::cout << "No handled event in Sm1 " << typeid(e).name() << " on State " << state << std::endl;
+ }
+
ShootingGame::GameMain^ Running_::GameMain(){return gameMain_;}
ID3D11Texture2D * texture()
{
return test_.Get();
};
+
private:
void InitSound()
{
typedef boost::msm::back::state_machine<Running_> Running;
- struct SoundEdit : boost::msm::front::state<>
+ // \83\81\83j\83\85\81[\8fó\91Ô
+ struct Menu_ : msmf::state_machine_def<Menu_>
{
template <class Event, class Fsm>
- void on_entry(Event const&, Fsm& ) {};
+ void on_entry(Event const&, Fsm& fsm)
+ {
+ gameMain_ = fsm.GameMain();
+ gameMain_->IsBackButtonEnabled(false);
+ };
+
template <class Event, class Fsm>
- void on_exit(Event const&, Fsm& ) {};
+ void on_exit(Event const&, Fsm& )
+ {
+ };
+
+ // \83A\83C\83h\83\8b\8fó\91Ô
+ struct Idle : msmf::state<>
+ {
+ template <class Event, class Fsm>
+ void on_entry(Event const&, Fsm& fsm)
+ {
+ gameMain_ = fsm.GameMain();
+ MenuPage^ menuPage_ = ref new MenuPage(gameMain_->GameStateMachine());
+ gameMain_->Subframe(menuPage_);
+ gameMain_->IsBackButtonEnabled(false);
+ }
+
+ template <class Event, class Fsm>
+ void on_exit(Event const&, Fsm& )
+ {
+ gameMain_->Subframe(nullptr);
+ menuPage_ = nullptr;
+ };
+ private:
+ ShootingGame::GameMain^ gameMain_;
+ MenuPage^ menuPage_;
+ };
+ typedef Idle initial_state;
+
+
+ // \8fó\91Ô\91J\88Ú\83e\81[\83u\83\8b
+ struct transition_table
+ : boost::mpl::vector<
+ msmf::Row<Idle,Event::PushStart,State::Running>,
+ msmf::Row<State::Running::exit_pt<State::Running_::Exit>,msmf::none,Idle>,
+ msmf::Row<Idle,Event::PushSoundEdit,State::SoundEdit>,
+ msmf::Row<State::SoundEdit::exit_pt<State::SoundEdit_::Exit>,msmf::none,Idle>
+ >
+ {};
+ // No handled event handler
+ template <class Fsm,class Event>
+ void no_transition(Event const& e, Fsm& ,int state) {
+ // std::cout << "No handled event in Sm1 " << typeid(e).name() << " on State " << state << std::endl;
+ }
+
+ // \83v\83\8d\83p\83e\83B
+ ShootingGame::GameMain^ Menu_::GameMain(){return gameMain_;}
+ private:
+ ShootingGame::GameMain^ gameMain_;
};
+ typedef msmb::state_machine<Menu_> Menu;
+
struct Exit : boost::msm::front::state<>
{
template <class Event, class Fsm>
struct transition_table
: boost::mpl::vector<
- msmf::Row<State::Init,Event::Init,State::Running>//,
+ msmf::Row<State::Init,Event::Init,State::Menu>
// msmf::Row<State::Running,Event::Update,boost::msm::front::none,State::Running::Update>
/* _row<State::Menu,Event::PushStart,State::Running>,
_row<State::Menu,Event::PushSoundEdit,State::SoundEdit>,
_row<State::SoundEdit,Event::Escape,State::Menu>*/
>{};
- template <class FSM,class Event>
- void no_transition(Event const& ,FSM&, int state)
- {
- // BOOST_ASSERT(false);
- }
+ template <class Event, class Fsm>
+ void no_transition(Event const& e, Fsm& ,int state) {
+ // std::cout << "No handled event in Sm1 " << typeid(e).name() << " on State " << state << std::endl;
+ }
explicit GameStateMachine_(GameMain^ main) :gameMain_(main)
{
template void GameStateMachine::ProcessEvent<Event::Init>(Event::Init const &e);
template void GameStateMachine::ProcessEvent<Event::Update>(Event::Update const &e);
template void GameStateMachine::ProcessEvent<Event::Render>(Event::Render const &e);
+ template void GameStateMachine::ProcessEvent<Event::PushStart>(Event::PushStart const &e);
+ template void GameStateMachine::ProcessEvent<Event::PushSoundEdit>(Event::PushSoundEdit const &e);
+ template void GameStateMachine::ProcessEvent<Event::Escape>(Event::Escape const &e);
+ template void GameStateMachine::ProcessEvent<Event::Back>(Event::Back const &e);
}
struct Update {};
struct Render {};
struct Escape {};
+ struct Back {};
}
ref class GameMain;
struct GameStateMachine {
- private:
- struct impl;
- public:
-
explicit GameStateMachine(GameMain^ main);
template <class Event> void ProcessEvent(Event const& e);
void Start();
void Stop();
~GameStateMachine();
private:
+ struct impl;
std::unique_ptr<impl> impl_;
};
xmlns:common="using:ShootingGame.Common"
mc:Ignorable="d" Foreground="#FFFBF5F5" >
- <SwapChainBackgroundPanel x:Name="DXSwapChainPanel" >
+ <SwapChainBackgroundPanel x:Name="DXSwapChainPanel" ManipulationMode="None" >
<Grid x:Name="RouteGrid">
<Grid.RowDefinitions>
<RowDefinition Height="109*"/>
<RowDefinition Height="659*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
+<Button x:Name="backButton" Style="{StaticResource BackButtonStyle}" Click="backButton_Click" Margin="19,0,0,29"/>
+<UserControl x:Name="SubMenu"/>
+
+
+
<TextBlock HorizontalAlignment="Left" Height="23" Margin="486,24,0,0" TextWrapping="Wrap" Text="処理時間" VerticalAlignment="Top" Width="86" FontSize="20"/>
<TextBlock x:Name="processTime" HorizontalAlignment="Left" Height="23" Margin="572,24,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="121" FontSize="20"/>
<TextBlock HorizontalAlignment="Left" Height="18" Margin="833,29,0,0" TextWrapping="Wrap" Text="フレームレート" VerticalAlignment="Top" Width="139" FontSize="12"/>
- <TextBlock x:Name="frameTime" HorizontalAlignment="Left" Height="18" Margin="977,29,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="121" FontSize="20"/>
+ <TextBlock x:Name="frameTime" HorizontalAlignment="Left" Height="18" Margin="977,29,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="121" FontSize="13.333"/>
<TextBlock HorizontalAlignment="Left" Height="18" Margin="833,47,0,0" TextWrapping="Wrap" Text="最大" VerticalAlignment="Top" Width="139" FontSize="12"/>
- <TextBlock x:Name="frameTimeMax" HorizontalAlignment="Left" Height="18" Margin="977,47,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="121" FontSize="20"/>
+ <TextBlock x:Name="frameTimeMax" HorizontalAlignment="Left" Height="18" Margin="977,47,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="121" FontSize="13.333"/>
<TextBlock HorizontalAlignment="Left" Height="15" Margin="833,65,0,0" TextWrapping="Wrap" Text="最小" VerticalAlignment="Top" Width="139" FontSize="12"/>
- <TextBlock x:Name="frameTimeMin" HorizontalAlignment="Left" Height="15" Margin="977,65,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="121" FontSize="20"/>
+ <TextBlock x:Name="frameTimeMin" HorizontalAlignment="Left" Height="15" Margin="977,65,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="121" FontSize="13.333"/>
<TextBlock HorizontalAlignment="Left" Height="19" Margin="833,85,0,0" TextWrapping="Wrap" Text="平均" VerticalAlignment="Top" Width="139" FontSize="12"/>
- <TextBlock x:Name="frameTimeAvg" HorizontalAlignment="Left" Height="19" Margin="977,85,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="121" FontSize="12"/>
-<Button Content="Button" HorizontalAlignment="Left" Margin="317,61,0,0" VerticalAlignment="Top" Click="Button_Click_1"/>
+ <TextBlock x:Name="frameTimeAvg" HorizontalAlignment="Left" Height="19" Margin="977,85,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="121" FontSize="13.333"/>
</Grid>
<UserControl x:Name="SubContent" Grid.Row="1" />
</Grid>
//
#include "pch.h"
+#include "GameMain.h"
#include "MainPage.xaml.h"
#include "SoundEditorPage.xaml.h"
-using namespace ShootingGame;
-
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Xaml::Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
+namespace ShootingGame
+{
+
-MainPage::MainPage()
+MainPage::MainPage(GameMain^ g) : gameMain_(g)
{
InitializeComponent();
+ //std::function<void (Windows::UI::Xaml::Controls::Page^ )> f(std::bind(&MainPage::Subframe,this,std::placeholders::_1));
+ gameMain_->SetSubFrameFunc(ref new GameMain::SubFrameFuncDelegate(this,&MainPage::Subframe));
+ gameMain_->SetIsBackButtonEnabledDelgate( ref new GameMain::IsBackButtonEnabledDelgate
+ (
+ [this](bool v)
+ {
+ backButton->IsEnabled = v;
+ }
+ )
+ );
+}
- hiddenFrame_ = ref new Windows::UI::Xaml::Controls::Frame();
- hiddenFrame_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
- RouteGrid->Children->Append(hiddenFrame_);
- TypeName t = {ref new String(L"ShootingGame.SoundEditorPage"),TypeKind::Custom};
- if(!hiddenFrame_->Navigate(t,this))
+void MainPage::Subframe(Windows::UI::Xaml::Controls::Page^ p)
+{
+ if(p != nullptr)
{
- throw ref new FailureException(ref new String(L"サウンドエディタに切り替えできませんでした。"));
- };
-
- Page^ hiddenPage = safe_cast<Page^>(hiddenFrame_->Content);
- UIElement^ content = hiddenPage->Content;
- hiddenPage->Content = nullptr;
- SubContent->Content = content;
+ // hiddenFrame_->
+ UIElement^ content = p->Content;
+ p->Content = nullptr;
+ SubContent->Content = content;
+ } else {
+ SubContent->Content = nullptr;
+ }
}
+//UIElement^ MainPage::NavigateSubframe(Windows::UI::Xaml::Interop::TypeName typeName)
+//{
+// if(!hiddenFrame_->Navigate(typeName,this))
+// {
+// throw ref new FailureException(ref new String(L"切り替えできませんでした。"));
+// };
+//
+// Page^ hiddenPage = safe_cast<Page^>(hiddenFrame_->Content);
+// UIElement^ content = hiddenPage->Content;
+// hiddenPage->Content = nullptr;
+// SubContent->Content = content;
+// return content;
+//;
+//}
+
+
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
}
-void ShootingGame::MainPage::Button_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
-{
- //TypeName t = {ref new String(L"ShootingGame.SoundEditorPage"),TypeKind::Custom};
- // if(!hiddenFrame_->Navigate(t,this))
- // {
- // throw ref new FailureException(ref new String(L"サウンドエディタに切り替えできませんでした。"));
- // };
-
- // Page^ hiddenPage = safe_cast<Page^>(hiddenFrame_->Content);
- // UIElement^ content = hiddenPage->Content;
- // hiddenPage->Content = nullptr;
- // SubContent->Content = content;
-
- //Grid^ grid = safe_cast<Grid^>(hiddenPage->FindName(L"LayoutRoot"));
- //if(grid != nullptr){
- //// Get each element.
- //UIElement^ c = safe_cast<UIElement^>(grid->FindName(L"Editor"));
- //UIElementCollection^ collection = grid->Children;
- //unsigned int index;
- //collection->IndexOf(c, &index);
- //collection->RemoveAt(index);
- //SubContent->Content = c;
- //}
+//void ShootingGame::MainPage::Button_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
+//{
+// //TypeName t = {ref new String(L"ShootingGame.SoundEditorPage"),TypeKind::Custom};
+// // if(!hiddenFrame_->Navigate(t,this))
+// // {
+// // throw ref new FailureException(ref new String(L"サウンドエディタに切り替えできませんでした。"));
+// // };
+//
+// // Page^ hiddenPage = safe_cast<Page^>(hiddenFrame_->Content);
+// // UIElement^ content = hiddenPage->Content;
+// // hiddenPage->Content = nullptr;
+// // SubContent->Content = content;
+//
+// //Grid^ grid = safe_cast<Grid^>(hiddenPage->FindName(L"LayoutRoot"));
+// //if(grid != nullptr){
+// //// Get each element.
+// //UIElement^ c = safe_cast<UIElement^>(grid->FindName(L"Editor"));
+// //UIElementCollection^ collection = grid->Children;
+// //unsigned int index;
+// //collection->IndexOf(c, &index);
+// //collection->RemoveAt(index);
+// //SubContent->Content = c;
+// //}
+//
+//}
-}
+//void MainPage::GameMain(ShootingGame::GameMain^ p){gameMain_ = p;}
+//
+//ShootingGame::GameMain^ MainPage::GameMain(){return gameMain_; }
+//
+void ShootingGame::MainPage::backButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
+{
+ gameMain_->GameStateMachine().ProcessEvent(Event::Back());
+}
+}
\ No newline at end of file
#pragma once
#include "Common\LayoutAwarePage.h"
+#include "GameMain.h"
#include "MainPage.g.h"
namespace ShootingGame
{
- /// <summary>
- /// An empty page that can be used on its own or navigated to within a Frame.
- /// </summary>
- public ref class MainPage sealed
- {
- public:
- MainPage();
+
+ /// <summary>
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ /// </summary>
+ public ref class MainPage
+ {
+ internal:
+ MainPage(GameMain^ g);
Windows::UI::Xaml::Controls::SwapChainBackgroundPanel^ MainPage::SwapChainBackgroundPanel()
{
return DXSwapChainPanel;
}
- void UpdateProcessTime(float delta);
- void UpdateFrameTime(float delta,float max,float min,float avg);
-
- protected:
- virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
+ void UpdateProcessTime(float delta);
+ void UpdateFrameTime(float delta,float max,float min,float avg);
+ void Subframe(Windows::UI::Xaml::Controls::Page^ p);
+ protected:
+ virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
private:
- Windows::UI::Xaml::Controls::Frame^ hiddenFrame_;
- void Button_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ void backButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ GameMain^ gameMain_;
};
}
--- /dev/null
+<common:LayoutAwarePage
+ x:Name="pageRoot"
+ x:Class="ShootingGame.MenuPage"
+ DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
+ IsTabStop="false"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:local="using:ShootingGame"
+ xmlns:common="using:ShootingGame.Common"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ mc:Ignorable="d">
+
+ <Page.Resources>
+
+ <!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
+ <x:String x:Key="AppName">My Application</x:String>
+ </Page.Resources>
+ <Grid HorizontalAlignment="Left" Height="768" VerticalAlignment="Top" Width="1366">
+ <Button x:Name="StartButton" Content="ゲーム開始" HorizontalAlignment="Center" Height="75" Margin="470,220,464,473" VerticalAlignment="Center" Width="432" Click="Button_Click_2" FontSize="24"/>
+ <Button x:Name="EditSoundButton" Content="サウンド編集" HorizontalAlignment="Center" Height="75" Margin="470,316,464,377" VerticalAlignment="Center" Width="432" FontSize="24" Click="EditSoundButton_Click"/>
+ <Button x:Name="EditPosition" Content="配置エディタ" HorizontalAlignment="Center" Height="75" Margin="470,412,464,281" VerticalAlignment="Center" Width="432" FontSize="24"/>
+ </Grid>
+
+ <!--
+ This grid acts as a root panel for the page that defines two rows:
+ * Row 0 contains the back button and page title
+ * Row 1 contains the rest of the page layout
+ -->
+</common:LayoutAwarePage>
--- /dev/null
+//
+// MenuPage.xaml.cpp
+// Implementation of the MenuPage class
+//
+
+#include "pch.h"
+#include "MenuPage.xaml.h"
+
+using namespace ShootingGame;
+
+using namespace Platform;
+using namespace Windows::Foundation;
+using namespace Windows::Foundation::Collections;
+using namespace Windows::UI::Xaml;
+using namespace Windows::UI::Xaml::Controls;
+using namespace Windows::UI::Xaml::Controls::Primitives;
+using namespace Windows::UI::Xaml::Data;
+using namespace Windows::UI::Xaml::Input;
+using namespace Windows::UI::Xaml::Media;
+using namespace Windows::UI::Xaml::Navigation;
+
+// The Basic Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234237
+
+MenuPage::MenuPage(GameStateMachine& g) : gameStateMachine_(g)
+{
+ InitializeComponent();
+}
+
+/// <summary>
+/// Populates the page with content passed during navigation. Any saved state is also
+/// provided when recreating a page from a prior session.
+/// </summary>
+/// <param name="navigationParameter">The parameter value passed to
+/// <see cref="Frame::Navigate(Type, Object)"/> when this page was initially requested.
+/// </param>
+/// <param name="pageState">A map of state preserved by this page during an earlier
+/// session. This will be null the first time a page is visited.</param>
+void MenuPage::LoadState(Object^ navigationParameter, IMap<String^, Object^>^ pageState)
+{
+ (void) navigationParameter; // Unused parameter
+ (void) pageState; // Unused parameter
+}
+
+/// <summary>
+/// Preserves state associated with this page in case the application is suspended or the
+/// page is discarded from the navigation cache. Values must conform to the serialization
+/// requirements of <see cref="SuspensionManager::SessionState"/>.
+/// </summary>
+/// <param name="pageState">An empty map to be populated with serializable state.</param>
+void MenuPage::SaveState(IMap<String^, Object^>^ pageState)
+{
+ (void) pageState; // Unused parameter
+}
+
+
+void ShootingGame::MenuPage::Button_Click_2(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
+{
+ gameStateMachine_.ProcessEvent(Event::PushStart());
+}
+
+
+void ShootingGame::MenuPage::Button_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
+{
+
+}
+
+
+void ShootingGame::MenuPage::EditSoundButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
+{
+ gameStateMachine_.ProcessEvent(Event::PushSoundEdit());
+
+}
--- /dev/null
+//
+// MenuPage.xaml.h
+// Declaration of the MenuPage class
+//
+
+#pragma once
+#include "Common\LayoutAwarePage.h" // Required by generated header
+#include "MainPage.xaml.h"
+#include "GameMain.h"
+#include "MenuPage.g.h"
+
+namespace ShootingGame
+{
+ /// <summary>
+ /// A basic page that provides characteristics common to most applications.
+ /// </summary>
+ public ref class MenuPage sealed
+ {
+ internal:
+ explicit MenuPage(GameStateMachine& g);
+ protected:
+ virtual void LoadState(Platform::Object^ navigationParameter,
+ Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ pageState) override;
+ virtual void SaveState(Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ pageState) override;
+ private:
+ GameStateMachine& gameStateMachine_;
+ void Button_Click_2(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ void Button_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ void EditSoundButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ };
+}
<ClInclude Include="exception.h" />
<ClInclude Include="GameMain.h" />
<ClInclude Include=".\GameStateMachine.h" />
+ <ClInclude Include="MenuPage.xaml.h">
+ <DependentUpon>MenuPage.xaml</DependentUpon>
+ </ClInclude>
<ClInclude Include="pch.h" />
<ClInclude Include="App.xaml.h">
<DependentUpon>App.xaml</DependentUpon>
<ClInclude Include="sf_com.h" />
<ClInclude Include="sf_memory.h" />
<ClInclude Include="SoundDriver.h" />
+ <ClInclude Include="SoundEditor.h" />
<ClInclude Include="SoundEditorPage.xaml.h">
<DependentUpon>SoundEditorPage.xaml</DependentUpon>
</ClInclude>
<Page Include="MainPage.xaml">
<SubType>Designer</SubType>
</Page>
+ <Page Include="MenuPage.xaml">
+ <SubType>Designer</SubType>
+ </Page>
<Page Include="SoundEditorPage.xaml">
<SubType>Designer</SubType>
</Page>
<ClCompile Include="MainPage.xaml.cpp">
<DependentUpon>MainPage.xaml</DependentUpon>
</ClCompile>
+ <ClCompile Include="MenuPage.xaml.cpp">
+ <DependentUpon>MenuPage.xaml</DependentUpon>
+ </ClCompile>
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
using namespace Platform;
#pragma comment(lib, "mmdevapi.lib")
-using namespace std::placeholders;
+namespace stps = std::placeholders;
using namespace Microsoft::WRL;
namespace {
// : public RuntimeClass< RuntimeClassFlags< ClassicCom >, FtmBase, IActivateAudioInterfaceCompletionHandler >
{
- impl() : bufferIndex_(0),eventHolder_(nullptr),processBuffer_(std::bind(&SoundDriver::impl::DefaultProcessBuffer,this,_1,_2)),isStart_(false)
+ impl() : bufferIndex_(0),eventHolder_(nullptr),processBuffer_(std::bind(&SoundDriver::impl::DefaultProcessBuffer,this,stps::_1,stps::_2)),isStart_(false)
{
//::AvMMAvSetMmThreadCharacteristics
String^ deviceID = MediaDevice::GetDefaultAudioRenderId(AudioDeviceRole::Default);
void ResetProcessBufferFunc()
{
Stop();
- processBuffer_ = std::move(std::bind(&SoundDriver::impl::DefaultProcessBuffer,this,_1,_2));
+ processBuffer_ = std::move(std::bind(&SoundDriver::impl::DefaultProcessBuffer,this,stps::_1,stps::_2));
Start();
}
--- /dev/null
+#pragma once
+
+#include "SoundEditorPage.xaml.h"
+
+namespace ShootingGame
+{
+ namespace State {
+ struct SoundEdit_ : msmf::state_machine_def<SoundEdit_>
+ {
+ template <class Event, class Fsm>
+ void on_entry(Event const&, Fsm& fsm)
+ {
+ gameMain_ = fsm.GameMain();
+ };
+
+ template <class Event, class Fsm>
+ void on_exit(Event const&, Fsm& )
+ {
+
+ };
+
+ // \8fI\97¹\8fó\91Ô
+ struct Exit : msmf::exit_pseudo_state<msmf::none> {};
+
+ // \83A\83C\83h\83\8b\8fó\91Ô
+ struct Idle : msmf::state<>
+ {
+ template <class Event, class Fsm>
+ void on_entry(Event const&, Fsm& fsm)
+ {
+ gameMain_ = fsm.GameMain();
+ SoundEditorPage^ page_ = ref new SoundEditorPage();
+ gameMain_->Subframe(page_);
+ gameMain_->IsBackButtonEnabled(true);
+ }
+
+ template <class Event, class Fsm>
+ void on_exit(Event const&, Fsm& )
+ {
+ gameMain_->Subframe(nullptr);
+ page_ = nullptr;
+ };
+ private:
+ ShootingGame::GameMain^ gameMain_;
+ SoundEditorPage^ page_;
+ };
+
+ typedef boost::mpl::vector<Idle> initial_state;
+
+ // \8fó\91Ô\91J\88Ú\83e\81[\83u\83\8b
+ struct transition_table
+ : boost::mpl::vector<
+ msmf::Row<Idle,Event::Back,Exit>
+ >
+ {};
+
+ // No handled event handler
+ template <class Fsm,class Event>
+ void no_transition(Event const& e, Fsm& ,int state)
+ {
+ // std::cout << "No handled event in Sm1 " << typeid(e).name() << " on State " << state << std::endl;
+ }
+
+ // \83v\83\8d\83p\83e\83B
+ ShootingGame::GameMain^ SoundEdit_::GameMain(){return gameMain_;}
+ private:
+ ShootingGame::GameMain^ gameMain_; };
+
+ typedef msmb::state_machine<SoundEdit_> SoundEdit;
+
+ }
+}
\ No newline at end of file
<Grid x:Name="LayoutRoot" >
<local:EnvelopeEditorControl Margin="10,10.5,902,546.052" Height="Auto" Width="Auto"/>
<TextBlock HorizontalAlignment="Left" Height="90" Margin="697.956,31.955,0,0" TextWrapping="Wrap" Text="Sound Editor Page" VerticalAlignment="Top" Width="221"/>
+ <Slider HorizontalAlignment="Left" Margin="551,185,0,0" VerticalAlignment="Top" Width="511"/>
<VisualStateManager.VisualStateGroups>
protected:
virtual void LoadState(Platform::Object^ navigationParameter,
- Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ pageState) override;
- virtual void SaveState(Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ pageState) override;
+ Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ pageState) ;
+ virtual void SaveState(Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ pageState) ;
};
}
#include "pch.h"
#include "SoundManager.h"
-using namespace std::placeholders;
+
+namespace stps = std::placeholders;
namespace sf {
SoundManager::SoundManager(SoundDriver& driver) : driver_(driver),synth_(driver_.Format()),sequencer_(synth_,driver_.Format())
{
sequencer_.Tempo(150.0f);
TestSong song(sequencer_.SequenceTracks());
- driver_.SetProcessBufferFunc(std::bind(&SoundManager::ProcessBuffer,this,_1,_2));
+ driver_.SetProcessBufferFunc(std::bind(&SoundManager::ProcessBuffer,this,stps::_1,stps::_2));
}
void SoundManager::ProcessBuffer(boost::shared_array<float> arr,int bufferSize)
//#include "xbyak\xbyak.h"
#include "WaveTableSynth.h"
-using namespace std::placeholders;
+namespace stps = std::placeholders;
namespace sf {
waveTable_ = p;
if(waveTable_->stereo)
{
- processor_ = std::bind(&sf::Synthesizer::WaveTableOscillator::ProcessStereo,this,_1,_2,_3);
+ processor_ = std::bind(&sf::Synthesizer::WaveTableOscillator::ProcessStereo,this,stps::_1,stps::_2,stps::_3);
} else {
- processor_ = std::bind(&sf::Synthesizer::WaveTableOscillator::ProcessMono,this,_1,_2,_3);
+ processor_ = std::bind(&sf::Synthesizer::WaveTableOscillator::ProcessMono,this,stps::_1,stps::_2,stps::_3);
}
}
#include "sf_com.h"
#include "sf_memory.h"
#define COMPTR_TYPEDEF(x) typedef Microsoft::WRL::ComPtr<x> x## Ptr
+#include "windows.ui.xaml.media.dxinterop.h"
+