Esempio n. 1
0
File: swnd.c Progetto: goriy/sif
static void on_dir_dblclick (void)
{
  char buf[MAX_PATH];
  if (DlgDirSelectEx (hMainWindow, buf, sizeof(buf), IDC_DIRS))  {
    strcat (CurrentPath, buf);
    strcpy (buf, CurrentPath);
    PathCanonicalize(CurrentPath, buf);
    current_path_to_edit ();
    populate_dir ();
  }
}
Esempio n. 2
0
File: swnd.c Progetto: goriy/sif
static void do_gui_main_action (LPSTR cmdline)
{
  NARGV *args = nargv_parse(cmdline);

  if (args->argc > 0)  {
    if (DirectoryExists(args->argv[0]))  {
      SetWindowText(GetDlgItem(hMainWindow, IDC_MANPATH), args->argv[0]);
      DoEvents (NULL);
      populate_dir ();
    }
  }
  nargv_free (args);
}
Esempio n. 3
0
File: swnd.c Progetto: goriy/sif
static void on_drives_select (void)
{
  char buf[_MAX_PATH];
  //HWND wnd = GetDlgItem (hMainWindow, IDC_DRIVES);
  int drive;
  if (DlgDirSelectComboBoxEx (hMainWindow, buf, sizeof(buf), IDC_DRIVES))  {
    drive = toupper(buf[0]) - 'A' + 1;
    if(_getdcwd (drive, buf, _MAX_PATH) != NULL)  {
      strcat (buf, "\\");
      PathCanonicalize(CurrentPath, buf);
      current_path_to_edit ();
      populate_dir ();
    }
  }
}
Esempio n. 4
0
int main(void)
{
    /* enable interrupts (on the CPU) */
    init_interrupts();

    /* Initialize audio and video */
    audio_init(44100,2);
    console_init();

    /* Initialize key detection */
    controller_init();

    MikMod_RegisterAllDrivers();
    MikMod_RegisterAllLoaders();

    md_mode |= DMODE_16BITS;
    md_mode |= DMODE_SOFT_MUSIC;
    md_mode |= DMODE_SOFT_SNDFX;
    //md_mode |= DMODE_STEREO;
                                            
    md_mixfreq = audio_get_frequency();

    MikMod_Init("");

    if(dfs_init( DFS_DEFAULT_LOCATION ) != DFS_ESUCCESS)
    {
        printf("Filesystem failed to start!\n");
    }
    else
    {
        direntry_t *list;
        int count = 0;
        int page = 0;
        int cursor = 0; 

        console_set_render_mode(RENDER_MANUAL);
        console_clear();

        list = populate_dir(&count);

        while(1)
        {
            console_clear();
            display_dir(list, cursor, page, MAX_LIST, count);
            console_render();

            controller_scan();
            struct controller_data keys = get_keys_down();

            if(keys.c[0].up)
            {
                cursor--;
                new_scroll_pos(&cursor, &page, MAX_LIST, count);
            }

            if(keys.c[0].down)
            {
                cursor++;
                new_scroll_pos(&cursor, &page, MAX_LIST, count);
            }

            if(keys.c[0].C_right && list[cursor].type == DT_REG)
            {
                /* Module playing loop */
                MODULE *module = NULL;

                /* Concatenate to make file */
                char path[512];

                strcpy( path, dir );
                strcat( path, list[cursor].filename );

                module = Player_Load(path, 256, 0);
                
                /* Ensure that first part of module doesn't get cut off */
                audio_write_silence();
                audio_write_silence();

                if(module)
                {
                    char c = '-';
                    int sw = 0;

                    Player_Start(module);

                    while(1)
                    {
                        if(sw == 5)
                        {
                            console_clear();
                            display_dir(list, cursor, page, MAX_LIST, count);

                            sw = 0;
                            switch(c)
                            {
                                case '-':
                                    c = '\\';
                                    break;
                                case '\\':
                                    c = '|';
                                    break;
                                case '|':
                                    c = '/';
                                    break;
                                case '/':
                                    c = '-';
                                    break;
                            }
    
                            printf("\n\n\n%c Playing module", c);                        
                            console_render();
                        }
                        else
                        {
                            sw++;
                        }

                        MikMod_Update();

                        controller_scan();
                        struct controller_data keys = get_keys_down();

                        if(keys.c[0].C_left || !Player_Active())
                        {
                            /* End playback */
                            audio_write_silence();
                            audio_write_silence();
                            audio_write_silence();
                            audio_write_silence();

                            break;
                        }
                    }
                
                    Player_Stop();
                    Player_Free(module);
                }
            }

            if(keys.c[0].L)
            {
                /* Open the SD card */
                strcpy( dir, "sd://" );

                /* Populate new directory */
                free_dir(list);
                list = populate_dir(&count);

                page = 0;
                cursor = 0;
            }

            if(keys.c[0].R)
            {
                /* Open the ROM FS card */
                strcpy( dir, "rom://" );

                /* Populate new directory */
                free_dir(list);
                list = populate_dir(&count);

                page = 0;
                cursor = 0;
            }

            if(keys.c[0].A && list[cursor].type == DT_DIR)
            {
                /* Change directories */
                chdir(list[cursor].filename);
       
                /* Populate new directory */
                free_dir(list);
                list = populate_dir(&count);

                page = 0;
                cursor = 0;
            }

            if(keys.c[0].B)
            {
                /* Up! */
                chdir("..");
       
                /* Populate new directory */
                free_dir(list);
                list = populate_dir(&count);

                page = 0;
                cursor = 0;
            }
        }
    }

    while(1);

    return 0;
}
Esempio n. 5
0
File: swnd.c Progetto: goriy/sif
static void on_update_click (void)
{
  populate_dir ();
}
Esempio n. 6
0
File: swnd.c Progetto: goriy/sif
// main function.
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinst, LPSTR cmdline, int show)
{
  instance = hinstance;
  InitCommonControls();
  register_classes();
  h_font = CreateFont(-11, 0, 0, 0, FW_NORMAL, 0,
              0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
              DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "MS Sans Serif");


  GetModuleFileName(NULL, MyPath, sizeof(MyPath));
  //fprintf (stderr, "MyPath = %s\n", MyPath);
  if (!SHGetSpecialFolderPath(NULL, ConfigPath, CSIDL_LOCAL_APPDATA, 0))  {
    //fprintf (stderr, "Cannot determine LocalAppData folder\n");
  }
  else  {
  }
  strcat (ConfigPath, "\\.sif2\\");
  _mkdir (ConfigPath);
  //fprintf (stderr, "ConfigPath = %s\n", ConfigPath);

  config_init ();

  hMainWindow = create_wnd0();

  memset (&clfnt, 0, sizeof(clfnt));
  clfnt.lfHeight = -MulDiv(OptFontHeight, GetDeviceCaps(GetDC(hMainWindow), LOGPIXELSY), 72);
  clfnt.lfWidth = 0;
  clfnt.lfEscapement = 0;
  clfnt.lfOrientation = 0;
  clfnt.lfWeight = FW_NORMAL;
  clfnt.lfItalic = 0;
  clfnt.lfUnderline = 0;
  clfnt.lfStrikeOut = 0;
  clfnt.lfCharSet = RUSSIAN_CHARSET;
  clfnt.lfOutPrecision = OUT_DEFAULT_PRECIS;
  clfnt.lfClipPrecision = CLIP_DEFAULT_PRECIS;
  clfnt.lfQuality =  DEFAULT_QUALITY;
  clfnt.lfPitchAndFamily = DEFAULT_PITCH | FF_MODERN;
  strcpy (clfnt.lfFaceName, OptFontFace);

  h_font_code = CreateFontIndirect(&clfnt);

  create_wnd_content0(hMainWindow);

  _fullpath (CurrentPath, ".", sizeof(CurrentPath));
  strcat (CurrentPath, "\\");
  current_path_to_edit ();

  SetFocus(GetDlgItem(hMainWindow, IDC_TXT));
  resize_controls ();

  recent_load ();
  recent_fill_combo (IDC_RECENT);

  set_options ();
  populate_dir ();

  search_init ();

  hDlgCurrent = hMainWindow;

  if (!SHGetSpecialFolderPath(NULL, SendtoPath, CSIDL_SENDTO, 0))  {
    //fprintf (stderr, "Cannot determine SendTo folder\n");
  }
  else  {
    //fprintf (stderr, "SendtoPath = %s\n", SendtoPath);
  }

  strcat (SendtoPath, "\\Search in files.lnk");

  if (CreateShortCut(MyPath, "", SendtoPath, "Search in files", SW_SHOWNORMAL, "", "", 0) < 0)  {
    //fprintf (stderr, "Error create shortcut %ld\n", GetLastError());
  }

  do_gui_main_action (cmdline);
  return message_loop();
}