static void signal_quit(int sig) { config_timelapse_save_status(); if (pikrellcam.config_modified) config_save(pikrellcam.config_file); display_quit(); log_printf("quit signal received - exiting!\n"); exit(0); }
void command_process(char *command_line) { VideoCircularBuffer *vcb = &video_circular_buffer; Command *cmd; char command[64], args[128], buf[32], *path; int i, n; if (!command_line || *command_line == '\0') return; n = sscanf(command_line, "%63s %[^\n]", command, args); if (n < 1 || command[0] == '#') return; for (cmd = NULL, i = 0; i < COMMAND_SIZE; cmd = NULL, ++i) { cmd = &commands[i]; if (!strcmp(command, cmd->name)) { if (cmd->n_args != n - 1) { log_printf("Wrong number of args for command: %s\n", command); return; } break; } } if (!cmd) { if ( !config_set_option(command, args, FALSE) && !mmalcam_config_parameter_set(command, args, TRUE) ) log_printf("Bad command: [%s] [%s]\n", command, args); return; } if (cmd->code != display_cmd) log_printf("command_process: %s\n", command_line); if (cmd->code < display_cmd && !display_is_default()) { display_set_default(); return; } switch (cmd->code) { case record: pthread_mutex_lock(&vcb->mutex); if (config_boolean_value(args) == TRUE) { if (vcb->pause) vcb->pause = FALSE; else { if (vcb->state == VCB_STATE_MOTION_RECORD) video_record_stop(vcb); video_record_start(vcb, VCB_STATE_MANUAL_RECORD_START); } } else video_record_stop(vcb); pthread_mutex_unlock(&vcb->mutex); break; case record_pause: /* Can pause manual record only. Because of event_gap/capture | times, I'm not even sure what it would mean to pause a | motion record. */ pthread_mutex_lock(&vcb->mutex); if (vcb->state == VCB_STATE_MANUAL_RECORD) vcb->pause = vcb->pause ? FALSE : TRUE; else vcb->pause = FALSE; pthread_mutex_unlock(&vcb->mutex); break; case still: snprintf(buf, sizeof(buf), "%d", pikrellcam.still_sequence); path = media_pathname(pikrellcam.still_dir, pikrellcam.still_filename, 'N', buf, '\0', NULL); pikrellcam.still_sequence += 1; still_capture(path); free(path); break; case tl_start: if ((n = atoi(args)) < 1) n = 0; time_lapse.activated = TRUE; time_lapse.on_hold = FALSE; if (!time_lapse.event && n > 0) { time_lapse.sequence = 0; ++time_lapse.series; time_lapse.event = event_add("timelapse", pikrellcam.t_now, n, timelapse_capture, NULL); } else if (n > 0) /* Change the period */ { time_lapse.event->time += (n - time_lapse.period); time_lapse.event->period = n; } if (n > 0) time_lapse.period = n; /* n == 0 just sets on_hold FALSE */ config_timelapse_save_status(); break; case tl_hold: config_set_boolean(&time_lapse.on_hold, args); config_timelapse_save_status(); break; case tl_end: if (time_lapse.activated) { event_remove(time_lapse.event); time_lapse.event = NULL; time_lapse.activated = FALSE; time_lapse.on_hold = FALSE; config_timelapse_save_status(); exec_no_wait(pikrellcam.on_timelapse_end_cmd, NULL); } break; case tl_inform_convert: if (!strcmp(args, "done")) { event_remove(time_lapse.inform_event); dup_string(&time_lapse.convert_name, ""); time_lapse.convert_size = 0; } else { dup_string(&time_lapse.convert_name, args); time_lapse.inform_event = event_add("tl_inform_convert", pikrellcam.t_now, 5, timelapse_inform_convert, NULL); } break; case tl_show_status: config_set_boolean(&time_lapse.show_status, args); break; case display_cmd: display_command(args); break; case motion_cmd: motion_command(args); break; case motion_enable: n = motion_frame.motion_enable; config_set_boolean(&motion_frame.motion_enable, args); if (n && !motion_frame.motion_enable) { pthread_mutex_lock(&vcb->mutex); if (vcb->state == VCB_STATE_MOTION_RECORD) video_record_stop(vcb); pthread_mutex_unlock(&vcb->mutex); } break; case save_config: config_save(pikrellcam.config_file); break; case quit: config_timelapse_save_status(); if (pikrellcam.config_modified) config_save(pikrellcam.config_file); display_quit(); exit(0); break; default: log_printf("command in table with no action!\n"); break; } }
void gh_player::display (void) { GH_FUNCTION() gh_thing *player_thing = thing; gh_level *level = player_thing->level; if (!level) { GH_THROW("no level?"); } if (game->want_to_enter_level_editor_mode) { enter_level_editor(); } if (game->paused) { display_pause(); return; } if (game->quit_screen) { display_quit(); return; } if (game->help_screen) { if (level->is_editing) { display_editor_help(); } else { display_help(); } return; } if (game->info_screen) { display_info(); return; } // // Is the level ending soon? // if (end_in_ticks) { // // Allow the monsters to run around a bit before we end. // level->freeze_things = false; if (gh_global::debug) { GH_LOG(""); GH_LOG("*** Ending in ticks " + tostring(end_in_ticks) + " ***"); GH_LOG(""); } // // Move the player off of the level so they can't be killed. // if (player_thing->is_on_map) { player_thing->collect_followers(); level->map.pop(player_thing); } // // Allow enough time for things like explosions to vanish. // end_in_ticks--; if (!end_in_ticks) { gh_global::done = true; // // Ensure we don't hit this condition twice and stop // the hi score screen from running. // end_in_ticks--; } } if (player_thing->is_dead) { // // Allow the monsters to move // level->freeze_things = false; // // Allow the player's explosion to finish before we end // the level. // if (end_in_ticks == 0) { end_in_ticks = 50; GH_LOG(""); GH_LOG("*** Ending level soon ***"); GH_LOG(""); } } if (!level->is_level_completed) { // // Don't allow the player to quit whilst the game is ending! // if (!player_thing->is_dead) { // // And don't allow them to move when dead! // level->tick_hero(); } } level->tick_things(); level->tick(); display_game(); level->handle_dead_all(); if (level->is_level_completed) { // // If the end of the level, let the explosions complete. // if (end_in_ticks == 0) { end_in_ticks = 10; // // If the end of the game, allow for a long ending. // if (level->is_last_level) { end_in_ticks = 100; } } } if (ignore_game_start_events_ticks > 0) { ignore_game_start_events_ticks--; } }