Commit dcd94678 authored by Dark Zane's avatar Dark Zane Committed by GitHub

Merge branch 'fallenstardust:master' into master

parents aa644d68 6601cb87
......@@ -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();
......@@ -831,9 +836,9 @@ void Game::DrawSpec() {
return;
dimension2d<u32> orisize = showimg->getOriginalSize();
switch(showcard) {
case 1: {
driver->draw2DImage(imageManager.GetTexture(showcardcode), Resize(574, 150, 574 + CARD_IMG_WIDTH, 150 + CARD_IMG_HEIGHT), recti(0, 0, orisize.Width, orisize.Height), 0, 0, true);
driver->draw2DImage(imageManager.tMask, Resize(574, 150, 574 + (showcarddif > CARD_IMG_WIDTH ? CARD_IMG_WIDTH : showcarddif), 150 + CARD_IMG_HEIGHT),
case 1: {//show activiting effect
driver->draw2DImage(showimg, recti(660 * xScale - (CARD_IMG_WIDTH / 2) * yScale, 150 * yScale, 660 * xScale + (CARD_IMG_WIDTH / 2) * yScale, (150 + CARD_IMG_HEIGHT) * yScale), recti(0, 0, orisize.Width, orisize.Height), 0, 0, true);
driver->draw2DImage(imageManager.tMask, recti(660 * xScale - (CARD_IMG_WIDTH / 2) * yScale, 150 * yScale, 660 * xScale - (CARD_IMG_WIDTH / 2) * yScale + (showcarddif > CARD_IMG_WIDTH ? CARD_IMG_WIDTH : showcarddif) * yScale, (150 + CARD_IMG_HEIGHT) * yScale),
recti(CARD_IMG_HEIGHT - showcarddif, 0, CARD_IMG_HEIGHT - (showcarddif > CARD_IMG_WIDTH ? showcarddif - CARD_IMG_WIDTH : 0), CARD_IMG_HEIGHT), 0, 0, true);
showcarddif += 15;
if(showcarddif >= CARD_IMG_HEIGHT) {
......@@ -843,18 +848,18 @@ void Game::DrawSpec() {
break;
}
case 2: {
driver->draw2DImage(imageManager.GetTexture(showcardcode), Resize(574, 150, 574 + CARD_IMG_WIDTH, 150 + CARD_IMG_HEIGHT), recti(0, 0, orisize.Width, orisize.Height), 0, 0, true);
driver->draw2DImage(imageManager.tMask, Resize(574 + showcarddif, 150, 774, 150 + CARD_IMG_HEIGHT),
recti(0, 0, (CARD_IMG_WIDTH - showcarddif), CARD_IMG_HEIGHT), 0, 0, true);
driver->draw2DImage(showimg, recti(660 * xScale - (CARD_IMG_WIDTH / 2) * yScale, 150 * yScale, 660 * xScale + (CARD_IMG_WIDTH / 2) * yScale, (150 + CARD_IMG_HEIGHT) * yScale), recti(0, 0, orisize.Width, orisize.Height), 0, 0, true);
driver->draw2DImage(imageManager.tMask, recti(660 * xScale - (CARD_IMG_WIDTH / 2) * yScale + showcarddif * yScale, 150 * yScale, 660 * xScale + (CARD_IMG_WIDTH / 2) * yScale, (150 + CARD_IMG_HEIGHT) * yScale),
recti(0, 0, CARD_IMG_WIDTH - showcarddif, CARD_IMG_HEIGHT), 0, 0, true);
showcarddif += 15;
if(showcarddif >= CARD_IMG_WIDTH) {
showcard = 0;
}
break;
}
case 3: {
driver->draw2DImage(imageManager.GetTexture(showcardcode), Resize(574, 150, 574 + CARD_IMG_WIDTH, 150 + CARD_IMG_HEIGHT), recti(0, 0, orisize.Width, orisize.Height), 0, 0, true);
driver->draw2DImage(imageManager.tNegated, Resize(536 + showcarddif, 141 + showcarddif, 793 - showcarddif, 397 - showcarddif), recti(0, 0, 128, 128), 0, 0, true);
case 3: {//show negating effect
driver->draw2DImage(showimg, recti(660 * xScale - (CARD_IMG_WIDTH / 2) * yScale, 150 * yScale, 660 * xScale + (CARD_IMG_WIDTH / 2) * yScale, (150 + CARD_IMG_HEIGHT) * yScale), recti(0, 0, orisize.Width, orisize.Height), 0, 0, true);
driver->draw2DImage(imageManager.tNegated, recti(660 * xScale - 130 * yScale + showcarddif * yScale, (141 + showcarddif) * yScale, 660 * xScale + 130 * yScale - showcarddif * yScale, (397 - showcarddif) * yScale), recti(0, 0, 128, 128), 0, 0, true);
if(showcarddif < 64)
showcarddif += 4;
break;
......@@ -864,39 +869,39 @@ void Game::DrawSpec() {
matManager.c2d[1] = (showcarddif << 24) | 0xffffff;
matManager.c2d[2] = (showcarddif << 24) | 0xffffff;
matManager.c2d[3] = (showcarddif << 24) | 0xffffff;
driver->draw2DImage(imageManager.GetTexture(showcardcode), Resize(574, 154, 751, 404),
driver->draw2DImage(showimg, recti(660 * xScale - (CARD_IMG_WIDTH / 2) * yScale, 154 * yScale, 660 * xScale + (CARD_IMG_WIDTH / 2) * yScale, 404 * yScale),
recti(0, 0, orisize.Width, orisize.Height), 0, matManager.c2d, true);
if(showcarddif < 255)
showcarddif += 17;
break;
}
case 5: {
case 5: {//show card special summoning
matManager.c2d[0] = (showcarddif << 25) | 0xffffff;
matManager.c2d[1] = (showcarddif << 25) | 0xffffff;
matManager.c2d[2] = (showcarddif << 25) | 0xffffff;
matManager.c2d[3] = (showcarddif << 25) | 0xffffff;
driver->draw2DImage(imageManager.GetTexture(showcardcode), Resize(662 - showcarddif * 0.69685f, 277 - showcarddif, 662 + showcarddif * 0.69685f, 277 + showcarddif),
driver->draw2DImage(showimg, recti(660 * xScale - showcarddif * 0.69685f * yScale, (277 - showcarddif) * yScale, 660 * xScale + showcarddif * 0.69685f * yScale, (277 + showcarddif) * yScale),
recti(0, 0, orisize.Width, orisize.Height), 0, matManager.c2d, true);
if(showcarddif < 127)
showcarddif += 9;
break;
}
case 6: {
driver->draw2DImage(imageManager.GetTexture(showcardcode), Resize(574, 150, 574 + CARD_IMG_WIDTH, 150 + CARD_IMG_HEIGHT), recti(0, 0, orisize.Width, orisize.Height), 0, 0, true);
driver->draw2DImage(imageManager.tNumber, Resize(536 + showcarddif, 141 + showcarddif, 793 - showcarddif, 397 - showcarddif),
case 6: {//show time counter
driver->draw2DImage(showimg, recti(660 * xScale - (CARD_IMG_WIDTH / 2) * yScale, 150 * yScale, 660 * xScale + (CARD_IMG_WIDTH / 2) * yScale, (150 + CARD_IMG_HEIGHT) * yScale), recti(0, 0, orisize.Width, orisize.Height), 0, 0, true);
driver->draw2DImage(imageManager.tNumber, recti(660 * xScale - 130 * yScale + showcarddif * yScale, (141 + showcarddif) * yScale, 660 * xScale + 130 * yScale - showcarddif * yScale, (397 - showcarddif) * yScale),
recti((showcardp % 5) * 64, (showcardp / 5) * 64, (showcardp % 5 + 1) * 64, (showcardp / 5 + 1) * 64), 0, 0, true);
if(showcarddif < 64)
showcarddif += 4;
break;
}
case 7: {
case 7: {//show normal summoning
core::position2d<s32> corner[4];
float y = sin(showcarddif * 3.1415926f / 180.0f) * CARD_IMG_HEIGHT * mainGame->yScale;
corner[0] = core::position2d<s32>(574 * mainGame->xScale - (CARD_IMG_HEIGHT * mainGame->yScale - y) * 0.3f , 404 * mainGame->yScale - y);
corner[1] = core::position2d<s32>(751 * mainGame->xScale + (CARD_IMG_HEIGHT * mainGame->yScale - y) * 0.3f , 404 * mainGame->yScale - y);
corner[2] = core::position2d<s32>(574 * mainGame->xScale, 404 * mainGame->yScale);
corner[3] = core::position2d<s32>(751 * mainGame->xScale, 404 * mainGame->yScale);
irr::gui::Draw2DImageQuad(driver, imageManager.GetTexture(showcardcode), rect<s32>(0, 0, orisize.Width, orisize.Height), corner);
corner[0] = core::position2d<s32>(660 * xScale - (CARD_IMG_WIDTH / 2) * yScale - (CARD_IMG_HEIGHT * mainGame->yScale - y) * 0.3f , 404 * mainGame->yScale - y);
corner[1] = core::position2d<s32>(660 * xScale + (CARD_IMG_WIDTH / 2) * yScale + (CARD_IMG_HEIGHT * mainGame->yScale - y) * 0.3f , 404 * mainGame->yScale - y);
corner[2] = core::position2d<s32>(660 * xScale - (CARD_IMG_WIDTH / 2) * yScale, 404 * mainGame->yScale);
corner[3] = core::position2d<s32>(660 * xScale + (CARD_IMG_WIDTH / 2) * yScale, 404 * mainGame->yScale);
irr::gui::Draw2DImageQuad(driver, showimg, rect<s32>(0, 0, orisize.Width, orisize.Height), corner);
showcardp++;
showcarddif += 9;
if(showcarddif >= 90)
......@@ -907,7 +912,7 @@ void Game::DrawSpec() {
}
break;
}
case 100: {
case 100: {//show finger-guessing 3 buttons
if(showcardp < 60) {
driver->draw2DImage(imageManager.tHand[(showcardcode >> 16) & 0x3], Resize(615, showcarddif, 615 + 89, 128 + showcarddif), recti(0, 0, 89, 128), 0, 0, true);
driver->draw2DImage(imageManager.tHand[showcardcode & 0x3], Resize(615, 540 - showcarddif, 615 + 89, 128 + 540 - showcarddif), recti(0, 0, 89, 128), 0, 0, true);
......
......@@ -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