当前位置: 首页>>代码示例>>C++>>正文


C++ EventHandler类代码示例

本文整理汇总了C++中EventHandler的典型用法代码示例。如果您正苦于以下问题:C++ EventHandler类的具体用法?C++ EventHandler怎么用?C++ EventHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了EventHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: manageInvasionEvent

static void manageInvasionEvent(color_ostream& out) {
    if ( handlers[EventType::INVASION].empty() )
        return;

    multimap<Plugin*,EventHandler> copy(handlers[EventType::INVASION].begin(), handlers[EventType::INVASION].end());

    if ( df::global::ui->invasions.next_id <= nextInvasion )
        return;
    nextInvasion = df::global::ui->invasions.next_id;

    for ( auto a = copy.begin(); a != copy.end(); a++ ) {
        EventHandler handle = (*a).second;
        handle.eventHandler(out, (void*)nextInvasion);
    }
}
开发者ID:AlexanderStarr,项目名称:dfhack,代码行数:15,代码来源:EventManager.cpp

示例2:

Mouse::~Mouse()
{
  _pickerPath.remove_node();
  
  EventHandler* events = EventHandler::get_global_event_handler();
  
  
  events->remove_hook("mouse1",     &Mouse::CallbackButton1,   (void*)this);
  events->remove_hook("mouse2",     &Mouse::CallbackButton2,   (void*)this);
  events->remove_hook("mouse3",     &Mouse::CallbackButton3,   (void*)this);
  events->remove_hook("wheel_up",   &Mouse::CallbackWheelUp,   (void*)this);
  events->remove_hook("wheel_down", &Mouse::CallbackWheelDown, (void*)this);
  
  MouseCursor::Get()->SetCursorType("cursor-interaction");
}
开发者ID:655473,项目名称:fallout-equestria,代码行数:15,代码来源:mouse.cpp

示例3: bool

    /*--------------------------------------------------------------------------------
        Function    : InventoryScreen::eventLoop
        Description : Event loop for the inventory screen.
        Inputs      : None
        Outputs     : Results of the player's actions in the inventory.
        Return      : bool (whether the action costs a turn)
    --------------------------------------------------------------------------------*/
    bool InventoryScreen::eventLoop()
    {
        EventHandler eventHandler;
        EventType event;

        do
        {
            update();
            event = eventHandler.getPlayerInput();
            interpretEvent(event);
        }
        while(keepRunning);

        return false;
    }
开发者ID:jcarvajal288,项目名称:RLEngine,代码行数:22,代码来源:MenuScreen.cpp

示例4: Tcl_SetResult

int EventHandler::playToneHandler(ClientData cdata, Tcl_Interp *irp,
      	      	      	      int argc, const char *argv[])
{
  if(argc != 4)
  {
    char msg[] = "Usage: playTone <fq> <amp> <milliseconds>";
    Tcl_SetResult(irp, msg, TCL_STATIC);
    return TCL_ERROR;
  }
  //cout << "EventHandler::playTone: " << argv[1] << endl;

  EventHandler *self = static_cast<EventHandler *>(cdata);
  self->playTone(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));

  return TCL_OK;
}
开发者ID:f5nlg,项目名称:svxlink,代码行数:16,代码来源:EventHandler.cpp

示例5: OnPlayerGiveDamage

static cell OnPlayerGiveDamage(AMX *amx) {
	int playerid = GetCellFromStack(amx, 0);
	int damagedid = GetCellFromStack(amx, 1);
	float amount = GetFloatFromStack(amx, 2);
	int weaponid = GetCellFromStack(amx, 3);
	
	EventHandler *cur = EventHandler::GetFirstEventHandler();
	while (cur != 0) {
		if (!cur->OnPlayerGiveDamage(playerid, damagedid, amount, weaponid)) {
			return 0;
		}
		cur = cur->GetNext();
	}

	return 1;
}
开发者ID:Hereticbeast,项目名称:sampgdk,代码行数:16,代码来源:callbacks.cpp

示例6: removeHandler

// synchronized
void InitiationDispatcher::removeHandler(const EventHandler & handler,
        const EventType & type)
{
    BOOST_LOG_TRIVIAL(trace) << "InitiationDispatcher entering removeHandler.";

    lock_guard<mutex> grd_lock(m_mutex);

    string id = handler.getId();

    BOOST_LOG_TRIVIAL(trace) << "Searching event handler w/ID ["
                             << id
                             << "]";

    auto type_handler = m_handlers.find(id);
    if(type_handler != m_handlers.end())
    {
        // found handler
        if (type_handler->second.type == type)
        {
            BOOST_LOG_TRIVIAL(info) << "Removing event handler w/ID ["
                                    << id + "] and type ["
                                    << EventTypeMap[type]
                                    << "]";
            m_handlers.erase(id);
        }
    }
}
开发者ID:rubensgomes,项目名称:misc-cpp-projs,代码行数:28,代码来源:initiation_dispatcher.cpp

示例7: registerHandler

// synchronized
void InitiationDispatcher::registerHandler(
        const EventHandler & handler,
        const EventType & type)
{
    BOOST_LOG_TRIVIAL(info) <<
            "InitiationDispatcher entering registerHandler.";

    lock_guard<mutex> grd_lock(m_mutex);

    if(m_is_closed)
    {
        throw new runtime_error(
                "The initiation dispatcher is closed.");
    }

    string id = handler.getId();

    BOOST_LOG_TRIVIAL(info) <<
            "Registering event handler w/ID [" +
            id +  "] and type [" +
            EventTypeMap[type] + "]";

    if (m_handlers.find(id))
    {
        throw invalid_argument ("Event handler with ID [" +
                id + "] has already been registered.");
    }

    EventTypeHandler type_handler;
    type_handler.type = type;
    type_handler.handler = handler;

    m_handlers.insert(
            pair<string,EventTypeHandler>(id, type_handler));
}
开发者ID:rubensgomes,项目名称:misc-cpp-projs,代码行数:36,代码来源:initiation_dispatcher.cpp

示例8: stop

SelectManager::~SelectManager()
{
    EventHandler *handler;
    EventMap::const_iterator iter;

    stop();
    FD_ZERO(&m_readSet);
    FD_ZERO(&m_writeSet);

    for (iter = m_eventMap.begin(); iter != m_eventMap.end(); )
    {
        handler = iter->second;
        if (handler->dec() == 0) delete handler;
        iter = m_eventMap.erase(iter);
    }
}
开发者ID:ivanchen36,项目名称:eagle,代码行数:16,代码来源:SelectManager.cpp

示例9: OnPlayerClickMap

static cell OnPlayerClickMap(AMX *amx) {
	int playerid = GetCellFromStack(amx, 0);
	float x = GetFloatFromStack(amx, 1);
	float y = GetFloatFromStack(amx, 2);
	float z = GetFloatFromStack(amx, 3);
	
	EventHandler *cur = EventHandler::GetFirstEventHandler();
	while (cur != 0) {
		if (!cur->OnPlayerClickMap(playerid, x, y, z)) {
			return 0;
		}
		cur = cur->GetNext();
	}

	return 1;
}
开发者ID:Hereticbeast,项目名称:sampgdk,代码行数:16,代码来源:callbacks.cpp

示例10: INFO_OUT

void LibEventMain::errorfn(bufferevent *bev, short int error, void *arg) {
    INFO_OUT("Errorfn: %x\n", error);
    if (error & BEV_EVENT_CONNECTED) {
        bufferevent_setwatermark(bev, EV_READ, 0, max_buff);
        bufferevent_enable(bev, EV_READ | EV_WRITE);
        EventHandler *p = (EventHandler *) arg;
        if (p) {
            p->enable();
        }
    }
    // if error & BEV_EVENT_EOF, BEV_EVENT_ERROR, BEV_EVENT_TIMEOUT
    if ((error & BEV_EVENT_ERROR) || (error & BEV_EVENT_EOF)
            || (error & BEV_EVENT_TIMEOUT)) {
        bufferevent_free(bev);
    }
}
开发者ID:ahsank,项目名称:EvaluateIPC,代码行数:16,代码来源:eventserver.cpp

示例11: OnVehicleRespray

static cell OnVehicleRespray(AMX *amx) {
	int playerid = GetCellFromStack(amx, 0);
	int vehicleid = GetCellFromStack(amx, 1);
	int color1 = GetCellFromStack(amx, 2);
	int color2 = GetCellFromStack(amx, 3);

	EventHandler *cur = EventHandler::GetFirstEventHandler();
	while (cur != 0) {
		if (!cur->OnVehicleRespray(playerid, vehicleid, color1, color2)) {
			return 0;
		}
		cur = cur->GetNext();
	}

	return 1;
}
开发者ID:Hereticbeast,项目名称:sampgdk,代码行数:16,代码来源:callbacks.cpp

示例12: manageBuildingEvent

static void manageBuildingEvent(color_ostream& out) {
    /*
     * TODO: could be faster
     * consider looking at jobs: building creation / destruction
     **/
    if ( handlers[EventType::BUILDING].empty() )
        return;
    
    multimap<Plugin*,EventHandler> copy(handlers[EventType::BUILDING].begin(), handlers[EventType::BUILDING].end());
    //first alert people about new buildings
    for ( int32_t a = nextBuilding; a < *df::global::building_next_id; a++ ) {
        int32_t index = df::building::binsearch_index(df::global::world->buildings.all, a);
        if ( index == -1 ) {
            //out.print("%s, line %d: Couldn't find new building with id %d.\n", __FILE__, __LINE__, a);
            //the tricky thing is that when the game first starts, it's ok to skip buildings, but otherwise, if you skip buildings, something is probably wrong. TODO: make this smarter
            continue;
        }
        buildings.insert(a);
        for ( auto b = copy.begin(); b != copy.end(); b++ ) {
            EventHandler bob = (*b).second;
            bob.eventHandler(out, (void*)a);
        }
    }
    nextBuilding = *df::global::building_next_id;
    
    //now alert people about destroyed buildings
    unordered_set<int32_t> toDelete;
    for ( auto a = buildings.begin(); a != buildings.end(); a++ ) {
        int32_t id = *a;
        int32_t index = df::building::binsearch_index(df::global::world->buildings.all,id);
        if ( index != -1 )
            continue;
        toDelete.insert(id);

        for ( auto b = copy.begin(); b != copy.end(); b++ ) {
            EventHandler bob = (*b).second;
            bob.eventHandler(out, (void*)id);
        }
    }

    for ( auto a = toDelete.begin(); a != toDelete.end(); a++ ) {
        int32_t id = *a;
        buildings.erase(id);
    }
    
    //out.print("Sent building event.\n %d", __LINE__);
}
开发者ID:AlexanderStarr,项目名称:dfhack,代码行数:47,代码来源:EventManager.cpp

示例13: ProtoMonitor

LiveTVPlayback::LiveTVPlayback(EventHandler& handler)
: ProtoMonitor(handler.GetServer(), handler.GetPort()), EventSubscriber()
, m_eventHandler(handler)
, m_eventSubscriberId(0)
, m_tuneDelay(MIN_TUNE_DELAY)
, m_recorder()
, m_signal()
, m_chain()
{
  m_eventSubscriberId = m_eventHandler.CreateSubscription(this);
  m_eventHandler.SubscribeForEvent(m_eventSubscriberId, EVENT_SIGNAL);
  m_eventHandler.SubscribeForEvent(m_eventSubscriberId, EVENT_LIVETV_CHAIN);
  m_eventHandler.SubscribeForEvent(m_eventSubscriberId, EVENT_LIVETV_WATCH);
  m_eventHandler.SubscribeForEvent(m_eventSubscriberId, EVENT_DONE_RECORDING);
  m_eventHandler.SubscribeForEvent(m_eventSubscriberId, EVENT_UPDATE_FILE_SIZE);
  Open();
}
开发者ID:jshattoc,项目名称:pvr.mythtv,代码行数:17,代码来源:mythlivetvplayback.cpp

示例14: addEventHandler

void Game::addEventHandler(EventHandler & eventHandler) {

	if(window != NULL) {
		eventHandler.setGame(*this);
		window->addEventHandler(eventHandler);
	}

}
开发者ID:zapo,项目名称:BomberSFML,代码行数:8,代码来源:Game.cpp

示例15: strdup

void DynamicObject::AddEventHandler(const char *event, const char *code)
{
    char *ename = strdup(event);

    while (ename) {
        char *end = strchr(ename, ',');
        if (end) {
            *end++ = 0;
        }
        Script *script = new Script(ename, code);
        EventHandler *handler = new EventHandler(ename, script);
        RegisterEventHandler(handler);
        handler->DecRef();
        ename = end;
    }
    free(ename);
}
开发者ID:vseryakov,项目名称:lmbox,代码行数:17,代码来源:object.cpp


注:本文中的EventHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。