#include "CGameContext.h"

using namespace irr;

CGameContext::CGameContext()
{
}

core::array<core::stringc> CGameContext::LoadMaps() {
    core::array<core::stringc> maps;
    //printf("LoadMaps");
    const char *path = "./maps";

    struct dirent *entry;
    DIR *dir = opendir(path);

    if (dir == NULL) {
          printf("LoadMaps -> dir null exit \n");
          return maps;
       }

    while ((entry = readdir(dir)) != NULL) {
       //printf(entry->d_name);
       if(strcmp(entry->d_name,".") !=0 && strcmp(entry->d_name,"..") !=0) {

          if(strstr(entry->d_name,".map"))
            {
               //printf("map.push_back %s\n",entry->d_name);
               maps.push_back(entry->d_name);
            }
       }

    }
   closedir(dir);

    return maps;
}

core::stringc CGameContext::GetSelectedMap() {
    return selectedmap;
}

void CGameContext::SetSelectedMap(core::stringc mapname) {
    selectedmap=mapname;
}

CGameContext::~CGameContext()
{


}
