1 #include "MyInstructionSet.hpp"
2 #include "mof/ImageTileWidgetView.hpp"
3 #include "mof/utilities.hpp"
4 #include "mof/LayoutManager.hpp"
5 #include "mof/Deleter.hpp"
6 #include "mof/mofInput.hpp"
7 #include "mof/mofGraphics.hpp"
8 #include <boost/bind.hpp>
9 #include "mof/EventScheduler.hpp"
11 #include "mof/ConsoleIO.hpp"
12 #include "mof/widgets.hpp"
14 struct MyInstructionSet::Impl
16 std::list<boost::weak_ptr<mof::MessageWidget> > inactiveResources;
17 mof::EventScheduler scheduler;
18 std::list<boost::shared_ptr<mof::MessageWidget> > messages;
31 MyInstructionSet::MyInstructionSet( )
32 : m_pImpl(new Impl() )
37 MyInstructionSet::~MyInstructionSet( )
40 //{{{ createMessageWidget
41 boost::shared_ptr<mof::MessageWidget>
42 MyInstructionSet::createMessageWidget( )
44 mof::LayoutManager* pLayout = new mof::LayoutManager( mof::LayoutManager::HORIZONTAL , 1);
45 mof::WidgetView* pBackgroundView = new mof::ImageTileWidgetView( _T("image/frame0.png") );
48 boost::shared_ptr<mof::MessageWidget> p
50 new mof::MessageWidget
53 mof::Rectangle<int>(70+20 , 300 , 570+20 , 450) , pLayout
57 m_pImpl->messages.push_back(p);
62 //{{{ addMessageWidgetPage
64 MyInstructionSet::addMessageWidgetPage
66 boost::shared_ptr<mof::MessageWidget>& message ,
67 const mof::tstring &title ,
68 const mof::tstring &text
71 mof::PageRequest page(text , mof::Font(_T("
\94~UI
\83S
\83V
\83b
\83N") , 25) );
72 message->addPage( page );
73 return 30;// TODO
\83y
\81[
\83W
\8aJ
\82
\82Ì
\82É
\82©
\82©
\82é
\8e\9e\8aÔ
77 void MyInstructionSet::inactive( boost::shared_ptr<mof::MessageWidget>& message )
80 /*mof::Deleter<mof::MessageWidget> del(message);
82 m_pImpl->inactiveResources.push_back(del.getWeak());
83 m_pImpl->scheduler.addEvent( 40 , del );*/
84 //m_pImpl->scheduler.addEvent( 40 , boost::bind( &mof::Interpreter::doNextCommand , this ) );
87 void MyInstructionSet::update( )
89 m_pImpl->scheduler.update( );
90 foreach(boost::weak_ptr<mof::MessageWidget>& resource , m_pImpl->inactiveResources)
92 if(resource.lock())resource.lock()->update();
96 void MyInstructionSet::draw() const
98 foreach(boost::shared_ptr<mof::MessageWidget>& resource , m_pImpl->messages )
102 foreach(boost::weak_ptr<mof::MessageWidget>& resource , m_pImpl->inactiveResources)
104 if(resource.lock())resource.lock()->draw();