int BC_FileBox::resize_event(int w, int h) { draw_background(0, 0, w, h); flash(); // OK button handles resize event itself // ok_button->reposition_window(ok_button->get_x(), // h - (get_h() - ok_button->get_y())); // cancel_button->reposition_window(w - (get_w() - cancel_button->get_x()), // h - (get_h() - cancel_button->get_y())); if(usethis_button) usethis_button->reposition_window(w / 2 - 50, h - (get_h() - usethis_button->get_y())); if(filter_popup) filter_popup->reposition_window(w - (get_w() - filter_popup->get_x()), h - (get_h() - filter_popup->get_y()), w - 30); if(filter_text) filter_text->reposition_window(filter_text->get_x(), h - (get_h() - filter_text->get_y()), w - (get_w() - filter_text->get_w()), 1); directory_title->reposition_window( directory_title->get_x(), directory_title->get_y(), get_w() - recent_popup->get_w() - 20, 1); recent_popup->reposition_window( directory_title->get_x() + directory_title->get_w(), directory_title->get_y(), directory_title->get_w() + recent_popup->get_w(), recent_popup->get_h()); textbox->reposition_window(textbox->get_x(), h - (get_h() - textbox->get_y()), w - (get_w() - textbox->get_w()), 1); listbox->reposition_window(listbox->get_x(), listbox->get_y(), w - (get_w() - listbox->get_w()), h - (get_h() - listbox->get_h())); icon_button->reposition_window(w - (get_w() - icon_button->get_x()), icon_button->get_y()); text_button->reposition_window(w - (get_w() - text_button->get_x()), text_button->get_y()); folder_button->reposition_window(w - (get_w() - folder_button->get_x()), folder_button->get_y()); reload_button->reposition_window(w - (get_w() - reload_button->get_x()), reload_button->get_y()); delete_button->reposition_window(w - (get_w() - delete_button->get_x()), delete_button->get_y()); updir_button->reposition_window(w - (get_w() - updir_button->get_x()), updir_button->get_y()); set_w(w); set_h(h); get_resources()->filebox_w = get_w(); get_resources()->filebox_h = get_h(); return 1; }
void pulse(unsigned char t) { if (t > 0) { set_h(hi); set_l(lo); OCR2B = t-1; TCNT2 = 0xFF; TCCR2A = (1 << COM2B1) | (0 << COM2B0) | (1 << WGM21) | (1 << WGM20); TCCR2B = (0 << WGM22) | 0x02; //i2c[1] = t; } }
void Babar::load_anim (int age) { #ifdef DEBUG_COLL age = 0; #endif if ( m_spriteGrid ) { m_spriteGrid->to_delete(); } //TODO (Guillaume) var for the path m_spriteGrid = gGraphics->get_sprites_manager()->addGrid ("../res/pic/players/babar_states.png"); m_spriteGrid->setPictures (0, 1, 2); m_spriteGrid->set_pos (position() ); set_h (m_spriteGrid->h() ); set_w (m_spriteGrid->w() ); m_last_pos.x = 0; m_last_pos.y = 0; }
void Babar::update_state() { if (locked() ) m_lock--; if (m_lock == 0) { unlock(); } if (!Keyboard::GetInstance()->time_pressed (k_jump) ) m_jump = false; if (m_jump) { if ( Keyboard::GetInstance()->time_pressed (k_jump) > 1 ) { m_ready_double_jump = true; if ( Keyboard::GetInstance()->time_pressed (k_jump) > JUMP_TIME) { m_jump = false; Keyboard::GetInstance()->disable_key (k_jump); } } } update_direction(); if ( CollisionsManager::is_down_coll (gCollision->get_matrix()->down_collision_type (position() ) ) ) { interrupt_jump(); } if (can_fire() ) { m_fire = true; gProj->add_proj (fire_old(), PLAYER1); m_fire_phase = 0; } else { m_fire = false; m_fire_phase++; } if (can_crouch() ) { crouch(); } else { /* si on se releve */ if ( m_crouch_time ) { interrupt_crouch(); } } if (can_jump() ) jump(); if (can_double_jump() ) double_jump(); if (can_go_down() ) go_down(); if (m_invincible > 0) { m_invincible --; if (!locked() ) { if ( m_invincible % 2) { m_spriteGrid->no_pic(); } else { m_spriteGrid->set_pic(); } } } m_weapons_armory.update(); if (Keyboard::GetInstance()->time_pressed (k_prev_weapon) == 1) m_weapons_armory.previous_weapon(); if (Keyboard::GetInstance()->time_pressed (k_next_weapon) == 1) m_weapons_armory.next_weapon(); switch (get_state() ) { case STATIC: m_spriteGrid->setPictures (0); break; case WALK: m_spriteGrid->setPictures (1, 0, 2, 0); break; case JUMP: m_spriteGrid->setPictures (1); break; case CROUCH: m_spriteGrid->setPictures (12); break; case CROUCH_WALKING: m_spriteGrid->setPictures (13, 12, 14, 12); break; default: m_spriteGrid->setPictures (0); break; } //m_spriteGrid->change_anim(get_state(), m_dir, Keyboard::GetInstance()->key_down(k_fire)); m_spriteGrid->set_pos (position() ); set_h (m_spriteGrid->h() ); set_w (m_spriteGrid->w() ); }
void MainWindow::choose_file_button_clicked() { try { QString fileName = QFileDialog::getOpenFileName(this,QString::fromUtf8("Choose File"),QDir::currentPath(),"Text(*.txt)"); if (fileName.length() != 0) { // ДАЛЕЕ ОЧИСТКА ЗНАЧЕНИЙ!!! clear_data(); clear_lines(); ui->fileName->setText(fileName); QFile my_file(fileName); my_file.open(QIODevice::ReadOnly); if (my_file.isOpen()) while (!my_file.atEnd()) { QString exmpl = changeOnDoTA(my_file.readLine()); double obj = exmpl.toDouble(); started_data.push_back(obj); } try { set_average_data(); // qDebug() << max_x << " " << min_x; set_square_deviation(); set_Sx(); // for (int i = 0; i < started_data.size(); i++) // qDebug() << started_data[i]; set_r(); // КИДАЕТ ВНУТРЕННИЙ ЭКСЕПШЕН! set_h(); fill_intervals(); set_f(); set_middle_value(); set_middle_value2(); set_average_of_intervals(); set_si(); set_n_i(); set_xi_sq(); choose_quantile(); // qDebug() << "BEgin"; // for (int i = 0;i < started_data.size();i++) // qDebug() << started_data[i]; // qDebug() << "END"; set_lines(); for (int i = 0; i < intervals.size();i++) { for (int j = 0; j < intervals[i].size();j++) qDebug() << intervals[i][j]; qDebug() << "end_line"; } // check_result(); is_chButton_clicked_flag = true; my_file.close(); } catch(std::exception &e){ clear_data(); clear_lines(); is_chButton_clicked_flag = false; QMessageBox::critical(this,"Not Valid!!!",e.what()); } } else { throw (std::invalid_argument("Choose txt File!")); } } catch(std::exception& e) { clear_data(); clear_lines(); is_chButton_clicked_flag = false; // QMessageBox::critical(this, "Error!",e.what()); } }
void switch_phase(void) { switch(phase) { case 0: sense = 0xC2; ACSR = (ACSR & ~0x03) | 0x03; clr_h(0x04); set_h(0x01); hi = 0x01; lo = 0x02; phase = 1; break; case 1: sense = 0xC1; ACSR = (ACSR & ~0x03) | 0x02; clr_l(0x02); set_l(0x04); hi = 0x01; lo = 0x04; phase = 2; break; case 2: sense = 0xC0; ACSR = (ACSR & ~0x03) | 0x03; clr_h(0x01); set_h(0x02); hi = 0x02; lo = 0x04; phase = 3; break; case 3: sense = 0xC2; ACSR = (ACSR & ~0x03) | 0x02; clr_l(0x04); set_l(0x01); hi = 0x02; lo = 0x01; phase = 4; break; case 4: sense = 0xC1; ACSR = (ACSR & ~0x03) | 0x03; clr_h(0x02); set_h(0x04); hi = 0x04; lo = 0x01; phase = 5; break; case 5: sense = 0xC0; ACSR = (ACSR & ~0x03) | 0x02; clr_l(0x01); set_l(0x02); hi = 0x04; lo = 0x02; phase = 0; break; default: break; } //i2c[2] = phase; }
bool Dstar::search(Graph* graph, const Position& start, const Position& goal) { auto s = graph->get_state(start); s->set_rhs(MAX_WEIGHT); s->set_g(MAX_WEIGHT); auto g = graph->get_state(goal); auto g_elem = std::find(open_.begin(), open_.end(), g); if(g_elem == open_.end()) { g->set_rhs(0); g->set_g(MAX_WEIGHT); open_.push_back(g); } g->set_h(graph->get_h(start, g->get_position())); auto current = g; auto search_limit = graph->get_states().size() * 2; std::size_t cnt = 0; while((current->get_key() < s->get_key()) || (s->rhs() != s->g())) { if(cnt > search_limit) { emit report_exp_dst(cnt); return false; } ++cnt; current->set_expanded(); if(current->g() > current->rhs()) { current->set_g(current->rhs()); for(auto& pred : graph->get_succ(current)) // succ = pred update_state(pred, start, goal, graph); } else { current->set_g(MAX_WEIGHT); update_state(current, start, goal, graph); for(auto& pred : graph->get_succ(current)) // succ = pred update_state(pred, start, goal, graph); } auto it_elem = std::find(open_.begin(), open_.end(), current); if(it_elem != open_.end()) open_.erase(it_elem); current = *(std::min_element(open_.begin(), open_.end(), [](State * l, State * r) { return l->get_key() < r->get_key(); })); } emit report_exp_dst(cnt); return true; }