Пример #1
0
void Setup(){
    for(uint i = 0; i < 512; i++)
        keys[i] = false;

    Scene::LoadMap(CurrentWorkingDirectory() + "/Resources/Maps/test.map");
    Script::manager.Setup();
    Script::manager.LoadScript(CurrentWorkingDirectory() + "/Resources/Scripts/test.js");

    testScript = new Script( CurrentWorkingDirectory() + "/testScript", "Player");

    GUI::GUIManager::Setup(800, 600);

    Node * terrain = new Node("terrain", Transform(glm::vec3(0.0f, -20.0f, 0.0f), glm::quat(glm::vec3(0.0f, 0.0f, 0.0f)), glm::vec3(1.0f, 1.0f, 1.0f)));
    Mesh * terrainMesh = new Mesh("terrain");
    terrainMesh->LoadTerrain(CurrentWorkingDirectory() + "/Resources/Textures/terrain.png");
    terrain->SetMesh(terrainMesh);
    terrain->SetMaterial(Material::manager.At("floor"));
    Node::manager.At("base")->AddChild(terrain);

    camera = Camera::manager.At("camera");
    player = Node::manager.At("player");
    playerCamera = Node::manager.At("playerCamera");
    boat = Node::manager.At("boat");
    Scene::SetCurrentCamera(playerCamera);

    if(player == NULL) std::cout << "player is null" << std::endl;
}
Пример #2
0
QString Application::ParseWildCardFilename(const QString& input)
{
    // Parse all the special symbols from the log filename.
    QString filename = input.trimmed().replace("$(CWD)", CurrentWorkingDirectory(), Qt::CaseInsensitive);
    filename = filename.replace("$(INSTDIR)", InstallationDirectory(), Qt::CaseInsensitive);
    filename = filename.replace("$(USERDATA)", UserDataDirectory(), Qt::CaseInsensitive);
    filename = filename.replace("$(USERDOCS)", UserDocumentsDirectory(), Qt::CaseInsensitive);
    QRegExp rx("\\$\\(DATE:(.*)\\)");
    // Qt Regexes don't support non-greedy matching. The above regex should be "\\$\\(DATE:(.*?)\\)". Instead Qt supports
    // only setting the matching to be non-greedy globally.
    rx.setMinimal(true); // This is to avoid e.g. $(DATE:yyyyMMdd)_aaa).txt to be incorrectly captured as "yyyyMMdd)_aaa".
    for(;;) // Loop and find all instances of $(DATE:someformat).
    {
        int pos = rx.indexIn(filename);
        if (pos > -1)
        {
            QString dateFormat = rx.cap(1);
            QString date = QDateTime::currentDateTime().toString(dateFormat);
            filename = filename.replace(rx.pos(0), rx.cap(0).length(), date);
        }
        else
            break;
    }
    return filename;
}
Пример #3
0
const char*
TestFixture::TemporaryDirectoryCreator::Create(bool changeDirectory)
{
	Delete();

	try {
		// get the current working directory
		if (changeDirectory)
			fOldWorkingDirectory = CurrentWorkingDirectory();

		// create a temporary test directory
		CreateTemporaryDirectory(fTemporaryDirectory);

		// change the directory to the test directory
		if (changeDirectory && chdir(fTemporaryDirectory.c_str()) < 0) {
			fOldWorkingDirectory.clear();
				// clear, since we don't need to chdir() back
			HAM_TEST_THROW("Failed to cd into temporary directory: %s",
				strerror(errno))
		}
	} catch (...) {
		Delete();
		throw;
	}

	return fTemporaryDirectory.c_str();
}
Пример #4
0
QString Application::InstallationDirectory()
{
    // When running from a debugger, the current directory may in fact be the install directory.
    // Check for the presence of a special tag file to see if we should treat cwd as the installation directory
    // instead of the directory where the current .exe resides.
    QString cwd = CurrentWorkingDirectory();
    if (QFile::exists(cwd + "plugins/TundraInstallationDirectory.txt"))
        return cwd;

#ifdef _WINDOWS
    WCHAR str[MAX_PATH+1] = {};
    DWORD success = GetModuleFileNameW(0, str, MAX_PATH);
    if (success == 0)
        return "";
    QString qstr = WStringToQString(str);
    // The module file name also contains the name of the executable, so strip it off.
    int trailingSlash = qstr.lastIndexOf('\\');
    if (trailingSlash == -1)
        return ""; // Some kind of error occurred.

    return qstr.left(trailingSlash+1); // +1 so that we return the trailing slash as well.
#elif defined(__APPLE__)
    char path[1024];
    uint32_t size = sizeof(path)-2;
    int ret = _NSGetExecutablePath(path, &size);
    if (ret == 0 && size > 0)
    {
        // The returned path also contains the executable name, so strip that off from the path name.
        QString p = path;
        int lastSlash = p.lastIndexOf("/");
        if (lastSlash != -1)
            p = p.left(lastSlash+1);
        return p;
    }
    else
    {
        LogError("Application::InstallationDirectory: _NSGetExecutablePath failed! Returning './'");
        return "./";
    }
#elif defined(ANDROID)
    /// \todo Implement a proper file access mechanism. Hardcoded internal storage access is used for now
    return "/sdcard/Download/Tundra/";
#elif defined(__linux__)
    char exeName[1024];
    memset(exeName, 0, 1024);
    pid_t pid = getpid();
    QString link = "/proc/" + QString::number(pid) + "/exe";
    readlink(link.toStdString().c_str(), exeName, 1024);
    // The returned path also contains the executable name, so strip that off from the path name.
    QString p(exeName);
    int lastSlash = p.lastIndexOf("/");
    if (lastSlash != -1)
        p = p.left(lastSlash+1);
    return p;     
#else
    LogError("Application::InstallationDirectory not implemented for this platform. Returning './'");
    return "./";
#endif
}
Пример #5
0
static 
std::string DirectoryPath(const std::string & file) 
{
    // Return either relative or absolute directory path of file
    std::size_t pos = file.rfind('/');
    if (IsAbsolutePath(file)) {
        if (pos != std::string::npos) 
            return file.substr(0, pos);
        else 
            return std::string();
    } else {
        if (pos != std::string::npos)
            return CurrentWorkingDirectory() + "/" + file.substr(0, pos);
        else
            return CurrentWorkingDirectory();
    }
}