OSDN Git Service

fix build system ofmoflib1 and saisei1
[moflib/moflib.git] / saisei-1.0 / src / oldcode / Demo1.cpp~
1 #include "Demo1.hpp"
2 #include "configure.hpp"
3 #include "MyInstructionSet.hpp"
4 #include "mof/Interpreter.hpp"
5 #include "mof/EventScheduler.hpp"
6 #include "mof/mofInput.hpp"
7 #include "mof/mofGraphics.hpp"
8 #include "mof/Application.hpp"
9 #include "mof/utilities.hpp"
10 #include "mof/widgets.hpp"
11 #include "mof/Font.hpp"
12 #include "resource.hpp"
13 #include <mof/streams.hpp>
14 #include <mof/FactoryMethod.hpp>
15 #include <boost/bind.hpp> 
16 #include <boost/make_shared.hpp> 
17 #include "widget/createMenuView.hpp"
18 #include "widget/createFrame.hpp"
19
20 using namespace mof::widget;
21 using namespace boost;
22
23 namespace
24 {
25         
26         boost::shared_ptr<mof::InputReceiver> m_pInputReceiver;
27         mof::EventScheduler m_scheduler;
28     Frame* m_pView;
29     shared_ptr<Menu> m_pWidget;
30 }
31         
32 namespace Demo1
33 {
34
35     void initialize()
36     {
37
38
39         {
40             mof::widget::MenuItem menuItems[] = {
41                 mof::widget::MenuItem
42                 (
43                     ::createMenuView(_T("\83L\81[\83{\81[\83h\82Ì\81ª\81«\82Å\81A")) 
44                 ) ,
45                 mof::widget::MenuItem
46                 (
47                     ::createMenuView(_T("\91I\91ð\8e\88\82ð\95Ï\8dX\82Å\82«\82Ü\82·\81B")) 
48                 ) ,
49                 mof::widget::MenuItem
50                 (
51                     ::createMenuView(_T("\83t\83H\81[\83J\83X\82³\82ê\82½\91I\91ð\8e\88\82Í\83A\83j\83\81\81[\83V\83\87\83\93\82ª\81A"))
52                 ) ,
53                 mof::widget::MenuItem
54                 (
55                     ::createMenuView(_T("\83A\81[\83N\83X\83\8c\83C\83\84\81[ +128")) 
56                 ) ,
57
58
59             };
60             m_pWidget = make_shared<Menu>( menuItems[0] , mof::lastOf( menuItems ) );
61
62             m_pView = 
63                 createFrame
64                 (
65                     _T("\91I\91ð\83\81\83j\83\85\81[\82Ì\83f\83\82") ,
66                     _T("image/frame0.png") ,
67                     _T("image/frame3.png") ,
68                     m_pWidget->getView()
69                 ).release();
70         }
71         
72         {
73             m_pView->getView()->getPositionStream() << mof::makeConstantHandler( mof::Vector2D(100, 100) );
74         }
75
76         m_pView->show();
77
78         m_pInputReceiver = boost::shared_ptr<mof::InputReceiver>(mof::InputDevice::getInputReceiver());
79         
80             mof::GraphicsDevice::lightEnable(false);
81             mof::GraphicsDevice::setAlphaBlendingMode(mof::GraphicsDevice::BLENDING_MODE_ALPHA);
82
83             
84
85             //---input event\82Ì\90Ý\92è
86             m_scheduler.addEvent
87         (
88                     new mof::KeyPressedEventCondition( mof::InputReceiver::ESCAPE , m_pInputReceiver ) , 
89                     &mof::Application::quit 
90                 );
91         m_scheduler.addEvent
92         (
93                     new mof::KeyPressedEventCondition( mof::InputReceiver::UP , m_pInputReceiver ) , 
94                     boost::bind( &Menu::up , m_pWidget ) 
95                 );
96         m_scheduler.addEvent
97         (
98                     new mof::KeyPressedEventCondition( mof::InputReceiver::DOWN , m_pInputReceiver ) , 
99                     boost::bind( &Menu::down , m_pWidget ) 
100                 );
101         m_scheduler.addEvent
102         (
103                     new mof::KeyPressedEventCondition( mof::InputReceiver::LEFT , m_pInputReceiver ) , 
104                     boost::bind( &Menu::left , m_pWidget ) 
105                 );
106         m_scheduler.addEvent
107         (
108                     new mof::KeyPressedEventCondition( mof::InputReceiver::RIGHT , m_pInputReceiver ) , 
109                     boost::bind( &Menu::right , m_pWidget ) 
110                 );
111
112
113     }
114
115     void finalize( )
116     {
117         mof::safe_delete( m_pView );
118     }
119     
120     
121
122     void update()
123     {
124         m_scheduler.update();
125         m_pInputReceiver->update();
126         m_pView->update( );
127     }
128
129     void draw()
130     {
131             mof::VertexXYZRHWC vertices[] = 
132             {
133                 mof::VertexXYZRHWC(mof::Vector2D(0 , 0) , mof::createColor(0 , 0 , 127)) ,
134                 mof::VertexXYZRHWC(mof::Vector2D(640 , 0) , mof::createColor(0 , 0 , 127)) ,
135                 mof::VertexXYZRHWC(mof::Vector2D(0 , 480) , mof::createColor(0 , 0 , 0)) ,
136                 mof::VertexXYZRHWC(mof::Vector2D(640 , 480) , mof::createColor(0 , 0 , 0))
137             };
138             mof::GraphicsDevice::setTexture(NULL);
139             mof::GraphicsDevice::drawVertexArray(vertices[0] , vertices[3] , mof::PRIMITIVE_TYPE_TRIANGLESTRIP );
140         
141         m_pView->getView()->draw( );
142     }
143
144 } // namespace Demo1
145
146