Hey guys, I have a pretty MAJOR issue with some of my code for a game I'm working on.
Basically, I have the following code to find all the lua scripts and then grab some information from them on a selection screen. It works fine when I run it from Visual Studio 2012 (as both release and debug) but doesn't appear to function properly. Some pictures don't appear, and some random text characters appear instead of the actual text, and in some place there's on text whatsoever. I don't have any include how to debug this to be honest.
Here's the code that initializes all the stuff.
void SongSelect::init(GamestateManager* gameStateManager, lua_State* L)
{
m_pInputManager = InputManager::Instance();
ImageManager* m_pImageManager = ImageManager::Instance();
Game* m_pGame = Game::Instance();
AudioManager* m_pAudioManager = AudioManager::Instance();
songs = initSongs(L);
std::cout << "Attemping to read songselect.lua\n";
luaL_dofile(L, "Assets/Scripts/States/SongSelect.lua");
std::cout << "Read songselect.lua\n";
m_pImageManager->load(bg, "bg", m_pGame->getRenderer());
current_pad = old_pad = NULL;
initAlbumArt(songs);
info_col.a = 200;
info_col.r = 255;
info_col.g = 255;
info_col.b = 255;
TextManager::Instance()->loadText(font, label, 36);
selected = 0;
}
std::vector<Track*> SongSelect::initSongs(lua_State* L)
{
std::vector<Track*> tracks;
// code based off of code found on Google, with modifications to create the track objects
WIN32_FIND_DATA file_search;
HANDLE handle = FindFirstFile("Assets\\Scripts\\Songs\\*.lua", &file_search);
while (handle != INVALID_HANDLE_VALUE)
{
std::string song_file;
std::stringstream song_file_stream;
song_file_stream << "Assets\\Scripts/Songs\\" << file_search.cFileName;
song_file = song_file_stream.str();
song_files.push_back(song_file);
luaL_dofile(L, song_file.c_str());
Track* track = luabridge::getGlobal(L, "music_track");
tracks.push_back(track);
if (!FindNextFile(handle, &file_search))
{
break;
}
}
FindClose(handle);
return tracks;
}
Any ideas why this may work when run from Visual Studio 2012 but not when launched directly from Windows Explorer in a different location? It makes it kind of hard to playtest/ release the game if I can't even get it to run properly on other computers!
Thanks a ton!