OSDN Git Service

Merge branch 'master' of o_ggy@git.sourceforge.jp:/gitroot/moflib/moflib
[moflib/moflib.git] / saisei-1.0 / rpg / rpg / widget / createMenuView.cpp
1 #include "widget/createMenuView.hpp"
2 #include <mof/widgets.hpp>
3 #include "widget/HighlightButtonView.hpp"
4 #include <mof/FactoryMethod.hpp>
5 #include <mof/Font.hpp>
6 #include <mof/utilities.hpp>
7 #include "configure.hpp"
8 #include "resource.hpp"
9 #include <mof/widget/TextCompiler.hpp>
10
11 using mof::widget::WidgetView;
12 using mof::widget::ImageView;
13
14 namespace 
15 {
16         std::shared_ptr<mof::widget::AbstractTextCompiler> text_compiler;
17 }
18
19 mof::FactoryMethod<WidgetView> createMenuView(const mof::tstring& text, bool is_disable_item)
20 {
21         //using namespace mof::widget;
22
23         if (text_compiler.get() == NULL) {
24                 text_compiler = std::make_shared<mof::widget::TextCompiler>
25                         (
26                                 mof::Font(FONT_NAME_UME, FONT_SIZE_STANDARD),
27                                 [] (const mof::tstring& path) { return ::getTextureResourceManager(::SYSTEM)->getResource(path);}
28                         );
29
30                 text_compiler->setBehaviorOnColor
31                 (
32                         mof::widget::AbstractTextCompiler::PAGE_OPEN, 
33                         mof::makeConstantHandler(mof::Color4f(1, 1, 1, 1)),
34                         0
35                 );
36
37                 text_compiler->setBehaviorOnColor
38                 (
39                         mof::widget::AbstractTextCompiler::PAGE_CLOSE, 
40                         mof::makeConstantHandler(mof::Color4f(1, 1, 1, 1)),
41                         0
42                 );
43         }
44
45     return mof::makeFactoryMethod<HighlightButtonView> 
46         (
47                         [text]() {return text_compiler->compile_d(text).release();},
48                         is_disable_item
49         );
50 }
51
52
53