示例#1
0
void IAGSEngine::PollSystem () {
  
  NEXT_ITERATION();
  domouse(DOMOUSE_NOCURSOR);
  update_polled_stuff(true);
  int mbut = mgetbutton();
  if (mbut > NONE)
    pl_run_plugin_hooks (AGSE_MOUSECLICK, mbut);

  if (rec_kbhit()) {
    int kp = rec_getch();
    if (kp == 0) kp = rec_getch()+300;
    pl_run_plugin_hooks (AGSE_KEYPRESS, kp);
  }

}
示例#2
0
int dxmedia_play_video(const char* filename, bool pUseSound, int canskip, int stretch) {
    HRESULT hr;

    useSound = pUseSound;
    ghWnd = win_get_window();

    CoInitialize(NULL);

    if (!useSound)
        update_polled_stuff();

    hr = RenderFileToMMStream(filename);
    if (FAILED(hr)) {
        ExitCode();
        CoUninitialize();
        return -1;
    }

    if (!useSound)
        update_polled_stuff();

    hr = InitRenderToSurface();
    if (FAILED(hr)) {
        ExitCode();
        CoUninitialize();
        return -1;
    }

    newWidth = vscreen->w;
    newHeight = vscreen->h;

    if ((stretch == 1) || (vscreen->w > screen->w) || (vscreen->h > screen->h)) {
        // If they want to stretch, or if it's bigger than the screen, then stretch
        float widthRatio = (float)vscreen->w / (float)screen->w;
        float heightRatio = (float)vscreen->h / (float)screen->h;

        if (widthRatio > heightRatio) {
            newWidth = vscreen->w / widthRatio;
            newHeight = vscreen->h / widthRatio;
        }
        else {
            newWidth = vscreen->w / heightRatio;
            newHeight = vscreen->h / heightRatio;
        }
    }

    //Now set the multimedia stream to RUN
    hr = g_pMMStream->SetState(STREAMSTATE_RUN);
    g_bAppactive = TRUE;

    if (FAILED(hr)) {
        sprintf(lastError, "Unable to play stream: 0x%08X", hr);
        ExitCode();
        CoUninitialize();
        destroy_bitmap (vscreen);
        return -1;
    }
    // in case we're not full screen, clear the background
    clear(screen);

    currentlyPlaying = true;

    gfxDriver->ClearDrawList();
    BITMAP *savedBackBuffer = gfxDriver->GetMemoryBackBuffer();
    gfxDriver->SetMemoryBackBuffer(screen);

    while ((g_bAppactive) && (!want_exit)) {

        while (currentlyPaused) ;

        next_iteration();
        RenderToSurface(vscreen);
        //Sleep(0);
        if (rec_kbhit()) {
            int key = rec_getch();

            if ((canskip == 1) && (key == 27))
                break;
            if (canskip >= 2)
                break;
        }
        if ((rec_mgetbutton() >= 0) && (canskip == 3))
            break;
    }

    dxmedia_abort_video();

    gfxDriver->SetMemoryBackBuffer(savedBackBuffer);

    return 0;
}
示例#3
0
int find_route_dijkstra(int fromx, int fromy, int destx, int desty)
{
  int i, j;

  // This algorithm doesn't behave differently the second time, so ignore
  if (leftorright == 1)
    return 0;

  for (i = 0; i < wallscreen->h; i++)
    memset(&beenhere[i][0], 0xff, wallscreen->w * BEENHERE_SIZE);

  round_down_coords(fromx, fromy);
  beenhere[fromy][fromx] = 0;

  int temprd = destx, tempry = desty;
  round_down_coords(temprd, tempry);
  if ((temprd == fromx) && (tempry == fromy)) {
    // already at destination
    pathbackstage = 0;
    return 1;
  }

  int allocsize = int (wallscreen->w) * int (wallscreen->h) * sizeof(int);
  int *parent = (int *)malloc(allocsize);
  int min = 999999, cheapest[40], newcell[40], replace[40];
  int *visited = (int *)malloc(MAX_TRAIL_LENGTH * sizeof(int));
  int iteration = 1;
  visited[0] = fromy * wallscreen->w + fromx;
  parent[visited[0]] = -1;

//  write_log("Pathfind starting");
  int granularity = 3, newx = -1, newy, foundAnswer = -1, numreplace;
  int changeiter, numfound, adjcount;
  int destxlow = destx - MAX_GRANULARITY;
  int destylow = desty - MAX_GRANULARITY;
  int destxhi = destxlow + MAX_GRANULARITY * 2;
  int destyhi = destylow + MAX_GRANULARITY * 2;
  int modifier = 0;
  int totalfound = 0;
  int DIRECTION_BONUS = 0;

  update_polled_stuff();

  while (foundAnswer < 0) {
    min = 29999;
    changeiter = iteration;
    numfound = 0;
    numreplace = 0;

    for (int n = 0; n < iteration; n++) {
      if (visited[n] == -1)
        continue;

      i = visited[n] % wallscreen->w;
      j = visited[n] / wallscreen->w;
      granularity = walk_area_granularity[wallscreen->line[j][i]];
      adjcount = 1;

//    char tempb[200]; sprintf(tempb, "checking: %d,%d\n",i,j); write_log(tempb);
      if (i >= granularity) {
        modifier = (destx < i) ? DIRECTION_BONUS : 0;
        CHECK_MIN(i - granularity, j)
      }

      if (j >= granularity) {
        modifier = (desty < j) ? DIRECTION_BONUS : 0;
        CHECK_MIN(i, j - granularity)
      }

      if (i < wallscreen->w - granularity) {
        modifier = (destx > i) ? DIRECTION_BONUS : 0;
        CHECK_MIN(i + granularity, j)
      }
示例#4
0
void play_theora_video(const char *name, int skip, int flags)
{
  apeg_set_display_depth(bitmap_color_depth(screen));
  // we must disable length detection, otherwise it takes ages to start
  // playing if the file is large because it seeks through the whole thing
  apeg_disable_length_detection(TRUE);
  apeg_enable_framedrop(TRUE);
  update_polled_stuff();

  stretch_flc = (flags % 10);
  canabort = skip;
  apeg_ignore_audio((flags >= 10) ? 1 : 0);

  int videoWidth, videoHeight;
  APEG_STREAM *oggVid = get_theora_size(name, &videoWidth, &videoHeight);

  if (videoWidth == 0)
  {
    Display("Unable to load theora video '%s'", name);
    return;
  }

  if (flags < 10)
  {
    stop_all_sound_and_music();
  }

  fli_target = NULL;
  //fli_buffer = create_bitmap_ex(final_col_dep, videoWidth, videoHeight);
  calculate_destination_size_maintain_aspect_ratio(videoWidth, videoHeight, &fliTargetWidth, &fliTargetHeight);

  if ((fliTargetWidth == videoWidth) && (fliTargetHeight == videoHeight) && (stretch_flc))
  {
    // don't need to stretch after all
    stretch_flc = 0;
  }

  if ((stretch_flc) && (!gfxDriver->HasAcceleratedStretchAndFlip()))
  {
    fli_target = create_bitmap_ex(final_col_dep, scrnwid, scrnhit);
    clear(fli_target);
    fli_ddb = gfxDriver->CreateDDBFromBitmap(fli_target, false, true);
  }
  else
  {
    fli_ddb = NULL;
  }

  update_polled_stuff();

  clear(virtual_screen);

  if (apeg_play_apeg_stream(oggVid, NULL, 0, theora_playing_callback) == APEG_ERROR)
  {
    Display("Error playing theora video '%s'", name);
  }
  apeg_close_stream(oggVid);

  //destroy_bitmap(fli_buffer);
  if (fli_target != NULL)
    destroy_bitmap(fli_target);
  gfxDriver->DestroyDDB(fli_ddb);
  fli_ddb = NULL;
  invalidate_screen();
}