Commit efd241fb authored by fallenstardust's avatar fallenstardust

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

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