Commit efd241fb authored by fallenstardust's avatar fallenstardust

根据屏幕分辨率等比缩放手卡、场上卡片

parent 9ba25440
......@@ -166,7 +166,7 @@ bool DataManager::Error(sqlite3* pDB, sqlite3_stmt* pStmt) {
std::strncat(errmsg, sqlite3_errmsg(pDB), sizeof errmsg - 1);
if(pStmt)
sqlite3_finalize(pStmt);
ALOGE("cdb Error=", errmsg);
ALOGE("cc data_manager: cdb Error=", errmsg);
return false;
}
code_pointer DataManager::GetCodePointer(unsigned int code) const {
......
......@@ -13,9 +13,15 @@ inline void SetS3DVertex(S3DVertex* v, f32 x1, f32 y1, f32 x2, f32 y2, f32 z, f3
v[2] = S3DVertex(x1, y2, z, 0, 0, nz, SColor(255, 255, 255, 255), tu1, tv2);
v[3] = S3DVertex(x2, y2, z, 0, 0, nz, SColor(255, 255, 255, 255), tu2, tv2);
}
void Game::SetCardS3DVertex() {
f32 defalutScale = (mainGame->xScale - mainGame->yScale) / 10;
ALOGD("cc drawing defalutScale = %f",defalutScale);
SetS3DVertex(matManager.vCardFront, -0.35f + defalutScale, -0.5f, 0.35f - defalutScale, 0.5f, 0, 1, 0, 0, 1, 1);
SetS3DVertex(matManager.vCardOutline, -0.375f + defalutScale, -0.54f, 0.37f - defalutScale, 0.54f, 0, 1, 0, 0, 1, 1);
SetS3DVertex(matManager.vCardOutliner, 0.37f - defalutScale, -0.54f, -0.375f + defalutScale, 0.54f, 0, 1, 0, 0, 1, 1);
SetS3DVertex(matManager.vCardBack, 0.35f - defalutScale, -0.5f, -0.35f + defalutScale, 0.5f, 0, -1, 0, 0, 1, 1);
}
void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, float* cv) {
#ifdef _IRR_ANDROID_PLATFORM_
glLineWidth(width+2);
driver->setMaterial(matManager.mOutLine);
if(strip) {
......@@ -36,7 +42,6 @@ void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width,
driver->draw3DLine(vec[3].Pos, vec[2].Pos);
driver->draw3DLine(vec[2].Pos, vec[0].Pos);
}
#endif
}
void Game::DrawSelectionLine(irr::gui::IGUIElement* element, int width, irr::video::SColor color) {
recti pos = element->getAbsolutePosition();
......
......@@ -77,7 +77,7 @@ void Game::process(irr::SEvent &event) {
}
void Game::stopBGM() {
ALOGD("stop bgm");
ALOGD("cc game: stop bgm");
gMutex.lock();
soundManager->StopBGM();
gMutex.unlock();
......@@ -109,14 +109,14 @@ void Game::onHandleAndroidCommand(ANDROID_APP app, int32_t cmd){
switch (cmd)
{
case APP_CMD_PAUSE:
ALOGD("APP_CMD_PAUSE");
ALOGD("cc game: APP_CMD_PAUSE");
if(ygo::mainGame != nullptr){
ygo::mainGame->stopBGM();
}
break;
case APP_CMD_RESUME:
//第一次不一定调用
ALOGD("APP_CMD_RESUME");
ALOGD("cc game: APP_CMD_RESUME");
if(ygo::mainGame != nullptr){
ygo::mainGame->playBGM();
}
......@@ -137,8 +137,6 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
this->appMain = app;
srand(time(0));
irr::SIrrlichtCreationParameters params = irr::SIrrlichtCreationParameters();
#ifdef _IRR_ANDROID_PLATFORM_
glversion = options->getOpenglVersion();
if (glversion == 0) {
params.DriverType = irr::video::EDT_OGLES1;
......@@ -172,10 +170,12 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
xScale = android::getXScale(app);
yScale = android::getYScale(app);
ALOGD("xScale = %f, yScale = %f", xScale, yScale);
ALOGD("cc game: xScale = %f, yScale = %f", xScale, yScale);
SetCardS3DVertex();//reset cardfront cardback S3DVertex size
//io::path databaseDir = options->getDBDir();
io::path workingDir = options->getWorkDir();
ALOGD("workingDir= %s", workingDir.c_str());
ALOGD("cc game: workingDir= %s", workingDir.c_str());
dataManager.FileSystem->changeWorkingDirectoryTo(workingDir);
/* Your media must be somewhere inside the assets folder. The assets folder is the root for the file system.
......@@ -200,12 +200,12 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
for(int i=0;i<len;i++){
io::path zip_path = zips[i];
if(dataManager.FileSystem->addFileArchive(zip_path.c_str(), false, false, EFAT_ZIP)) {
ALOGD("add arrchive ok:%s", zip_path.c_str());
ALOGD("cc game: add arrchive ok:%s", zip_path.c_str());
}else{
ALOGW("add arrchive fail:%s", zip_path.c_str());
ALOGW("cc game: add arrchive fail:%s", zip_path.c_str());
}
}
#endif
LoadConfig();
linePatternD3D = 0;
linePatternGL = 0x0f0f;
......@@ -229,7 +229,7 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
} else {
isNPOTSupported = ((COGLES1Driver *) driver)->queryOpenGLFeature(COGLES1ExtensionHandler::IRR_OES_texture_npot);
}
ALOGD("isNPOTSupported = %d", isNPOTSupported);
ALOGD("cc game: isNPOTSupported = %d", isNPOTSupported);
if (isNPOTSupported) {
if (quality == 1) {
driver->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS, false);
......@@ -258,15 +258,15 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
wchar_t wpath[1024];
BufferIO::DecodeUTF8(cdb_path.c_str(), wpath);
if(dataManager.LoadDB(wpath)) {
ALOGD("add cdb ok:%s", cdb_path.c_str());
ALOGD("cc game: add cdb ok:%s", cdb_path.c_str());
}else{
ALOGW("add cdb fail:%s", cdb_path.c_str());
ALOGW("cc game: add cdb fail:%s", cdb_path.c_str());
}
}
//if(!dataManager.LoadDB(workingDir.append("/cards.cdb").c_str()))
// return false;
if(dataManager.LoadStrings((workingDir + path("/expansions/strings.conf")).c_str())){
ALOGD("loadStrings expansions/strings.conf");
ALOGD("cc game: loadStrings expansions/strings.conf");
}
if(!dataManager.LoadStrings((workingDir + path("/strings.conf")).c_str())) {
ErrorLog("Failed to load strings!");
......@@ -282,7 +282,7 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
titleFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.textfont, 32 * yScale, isAntialias, true);
textFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.textfont, (int)gameConf.textfontsize * yScale, isAntialias, true);
if(!numFont || !guiFont) {
ALOGW("add font fail ");
ALOGW("cc game: add font fail ");
}
smgr = device->getSceneManager();
device->setWindowCaption(L"[---]");
......@@ -1328,9 +1328,8 @@ void Game::MainLoop() {
float atkframe = 0.1f;
irr::ITimer* timer = device->getTimer();
timer->setTime(0);
#ifdef _IRR_ANDROID_PLATFORM_
// get FPS
IGUIElement *stat = device->getGUIEnvironment()->getRootGUIElement()->getElementFromId ( GUI_INFO_FPS );
#endif
int fps = 0;
int cur_time = 0;
#if defined(_IRR_ANDROID_PLATFORM_)
......@@ -1349,14 +1348,14 @@ void Game::MainLoop() {
if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) &&
!driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1))
{
ALOGD("WARNING: Pixel shaders disabled "
ALOGD("cc game: WARNING: Pixel shaders disabled "
"because of missing driver/hardware support.");
psFileName = "";
}
if (!driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1) &&
!driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1))
{
ALOGD("WARNING: Vertex shaders disabled "
ALOGD("cc game: WARNING: Vertex shaders disabled "
"because of missing driver/hardware support.");
solidvsFileName = "";
TACvsFileName = "";
......@@ -1377,9 +1376,9 @@ void Game::MainLoop() {
psFileName, "vertexMain", video::EVST_VS_1_1,
blendvsFileName, "pixelMain", video::EPST_PS_1_1,
&customShadersCallback, video::EMT_ONETEXTURE_BLEND, 0 , shadingLanguage);
ALOGD("ogles2Sold = %d", ogles2Solid);
ALOGD("ogles2BlendTexture = %d", ogles2BlendTexture);
ALOGD("ogles2TrasparentAlpha = %d", ogles2TrasparentAlpha);
ALOGD("cc game:ogles2Sold = %d", ogles2Solid);
ALOGD("cc game:ogles2BlendTexture = %d", ogles2BlendTexture);
ALOGD("cc game:ogles2TrasparentAlpha = %d", ogles2TrasparentAlpha);
}
}
matManager.mCard.MaterialType = (video::E_MATERIAL_TYPE)ogles2BlendTexture;
......@@ -1407,7 +1406,7 @@ void Game::MainLoop() {
}
#endif
while(device->run()) {
//ALOGV("game draw frame");
//ALOGV("cc game draw frame");
linePatternD3D = (linePatternD3D + 1) % 30;
linePatternGL = (linePatternGL << 1) | (linePatternGL >> 15);
atkframe += 0.1f;
......
......@@ -171,6 +171,7 @@ public:
void RefreshReplay();
void RefreshSingleplay();
void RefreshBot();
void SetCardS3DVertex();
void DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, float* cv);
void DrawSelectionLine(irr::gui::IGUIElement* element, int width, irr::video::SColor color);
void DrawBackGround();
......
......@@ -65,7 +65,7 @@ int main(int argc, char* argv[]) {
*/
bool keep_on_return = false;
#ifdef _IRR_ANDROID_PLATFORM_
ALOGD("handle args %d", argc);
ALOGD("cc gframe: handle args %d", argc);
//android
for(int i = 0; i < argc; ++i) {
const char* arg = argv[i].c_str();
......@@ -112,7 +112,7 @@ int main(int argc, char* argv[]) {
wchar_t fname[1024];
BufferIO::DecodeUTF8(name, fname);
index = GetListBoxIndex(ygo::mainGame->lstReplayList, fname);
ALOGD("open replay file:index=%d, name=%s", index, name);
ALOGD("cc gframe: open replay file:index=%d, name=%s", index, name);
}
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
ClickButton(ygo::mainGame->btnReplayMode);
......@@ -139,7 +139,7 @@ int main(int argc, char* argv[]) {
wchar_t fname[1024];
BufferIO::DecodeUTF8(name, fname);
index = GetListBoxIndex(ygo::mainGame->lstSinglePlayList, fname);
ALOGD("open single file:index=%d, name=%s", index, name);
ALOGD("cc gframe: open single file:index=%d, name=%s", index, name);
}
if(index >= 0){
ygo::mainGame->lstSinglePlayList->setSelected(index);
......
......@@ -377,9 +377,9 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
prev_operation = id;
prev_sel = sel;
#ifdef _IRR_ANDROID_PLATFORM_
ALOGD("1share replay file=%s", name);
ALOGD("cc menu_handler: 1share replay file=%s", name);
android::OnShareFile(mainGame->appMain, "yrp", name);
ALOGD("2after share replay file:index=%d", sel);
ALOGD("cc menu_handler: 2after share replay file:index=%d", sel);
#endif
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment