コード例 #1
0
ファイル: acpland.cpp プロジェクト: josthas/KrusAGS
int ReadInteger(int* variable, char* section, char* name, int minimum, int maximum, int default_value)
{
  if (reset_configuration)
  {
    *variable = default_value;
    return 0;
  }

  int temp = INIreadint(section, name);

  if (temp == -1)
    return 0;

  if ((temp < minimum) || (temp > maximum))
    temp = default_value;

  *variable = temp;

  return 1;
}
コード例 #2
0
ファイル: ACWSETUP.CPP プロジェクト: smarinel/ags-web
void populate_drop_down_with_filters(HWND hDlg)
{
  SendDlgItemMessage(hDlg, IDC_GFXFILTER, CB_RESETCONTENT, 0, 0);

  int idx = 0;
  GFXFilter *thisFilter = filterList[idx];
  while (thisFilter != NULL) {

    if ((idx != 0) && (INIreadint("disabled", thisFilter->GetFilterID(), 0) == 1)) {
      // this filter is disabled
      delete thisFilter;
      // remove from list of filters
      for (int i = idx; filterList[i] != NULL; i++)
        filterList[i] = filterList[i + 1];

      thisFilter = filterList[idx];
      continue;
    }

    const char *filterName = thisFilter->GetVersionBoxText();
    char filterNameBuffer[100];

    if ((filterName == NULL) || (filterName[0] == 0)) {
      strcpy(filterNameBuffer, "None");
    }
    else {
      strcpy(filterNameBuffer, filterName);
      // strip trailing [
      if (filterNameBuffer[strlen(filterNameBuffer) - 1] == '[')
        filterNameBuffer[strlen(filterNameBuffer) - 1] = 0;
    }

    SendDlgItemMessage(hDlg, IDC_GFXFILTER, CB_ADDSTRING, 0, (LPARAM)filterNameBuffer);

    if ((strcmp(curFilter, thisFilter->GetFilterID()) == 0) || (idx == 0))
      SendDlgItemMessage(hDlg, IDC_GFXFILTER, CB_SETCURSEL, idx, 0);

    idx++;
    thisFilter = filterList[idx];
  }
}
コード例 #3
0
ファイル: ACWSETUP.CPP プロジェクト: smarinel/ags-web
int acwsetup(const char*vername, const char*enbuild) {
  setupstring = vername;
  enginever = enbuild;
  FILE*iiio=fopen(ac_config_file,"rt");
  if (iiio!=NULL) {
    fclose(iiio);
    curscrn=INIreadint("misc","screenres");
    if (curscrn > 1)
      curscrn = 1;
    defaultRes = INIreadint ("misc", "defaultres", 0);
    if (defaultRes < 1)
      defaultRes = -1;

    curdigi=INIreadint("sound","digiwinindx");
    curmidi=INIreadint("sound","midiwinindx");

    if (curdigi < 0) curdigi=0;
    if (curdigi > 3) curdigi = 0;
    if (curmidi < 0) curmidi=0;

    windowed = INIreadint("misc","windowed",0);
    useletterbox = INIreadint("misc","forceletterbox",0);

    reduce32to16 = INIreadint("misc","notruecolor",0);
    if (reduce32to16 < 0)
      reduce32to16 = 0;

    gameColDep = INIreadint("misc", "gamecolordepth", 0);
    if (gameColDep < 0)
      gameColDep = 0;

    if ((defaultRes == 2) || (defaultRes == 4)) {
      useletterbox = 1;
      mustBeLetterbox = 1;
    }

    refresh = INIreadint("misc","refresh",0);
    if (refresh < 1)
      refresh = 0;
    antialias = INIreadint("misc","antialias",0);
    if (antialias < 1)
      antialias = 0;

    sideBorders = INIreadint("misc","sideborders",0);
    if (sideBorders == -1)
      sideBorders = 1;

    int cacheval = INIreadint ("misc", "cachemax", 0);
    if (cacheval > 0)
      curmaxcache = cacheval;
    curusespeech = INIreadint ("sound", "usespeech", 0);
    if (curusespeech < 0)
      curusespeech = 1;

    GetPrivateProfileString("language", "translation", "", curtranslation, 200, ac_config_file);
    GetPrivateProfileString("misc", "replay", "", curreplay, 200, ac_config_file);
    GetPrivateProfileString("misc", "datadir", ".", curdatadir, 255, ac_config_file);
    GetPrivateProfileString("misc", "gfxfilter", "None", curFilter, 100, ac_config_file);
    GetPrivateProfileString("misc", "gfxdriver", "D3D9", curGfxDriver, 100, ac_config_file);
    GetPrivateProfileString("misc", "titletext", "Game Setup", gameNameForTitleBar, 200, ac_config_file);
  }
  if (DialogBox(GetModuleHandle(NULL), (LPCTSTR)IDD_DIALOG1,allegro_wnd,(DLGPROC)callback_settings) == IDOKRUN)
    return 1;
  return 0;
}
コード例 #4
0
ファイル: ACWSETUP.CPP プロジェクト: smarinel/ags-web
void InitializeDialog(HWND hDlg) {
  struct _finddata_t c_file;
  long hFile;
  FILE *fhan;
  int idx;
  retrieve_filter_list(false);

  SendDlgItemMessage(hDlg,IDC_VERSION, WM_SETTEXT, 0, (LPARAM)setupstring);

  SendDlgItemMessage(hDlg,IDC_GFXDRIVER,CB_ADDSTRING,0,(LPARAM)"DirectDraw 5");
  SendDlgItemMessage(hDlg,IDC_GFXDRIVER,CB_ADDSTRING,0,(LPARAM)"Direct3D 9");
  SendDlgItemMessage(hDlg,IDC_COMBO1,CB_RESETCONTENT,0,0);
  SendDlgItemMessage(hDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)"Default DirectSound Device");
  SendDlgItemMessage(hDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)"Default WaveOut Device");
  SendDlgItemMessage(hDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)"No Digital Sound");
  SendDlgItemMessage(hDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)"DirectSound (Hardware mixer)");
  SendDlgItemMessage(hDlg,IDC_COMBO1,CB_SETTOPINDEX,0,0);
  SendDlgItemMessage(hDlg,IDC_COMBO1,CB_SETCURSEL,curdigi,0);
  SendDlgItemMessage(hDlg,IDC_COMBO2,CB_ADDSTRING,0,(LPARAM)"Default MCI Music Device");
  SendDlgItemMessage(hDlg,IDC_COMBO2,CB_ADDSTRING,0,(LPARAM)"Disable music");
  SendDlgItemMessage(hDlg,IDC_COMBO2,CB_ADDSTRING,0,(LPARAM)"Win32 MIDI Mapper");
  SendDlgItemMessage(hDlg,IDC_COMBO2,CB_SETTOPINDEX,0,0);
  SendDlgItemMessage(hDlg,IDC_COMBO2,CB_SETCURSEL,curmidi,0);
  SendDlgItemMessage(hDlg,IDC_COMBO3,CB_ADDSTRING,0,(LPARAM)"Game Default");
  SendDlgItemMessage(hDlg,IDC_COMBO3,CB_SETCURSEL,0,0);
  idx = 1;

  char translationFindSpec[255];
  sprintf(translationFindSpec, "%s\\*.tra", curdatadir);
  // Find and add all translations in folder
  if ((hFile = _findfirst(translationFindSpec, &c_file )) != -1L ) {
    do {
      if (c_file.name[strlen(c_file.name)-4] == '.') {
        // it actually returns *.tra* so make sure it's a .TRA file,
        // then add to our list
        c_file.name[0] = toupper (c_file.name[0]);
        c_file.name[strlen(c_file.name)-4] = 0;
        int needToSet = 0;
        // if this is the translation we're using, set it
        if (stricmp (curtranslation, c_file.name) == 0)
          needToSet = 1;
        strcat (c_file.name, " translation");
        SendDlgItemMessage(hDlg,IDC_COMBO3,CB_ADDSTRING,0,(LPARAM)c_file.name);

        if (needToSet)
          SendDlgItemMessage (hDlg, IDC_COMBO3, CB_SETCURSEL, idx, 0);
        idx++;
      }
    } while( _findnext( hFile, &c_file ) == 0 );

    _findclose( hFile );
  }
  SendDlgItemMessage(hDlg,IDC_COMBO4,CB_ADDSTRING,0,(LPARAM)"10 MB");
  SendDlgItemMessage(hDlg,IDC_COMBO4,CB_ADDSTRING,0,(LPARAM)"20 MB (default)");
  SendDlgItemMessage(hDlg,IDC_COMBO4,CB_ADDSTRING,0,(LPARAM)"50 MB");
  SendDlgItemMessage(hDlg,IDC_COMBO4,CB_ADDSTRING,0,(LPARAM)"100 MB");
  idx = 0;
  if (curmaxcache >= 100*1024)
    idx = 3;
  else if (curmaxcache >= 50*1024)
    idx = 2;
  else if (curmaxcache >= 20*1024)
    idx = 1;
    
  SendDlgItemMessage(hDlg,IDC_COMBO4,CB_SETCURSEL,idx,0);

  SendDlgItemMessage(hDlg,IDC_REPLAYBOX,CB_ADDSTRING,0,(LPARAM)"Don't run a replay");
  SendDlgItemMessage(hDlg,IDC_REPLAYBOX,CB_SETCURSEL,0,0);
  idx = 1;
  // Find and add all replays in folder
  if ((hFile = _findfirst( "*.agr", &c_file )) != -1L ) {
    do {
      if (c_file.name[strlen(c_file.name)-4] == '.') {
        // it actually returns *.agr* so make sure it's a .AGR file,
        // then add to our list
        char listentry[300] = "(unknown replay)";
        get_replay_name (c_file.name, listentry);
        strcat (listentry, " (File: ");
        strcat (listentry, c_file.name);
        strcat (listentry, ")");

        int needToSet = 0;
        // if this is the translation we're using, set it
        if (stricmp (curreplay, c_file.name) == 0)
          needToSet = 1;
        
        SendDlgItemMessage(hDlg,IDC_REPLAYBOX,CB_ADDSTRING,0,(LPARAM)listentry);

        if (needToSet)
          SendDlgItemMessage (hDlg, IDC_REPLAYBOX, CB_SETCURSEL, idx, 0);
        idx++;
      }
    } while( _findnext( hFile, &c_file ) == 0 );

    _findclose( hFile );
  }

  populate_drop_down_with_filters(hDlg);

  if (stricmp(curGfxDriver, "D3D9") == 0)
    SendDlgItemMessage(hDlg, IDC_GFXDRIVER, CB_SETCURSEL, 1, 0);
  else
    SendDlgItemMessage(hDlg, IDC_GFXDRIVER, CB_SETCURSEL, 0, 0);
  update_gfx_filter_box_enabled(hDlg);

  if (windowed > 0)
    SendDlgItemMessage(hDlg,IDC_WINDOWED,BM_SETCHECK,BST_CHECKED,0);

  if (refresh > 0)
    SendDlgItemMessage(hDlg,IDC_REFRESH,BM_SETCHECK,BST_CHECKED,0);

  if (antialias > 0)
    SendDlgItemMessage(hDlg,IDC_ANTIALIAS,BM_SETCHECK,BST_CHECKED,0);

  if (curusespeech > 0)
    SendDlgItemMessage(hDlg,IDC_SPEECHPACK,BM_SETCHECK,BST_CHECKED,0);

  if (sideBorders > 0)
    SendDlgItemMessage(hDlg, IDC_SIDEBORDERS, BM_SETCHECK, BST_CHECKED, 0);

  if (useletterbox > 0)
    SendDlgItemMessage(hDlg, IDC_LETTERBOX,BM_SETCHECK,BST_CHECKED,0);
  // If the game is 320x240, don't let them un-tick it
  if (mustBeLetterbox)
    EnableWindow (GetDlgItem (hDlg, IDC_LETTERBOX), FALSE);
  // If it's 800x600, hide the letterbox option
  if (defaultRes >= 5)
    ShowWindow (GetDlgItem (hDlg, IDC_LETTERBOX), SW_HIDE);

  // If the game isn't 32-bit, disable it
  if (gameColDep < 32)
    EnableWindow (GetDlgItem (hDlg, IDC_REDUCESPR), FALSE);
  else if (reduce32to16 > 0)
    SendDlgItemMessage(hDlg, IDC_REDUCESPR, BM_SETCHECK, BST_CHECKED,0);

  // if no speech pack, disable the checkbox
  fhan = fopen("speech.vox", "rb");
  if (fhan == NULL)
    EnableWindow (GetDlgItem (hDlg, IDC_SPEECHPACK), FALSE);
  else
    fclose(fhan);

  if (INIreadint("disabled", "speechvox", 0) == 1)
    EnableWindow (GetDlgItem (hDlg, IDC_SPEECHPACK), FALSE);

  if (INIreadint("disabled", "16bit", 0) == 1)
    EnableWindow (GetDlgItem (hDlg, IDC_REDUCESPR), FALSE);

  if (INIreadint("disabled", "filters", 0) == 1)
    EnableWindow (GetDlgItem(hDlg, IDC_GFXFILTER), FALSE);

  RECT winsize;
  GetWindowRect (hDlg, &winsize);
  wwidth = winsize.right - winsize.left;
  wheight = winsize.bottom - winsize.top;

  MoveWindow (hDlg, winsize.left, winsize.top, wwidth, wheight-175, TRUE);
  update_resolution_texts (hDlg);

  SendMessage(hDlg, WM_SETTEXT, NULL, (LPARAM)gameNameForTitleBar);
  SendMessage(allegro_wnd, WM_SETTEXT, NULL, (LPARAM)gameNameForTitleBar);
}