Exemplo n.º 1
0
EngineClient::EngineClient(	ds::App& app, const ds::cfg::Settings& settings,
							ds::EngineData& ed, const ds::RootList& roots)
		: inherited(app, settings, ed, roots)
		, mLoadImageService(*this, mIpFunctions)
		, mRenderTextService(mRenderTextThread)
		, mSender(mSendConnection)
		, mReceiver(mReceiveConnection)
		, mBlobReader(mReceiver.getData(), *this)
		, mSessionId(0)
		, mConnectionRenewed(false)
		, mServerFrame(-1)
		, mState(nullptr)
		, mIoInfo(*this)
{

	// NOTE:  Must be EXACTLY the same items as in EngineServer, in same order,
	// so that the BLOB ids match.
	HEADER_BLOB = mBlobRegistry.add([this](BlobReader& r) {receiveHeader(r.mDataBuffer);});
	COMMAND_BLOB = mBlobRegistry.add([this](BlobReader& r) {receiveCommand(r.mDataBuffer);});
	DELETE_SPRITE_BLOB = mBlobRegistry.add([this](BlobReader& r) {receiveDeleteSprite(r.mDataBuffer);});
	CLIENT_STATUS_BLOB = mBlobRegistry.add([this](BlobReader& r) {receiveClientStatus(r.mDataBuffer); });
	CLIENT_INPUT_BLOB = mBlobRegistry.add([this](BlobReader& r) {receiveClientInput(r.mDataBuffer); });
	mReceiver.setHeaderAndCommandIds(HEADER_BLOB, COMMAND_BLOB);
	
	try {
		if (settings.getBool("server:connect", 0, true)) {
			mSendConnection.initialize(true, settings.getText("server:ip"), ds::value_to_string(settings.getInt("server:listen_port")));
			mReceiveConnection.initialize(false, settings.getText("server:ip"), ds::value_to_string(settings.getInt("server:send_port")));
		}
	} catch(std::exception &e) {
		DS_LOG_ERROR_M("EngineClient::EngineClient() initializing UDP: " << e.what(), ds::ENGINE_LOG);
	}

	setState(mClientStartedState);
}
Exemplo n.º 2
0
DrawTouchView::DrawTouchView(ds::ui::SpriteEngine& e, const ds::cfg::Settings &settings, ds::ui::TouchManager& tm)
	: ds::ui::Sprite(e)
	, mTouchTrailsUse(false)
	, mTouchTrailsLength(5)
	, mTouchTrailsIncrement(5.0f) {
	mTouchTrailsUse = settings.getBool("touch_overlay:trails:use", 0, mTouchTrailsUse);
	mTouchTrailsLength = settings.getInt("touch_overlay:trails:length", 0, mTouchTrailsLength);
	mTouchTrailsIncrement = settings.getFloat("touch_overlay:trails:increment", 0, mTouchTrailsIncrement);

	if(mTouchTrailsUse){
		setTransparent(false); 
		setColor(settings.getColor("touch_color", 0, ci::Color(1.0f, 1.0f, 1.0f)));
	}

	tm.setCapture(this);
}