Ejemplo n.º 1
0
TEST(CoreTests, VolumeOutOfBounds) {
    Volume<char> * image = new Volume<char>(10,10, 10);

    // Getters
    EXPECT_THROW(image->get(-1), OutOfBoundsException);
    EXPECT_THROW(image->get(10*10*10), OutOfBoundsException);
    EXPECT_THROW(image->get(-4, 4, 2), OutOfBoundsException);
    EXPECT_THROW(image->get(-1,-10, 0), OutOfBoundsException);
    EXPECT_THROW(image->get(10, 0, 0), OutOfBoundsException);
    EXPECT_THROW(image->get(2, 1, -1), OutOfBoundsException);
    EXPECT_THROW(image->get(int3(-1, 4, 0)), OutOfBoundsException);
    EXPECT_THROW(image->get(int3(0, 200, 2)), OutOfBoundsException);
    EXPECT_THROW(image->get(Region(11, 11, 1)), OutOfBoundsException);

    // Setters
    EXPECT_THROW(image->set(-1,1), OutOfBoundsException);
    EXPECT_THROW(image->set(10*10*10,1), OutOfBoundsException);
    EXPECT_THROW(image->set(-4, 4, 2,1), OutOfBoundsException);
    EXPECT_THROW(image->set(-1,-10, 0,1), OutOfBoundsException);
    EXPECT_THROW(image->set(10, 0, 0,1), OutOfBoundsException);
    EXPECT_THROW(image->set(2, 1, -1,1), OutOfBoundsException);
    EXPECT_THROW(image->set(int3(-1, 4, 0),1), OutOfBoundsException);
    EXPECT_THROW(image->set(int3(0, 200, 2),1), OutOfBoundsException);
    EXPECT_THROW(image->set(Region(11, 11, 1),1), OutOfBoundsException);
}
Ejemplo n.º 2
0
	void ComputeMipsSize(
		int32_t width,
		int32_t heigth,
		int32_t depth,
		std::vector<int3> & outMipsSize)
	{
		outMipsSize.clear();

		int32_t x = std::max<int32_t>(1, width);
		int32_t y = std::max<int32_t>(1, heigth);
		int32_t z = std::max<int32_t>(1, depth);

		// Mip 0
		outMipsSize.push_back(int3(x, y, z));

		// Loop until x=y=z=1
		while ((x != 1) || (y != 1) || (z != 1))
		{
			x = std::max<int32_t>(1, x >> 1);
			y = std::max<int32_t>(1, y >> 1);
			z = std::max<int32_t>(1, z >> 1);

			outMipsSize.push_back(int3(x, y, z));
		}
	}
Ejemplo n.º 3
0
	void View::drawGrid(Renderer2D &out) const {
		if(!m_is_visible)
			return;

		const int2 tile_map_size = m_tile_map.dimensions();

		int2 p[4] = {
			screenToWorld(m_view_pos + int2(0, 0)),
			screenToWorld(m_view_pos + int2(0, m_view_size.y)),
			screenToWorld(m_view_pos + int2(m_view_size.x, m_view_size.y)),
			screenToWorld(m_view_pos + int2(m_view_size.x, 0)) };
		int2 offset = screenToWorld(worldToScreen(int3(0, m_height, 0)));
		for(int n = 0; n < 4; n++)
			p[n] -= offset;

		int2 tmin = min(min(p[0], p[1]), min(p[2], p[3]));
		int2 tmax = max(max(p[0], p[1]), max(p[2], p[3]));
		IRect box(max(tmin, int2(0, 0)), min(tmax, tile_map_size));

		Color color(255, 255, 255, 64);
		for(int x = box.min.x - box.min.x % m_cell_size; x <= box.max.x; x += m_cell_size)
			drawLine(out, int3(x, m_height, box.min.y), int3(x, m_height, box.max.y), color);
		for(int y = box.min.y - box.min.y % m_cell_size; y <= box.max.y; y += m_cell_size)
			drawLine(out, int3(box.min.x, m_height, y), int3(box.max.x, m_height, y), color);
	}
Ejemplo n.º 4
0
void CPrivilagedInfoCallback::getAllTiles (std::unordered_set<int3, ShashInt3> &tiles, boost::optional<PlayerColor> Player/*=uninit*/, int level, int surface ) const
{
	if(!!Player && *Player >= PlayerColor::PLAYER_LIMIT)
	{
        logGlobal->errorStream() << "Illegal call to getAllTiles !";
		return;
	}
	bool water = surface == 0 || surface == 2,
		land = surface == 0 || surface == 1;

	std::vector<int> floors;
	if(level == -1)
	{
		for(int b = 0; b < (gs->map->twoLevel ? 2 : 1); ++b)
		{
			floors.push_back(b);
		}
	}
	else
		floors.push_back(level);

	for (auto zd : floors)
	{

		for (int xd = 0; xd < gs->map->width; xd++)
		{
			for (int yd = 0; yd < gs->map->height; yd++)
			{
				if ((getTile (int3 (xd,yd,zd))->terType == ETerrainType::WATER && water)
					|| (getTile (int3 (xd,yd,zd))->terType != ETerrainType::WATER && land))
					tiles.insert(int3(xd,yd,zd));
			}
		}
	}
}
Ejemplo n.º 5
0
void fn00401090(Eq_4 * fs)
{
	fs->dw0000 = fp - 0x00000004;
	int3();
	int3();
	return;
}
Ejemplo n.º 6
0
void CPrivilagedInfoCallback::getAllTiles (boost::unordered_set<int3, ShashInt3> &tiles, int Player/*=-1*/, int level, int surface ) const
{
	if(Player >= GameConstants::PLAYER_LIMIT)
	{
		tlog1 << "Illegal call to getAllTiles !\n";
		return;
	}
	bool water = surface == 0 || surface == 2,
		land = surface == 0 || surface == 1;

	std::vector<int> floors;
	if(level == -1)
	{
		for(int b = 0; b < (gs->map->twoLevel ? 2 : 1); ++b)
		{
			floors.push_back(b);
		}
	}
	else
		floors.push_back(level);

	for (std::vector<int>::const_iterator i = floors.begin(); i!= floors.end(); i++)
	{
		register int zd = *i;
		for (int xd = 0; xd < gs->map->width; xd++)
		{
			for (int yd = 0; yd < gs->map->height; yd++)
			{
				if ((getTile (int3 (xd,yd,zd))->terType == 8 && water)
					|| (getTile (int3 (xd,yd,zd))->terType != 8 && land))
					tiles.insert(int3(xd,yd,zd));
			}
		}
	}
}
Ejemplo n.º 7
0
void CPrivilagedInfoCallback::getTilesInRange( boost::unordered_set<int3, ShashInt3> &tiles, int3 pos, int radious, int player/*=-1*/, int mode/*=0*/ ) const
{
	if(player >= GameConstants::PLAYER_LIMIT)
	{
		tlog1 << "Illegal call to getTilesInRange!\n";
		return;
	}
	if (radious == -1) //reveal entire map
		getAllTiles (tiles, player, -1, 0);
	else
	{
		const TeamState * team = gs->getPlayerTeam(player);
		for (int xd = std::max<int>(pos.x - radious , 0); xd <= std::min<int>(pos.x + radious, gs->map->width - 1); xd++)
		{
			for (int yd = std::max<int>(pos.y - radious, 0); yd <= std::min<int>(pos.y + radious, gs->map->height - 1); yd++)
			{
				double distance = pos.dist2d(int3(xd,yd,pos.z)) - 0.5;
				if(distance <= radious)
				{
					if(player < 0
						|| (mode == 1  && team->fogOfWarMap[xd][yd][pos.z]==0)
						|| (mode == -1 && team->fogOfWarMap[xd][yd][pos.z]==1)
					)
						tiles.insert(int3(xd,yd,pos.z));
				}
			}
		}
	}
}
Ejemplo n.º 8
0
bool BOTechTreeNode::Initialize(float2 p_pos, int2 p_size, std::string p_tooltip)
{
    m_isActive = false;
    m_isAdjacentActive = false;
    m_hoveringOver = false;
    m_layer = 0;
    m_price = 0;
    m_effect = 0;

    m_icon = BOTextureManager::GetTexture(TEXTTINACTIVE);
    m_active = BOTextureManager::GetTexture(TEXTTCHOSEN);
    m_inactive = BOTextureManager::GetTexture(TEXTTINACTIVE);
    m_adjacentActive = BOTextureManager::GetTexture(TEXTTADJACENTACTIVE);
    m_highlighted = BOTextureManager::GetTexture(TEXTTHIGHLIGHTED);

    // Tooltip
    m_tooltipHeading.Initialize(float2(0, 0), "Heading", int3(255, 255, 255), 40, 0);
    m_tooltipText.Initialize(float2(0,0), " ", int3(255, 255, 255), 30, 0);
    int2 windowBounds = BOGraphicInterface::GetWindowSize();
    m_tooltipFrame.Initialize(float2(0,0), int2(310,210), BOTextureManager::GetTexture(TEXTTTOLTIPFRAME));
    int2 framesSize = m_tooltipFrame.GetSize();
    m_tooltipFrame.SetPosition(float2(windowBounds.x - 50 - framesSize.x*0.5f, framesSize.y*0.5f +50));

    //priceText
    m_priceText.Initialize(float2(0, 0), " ", int3(255, 255, 255), 25, 0);

    return BOObject::Initialize(p_pos, p_size, m_inactive);
}
Ejemplo n.º 9
0
void NaviHeightmap::update(const vector<IBox> &walkable, const vector<IBox> &blockers) {
	m_level_count = 0;
	m_data.clear();

	PodArray<IBox> bboxes(walkable.size());
	for(int n = 0; n < bboxes.size(); n++) {
		IBox bbox = walkable[n];
		bboxes[n] = { vmax(bbox.min(), int3(0, 0, 0)), vmin(bbox.max(), int3(m_size.x, 255, m_size.y))};
	}

	std::sort(bboxes.data(), bboxes.end(), [](const IBox &a, const IBox &b)
		{ return a.y() == b.y()? a.x() == b.x()?
			a.z() < b.z() : a.x() < b.x() : a.y() < b.y(); } );
		
	for(int n = 0; n < bboxes.size(); n++) {
		const IBox &bbox = bboxes[n];
		int min_y = bbox.y(), max_y = bbox.ey();

		for(int z = 0; z < bbox.depth(); z++)
			for(int x = 0; x < bbox.width(); x++) {
				int level = 0;
				int px = x + bbox.x();
				int pz = z + bbox.z();

				while(level < m_level_count) {
					int value = m_data[index(px, pz, level)];
					if(value == invalid_value || value >= min_y - 4)
						break;
					level++;
				}
				if(level == m_level_count) {
					if(level == max_levels)
						continue;
					addLevel();
				}

				m_data[index(px, pz, level)] = max_y;
			}
	}

	for(int n = 0; n < (int)blockers.size(); n++) {
		IBox blocker(
				vmax(blockers[n].min(), int3(0, 0, 0)),
				vmin(blockers[n].max(), int3(m_size.x, 255, m_size.y)));
		u8 min_y = max(0, blocker.y() - 4), max_y = blocker.ey();

		for(int z = 0; z < blocker.depth(); z++)
			for(int x = 0; x < blocker.width(); x++) {
				int level = 0;
				int px = x + blocker.x();
				int pz = z + blocker.z();

				while(level < m_level_count) {
					u8 &value = m_data[index(px, pz, level++)];
					if(value >= min_y && value <= max_y)
						value = invalid_value;
				}
			}
	}
}
Ejemplo n.º 10
0
int3 __CGsampler1DARRAY_state::size(int1 lod)
{
    lod += trueBaseLevel;

    if (lod <= effectiveMaxLevel) {
        return int3(image[lod].borderlessSize.xy, 0);
    } else {
        return int3(0);
    }
}
Ejemplo n.º 11
0
int3 CMap::guardingCreaturePosition (int3 pos) const
{

    const int3 originalPos = pos;
    // Give monster at position priority.
    if (!isInTheMap(pos))
        return int3(-1, -1, -1);
    const TerrainTile &posTile = getTile(pos);
    if (posTile.visitable)
    {
        for (CGObjectInstance* obj : posTile.visitableObjects)
        {
            if(obj->blockVisit)
            {
                if (obj->ID == Obj::MONSTER) // Monster
                    return pos;
                else
                    return int3(-1, -1, -1); //blockvis objects are not guarded by neighbouring creatures
            }
        }
    }

    // See if there are any monsters adjacent.
    bool water = posTile.isWater();

    pos -= int3(1, 1, 0); // Start with top left.
    for (int dx = 0; dx < 3; dx++)
    {
        for (int dy = 0; dy < 3; dy++)
        {
            if (isInTheMap(pos))
            {
                const auto & tile = getTile(pos);
                if (tile.visitable && (tile.isWater() == water))
                {
                    for (CGObjectInstance* obj : tile.visitableObjects)
                    {
                        if (obj->ID == Obj::MONSTER  &&  checkForVisitableDir(pos, &posTile, originalPos)) // Monster being able to attack investigated tile
                        {
                            return pos;
                        }
                    }
                }
            }

            pos.y++;
        }
        pos.y -= 3;
        pos.x++;
    }

    return int3(-1, -1, -1);
}
Ejemplo n.º 12
0
void CButton::showAll(SDL_Surface * to)
{
	CIntObject::showAll(to);
	
	#ifdef VCMI_SDL1
	if (borderColor && borderColor->unused == 0)
		CSDL_Ext::drawBorder(to, pos.x-1, pos.y-1, pos.w+2, pos.h+2, int3(borderColor->r, borderColor->g, borderColor->b));
	#else
	if (borderColor && borderColor->a == 0)
		CSDL_Ext::drawBorder(to, pos.x-1, pos.y-1, pos.w+2, pos.h+2, int3(borderColor->r, borderColor->g, borderColor->b));
	#endif // 0
}
Ejemplo n.º 13
0
bool CMap::isCoastalTile(const int3 & pos) const
{
	//todo: refactoring: extract neighbor tile iterator and use it in GameState
	static const int3 dirs[] = { int3(0,1,0),int3(0,-1,0),int3(-1,0,0),int3(+1,0,0),
					int3(1,1,0),int3(-1,1,0),int3(1,-1,0),int3(-1,-1,0) };

	if(!isInTheMap(pos))
	{
		logGlobal->errorStream() << "Coastal check outside of map :"<<pos;
		return false;
	}

	if(isWaterTile(pos))
		return false;

	for (auto & dir : dirs)
	{
		const int3 hlp = pos + dir;

		if(!isInTheMap(hlp))
			continue;
		const TerrainTile &hlpt = getTile(hlp);
		if(hlpt.isWater())
			return true;
	}

	return false;
}
Ejemplo n.º 14
0
void CAdventureMapButton::showAll(SDL_Surface * to)
{
	CIntObject::showAll(to);

	if (borderEnabled && borderColor.unused == 0)
		CSDL_Ext::drawBorder(to, pos.x-1, pos.y-1, pos.w+2, pos.h+2, int3(borderColor.r, borderColor.g, borderColor.b));
}
Ejemplo n.º 15
0
void fn004010AA(Eq_24 * fs)
{
	fs->dw0000 = fp - 0x00000004;
	globals->dw401000 = globals->dw401000 & 0xFFFFFFFD;
	int3();
	return;
}
Ejemplo n.º 16
0
void CMinimapInstance::drawScaled(int level)
{
    int3 mapSizes = LOCPLINT->cb->getMapSize();

    //size of one map tile on our minimap
    double stepX = double(pos.w) / mapSizes.x;
    double stepY = double(pos.h) / mapSizes.y;

    double currY = 0;
    for (int y=0; y<mapSizes.y; y++, currY += stepY)
    {
        double currX = 0;
        for (int x=0; x<mapSizes.x; x++, currX += stepX)
        {
            const SDL_Color &color = getTileColor(int3(x,y,level));

            //coordinates of rectangle on minimap representing this tile
            // begin - first to blit, end - first NOT to blit
            int xBegin = currX;
            int yBegin = currY;
            int xEnd = currX + stepX;
            int yEnd = currY + stepY;

            for (int y=yBegin; y<yEnd; y++)
            {
                Uint8 *ptr = (Uint8*)minimap->pixels + y * minimap->pitch + xBegin * minimap->format->BytesPerPixel;

                for (int x=xBegin; x<xEnd; x++)
                    ColorPutter<4, 1>::PutColor(ptr, color);
            }
        }
    }
}
Ejemplo n.º 17
0
word64 fn00000001400012BC(word32 edx, word64 rdi, word64 r13, selector gs, word64 qwArg08, word64 qwArg10)
{
	if (fn0000000140001600(0x01, edx, r13) == 0x00)
	{
		word64 rcx_362;
		byte bl_363;
		fn0000000140001974(0x07, qwLoc04, qwArg00, qwArg04, qwArg0C, out rcx_362, out bl_363);
		int3();
	}
	Mem23[fp - 0x14 + 0x00:byte] = 0x00;
	word32 eax_25 = fn00000001400015C4(gs);
	word64 rax_28 = DPB(rax, eax_25, 0);
	byte bl_29 = (byte) eax_25;
	word32 ecx_33 = Mem23[0x00000001400035B0 + 0x00:word32];
	if (ecx_33 == 0x01)
	{
		ecx_33 = 0x07;
		word64 rcx_355;
		rax_28 = DPB(rax, fn0000000140001974(0x07, qwLoc04, qwArg00, qwArg04, qwArg0C, out rcx_355, out bl_29), 0);
	}
	word64 rax_233;
	if (ecx_33 == 0x00)
	{
		Mem331[0x00000001400035B0 + 0x00:word32] = 0x01;
		word64 rax_334 = DPB(rax_28, _initterm_e(0x00000001400021B8, 0x00000001400021D0), 0);
		if (_initterm_e(0x00000001400021B8, 0x00000001400021D0) != 0x00)
		{
			rax_233 = DPB(rax_28, 0xFF, 0);
			return rax_233;
		}
		_initterm(0x00000001400021A0, 0x00000001400021B0);
		Mem344[0x00000001400035B0 + 0x00:word32] = 0x02;
	}
Ejemplo n.º 18
0
static void TestCatalog(skiatest::Reporter* reporter) {
    SkPDFCatalog catalog((SkPDFDocument::Flags)0);
    SkAutoTUnref<SkPDFInt> int1(new SkPDFInt(1));
    SkAutoTUnref<SkPDFInt> int2(new SkPDFInt(2));
    SkAutoTUnref<SkPDFInt> int3(new SkPDFInt(3));
    int1.get()->ref();
    SkAutoTUnref<SkPDFInt> int1Again(int1.get());

    catalog.addObject(int1.get(), false);
    catalog.addObject(int2.get(), false);
    catalog.addObject(int3.get(), false);

    REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int1.get()) == 3);
    REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int2.get()) == 3);
    REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int3.get()) == 3);

    SkDynamicMemoryWStream buffer;
    catalog.emitObjectNumber(&buffer, int1.get());
    catalog.emitObjectNumber(&buffer, int2.get());
    catalog.emitObjectNumber(&buffer, int3.get());
    catalog.emitObjectNumber(&buffer, int1Again.get());
    char expectedResult[] = "1 02 03 01 0";
    REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResult,
                                            strlen(expectedResult)));
}
Ejemplo n.º 19
0
void foreach_tile_pos(std::function<void(const int3& pos)> foo)
{
	for(int i = 0; i < cb->getMapSize().x; i++)
		for(int j = 0; j < cb->getMapSize().y; j++)
			for(int k = 0; k < cb->getMapSize().z; k++)
				foo(int3(i,j,k));
}
Ejemplo n.º 20
0
void CPrivilagedInfoCallback::getTilesInRange( std::unordered_set<int3, ShashInt3> &tiles, int3 pos, int radious, boost::optional<PlayerColor> player/*=uninit*/, int mode/*=0*/, bool patrolDistance/*=false*/) const
{
	if(!!player && *player >= PlayerColor::PLAYER_LIMIT)
	{
        logGlobal->errorStream() << "Illegal call to getTilesInRange!";
		return;
	}
	if (radious == -1) //reveal entire map
		getAllTiles (tiles, player, -1, 0);
	else
	{
		const TeamState * team = !player ? nullptr : gs->getPlayerTeam(*player);
		for (int xd = std::max<int>(pos.x - radious , 0); xd <= std::min<int>(pos.x + radious, gs->map->width - 1); xd++)
		{
			for (int yd = std::max<int>(pos.y - radious, 0); yd <= std::min<int>(pos.y + radious, gs->map->height - 1); yd++)
			{
				int3 tilePos(xd,yd,pos.z);
				double distance;
				if(patrolDistance)
					distance = pos.mandist2d(tilePos);
				else
					distance = pos.dist2d(tilePos) - 0.5;

				if(distance <= radious)
				{
					if(!player
						|| (mode == 1  && team->fogOfWarMap[xd][yd][pos.z]==0)
						|| (mode == -1 && team->fogOfWarMap[xd][yd][pos.z]==1)
					)
						tiles.insert(int3(xd,yd,pos.z));
				}
			}
		}
	}
}
Ejemplo n.º 21
0
    void run()
    {
        // Code from
        // http://llvm.org/svn/llvm-project/libcxx/trunk/test/utilities/intseq/intseq.general/integer_seq.pass.cpp

        //  Make a couple of sequences
        using int3    = std::make_integer_sequence<int, 3>;     // generates int:    0,1,2
        using size7   = std::make_integer_sequence<size_t, 7>;  // generates size_t: 0,1,2,3,4,5,6
        using size4   = std::make_index_sequence<4>;            // generates size_t: 0,1,2,3
        using size2   = std::index_sequence_for<int, size_t>;   // generates size_t: 0,1
        using intmix  = std::integer_sequence<int, 9, 8, 7, 2>; // generates int:    9,8,7,2
        using sizemix = std::index_sequence<1, 1, 2, 3, 5>;     // generates size_t: 1,1,2,3,5
    
        // Make sure they're what we expect
        static_assert ( std::is_same <int3::value_type, int>::value, "int3 type wrong" );
        static_assert ( int3::static_size == 3, "int3 size wrong" );
    
        static_assert ( std::is_same <size7::value_type, size_t>::value, "size7 type wrong" );
        static_assert ( size7::static_size == 7, "size7 size wrong" );
    
        static_assert ( std::is_same <size4::value_type, size_t>::value, "size4 type wrong" );
        static_assert ( size4::static_size == 4, "size4 size wrong" );
    
        static_assert ( std::is_same <size2::value_type, size_t>::value, "size2 type wrong" );
        static_assert ( size2::static_size == 2, "size2 size wrong" );
    
        static_assert ( std::is_same <intmix::value_type, int>::value, "intmix type wrong" );
        static_assert ( intmix::static_size == 4, "intmix size wrong" );

        static_assert ( std::is_same <sizemix::value_type, size_t>::value, "sizemix type wrong" );
        static_assert ( sizemix::static_size == 5, "sizemix size wrong" );

        auto tup = std::make_tuple ( 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 );
    
        //  Use them
        auto t3 = extract ( tup, int3() );
        static_assert ( std::tuple_size<decltype(t3)>::value == int3::static_size, "t3 size wrong");
        expect ( t3 == std::make_tuple ( 10, 11, 12 ));

        auto t7 = extract ( tup, size7 ());
        static_assert ( std::tuple_size<decltype(t7)>::value == size7::static_size, "t7 size wrong");
        expect ( t7 == std::make_tuple ( 10, 11, 12, 13, 14, 15, 16 ));

        auto t4 = extract ( tup, size4 ());
        static_assert ( std::tuple_size<decltype(t4)>::value == size4::static_size, "t4 size wrong");
        expect ( t4 == std::make_tuple ( 10, 11, 12, 13 ));

        auto t2 = extract ( tup, size2 ());
        static_assert ( std::tuple_size<decltype(t2)>::value == size2::static_size, "t2 size wrong");
        expect ( t2 == std::make_tuple ( 10, 11 ));

        auto tintmix = extract ( tup, intmix ());
        static_assert ( std::tuple_size<decltype(tintmix)>::value == intmix::static_size, "tintmix size wrong");
        expect ( tintmix == std::make_tuple ( 19, 18, 17, 12 ));

        auto tsizemix = extract ( tup, sizemix ());
        static_assert ( std::tuple_size<decltype(tsizemix)>::value == sizemix::static_size, "tsizemix size wrong");
        expect ( tsizemix == std::make_tuple ( 11, 11, 12, 13, 15 ));
        pass();
    }
Ejemplo n.º 22
0
bool BOState::Initialize(float2 p_position, int2 p_size, float2 p_menuPosition, std::string p_name, SDL_Texture* p_sprite)
{
	m_name = p_name;
	m_position = p_position;
	m_screenSize = p_size;
	m_buttonList.empty();

	BOPublisher::AddSubscriber(this);

	// Load background.
	if (!m_background.Initialize(p_position, p_size, p_sprite))
	{
		std::cout << "Failed to load background for " << m_name << "!" << std::endl;
		return false;
	}

	// Load the menu bars first edge.
	BOObject firstEdge;
	if (!firstEdge.Initialize(float2(p_menuPosition.x + 2.5f, p_menuPosition.y + 35), int2(5, 70), BOTextureManager::GetTexture(TEXMENUEDGE)))
	{
		std::cout << "Failed to load first edge of menu" << m_name << "!" << std::endl;
		return false;
	}

	m_menuBar.push_back(firstEdge);

	// Load the menu bar.
	BOObject menuBar;
	if (!menuBar.Initialize(float2(p_menuPosition.x + 125, p_menuPosition.y + 35), int2(240, 70), BOTextureManager::GetTexture(TEXMENUBAR)))
	{
		std::cout << "Failed to load last edge of menu" << m_name << "!" << std::endl;
		return false;
	}

	m_menuBar.push_back(menuBar);

	// Load the last edge of the menu bars.
	BOObject lastEdge;
	if (!lastEdge.Initialize(float2(p_menuPosition.x + 247.5f, p_menuPosition.y + 35), int2(5, 70), BOTextureManager::GetTexture(TEXMENUEDGE)))
	{
		std::cout << "Failed to load last edge of menu" << m_name << "!" << std::endl;
		return false;
	}

	m_menuBar.push_back(lastEdge);

	// Load menu text
	if (!m_menuText.Initialize(float2(0,0), m_name, int3(255, 255, 255), 72, 0))
	{
		std::cout << "Failed to create menu text in " << m_name << "!" << std::endl;
		return false;
	}

	// Calculate menu text position
	int2 tempSize = m_menuText.GetSize();
	float2 tempPos = float2(25.0f + p_menuPosition.x + tempSize.x / 2, 13 + p_menuPosition.y + tempSize.y / 2);
	m_menuText.SetPosition(tempPos);

	return true;
}
Ejemplo n.º 23
0
int main()
{
#if _LIBCPP_STD_VER > 11

//  Make a couple of sequences
    using int3    = std::make_integer_sequence<int, 3>;     // generates int:    0,1,2
    using size7   = std::make_integer_sequence<size_t, 7>;  // generates size_t: 0,1,2,3,4,5,6
    using size4   = std::make_index_sequence<4>;            // generates size_t: 0,1,2,3
    using size2   = std::index_sequence_for<int, size_t>;   // generates size_t: 0,1
    using intmix  = std::integer_sequence<int, 9, 8, 7, 2>; // generates int:    9,8,7,2
    using sizemix = std::index_sequence<1, 1, 2, 3, 5>;     // generates size_t: 1,1,2,3,5
    
//  Make sure they're what we expect
    static_assert ( std::is_same<int3::value_type, int>::value, "int3 type wrong" );
    static_assert ( int3::size () == 3, "int3 size wrong" );
    
    static_assert ( std::is_same<size7::value_type, size_t>::value, "size7 type wrong" );
    static_assert ( size7::size () == 7, "size7 size wrong" );
    
    static_assert ( std::is_same<size4::value_type, size_t>::value, "size4 type wrong" );
    static_assert ( size4::size () == 4, "size4 size wrong" );
    
    static_assert ( std::is_same<size2::value_type, size_t>::value, "size2 type wrong" );
    static_assert ( size2::size () == 2, "size2 size wrong" );
    
    static_assert ( std::is_same<intmix::value_type, int>::value, "intmix type wrong" );
    static_assert ( intmix::size () == 4, "intmix size wrong" );

    static_assert ( std::is_same<sizemix::value_type, size_t>::value, "sizemix type wrong" );
    static_assert ( sizemix::size () == 5, "sizemix size wrong" );

    auto tup = std::make_tuple ( 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 );
    
//  Use them
    auto t3 = extract ( tup, int3() );
    static_assert ( std::tuple_size<decltype(t3)>::value == int3::size (), "t3 size wrong");
    assert ( t3 == std::make_tuple ( 10, 11, 12 ));

    auto t7 = extract ( tup, size7 ());
    static_assert ( std::tuple_size<decltype(t7)>::value == size7::size (), "t7 size wrong");
    assert ( t7 == std::make_tuple ( 10, 11, 12, 13, 14, 15, 16 ));

    auto t4 = extract ( tup, size4 ());
    static_assert ( std::tuple_size<decltype(t4)>::value == size4::size (), "t4 size wrong");
    assert ( t4 == std::make_tuple ( 10, 11, 12, 13 ));

    auto t2 = extract ( tup, size2 ());
    static_assert ( std::tuple_size<decltype(t2)>::value == size2::size (), "t2 size wrong");
    assert ( t2 == std::make_tuple ( 10, 11 ));

    auto tintmix = extract ( tup, intmix ());
    static_assert ( std::tuple_size<decltype(tintmix)>::value == intmix::size (), "tintmix size wrong");
    assert ( tintmix == std::make_tuple ( 19, 18, 17, 12 ));

    auto tsizemix = extract ( tup, sizemix ());
    static_assert ( std::tuple_size<decltype(tsizemix)>::value == sizemix::size (), "tsizemix size wrong");
    assert ( tsizemix == std::make_tuple ( 11, 11, 12, 13, 15 ));
#endif  // _LIBCPP_STD_VER > 11
}
Ejemplo n.º 24
0
bool BOTechTreeManager::Initialize(int2 p_windowDimension)
{
    m_windowSize = p_windowDimension;

    m_grid = BOTextureManager::GetTexture(TEXTTHIGHLIGHTED);

    int2 m_Size = int2(100, 100);
    float2 midScreen = float2(m_windowSize.x * 0.5f, m_windowSize.y * 0.5f + 150); // To save computation
    int diameter = 7; // Original is 7
    float xOffset = m_Size.x * 0.85f;
    float yOffset = m_Size.y*0.5f;

    for (unsigned int y = diameter - 3, x = 0; y != 0; y--, x++)
    {
        BOTechTreeNode* newNode = CreateNode(float2(midScreen.x - x * xOffset, midScreen.y - (y + 4) * yOffset), m_Size, " ");
    }
    for (unsigned int y = diameter - 2, x = 0; y != 0; y--, x++)
    {
        BOTechTreeNode* newNode = CreateNode(float2(midScreen.x + xOffset - x * xOffset, midScreen.y + yOffset - (y + 3) * yOffset), m_Size, " ");
    }
    for (unsigned int y = diameter - 1, x = 0; y != 0; y--, x++)
    {
        BOTechTreeNode* newNode = CreateNode(float2(midScreen.x + xOffset * 2 - x * xOffset, midScreen.y + yOffset * 3 - (y + 3) * yOffset), m_Size, " ");
    }
    for (unsigned int y = diameter, x = 0; y != 0; y--, x++)
    {
        BOTechTreeNode* newNode = CreateNode(float2(midScreen.x + xOffset * 3 - x * xOffset, midScreen.y + yOffset * 5 - (y + 3) * yOffset), m_Size, " ");
    }
    for (unsigned int y = diameter - 1, x = 0; y != 0; y--, x++)
    {
        BOTechTreeNode* newNode = CreateNode(float2(midScreen.x + xOffset * 3 - x * xOffset, midScreen.y + yOffset * 6 - (y + 3) * yOffset), m_Size, " ");
    }
    for (unsigned int y = diameter - 2, x = 0; y != 0; y--, x++)
    {
        BOTechTreeNode* newNode = CreateNode(float2(midScreen.x + xOffset * 3 - x * xOffset, midScreen.y + yOffset * 7 - (y + 3) * yOffset), m_Size, " ");
    }
    for (unsigned int y = diameter - 3, x = 0; y != 0; y--, x++)
    {
        BOTechTreeNode* newNode = CreateNode(float2(midScreen.x + xOffset * 3 - x * xOffset, midScreen.y + yOffset * 8 - (y + 3) * yOffset), m_Size, " ");
    }

    MapNodes();
    SetLPE();

    m_resetButton.Initialize(float2(m_windowSize.x-300.0f, m_windowSize.y-125.0f), int2(250, 75), BOTextureManager::GetTexture(TEXMENUBUTTON), "RESET", TECHTREERESET, "");

    // Tech Points
    m_techPointsText.Initialize(float2(0,0), "ERROR", int3(255, 255, 255), 50, 0);
    float2 resetPos = m_resetButton.GetPosition();
    int2 resetSize = m_resetButton.GetSize();
    int2 textSize = m_techPointsText.GetSize();
    m_techPointsText.SetPosition(float2(resetPos.x - textSize.x*0.5f - 50.0f, resetPos.y + resetSize.y*0.5f));
    m_maxTechPoints = 0;
    m_techPointsLeft = 0;

    BOPublisher::AddSubscriber(this);

    return true;
}
Ejemplo n.º 25
0
void CSelectableComponent::showAll(SDL_Surface * to)
{
	CComponent::showAll(to);
	if(selected)
	{
		CSDL_Ext::drawBorder(to, Rect::around(image->pos), int3(239,215,123));
	}
}
Ejemplo n.º 26
0
void CGHeroInstance::getOutOffsets(std::vector<int3> &offsets) const
{
	offsets = 
	{ 
		int3(0,1,0), int3(0,-1,0), int3(-1,0,0), int3(+1,0,0), int3(1,1,0), int3(-1,1,0), int3(1,-1,0), int3(-1,-1,0) 
	};
}
Ejemplo n.º 27
0
	const IBox View::computeCursor(const int2 &start, const int2 &end, const int3 &bbox, int height, int offset) const {
		float2 height_off = worldToScreen(int3(0, height, 0));
		int3 gbox(cellSize(), 1, cellSize());

		int3 start_pos = asXZ((int2)( screenToWorld(float2(start + pos()) - height_off) + float2(0.5f, 0.5f)));
		int3 end_pos   = asXZ((int2)( screenToWorld(float2(end   + pos()) - height_off) + float2(0.5f, 0.5f)));

		start_pos.y = end_pos.y = height + offset;
		
		{
			int apos1 = start_pos.x % gbox.x;
			int apos2 = apos1 - gbox.x + bbox.x;
			start_pos.x -= apos1 < gbox.x - apos1 || bbox.x >= gbox.x? apos1 : apos2;
		}
		{
			int apos1 = start_pos.z % gbox.z;
			int apos2 = apos1 - gbox.z + bbox.z;
			start_pos.z -= apos1 < gbox.z - apos1 || bbox.z >= gbox.z? apos1 : apos2;
		}
		if(end == start)
			end_pos = start_pos;
		
		int3 dir(end_pos.x >= start_pos.x? 1 : -1, 1, end_pos.z >= start_pos.z? 1 : -1);
		int3 size(abs(end_pos.x - start_pos.x), 1, abs(end_pos.z - start_pos.z));
		size += bbox - int3(1, 1, 1);
		size.x -= size.x % bbox.x;
		size.z -= size.z % bbox.z;
		size = max(bbox, size);

		if(dir.x < 0)
			start_pos.x += bbox.x;
		if(dir.z < 0)
			start_pos.z += bbox.z;
		end_pos = start_pos + dir * size;

		if(start_pos.x > end_pos.x) swap(start_pos.x, end_pos.x);
		if(start_pos.z > end_pos.z) swap(start_pos.z, end_pos.z);
		
		int2 dims = m_tile_map.dimensions();
		start_pos = asXZY(clamp(start_pos.xz(), int2(0, 0), dims), start_pos.y);
		  end_pos = asXZY(clamp(  end_pos.xz(), int2(0, 0), dims),   end_pos.y);

		return IBox(start_pos, end_pos);

	}
Ejemplo n.º 28
0
void BOTechTreeNode::SetToolTip(std::string p_toolTip, std::string p_heading)
{
    int2 windowBounds = BOGraphicInterface::GetWindowSize();
    float2 tooltipPos = m_tooltipFrame.GetPosition();
    
    m_tooltipHeading.SetText(p_heading, int3(255, 255, 255), 0);

    int2 headingSize = m_tooltipHeading.GetSize();
    m_tooltipHeading.SetPosition(float2(tooltipPos.x, headingSize.y*0.5f + 60.0f));

    m_tooltipText.SetText(p_toolTip, int3(255, 255, 255), 290);

    int2 textSize = m_tooltipText.GetSize();
    m_tooltipText.SetPosition(float2(windowBounds.x - textSize.x*0.5f -60.0f, textSize.y*0.5f + 60.0f + headingSize.y));

    m_priceText.SetText(std::to_string(m_price), int3(255, 255, 255), 290);
    m_priceText.SetPosition(float2(m_position.x + 25,m_position.y + 25));
}
Ejemplo n.º 29
0
void foreach_tile_pos(CCallback * cbp, std::function<void(CCallback * cbp, const int3& pos)> foo)
{
	int3 mapSize = cbp->getMapSize();

	for(int i = 0; i < mapSize.x; i++)
		for(int j = 0; j < mapSize.y; j++)
			for(int k = 0; k < mapSize.z; k++)
				foo(cbp, int3(i,j,k));
}
Ejemplo n.º 30
0
void __CGsampler1DARRAY_state::initImages()
{
    // Just width dimension supports border.
    const int3 borderSupport = int3(1, 0, 0);

    for (int level=0; level<maxLevels; level++) {
        image[level].initImage(texTarget, level, borderSupport);
    }
}