示例#1
0
void GmailSettings::remove()
{
    removeResource(mMailtransportIdentifier);
    removeResource(mImapIdentifier);
    removeIdentity();
    removeAccount();
}
示例#2
0
//:Inserts "rResource" into the flow graph upstream of the
//:designated "rDownstreamResource" resource.
// The new resource will be inserted on the "inPortIdx" input
// link of "rDownstreamResource".
// If the flow graph is not "started", this call takes effect
// immediately.  Otherwise, the call takes effect at the start of the
// next frame processing interval.
// Returns OS_SUCCESS if the resource was successfully inserted. Returns
// OS_INVALID_ARGUMENT if the caller specified an invalid port index.
OsStatus MpFlowGraphBase::insertResourceBefore(MpResource& rResource,
                                 MpResource& rDownstreamResource,
                                 int inPortIdx)
{
   MpResource *pUpstreamResource;
   int         upstreamOutPortIdx;
   OsStatus    res;

   // Get information about the downstream end of the link
   rDownstreamResource.getInputInfo(inPortIdx, pUpstreamResource,
                                    upstreamOutPortIdx);

   // Add the new resource to the flow graph
   res = addResource(rResource);
   if (res != OS_SUCCESS)
      return res;

   if (pUpstreamResource != NULL)
   {
      // Remove the link between the upstream and downstream resources
      res = removeLink(*pUpstreamResource, upstreamOutPortIdx);
      if (res != OS_SUCCESS)
      {                              // recover from remove link failure
         removeResource(rResource);
         return res;
      }

      // Add the link between output port 0 the new resource and the
      // downstream resource
      res = addLink(rResource, 0, rDownstreamResource, inPortIdx);
      if (res != OS_SUCCESS)
      {                              // recover from add link failure
         removeResource(rResource);
         addLink(*pUpstreamResource, upstreamOutPortIdx,
                 rDownstreamResource, inPortIdx);
         return res;
      }
   }

   // Add the link between the upstream resource and input port 0 of
   // the new resource
   res = addLink(*pUpstreamResource, upstreamOutPortIdx, rResource, 0);
   if (res != OS_SUCCESS)
   {                              // recover from add link failure
      removeResource(rResource);
      if (pUpstreamResource != NULL)
      {
         addLink(*pUpstreamResource, upstreamOutPortIdx,
                 rDownstreamResource, inPortIdx);
      }
   }

   return res;
}
示例#3
0
void Player::reduceResources(eChipType c)
{
    switch (c)
    {
    case ROAD:
            removeResource(CT_LUMBER, 1);
            removeResource(CT_BRICK, 1);
            GameEngine::instance().putRecourcesToBank(CT_LUMBER, 1);
            GameEngine::instance().putRecourcesToBank(CT_BRICK, 1);
        break;
    case VILLAGE:
            removeResource(CT_LUMBER, 1);
            removeResource(CT_BRICK, 1);
            removeResource(CT_WOOL, 1);
            removeResource(CT_GRAIN, 1);
            GameEngine::instance().putRecourcesToBank(CT_LUMBER, 1);
            GameEngine::instance().putRecourcesToBank(CT_BRICK, 1);
            GameEngine::instance().putRecourcesToBank(CT_WOOL, 1);
            GameEngine::instance().putRecourcesToBank(CT_GRAIN, 1);
        break;
    case CITY:
            removeResource(CT_ORE, 3);
            removeResource(CT_GRAIN, 2);
            GameEngine::instance().putRecourcesToBank(CT_ORE, 3);
            GameEngine::instance().putRecourcesToBank(CT_GRAIN, 2);
        break;
    case ROBBERS:
    case TYPE_UNDEFINE:
    default:
        break;
    }
}
示例#4
0
void ResourceManager::removeResource(Resource* resource)
{
	if( !resource ) return;

	const String& path = resource->getPath();
	removeResource(path);
}
示例#5
0
void ResourceManager::removeResource(const String& path)
{
	auto key = MurmurHash64(path.c_str(), path.size(), 0);
	removeResource(key);

	LogInfo("Unloaded resource: %s", path.c_str());
}
示例#6
0
文件: Entity.cpp 项目: Cmdu76/Delmia
int Entity::moveResource(std::size_t resourceId, int value)
{
    if (hasResourceAmount(resourceId,value))
    {
        removeResource(resourceId,value);
        return value;
    }
    return 0;
}
/*! \brief Remove the selected entity node
*/
void EntitiesTreeWidget::onRemove()
{
    QTreeWidgetItem *item = currentItem();


    if(!item){
        return;
    }



    if(QMessageBox::question(this,"Removing","Are you sure to remove this item?") == QMessageBox::Yes){

        if(item->parent() == applicationNode){
            if(item->data(0,Qt::UserRole)  == yarp::manager::APPLICATION){
                yarp::manager::Application *app = (yarp::manager::Application*)item->data(0,Qt::UserRole + 1).toLongLong();
                if(app){
                    QString appName = item->text(0);

                    removeApplication(appName);
                }

            }
        }else
            if(item->parent() == resourcesNode){
                if(item->data(0,Qt::UserRole)  == yarp::manager::RESOURCE){
                    yarp::manager::Computer *res = (yarp::manager::Computer*)item->data(0,Qt::UserRole + 1).toLongLong();
                    if(res){
                        QString resName = item->text(0);

                        removeResource(resName);
                    }
                }
            }else
            if(item->parent() == modulesNode){
                if(item->data(0,Qt::UserRole)  == yarp::manager::MODULE){
                    yarp::manager::Module *mod = (yarp::manager::Module*)item->data(0,Qt::UserRole + 1).toLongLong();
                    if(mod){
                        QString modName = item->text(0);

                        removeModule(modName);
                    }
                }
            }

            while(item->childCount()>0){
                delete item->takeChild(0);
            }

            if(item->parent()){
                int index = item->parent()->indexOfChild(item);
                delete item->parent()->takeChild(index);
            }
    }
}
示例#8
0
bool DnsLayer::removeAnswer(DnsResource* answerToRemove)
{
	bool res = removeResource(answerToRemove);
	if (res)
	{
		// decrease number of answer records
		getDnsHeader()->numberOfAnswers = htons(getAnswerCount() - 1);
	}

	return res;
}
示例#9
0
bool DnsLayer::removeQuery(DnsQuery* queryToRemove)
{
	bool res = removeResource(queryToRemove);
	if (res)
	{
		// decrease number of query records
		getDnsHeader()->numberOfQuestions = htons(getQueryCount() - 1);
	}

	return res;
}
示例#10
0
bool DnsLayer::removeAdditionalRecord(DnsResource* additionalRecordToRemove)
{
	bool res = removeResource(additionalRecordToRemove);
	if (res)
	{
		// decrease number of additional records
		getDnsHeader()->numberOfAdditional = htons(getAdditionalRecordCount() - 1);
	}

	return res;
}
示例#11
0
bool DnsLayer::removeAuthority(DnsResource* authorityToRemove)
{
	bool res = removeResource(authorityToRemove);
	if (res)
	{
		// decrease number of authority records
		getDnsHeader()->numberOfAuthority = htons(getAuthorityCount() - 1);
	}

	return res;
}
示例#12
0
void AppPanini::Exit(Renderer* pRenderer)
{
	ASSERT(pRenderer);

	removeShader(pRenderer, pShaderPanini);

	removeSampler(pRenderer, pSamplerTrilinearAniso);
	removeRasterizerState(pRasterizerStateCullNone);
	removeDepthState(pDepthStateDisable);

	removeRootSignature(pRenderer, pRootSignaturePaniniPostProcess);
	removePipeline(pRenderer, pPipielinePaniniPostProcess);

	removeResource(pVertexBufferTessellatedQuad);
	removeResource(pIndexBufferTessellatedQuad);

#if USE_DEDICATED_COMMAND_LIST
	removeCmd_n(pPaniniCmdPool, imageCount, ppPaniniCmds);
	removeCmdPool(pRenderer, pPaniniCmdPool);
#endif
}
示例#13
0
void ResourceManager::removeUnusedResources()
{
	#pragma TODO("Finish the unused resource collecetor")
	return;

	Array<uint64> resourcesToRemove;
	for(auto e : resources)
	{
		auto resource = e.value;
		if( resource.Resolve()->references.read() == 1 )
			resourcesToRemove.pushBack(e.key);
	}

	for(auto key : resourcesToRemove)
		removeResource(key);
}
示例#14
0
void Player::makeExchange(QList <int> &offer, QList <int> &taking, Player &player)
{
    for (int i = 0; i < CT_DEVELOPMENT; ++i)
    {
        if (offer[i] != 0)
        {
            addResource(static_cast<eCardType> (i), offer[i]);
            player.removeResource(static_cast<eCardType> (i), offer[i]);
        }
        if (taking[i] != 0)
        {
            removeResource(static_cast<eCardType> (i), taking[i]);
            player.addResource(static_cast<eCardType> (i), taking[i]);
        }
    }
    GameEngine::instance().updateAfterExchange();
}
status_t BnResourceManagerService::onTransact(
    uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags)
{
    switch (code) {
        case CONFIG: {
            CHECK_INTERFACE(IResourceManagerService, data, reply);
            Vector<MediaResourcePolicy> policies;
            readFromParcel(data, &policies);
            config(policies);
            return NO_ERROR;
        } break;

        case ADD_RESOURCE: {
            CHECK_INTERFACE(IResourceManagerService, data, reply);
            int pid = data.readInt32();
            int64_t clientId = data.readInt64();
            sp<IResourceManagerClient> client(
                    interface_cast<IResourceManagerClient>(data.readStrongBinder()));
            Vector<MediaResource> resources;
            readFromParcel(data, &resources);
            addResource(pid, clientId, client, resources);
            return NO_ERROR;
        } break;

        case REMOVE_RESOURCE: {
            CHECK_INTERFACE(IResourceManagerService, data, reply);
            int pid = data.readInt32();
            int64_t clientId = data.readInt64();
            removeResource(pid, clientId);
            return NO_ERROR;
        } break;

        case RECLAIM_RESOURCE: {
            CHECK_INTERFACE(IResourceManagerService, data, reply);
            int callingPid = data.readInt32();
            Vector<MediaResource> resources;
            readFromParcel(data, &resources);
            bool ret = reclaimResource(callingPid, resources);
            reply->writeInt32(ret);
            return NO_ERROR;
        } break;

        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
示例#16
0
void InspectorController::pruneResources(ResourcesMap* resourceMap, DocumentLoader* loaderToKeep)
{
    ASSERT_ARG(resourceMap, resourceMap);

    ResourcesMap mapCopy(*resourceMap);
    ResourcesMap::iterator end = mapCopy.end();
    for (ResourcesMap::iterator it = mapCopy.begin(); it != end; ++it) {
        InspectorResource* resource = (*it).second.get();
        if (resource == m_mainResource)
            continue;

        if (!loaderToKeep || resource->loader != loaderToKeep) {
            removeResource(resource);
            if (windowVisible() && resource->scriptObject)
                removeScriptResource(resource);
        }
    }
}
示例#17
0
void InspectorController::didFinishLoading(DocumentLoader* loader, unsigned long identifier)
{
    if (!enabled())
        return;

    RefPtr<InspectorResource> resource = m_resources.get(identifier);
    if (!resource)
        return;

    removeResource(resource.get());

    resource->finished = true;
    resource->endTime = currentTime();

    addResource(resource.get());

    if (windowVisible() && resource->scriptObject) {
        updateScriptResource(resource.get(), resource->startTime, resource->responseReceivedTime, resource->endTime);
        updateScriptResource(resource.get(), resource->finished);
    }
}
示例#18
0
void WindowBase::setFontResource(std::shared_ptr<FontResource> fontResource) {
	::SendMessage (mHWnd, WM_SETFONT, reinterpret_cast<WPARAM>(fontResource->getHFont()), TRUE);

	// When the font instance change remove previous instance from the resource
	// repository to avoid memory leaks
	if (mCurrentFontResourceInstId && mCurrentFontResourceInstId != fontResource->getFont().get()) {
		removeResource (mCurrentFontResourceInstId);
		mCurrentFontResourceInstId = nullptr;
	}
	
	// If the font is not stored in the resource repository, add it
	if (!resourceExist (fontResource->getFont().get())) {
		mCurrentFontResourceInstId = fontResource->getFont().get();
		addResource (mCurrentFontResourceInstId, fontResource);
		
		fontResource->changedEvent.add([&]{ 
			auto resource = getFontResource();
			if (resource) {
				::SendMessage (mHWnd, WM_SETFONT, reinterpret_cast<WPARAM>(resource->getHFont()), TRUE);
			}
		});
	}
}
示例#19
0
int main(int argc, char **argv)
{
	const char *inputImage = NULL, *outputImage = NULL, *string = NULL, *file = NULL;
	unsigned long mode = 0, result = 0, id = 0;
	Elf32_ResType type = ELF_RES_TYPE_UNKNOWN;
	extern char *optarg;
	int c;

	while ((c = getopt(argc, argv, "lhupart:n:s:f:i:o:I:")) != EOF)
	{
		switch (c) 
		{
			case 'h':
				fprintf(stderr, "Usage: elfres [-u/-p/-l/-a/-r] [-t type] [-s string] [-f file]\n"
									 "              [-I id] [-i input img] [-o output img]\n\n"
									 "       -p --> print a resource specified by an id.\n"
									 "       -u --> update a resource.\n"
									 "       -l --> list resources in the specified input file.\n"
									 "       -a --> add a resource to the specified input file\n"
									 "              and store it in the output file, if specified.\n"
									 "       -r --> remove a resource to the specified input file\n"
									 "              and store it in the output file, if specified.\n"
									 "              the resource is identified by an index (-n).\n");
				return 0;
			case 'l':
				mode = OPERATION_LIST;
				break;
			case 'p':
				mode = OPERATION_PRINT;
				break;
			case 'a':
				mode = OPERATION_ADD;
				break;
			case 'r':
				mode = OPERATION_REM;
				break;
			case 'u':
				mode = OPERATION_UPDATE;
				break;
			case 't':
				if (!strcasecmp(optarg, "binary")) 
					type = ELF_RES_TYPE_BINARY;
				else if (!strcasecmp(optarg, "string")) 
					type = ELF_RES_TYPE_STRING;
				else
					type = ELF_RES_TYPE_UNKNOWN;
				break;
			case 's':
				string = optarg;
				break;
			case 'f':
				file = optarg;
				break;
			case 'I':
				id = strtoul(optarg, NULL, 10);
				break;
			case 'i':
				inputImage = optarg;
				break;
			case 'o':
				outputImage = optarg;
				break;
			default:
				break;
		}
	}

	if (!inputImage)
	{
		fprintf(stderr, "elfres: No input file was specified.\n");
		return 0;
	}

	if (!outputImage)
		outputImage = inputImage;

	switch (mode)
	{
		case OPERATION_LIST:
			result = listResources(inputImage);
			break;
		case OPERATION_PRINT:
			if (!id)
				fprintf(stderr, "elfres: no identifier was specified (-I).\n");
			else
				result = printResource(inputImage, id);
			break;
		case OPERATION_ADD:
		case OPERATION_UPDATE:
			if (!id)
				fprintf(stderr, "elfres: no identifier was specified (-I).\n");
			else if (!string && !file)
				fprintf(stderr, "elfres: no data source was specified (-s/-f).\n");
			else
				result = addResource(mode, inputImage, outputImage, type, id, string, file);
			break;
		case OPERATION_REM:
			if (!id)
				fprintf(stderr, "elfres: no identifier was specified (-I).\n");
			else
				result = removeResource(inputImage, outputImage, id);
			break;
		default:
			fprintf(stderr, "elfres: unknown mode of operation.\n");
			break;
	}

	if (!result)
		fprintf(stderr, "elfres: the operation did not complete successfully.\n");

	return result;
}
示例#20
0
文件: Entity.cpp 项目: Cmdu76/Delmia
int Entity::moveResource(std::size_t resourceId)
{
    int amount = getResourceAmount(resourceId);
    removeResource(resourceId,amount);
    return amount;
}
示例#21
0
ResourceView::ResourceView( KCal::CalendarResources *calendar, QWidget *parent )
  : CalendarViewExtension( parent ), mCalendar( calendar )
{
  QVBoxLayout *topLayout = new QVBoxLayout( this );
  topLayout->setSpacing( KDialog::spacingHint() );

  QHBoxLayout *buttonBox = new QHBoxLayout();
  buttonBox->setSpacing( KDialog::spacingHint() );
  topLayout->addLayout( buttonBox );

  mListView = new QTreeWidget( this );
  mListView->setWhatsThis(
    i18nc( "@info:whatsthis",
           "This list shows all the calendars currently known to KOrganizer. "
           "Use the associated checkboxes to make a calendar active or inactive. "
           "Use the context menu to add, remove or edit calendars in the list."
           "<p>Events, journal entries and to-dos are retrieved and stored "
           "from their respective calendars. Calendars can be accessed from "
           "groupware servers, local files, etc...</p>"
           "<p>If you have more than one active calendar, you will be "
           "prompted for which calendar to store new items into, unless "
           "configured to always store to the default calendar.</p>" ) );
  mListView->setRootIsDecorated( false );
  mListView->setHeaderLabel( i18n( "Calendars" ) );
  mListView->header()->hide();
  topLayout->addWidget( mListView );

  mSelectedParent = 0;

  connect( mListView, SIGNAL(itemDoubleClicked(QTreeWidgetItem *,int)),
           SLOT(editResource()) );
  connect( mListView, SIGNAL(itemClicked(QTreeWidgetItem *,int)),
           SLOT(slotItemClicked(QTreeWidgetItem *,int)) );
  connect( mListView, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
           SLOT(currentChanged()) );

  mListView->setContextMenuPolicy( Qt::CustomContextMenu );
  connect( mListView, SIGNAL(customContextMenuRequested(const QPoint &)),
           SLOT(showContextMenu(const QPoint &)) );

  QLabel *calLabel = new QLabel( i18n( "Calendars" ), this );
  buttonBox->addWidget( calLabel );
  buttonBox->addStretch( 1 );

  mAddButton = new QToolButton( this );
  mAddButton->setIcon( KIcon( "list-add" ) );
  buttonBox->addWidget( mAddButton );
  mAddButton->setToolTip( i18nc( "@info:tooltip", "Add calendar" ) );
  mAddButton->setWhatsThis(
    i18nc( "@info:whatsthis",
           "Press this button to add a new calendar to KOrganizer. "
           "<p>Events, journal entries and to-dos are retrieved and stored "
           "from their respective calendars. Calendars can be accessed from "
           "groupware servers, local files, etc...</p>"
           "<p>If you have more than one active calendar, you will be "
           "prompted for which calendar to store new items into, unless "
           "configured to always store to the default calendar.</p>" ) );
  mEditButton = new QToolButton( this );
  mEditButton->setIcon( KIcon( "document-properties" ) );
  buttonBox->addWidget( mEditButton );
  mEditButton->setToolTip( i18nc( "@info:tooltip", "Edit calendar settings" ) );
  mEditButton->setWhatsThis(
    i18nc( "@info:whatsthis",
           "Press this button to edit the calendar currently "
           "selected in the list above." ) );
  mDeleteButton = new QToolButton( this );
  mDeleteButton->setIcon( KIcon( "edit-delete" ) );
  buttonBox->addWidget( mDeleteButton );
  mDeleteButton->setToolTip( i18nc( "@info:tooltip", "Remove calendar" ) );
  mDeleteButton->setWhatsThis(
    i18nc( "@info:whatsthis",
           "Press this button to delete the calendar currently "
           "selected in the list above." ) );
  mDeleteButton->setDisabled( true );
  mEditButton->setDisabled( true );

  connect( mAddButton, SIGNAL( clicked() ), SLOT( slotAddButtonClicked() ) );
  connect( mDeleteButton, SIGNAL( clicked() ), SLOT( removeResource() ) );
  connect( mEditButton, SIGNAL( clicked() ), SLOT( editResource() ) );

  setMinimumHeight( 50 );
  mListView->setSortingEnabled( true );

  updateView();
}
示例#22
0
bool BuildFleet::doOrder(IGObject::Ptr ob)
{
  Logger::getLogger()->debug("Entering BuildFleet::doOrder");

  Planet* planet = static_cast<Planet*>(ob->getObjectBehaviour());

  Game* game = Game::getGame();
  ResourceManager::Ptr resman = game->getResourceManager();
  const uint32_t resType = resman->getResourceDescription("Factories")->getResourceType();
  const uint32_t resValue = planet->getResourceSurfaceValue(resType);

  int ownerid = planet->getOwner();
  if(ownerid == 0){
      Logger::getLogger()->debug("Exiting BuildFleet::doOrder ownerid == 0");
      //currently not owned by anyone, just forget about it
      return true;
  }

  uint32_t runningTotal = resources[1];
  if (resValue == 0) {
    Message::Ptr msg(new Message());
    msg->setSubject("Build Fleet order error");
    msg->setBody(std::string("The construction of your  new fleet \"") + fleetname->getString() + "\" has been delayed, you do not have any production points this turn.");
    Game::getGame()->getPlayerManager()->getPlayer(ownerid)->postToBoard(msg);
    return false;
  } else if(runningTotal > resValue) {
    if (planet->removeResource(resType, resValue)) {
      removeResource(1, resValue);
      runningTotal = resources[1];
      uint32_t planetFactories = planet->getFactoriesPerTurn();
      turns = static_cast<uint32_t>(ceil(runningTotal / planetFactories));
      Message::Ptr msg(new Message());
      msg->setSubject("Build Fleet order slowed");
      msg->setBody(std::string("The construction of your new fleet \"") + fleetname->getString() + "\" has been delayed.");
      Game::getGame()->getPlayerManager()->getPlayer(ownerid)->postToBoard(msg);
      return false;
    }
  } else if(runningTotal <= resValue && planet->removeResource(resType, runningTotal)){
    //create fleet

    //this is probably unnecessary
    resources[1] = 0;
    Game* game = Game::getGame();
    
    
    IGObject::Ptr fleet = game->getObjectManager()->createNewObject();
    game->getObjectTypeManager()->setupObject(fleet, game->getObjectTypeManager()->getObjectTypeByName("Fleet"));

    //add fleet to container
    fleet->addToParent(ob->getID());

    fleet->setName(fleetname->getString().c_str());

    Fleet * thefleet = dynamic_cast<Fleet*>(fleet->getObjectBehaviour());

    thefleet->setSize(2);
    thefleet->setOwner(ownerid); // set ownerid
    thefleet->setPosition(planet->getPosition());
    thefleet->setVelocity(Vector3d(0LL, 0ll, 0ll));
    
    uint32_t queueid = Game::getGame()->getOrderManager()->addOrderQueue(fleet->getID(), ownerid);
    OrderQueueObjectParam* oqop = static_cast<OrderQueueObjectParam*>(fleet->getParameterByType(obpT_Order_Queue));
    oqop->setQueueId(queueid);
    thefleet->setDefaultOrderTypes();

    //set ship type
    IdMap fleettype = fleetlist->getList();
    for(IdMap::iterator itcurr = fleettype.begin(); itcurr != fleettype.end(); ++itcurr){
      thefleet->addShips(itcurr->first, itcurr->second);
      Design::Ptr design = Game::getGame()->getDesignStore()->getDesign(itcurr->first);
        design->addComplete(itcurr->second);
        Game::getGame()->getDesignStore()->designCountsUpdated(design);
    }
    //add fleet to universe
    Game::getGame()->getObjectManager()->addObject(fleet);
    Game::getGame()->getPlayerManager()->getPlayer(ownerid)->getPlayerView()->addOwnedObject(fleet->getID());

    Message::Ptr msg( new Message() );
    msg->setSubject("Build Fleet order complete");
    msg->setBody(std::string("The construction of your new fleet \"") + fleetname->getString() + "\" is complete.");
    msg->addReference(rst_Action_Order, rsorav_Completion);
    msg->addReference(rst_Object, fleet->getID());
    msg->addReference(rst_Object, ob->getID());
 
    Game::getGame()->getPlayerManager()->getPlayer(ownerid)->postToBoard(msg);
    Logger::getLogger()->debug("Exiting BuildFleet::doOrder on Success");

    return true;
  }
  Logger::getLogger()->debug("Exiting BuildFleet::doOrder on failure");

  return false;
}
示例#23
0
文件: GOAP.cpp 项目: OrangeKnife/NBE
	void GOAPapp::updateFrame()
	{
		m_startFrameTime = m_timer.GetSystemClocks();
		m_timer.PreciseWaitUntill(m_nextUpdateTime);
		m_nextUpdateTime = m_timer.GetSystemClocks() + m_timer.getDesireClocsPerFrame();

		if (m_pRenderer->isActive())
		{
			for (size_t i = 0; i < Input::getTotalInputNum(); ++i)
				Input::getInput(i)->update();

		}

		m_pCamera->updateViewMatrix();

		float color[4] = { 0.5f,0.6f,0.7f,0.1f };
		m_pRenderer->clearColorBuffer(color);
		m_pRenderer->clearDepthBuffer(1.0);

		m_pRenderer->applyShader(m_shaderID);

		m_pRenderer->applyMatrix(m_shaderID, "modelMat", Matrix4f::Identity());
		m_pRenderer->applyMatrix(m_shaderID, "viewMat", m_pCamera->getViewMatrix());
		m_pRenderer->applyMatrix(m_shaderID, "projMat", m_pCamera->getProjection());

		//static auto defTex = texArray[3];

		m_pRenderer->applyTexture(m_shaderID, "diftex", m_combinedTex, 0);

		static auto pShader = ShaderManager::getInstancePtr()->getShaderByIdx(m_shaderID);








		auto currentMap = m_maps[currentMapIdx];


		//start!
		static uint fcount = 0;
		fcount++;
		for (int i = 0; i < (int)botVec.size(); ++i)
		{
			if (!botVec[i]->foundPlan)
			{
				botVec[i]->updateExistenceByMap();
				botVec[i]->foundPlan = botVec[i]->doPlanfinding();

			}

			if (!botVec[i]->foundPathToTargetNode && botVec[i]->currentPlan.size() > 0)
			{
				uint end;
				if (botVec[i]->currentPlan.back()->needNodeType >= 0)
					end = currentMap->getAstarMapNodeByResourceType(botVec[i]->currentPlan.back()->needNodeType);
				else
					end = botVec[i]->currentMapNode;

				botVec[i]->foundPathToTargetNode = doPathFinding(currentMap, botVec[i], end);
				if (botVec[i]->foundPathToTargetNode)
				{
					botVec[i]->posInPathNode = botVec[i]->pathNodes.size() - 1;
					botVec[i]->goToNodeAction = botVec[i]->currentPlan.back();
					botVec[i]->currentPlan.pop_back();
				}
				else
				{
					clearAllBotsInfo();
				}
			}

			//rendering!!!
			if (fcount == 20 * 500)
			{
				fcount = 0;

				float rdIdx = ((float)rand()) / RAND_MAX * currentMap->nodesList.size();
				AstarMapNode& nd = currentMap->nodesList[(int)rdIdx];
				if (nd.nodeType == EMPTY)
				{
					nd.nodeType = WOLF;
					currentMap->resource[WOLF]->push_back(Res((int)rdIdx, true));
					currentMap->changeNodeTexInVBO(currentMap->nodesList[(int)rdIdx]);
					clearAllBotsInfo();
				}
			}





			if (fcount % 10 == 0)
			{
				int j = botVec[i]->posInPathNode--;
				if (j >= 0)
				{
					uint ndidx = botVec[i]->pathNodes[j];
					botVec[i]->currentMapNode = ndidx;

					botVec[i]->currentMapNode_Type = currentMap->nodesList[ndidx].nodeType;

					//botVec[i]->pathNodes.pop_back();

					if (j > 0)
					{
						currentMap->changeNodeTexInVBO(currentMap->nodesList[ndidx], botVec[i]->display);
						m_pRenderer->updateVBO(currentMap->renderObj->vbo_id, currentMap->renderObj->vbo, 0, currentMap->renderObj->VertexNum, sizeof(PT_Vertex));

					}
					else
					{
						botVec[i]->current->act(botVec[i]->goToNodeAction);//change Aibot aistate
						botVec[i]->goToNodeAction = NULL;//action done
						botVec[i]->foundPathToTargetNode = false;//need to find next target node

						if (botVec[i]->currentMapNode_Type == MONEY || botVec[i]->currentMapNode_Type == WOLF)
						{
							currentMap->removeResource(botVec[i]->currentMapNode_Type, ndidx);
							currentMap->nodesList[ndidx].nodeType = EMPTY;//set current node type = EMPTY, wipe it 
							clearAllBotsInfo();
							// map changed, re-find plan and path

						}

					}
				}
				else
				{
					int ndidx = botVec[i]->currentMapNode;

					currentMap->changeNodeTexInVBO(currentMap->nodesList[ndidx], botVec[i]->display);

					m_pRenderer->updateVBO(currentMap->renderObj->vbo_id, currentMap->renderObj->vbo, 0, currentMap->renderObj->VertexNum, sizeof(PT_Vertex));
				}
			}


		}


		if (fcount % 10 == 0)
		{
			for (int i = 0; i < (int)botVec.size(); ++i)
			{
				int ndidx = botVec[i]->currentMapNode;
				currentMap->nodesList[ndidx].nodeType = botVec[i]->currentMapNode_Type;
				currentMap->changeNodeTexInVBO(currentMap->nodesList[ndidx]);//,botVec[i]->display );
			}
		}


		m_pRenderer->bindVertexBuffer(currentMap->renderObj->vbo_id, sizeof(PT_Vertex), 0, pShader);//DX11:auto set the input layout
		m_pRenderer->bindIndexBuffer(currentMap->renderObj->ibo_id);



		m_pRenderer->drawIndex(4, currentMap->renderObj->IndexNum, 0, 0);//4 == triangles


		//DX need to reset shader resource = NULL when set render target
		//m_pRenderer->applyTexture(m_shaderID, "diftex", NULL,-1);
		//m_pRenderer->drawIndex(0,0,0,0);//apply the shader cleaning

		m_pRenderer->swapBuff(false);

	}
示例#24
0
// ----------------------------------------------------------------------------------
int main(int argc, char* argv[])
{
	ctkCommandLineParser commandLine;
	commandLine.setArgumentPrefix("--", "-");

	commandLine.beginGroup(QString("Option"));
	commandLine.addArgument("help", "h", QVariant::Bool,
		"Display available command line arguments.");
	commandLine.addArgument("list-resources", "l", QVariant::String,
		"List all resources of an executable or library.");
	commandLine.addArgument("add-resource-bitmap", "", QVariant::StringList,
		"Add resource using the provided <path/to/exec/or/lib> <resourceName> and <path/to/resource>");
	commandLine.addArgument("update-resource-ico", "", QVariant::StringList,
		"Add resource using the provided <path/to/exec/or/lib> <resourceName> and <path/to/resource>");
	commandLine.addArgument("delete-resource", "", QVariant::StringList,
		"Delete resource using the provided <path/to/exec/or/lib> <resourceType> <resourceName>");
	commandLine.endGroup();

	bool ok;
	QHash<QString, QVariant> parsedArgs = commandLine.parseArguments(argc, argv, &ok);
	if (!ok)
		{
		QTextStream(stdout, QIODevice::WriteOnly) << "Error parsing arguments : " << commandLine.errorString() << "\n";
		return EXIT_FAILURE;
		}

	if(parsedArgs.contains("help") || parsedArgs.contains("h"))
		{
		QTextStream(stdout, QIODevice::WriteOnly) << commandLine.helpText() << "\n";
		return EXIT_SUCCESS;
		}

	char* exePath;
	HMODULE hExe;       // handle to existing .EXE file

	if(parsedArgs.contains("list-resources") || parsedArgs.contains("l"))
		{
		// Load the .EXE file that contains the dialog box you want to copy.
		exePath =
			(char*) malloc(strlen(parsedArgs.value("list-resources").toString().toStdString().c_str()) * sizeof(char));
		strcpy(exePath, parsedArgs.value("list-resources").toString().toStdString().c_str());
		hExe = loadLibraryEx(TEXT(exePath), NULL, LOAD_LIBRARY_AS_IMAGE_RESOURCE);

		// List all resources
		EnumResourceTypes(hExe, (ENUMRESTYPEPROC)EnumTypesFunc, 0);

		for (int i = 0; i < resources::Resources.size() ; ++i)
			{
			QTextStream(stdout, QIODevice::WriteOnly) << "Type : " << resources::Resources.at(i).Type <<  " -- " << resources::types[resources::Resources.at(i).Type.toInt()] << "\n";
			QTextStream(stdout, QIODevice::WriteOnly) << "\tName : " << resources::Resources.at(i).Name << "\n";
			QTextStream(stdout, QIODevice::WriteOnly) << "\t\tLang : " << resources::Resources.at(i).Lang << "\n";
			}

		// Clean up.
		if (!FreeLibrary(hExe))
			{
			QTextStream(stdout, QIODevice::WriteOnly) << "Could not free executable : " << exePath << "\n";
			return EXIT_FAILURE;
			}
		}

	else if(parsedArgs.contains("delete-resource"))
		{
		QStringList arguments = parsedArgs.value("delete-resource").toStringList();
		exePath = (char*) malloc(strlen(arguments.at(0).toStdString().c_str()) * sizeof(char));
		strcpy(exePath, arguments.at(0).toStdString().c_str());
		hExe = loadLibraryEx(TEXT(exePath), NULL, LOAD_LIBRARY_AS_IMAGE_RESOURCE);

		// List all resources
		EnumResourceTypes(hExe, (ENUMRESTYPEPROC)EnumTypesFunc, 0);
		FreeLibrary(hExe);

		bool resultat = removeResource(arguments.at(0), arguments.at(1), arguments.at(2));
		if(!resultat)
			{
			return EXIT_FAILURE;
			}
		}

	else if(parsedArgs.contains("add-resource-bitmap"))
		{
		QStringList arguments = parsedArgs.value("add-resource-bitmap").toStringList();

		bool result = addResourceBITMAP(arguments.at(0), arguments.at(1), arguments.at(2));
		if(!result)
			{
			QTextStream(stdout, QIODevice::WriteOnly) << "Resource bitmap couldn't be added.\n";
			return EXIT_FAILURE;
			}
		QTextStream(stdout, QIODevice::WriteOnly) << "Resource bitmap added.\n";
		return EXIT_SUCCESS;
		}

	else if(parsedArgs.contains("update-resource-ico"))
		{
		QStringList arguments = parsedArgs.value("update-resource-ico").toStringList();

		bool result = updateResourceICO(arguments.at(0), arguments.at(1), arguments.at(2));
		if(!result)
			{
			QTextStream(stdout, QIODevice::WriteOnly) << "Resource ico couldn't be updated.\n";
			return EXIT_FAILURE;
			}
		QTextStream(stdout, QIODevice::WriteOnly) << "Resource ico updated.\n";
		return EXIT_SUCCESS;
		}

  return EXIT_SUCCESS;
}
示例#25
0
void CC3Resource::remove()
{
    removeResource( this );
}