예제 #1
0
void RangeT<T>::load( const ci::JsonTree &data )
{
    if( data.hasChild( "LVALUE" ) && data.hasChild( "HVALUE" ) ) {
        setValue( data.getValueForKey<T>("LVALUE"), data.getValueForKey<T>("HVALUE") );
        trigger();
    }
    View::load( data );
}
예제 #2
0
void XYPad::load( const ci::JsonTree &data )
{
    if( data.hasChild( "XVALUE" ) && data.hasChild( "YVALUE" ) )
    {
        setValue( vec2( data.getValueForKey<float>( "XVALUE" ),
                        data.getValueForKey<float>( "YVALUE" ) ) );
        trigger();
    }
    View::load( data );
}
예제 #3
0
void ColorPicker::load( const ci::JsonTree &data )
{
	if( data.hasChild( "RED" ) && data.hasChild( "GREEN" ) && data.hasChild( "BLUE" ) && data.hasChild( "ALPHA" ) ) {
		setColor( ColorA( data.getValueForKey<float>( "RED" ), data.getValueForKey<float>( "GREEN" ), data.getValueForKey<float>( "BLUE" ), data.getValueForKey<float>( "ALPHA" ) ) );
		if( mTriggerOnLoad ) {
			trigger();
		}
	}
	View::load( data );
}
예제 #4
0
config::TextItem JsonTools::parseTextItem(ci::JsonTree json)
{
	config::TextItem textItem;
	textItem.setText(json.getChild("text").getValue<std::string>());
	textItem.setFontName(json.getChild("font").getValue<std::string>());
	textItem.setSize(json.getChild("size").getValue<int>());
	textItem.setColor(json.getChild("color").getValue<std::string>());

	return textItem;
}
예제 #5
0
void Radio::load( const ci::JsonTree &data )
{
    if( data.hasChild( "ACTIVE" ) )
    {
        activate( data.getValueForKey<string>("ACTIVE") );
    }
    View::load( data );
}
예제 #6
0
파일: Dialer.cpp 프로젝트: eriser/Cinder-UI
void DialerT<T>::load( const ci::JsonTree &data )
{
    if( data.hasChild( "VALUE" ) )
    {
        setValue( data.getValueForKey<T>("VALUE") );
        trigger();
    }
    View::load( data );
}
예제 #7
0
void TextInput::load( const ci::JsonTree &data )
{
	if( data.hasChild( "VALUE" ) ) {
		setValue( data.getValueForKey<string>( "VALUE" ) );
		if( mTriggerOnLoad ) {
			trigger();
		}
	}
	View::load( data );
}
예제 #8
0
void BSplineEditor::load( const ci::JsonTree &data )
{
	mControlPoints.clear();
	if( data.hasChild( "POINTS" ) ) {
		auto pts = data.getChild( "POINTS" );
		int total = pts.getNumChildren();
		if( (int)mControlPoints.size() < total ) {
			mControlPoints.resize( total );
		}
		for( int i = 0; i < total; i++ ) {
			auto child = pts.getChild( i );
			mControlPoints[i] = expand( vec2( child.getValueForKey<float>( "X" ), child.getValueForKey<float>( "Y" ) ) );
		}
		updateSplineRef();
		if( mTriggerOnLoad ) {
			trigger();
		}
	}
	View::load( data );
}
예제 #9
0
std::vector<T> getArray(const ci::JsonTree& json) noexcept {
  size_t num = json.getNumChildren();

  std::vector<T> array;
  array.reserve(num);

  for (size_t i = 0; i < num; ++i) {
    array.push_back(json[i].getValue<T>());
  }

  return array;
}
예제 #10
0
void MultiSlider::load( const ci::JsonTree &data )
{
	for( auto &it : mData ) {
		if( data.hasChild( it.mKey ) ) {
			setValue( it.mKey, data.getValueForKey<float>( it.mKey ) );
		}
		mHitKey = it.mKey;
		if( mTriggerOnLoad ) {
			trigger();
		}
	}
	mHitKey = "";
	View::load( data );
}
예제 #11
0
ec::SceneRef SceneFactory::createScene( const ci::JsonTree& init )
{
    std::string name = "";
    
    try{
        
        name = init.getValueForKey("name");
        
    } catch (const ci::JsonTree::ExcChildNotFound &e) {
        CI_LOG_E( e.what() );
    }
    
    if (name == "intro")
    {
        CI_LOG_V("parsed intro scene");
        return IntroScene::create(name);
    }else{
        return nullptr;
    }

}
예제 #12
0
  GameoverController(ci::JsonTree& params,
                     ci::TimelineRef timeline,
                     Event<EventParam>& event,
                     const EventParam& event_params,
                     std::unique_ptr<UIView>&& view) noexcept :
    params_(params),
    event_(event),
    tween_delay_(params["gameover.tween_delay"].getValue<float>()),
    event_delay_(params["gameover.event_delay"].getValue<float>()),
    deactive_delay_(params["gameover.deactive_delay"].getValue<float>()),
    sns_delay_(params["gameover.sns_delay"].getValue<float>()),
    view_(std::move(view)),
    active_(true),
    sns_url_(Localize::get(params["gameover.sns_url"].getValue<std::string>())),
    event_timeline_(ci::Timeline::create())
  {
    DOUT << "GameoverController()" << std::endl;
    
    auto current_time = timeline->getCurrentTime();
    event_timeline_->setStartTime(current_time);
    timeline->apply(event_timeline_);

    connections_ += event.connect("gameover-agree",
                                  [this](const Connection&, EventParam& param) noexcept {
                                    view_->setActive(false);
                                    
                                    event_timeline_->add([this]() noexcept {
                                        view_->startWidgetTween("tween-out");

                                        event_timeline_->add([this]() noexcept {
                                            event_.signal("check-after-gameover", EventParam());
                                            
                                            event_timeline_->add([this]() noexcept {
                                                active_ = false;
                                              },
                                              event_timeline_->getCurrentTime() + deactive_delay_);
                                          },
                                          event_timeline_->getCurrentTime() + event_delay_);
                                      },
                                      event_timeline_->getCurrentTime() + tween_delay_);
                                  });

    connections_ += event.connect("gameover-continue",
                                  [this](const Connection&, EventParam& param) noexcept {
                                    view_->setActive(false);
                                    
                                    event_timeline_->add([this]() noexcept {
                                        view_->startWidgetTween("tween-out");

                                        event_timeline_->add([this]() {
                                            event_.signal("continue-game", EventParam());
                                            
                                            event_timeline_->add([this]() noexcept {
                                                active_ = false;
                                              },
                                              event_timeline_->getCurrentTime() + deactive_delay_);
                                          },
                                          event_timeline_->getCurrentTime() + event_delay_);
                                      },
                                      event_timeline_->getCurrentTime() + tween_delay_);
                                  });

    connections_ += event.connect("selected-share",
                                  [this](const Connection&, EventParam& param) noexcept {
                                    view_->setActive(false);
                                    
                                    event_timeline_->add([this]() noexcept {
                                        DOUT << "Share" << std::endl;

                                        AppSupport::pauseDraw(true);
                                        
                                        Share::post(sns_text_,
                                                    Capture::execute(),
                                                    [this]() noexcept {
                                                      AppSupport::pauseDraw(false);
                                                      view_->setActive(true);
                                                    });
                                      },
                                      event_timeline_->getCurrentTime() + sns_delay_);
                                  });
    
    // 再開できるかどうかの判断
    if (boost::any_cast<bool>(event_params.at("can_continue"))) {
      view_->getWidget("continue").setDisp(true);
      view_->getWidget("continue").setActive(true);
      view_->getWidget("done").setDisp(true);
      view_->getWidget("done").setActive(true);

      view_->getWidget("agree").setDisp(false);
      view_->getWidget("agree").setActive(false);
    }

    
    auto game_score = boost::any_cast<int>(event_params.at("score"));
    view_->getWidget("score-result").setText(toFormatedString(game_score, 5));
    auto total_items = boost::any_cast<int>(event_params.at("total_items"));
    GameCenter::submitScore(game_score, total_items);

    if (game_score == 0) {
      GameCenter::submitAchievement("BRICKTRIP.ACHIEVEMENT.NO_SCORE");
    }
    
    if (boost::any_cast<bool>(event_params.at("hi_score"))) {
      view_->startWidgetTween("tween-hi-score");
    }
    
    view_->startWidgetTween("tween-in");
    requestSound(event_, params["gameover.jingle-se"].getValue<std::string>());

    if (params.hasChild("gameover.active_delay")) {
      view_->setActive(false);

      float delay = params["gameover.active_delay"].getValue<float>();
      event_timeline_->add([this]() noexcept {
          view_->setActive(true);
        },
        event_timeline_->getCurrentTime() + delay);
    }

    if (Capture::canExec() && Share::canPost()) {
      auto& widget = view_->getWidget("share");
        
      widget.setDisp(true);
      widget.setActive(true);
    }

    {
      // SNSへの投稿テキストはローカライズされたものを使う
      auto text = params["gameover.sns_text"].getValue<std::string>();
      
      sns_text_ = Localize::get(text);
      replaceString(sns_text_, "%1", std::to_string(game_score));
      replaceString(sns_text_, "%5", sns_url_);
    }
  }
예제 #13
0
T getValue(const ci::JsonTree& json, const std::string& name, const T& default_value) noexcept {
  return (json.hasChild(name)) ? json[name].getValue<T>()
                               : default_value;
}
예제 #14
0
Model::Model(ci::JsonTree & data, std::string idKey) : raw(data) {
    uid = data.getChild(idKey).getValue<int>();
}
예제 #15
0
Model::Model(ci::JsonTree & data) : raw(data) {
    uid = data.getChild("id").getValue<int>();
}
예제 #16
0
  SettingsController(ci::JsonTree& params,
                    ci::TimelineRef timeline,
                    Event<EventParam>& event,
                    Records& records,
                     std::unique_ptr<UIView>&& view) noexcept :
    params_(params),
    event_(event),
    tween_delay_(params["settings.tween_delay"].getValue<float>()),
    event_delay_(params["settings.event_delay"].getValue<float>()),
    deactive_delay_(params["settings.deactive_delay"].getValue<float>()),
    records_(records),
    view_(std::move(view)),
    active_(true),
    event_timeline_(ci::Timeline::create())
  {
    DOUT << "SettingsController()" << std::endl;

    auto current_time = timeline->getCurrentTime();
    event_timeline_->setStartTime(current_time);
    timeline->apply(event_timeline_);

    connections_ += event.connect("se-change",
                                  [this](const Connection&, EventParam& param) noexcept {
                                    bool active = records_.toggleSeOn();
                                    setSoundIcon("se-setting", active);
                                    
                                    EventParam p = {
                                      { "silent", !active },
                                    };
                                    event_.signal("se-silent", p);
                                    records_.write(params_["game.records"].getValue<std::string>());
                                  });

    connections_ += event.connect("bgm-change",
                                  [this](const Connection&, EventParam& param) noexcept {
                                    bool active = records_.toggleBgmOn();
                                    setSoundIcon("bgm-setting", active);
                                    
                                    EventParam p = {
                                      { "silent", !active },
                                    };
                                    event_.signal("bgm-silent", p);
                                    records_.write(params_["game.records"].getValue<std::string>());
                                  });

    connections_ += event.connect("settings-agree",
                                  [this](const Connection&, EventParam& param) noexcept {
                                    view_->setActive(false);

                                    event_timeline_->add([this]() noexcept {
                                        view_->startWidgetTween("tween-out");

                                        event_timeline_->add([this]() noexcept {
                                            EventParam params = {
                                              { "menu-to-title", true },
                                            };
                                            event_.signal("begin-title", params);
                                            
                                            event_timeline_->add([this]() noexcept {
                                                active_ = false;
                                              },
                                              event_timeline_->getCurrentTime() + deactive_delay_);
                                          },
                                          event_timeline_->getCurrentTime() + event_delay_);
                                      },
                                      event_timeline_->getCurrentTime() + tween_delay_);
                                  });
    
    setSoundIcon("se-setting", records_.isSeOn());
    setSoundIcon("bgm-setting", records_.isBgmOn());

    view_->startWidgetTween("tween-in");
    requestSound(event_, params["settings.jingle-se"].getValue<std::string>());

    if (params.hasChild("settings.active_delay")) {
      view_->setActive(false);

      float delay = params["settings.active_delay"].getValue<float>();
      event_timeline_->add([this]() noexcept {
          view_->setActive(true);
        },
        event_timeline_->getCurrentTime() + delay);
    }
    
    GameCenter::submitAchievement("BRICKTRIP.ACHIEVEMENT.VIEWED_SETTINGS");
  }