void Dlg_AchievementsReporter::SetupColumns()
{
	//	Remove all columns,
	while (ListView_DeleteColumn(m_hList, 0)) {}

	//	Remove all data.
	ListView_DeleteAllItems(m_hList);
	auto limit{ static_cast<int>(col_num) };
	for (auto i = 0; i < limit; i++)
	{

		auto sStr{ std::string{col_names.at(to_unsigned(i))} }; // you can't do it directly

		// would be easier with delegates...
		// Probably should be made in to a class from repetition
		LV_COLUMN col
		{
			LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM | LVCF_FMT,
			LVCFMT_LEFT | LVCFMT_FIXED_WIDTH,
			col_sizes.at(to_unsigned(i)),
			sStr.data(),
			255,
			i
		};

		if (i == limit - 1)	//If the last element: fill to the end
			col.fmt |= LVCFMT_FILL;

		ListView_InsertColumn(m_hList, i, &col);
	}
}
Beispiel #2
0
void FullbrightMaterialComponent::onParams(const CaffUtil::Param &params)
{
	// RGB
	{
		const std::array<float, 4> rgba = params["rgba"].asFloat4({m_rgba.r, m_rgba.g, m_rgba.b, m_rgba.a});
		
		enum { R = 0, G, B, A, };
		
		m_rgba.r = rgba.at(R);
		m_rgba.g = rgba.at(G);
		m_rgba.b = rgba.at(B);
		m_rgba.a = rgba.at(A);
	}
	
	// Lookup textureName.
	{
		m_textureName = params["diffuse_map"].asStdString();
	}
	
	// Texture scale
	{
		const std::array<float, 2> uvScale = params["diffuse_map_scale"].asFloat2({m_diffuseScale.x, m_diffuseScale.y});
		
		enum { U = 0, V };
		m_diffuseScale.u = uvScale.at(U);
		m_diffuseScale.v = uvScale.at(V);
	}
}
Beispiel #3
0
const std::list<sf::Vector2i> King::getValidMoves(const std::array<std::array<std::shared_ptr<Figure>, 8>, 8> &board)
{
	std::list<sf::Vector2i> movements;

#pragma region 1 to all directions

	for(int x = this->m_Position.x -1; x <= this->m_Position.x +1; ++x)
	{
		for(int y = this->m_Position.y -1; y <= this->m_Position.y +1; ++y)
		{
			if(x >= 0 && x < 8 && y >= 0 && y < 8 && (x != 0 || y != 0) )
			{
				if(board.at(x).at(y) != NULL)	// other figure at position
				{
					if(board.at(x).at(y)->isPlayerOne() == this->m_PlayerOne)		// figure of same color -> not a valid move
						continue;
				}
				// different players or no other figure on the field
				movements.push_back(sf::Vector2i(x, y) );
			}
		}
	}
#pragma endregion

	// to do
#pragma region Rochade
	// to do
#pragma endregion

	return movements;
}
Beispiel #4
0
bool fileinformation::validate_lines_information(std::string& line) {
	std::smatch  matches; 
	bool output = false;
	std::size_t index;
	static bool recursivecomment = false;

	for(index = 0; index < regularexpression.size(); ++index) {
		regularexpression[index].second = std::regex_search(line, matches, regularexpression[index].first);
		/*
		{
				output = true;
				if(index != 2){
					break;
				}
		}
		*/
	}

	recursivecomment = (regularexpression.at(2).second) && !(regularexpression.at(3).second);


	for(index = 0; index < regularexpression.size(); ++index) {
		regularexpression[index].second = false;
	}



	return output;
}
Beispiel #5
0
std::array<float, 3> Param::asFloat3(const std::array<float, 3> &defaultData) const
{
    std::array<float, 4> resultArr = asFloat4({{defaultData.at(0), defaultData.at(1), defaultData.at(2), 0.f}});
    std::array<float, 3> returnArr {{ resultArr.at(0), resultArr.at(1), resultArr.at(2) }};

    return returnArr;
}
	 	inline uint32_t GetPayloadLenght(std::array<char, 4>& x)
	 	{
	 		Int32U conv;
	 		conv.c[0] = x.at(0);
	 		conv.c[1] = x.at(1);
	 		conv.c[2] = x.at(2);
	 		conv.c[3] = x.at(3);
	 		return conv.dw;
	 	}
Beispiel #7
0
void PointLightComponent::onParams(const CaffUtil::Param &params)
{
	const std::array<float, 3> color = params["color"].asFloat3({m_color.x, m_color.y, m_color.z});

	enum { X = 0, Y, Z };
	m_color = CaffMath::Vector3Init(color.at(X), color.at(Y), color.at(Z));

	m_intensity = params["intensity"].asFloat(m_intensity);
	m_radius	= params["radius"].asFloat(m_radius);
}
uint16_t collatz(uint32_t n) {
	uint16_t count = 1;
	while (n != 1) {
		if (n < 1000000 && dm.at(n-1) != 0) {
			return count + dm.at(n-1);
		}
		++count;
		if (n % 2 == 0) {
			n /= 2;
		} else {
			n = 3 * n + 1;
		}
	}
	return count;
};
Beispiel #9
0
bool Bishop::beatableMove(const sf::Vector2i position, const std::array<std::array<std::shared_ptr<Figure>, 8>, 8> &board)
{
	int rel_x = this->m_Position.x - position.x, rel_y = this->m_Position.y - position.y;

	if( (rel_x != rel_y) && (rel_x != -1*rel_y) )
		return false;

	int relative_movement_x = -1, relative_movement_y = -1;

	if(rel_x < 0)
		relative_movement_x = 1;
	
	if(rel_y < 0)
		relative_movement_y = 1;


	int new_X = this->m_Position.x, new_Y = this->m_Position.y;

	for(int i = relative_movement_x; i != -rel_x; i += relative_movement_x)
	{
		new_X += relative_movement_x;
		new_Y += relative_movement_y;

		if(board.at(new_X).at(new_Y) != NULL)
			return false;
	}
	return true;
}
Beispiel #10
0
    std::string select(){

        if (++current_ >= methods_.size()) {
            current_ = 0;
        }
        return methods_.at(current_);
    }
Beispiel #11
0
 uint16_t operator()( uint16_t code ) const {
     
     if ( code < code_.size() )
         return code_.at( code );
     
     return (-1);
 }
Beispiel #12
0
void SingleDigit::drawHorizontalSegment(QPainter &painter, const QPointF& startPoint, bool filled,
                          QBrush &brush)
{
    const std::array<QPointF, 7>baseSegment{
        QPointF(0,0),
        QPointF(3,-3),
        QPointF(23,-3),
        QPointF(26,0),
        QPointF(23,3),
        QPointF(3,3),
        QPointF(0,0)
    };

    QPainterPath segmentPath;

    segmentPath.moveTo(baseSegment.at(0)+startPoint);

    for(auto & point : baseSegment)
        segmentPath.lineTo(point*m_scale + startPoint);

    if(filled)
        painter.fillPath(segmentPath,brush);
    else
        painter.drawPath(segmentPath);
}
Beispiel #13
0
///
/// Конвертирование текстового ИД константы в ее значение в коде.
/// \return значение константы или -1, если ничего не было найдено
///
int to_num(IdType type, const std::string &str)
{
	if (type < TEXT_ID_COUNT)
	{
		return text_id_list.at(type).to_num(str);
	}
	return -1;
}
Beispiel #14
0
void Boss::handleCollision(std::array<bool, CollisionSide::SOLID_TOTAL> detections_){
	if(detections_.at(CollisionSide::SOLID_TOP)){ 
		this->vy = 0.0;
	}
	if(detections_.at(CollisionSide::SOLID_BOTTOM)){		
			this->nextY -= fmod(this->nextY, 64.0) - 16.0;
			this->vy = 0.0;
	}
	if(detections_.at(CollisionSide::SOLID_LEFT)){
		this->nextX = this->x;
		this->vx = 0.0;
	}
	if(detections_.at(CollisionSide::SOLID_RIGHT)){
		this->nextX = this->x;
		this->vx = -0.001;
	}
}
Beispiel #15
0
///
/// Конвертирование значения константы в ее текстовый ИД.
/// \return текстовый ИД константы или пустая строка, если ничего не было найдено
///
std::string to_str(IdType type, int num)
{
	if (type < TEXT_ID_COUNT)
	{
		return text_id_list.at(type).to_str(num);
	}
	return "";
}
Beispiel #16
0
void print_ar1(std::array<int, size> ar)
{
  for (int i = 0; i < sizey; i++) {
    for (int j = 0; j < sizex; j++) {
      std::cout << ar.at(i * sizey + j) << " ";
    }
    std::cout << std::endl;
  }
  std::cout << std::endl;
}
Beispiel #17
0
///
/// Инит текстовых ИД параметров предметов для сохранения в файл.
///
void init_obj_vals()
{
	TextIdNode &tmp = text_id_list.at(OBJ_VALS);
	tmp.add(ObjVal::POTION_SPELL1_NUM, "POTION_SPELL1_NUM");
	tmp.add(ObjVal::POTION_SPELL1_LVL, "POTION_SPELL1_LVL");
	tmp.add(ObjVal::POTION_SPELL2_NUM, "POTION_SPELL2_NUM");
	tmp.add(ObjVal::POTION_SPELL2_LVL, "POTION_SPELL2_LVL");
	tmp.add(ObjVal::POTION_SPELL3_NUM, "POTION_SPELL3_NUM");
	tmp.add(ObjVal::POTION_SPELL3_LVL, "POTION_SPELL3_LVL");
	tmp.add(ObjVal::POTION_PROTO_VNUM, "POTION_PROTO_VNUM");
}
Beispiel #18
0
const QByteArray& TorProtocolManager::getName(const ProtocolManager::State state)
{
    static const std::array<QByteArray, 5> names = {{
       "OFFLINE",
       "CONNECTING",
       "CONNECTED",
       "ONLINE",
       "SHUTTINGDOWN"
   }};

   return names.at(static_cast<size_t>(state));
}
 const std::vector<unsigned int>& getPoseBodyPartPairsRender(const PoseModel poseModel)
 {
     try
     {
         return POSE_BODY_PART_PAIRS_RENDER.at((int)poseModel);
     }
     catch (const std::exception& e)
     {
         error(e.what(), __LINE__, __FUNCTION__, __FILE__);
         return POSE_BODY_PART_PAIRS_RENDER[(int)poseModel];
     }
 }
 const std::vector<float>& getPoseColors(const PoseModel poseModel)
 {
     try
     {
         return POSE_COLORS.at((int)poseModel);
     }
     catch (const std::exception& e)
     {
         error(e.what(), __LINE__, __FUNCTION__, __FILE__);
         return POSE_COLORS[(int)poseModel];
     }
 }
uint16_t extendedChecksum16(const std::array<unsigned char, MAXIMUM_BUFFER>& bytes, int count)
{
	uint16_t accumulator = 0;

	//Sums bytes 6 to n-1 to an unsigned 2 byte value
	for (int i = 6; i < count; ++i)
	{
		accumulator += static_cast<uint16_t>(bytes.at(i));
	}

	return accumulator;
}
Beispiel #22
0
void ModelObject::load(std::istream &stream, const std::array<std::array<char,8>,750> &mdldata)
{
    mXRot = VFS::read_le32(stream);
    mYRot = VFS::read_le32(stream);
    mZRot = VFS::read_le32(stream);

    mModelIdx = VFS::read_le16(stream);
    mActionFlags = VFS::read_le32(stream);
    mSoundId = stream.get();
    mActionOffset = VFS::read_le32(stream);

    mModelData = mdldata.at(mModelIdx);
}
Beispiel #23
0
//----------------------------------------------------------------------//
// This operator is used for regular stream formatting
std::ostream& operator<<(std::ostream& strm, SeverityLevel level)
{
  try
    {
      strm << s_strings.at(static_cast<int>(level));
    }
  catch (...)
    {
      assert(false);
      strm << static_cast<int>(level);
    }

  return strm;
}
Beispiel #24
0
void print_ar2(std::array<int, size> ar)
{
  for (int i = 0; i < sizey; i++) {
    for (int j = 0; j < sizex; j++) {
      if (ar.at(i * sizey + j) == 1) {
        std::cout << 'o';
      } else {
        std::cout << 'x';
      }
    }
    std::cout << std::endl;
  }
  std::cout << std::endl;
}
inline typename IsingModelRule::state_type
IsingModelRule::step(const cell_type& cell) const
{
    const bool center = cell.state;
    short dE = 0;
    for(auto iter = cell.neighbors.cbegin();
            iter != cell.neighbors.cend(); ++iter)
    {
        if(center != (*iter)->state) --dE;
        else ++dE;
    }

    return (dE <= 0) ? (!center) :
        ((rng_->uniform_real<float>(0.,1.) < probs.at(dE)) != center);
}
int main( void ) {
	dm.fill(0);
	uint16_t max = 0;
	uint32_t num = 0;
	for (uint32_t i = 1; i < 1000000; ++i ){
		uint16_t v = collatz(i);
		dm.at(i-1) = v;
		if (v > max) {
			max = v;
			num = i;
		}
	}
	std::cout <<  num << std::endl;

	return 0;
};
Beispiel #27
0
std::string ExteriorLocation::getMapBlockName(size_t idx, size_t regnum) const
{
    std::stringstream name;

    name<< gBuildingLabel.at(mBlockIndex[idx]).data();
    if(mBlockIndex[idx] == 13 || mBlockIndex[idx] == 14)
    {
        if(mBlockCharacter[idx] > 0x07)
            name<< "GA";
        else
            name<< "AA";
        static const char numbers[8][3] = {
            "A0", "B0", "C0", "D0", "E0", "F0", "G0", "H0"
        };
        name<< numbers[mBlockCharacter[idx]&0x07];
    }
    else
    {
        size_t q = mBlockCharacter[idx] >> 4;
        if(regnum == 23 /* Wayrest special-case */)
        {
            if(mBlockIndex[idx] == 40)
                q = 0;
            else if(q > 0)
                --q;
        }
        else if(regnum == 20 /* Sentinel special-case */)
        {
            if(mBlockIndex[idx] == 40)
                q = 8;
        }
        else
        {
            if(mBlockIndex[idx] == 40)
                q = 0;
        }
        const std::array<std::array<char,3>,12> letters{{
            {"AA"}, {"BA"}, {"AL"}, {"BL"}, {"AM"}, {"BM"},
            {"AS"}, {"BS"}, {"GA"}, {"GL"}, {"GM"}, {"GS"}
        }};
        name<< letters.at(q).data();
        name<< std::setfill('0')<<std::setw(2)<<(int)mBlockNumber[idx];
    }
    name<< ".RMB";

    return name.str();
}
Beispiel #28
0
//----------------------------------------------------------------------//
// The operator is used when putting the severity level to log
boost::log::formatting_ostream& operator<<(boost::log::formatting_ostream& strm,
					   boost::log::to_log_manip<SeverityLevel,
					   SeverityTag > const& manip)
{
  SeverityLevel level = manip.get();
  try
    {
      strm << s_strings.at(static_cast<int>(level));
    }
  catch (...)
    {
      assert(false);
      strm << static_cast<int>(level);
    }

  return strm;
}
Beispiel #29
0
void DirectionalLightComponent::onParams(const CaffUtil::Param &params)
{
	enum { X = 0, Y, Z };

	const std::array<float, 3> color = params["color"].asFloat3({m_color.x, m_color.y, m_color.z});
	m_color = CaffMath::Vector3Init(color.at(X), color.at(Y), color.at(Z));

	const std::array<float, 3> ambient = params["ambient"].asFloat3({m_ambient.x, m_ambient.y, m_ambient.z});
	m_ambient = CaffMath::Vector3Init(ambient.at(X), ambient.at(Y), ambient.at(Z));

	m_intensity = params["intensity"].asFloat(m_intensity);
}
unsigned char normalChecksum8(const std::array<unsigned char, MAXIMUM_BUFFER>& bytes, int count)
{
	uint16_t accumulator = 0;

	//Sums bytes 1 to n-1 unsigned to a 2 byte value. Sums quotient and
	//remainder of 256 division.  Again, sums quotient and remainder of
	//256 division.
	for (int i = 1; i < count; ++i)
	{
		accumulator += static_cast<uint16_t>(bytes.at(i));
	}

	uint16_t quotient = accumulator / 256;
	accumulator = (accumulator - 256 * quotient) + quotient;
	quotient = accumulator / 256;

	return static_cast<unsigned char>((accumulator - 256 * quotient) + quotient);
}