Example #1
0
bool 
StatusWindow::UpdateStatusBar(uint32 page, uint32 copy)
{
	Lock();
		Activate(true);		
			// Frontmost Window
		char buffer[20];
		
		sprintf(buffer,"%d", (int)(page + 1));
		BString string1(buffer);
		
		sprintf(buffer,"%d",(int)fNops );						
		BString string2(buffer);
		string1.Append(BString(" / "));
		string1.Append(string2);
		
		BString string3 = BString("Remaining Document Copies:  ");	
		if (fDocumentCopy == true) {
			sprintf(buffer, "%d", (int)(fDocCopies));
			BString string4(buffer);
			string3.Append(string4);
		} else {
			string3 = BString("Remaining Page Copies:  ");	
			char buffer[20];
			sprintf(buffer,"%d",(int)(fCopies - copy) );						
			BString string4(buffer);
			string3.Append(string4);		
		}
		
		fStatusBar->Update(fStatusDelta*100.0/fNops, string1.String(), string3.String());
		if ( (fStatusBar->MaxValue()) == (fStatusBar->CurrentValue()) )
				fCancelButton->SetEnabled(false);
	Unlock();
	return fCancelBar;
}
Example #2
0
TEST(json, DISABLED_fetch_write_fail)
{
	std::string string4("");
	std::stringstream stream4(string4, std::ios_base::in);
	json_upgrade_test object4;
	auto error4(rai::fetch_object(object4, stream4));
	ASSERT_TRUE(error4);
}
int main(int argc, const char* argv[]) {
    std::string string1("Testing the comparision functions.");
    std::string string2("Hello");
    std::string string3("stinger");
    std::string string4(string2);

    std::cout << "string1: " << string1 << "\nstring2: " << string2
              << "\nstring3: " << string3 << "\nstring4: " << string4 << "\n\n";

    // comparing string1 and string4
    if (string1 == string4)
        std::cout << "string1 == string4\n";
    else {
        if (string1 > string4)
            std::cout << "string1 > string4\n";
        else
            std::cout << "string1 < string4\n";
    }

    // comparing string1 and string2
    int result = string1.compare(string2);

    if (result == 0)
        std::cout << "string1.compare(string2) == 0\n";
    else {
        if (result > 0)
            std::cout << "string1.compare(string2) > 0\n";
        else
            std::cout << "string1.compare(string2) < 0\n";
    }

    // comparing string1 (elements 2-5) and string3 (elements 0-5)
    result = string1.compare(2, 5, string3, 0, 5);

    if (result == 0)
        std::cout << "string1.compare(2, 5, string3, 0, 5) == 0\n";
    else {
        if (result > 0)
            std::cout << "string1.compare(2, 5, string3, 0, 5) > 0\n";
        else
            std::cout << "string1.compare(2, 5, string3, 0, 5) < 0\n";
    }

    // comparing string2 and string4
    result = string4.compare(0, string2.length(), string2);

    if (result == 0)
        std::cout << "string4.compare(0, string2.length(), string2) == 0"
                  << std::endl;
    else {
        if (result > 0)
            std::cout << "string4.compare(0, string2.length(), string2) > 0"
                      << std::endl;
        else
            std::cout << "string4.compare(0, string2.length(), string2) < 0"
                      << std::endl;
    }

    // comparing string2 and string4
    result = string2.compare(0, 3, string4);

    if (result == 0)
        std::cout << "string2.compare(0, 3, string4) == 0" << std::endl;
    else {
        if (result > 0)
            std::cout << "string2.compare(0, 3, string4) > 0" << std::endl;
        else
            std::cout << "string2.compare(0, 3, string4) < 0" << std::endl;
    }

    return 0;
}
Example #4
0
void Debuger::DrawEntitiesStats(int eco){
    sf::View currentView    = _window->getView();
    sf::Vector2f centerView = currentView.getCenter();
    sf::Vector2f sizeView   = currentView.getSize();
    _text.setPosition(centerView.x-sizeView.x/2, centerView.y-sizeView.y/2+_displace);
    std::stringstream buffer;

    Scene* s = Scene::getScene();
    Ecosystem *e1 = s->getEcosystem(eco);

    buffer << "Ecosystem " << eco << " (" << e1->getInterval().x << " - " << e1->getInterval().y <<") Num Mobs: " << e1->getMobPopulationAndTreshold().x <<  "/" << e1->getMobPopulationAndTreshold().y <<  "/" << e1->getMobPopulationAndTreshold().z << "Num Trees: " << e1->getTreePopulationAndTreshold().x <<  "/" << e1->getTreePopulationAndTreshold().y <<  "/" << e1->getTreePopulationAndTreshold().z;
    std::string string(buffer.str());
    sf::String str(string);
    _text.setString(str);
    _window->draw(_text);
    _displace = _displace + DISPLACEMENT;

    sf::Vector2f position = _window->mapPixelToCoords(sf::Mouse::getPosition(*_window));
    float zoom = s->getZoom();
    sf::Vector2f position_center = sf::Vector2f(s->getPlayer()->GetPosition().x+Player::PLAYER_WIDTH/2,s->getPlayer()->GetPosition().y+Player::PLAYER_WIDTH/2);
    sf::Vector2f position_zoomed = (position-position_center)/zoom +position_center;
    position = position_zoomed;
    std::vector<Mob*> mobs;
    s->getMobsOnArea(mobs,sf::Vector2i(position),100,eco);
    for(int i =0; i<mobs.size();i++){
        mobs[i]->_focusDebug = true;
    }
    if(mobs.size()>0) {
        std::stringstream buffer2;
        buffer2 << "Mob Position colision: " << mobs[0]->_positionCol.x << " " << mobs[0]->_positionCol.y << " Size colision: " << mobs[0]->_sizeCol.x << " " << mobs[0]->_sizeCol.y << " Radius: " << mobs[0]->getGenetics()->_distanceMaxReproduce << "/" << mobs[0]->getGenetics()->_distanceMaxMove;
        std::string string(buffer2.str());
        sf::String str(string);
        _text.setString(str);
        _text.setPosition(centerView.x-sizeView.x/2, centerView.y-sizeView.y/2+_displace);
        _window->draw(_text);
        _displace = _displace + DISPLACEMENT;

        std::stringstream buffer3;
        buffer3 << "Race: " << mobs[0]->getGenetics()->_race << " Life: " << mobs[0]->_life << "/" << mobs[0]->getGenetics()->_health << " Hunger: " << mobs[0]->_hunger << "/" << mobs[0]->getGenetics()->_foodNeeds << " Age: " << mobs[0]->_age << "/" << mobs[0]->getGenetics()->_age << " Target: " << (mobs[0]->_target !=nullptr);
        std::string string3(buffer3.str());
        sf::String str3(string3);
        _text.setString(str3);
        _text.setPosition(centerView.x-sizeView.x/2, centerView.y-sizeView.y/2+_displace);
        _window->draw(_text);
        _displace = _displace + DISPLACEMENT;

        std::stringstream buffer4;
        buffer4 << "Food: ";
        for(int i =0; i< mobs[0]->getGenetics()->_food.size();i++){
            buffer4 << mobs[0]->getGenetics()->_food[i] << " ";
        }
        buffer4 << "\n Enemys: ";
        for(int i =0; i< mobs[0]->getGenetics()->_enemys.size();i++){
            buffer4 << mobs[0]->getGenetics()->_enemys[i] << " ";
        }
        buffer4 << "\n Friends: ";
        for(int i =0; i< mobs[0]->getGenetics()->_friends.size();i++){
            buffer4 << mobs[0]->getGenetics()->_friends[i] << " ";
        }
        buffer4 << "\n Neutral: ";
        for(int i =0; i< mobs[0]->getGenetics()->_neutral.size();i++){
            buffer4 << mobs[0]->getGenetics()->_neutral[i] << " ";
        }
        std::string string4(buffer4.str());
        sf::String str4(string4);
        _text.setString(str4);
        _text.setPosition(centerView.x-sizeView.x/2, centerView.y-sizeView.y/2+_displace);
        _window->draw(_text);
        _displace = _displace + DISPLACEMENT*4;
    } else {

        std::vector<Tree*> trees;
        s->getTreesOnArea(trees,sf::Vector2i(position),100,eco);
        if(trees.size() >0){
            int pos_l = 0;
            int pos_r = 0;
            if(trees[0]->_left_n != nullptr) pos_l = trees[0]->_left_n->_position.x;
            if(trees[0]->_right_n != nullptr) pos_r = trees[0]->_right_n->_position.x;
            std::stringstream buffer2;
            buffer2 << "Tree Position: " << trees[0]->_position.x << " " << trees[0]->_position.y << " padding: " << trees[0]->_min_x << ", " << trees[0]->_max_x <<" Health: " << trees[0]->_life <<" Reproduce countdown: " << trees[0]->_timeToReproduce << "\n";
            buffer2 << "Damage time: " << trees[0]->_debug_last_damage_time << " Damage distance: " << trees[0]->_debug_last_damage_distance << " Damage temp: " << trees[0]->_debug_last_damage_temp << " Damage humid " << trees[0]->_debug_last_damage_hum << "\n";
            buffer2 << "Tree Fathers: " << pos_l << " " << pos_r << "\n";
            TreeGenetics *gens = trees[0]->getGenetics();
            buffer2 << "Tree corb: " << gens->_corb << " Tree amplitude: " << gens->_amplitude << " Tree height: " << gens->_height << "\n";
            buffer2 << "Branch amount: " << gens->_branchAmount << " Curve branch: " << gens->_curveBranch << " Branch size: " << gens->_sizeBranch << "\n";
            buffer2 << "Type leave: " << gens->_typeLeave << " Amount leave: " << gens->_amountLeave << " Density leave: " << gens->_densityLeave << "\n";
            buffer2 << "Life: " << gens->_health << " Cold res " << gens->_cold << " Hot res " << gens->_hot << " Humidity res " << gens->_humidity << " Gen strenght " << gens->_strenghtGen << " Reproduce freq " << gens->_reproduceFactor;
            std::string string(buffer2.str());
            sf::String str(string);
            _text.setString(str);
            _text.setPosition(centerView.x-sizeView.x/2, centerView.y-sizeView.y/2+_displace);
            _window->draw(_text);
            _displace = _displace + DISPLACEMENT*7;
        }


    }
}