void RenderScrollbarPart::paintIntoRect(GraphicsContext* graphicsContext, int tx, int ty, const IntRect& rect)
{
    // Make sure our dimensions match the rect.
    setLocation(rect.x() - tx, rect.y() - ty);
    setWidth(rect.width());
    setHeight(rect.height());

    if (graphicsContext->paintingDisabled())
        return;

    // Now do the paint.
    RenderObject::PaintInfo paintInfo(graphicsContext, rect, PaintPhaseBlockBackground, false, 0, 0);
    paint(paintInfo, tx, ty);
    paintInfo.phase = PaintPhaseChildBlockBackgrounds;
    paint(paintInfo, tx, ty);
    paintInfo.phase = PaintPhaseFloat;
    paint(paintInfo, tx, ty);
    paintInfo.phase = PaintPhaseForeground;
    paint(paintInfo, tx, ty);
    paintInfo.phase = PaintPhaseOutline;
    paint(paintInfo, tx, ty);
}
Example #2
0
void welcome(GWindow window)
{
	GRect rectW = newGRect(0, 0, WIDTH, HEIGHT);
    setFilled(rectW, true);
    setColor(rectW, "#008080");
    add(window, rectW);
    
    GLabel labelW = newGLabel("Hello World!!");
    setFont(labelW, "SansSerif-32");
    setLabel(labelW, "Tic-Tac-Toe");
    add(window, labelW);
    double x = WIDTH/2 - getWidth(labelW)/2;
    double y = HEIGHT/2;
    setLocation(labelW, x, y);
    
    // Wait for Click
    waitForClick();
    
    // Remove Welcome Message
    removeGWindow(window, labelW);

}
Example #3
0
void RenderScrollbarPart::paintIntoRect(GraphicsContext* graphicsContext, const LayoutPoint& paintOffset, const LayoutRect& rect)
{
    // Make sure our dimensions match the rect.
    setLocation(rect.location() - toSize(paintOffset));
    setWidth(rect.width());
    setHeight(rect.height());

    if (graphicsContext->paintingDisabled())
        return;

    // Now do the paint.
    PaintInfo paintInfo(graphicsContext, pixelSnappedIntRect(rect), PaintPhaseBlockBackground, false, 0, 0, 0);
    paint(paintInfo, paintOffset);
    paintInfo.phase = PaintPhaseChildBlockBackgrounds;
    paint(paintInfo, paintOffset);
    paintInfo.phase = PaintPhaseFloat;
    paint(paintInfo, paintOffset);
    paintInfo.phase = PaintPhaseForeground;
    paint(paintInfo, paintOffset);
    paintInfo.phase = PaintPhaseOutline;
    paint(paintInfo, paintOffset);
}
Example #4
0
MonoRecorder::MonoRecorder(bool fromFile) {
	is_truncated = is_processed = false;
	if ( fromFile ) {
		stamped_offset = 0;
		Read(false);
		assertid("OUT1");
		filename = ReadString();
		float t = ReadFloat();
		if ( Datatype::PeakId() == "anim" ) {
			animation = new Animated<gmtl::Point3f>();
		} else {
			setLocation(ReadVec());
			animation = 0;
		}
		std::cout << this->toString();
	} else {
		animation = 0;
		filename = "";
	}
	has_samples = save_processed = false;
	tracks.push_back(new RecorderTrack());
}
Example #5
0
SoundFile::SoundFile() {
	Read(false);
	assertid("SSRC");
	filename = ReadString();
	WaveFile w(filename.c_str());
	data = w.ToFloat();
	sample_owner = true;
	sample_length = w.GetSampleSize();
	if ( !data || !sample_length ) {
		throw DatatypeException("Failed to open sound file " + filename);
	}
	soundfiles[0] = soundfiles[1] = soundfiles[2] = 0;
	data_low = data_mid = data_high = 0;
	mesh = 0;
	animation = 0;
	if ( Datatype::PeakId() == "anim" ) {
		animation = new Animated<gmtl::Point3f>();
	} else if ( Datatype::PeakId() == "mesh" ) {
		Datatype::prefix = " +- " + Datatype::prefix;
		mesh = new Mesh();
		Datatype::prefix = Datatype::prefix.substr(4);
	} else {
		setLocation(ReadPoint());			
	}
	if ( Datatype::PeakId() == "flt4" ) {
		gain = Datatype::ReadFloat();
	} else {
		gain = 1.0f;
	}
	if ( Datatype::PeakId() == "flt4" ) {
		offset = (unsigned int) (Datatype::ReadFloat() * 44100.0f);
	} else {
		offset = 0;
	}
	std::cout << this->toString();
	std::cout << Datatype::stringblock;
	Datatype::stringblock = "";
}
Example #6
0
MockInputDeviceNode* getHeadsetJack() {
    auto node = new MockInputDeviceNode();
    node->setPath("/dev/input/event3");
    node->setName("apq8064-tabla-snd-card Headset Jack");
    node->setLocation("ALSA");
    // UniqueId not set
    node->setBusType(0);
    node->setVendorId(0);
    node->setProductId(0);
    node->setVersion(0);
    // No keys
    // No relative axes
    // No absolute axes
    node->addSwitch(SW_HEADPHONE_INSERT);
    node->addSwitch(SW_MICROPHONE_INSERT);
    node->addSwitch(SW_LINEOUT_INSERT);
    // ASUS adds some proprietary switches, but we'll only see two of them.
    node->addSwitch(0x0e);  // SW_HPHL_OVERCURRENT
    node->addSwitch(0x0f);  // SW_HPHR_OVERCURRENT
    // No forcefeedback
    node->addInputProperty(INPUT_PROP_DIRECT);
    return node;
}
Example #7
0
/**
 * Detects the paddle based on the location of the mouse pointer
 */
void checkForEvent(Paddle *bat)
{
    GEvent event = getNextEvent(MOUSE_EVENT);
    if (event != NULL)
    {
        if (getEventType(event) == MOUSE_MOVED)
        {
            double xCoordinate = getX(event) - getWidth(bat->paddle) / 2;
            setLocation(bat->paddle, xCoordinate, HEIGHT - PADDLE_HEIGHT - 100);
            
            // mouse moving right
            if (xCoordinate > bat->x)
            {
                strcpy(bat->direction, "right\0");
            }
            else if(xCoordinate < bat->x)
            {
                strcpy(bat->direction, "left\0");
            }
            bat->x = xCoordinate;
        }
    }
}
Example #8
0
bool Shorty::keyReleaseEventHandler(QEvent *event){
    qDebug(shorty_Main()) << "Key relese event. the key is" << ((QKeyEvent*)event)->key()
                          << "Our location is" << getLocation() << "now it'll be" << getLocation()-1;
    pressedKeys -= ((QKeyEvent*)event)->key();
    setLocation(getLocation()-1);
    qDebug(shorty_Main()) << "errorFlag is" << errorFlag;
    if (errorFlag) {
        if (keysPressed == 0) {
            qDebug(shorty_Main()) << "Clearing flag" << getLocation();
            errorFlag = !errorFlag;
            updateText();
        }
        else{
            qDebug(shorty_Main()) << "There are still" << keysPressed << "pressed keys";
            return true;
        }
    }
    else {
        qDebug() << keysPressed << "No errorFlag";
        unPaint(getLocation());
    }
    return true;
}
Example #9
0
CCylinder::CCylinder(float x, float y, float z)
{	
	m_sizeX= x; m_sizeY= y; m_sizeZ= z;
	setLocation(0.0,0.0,0.0);
	m_control= new CCylinderControl(this);
	s= gluNewQuadric();
	d1= gluNewQuadric(); gluQuadricOrientation(d1, GLU_OUTSIDE);
	d2= gluNewQuadric(); gluQuadricOrientation(d1, GLU_INSIDE);
	m_ratio= 1;

	diskATrans= new hduMatrix ( );
	diskBTrans= new hduMatrix ( );

	diskAShape= new CDisk ();
	diskBShape= new CDisk ();

	diskAShape->AddDependant ( this );
	diskAShape->AddDependant ( this );

	customCylinder= new CHapticCylinder ( this );
	diskA= new CHapticDisk ( diskATrans );
	diskB= new CHapticDisk ( diskBTrans );
}
Example #10
0
GameOver::GameOver() {

    setType("GameOver");

    // link to "message" sprite
    ResourceManager &resource_manager = ResourceManager::getInstance();
    Sprite *p_temp_sprite = resource_manager.getSprite("gameover");
    if (!p_temp_sprite) {
        LogManager &log_manager = LogManager::getInstance();
        log_manager.writeLog("GameOver::GameOver(): Warning! Sprite 'gameover' not found");
    } else {
        setSprite(p_temp_sprite);
        setSpriteSlowdown(15);
        setTransparency('#');    // transparent character
        time_to_live = p_temp_sprite->getFrameCount() * 15;
    }

    // put in center of screen
    setLocation(CENTER_CENTER);

    // register for step event
    registerInterest(STEP_EVENT);
}
Example #11
0
int main(void)
{
    GWindow window = newGWindow(320, 240);
    GOval circle = newGOval(0,0,50,50);
    setColor(circle, "RED");
    setFilled(circle, true);
    add(window, circle);
    
    while ( true )
    {
        GEvent event = getNextEvent( MOUSE_EVENT );
        
        if( event != NULL )
        {
            if( getEventType(event) == MOUSE_MOVED )
            {
                double x = getX(event) - getWidth(circle) / 2;
                double y = getY(event) - getWidth(circle) /2;
                setLocation(circle, x, y);
            } 
        }
    }
}
Example #12
0
/**
 * Updates scoreboard's label, keeping it centered in window.
 */
void updateScoreboard(GWindow window, GLabel label, int points)
{
    // update label
    char s[12];
    sprintf(s, "%i", points);
    if (points == 51)
    {
        setLabel(label, "WIN!");
    }
    else if (points == 0)
    {
        setLabel(label, ":(");
    }
    else 
    {
        setLabel(label, s);
    }
    
    // center label in window
    double x = (getWidth(window) - getWidth(label)) / 2;
    double y = (getHeight(window) - getHeight(label)) / 2;
    setLocation(label, x, y);
}
Example #13
0
void Path::setLocation( const String &loc )
{
   uint32 pos = loc.find( ":" );
   if ( pos != String::npos )
   {
      if( loc.find( ":", pos + 1 ) != String::npos )
      {
         m_bValid = false;
      }
      else
      {
         setResource( loc.subString( 0, pos ) );
         setLocation( loc.subString( pos + 1 ) );
      }
   }
   else
   {
      if( m_location != loc )
      {
         m_location = loc;

         uint32 pos1 = m_location.find( "\\" );
         while( pos1 != String::npos )
         {
            m_location.setCharAt( pos1, '/' );
            pos1 = m_location.find( "\\", pos1 );
         }

         // remove trailing "/"
         if ( m_location.size() > 1 && m_location.getCharAt( m_location.length() - 1 ) == '/' )
            m_location.remove( m_location.length() - 1, 1 );

         compose();
      }

   }
}
Example #14
0
static int l_setLocation(lua_State *L) {

   Player     *player;
   Room       *newLocation;
   const char *playerName;
   const char *roomName;

   int n = lua_gettop(L);

   /* script must provide player name and room name as arguments */
   if (n < 2) {
      lua_pushboolean(L, 0);
      lua_pushstring(L, "must pass player and room names to setLocation");
      return 2;
   }

   playerName = lua_tostring(L, 1);
   roomName = lua_tostring(L, 2);

   player = g_hash_table_lookup(g_players, playerName);
   if (NULL == player) {
      lua_pushboolean(L, 0);
      lua_pushstring(L, "player doesn't exist");
      return 2;
   }

   newLocation = g_hash_table_lookup(g_rooms, roomName);
   if (NULL == newLocation) {
      lua_pushboolean(L, 0);
      lua_pushstring(L, "room doesn't exist");
      return 2;
   }

   setLocation(player, newLocation, 0);
   lua_pushboolean(L, 1);
   return 1;
}
Example #15
0
/*Determine whether Color has legal Moves on Board*/
int hasMoves(Game *game, Color col){
	ListNode *temp = (ListNode*)malloc(sizeof(ListNode));
	if (temp == NULL) exitOnError("malloc");
	int flag = 0;
	temp->move = NULL;
	temp->next = NULL;
	ListNode *head = temp;
	int i, j;
	for (i = 0; i < BOARD_SIZE; i++){
		for (j = 0; j < BOARD_SIZE; j++){
			if (sameCol(game->board[i][j], col)){
				Location *loc = setLocation(i, j);
				flag = getMovesSinglePiece(game, loc, temp);
				free(loc);
			}
			if (flag){
				freeList(head);
				return 1;
			}
		}
	}
	freeList(head);
	return 0;
}
Example #16
0
/**
 * Initializes window with a grid of bricks.
 */
void initBricks(GWindow window)
{
    int brickLocationX = 2;
    int brickLocationY = 50;
    char* colors[5] = {"RED", "ORANGE", "YELLOW", "GREEN", "CYAN"};
    for (int i = 0; i < ROWS; i++)
    {
        for (int j = 0; j < COLS; j++)
        {
            GRect brick = newGRect(0, 0, BWIDTH, BHEIGHT);
            setFilled(brick, true);
            setColor(brick, colors[i]);
            setLocation(brick, brickLocationX, brickLocationY);
            brickLocationX += 40;
            add(window, brick);
            
            if (j == 9)
            {
                brickLocationX = 2;       
                brickLocationY += 14; 
            }
        }
    }
}
Example #17
0
void RenderScrollbarPart::paintIntoRect(GraphicsContext* graphicsContext, const LayoutPoint& paintOffset, const LayoutRect& rect)
{
    // Make sure our dimensions match the rect.
    setLocation(rect.location() - toLayoutSize(paintOffset));
    setWidth(rect.width());
    setHeight(rect.height());

    if (graphicsContext->paintingDisabled() || !style().opacity())
        return;

    // We don't use RenderLayers for scrollbar parts, so we need to handle opacity here.
    // Opacity for ScrollbarBGPart is handled by RenderScrollbarTheme::willPaintScrollbar().
    bool needsTransparencyLayer = m_part != ScrollbarBGPart && style().opacity() < 1;
    if (needsTransparencyLayer) {
        graphicsContext->save();
        graphicsContext->clip(rect);
        graphicsContext->beginTransparencyLayer(style().opacity());
    }
    
    // Now do the paint.
    PaintInfo paintInfo(graphicsContext, snappedIntRect(rect), PaintPhaseBlockBackground, PaintBehaviorNormal);
    paint(paintInfo, paintOffset);
    paintInfo.phase = PaintPhaseChildBlockBackgrounds;
    paint(paintInfo, paintOffset);
    paintInfo.phase = PaintPhaseFloat;
    paint(paintInfo, paintOffset);
    paintInfo.phase = PaintPhaseForeground;
    paint(paintInfo, paintOffset);
    paintInfo.phase = PaintPhaseOutline;
    paint(paintInfo, paintOffset);

    if (needsTransparencyLayer) {
        graphicsContext->endTransparencyLayer();
        graphicsContext->restore();
    }
}
GameStart::GameStart() {
  setType("GameStart");

  // Link to "message" sprite.
  df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
  df::Sprite *p_temp_sprite = resource_manager.getSprite("gamestart");
  if (!p_temp_sprite) {
    df::LogManager &log_manager = df::LogManager::getInstance();
    log_manager.writeLog("GameStart::GameStart(): Warning! Sprite 'gamestart' not found");
  } else {
    setSprite(p_temp_sprite);
    setSpriteSlowdown(15);		  
  }

  // Put in center of screen.
  setLocation(df::CENTER_CENTER);

  // Register for "keyboard" event.
  registerInterest(df::KEYBOARD_EVENT);

  // Play start music.
  p_music = df::ResourceManager::getInstance().getMusic("start music");
  playMusic();
}
Example #19
0
int main(void)
{
    // seed pseudorandom number generator
    srand48(time(NULL));

    // instantiate window
    GWindow window = newGWindow(WIDTH, HEIGHT);

    // instantiate bricks
    initBricks(window);

    // instantiate ball, centered in middle of window
    GOval ball = initBall(window);

    // instantiate paddle, centered at bottom of window
    GRect paddle = initPaddle(window);

    // instantiate scoreboard, centered in middle of window, just above ball
    GLabel label = initScoreboard(window);

    // number of bricks initially
    int bricks = COLS * ROWS;

    // number of lives initially
    int lives = LIVES;

    // number of points initially
    int points = 0;
    
    // need to get velocity of paddle
    double t_paddle = 0.0;
    

    // keep playing until game over
    while (lives > 0 && bricks > 0)
    {
      // Win condition
      if (points == bricks) {
        setLabel(scoreboard, "You WIN!");
        break;
      }
      
      // Lose life condition
      if (getHeight(ball) == HEIGHT) {
        lives--;
        break;
      }
      
      // Dictate Paddle movement
      // Test to see if you can move off screen
      // if left and right cursors move at an accelrated pace, time based
      GKeyEvent e = waitForEvent(KEY_EVENT);
      
      
      
      if (getEventType(e) == LEFT_ARROW_KEY) {
          //KEY_PRESSED
         // KEY_RELEASED
        t_paddle = e.getEventTime();
        move(paddle, -1, 0); 
      }
      else if (getEventType(e) == LEFT_ARROW_KEY) {
        t_paddle = e.getEventTime();
        move(paddle, 1, 0); 
      }
      printf("time of event: %d", t_paddle);
        
      // If ball hits brick
      // Test if top or side of ball hits a brick, does it still detect
      GObject hitBrick = detectCollision(window, ball);
      if(hitBrick != NULL) {
        remove(window, hitBrick);
        points++;
        updateScoreboard(window, scoreboard, points);
        //call ball bounce logic;
      }

      // Ball bouncing logic
      int ballX = getX(ball);
      int ballY = getY(ball);
      int paddleX = getX(paddle);
      
      
      if (ballX == 0 || ballX + getWidth(ball) == WIDTH) {
        setLocation(ball, -ballX, y);
      }
      else if (ballY == 0) {
        setLocation(ball, x, -ballY); 
      }
      
      // Hit paddle and within the width of paddle, do complicated bouncing
      else if (ballY + getHieght(ball) == getY(paddle) &&
        ballX >= paddleX &&
        ballX + getWidth(ball) <= paddleX + getWidth(paddle)) {
        //bounce logic
      }
    }

    // wait for click before exiting
    waitForClick();

    // game over
    closeGWindow(window);
    return 0;
}
Example #20
0
View::View(QWindow *)
    : PlasmaQuick::Dialog(),
      m_offset(.5),
      m_floating(false)
{
    setClearBeforeRendering(true);
    setColor(QColor(Qt::transparent));
    setFlags(Qt::FramelessWindowHint);

    KCrash::setFlags(KCrash::AutoRestart);

    m_config = KConfigGroup(KSharedConfig::openConfig(QStringLiteral("krunnerrc")), "General");

    setFreeFloating(m_config.readEntry("FreeFloating", false));
    reloadConfig();

    new AppAdaptor(this);
    QDBusConnection::sessionBus().registerObject(QStringLiteral("/App"), this);

    if (KAuthorized::authorize(QStringLiteral("run_command"))) {
        QAction *a = new QAction(0);
        QObject::connect(a, &QAction::triggered, this, &View::displayOrHide);
        a->setText(i18n("Run Command"));
        a->setObjectName(QStringLiteral("run command"));
        KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << QKeySequence(Qt::ALT + Qt::Key_Space), KGlobalAccel::NoAutoloading);
        KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << QKeySequence(Qt::ALT + Qt::Key_Space) << QKeySequence(Qt::ALT + Qt::Key_F2) << Qt::Key_Search);

        a = new QAction(0);
        QObject::connect(a, &QAction::triggered, this, &View::displayWithClipboardContents);
        a->setText(i18n("Run Command on clipboard contents"));
        a->setObjectName(QStringLiteral("run command on clipboard contents"));
        KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << QKeySequence(Qt::ALT+Qt::SHIFT+Qt::Key_F2));
        KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << QKeySequence(Qt::ALT+Qt::SHIFT+Qt::Key_F2));
    }

    m_qmlObj = new KDeclarative::QmlObject(this);
    m_qmlObj->setInitializationDelayed(true);
    connect(m_qmlObj, &KDeclarative::QmlObject::finished, this, &View::objectIncubated);

    KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel"));
    KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "KDE");
    const QString packageName = cg.readEntry("LookAndFeelPackage", QString());
    if (!packageName.isEmpty()) {
        package.setPath(packageName);
    }

    m_qmlObj->setSource(QUrl::fromLocalFile(package.filePath("runcommandmainscript")));
    m_qmlObj->engine()->rootContext()->setContextProperty(QStringLiteral("runnerWindow"), this);
    m_qmlObj->completeInitialization();

    auto screenRemoved = [=](QScreen* screen) {
        if (screen == this->screen()) {
            setScreen(qGuiApp->primaryScreen());
            hide();
        }
    };

    auto screenAdded = [=](QScreen* screen) {
        connect(screen, &QScreen::geometryChanged, this, &View::screenGeometryChanged);
        screenGeometryChanged();
    };

    foreach(QScreen* s, QGuiApplication::screens())
        screenAdded(s);
    connect(qApp, &QGuiApplication::screenAdded, this, screenAdded);
    connect(qApp, &QGuiApplication::screenRemoved, this, screenRemoved);

    connect(KWindowSystem::self(), &KWindowSystem::workAreaChanged, this, &View::resetScreenPos);

    connect(this, &View::visibleChanged, this, &View::resetScreenPos);

    KDirWatch::self()->addFile(m_config.name());

    // Catch both, direct changes to the config file ...
    connect(KDirWatch::self(), &KDirWatch::dirty, this, &View::reloadConfig);
    connect(KDirWatch::self(), &KDirWatch::created, this, &View::reloadConfig);

    if (m_qmlObj->rootObject()) {
        connect(m_qmlObj->rootObject(), SIGNAL(widthChanged()), this, SLOT(resetScreenPos()));
    }

    if (m_floating) {
        setLocation(Plasma::Types::Floating);
    } else {
        setLocation(Plasma::Types::TopEdge);
    }

    connect(qGuiApp, &QGuiApplication::focusWindowChanged, this, &View::slotFocusWindowChanged);
}
Example #21
0
void OEvent::fromMap( const QMap<int, QString>& map )
{

	// We just want to set the UID if it is really stored.
	if ( !map[OEvent::FUid].isEmpty() )
		setUid( map[OEvent::FUid].toInt() );

	setCategories( idsFromString( map[OEvent::FCategories] ) );
	setDescription( map[OEvent::FDescription] );
	setLocation( map[OEvent::FLocation] );

	if ( map[OEvent::FType] == "AllDay" )
		setAllDay( true );
	else
		setAllDay( false );

	int alarmTime = -1;
	if( !map[OEvent::FAlarm].isEmpty() )
		alarmTime = map[OEvent::FAlarm].toInt();

	int sound = ( ( map[OEvent::FSound] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent );
	if ( ( alarmTime != -1 )  ){
		QDateTime dt = startDateTime().addSecs( -1*alarmTime*60 );
		OPimAlarm al( sound ,  dt  );
		notifiers().add( al );
	}
	if ( !map[OEvent::FTimeZone].isEmpty() && ( map[OEvent::FTimeZone] != "None" ) ){
		setTimeZone( map[OEvent::FTimeZone] );
	}

	time_t start = (time_t) map[OEvent::FStart].toLong();
	time_t end   = (time_t) map[OEvent::FEnd].toLong();

	/* AllDay is always in UTC */
	if ( isAllDay() ) {
		OTimeZone utc = OTimeZone::utc();
		setStartDateTime( utc.fromUTCDateTime( start ) );
		setEndDateTime  ( utc.fromUTCDateTime( end   ) );
		setTimeZone( "UTC"); // make sure it is really utc
	}else {
		/* to current date time */
		// qWarning(" Start is %d", start );
		OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() );
		QDateTime date = zone.toDateTime( start );
		qWarning(" Start is %s", date.toString().latin1() );
		setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) );

		date = zone.toDateTime( end );
		setEndDateTime  ( zone.toDateTime( date, OTimeZone::current() ) );
	}

	if ( !map[OEvent::FRecParent].isEmpty() )
		setParent( map[OEvent::FRecParent].toInt() );

	if ( !map[OEvent::FRecChildren].isEmpty() ){
		QStringList list = QStringList::split(' ', map[OEvent::FRecChildren] );
		for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
			addChild( (*it).toInt() );
		}
	}

	// Fill recurrence stuff and put it directly into the ORecur-Object using fromMap..
	if( !map[OEvent::FRType].isEmpty() ){
		QMap<int, QString> recFields;
		recFields.insert( ORecur::RType, map[OEvent::FRType] );
		recFields.insert( ORecur::RWeekdays, map[OEvent::FRWeekdays] );
		recFields.insert( ORecur::RPosition, map[OEvent::FRPosition] );
		recFields.insert( ORecur::RFreq, map[OEvent::FRFreq] );
		recFields.insert( ORecur::RHasEndDate, map[OEvent::FRHasEndDate] );
		recFields.insert( ORecur::EndDate, map[OEvent::FREndDate] );
		recFields.insert( ORecur::Created, map[OEvent::FRCreated] );
		recFields.insert( ORecur::Exceptions, map[OEvent::FRExceptions] );
		ORecur recur( recFields );
		setRecurrence( recur );
	}

}
int main(void)
{

    // instantiate window
    GWindow window = newGWindow(WIDTH, HEIGHT);

    // instantiate bricks
    initBricks(window);

    // instantiate ball, centered in middle of window
    GOval ball = initBall(window);

    // instantiate paddle, centered at bottom of window
    GRect paddle = initPaddle(window);

    // instantiate scoreboard, centered in middle of window, just above ball
    GLabel label = initScoreboard(window);

    // number of bricks initially
    int bricks = COLS * ROWS;

    // number of lives initially
    int lives = LIVES;

    // number of points initially
    int points = 0;

    // wait for click before starting
    waitForClick();
    
    velocityX = 1.0; 
    velocityY = 2.5;

    // keep playing until game over
    while (lives > 0 && bricks > 0)
    {        
        // Scoreboard
        updateScoreboard(window, label, points);
        
        // move ball
        move(ball, velocityX, velocityY);

        pause(10);
        
        // check for mouse event.
        GEvent event = getNextEvent(MOUSE_EVENT);
        
        // Lock the paddle X to the cursor.
        if (event != NULL)
        {
            // if the event was movement
            if (getEventType(event) == MOUSE_MOVED)
            {
                // ensure paddle follows top cursor
                double x = getX(event) - getWidth(paddle) / 2;
                double y = 500;
                setLocation(paddle, x, y);
            }
        }
        
        
        GObject object = detectCollision(window, ball);
        
        if (object != NULL)
        {
            // If the ball hits the paddle.
            if (object == paddle)
            {
                velocityY = -velocityY;
            }
            
            // If the ball hits a block. Remove block, add a point, decrement count and bounce.
            else if (strcmp(getType(object), "GRect") == 0)
            {
                removeGWindow(window, object);
                velocityY = -velocityY;
                points++;
                bricks--;                
            }
        }
        
        // If the ball hits the right wall.
        if (getX(ball) + getWidth(ball) >= getWidth(window))
        {
            velocityX = -velocityX;
        }
        
        // If the ball hits the left wall.
        if (getX(ball) <= 0)
        {
            velocityX = -velocityX;
        }
        
        // If the ball hits the top wall.
        if (getY(ball) <= 0)
        {
            velocityY = -velocityY;
        }
        
        // Remove a life. Start over.
        if (getY(ball) + getHeight(ball) >= getHeight(window))
        {
            lives--;
            //move ball to start
            setLocation(ball, 190, 200);
            //move paddle to start
            setLocation(paddle, 160, 500);
            waitForClick();
        }
        
    }

    // You Lose Label Message for kicks.
    if (bricks > 0)
    {
        GLabel game_over = newGLabel("YOU LOSE!");
        setFont(game_over, "SansSerif-70");
        setColor(game_over, "RED");
        add(window, game_over);
        setLocation(game_over, 15, 300);
    }
    else
    {
        GLabel game_over = newGLabel("YOU WIN!");
        setFont(game_over, "SansSerif-70");
        setColor(game_over, "GREEN");
        add(window, game_over);
        setLocation(game_over, 15, 300);
    }
    
    // wait for click before exiting
    waitForClick();

    // game over
    closeGWindow(window);
    return 0;
}
Example #23
0
int main(int argv, string args[] )
{
    int isGod= -1;
    if (argv ==2)
    {
        if (strcmp(args[1] ,"GOD")==0)
        {
            isGod = 1;; //printf("args %s \n",args[1]);
        }
    }
    // seed pseudorandom number generator
    srand48(time(NULL));

    // instantiate window
    GWindow window = newGWindow(WIDTH, HEIGHT);

    // instantiate bricks
    initBricks(window);

    // instantiate ball, centered in middle of window
    GOval ball = initBall(window);

    // instantiate paddle, centered at bottom of window
    GRect paddle = initPaddle(window);

    // instantiate scoreboard, centered in middle of window, just above ball
    GLabel label = initScoreboard(window);

    // number of bricks initially
    int bricks = COLS * ROWS;

    // number of lives initially
    int lives = LIVES;

    // number of points initially
    int points = 0;

    // Variable declation for whiel
    
    double velocityX = drand48()+5;
    double velocityY = drand48()+1;
    
    // keep playing until game over
    while (lives > 0 && bricks > 0)
    {
       // ball beyond paddle
        if( (getY(ball) + getWidth(ball)) > getHeight(window) )
        {
            lives--;
            removeGWindow(window, ball);
            freeGObject(ball);
            
            if(lives <= 0)
            {
                break;
            }
            
            initBall(window);
        }
        waitForClick();
        // paddle moment
        
        if (isGod == -1) 
        {
            GEvent event = getNextEvent(MOUSE_EVENT);
        
            if(event !=NULL)
            {
                //printf("before MOUSE_MOVED event\n");
                if(getEventType(event) == MOUSE_MOVED)
                {
                    double x = getX(event);
                
                    // repositioning paddle from going beyond the window's width
                    if(x + getWidth(paddle)  > getWidth(window))
                    {
                        x = getWidth(window) - getWidth(paddle);
                    
                    }
                    double y = getHeight(window)-SPACE - getHeight(paddle);
                
                    setLocation(paddle, x , y );
                }
                //printf("After  MOUSE_MOVED event\n");
        
            }
            
         }
         else if(isGod == 1)//Its GOD mode 
         {
            double ballX  = getX(ball);
            double ballY =  getX(ball);
            double x = ballX;
            
            if(x + getWidth(paddle)  > getWidth(window))
            {
                x = getWidth(window) - getWidth(paddle);                    
            }
            double y = getHeight(window)-SPACE - getHeight(paddle);
            setLocation(paddle, x , y );
            
         }
        // Accelerate x cordinates of the ball i.e. left and right
      
       
        if( getX(ball) + getWidth(ball) > getWidth(window) )
        {
            velocityX = - velocityX ;
        }
        else if( getX(ball) <= 0)
        {
            velocityX = - velocityX;
        }
        
        
        // Acceleration control check for top of the window
        if( getY(ball) < 0)
        {
            velocityY = - velocityY;
        }
        // Acceleration control if ball collided with paddle or brick
        GObject object = detectCollision(window,ball);
        
        if( object != NULL)
        {
            // Acceleration control if ball collided with paddle
            if( object == paddle)
            {
                velocityY = - velocityY;
                //move(ball, velocityX, velocityY);
            }
            
            // Ignore collision 
            if (strcmp(getType(object), "GLabel") == 0)
            {
                //do nothing
            }
            
            // Acceleration, ScoreBoard,  brick control if ball collided with brick
            if( (strcmp(getType(object), "GRect") == 0) && getY(ball) < HEIGHT / 2)
            {
                velocityY = - velocityY;
                //update points
                string colorB = getColorGObject(object);
                
                 // return type is "#rrggbb"
                if(strcmp(colorB,"RED")==0 ) 
                {
                    points = points+5;
                }
                else if(strcmp(colorB,"ORANGE")==0) 
                {
                    points = points+4;
                }
                else if(strcmp(colorB,"YELLOW")==0 )  
                {
                    points = points+3;
                }
                else if(strcmp(colorB,"GREEN")==0) 
                {
                    points = points+2;
                }
                else if(strcmp(colorB,"CYAN")==0) 
                {
                    points++;
                }
                
                // shrink bat with points increased
                if( points % 10 == 0 )
                {
                    double x = getX(paddle);
                    double y = getY(paddle);
                    
                    paddleL -= 5;
                    removeGWindow(window, paddle);
                    paddle = newGRect(x, y, paddleL, paddleH);
                    setFilled(paddle, true);
                    setColor(paddle,"BLACK");
                    
                    add(window,paddle);
                    
                    //paddle = initPaddle(window)
                    
                }
                
                //update Scoreboard
                updateScoreboard(window, label, points);
                
                //brick
                removeGWindow(window, object);
                bricks--;
                if(bricks < 0)
                {
                    break;
                }
            }    
        
        }
        
        // move ball 
        
        
        move(ball, velocityX, velocityY);
        pause(10);
        
        
    }

    // wait for click before exiting
    waitForClick();

    // game over
    closeGWindow(window);
    return 0;
}
Example #24
0
void WeatherPlugin::element_end(const char *el)
{
    if (!strcmp(el, "obst")){
        setLocation(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "lsup")){
        setUpdated(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "sunr") && m_bCC){
        setSun_raise(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "suns") && m_bCC){
        setSun_set(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "vis") && m_bCC){
        setVisibility(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "tmp") && m_bCC){
        setTemperature(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "flik") && m_bCC){
        setFeelsLike(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "devp") && m_bCC){
        setDewPoint(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "hmid") && m_bCC){
        setHumidity(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "low") && m_day){
        setMinT(m_day, m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "hi") && m_day){
        setMaxT(m_day, m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "t")){
        if (!m_bBar && !m_bWind && !m_bUv){
			if (m_bCC){
				setConditions(m_data.c_str());
			}else{
				setDayConditions(m_day, m_data.c_str());
			}
		}
        if (m_bWind && m_bCC)
            setWind(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "icon")){
		if (m_bCC){
			setIcon(atol(m_data.c_str()));
		}else{
			setDayIcon(m_day, m_data.c_str());
		}
        m_data = "";
        return;
    }
    if (!strcmp(el, "ut")){
        setUT(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "up")){
        setUP(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "us")){
        setUS(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "gust") && m_bCC){
        setWindGust(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "bar")){
        m_bBar = false;
        return;
    }
    if (!strcmp(el, "cc")){
        m_bCC = false;
        return;
    }
    if (!strcmp(el, "r") && m_bBar && m_bCC){
        unsigned long v = 0;
        for (const char *p = m_data.c_str(); *p; p++){
            if (*p == '.')
                break;
            if (*p == ',')
                continue;
            v = (v * 10) + (*p - '0');
        }
        setPressure(v);
        return;
    }
    if (!strcmp(el, "d") && m_bBar && m_bCC){
		setPressureD(m_data.c_str());
		m_data = "";
		return;
	}
    if (!strcmp(el, "wind")){
        m_bWind = false;
        return;
    }
    if (!strcmp(el, "s") && m_bWind && m_bCC){
        setWind_speed(atol(m_data.c_str()));
        return;
    }
    if (!strcmp(el, "uv")){
        m_bUv = false;
        return;
    }
}
Example #25
0
void Location::setHref(DOMWindow* callingWindow, DOMWindow* enteredWindow, const String& url)
{
    if (!m_frame)
        return;
    setLocation(url, callingWindow, enteredWindow);
}
 void setup_setLocation(Eris::Entity * e) {
     setLocation(e);
 }
Example #27
0
int main(void)
{
    // seed pseudorandom number generator
    srand48(time(NULL));

    // instantiate window
    GWindow window = newGWindow(WIDTH, HEIGHT);

    // instantiate bricks
    initBricks(window);

    // instantiate ball, centered in middle of window
    GOval ball = initBall(window);

    // instantiate paddle, centered at bottom of window
    GRect paddle = initPaddle(window);

    // instantiate scoreboard, centered in middle of window, just above ball
    GLabel label = initScoreboard(window);

    // number of bricks initially
    int bricks = COLS * ROWS;

    // number of lives initially
    int lives = LIVES;

    // number of points initially
    int points = 0;
    
    // initial velocity
    double Xvelocity = drand48();
    double  Yvelocity = 2.0;    

    // keep playing until game over
    while (lives > 0 && bricks > 0)
    {    
        
            // move circle along y-axis
            move(ball, Xvelocity, Yvelocity);

            // bounce off top edge of window
            if (getY(ball) <= 0)
            {
                Yvelocity = -Yvelocity;
            }
            
            //  ball hits bottom edge, lose life
            if (getY(ball) + getHeight(ball) >= getHeight(window))
            {
                lives = lives - 1;
                removeGWindow(window, ball);
                waitForClick();
                ball = initBall(window);
                pause(20);
                Yvelocity = -Yvelocity;
            }
            
            // bounce off right edge of window
            if (getX(ball) + getWidth(ball) >= getWidth(window))
            {
                Xvelocity = -Xvelocity;
            }

            // bounce off left edge of window
            if (getX(ball) <= 0)
            {
                Xvelocity = -Xvelocity;
            }

            // linger before moving again
            pause(10);
    
        // check for mouse event
        GEvent event = getNextEvent(MOUSE_EVENT);
        
        // if we heard one
        if (event != NULL)
        {
            // if the event was movement
            if (getEventType(event) == MOUSE_MOVED)
            {
                // ensure grect follows top cursor
                double x = getX(event) - pWIDTH / 2;
                double y = 500;
                setLocation(paddle, x, y);
            }
        }
       
       //check for ball collision 
       GObject object = detectCollision(window, ball);
       
       //if there was a collision
       if (object != NULL)
       {
       
            //if it collided with the paddle
            if (object == paddle)
            {
                Yvelocity = -Yvelocity;
            }
            
            //removes brick, updates scores
            else if (strcmp(getType(object), "GRect") == 0)
            {
                Yvelocity = -Yvelocity;
                
                removeGWindow(window, object);
                
                points = points + 1;
                
                updateScoreboard(window, label, points);
            }
            
            //Do not detect scoreboard
            if (strcmp(getType(object), "GLabel") == 0)
            {
                    return 0;
            }
        }
        
    }

    // wait for click before exiting
    waitForClick();

    // game over
    closeGWindow(window);
    return 0;
}
Example #28
0
int main(void)
{
    // seed pseudorandom number generator
    srand48(time(NULL));

    // instantiate window
    GWindow window = newGWindow(WIDTH, HEIGHT);
    
    // instantiate bricks
    initBricks(window);
    
    // instantiate life counter
    GOval lifeball1 = newGOval(WIDTH - 30, 20, DIAMETER, DIAMETER);
    setFilled(lifeball1, true);
    setColor(lifeball1, "#000000");
    add(window, lifeball1);

    GOval lifeball2 = newGOval(WIDTH - 50, 20, DIAMETER, DIAMETER);
    setFilled(lifeball2, true);
    setColor(lifeball2, "#000000");
    add(window, lifeball2);

    // instantiate ball, centered in middle of window
    GOval ball = initBall(window);

    // instantiate paddle, centered at bottom of window
    GRect paddle = initPaddle(window);

    // instantiate scoreboard, centered in middle of window, just above ball
    GLabel scoreboard = initScoreboard(window);

    // number of bricks initially
    int bricks = COLS * ROWS;

    // number of lives initially
    int lives = LIVES;

    // number of points initially
    int points = 0;

    //initialize ball velocities
    double xvelocity = drand48();
    double yvelocity = 2.0;

    // keep playing until game over
    
    if (lives > 0)
    {
        waitForClick();
    }
    while (lives > 0 && bricks > 0)
    {

        // compel paddle to follow mouse along x-axis by listening for mouse_event
        GEvent paddlemove = getNextEvent(MOUSE_EVENT);
        // if there was an event
        if (paddlemove != NULL)
            {
                // if the event was movement
                if (getEventType(paddlemove) == MOUSE_MOVED)
                {
                    // make paddle follow mouse pointer's motion along the x axis only
                    double paddlex = getX(paddlemove) - getWidth(paddle) / 2;
                    double paddley = 565;
                    setLocation(paddle, paddlex, paddley);
                }
            }
        

        // move ball along both x and y
        move(ball, xvelocity, yvelocity);
        
        GObject collided = detectCollision(window, ball);
        
        // Correct code to make ball bounce - this does not work, despite working exactly as so in bounce.c
        //perhaps a switch is in order using detect collision for bouncing
        if (getX(ball) + DIAMETER >= WIDTH)
        {
            xvelocity = -xvelocity;
        }

        // bounce off left edge of window
        else if (getX(ball) <= 0)
        {
            xvelocity = -xvelocity;
        }
        
        else if (getY(ball) <= 0)
        {
            yvelocity = -yvelocity;
        }
        
        else if (collided == paddle)
        {
            yvelocity = -yvelocity;
            xvelocity = xvelocity + (drand48() - drand48());
        }
        else if ((((collided != NULL) && (collided != paddle))
        && (collided != scoreboard)) && (strcmp(getType(collided), "GOval") != 0))
        {
            yvelocity = -yvelocity;
            xvelocity = xvelocity + (drand48() - drand48());
            removeGWindow(window, collided);
            points++;
            bricks = bricks - 1;
            updateScoreboard(window, scoreboard, points);
        }
        else if (getY(ball) + DIAMETER >= HEIGHT)
        {
            yvelocity = 2.0;
            xvelocity = drand48();
            lives = lives - 1;
            if (lives == 2)
            {
                removeGWindow(window, lifeball2);
            }
            else if (lives == 1)
            {
                removeGWindow(window, lifeball1);
            }
            
            setLocation(ball, (WIDTH / 2) - (DIAMETER / 2), (HEIGHT / 2) - (DIAMETER / 2));
            setLocation(paddle, (WIDTH / 2) - (PADDLEWIDTH / 2), HEIGHT - 35);
            if (lives > 0)
            {
                waitForClick();
            }
        }

        // linger before moving again
        pause(10);
    }
    // game over
    if (lives > 0 && bricks == 0)
    {
        GLabel winner = newGLabel("YOU WON!");
        setFont(winner, "SansSerif-22");
        double x = (WIDTH / 2) - (getWidth(winner) / 2);
        double y = HEIGHT - 250;
        setLocation(winner, x, y);
        setColor(winner, "#0033FF");
        add(window, winner);
    }
    else
    {
        GLabel gameover = newGLabel("GAME OVER");
        setFont(gameover, "SansSerif-22");
        double x = (WIDTH / 2) - (getWidth(gameover) / 2);
        double y = HEIGHT - 250;
        setLocation(gameover, x, y);
        setColor(gameover, "#990000");
        add(window, gameover);
    }
    waitForClick();
    return 0;
}
Example #29
0
void Location::assign(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, const String& url)
{
    if (!m_frame)
        return;
    setLocation(url, callingWindow, enteredWindow);
}
RexxInstructionOtherwise::RexxInstructionOtherwise(RexxToken *token)
{
    setLocation(token->getLocation());
}