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


C++ Tool::GetIdentifier方法代码示例

本文整理汇总了C++中Tool::GetIdentifier方法的典型用法代码示例。如果您正苦于以下问题:C++ Tool::GetIdentifier方法的具体用法?C++ Tool::GetIdentifier怎么用?C++ Tool::GetIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tool的用法示例。


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

示例1: Update

void GameController::Update()
{
	ui::Point pos = gameView->GetMousePosition();
	gameModel->GetRenderer()->mousePos = PointTranslate(pos);
	if (pos.X < XRES && pos.Y < YRES)
		gameView->SetSample(gameModel->GetSimulation()->GetSample(PointTranslate(pos).X, PointTranslate(pos).Y));
	else
		gameView->SetSample(gameModel->GetSimulation()->GetSample(pos.X, pos.Y));

	Simulation * sim = gameModel->GetSimulation();
	sim->update_particles();

	//if either STKM or STK2 isn't out, reset it's selected element. Defaults to PT_DUST unless right selected is something else
	//This won't run if the stickmen dies in a frame, since it respawns instantly
	if (!sim->player.spwn || !sim->player2.spwn)
	{
		int rightSelected = PT_DUST;
		Tool * activeTool = gameModel->GetActiveTool(1);
		if (activeTool->GetIdentifier().find("DEFAULT_PT_") != activeTool->GetIdentifier().npos)
		{
			int sr = activeTool->GetToolID();
			if ((sr>0 && sr<PT_NUM && sim->elements[sr].Enabled && sim->elements[sr].Falldown>0) || sr==SPC_AIR || sr == PT_NEUT || sr == PT_PHOT || sr == PT_LIGH)
				rightSelected = sr;
		}

		if (!sim->player.spwn)
			sim->player.elem = rightSelected;
		if (!sim->player2.spwn)
			sim->player2.elem = rightSelected;
	}
	if(renderOptions && renderOptions->HasExited)
	{
		delete renderOptions;
		renderOptions = NULL;
	}

	if(search && search->HasExited)
	{
		delete search;
		search = NULL;
	}

	if(activePreview && activePreview->HasExited)
	{
		delete activePreview;
		activePreview = NULL;
	}

	if(loginWindow && loginWindow->HasExited)
	{
		delete loginWindow;
		loginWindow = NULL;
	}

	if(localBrowser && localBrowser->HasDone)
	{
		delete localBrowser;
		localBrowser = NULL;
	}
}
开发者ID:JoeyJo0,项目名称:The-Powder-Toy,代码行数:60,代码来源:GameController.cpp

示例2: searchTools

void ElementSearchActivity::searchTools(std::string query)
{
	firstResult = NULL;
	for(std::vector<ToolButton*>::iterator iter = toolButtons.begin(), end = toolButtons.end(); iter != end; ++iter) {
		delete *iter;
		RemoveComponent(*iter);
	}
	toolButtons.clear();

	ui::Point viewPosition = searchField->Position + ui::Point(2+0, searchField->Size.Y+2+8);
	ui::Point current = ui::Point(0, 0);

	std::string queryLower = std::string(query);
	std::transform(queryLower.begin(), queryLower.end(), queryLower.begin(), ::tolower);

	std::vector<Tool *> matches;
	std::vector<Tool *> frontmatches;
	std::vector<Tool *> exactmatches;

	for(std::vector<Tool*>::const_iterator iter = tools.begin(), end = tools.end(); iter != end; ++iter)
	{
		std::string nameLower = std::string((*iter)->GetName());
		std::transform(nameLower.begin(), nameLower.end(), nameLower.begin(), ::tolower);
		if(!strcmp(nameLower.c_str(), queryLower.c_str()))
			exactmatches.push_back(*iter);
		else if(!strncmp(nameLower.c_str(), queryLower.c_str(), queryLower.length()))
			frontmatches.push_back(*iter);
		else if(strstr(nameLower.c_str(), queryLower.c_str()))
			matches.push_back(*iter);
	}

	matches.insert(matches.begin(), frontmatches.begin(), frontmatches.end());
	matches.insert(matches.begin(), exactmatches.begin(), exactmatches.end());

	for(std::vector<Tool*>::const_iterator iter = matches.begin(), end = matches.end(); iter != end; ++iter)
	{
		Tool * tool = *iter;

		if(!firstResult)
			firstResult = tool;

		VideoBuffer * tempTexture = tool->GetTexture(26, 14);
		ToolButton * tempButton;

		if(tempTexture)
			tempButton = new ToolButton(current+viewPosition, ui::Point(30, 18), "", tool->GetIdentifier(), tool->GetDescription());
		else
			tempButton = new ToolButton(current+viewPosition, ui::Point(30, 18), tool->GetName(), tool->GetIdentifier(), tool->GetDescription());

		tempButton->Appearance.SetTexture(tempTexture);
		tempButton->Appearance.BackgroundInactive = ui::Colour(tool->colRed, tool->colGreen, tool->colBlue);
		tempButton->SetActionCallback(new ToolAction(this, tool));

		if(gameController->GetActiveTool(0) == tool)
		{
			tempButton->SetSelectionState(0);	//Primary
		}
		else if(gameController->GetActiveTool(1) == tool)
		{
			tempButton->SetSelectionState(1);	//Secondary
		}
		else if(gameController->GetActiveTool(2) == tool)
		{
			tempButton->SetSelectionState(2);	//Tertiary
		}

		toolButtons.push_back(tempButton);
		AddComponent(tempButton);

		current.X += 31;

		if(current.X + 30 > searchField->Size.X) {
			current.X = 0;
			current.Y += 19;
		}

		if(current.Y + viewPosition.Y + 18 > Size.Y-23)
			break;
	}
}
开发者ID:SopaXorzTaker,项目名称:TPT-Alchemy,代码行数:80,代码来源:ElementSearchActivity.cpp

示例3: Update

void GameController::Update()
{
    ui::Point pos = gameView->GetMousePosition();
    gameModel->GetRenderer()->mousePos = PointTranslate(pos);
    if (pos.X < XRES && pos.Y < YRES)
        gameView->SetSample(gameModel->GetSimulation()->GetSample(PointTranslate(pos).X, PointTranslate(pos).Y));
    else
        gameView->SetSample(gameModel->GetSimulation()->GetSample(pos.X, pos.Y));

    Simulation * sim = gameModel->GetSimulation();
    sim->BeforeSim();
    if (!sim->sys_pause || sim->framerender)
    {
        sim->UpdateParticles(0, NPART);
        sim->AfterSim();
    }

    //if either STKM or STK2 isn't out, reset it's selected element. Defaults to PT_DUST unless right selected is something else
    //This won't run if the stickmen dies in a frame, since it respawns instantly
    if (!sim->player.spwn || !sim->player2.spwn)
    {
        int rightSelected = PT_DUST;
        Tool * activeTool = gameModel->GetActiveTool(1);
        if (activeTool->GetIdentifier().find("DEFAULT_PT_") != activeTool->GetIdentifier().npos)
        {
            int sr = activeTool->GetToolID();
            if (sr && sim->IsValidElement(sr))
                rightSelected = sr;
        }

        if (!sim->player.spwn)
            Element_STKM::STKM_set_element(sim, &sim->player, rightSelected);
        if (!sim->player2.spwn)
            Element_STKM::STKM_set_element(sim, &sim->player2, rightSelected);
    }
    if(renderOptions && renderOptions->HasExited)
    {
        delete renderOptions;
        renderOptions = NULL;
    }

    if(search && search->HasExited)
    {
        delete search;
        search = NULL;
    }

    if(activePreview && activePreview->HasExited)
    {
        delete activePreview;
        activePreview = NULL;
    }

    if(loginWindow && loginWindow->HasExited)
    {
        delete loginWindow;
        loginWindow = NULL;
    }

    if(localBrowser && localBrowser->HasDone)
    {
        delete localBrowser;
        localBrowser = NULL;
    }
}
开发者ID:Gabrieltorreiro,项目名称:The-Powder-Toy,代码行数:65,代码来源:GameController.cpp


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