Пример #1
0
ResearchView::ResearchView(ViewManager* gvm) : View(gvm), book(new BookView(4))
{
  buttons.resize(BUTTON_COUNT);
  
  buttons[PREV_PAGE] = Button::buildSimple("Prev page", 15, 9, LSI(SCROLL, 7));
  buttons[NEXT_PAGE] = Button::buildSimple("Next page", 289, 9, LSI(SCROLL, 8));
  
  
  buttons[PREV_PAGE]->setAction([this]() {
    book->prevPage();
    buttons[NEXT_PAGE]->show();
    buttons[PREV_PAGE]->showIf(book->hasPrevPage());
  });
  
  buttons[NEXT_PAGE]->setAction([this]() {
    book->nextPage();
    buttons[PREV_PAGE]->show();
    buttons[NEXT_PAGE]->showIf(book->hasNextPage());
  });
  
  u16 sx = 22, sy = 24;
  u16 dy = 37, dx = 148;
  u16 ww = 123, hh = 36;
  
  for (u16 i = 0; i < 8; ++i)
    addArea((new Clickable(sx + (i/4)*dx, sy + (i%4)*dy, ww, hh))->setAction([this,i](){ indexClicked(i); }));
  
  auto backToMap = [gvm](){ gvm->switchView(VIEW_MAIN); };
  addArea((new Clickable(0,10, 5, 189))->setAction(backToMap));
  addArea((new Clickable(315,10, 5, 189))->setAction(backToMap));
  addArea((new Clickable(6,180, 308, 19))->setAction(backToMap));
}
Пример #2
0
void CvMap::calculateAreas()
{
	PROFILE_FUNC();
	CvPlot* pLoopPlot;
	CvArea* pArea;
	int iArea;
	int iI;

	for (iI = 0; iI < numPlotsINLINE(); iI++)
	{
		pLoopPlot = plotByIndexINLINE(iI);
		gDLL->callUpdater();
		FAssertMsg(pLoopPlot != NULL, "LoopPlot is not assigned a valid value");

		if (pLoopPlot->getArea() == FFreeList::INVALID_INDEX)
		{
			pArea = addArea();
			pArea->init(pArea->getID(), pLoopPlot->isWater());

			iArea = pArea->getID();

			pLoopPlot->setArea(iArea);

			gDLL->getFAStarIFace()->GeneratePath(&GC.getAreaFinder(), pLoopPlot->getX_INLINE(), pLoopPlot->getY_INLINE(), -1, -1, pLoopPlot->isWater(), iArea);
		}
	}
}
Пример #3
0
void Grid::rebuildGrid()
{
    cells.clear();
    globalCell = SharedCell(new Cell());
    calculateTranslationMatrix();
    for (boost::unordered_map<int, Item::SharedArea>::iterator a = core->getData()->areas.begin(); a != core->getData()->areas.end(); ++a)
    {
        addArea(a->second);
    }
    for (boost::unordered_map<int, Item::SharedCheckpoint>::iterator c = core->getData()->checkpoints.begin(); c != core->getData()->checkpoints.end(); ++c)
    {
        addCheckpoint(c->second);
    }
    for (boost::unordered_map<int, Item::SharedMapIcon>::iterator m = core->getData()->mapIcons.begin(); m != core->getData()->mapIcons.end(); ++m)
    {
        addMapIcon(m->second);
    }
    for (boost::unordered_map<int, Item::SharedObject>::iterator o = core->getData()->objects.begin(); o != core->getData()->objects.end(); ++o)
    {
        addObject(o->second);
    }
    for (boost::unordered_map<int, Item::SharedPickup>::iterator p = core->getData()->pickups.begin(); p != core->getData()->pickups.end(); ++p)
    {
        addPickup(p->second);
    }
    for (boost::unordered_map<int, Item::SharedRaceCheckpoint>::iterator r = core->getData()->raceCheckpoints.begin(); r != core->getData()->raceCheckpoints.end(); ++r)
    {
        addRaceCheckpoint(r->second);
    }
    for (boost::unordered_map<int, Item::SharedTextLabel>::iterator t = core->getData()->textLabels.begin(); t != core->getData()->textLabels.end(); ++t)
    {
        addTextLabel(t->second);
    }
}
Пример #4
0
void World::parseArea(YAML::Node fileNode, std::ostream& lerr) {
    String name = readYAMLStr(fileNode, "Name", "nil", "Name expected.", lerr);
    int width = fileNode["Dim"][0].as<int>();
    Area* newArea = new Area(width, name);
    addArea(newArea);
    areaNameMap[name] = newArea;
}
Пример #5
0
void GUI::insertComponent (Component *component)
{
    Component *destination;
    destination = contains (component->getPosition());
    destination->addChild (component);
    component->setParent (destination);
    addArea (destination, component->getAreaUsage());
}
Пример #6
0
void subtractArea (Component *node, int toSubtr)
{
    if (node)
    {
        node->setAreaUsage (node->getAreaUsage() - toSubtr);
        addArea (node->getParent(), toSubtr);
    }
}
Пример #7
0
void addArea (Component *node, int toAdd)
{
    if (node)
    {
        node->setAreaUsage (node->getAreaUsage() + toAdd);
        addArea (node->getParent(), toAdd);
    }
}
Пример #8
0
        void CritterDialogReview::addAnswer(const std::string &value)
        {
            auto dudeName = new UI::TextArea(0, 0);
            dudeName->setWidth(340);
            dudeName->setWordWrap(true);
            dudeName->setFont("font1.aaf", {0xa0,0xa0, 0xa0, 0xff});
            dudeName->setText(Game::getInstance()->player()->name()+":");

            auto answer = new UI::TextArea(0, 0);
            answer->setWidth(316);
            answer->setOffset(26,0);
            answer->setWordWrap(true);
            answer->setFont("font1.aaf", {0x74,0x74, 0x74, 0xff});
            answer->setText(value);

            auto list = dynamic_cast<UI::TextAreaList*>(getUI("list"));
            list->addArea(std::unique_ptr<UI::TextArea>(dudeName));
            list->addArea(std::unique_ptr<UI::TextArea>(answer));
        }
Пример #9
0
        void CritterDialogReview::addQuestion(const std::string &value)
        {
            auto crName = new UI::TextArea(0, 0);
            crName->setWidth(340);
            crName->setWordWrap(true);
            crName->setFont("font1.aaf", {0x3f,0xf8, 0x00, 0xff});
            crName->setText(_critterName+":");

            auto question = new UI::TextArea(0, 0);
            question->setWidth(316);
            question->setOffset(26,0);
            question->setWordWrap(true);
            question->setFont("font1.aaf", {0x00,0xa4, 0x00, 0xff});
            question->setText(value);

            auto list = dynamic_cast<UI::TextAreaList*>(getUI("list"));
            list->addArea(std::unique_ptr<UI::TextArea>(crName));
            list->addArea(std::unique_ptr<UI::TextArea>(question));

        }
Пример #10
0
// this func is called by the xml map importer
// NOTE: we no longer accept duplicate IDs or duplicate area names
//       duplicate definitions are ignored
bool TRoomDB::addArea( int id, QString name )
{
    if( areaNamesMap.values().contains(name) ) return false;
    if( areaNamesMap.keys().contains(id) ) return false;
    if( addArea( id ) )
    {
        areaNamesMap[id] = name;
        return true;
    }
    return false;

}
Пример #11
0
SpellBookView::SpellBookView(ViewManager* gvm) : View(gvm), book(new BookView(6)), combatMode(false)
{
  buttons.resize(BUTTON_COUNT);
  
  buttons[PREV_PAGE] = Button::buildSimple("Prev page", 29, 15, LSI(SPELLS, 1));
  buttons[NEXT_PAGE] = Button::buildSimple("Next page", 274, 15, LSI(SPELLS, 2));
  
  
  buttons[PREV_PAGE]->setAction([this]() {
    book->prevPage();
    buttons[NEXT_PAGE]->show();
    buttons[PREV_PAGE]->showIf(book->hasPrevPage());
  });
  
  buttons[NEXT_PAGE]->setAction([this]() {
    book->nextPage();
    buttons[PREV_PAGE]->show();
    buttons[NEXT_PAGE]->showIf(book->hasNextPage());
  });
  
  addArea((new Clickable(175,165,18,29))->setAction([gvm](){ gvm->closeOverview(); }));

  ClickableGrid* spellGrid = new ClickableGrid(topLeftX[0]-2, topLeftY[0]-2, 125, 22, 6, 2, 7, 0);
  spellGrid->setCellAction([this](coord_t x, coord_t y, MouseButton bt) {
    if (bt == MouseButton::BUTTON_LEFT)
      startCast(book->getEntry(x*6 + y));
    else
      return true;
    return true;
  });
  addArea(spellGrid);
  
  /*
  for (u16 k = 0; k < 2; ++k)
    for (u16 i = 0; i < 6;++i)
      addArea((new Clickable(topLeftX[k]-2,topLeftY[k]+22*i-2,125,22))->setAction([k,i,this](coord_t, coord_t, MouseButton bt){
        startCast(book->getEntry(k*6 + i));
      }));*/
}
Пример #12
0
int TRoomDB::addArea( QString name )
{
    // area name already exists
    if( areaNamesMap.values().contains( name ) ) return -1;

    int areaID = createNewAreaID();
    if( addArea( areaID ) )
    {
        areaNamesMap[areaID] = name;
        return areaID;
    }
    else
        return -1; //fail
}
Пример #13
0
void Grid::removeArea(const Item::SharedArea &area, bool reassign)
{
    bool found = false;
    if (area->cell)
    {
        boost::unordered_map<CellID, SharedCell>::iterator c = cells.find(area->cell->cellID);
        if (c != cells.end())
        {
            boost::unordered_map<int, Item::SharedArea>::iterator a = c->second->areas.find(area->areaID);
            if (a != c->second->areas.end())
            {
                c->second->areas.quick_erase(a);
                eraseCellIfEmpty(c->second);
                found = true;
            }
        }
    }
    else
    {
        boost::unordered_map<int, Item::SharedArea>::iterator a = globalCell->areas.find(area->areaID);
        if (a != globalCell->areas.end())
        {
            globalCell->areas.quick_erase(a);
            found = true;
        }
    }
    if (found)
    {
        if (reassign)
        {
            addArea(area);
        }
        else
        {
            if (area->attach)
            {
                core->getStreamer()->attachedAreas.erase(area);
            }
        }
    }
}
Пример #14
0
int processInventoryRdr(SaHpiSessionIdT sessionId,
			SaHpiResourceIdT resourceId,
			SaHpiRdrT * rdr, SaHpiInventoryRecT * inventoryRec)
{
	SaErrorT status;
	int retval;
	int response;
	SaHpiEntryIdT AreaId, NextAreaId;
	SaHpiIdrAreaHeaderT Header;
	SaHpiIdrIdT idrId = inventoryRec->IdrId;

	status = saHpiIdrAreaHeaderGet(sessionId,
				       resourceId,
				       idrId,
				       SAHPI_IDR_AREATYPE_UNSPECIFIED,
				       SAHPI_FIRST_ENTRY, &NextAreaId, &Header);

	if (status == SA_OK) {

		retval = runTest(sessionId, resourceId, idrId, Header.AreaId);

	} else if (status == SA_ERR_HPI_NOT_PRESENT) {

		response = addArea(sessionId, resourceId, idrId, &AreaId);
		if (response != SAF_TEST_PASS) {
			retval = response;
		} else {
			retval = runTest(sessionId, resourceId, idrId, AreaId);
			deleteArea(sessionId, resourceId, idrId, AreaId);
		}

	} else {

		retval = SAF_TEST_UNRESOLVED;
		e_print(saHpiIdrAreaHeaderGet, SA_OK, status);
	}

	return retval;
}
Пример #15
0
CityView::CityView(ViewManager* gvm) : View(gvm)
{
  cityEnchantPage = 0;
  
  buttons.resize(BUTTON_COUNT);
  
  buttons[BUY] = Button::buildTristate("Buy", 214, 188, LSI(BACKGRND, 7), LSI(BACKGRND, 14));
  buttons[CHANGE] = Button::buildBistate("Change", 247, 188, LSI(BACKGRND, 8));
  buttons[OK] = Button::buildBistate("Ok", 286, 188, LSI(BACKGRND, 9));
  
  /* TODO: add behavior */
  buttons[PREV_CITY_ENCHANT] = Button::buildBistate("Prev City Enchant", 201, 50, LSI(BACKGRND,15))->setAction([this](){
    const size_t pageCount = Math::roundWithMod(city->getSpells().size(), CITY_ENCHANT_PER_PAGE);
    cityEnchantPage = Math::negativeWrap(cityEnchantPage, pageCount);
  });
  
  buttons[NEXT_CITY_ENCHANT] = Button::buildBistate("Prev City Enchant", 201, 85, LSI(BACKGRND,16))->setAction([this](){
    const size_t pageCount = Math::roundWithMod(city->getSpells().size(), CITY_ENCHANT_PER_PAGE);
    cityEnchantPage = (cityEnchantPage + 1) % pageCount;
  });

  
  buttons[BUY]->deactivate();
  
  buttons[BUY]->setAction([this](){
    player->send(new msgs::Confirm(fmt::sprintf("Do you wish to spend %d Gold by purchasing a %s?", city->getProductable()->productionCost(), city->getProductable()->productionName()), [&]() {
      g->cityMechanics.buyProduction(city);
    }));
  });
  
  buttons[OK]->setAction([gvm](){ gvm->switchView(VIEW_MAIN); });
  buttons[CHANGE]->setAction([gvm,this]{ gvm->productionView()->setCity(city); gvm->switchOverview(VIEW_PRODUCTION); });
  
  addArea(new ClickableGrid(139, 50, 60, 7, 6, 1))->setCellAction([this](coord_t x, coord_t y) { 
    clickOnCitySpell(y);
  });
}
Пример #16
0
/*
	Goes recursively through the neighbours of the node.

	Alters only transparent nodes.

	If the lighting of the neighbour is lower than the lighting of
	the node was (before changing it to 0 at the step before), the
	lighting of the neighbour is set to 0 and then the same stuff
	repeats for the neighbour.

	The ending nodes of the routine are stored in light_sources.
	This is useful when a light is removed. In such case, this
	routine can be called for the light node and then again for
	light_sources to re-light the area without the removed light.

	values of from_nodes are lighting values.
*/
void VoxelManipulator::unspreadLight(enum LightBank bank,
		core::map<v3s16, u8> & from_nodes,
		core::map<v3s16, bool> & light_sources)
{
	v3s16 dirs[6] = {
		v3s16(0,0,1), // back
		v3s16(0,1,0), // top
		v3s16(1,0,0), // right
		v3s16(0,0,-1), // front
		v3s16(0,-1,0), // bottom
		v3s16(-1,0,0), // left
	};

	if(from_nodes.size() == 0)
		return;

	core::map<v3s16, u8> unlighted_nodes;
	core::map<v3s16, u8>::Iterator j;
	j = from_nodes.getIterator();

	for(; j.atEnd() == false; j++)
	{
		v3s16 pos = j.getNode()->getKey();

		addArea(VoxelArea(pos - v3s16(1,1,1), pos + v3s16(1,1,1)));

		//MapNode &n = m_data[m_area.index(pos)];

		u8 oldlight = j.getNode()->getValue();

		// Loop through 6 neighbors
		for(u16 i=0; i<6; i++)
		{
			// Get the position of the neighbor node
			v3s16 n2pos = pos + dirs[i];

			u32 n2i = m_area.index(n2pos);

			if(m_flags[n2i] & VOXELFLAG_NO_DATA)
				continue;

			MapNode &n2 = m_data[n2i];

			/*
				If the neighbor is dimmer than what was specified
				as oldlight (the light of the previous node)
			*/
			if(n2.getLight(bank, nodemgr) < oldlight)
			{
				/*
					And the neighbor is transparent and it has some light
				*/
				if(nodemgr->get(n2).light_propagates && n2.getLight(bank, nodemgr) != 0)
				{
					/*
						Set light to 0 and add to queue
					*/

					u8 current_light = n2.getLight(bank, nodemgr);
					n2.setLight(bank, 0);

					unlighted_nodes.insert(n2pos, current_light);

					/*
						Remove from light_sources if it is there
						NOTE: This doesn't happen nearly at all
					*/
					/*if(light_sources.find(n2pos))
					{
						std::cout<<"Removed from light_sources"<<std::endl;
						light_sources.remove(n2pos);
					}*/
				}
			}
			else{
				light_sources.insert(n2pos, true);
			}
		}
	}

	/*dstream<<"unspreadLight(): Changed block "
			<<blockchangecount<<" times"
			<<" for "<<from_nodes.size()<<" nodes"
			<<std::endl;*/

	if(unlighted_nodes.size() > 0)
		unspreadLight(bank, unlighted_nodes, light_sources);
}
Пример #17
0
/*
	Lights neighbors of from_nodes, collects all them and then
	goes on recursively.
*/
void VoxelManipulator::spreadLight(enum LightBank bank,
		std::set<v3s16> & from_nodes, INodeDefManager *nodemgr)
{
	const v3s16 dirs[6] = {
		v3s16(0,0,1), // back
		v3s16(0,1,0), // top
		v3s16(1,0,0), // right
		v3s16(0,0,-1), // front
		v3s16(0,-1,0), // bottom
		v3s16(-1,0,0), // left
	};

	if(from_nodes.empty())
		return;

	std::set<v3s16> lighted_nodes;

	for(std::set<v3s16>::iterator j = from_nodes.begin();
		j != from_nodes.end(); ++j)
	{
		v3s16 pos = *j;

		VoxelArea voxel_area(pos - v3s16(1,1,1), pos + v3s16(1,1,1));
		addArea(voxel_area);

		u32 i = m_area.index(pos);

		if(m_flags[i] & VOXELFLAG_NO_DATA)
			continue;

		MapNode &n = m_data[i];

		u8 oldlight = n.getLight(bank, nodemgr);
		u8 newlight = diminish_light(oldlight);

		// Loop through 6 neighbors
		for(u16 i=0; i<6; i++)
		{
			// Get the position of the neighbor node
			v3s16 n2pos = pos + dirs[i];

			try
			{
				u32 n2i = m_area.index(n2pos);

				if(m_flags[n2i] & VOXELFLAG_NO_DATA)
					continue;

				MapNode &n2 = m_data[n2i];

				u8 light2 = n2.getLight(bank, nodemgr);

				/*
					If the neighbor is brighter than the current node,
					add to list (it will light up this node on its turn)
				*/
				if(light2 > undiminish_light(oldlight))
				{
					lighted_nodes.insert(n2pos);
				}
				/*
					If the neighbor is dimmer than how much light this node
					would spread on it, add to list
				*/
				if(light2 < newlight)
				{
					if(nodemgr->get(n2).light_propagates)
					{
						n2.setLight(bank, newlight, nodemgr);
						lighted_nodes.insert(n2pos);
					}
				}
			}
			catch(InvalidPositionException &e)
			{
				continue;
			}
		}
	}

	/*dstream<<"spreadLight(): Changed block "
			<<blockchangecount<<" times"
			<<" for "<<from_nodes.size()<<" nodes"
			<<std::endl;*/

	if(!lighted_nodes.empty())
		spreadLight(bank, lighted_nodes, nodemgr);
}
Пример #18
0
void VoxelManipulator::spreadLight(enum LightBank bank, v3s16 p,
		INodeDefManager *nodemgr)
{
	const v3s16 dirs[6] = {
		v3s16(0,0,1), // back
		v3s16(0,1,0), // top
		v3s16(1,0,0), // right
		v3s16(0,0,-1), // front
		v3s16(0,-1,0), // bottom
		v3s16(-1,0,0), // left
	};

	VoxelArea voxel_area(p - v3s16(1,1,1), p + v3s16(1,1,1));
	addArea(voxel_area);

	u32 i = m_area.index(p);

	if(m_flags[i] & VOXELFLAG_NO_DATA)
		return;

	MapNode &n = m_data[i];

	u8 oldlight = n.getLight(bank, nodemgr);
	u8 newlight = diminish_light(oldlight);

	// Loop through 6 neighbors
	for(u16 i=0; i<6; i++)
	{
		// Get the position of the neighbor node
		v3s16 n2pos = p + dirs[i];

		u32 n2i = m_area.index(n2pos);

		if(m_flags[n2i] & VOXELFLAG_NO_DATA)
			continue;

		MapNode &n2 = m_data[n2i];

		u8 light2 = n2.getLight(bank, nodemgr);

		/*
			If the neighbor is brighter than the current node,
			add to list (it will light up this node on its turn)
		*/
		if(light2 > undiminish_light(oldlight))
		{
			spreadLight(bank, n2pos, nodemgr);
		}
		/*
			If the neighbor is dimmer than how much light this node
			would spread on it, add to list
		*/
		if(light2 < newlight)
		{
			if(nodemgr->get(n2).light_propagates)
			{
				n2.setLight(bank, newlight, nodemgr);
				spreadLight(bank, n2pos, nodemgr);
			}
		}
	}
}
Пример #19
0
void VoxelManipulator::unspreadLight(enum LightBank bank, v3s16 p, u8 oldlight,
		std::set<v3s16> & light_sources, INodeDefManager *nodemgr)
{
	v3s16 dirs[6] = {
		v3s16(0,0,1), // back
		v3s16(0,1,0), // top
		v3s16(1,0,0), // right
		v3s16(0,0,-1), // front
		v3s16(0,-1,0), // bottom
		v3s16(-1,0,0), // left
	};

	VoxelArea voxel_area(p - v3s16(1,1,1), p + v3s16(1,1,1));
	addArea(voxel_area);

	// Loop through 6 neighbors
	for(u16 i=0; i<6; i++)
	{
		// Get the position of the neighbor node
		v3s16 n2pos = p + dirs[i];

		u32 n2i = m_area.index(n2pos);

		if(m_flags[n2i] & VOXELFLAG_NO_DATA)
			continue;

		MapNode &n2 = m_data[n2i];

		/*
			If the neighbor is dimmer than what was specified
			as oldlight (the light of the previous node)
		*/
		u8 light2 = n2.getLight(bank, nodemgr);
		if(light2 < oldlight)
		{
			/*
				And the neighbor is transparent and it has some light
			*/
			if(nodemgr->get(n2).light_propagates && light2 != 0)
			{
				/*
					Set light to 0 and add to queue
				*/

				n2.setLight(bank, 0, nodemgr);

				unspreadLight(bank, n2pos, light2, light_sources, nodemgr);

				/*
					Remove from light_sources if it is there
					NOTE: This doesn't happen nearly at all
				*/
				/*if(light_sources.find(n2pos))
				{
					std::cout<<"Removed from light_sources"<<std::endl;
					light_sources.remove(n2pos);
				}*/
			}
		}
		else{
			light_sources.insert(n2pos);
		}
	}
}
Пример #20
0
void WCartesianChart::addDataPointArea(const WDataSeries& series,
				       const WModelIndex& xIndex,
				       WAbstractArea *area)
{
  addArea(area);
}