Ejemplo n.º 1
0
/**
 * Returns to the previous screen.
 * @param action Pointer to an action.
 */
void BaseNameState::edtNameKeyPress(Action *action)
{
	if (action->getDetails()->key.keysym.sym == SDLK_RETURN)
	{
		nameBase();
	}
}
Ejemplo n.º 2
0
Shader* Render::LoadShader(const char* shaderName, bool reload) {
  static std::string g_currentShader;
  std::string shaderDir = "data/";
  std::string vertPrefix = std::string("vert");
  std::string fragPrefix = std::string("frag");
  std::string ext = std::string(".glsl");

  std::string baseNameWithExt;
  if(shaderName == NULL) {
    std::string search = shaderDir + vertPrefix + "*" + ext;
    const char* currentLevel = (g_currentShader.empty()) ? NULL : g_currentShader.c_str();
    std::string nextNameWithExt;
    if(!Platform::GetNextFileName(search.c_str(), currentLevel, nextNameWithExt)) {
      return NULL;
    }
    // muhahaha so robust
    const char* baseStart = &(nextNameWithExt.c_str()[4]); // skip vert
    baseNameWithExt.assign(baseStart);
  } else {
    std::string nameBase(shaderName);
    baseNameWithExt = nameBase + ext;
  }

  std::string vertName = shaderDir + vertPrefix + baseNameWithExt;
  std::string fragName = shaderDir + fragPrefix + baseNameWithExt;

  ::fd::Shader* pShader = ::fd::Shader::GetShaderByRefName(baseNameWithExt);
  if(!reload && pShader) {
    return pShader;
  }

  std::unique_ptr<::fd::Shader> shaderMem;
  if (pShader) {
    pShader->Release();
  } else {
    pShader = new ::fd::Shader();
    shaderMem.reset(pShader);
  }

  pShader->AddDynamicMeshCommonSubShaders();
  if(!pShader->LoadFromFile(baseNameWithExt.c_str(), vertName.c_str(), fragName.c_str())) {
    printf("Failed loading shader!\n");
    return NULL;
  }

  shaderMem.release();
  g_currentShader = vertPrefix + baseNameWithExt;
  printf("Loaded shader %s\n", vertName.c_str());

  return pShader;
}
Ejemplo n.º 3
0
/**
 * Returns to the previous screen.
 * @param action Pointer to an action.
 */
void BaseNameState::edtNameKeyPress(Action *action)
{
	if (action->getDetails()->key.keysym.sym == SDLK_RETURN ||
		action->getDetails()->key.keysym.sym == SDLK_KP_ENTER)
	{
		if(_edtName->getText().size() > 0)
		{
			nameBase();
		}
	}
	else
	{
		if(_edtName->getText().size() > 0)
		{
			_btnOk->setVisible(true);
		}
		else
		{
			_btnOk->setVisible(false);
		}
	}
}
Ejemplo n.º 4
0
/**
 * Returns to the previous screen
 * @param action Pointer to an action.
 */
void BaseNameState::btnOkClick(Action *action)
{
	nameBase();
}