예제 #1
0
void SpriteDef::substituteAction(std::string complete, std::string with)
{
    for (ActionsConstIter it = mActions.begin(), it_end = mActions.end();
         it != it_end; ++ it)
    {
        ActionMap *d = (*it).second;
        if (!d)
            continue;
        if (d->find(complete) == d->end())
        {
            ActionMap::iterator i = d->find(with);
            if (i != d->end())
                (*d)[complete] = i->second;
        }
    }
}
예제 #2
0
파일: guipage.cpp 프로젝트: imeteora/vdrift
static void ConnectActions(
	const std::string & actionstr,
	const ActionMap & actionmap,
	Signal & signal)
{
	size_t len = actionstr.size();
	size_t pos = 0;
	while (pos < len)
	{
		pos = actionstr.find_first_not_of(' ', pos);
		if (pos >= len)
			break;

		size_t posn = actionstr.find(' ', pos);
		size_t n = actionstr.find(':', pos);
		if (n < posn && n + 1 < len && actionstr[n + 1] == '"')
			posn = actionstr.find('"', n + 2) + 1;

		std::string action = actionstr.substr(pos, posn - pos);
		pos = posn;

		typename ActionMap::const_iterator it = actionmap.find(action);
		if (it != actionmap.end())
			it->second->connect(signal);
	}
}
예제 #3
0
void SpriteDef::fixDeadAction()
{
    for (ActionsIter it = mActions.begin(), it_end = mActions.end();
         it != it_end; ++ it)
    {
        ActionMap *d = (*it).second;
        if (!d)
            continue;
        ActionMap::iterator i = d->find(SpriteAction::DEAD);
        ActionMap::iterator i2 = d->find(SpriteAction::STAND);
        // search dead action and check what it not same with stand action
        if (i != d->end() && i->second && i->second != i2->second)
            (i->second)->setLastFrameDelay(0);
    }
}
예제 #4
0
bool InputManager::InvokeActions(Context* context, wxEvent* e, wxWindow* win)
{
    wxEventType eventType(e->GetEventType);

    EventTypeIter i = actions.find(eventType);
    if (i == actions.end()) return;

    ActionMap* actionMap = i->second;

    ActionMapIter j = actionMap->find(context);
    if (j == actionMap.end()) return;

    ActionSet* actionSet = j->second;

    wxString actionname;
    if (actionSet->matchesEvent(e, win, &actionname))
        return InvokeEvent(actionname, win);
    else
        return false;
}
예제 #5
0
파일: guipage.cpp 프로젝트: imeteora/vdrift
static void ParseActions(
	const std::string & actions,
	const ActionMap & vactionmap,
	const WidgetMap & widgetmap,
	const WidgetListMap & widgetlistmap,
	ActionValSet & action_val_set,
	ActionValnSet & action_valn_set)
{
	size_t len = actions.size();
	size_t pos = 0;
	while(pos < len)
	{
		pos = actions.find_first_not_of(' ', pos);
		if (pos >= len)
			break;

		// get next action with value
		size_t posn = actions.find(' ', pos);
		size_t n = actions.find(':', pos);
		if (n > posn)
		{
			pos = posn;
			continue;
		}

		if (n + 1 < len && actions[n + 1] == '"')
			posn = actions.find('"', n + 2) + 1;

		std::string action = actions.substr(pos, posn - pos);
		std::string aname = actions.substr(pos, n - pos);

		pos = posn;

		// check if action is in vactionmap
		typename ActionMap::const_iterator vai = vactionmap.find(aname);
		if (vai != vactionmap.end())
		{
			action_val_set.insert(std::make_pair(action, vai->second));
			continue;
		}

		size_t wn = aname.find('.');
		if (wn == 0 || wn == std::string::npos)
			continue;

		std::string wname = aname.substr(0, wn);
		std::string pname = aname.substr(wn + 1);

		// check if action is setting a widget property
		typename WidgetMap::const_iterator wi = widgetmap.find(wname);
		if (wi != widgetmap.end())
		{
			Slot1<const std::string &> * pslot;
			if (wi->second->GetProperty(pname, pslot))
				action_val_set.insert(std::make_pair(action, pslot));
			continue;
		}

		// check if action is setting a widget list property (only valid for control lists)
		typename WidgetListMap::const_iterator wli = widgetlistmap.find(wname);
		if (wli != widgetlistmap.end())
		{
			Slot2<int, const std::string &> * pslot;
			if (wli->second->GetProperty(pname, pslot))
				action_valn_set.insert(std::make_pair(action, pslot));
		}
	}
}