Exemple #1
0
void ScreenPainter::drawRect(QRectF rect)
{
	m_painter->save();
	setupState(true);
	m_painter->drawRect(rect.x(), rect.y(), rect.width(), rect.height());
	m_painter->restore();
}
Exemple #2
0
void ScreenPainter::drawGlyphOutline(const GlyphLayout gl, bool fill)
{
	if (fill)
		drawGlyph(gl);
	m_painter->save();
	bool fr = m_painter->fillRule();
	m_painter->setFillRule(false);

	setupState(false);
	m_painter->translate(0, -(fontSize() * gl.scaleV));

	FPointArray outline = font().glyphOutline(gl.glyph);
	double scaleHv = gl.scaleH * fontSize() / 10.0;
	double scaleVv = gl.scaleV * fontSize() / 10.0;
	QTransform trans;
	trans.scale(scaleHv, scaleVv);
	outline.map(trans);
	m_painter->setupPolygon(&outline, true);
	if (outline.size() > 3)
	{
		m_painter->setLineWidth(strokeWidth());
		m_painter->strokePath();
	}

	m_painter->setFillRule(fr);
	m_painter->restore();

}
Exemple #3
0
void ScreenPainter::drawLine(QPointF start, QPointF end)
{
	m_painter->save();
	setupState(false);
	m_painter->drawLine(start, end);
	m_painter->restore();
}
// Test adventurer
int main() {
    struct gameState G;
    struct gameState *p = &G;
    setupState(p);
    int x = testAdventurerPass(p);
    return x;
}
Exemple #5
0
void ScreenPainter::drawObject(PageItem* embedded)
{
	QRectF cullingArea;
	if (!embedded)
		return;
	if (!m_item->m_Doc->DoDrawing)
		return;

	m_painter->save();
	setupState(false);

	double pws = embedded->m_lineWidth;

	embedded->Dirty = m_item->Dirty;
	embedded->invalid = true;
	embedded->DrawObj_Pre(m_painter);

	switch(embedded->itemType())
	{
	case PageItem::ImageFrame:
	case PageItem::TextFrame:
	case PageItem::LatexFrame:
	case PageItem::OSGFrame:
	case PageItem::Polygon:
	case PageItem::PathText:
	case PageItem::Symbol:
	case PageItem::Group:
	case PageItem::RegularPolygon:
	case PageItem::Arc:
	case PageItem::Table:
		embedded->DrawObj_Item(m_painter, cullingArea);
		break;
	case PageItem::Line:
	case PageItem::PolyLine:
	case PageItem::Spiral:
	//	embedded->m_lineWidth = pws * qMin(scaleH(), scaleV());
		embedded->DrawObj_Item(m_painter, cullingArea);
		break;
	default:
		break;
	}

//	embedded->m_lineWidth = pws * qMin(scaleH(), scaleV());
	embedded->DrawObj_Post(m_painter);
	embedded->m_lineWidth = pws;

	if (m_item->m_Doc->guidesPrefs().framesShown)
	{
		int fm = m_painter->fillMode();
		m_painter->setPen(PrefsManager::instance()->appPrefs.displayPrefs.frameNormColor, 0, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin);
		m_painter->setFillMode(ScPainter::None);
		QRectF bBox = embedded->getVisualBoundingRect();
		m_painter->drawSharpRect(0, 0, bBox.width(), bBox.height());
		m_painter->setFillMode(fm);
	}

	m_painter->restore();
}
Exemple #6
0
bool GameCharacter::init( const char *animationName )
{
	if (!Node::init())
	{
		return false;
	}

	auto animationController = AnimationController::create();
	this->addComponent(animationController);

	animationController->load(animationName);
	animationController->setMovementCallback([=](cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID) {
		if (movementID.compare("attack_down") == 0)
		{
			if (movementType == cocostudio::MovementEventType::LOOP_COMPLETE || movementType == cocostudio::MovementEventType::COMPLETE)
			{
				this->doIdle();
			}
		}
	});

	auto fsm = StateMachine::create();
	this->addComponent(fsm);

	// init finite state machine
	fsm->setupState("doStartup", StateMachine::STATE_NONE, State::Idle);	
	fsm->setupState("doIdle", State::Walk, State::Idle);
	fsm->setupState("doIdle", State::Run, State::Idle);
	fsm->setupState("doWalk", State::Idle, State::Walk);
	fsm->setupState("doWalk", State::Run, State::Walk);
	fsm->setupState("doRun", State::Idle, State::Run);
	fsm->setupState("doRun", State::Walk, State::Run);
	fsm->setupState("doAttack", StateMachine::STATE_ALL, State::Attack);

	fsm->registerEnterStateCallback(State::Idle, [this](const char *eventName, int fromState, int toState) {
		this->onIdle();
		return true;
	});
	fsm->registerEnterStateCallback(State::Walk, [this](const char *eventName, int fromState, int toState) {
		this->onWalk();
		return true;
	});
	fsm->registerEnterStateCallback(State::Run, [this](const char *eventName, int fromState, int toState) {
		this->onRun();
		return true;
	});
	fsm->registerEnterStateCallback(State::Attack, [this](const char *eventName, int fromState, int toState) {
		this->onAttack();
		return true;
	});

	this->scheduleUpdate();

	return true;
}
/**
 * \brief Timer upate
 */
void	calibrationwidget::statusUpdate() {
	try {
		// find out whether something has changed in the state
		setupState();

		// check whether the calibration has changed
		snowstar::Calibration	cal = _guider->getCalibration(_controltype);
		if ((_calibration.id == cal.id)
			&& (_calibration.points.size() == cal.points.size())) {
			return;
		}
		_calibration = cal;
		ui->calibrationdisplayWidget->setCalibration(_calibration);
		displayCalibration();
	} catch (...) {

	}
}
Exemple #8
0
int main(int argc, char **argv){
  SelectStream(2);
  PutSeed(time(NULL));
  if(argc < 2){
    printf("Usage: cardtest4 <number of times to run>\n");
    return 1;
  }
  
  int loops = atoi(argv[1]);
  int i, failures = 0;
  struct gameState G; 
  for(i = 0; i < loops; i++) {
    setupState(&G);
    failures += testAdventurer(&G, i);
  }
  printf("Tests Run: %d, Tests passed: %d, Tests failed: %d\n", 
	 loops, loops - failures, failures);
  return 0;
}
void SSLEXScanner::yyDoBeforeRule( void )
{
	//set some stuff before a new rule is scanned

	//reset
	lastAcceptingState = -1;

	//base position for lexem
	startPos = pos;

	//are we at the beginning of a line?
	if( ( pos == basePos ) || ( pos[-1] == '\n' ) )
		//setup state
		state = setupState( baseState );

	else
		//base-State
		state = baseState;
}
/**
 * \brief handle when calibrate was clicked
 */
void	calibrationwidget::calibrateClicked() {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "start calibration for GuidePort");
	// make sure we have the most recent information on the
	// state
	setupState();
	if (_state == snowstar::GuiderCALIBRATING) {
		try {
			_guider->cancelCalibration();
		} catch (const std::exception& x) {
		}
	} else {
		if (_guidercontroller) {
			_guidercontroller->setupTracker();
		}
		try {
			_guider->startCalibration(_controltype);
		} catch (const std::exception& x) {
		}
	}
}
Exemple #11
0
int
main(int argc, char *argv[])
{
	int largc;
	char **largv;
	osInit();
	subsumeImplicitArgs(argc, argv, &largc, &largv);
	initState(argv[0]);
	uclSysName = getCfgName(largc, largv);
	uclOptFile = getCfgFile(largc, largv);

	if (!uclOptFile) exit(2);

	loadConfiguration();
	handleOptions(largc, largv);

	if (!setupState())
		exit(2);

	if (dbgLevel > 2) {
		int i;
		printf("Command:");
		for (i=0; i<largc; i++) {
			printf(" %s", largv[i]);
		}
		printf("\n");
	}

	generateCommands();
	
	if (!executeCommands())
                exit(1);
	exit(0);
	/* gack */
	return 0;
}
Exemple #12
0
void ScreenPainter::drawGlyph(const GlyphLayout gl)
{
	bool showControls = (m_item->doc()->guidesPrefs().showControls) &&
			    (gl.glyph == font().char2CMap(QChar(' ')) || gl.glyph >= ScFace::CONTROL_GLYPHS);
#if CAIRO_HAS_FC_FONT
	if (m_painter->fillMode() == 1 && m_painter->maskMode() <= 0 && !showControls)
	{
		m_painter->save();

		setupState(false);

		cairo_t* cr = m_painter->context();
		double r, g, b;
		m_painter->brush().getRgbF(&r, &g, &b);
		cairo_set_source_rgba(cr, r, g, b, m_painter->brushOpacity());
		m_painter->setRasterOp(m_painter->blendModeFill());

		if (m_fontPath != font().fontFilePath() || m_faceIndex != font().faceIndex() || m_cairoFace == NULL)
		{
			m_fontPath = font().fontFilePath();
			m_faceIndex = font().faceIndex();
			// A very ugly hack as we can’t use the font().ftFace() because
			// Scribus liberally calls FT_Set_CharSize() with all sorts of
			// crazy values, breaking any subsequent call to the layout
			// painter.  FIXME: drop the FontConfig dependency here once
			// Scribus font handling code is made sane!
			FcPattern *pattern = FcPatternBuild(NULL,
							    FC_FILE, FcTypeString, QFile::encodeName(font().fontFilePath()).data(),
							    FC_INDEX, FcTypeInteger, font().faceIndex(),
							    NULL);
			m_cairoFace = cairo_ft_font_face_create_for_pattern(pattern);
			FcPatternDestroy(pattern);
		}

		cairo_set_font_face(cr, m_cairoFace);
		cairo_set_font_size(cr, fontSize());

		cairo_scale(cr, gl.scaleH, gl.scaleV);
		cairo_glyph_t glyph = { gl.glyph, 0, 0 };
		cairo_show_glyphs(cr, &glyph, 1);

		m_painter->restore();
		return;
	}
#endif
	m_painter->save();

	setupState(false);

	bool fr = m_painter->fillRule();
	m_painter->setFillRule(false);

	uint gid = gl.glyph;
	if (showControls)
	{
		bool stroke = false;
		if (gid >= ScFace::CONTROL_GLYPHS)
			gid -= ScFace::CONTROL_GLYPHS;
		else
			gid = 32;
		QTransform chma, chma4;
		FPointArray outline;
		if (gid == SpecialChars::TAB.unicode())
		{
			outline = m_item->doc()->symTab.copy();
			chma4.translate(gl.xadvance - fontSize() * gl.scaleH * 0.7, -fontSize() * gl.scaleV * 0.5);
		}
		else if (gid == SpecialChars::COLBREAK.unicode())
		{
			outline = m_item->doc()->symNewCol.copy();
			chma4.translate(0, -fontSize() * gl.scaleV * 0.6);
		}
		else if (gid == SpecialChars::FRAMEBREAK.unicode())
		{
			outline = m_item->doc()->symNewFrame.copy();
			chma4.translate(0, -fontSize() * gl.scaleV * 0.6);
		}
		else if (gid == SpecialChars::PARSEP.unicode())
		{
			outline = m_item->doc()->symReturn.copy();
			chma4.translate(0, -fontSize() * gl.scaleV * 0.8);
		}
		else if (gid == SpecialChars::LINEBREAK.unicode())
		{
			outline = m_item->doc()->symNewLine.copy();
			chma4.translate(0, -fontSize() * gl.scaleV * 0.4);
		}
		else if (gid == SpecialChars::NBSPACE.unicode() || gid == 32)
		{
			stroke = (gid == 32);
			outline = m_item->doc()->symNonBreak.copy();
			chma4.translate(0, -fontSize() * gl.scaleV * 0.4);
		}
		else if (gid == SpecialChars::NBHYPHEN.unicode())
		{
			outline = font().glyphOutline(font().char2CMap(QChar('-')), fontSize());
			chma4.translate(0, -fontSize() * gl.scaleV);
		}
		else if (gid == SpecialChars::SHYPHEN.unicode())
		{
			outline.resize(0);
			outline.addQuadPoint(0, -10, 0, -10, 0, -6, 0, -6);
			stroke = true;
		}
		else if (gid == SpecialChars::OBJECT.unicode())
		{
			//for showing marks entries as control chars
			outline.resize(0);
			outline.addQuadPoint(0, -8, 1, -8, 0, -6, 1, -6);
			stroke = true;
		}
		else // ???
		{
			outline.resize(0);
			outline.addQuadPoint(0, -10, 0, -10, 0, -9, 0, -9);
			outline.addQuadPoint(0, -9, 0, -9, 1, -9, 1, -9);
			outline.addQuadPoint(1, -9, 1, -9, 1, -10, 1, -10);
			outline.addQuadPoint(1, -10, 1, -10, 0, -10, 0, -10);
		}
		chma.scale(gl.scaleH * fontSize() / 10.0, gl.scaleV * fontSize() / 10.0);
		outline.map(chma * chma4);
		m_painter->setupPolygon(&outline, true);
		QColor oldBrush = m_painter->brush();
		// FIXME
		/* p->setBrush( (flags & ScLayout_SuppressSpace) ? Qt::green
				: PrefsManager::instance()->appPrefs.displayPrefs.controlCharColor);*/
		m_painter->setBrush(PrefsManager::instance()->appPrefs.displayPrefs.controlCharColor);
		if (stroke)
		{
			QColor tmp = m_painter->pen();
			m_painter->setStrokeMode(1);
			m_painter->setPen(m_painter->brush(), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
			m_painter->setLineWidth(fontSize() * gl.scaleV / 20.0);
			m_painter->strokePath();
			m_painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
		}
		else
		{
			m_painter->setFillMode(1);
			m_painter->fillPath();
		}
		m_painter->setBrush(oldBrush);
	}
	else
	{
		m_painter->translate(0, -(fontSize() * gl.scaleV));
		double scaleH = gl.scaleH * fontSize() / 10.0;
		double scaleV = gl.scaleV * fontSize() / 10.0;
		m_painter->scale(scaleH, scaleV);
		FPointArray outline = font().glyphOutline(gid);
		m_painter->setupPolygon(&outline, true);
		if (outline.size() > 3)
			m_painter->fillPath();
	}
	m_painter->setFillRule(fr);

	m_painter->restore();
}