static void print_welcome(void) { _cleanup_free_ char *pretty_name = NULL; const char *os_release = NULL; static bool done = false; int r; if (done) return; os_release = prefix_roota(arg_root, "/etc/os-release"); r = parse_env_file(os_release, NEWLINE, "PRETTY_NAME", &pretty_name, NULL); if (r == -ENOENT) { os_release = prefix_roota(arg_root, "/usr/lib/os-release"); r = parse_env_file(os_release, NEWLINE, "PRETTY_NAME", &pretty_name, NULL); } if (r < 0 && r != -ENOENT) log_warning_errno(r, "Failed to read os-release file: %m"); printf("\nWelcome to your new installation of %s!\nPlease configure a few basic system settings:\n\n", isempty(pretty_name) ? "Linux" : pretty_name); press_any_key(); done = true; }
// 블럭 상태 및 스테이지 업뎃 void Tetris::Update() { int key = KeyInput(); switch( stage ) { case INIT : press_any_key( key ); break; case READY : level_select( key ); break; case RUNNING : m_block->Move( key ); // 블럭이 바닥이나 다른 블럭에 닿았다면 합침 if( m_block->GetBlockState() == 2 ) merge_block( m_block->GetBlockX(), m_block->GetBlockY() ); // 꽉 찬 라인이 있는지 확인 m_full_line_num = check_full_line(); if( m_full_line_num != 0 ) full_line_Set(); if( stage_data[m_level].clear_line == m_line ) { ++m_level; if( m_level >= MAX_STAGE ) { stage = SUCCESS; } m_line = 0; } // 게임 오버~ if( GameOver() ) stage = FAILED; break; case SUCCESS: case FAILED: if( key == 'y' || key == 'Y' ) { stage = READY; Init(); } if( key == 'n' || key == 'N' ) stage = RESULT; break; case RESULT: m_bIsGameOver = true; break; } }
int main(int argc, char **argv) { char *filename; FILE *fd; int left = (9*9)*9; int count=0; if (argc == 2) { filename = argv[1]; } else { filename = "fields.sud"; } bf_backups = malloc(sizeof(struct bf_backups)); if (!(fd = fopen(filename, "r"))) { printf("error opening file\n"); exit(1); } if(readfield(fd)) { printf("error reading field\n"); exit(1); } if (initialize()) exit(1); fill_all(); check_filled(); printfield(wfield, 1); bruteforced = 0; /* main loop */ while (left > 0) { check_validity(); solve_run(&count); check_validity(); left = get_left(); count++; } if (final_check()) { winprintf(wtext, "\n\rSolved successfully\n\r"); } else { winprintf(wtext, "\n\rThere are still some errors\n\r"); } printfield(wfield, 1); press_any_key(); endwin(); return(0); }
static int show_menu(char **x, unsigned n_columns, unsigned width, unsigned percentage) { unsigned n, per_column, i, j; unsigned break_lines, break_modulo; assert(n_columns > 0); n = strv_length(x); per_column = (n + n_columns - 1) / n_columns; break_lines = lines(); if (break_lines > 2) break_lines--; /* The first page gets two extra lines, since we want to show * a title */ break_modulo = break_lines; if (break_modulo > 3) break_modulo -= 3; for (i = 0; i < per_column; i++) { for (j = 0; j < n_columns; j ++) { _cleanup_free_ char *e = NULL; if (j * per_column + i >= n) break; e = ellipsize(x[j * per_column + i], width, percentage); if (!e) return log_oom(); printf("%4u) %-*s", j * per_column + i + 1, width, e); } putchar('\n'); /* on the first screen we reserve 2 extra lines for the title */ if (i % break_lines == break_modulo) { if (!press_any_key()) return 0; } } return 0; }
static void print_welcome(void) { _cleanup_free_ char *pretty_name = NULL; static bool done = false; int r; if (done) return; r = parse_os_release(arg_root, "PRETTY_NAME", &pretty_name, NULL); if (r < 0) log_full_errno(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r, "Failed to read os-release file, ignoring: %m"); printf("\nWelcome to your new installation of %s!\nPlease configure a few basic system settings:\n\n", isempty(pretty_name) ? "Linux" : pretty_name); press_any_key(); done = true; }