Ejemplo n.º 1
0
void ofxUISuperCanvas::keyReleased(int key)
{
    if(getIsBindedToKey(key) && bKeyHit)
    {
        bKeyHit = false;
        if((ofGetElapsedTimef() - lastHitTime) < deltaTime)
        {
            setMinified(false);
            lastPosition = ofxUIVec2f(ofGetMouseX(), ofGetMouseY());
            if(getTriggerType() & OFX_UI_TRIGGER_BEGIN)
            {
                triggerEvent(this);
            }
        }
        else
        {
            setMinified(true);
            rect->setX(lastPosition.x);
            rect->setY(lastPosition.y);
            if(getTriggerType() & OFX_UI_TRIGGER_END)
            {
                triggerEvent(this);
            }
        }
        lastHitTime = ofGetElapsedTimef();
    }
    ofxUICanvas::keyReleased(key);
}
Ejemplo n.º 2
0
void ofxUISuperCanvas::onMousePressed(ofMouseEventArgs& data)
{
    if(rect->inside(data.x, data.y) && didHitHeaderWidgets(data.x, data.y))
    {
        bTitleLabelHit = true;
        hitPoint.set(data.x - rect->getX(), data.y - rect->getY());
        
        if((ofGetElapsedTimef() - lastHitTime) < deltaTime)
        {
            if(isMinified())
            {
                setMinified(false);
                if(getTriggerType() & OFX_UI_TRIGGER_BEGIN)
                {
                    triggerEvent(this);
                }
            }
            else
            {
                setMinified(true);
                if(getTriggerType() & OFX_UI_TRIGGER_END)
                {
                    triggerEvent(this);
                }
            }
            return;
        }
        lastHitTime = ofGetElapsedTimef();
    }
    mousePressed(data.x, data.y, data.button);
}
Ejemplo n.º 3
0
void ofxUIRotarySlider::keyPressed(int key)
{
    if(state == OFX_UI_STATE_OVER)
    {
        switch (key)
        {
            case OF_KEY_RIGHT:
                setValue(getScaledValue()+increment);
                triggerEvent(this);
                break;
                
            case OF_KEY_UP:
                setValue(getScaledValue()+increment);
                triggerEvent(this);
                break;
                
            case OF_KEY_LEFT:
                setValue(getScaledValue()-increment);
                triggerEvent(this);
                break;
                
            case OF_KEY_DOWN:
                setValue(getScaledValue()-increment);
                triggerEvent(this);
                break;
                
            default:
                break;
        }
    }
}
Ejemplo n.º 4
0
void Mouse(int button, int state, int x, int y) {
	Object *OBJ = GAME.headInst->OBJ;
	if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
		triggerEvent(onMouseLeft, GAME.headInst);
	else if(button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN)
		triggerEvent(onMouseRight, GAME.headInst);
}
Ejemplo n.º 5
0
bool ofxUIButton::mouseReleased(ofMouseEventArgs &e)
{
    if(hit)
    {
#ifdef OFX_UI_TARGET_TOUCH
        state = OFX_UI_STATE_NORMAL;
#else
        if(rect->inside(e.x, e.y) || (label->isVisible() && label->getPaddingRect()->inside(e.x, e.y)))
        {
            state = OFX_UI_STATE_OVER;
        }
        else
        {
            state = OFX_UI_STATE_NORMAL;
        }
#endif
        toggleValue();
        if(triggerType & OFX_UI_TRIGGER_END)
        {
            triggerEvent(this);
        }
    }
    else
    {
        state = OFX_UI_STATE_NORMAL;
    }
    stateChange();
    hit = false;
    return false;
}
Ejemplo n.º 6
0
void ofxUIEnvelopeEditor::mousePressed(int x, int y, int button)
{
    if(rect->inside(x, y))
    {
        hit = true;
        state = OFX_UI_STATE_DOWN;

        ofxUIVec2f pos = rect->percentInside(x, y);
        pos.x = MIN(1.0, MAX(0.0, pos.x));
        pos.y = MIN(1.0, MAX(0.0, pos.y));

        if(button == 0)
        {            
            checkForClosestPointNode(pos.x, pos.y);
        }
        else if(!bHitCurve && !hitPoint)
        {
            deleteClosestPointNode(pos.x, pos.y);
        }
        
        triggerEvent(this);
    }
    else
    {
        state = OFX_UI_STATE_NORMAL;
    }
    stateChange();
}
Ejemplo n.º 7
0
Entity* EntityManager::createEntity(EntityType_t entityType) {
    Entity* newEntity = 0;

    switch (entityType) {
        case ENT_ASTEROID:
            newEntity = new Asteroid();
            break;

        case ENT_BULLET:
            newEntity = new Bullet();
            break;

        case ENT_SPACESHIP:
            newEntity = new Spaceship();
            break;

        default:
            return 0;
            break;
    }

    vEntities.push_back(newEntity);
    triggerEvent(EVT_ENTITY_CREATED, newEntity->getId(), static_cast<int>(entityType), static_cast<void*>(newEntity));    
    
    return newEntity;
}
Ejemplo n.º 8
0
/**
 * Checks for a new newline terminated line in the buffer and parses it
 *
 * @param client			the IRC proxy client to check for buffer lines
 */
static void checkForBufferLine(IrcProxyClient *client)
{
	char *message = client->ibuffer->str;

	if(strstr(message, "\n") != NULL) { // message has at least one newline
		g_string_free(client->ibuffer, false);
		stripDuplicateNewlines(message); // remove duplicate newlines, since server could send \r\n
		char **parts = g_strsplit(message, "\n", 0);
		int count = 0;
		for(char **iter = parts; *iter != NULL; iter++) {
			count++;
		}

		for(int i = 0; i < count - 1; i++) { // Don't trigger the last part, it's not yet complete
			char *part = parts[i];
			if(strlen(part) > 0) {
				IrcMessage *ircMessage = parseIrcMessage(part);

				if(ircMessage != NULL) {
					triggerEvent(client, "line", ircMessage);
					freeIrcMessage(ircMessage);
				}
			}
		}

		client->ibuffer = g_string_new(parts[count-1]); // reinitialize buffer

		g_strfreev(parts);
		free(message);
	}
}
void PusherClient::unsubscribe(String channel) {
    String unsubscribeEventName = getStringTableItem(12);
    String stringVar0 = getStringTableItem(0);
    String message = getStringTableItem(9);
    message.replace(stringVar0, channel);
    triggerEvent(unsubscribeEventName, message);
}
Ejemplo n.º 10
0
void ofxUIRangeSlider::mouseReleased(int x, int y, int button)
{
    if(hit)
    {
#ifdef OFX_UI_TARGET_TOUCH
        state = OFX_UI_STATE_NORMAL;
#else
        state = OFX_UI_STATE_OVER;
#endif
        if(triggerType & OFX_UI_TRIGGER_END)
        {
            input(x, y);
            triggerEvent(this);
        }
    }
    else
    {
        state = OFX_UI_STATE_NORMAL;
    }
    stateChange();
    hit = false;
    hitHigh = false;
    hitLow = false;
    hitCenter = false;
}
Ejemplo n.º 11
0
/*!
 * Preparations before entering the game loop
 * Would start the timer in an event based mainloop
 */
static void startGameLoop(void)
{
	SetGameMode(GS_NORMAL);

	// Not sure what aLevelName is, in relation to game.map. But need to use aLevelName here, to be able to start the right map for campaign, and need game.hash, to start the right non-campaign map, if there are multiple identically named maps.
	if (!levLoadData(aLevelName, &game.hash, NULL, GTYPE_SCENARIO_START))
	{
		debug( LOG_FATAL, "Shutting down after failure" );
		exit(EXIT_FAILURE);
	}

	screen_StopBackDrop();

	// Trap the cursor if cursor snapping is enabled
	if (war_GetTrapCursor())
	{
		wzGrabMouse();
	}

	// set a flag for the trigger/event system to indicate initialisation is complete
	gameInitialised = true;

	if (challengeActive)
	{
		addMissionTimerInterface();
	}
	if (game.type == SKIRMISH)
	{
		eventFireCallbackTrigger((TRIGGER_TYPE)CALL_START_NEXT_LEVEL);
	}
	triggerEvent(TRIGGER_START_LEVEL);
	screen_disableMapPreview();
}
Ejemplo n.º 12
0
void ofxUISuperCanvas::loadSettings(string fileName)
{
    ofxXmlSettings *XML = new ofxXmlSettings();
    XML->loadFile(fileName);
    int widgetTags = XML->getNumTags("Widget");
    for(int i = 0; i < widgetTags; i++)
    {
        XML->pushTag("Widget", i);
        string name = XML->getValue("Name", "NULL", 0);
        ofxUIWidget *widget = getWidget(name);
        if(widget != NULL && widget->hasState())
        {
            widget->loadState(XML);
            if(bTriggerWidgetsUponLoad)
            {
                triggerEvent(widget);
            }
        }
        XML->popTag();
    }
    XML->pushTag("Canvas", 0);
    int value = XML->getValue("IsMinified", (bIsMinified ? 1 : 0), 0);
    setMinified((value ? 1 : 0));
    rect->setX(XML->getValue("XPosition", rect->getX(), 0));
    rect->setY(XML->getValue("YPosition", rect->getY(), 0));
    XML->popTag();
    hasKeyBoard = false;
    delete XML;
}
Ejemplo n.º 13
0
  void BioMartGffHandler::fireNewgeneEvent() {


    //cout << exons.size()  << " exons parsed." << std::endl;
    //cout << transcripts.size() << " transcripts parsed." << std::endl;

    // fire new gene event

    log4cpp::Category& root = log4cpp::Category::getRoot();
    root.info("\n*** " + geneIdentifier + " ***\n");

    triggerEvent(shared_ptr<GffNewGeneEvent>(new GffNewGeneEvent(transcripts, exons)));

    // then reset the exons list and transcript list.

    //cout << "clear the current transcript list " << transcripts.size() << endl;
    transcripts.clear();
    //cout << "current transcript list done " << transcripts.size() << endl;

    //cout << "clear the current exon list " << exons.size() << endl;
    exons.clear();
    //cout << "current exon list done " << exons.size() << endl;

    //cout << "fireNewgeneEvent end" << endl;

    // purge the current status
    newGene = false;
    countGenes++;
  }
Ejemplo n.º 14
0
void ofxUICircleSlider::mouseDragged(int x, int y, int button)
{
    if(hit)
    {
        switch(inputDirection)
        {
            case OFX_UI_DIRECTION_NORTHSOUTH:
                value -= increment*(hitPoint.y-y);
                valueClamp();
                break;
            case OFX_UI_DIRECTION_SOUTHNORTH:
                value += increment*(hitPoint.y-y);
                valueClamp();
                break;
            case OFX_UI_DIRECTION_EASTWEST:
                value += increment*(hitPoint.x-x);
                valueClamp();
                break;
            case OFX_UI_DIRECTION_WESTEAST:
                value -= increment*(hitPoint.x-x);
                valueClamp();
                break;
        }
        
        hitPoint = ofxUIVec2f(x,y);
        updateValueRef();
        triggerEvent(this);
        state = OFX_UI_STATE_DOWN;
    }
    else
    {
        state = OFX_UI_STATE_NORMAL;
    }
    stateChange();
}
Ejemplo n.º 15
0
void ofxUIButton::mouseReleased(int x, int y, int button)
{
    if(hit)
    {
#ifdef OFX_UI_TARGET_TOUCH
        state = OFX_UI_STATE_NORMAL;
#else
        if(rect->inside(x, y) || (label->isVisible() && label->getPaddingRect()->inside(x, y)))
        {
            state = OFX_UI_STATE_OVER;
        }
        else
        {
            state = OFX_UI_STATE_NORMAL;
        }
#endif
        toggleValue();
        triggerEvent(this);
    }
    else
    {
        state = OFX_UI_STATE_NORMAL;
    }
    stateChange();
    hit = false;
}
Ejemplo n.º 16
0
void ofxUITextInput::mousePressed(int x, int y, int button)
{
    if(rect->inside(x, y))
    {
        if(state == OFX_UI_STATE_OVER)
        {
            clicked = true;
            theta = 0;
            hit = true;
        }
#ifdef OFX_UI_TARGET_TOUCH
        clicked = true;
        theta = 0;
        hit = true;
#endif
        cursorPosition = label->getLabel().length();
        
        state = OFX_UI_STATE_DOWN;
        inputTriggerType = OFX_UI_TEXTINPUT_ON_FOCUS;
        
        if(triggerOnClick)
        {
            triggerEvent(this);
        }
    }
    else
    {
        state = OFX_UI_STATE_NORMAL;
        if(clicked)
        {
            unClick();
        }
    }
    stateChange();
}
Ejemplo n.º 17
0
void Draw() {
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	triggerEvent(onDraw, GAME.headInst);
	glFlush();
	glutSwapBuffers();
	
	//if(flagDraw) {
		Instance *i = GAME.headInst->NEXT;
		while(i) {
			i->X += i->xVelocity;
			i->Y += i->yVelocity;
			i = i->NEXT;
		}
	//}
	flagDraw = 0;

	//Instance *i = GAME.headInst->NEXT;
	i = GAME.headInst->NEXT;
	while(i) {
		i->X += i->xVelocity;
		i->Y += i->yVelocity;
		i = i->NEXT;
	}
}
void PusherClient::subscribePrivate(const String& channel) 
{
    String message;
    getStringTableItem(7, message);
	
	{
		String stringVar;
		
		{
			String auth;
			getStringTableItem(1, stringVar);
			getAuthString(channel, auth);	
			message.replace(stringVar, auth);
			LogPrintLn(message);
		}
		
		getStringTableItem(0, stringVar);
		message.replace(stringVar, channel);
		LogPrintLn(message);	
	}
	
	String subscribeEventName;
	getStringTableItem(5, subscribeEventName);
    triggerEvent(subscribeEventName, message);
}
void PusherClient::subscribe(String channel, String auth) {
    String subscribeEventName = getStringTableItem(5);
    String stringVar0 = getStringTableItem(0);
    String stringVar1 = getStringTableItem(1);
    String message = getStringTableItem(7);
    message.replace(stringVar0, channel);
    message.replace(stringVar1, auth);
    triggerEvent(subscribeEventName, message);
}
Ejemplo n.º 20
0
int main(int argc, char** argv){

  EventQueue_t* queue = createEventQueue(3, 15);
 
  // Register an event to the "READ" (second phase) event stack
  addEvent(queue, EVENT_OPEN, myEventHandler);
  addEvent(queue, EVENT_READ, myEventHandler);
  addEvent(queue, EVENT_CLOSE, myEventHandler);

  triggerEvent(queue, EVENT_OPEN, "first");
  triggerEvent(queue, EVENT_READ, "second");
  triggerEvent(queue, EVENT_CLOSE, "third");

  freeEventQueue(queue);   


  return 0;
}
Ejemplo n.º 21
0
void ofxUIToggle::keyPressed(int key)
{
    if(getIsBindedToKey(key) && !bKeyHit)
    {
        bKeyHit = true;
        toggleValue();
        triggerEvent(this);
    }
}
Ejemplo n.º 22
0
void ofxUITextInput::unClick()
{
    if(clicked)
    {
        clicked = false;
        inputTriggerType = OFX_UI_TEXTINPUT_ON_UNFOCUS;
        triggerEvent(this);
    }
}
Ejemplo n.º 23
0
void ofxUISlider_<T>::keyPressed(int key)
{
	if(state == OFX_UI_STATE_OVER || state == OFX_UI_STATE_DOWN)
	{
		switch (key)
		{
			case OF_KEY_RIGHT:
				setValue(getScaledValue()+increment);
				triggerEvent(this);
				break;
				
			case OF_KEY_UP:
				setValue(getScaledValue()+increment);
				triggerEvent(this);
				break;
				
			case OF_KEY_LEFT:
				setValue(getScaledValue()-increment);
				triggerEvent(this);
				break;
				
			case OF_KEY_DOWN:
				setValue(getScaledValue()-increment);
				triggerEvent(this);
				break;
				
			case OF_KEY_SHIFT:
#if OF_VERSION_MINOR > 7
			case OF_KEY_LEFT_SHIFT:
			case OF_KEY_RIGHT_SHIFT:
#endif
				bRoundedToNearestInt = true;
				break;

			case OF_KEY_COMMAND:
				bSticky = true;
				break;
				
			default:
				break;
		}
	}
}
Ejemplo n.º 24
0
void ofxUIButton::keyPressed(int key)
{
    if(getIsBindedToKey(key) && !bKeyHit)
    {
        bKeyHit = true;
        toggleValue();
        if(triggerType & OFX_UI_TRIGGER_BEGIN)
        {
            triggerEvent(this);
        }
    }
}
Ejemplo n.º 25
0
void EntityManager::purge() {
    for (unsigned int k = 0; k < vEntities.size(); k++) {
        Entity* entity = vEntities[k];

        // This will signal the entity representation manager and other listeners
        // that an entity is no longer valid
        triggerEvent(EVT_ENTITY_DESTROYED, entity->getId(), 0, 0);
        delete entity;
    }

    vEntities.clear();
}
Ejemplo n.º 26
0
void ofxUIButton::keyReleased(int key)
{
    if(getIsBindedToKey(key) && bKeyHit)
    {
        bKeyHit = false; 
        toggleValue();
        if(triggerType & OFX_UI_TRIGGER_END)
        {
            triggerEvent(this);
        }
    }
}
Ejemplo n.º 27
0
void GuiCommandButton::update(const PlayerController &event, Vec pos, Vec dim)
{
    m_sprite.setPosition(pos.x, pos.y);
    m_sprite.setScale(m_textDim.x/dim.x, m_textDim.y/dim.y);
    if(m_commands > 0)
        m_loadProgress++;
    if(m_loadProgress > m_loadTime)
    {
        m_loadProgress = 0;
        m_commands--;
        triggerEvent();
    }
}
Ejemplo n.º 28
0
void ofxUICanvasPlus::loadSettingsFromXml(ofxXmlSettings& xml) {
	int widgetTags = xml.getNumTags("Widget"); 
	for(int i = 0; i < widgetTags; i++) {
		xml.pushTag("Widget", i);
		string name = xml.getValue("Name", "NULL", 0);
		ofxUIWidget *widget = getWidget(name); 
		if(widget != NULL) {
			loadSpecificWidgetData(widget, &xml); 
			triggerEvent(widget); 
		}
		xml.popTag(); 
	}
}
void ofxUIToggleMatrix::setAllTogglesAndTrigger(bool _value)
{
    for(unsigned int i = 0; i < toggles.size(); i++)
    {
        ofxUIToggle *t = toggles[i];
        t->setValue(_value);
    }
    
    for(unsigned int i = 0; i < toggles.size(); i++)
    {
        triggerEvent(toggles[i]);
    }
}
void PusherClient::unsubscribe(const String& channel) 
{
    String unsubscribeEventName; 
    String stringVar0; 
    String message; 
		
	getStringTableItem(12, unsubscribeEventName);
	getStringTableItem(0, stringVar0);
	getStringTableItem(9, message);
	
    message.replace(stringVar0, channel);
	
    triggerEvent(unsubscribeEventName, message);
}