예제 #1
0
/** Set label text displayed next to the edge.
 *
 * Passing the empty string will remove the label.
 */
void
Connection::set_label(const std::string& str)
{
	if (str != "") {
		if (!_handle)
			_handle = new Handle(*this);

		if (!_handle->text) {
			_handle->text = new Gnome::Canvas::Text(*_handle, 0, 0, str);
			_handle->text->property_size_set() = true;
			_handle->text->property_size() = 9000;
			_handle->text->property_weight_set() = true;
			_handle->text->property_weight() = 200;
			_handle->text->property_fill_color_rgba() = _color;
			_handle->text->show();
		} else {
			_handle->text->property_text() = str;
		}

		if (_handle->shape)
			show_handle(true);

		_handle->text->raise(1);
		update_location();
	} else if (_handle) {
		delete _handle->text;
		_handle->text = NULL;
	}
}
예제 #2
0
void opp_bot::update(){
   
    Mat roi_image = image(location);
    
    GaussianBlur( roi_image, roi_image, Size( 3, 3 ), 0, 0 );
    
    cvtColor(roi_image, roi_image, CV_BGR2HSV);

    mask[0] = Mat::zeros(roi_image.rows,roi_image.cols,CV_8UC1);
    
    pick_color( roi_image, mask[0], color );
    imshow("opp bot mask", mask[0]);
    FindCenter();
    
    cvtColor(roi_image, roi_image, CV_HSV2BGR);

    if( center.x != 0 ){
        center = Point( center.x + location.x, center.y + location.y );
        update_location( location, center );
    }
    else{
        expand_location( location );
    }

    limit_location_within_arena( location );

}
예제 #3
0
void update_all(node **head, int step, date_time time_stamp) {
    node *current = *head;
    for (current = *head; current != NULL; current = current->next) {

        current->loc = update_location(current->loc, current->speed,
                current->course, step);

        int new_area = check_location(current->loc, current->course);
        FILE *log = fopen(log_file, "a");
        if (current->in_area == 0 && new_area != 0) {
            printf("\nShip %s has left shipping area", current->ais_id);

            fprintf(log, "\nShip left: %s\nTime: %d %d %d %d:%d:%d",
                    current->ais_id,
                    time_stamp.day, time_stamp.month, time_stamp.year,
                    time_stamp.hours, time_stamp.minutes, time_stamp.seconds);

        } else if (current->in_area != 0 && new_area == 0) {
            printf("\nShip %s has entered shipping area", current->ais_id);

            fprintf(log, "Ship Entered: %s\nTime: %d %d %d %d:%d:%d",
                    current->ais_id,
                    time_stamp.day, time_stamp.month, time_stamp.year,
                    time_stamp.hours, time_stamp.minutes, time_stamp.seconds);
        }
        fclose(log);
        current->in_area = new_area;
    }
}
bool Soldier::update()
{
    if (state == 'm')
    {
        if (update_location() == true)
        {
            state = 's';
            return true;
        }

        else
        {
            return false;
        }
    }

    else if (state == 'x')
    {
        return false;
    }

    else if (state == 's')
    {
        return false;
    }

    else if (state == 'a')
    {
        if (cart_distance((*target).get_location(), get_location()) > range)
        {
            cout << "Target is out of range." << endl;
            state = 's';
            return true;
        }

        if (cart_distance((*target).get_location(), get_location()) <= range)
        {
            if ((*target).is_alive() == true)
            {
                cout << "Take that!" << endl;
                (*target).take_hit(attack_strength, this);
                state = 'a';
                return false;
            }

            else if ((*target).is_alive() == false)
            {
                cout << "I win." << endl;
                state = 's';
                return true;
            }
        }

    }
    else
    {
        return false;
    }
}
예제 #5
0
파일: gntfilesel.c 프로젝트: bf4/pidgin-mac
static void
file_sel_changed(GntWidget *widget, gpointer old, gpointer current, GntFileSel *sel)
{
	if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_HAS_FOCUS)) {
		g_free(sel->suggest);
		sel->suggest = NULL;
		update_location(sel);
	}
}
예제 #6
0
void scrollarea::test_scrollbar()
{
	if (recursive_)
		return;
	recursive_ = true;
	if (shown_scrollbar_ != has_scrollbar()) {
		bg_restore();
		bg_cancel();
		update_location(location());
	}
	recursive_ = false;
}
예제 #7
0
void widget::set_location(SDL_Rect const &rect)
{
	if(rect_.x == rect.x && rect_.y == rect.y && rect_.w == rect.w && rect_.h == rect.h)
		return;
	if(state_ == UNINIT && rect.x != -1234 && rect.y != -1234)
		state_ = DRAWN;

	bg_restore();
	bg_cancel();
	rect_ = rect;
	set_dirty(true);
	update_location(rect);
}
예제 #8
0
static void pre_move_tasks(boolean didmove)
{
    boolean is_on_elbereth = sengr_at("Elbereth", u.ux, u.uy);

    /* recalc attribute bonuses from items */
    calc_attr_bonus();
    find_ac();

    if (!flags.mv || Blind)
	special_vision_handling();

    /* update "Elbereth" status */
    if (was_on_elbereth != is_on_elbereth) {
	was_on_elbereth = is_on_elbereth;
	iflags.botl = 1;
    }

    if (iflags.botl)
	bot();

    if (didmove &&
	(u.uhave.amulet || Clairvoyant) &&
	!In_endgame(&u.uz) && !BClairvoyant &&
	!(moves % 15) && !rn2(2))
	    do_vicinity_map();

    u.umoved = FALSE;

    if (multi > 0) {
	lookaround();
	if (!multi) {
	    /* lookaround may clear multi */
	    flags.move = 0;
	    iflags.botl = 1;
	}
    }
    
    if (didmove && moves % 100 == 0)
	realtime_tasks();
    
    update_inventory();
    update_location(FALSE);

    if (didmove) {
	/* Mark the current square as stepped on unless blind,
	 * since that would imply that we had properly explored it. */
	struct rm *loc = &level->locations[u.ux][u.uy];
	if (!Blind && !loc->mem_stepped)
	    loc->mem_stepped = 1;
    }
}
예제 #9
0
파일: Lexer.cpp 프로젝트: c4wrd/Qwak
    /*
     * We will attempt to desired_char in our input stream (resulting in our
     * input stream pointing to desired_char + 1). If it does not exist, and we reach the
     * end of the file, we will return false, otherwise true if successfully skipped to
     * that position.
     */
    bool Lexer::skip_to(char desired_char) {
        if (this->f_fileStream.peek() == EOF) {
            return false;
        }

        char input_char;
        while (this->f_fileStream.good()) {
            this->f_fileStream.get(input_char);
            update_location(input_char);
            if (input_char == desired_char)
                return true;
        }   // we've reached the EOF

        return false;
    }
	void floating_textbox::show(gui::TEXTBOX_MODE mode, const std::string& label,
		const std::string& check_label, bool checked, game_display& gui)
	{
		close(gui);

		label_string_ = label;
		mode_ = mode;

		if(check_label != "") {
			check_.assign(new gui::button(gui.video(),check_label,gui::button::TYPE_CHECK));
			check_->set_check(checked);
		}


		box_.assign(new gui::textbox(gui.video(),100,"",true,256,0.8,0.6));

		update_location(gui);
	}
예제 #11
0
void form_location_insert(char *input) {
    Location *location;
    Client *client;

    location = location_malloc();
    location->id = insert_location(location);
    printf("\n=======\nLOCANDO: \n\n");
    // Definir cliente
    do {
        printf("> A qual cliente quer locar? ");
        client = form_client_select(input);
    } while (client->id == NON_EXIST);
    puts_client(client);
    // Tem certeza?
    if (!be_sure(input)) {
        printf("Abortando locacao.\n\n");
        erase_location(location);
        free(location);
        return;
    }
    location->id_client = client->id;
    free(client);

    // Definir filmes
    if (form_items_insert(location, input) < 1) {
        free(location);
        erase_location(location);
        printf("Voce precisa inserir algum filme a locacao. Abortando locacao.\n\n");
        return;
    }
    // Imprimir resultado geral
    printf("\n>>>> SUMARIO DA LOCACAO <<<< \n\n");
    puts_location(location, TRUE);
    printf("-------------------------------------\n\n");

    if (update_location(location)) {
        printf("Locacao foi um sucesso.\n");
    } else {
        printf("Locacao nao foi completada corretamente!\n");
    }

    printf("\n=======\n");
    free(location);
}
예제 #12
0
void our_bot::update(){

    Mat roi_image;
    roi_image = image(location);

    GaussianBlur( roi_image, roi_image, Size( 3, 3 ), 0, 0 );
    
    cvtColor(roi_image, roi_image, CV_BGR2HSV);
    
    mask[0] = Mat::zeros(roi_image.rows,roi_image.cols,CV_8UC1);
    mask[1] = Mat::zeros(roi_image.rows,roi_image.cols,CV_8UC1);
    mask[2] = Mat::zeros(roi_image.rows,roi_image.cols,CV_8UC1);

    pick_color( roi_image,mask[0], basecolor );
    pick_color( roi_image,mask[1], lcolor );
    pick_color( roi_image,mask[2], rcolor );
   
	imshow("base",mask[0]);
	imshow("left",mask[1]);
	imshow("right",mask[2]);
    
    FindCenter();
    
   cvtColor(roi_image, roi_image, CV_HSV2BGR);

    if( front_center.x != 0 && back_center.x != 0 ){
        //Taking care for the relative position changes due to ROI.
        front_center = Point( front_center.x + location.x, front_center.y + location.y );
        back_center = Point( back_center.x + location.x, back_center.y + location.y );
        bot_center = Point( ( front_center.x + back_center.x ) / 2, ( front_center.y + back_center.y ) / 2 );
        update_location( location, bot_center );
        //        cout<<"bot found!!"<<endl;
    }
    else{
        expand_location( location );
    }

    limit_location_within_arena( location );

    //    cout<<"location = "<<location.x<<' '<<location.y
    //        <<' '<<location.width<<' '<<location.height<<endl;
    pos();
    orientation();
}
예제 #13
0
bool Soldier::update(){
    switch(state){
        case 'x': return false; break;
        case 's': return false; break;
        case 'm':{
            bool ans=update_location();
            if (ans==true){
                state='s';
                return true;
            }
            else{
                state='m';
                return false;
            }
            break;
            
        }
        case 'a':{
            double distx=(target->location.x-Soldier::location.x);
            double disty=(target->location.y-Soldier::location.y);
            if (fabs(distx) <= range && fabs(disty) <= range && target->is_alive()){
                cout << Soldier::display_code<<Soldier::id_num<<":Take that!"<<endl;
                    target->take_hit(attack_strength, this);
                return false;
            }
            else if(fabs(distx) <= range && fabs(disty) <= range &&!target->is_alive()){
                        cout<<Soldier::display_code<<Soldier::id_num<<":I win."<<endl;
                        state='s';
                        return 1;
                        break;
                    }
            else{
                cout<<Soldier::display_code<<Soldier::id_num<<":Target is out of range."<<endl;
                cout<<Soldier::display_code<<Soldier::id_num<<":Chaaaaarge."<<endl;
                state='s';
                return 1;
            }
        }
             default: return false;
        }
}
예제 #14
0
void form_location_devolution(char *input) {
    Location *location;

    // Antes de tudo, precisamos testar se há alguma locação no arquivo
    if (locations_file_is_empty()) {
        printf(EMPTY_ERROR, __FILE__, "locacao");
        return;
    }

    do {
        printf("\n=======\nDEVOLUCAO DE DVDs: \n\n");
        location = form_location_select(input);
        if (location->id == NON_EXIST) {
            free(location);
            return;
        }
        printf("\n>>>> SUMARIO DA LOCACAO <<<< \n\n");
        puts_location(location, TRUE);
        printf("-------------------------------------\n\n");
    } while (!be_sure(input));
    do {
        printf("> Deseja devolver todos os filme? [S]im ou [n]ao? ");
        read_string(input);
    } while (strcasecmp(input, "S") && strcasecmp(input, "N"));
    if (!strcasecmp(input, "S")) {
        printf("OK, agora resta pagar R$ %.2lf\n", get_total_to_pay(location));
        location_full_returned(location);
    } else {
        form_items_return(location, input);
        puts_items_by_location(location, FALSE);
        printf("OK, agora resta pagar R$ %.2lf\n", get_total_to_pay(location));
    }
    // Escrevendo no arquivo
    if (update_location(location)) {
        printf("Locacao atualizada com sucesso.\n");
    } else {
        printf("Locacao nao foi atualizada corretamente!\n");
    }
    printf("\n=======\n");
    free(location);
}
예제 #15
0
파일: gntfilesel.c 프로젝트: bf4/pidgin-mac
static void
gnt_file_sel_map(GntWidget *widget)
{
	GntFileSel *sel = GNT_FILE_SEL(widget);
	GntWidget *hbox, *vbox;

	if (sel->current == NULL)
		gnt_file_sel_set_current_location(sel, g_get_home_dir());

	vbox = gnt_vbox_new(FALSE);
	gnt_box_set_pad(GNT_BOX(vbox), 0);
	gnt_box_set_alignment(GNT_BOX(vbox), GNT_ALIGN_MID);

	/* The dir. and files list */
	hbox = gnt_hbox_new(FALSE);
	gnt_box_set_pad(GNT_BOX(hbox), 0);

	gnt_box_add_widget(GNT_BOX(hbox), sel->dirs);

	if (!sel->dirsonly) {
		gnt_box_add_widget(GNT_BOX(hbox), sel->files);
	} else {
		g_signal_connect(G_OBJECT(sel->dirs), "selection_changed", G_CALLBACK(file_sel_changed), sel);
	}

	gnt_box_add_widget(GNT_BOX(vbox), hbox);
	gnt_box_add_widget(GNT_BOX(vbox), sel->location);

	/* The buttons */
	hbox = gnt_hbox_new(FALSE);
	gnt_box_add_widget(GNT_BOX(hbox), sel->cancel);
	gnt_box_add_widget(GNT_BOX(hbox), sel->select);
	gnt_box_add_widget(GNT_BOX(vbox), hbox);

	gnt_box_add_widget(GNT_BOX(sel), vbox);
	orig_map(widget);
	update_location(sel);
}
예제 #16
0
Connection::Connection(boost::shared_ptr<Canvas>      canvas,
	                   boost::shared_ptr<Connectable> source,
	                   boost::shared_ptr<Connectable> dest,
                       uint32_t                       color,
                       bool                           show_arrowhead)
	: Gnome::Canvas::Group(*canvas->root())
	, _canvas(canvas)
	, _source(source)
	, _dest(dest)
	, _bpath(*this)
	, _path(gnome_canvas_path_def_new())
	, _handle(NULL)
	, _color(color)
	, _handle_style(HANDLE_NONE)
	, _selected(false)
	, _show_arrowhead(show_arrowhead)
{
	_bpath.property_width_units() = 2.0;
	set_color(color);

	update_location();
	raise_to_top();
}
예제 #17
0
bool Inspector::update() {
    switch (state) {
    case 'k': { //outbound
        bool ans=update_location();
        if (ans==true) {
            state='c';
            return true;
        }
        else
            return false;
        break;
    }
    case 'c': { //counting gold at mine outbound
        Gold_Mine* ptr1;
        for (list<Gold_Mine*>::iterator i=minelist2.begin(); i!=minelist2.end(); i++) {
            if ((*i)->location.x == this->location.x && (*i)->location.y == this->location.y )
                ptr1= *i;
        }
        goldout[subscript]=(ptr1->amount);
        cout << "This mine contains " << ptr1->amount << " Gold!" <<endl;
        subscript=subscript+1;
        int truesize=getdestinationssize();
        if (subscript<truesize) {
            setup_destination(destinations[subscript]);
            state='k';
        }
        else {//setup new destination
            subscript=(subscript-2);
            setup_destination(destinations[subscript]);
            state='j';
            cout << "Heading Back!"<<endl;
        }
        return false;
        break;
    }

    case 'j': { //inbound journey
        bool ans=update_location();
        if (ans==true) {
            state='l';
            return true;
        }
        else
            return false;
        break;
    }
    case 'l': { //counting gold at mine inbound
        Gold_Mine* ptr1;
        for (list<Gold_Mine*>::iterator i=minelist2.begin(); i!=minelist2.end(); i++) {
            if ((*i)->location.x == this->location.x && (*i)->location.y == this->location.y )
                ptr1= *i;
        }

        cout << "Amount of gold removed from the mine is " << goldout[subscript]-(ptr1->amount) << " gold!" <<endl;
        if (subscript>0) {
            subscript=subscript-1;
            setup_destination(destinations[subscript]);
            state='j';
        }
        else {
            cout <<"Inspection trip completed!" <<endl;
            state='s';
        }
        return false;
        break;
    }
    case 's': {
        state='s';
        return false;
        break;
    }
    case 'x': {
        return false;
        break;
    }
    }
    return true;
}
예제 #18
0
void form_location_update(char *input) {
    Location *location;
    Client *client;

    // Antes de tudo, precisamos testar se há alguma locação no arquivo
    if (locations_file_is_empty()) {
        printf(EMPTY_ERROR, __FILE__, "locacao");
        return;
    }

    printf("\n=======\nALTERANDO LOCACAO: \n\n");
    location = form_location_select(input);
    if (location->id == NON_EXIST) {
        free(location);
        return;
    }
    // Mostra o resultado da pesquisa
    puts_location(location, TRUE);
    // Tem certeza?
    if (!be_sure(input)) {
        printf("Abortando alteracao de locacao.\n\n");
        free(location);
        return;
    }
    // Modificando cliente
    do {
        printf("> Deseja modificar cliente? [S]im ou [n]ao? ");
        read_string(input);
    } while (strcasecmp(input, "S") && strcasecmp(input, "N"));
    if (!strcasecmp(input, "S")) {
        do {
            printf("> Qual cliente? ");
            client = form_client_select(input);
        } while (client->id == NON_EXIST);
        location->id_client = client->id;
        free(client);
    }
    do {
        printf("> Deseja remover filme? [S]im ou [n]ao? ");
        read_string(input);
    } while (strcasecmp(input, "S") && strcasecmp(input, "N"));
    if (!strcasecmp(input, "S")) {
        // Listar todos os filmes da locação
        puts_items_by_location(location, FALSE);
        // Selecionar um ou mais ítens.
        form_items_remove(location, input);
        // Listar novamente
        puts_items_by_location(location, FALSE);
    }
    do {
        printf("> Deseja adicionar filme? [S]im ou [n]ao? ");
        read_string(input);
    } while (!strcasecmp(input, "S") && !strcasecmp(input, "N"));
    if (!strcasecmp(input, "S")) {
        // Selecionar um ou mais ítens.
        form_items_insert(location, input);
        // Listar novamente
        puts_items_by_location(location, FALSE);
    }

    // Escrevendo no arquivo
    if (update_location(location)) {
        printf("Locacao atualizada com sucesso.\n");
    } else {
        printf("Locacao nao foi atualizada corretamente!\n");
    }
    printf("\n=======\n");
    free(location);
}
예제 #19
0
bool Miner::update() {
    switch (state) {
    case 's': {
        state='s';
        return false;
        break;
    }
    case 'm': {
        bool ans=update_location();
        if (ans==true) {
            state='s';
            return true;
        }
        else {
            state='m';
            return false;
        }
        break;
    }
    case 'o': {
        bool ans=update_location();
        if (ans==true) {
            state='g';
            return true;
        }
        else {
            state='o';
            return false;
        }
        break;
    }
    case 'g': {
        amount=mine->dig_gold();
        cout << display_code<< get_id()<< ": Got " << amount << " gold." << endl;
        setup_destination(home->get_location());
        state='i';
        return true;
        break;
    }
    case 'i': {
        bool ans=update_location();
        if (ans==true) {
            state='d';
            return true;
        }
        else {
            state='i';
            return false;
        }
        break;
    }
    case 'd': {
        cout << display_code << get_id() << ": Deposit " << amount << " of gold." << endl;
        home->deposit_gold(amount);
        amount=0;//print out deposit amount

        if (mine->is_empty()==true) {
            state='s';
            cout<< display_code << get_id() << ": More work?" << endl;
            return true;//stop miner and ask for more work
        }
        else {
            setup_destination(mine->get_location());//setup new destination
            state='o';
            cout << display_code<< get_id() << ": Going back for more." << endl;
            return true;
        }
        break;
    }
    case 'x': {
        return false;
    }
    default:
        return false;
    }
}
예제 #20
0
파일: Lexer.cpp 프로젝트: c4wrd/Qwak
    /*
     * Starts the build process for generating our token queue. Will return a boolean, true signifying a successful
     * queue generation, false should we have some syntactical issues in our input stream
     */
    bool Lexer::build_tokens() {
        char current_char;

        this->m_tokenQueue.push(Token::make_token(token_identifier::FIRST_TOKEN, this->get_cur_loc()));

        while (this->f_fileStream.good()) {
            current_char = get();
            update_location(current_char);
            /*
             * Punctuation
             */
            switch (current_char) {
                case ' ':
                    continue;
                case '\t':
                    continue;
                case '\n':
                    emit(token_identifier::NEW_LINE);
                    break;
                case '+': {
                    emit(token_identifier::ADDITION_OP);
                    break;
                }

                case '-': {
                    emit(token_identifier::SUBTRACTION_OP);
                    break;
                }

                case ';': {
                    emit(token_identifier::SEMICOLON);
                    break;
                }

                case '(': {
                    emit(token_identifier::LEFT_PAREN);
                    break;
                }

                case ')': {
                    emit(token_identifier::RIGHT_PARAN);
                    break;
                }

                case '=': {
                    if (peek() == '=') {
                        skip_char();
                        emit(token_identifier::EQUALITY_OP);
                    } else {
                        emit(token_identifier::ASSIGNMENT_OP);
                    }
                    break;
                }

                case '&': {
                    emit(token_identifier::AND_OP);break;
                }

                case '|': {
                    if (peek() == '|') {
                        emit(token_identifier::OR_OP);
                        skip_char();
                    } else {
                        emit(token_identifier::INVALID_TOKEN);
                        skip_to('\n');                                       // missing matching bar
                    }
                    break;
                }

                case '<': {
                    if (peek() == '=') {
                        emit(token_identifier::LESS_THAN_EQ);
                        skip_char();
                    } else {
                        emit(token_identifier::LESS_THAN);
                    }
                    break;
                }

                case '>': {
                    if (peek() == '=') {
                        emit(token_identifier::GREATER_THAN_EQ);
                        skip_char();
                    } else {
                        emit(token_identifier::GREATER_THAN);
                    }
                    break;
                }

                case '!': {
                    if (peek() == '!') {
                        emit(token_identifier::NOT_EQ);
                        skip_char();
                    } else {
                        emit(token_identifier::INVALID_TOKEN);
                        skip_to('\n');
                    }
                    break;
                }
            }


            /*
             * Keywords and identifiers
             */
            if (isalpha(current_char) || current_char == '_') {
                std::string string_val;
                string_val.reserve(16);
                string_val += current_char;

                current_char = peek();
                while ((isalpha(current_char) || current_char == '_') && this->f_fileStream.good()) {
                    string_val += current_char;
                    skip_char();
                    current_char = peek();
                }

                auto type = Keywords::get_token_identifier(string_val);
                if (type == IDENTIFIER) {
                    this->m_tokenQueue.push(Token::create_identifier(this->get_cur_loc(), string_val));
                } else {
                    emit(type);
                }
            }

            /*
             * Integers
             */
            if (isdigit(current_char)) {
                std::string num_val;
                num_val.reserve(12);
                num_val += current_char;

                current_char = peek();
                while(isdigit(current_char) && this->f_fileStream.good()) {
                    num_val += current_char;
                    skip_char();
                    current_char = peek();
                }

                this->m_tokenQueue.push(Token::create_integer(this->get_cur_loc(), num_val));
            }

            /*
             * String literals
             */
            if (current_char == '\"') {
                std::string string_val;
                string_val.reserve(16);

                current_char = peek();
                while (current_char != '\n' && current_char != '"' && this->f_fileStream.good()) {
                    string_val += current_char;
                    skip_char();
                    current_char = peek();
                }

                if (current_char == '\n')
                {
                    throw ERROR_NON_TERMINATED_STRING;
                }

                if (current_char == '"')
                {
                    skip_char();
                }

                this->m_tokenQueue.push(Token::create_string(this->get_cur_loc(), string_val));
            }
        }

        this->m_tokenQueue.push(Token::make_token(token_identifier::END_OF_FILE, this->get_cur_loc()));
        this->m_tokenQueue.push(Token::make_token(token_identifier::LAST_TOKEN, this->get_cur_loc()));
        return true;
    }