View::View(QWidget *parent): QGraphicsView(parent) { setGeometry(300,300,GS_WIDTH,GS_HEIGHT); menu_scene = new GraphicMenu(-width()/2,-height()/2,width(),height(),this); board_scene = new GraphicBoard(-width()/2,-height()/2,width(),height(),this); QIcon icon(QPixmap(":/Graphic_source/icon.png")); setWindowIcon(icon); setWindowTitle("Pentago"); setFixedSize(this->size());//TODO:equally resize setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); setCacheMode(QGraphicsView::CacheBackground); setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); connect(menu_scene, SIGNAL(New_game_selected(int)), this, SIGNAL(New_game(int))); connect(menu_scene, SIGNAL(Join_game_selected(std::string)), this, SIGNAL(Join_game(std::string))); connect(menu_scene, SIGNAL(Host_game_selected(std::string)), this, SIGNAL(Host_game(std::string))); connect(menu_scene, SIGNAL(Exit_game_pressed()), this, SLOT(close())); connect(menu_scene, SIGNAL(Load_game_selected(std::string)),this,SIGNAL(Load_game(std::string))); connect(board_scene, SIGNAL(quadrant_rotated(IView::quadrant,IView::turn)), this, SIGNAL(Rotate(IView::quadrant,IView::turn))); connect(board_scene, SIGNAL(Stone_clicked(int, int)), this, SIGNAL(Put_stone(int,int))); connect(board_scene, SIGNAL(leave_game()),this,SLOT(on_leave_game())); connect(board_scene, SIGNAL(save_game(QString)),this,SLOT(on_save_game(QString))); connect(board_scene, SIGNAL(message_sended(QString)), this, SLOT(on_msg_sended(QString))); connect(menu_scene, SIGNAL(game_go_to_start()),board_scene, SLOT(clean_board())); connect(menu_scene, SIGNAL(game_go_to_start()),board_scene, SLOT(clean_log())); Set_control_settings(View::MENU);//it must be called in presenter after view constructing }
int main() { unsigned int menu; int quantity; int i; user profile; user blank; user *profiles = NULL; setlocale(LC_ALL, "Portuguese"); system("cls || clear"); system("printf \'\\033[8;45;160t\'"); clean_temps(); sleep(2); system("cls || clear"); interface(); system("cls || clear"); clean_log(); clean_domain_csv(); do { menu_interface(); printf("Escolha uma opção do menu: "); scanf("%u", &menu); while (menu > 5 || menu <= 0) { printf("Opção não reconhecida!!\n"); sleep(2); system("cls || clear"); menu_interface(); printf("Escolha uma opção do menu: "); scanf("%u", &menu); } fflush_in(); switch (menu) { case 1: profile = read_new_user(); sleep(2); system("cls || clear"); printf("Informações do novo usuário: \n"); show_user(profile); make_domain_csv(profile); make_log(profile); fflush_in(); getchar(); system("cls || clear"); break; case 2: printf("Quantos usuários deseja cadastrar?: "); scanf("%d", &quantity); fflush_in(); profiles = malloc(quantity * sizeof(user)); for (i = 0; i < quantity; ++i) { blank = make_blank_user(blank); profiles[i] = blank; } for (i = 0; i < quantity; ++i) { profile = read_new_user(); sleep(2); system("cls || clear"); printf("Informações do novo usuário: \n"); show_user(profile); fflush_in(); profiles[i] = profile; make_domain_csv(profile); make_log(profile); sleep(2); system("cls || clear"); } printf("Listando usuários criados: \n"); for (i = 0; i < quantity; ++i) { show_user(profiles[i]); printf("\n"); } printf("Todos os arquivos dos usuários estão em doc/log.txt!!\n"); printf("Aperte ENTER para continuar a execução"); getchar(); system("cls || clear"); break; case 3: system("cls || clear"); show_register_users(); break; case 4: printf("Terminando a execução...\n"); printf("Obrigado por usar o sistema!!!\n\n"); break; default: printf("Opção não válida!\n"); break; } } while (menu != 4); return 0; }