Commit ca18b39d authored by kenan's avatar kenan

game's width,height

parent c99935ed
...@@ -199,7 +199,7 @@ void Game::DrawBackGround() { ...@@ -199,7 +199,7 @@ void Game::DrawBackGround() {
DrawShadowText(numFont, dInfo.str_total_attack[1], recti(885 * mainGame->xScale, 271 * mainGame->yScale, 905 * mainGame->xScale, 291 * mainGame->yScale), recti(0, 1, 2, 0), dInfo.total_attack_color[1], 0xff000000, true, false, 0); DrawShadowText(numFont, dInfo.str_total_attack[1], recti(885 * mainGame->xScale, 271 * mainGame->yScale, 905 * mainGame->xScale, 291 * mainGame->yScale), recti(0, 1, 2, 0), dInfo.total_attack_color[1], 0xff000000, true, false, 0);
} else { } else {
driver->drawVertexPrimitiveList(matManager.vTotalAtkopT, 4, matManager.iRectangle, 2); driver->drawVertexPrimitiveList(matManager.vTotalAtkopT, 4, matManager.iRectangle, 2);
DrawShadowText(numFont, dInfo.str_total_attack[1], recti(740 * mainGame->xScale, 295 * mainGame->yScale, 760 * mainGame->xScale, 3315 * mainGame->yScale), recti(0, 1, 2, 0), dInfo.total_attack_color[1], 0xff000000, true, false, 0); DrawShadowText(numFont, dInfo.str_total_attack[1], recti(740 * mainGame->xScale, 295 * mainGame->yScale, 760 * mainGame->xScale, 315 * mainGame->yScale), recti(0, 1, 2, 0), dInfo.total_attack_color[1], 0xff000000, true, false, 0);
} }
} }
...@@ -1065,7 +1065,7 @@ void Game::DrawSpec() { ...@@ -1065,7 +1065,7 @@ void Game::DrawSpec() {
void Game::DrawBackImage(irr::video::ITexture* texture) { void Game::DrawBackImage(irr::video::ITexture* texture) {
if(!texture) if(!texture)
return; return;
driver->draw2DImage(texture, recti(0, 0, 1024 * mainGame->xScale, 640 * mainGame->yScale), recti(0, 0, texture->getOriginalSize().Width, texture->getOriginalSize().Height)); driver->draw2DImage(texture, recti(0, 0, GAME_WIDTH * mainGame->xScale, GAME_HEIGHT * mainGame->yScale), recti(0, 0, texture->getOriginalSize().Width, texture->getOriginalSize().Height));
} }
void Game::ShowElement(irr::gui::IGUIElement * win, int autoframe) { void Game::ShowElement(irr::gui::IGUIElement * win, int autoframe) {
FadingUnit fu; FadingUnit fu;
......
...@@ -2010,8 +2010,8 @@ void ClientField::GetHoverField(int x, int y) { ...@@ -2010,8 +2010,8 @@ void ClientField::GetHoverField(int x, int y) {
hovered_sequence = hc - 1 - (x - ofRect.UpperLeftCorner.X) * (hc - 1) / ((cardSize + cardSpace) * 5 * mainGame->xScale); hovered_sequence = hc - 1 - (x - ofRect.UpperLeftCorner.X) * (hc - 1) / ((cardSize + cardSpace) * 5 * mainGame->xScale);
} }
} else { } else {
double screenx = x / (1024.0 * mainGame->xScale) * 1.35 - 0.90; double screenx = x / (GAME_WIDTH * mainGame->xScale) * 1.35 - 0.90;
double screeny = y / (640.0 * mainGame->yScale) * 0.84 - 0.42; double screeny = y / (GAME_HEIGHT * mainGame->yScale) * 0.84 - 0.42;
double angle = 0.798056 - atan(screeny); //0.798056 = arctan(8.0/7.8) double angle = 0.798056 - atan(screeny); //0.798056 = arctan(8.0/7.8)
double vlen = sqrt(1.0 + screeny * screeny); double vlen = sqrt(1.0 + screeny * screeny);
double boardx = 4.2 + 7.8 * screenx / vlen / cos(angle); double boardx = 4.2 + 7.8 * screenx / vlen / cos(angle);
...@@ -2308,7 +2308,7 @@ void ClientField::ShowCardInfoInList(ClientCard* pcard, irr::gui::IGUIElement* e ...@@ -2308,7 +2308,7 @@ void ClientField::ShowCardInfoInList(ClientCard* pcard, irr::gui::IGUIElement* e
x = w + 10 * mainGame->xScale; x = w + 10 * mainGame->xScale;
if(x + w > 670 * mainGame->xScale) if(x + w > 670 * mainGame->xScale)
x = 670 * mainGame->xScale - w; x = 670 * mainGame->xScale - w;
mainGame->stCardListTip->setRelativePosition(recti(x - dTip.Width / 2, y - 10, x + dTip.Width / 2, y - 10 + dTip.Height)); mainGame->stCardListTip->setRelativePosition(recti(x - dTip.Width / 2, y - 10 * mainGame->yScale, x + dTip.Width / 2, y - 10 * mainGame->yScale + dTip.Height));
mainGame->stCardListTip->setVisible(true); mainGame->stCardListTip->setVisible(true);
} }
} }
......
...@@ -737,6 +737,14 @@ extern Game* mainGame; ...@@ -737,6 +737,14 @@ extern Game* mainGame;
#define CARD_ARTWORK_VERSIONS_OFFSET 10 #define CARD_ARTWORK_VERSIONS_OFFSET 10
#ifdef _IRR_ANDROID_PLATFORM_
#define GAME_WIDTH 1024
#define GAME_HEIGHT 640
#else
#define GAME_WIDTH 1280
#define GAME_HEIGHT 720
#endif
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
#define GUI_INFO_FPS 1000 #define GUI_INFO_FPS 1000
#endif #endif
......
...@@ -53,9 +53,13 @@ public abstract class GameApplication extends Application implements IrrlichtBri ...@@ -53,9 +53,13 @@ public abstract class GameApplication extends Application implements IrrlichtBri
isInitSoundEffectPool = initSoundEffectPool; isInitSoundEffectPool = initSoundEffectPool;
} }
public abstract int getGameWidth(); public int getGameWidth(){
return 1024;
}
public abstract int getGameHeight(); public int getGameHeight(){
return 640;
}
public abstract boolean isKeepScale(); public abstract boolean isKeepScale();
......
...@@ -213,9 +213,11 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -213,9 +213,11 @@ public class YGOMobileActivity extends NativeActivity implements
mFullScreenUtils.fullscreen(); mFullScreenUtils.fullscreen();
app().attachGame(this); app().attachGame(this);
//游戏大小 if(!app().isKeepScale()) {
int[] size = getGameSize(); //游戏大小
getWindow().setLayout(size[0], size[1]); int[] size = getGameSize();
getWindow().setLayout(size[0], size[1]);
}
} }
} }
...@@ -225,12 +227,16 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -225,12 +227,16 @@ public class YGOMobileActivity extends NativeActivity implements
float yScale = app().getYScale(); float yScale = app().getYScale();
int w = (int) (app().getGameWidth() * xScale); int w = (int) (app().getGameWidth() * xScale);
int h = (int) (app().getGameHeight() * yScale); int h = (int) (app().getGameHeight() * yScale);
Log.i("kk", "w=" + w + ",h=" + h + ",xScale=" + xScale + ",yScale=" + yScale); Log.i("kk", "w1=" + app().getGameWidth() + ",h1=" + app().getGameHeight() + ",w2=" + w + ",h2=" + h + ",xScale=" + xScale + ",yScale=" + yScale);
return new int[]{w, h}; return new int[]{w, h};
} }
@Override @Override
public void setContentView(View view) { public void setContentView(View view) {
if(!app().isKeepScale()) {
super.setContentView(view);
return;
}
int[] size = getGameSize(); int[] size = getGameSize();
int w = size[0]; int w = size[0];
int h = size[1]; int h = size[1];
......
...@@ -53,12 +53,12 @@ public class App extends GameApplication { ...@@ -53,12 +53,12 @@ public class App extends GameApplication {
@Override @Override
public float getXScale() { public float getXScale() {
return AppsSettings.get().getXScale(); return AppsSettings.get().getXScale(getGameWidth(), getGameHeight());
} }
@Override @Override
public float getYScale() { public float getYScale() {
return AppsSettings.get().getYScale(); return AppsSettings.get().getYScale(getGameWidth(), getGameHeight());
} }
@Override @Override
...@@ -76,16 +76,6 @@ public class App extends GameApplication { ...@@ -76,16 +76,6 @@ public class App extends GameApplication {
return AppsSettings.get().isKeepScale(); return AppsSettings.get().isKeepScale();
} }
@Override
public int getGameHeight() {
return Constants.CORE_GAME_SIZE[1];
}
@Override
public int getGameWidth() {
return Constants.CORE_GAME_SIZE[0];
}
@Override @Override
public void saveSetting(String key, String value) { public void saveSetting(String key, String value) {
AppsSettings.get().saveSettings(key, value); AppsSettings.get().saveSettings(key, value);
......
...@@ -185,31 +185,23 @@ public class AppsSettings { ...@@ -185,31 +185,23 @@ public class AppsSettings {
return false;//mSharedPreferences.getBoolean(PREF_DECK_MANAGER_V2, DEF_PREF_DECK_MANAGER_V2); return false;//mSharedPreferences.getBoolean(PREF_DECK_MANAGER_V2, DEF_PREF_DECK_MANAGER_V2);
} }
public float getGameHeight() { public float getXScale(int w, int h) {
return (float)Constants.CORE_GAME_SIZE[1];
}
public float getGameWidth() {
return (float)Constants.CORE_GAME_SIZE[0];
}
public float getXScale() {
if(isKeepScale()){ if(isKeepScale()){
float sx = getScreenHeight() / getGameWidth(); float sx = getScreenHeight() / w;
float sy = getScreenWidth() / getGameHeight(); float sy = getScreenWidth() / h;
return Math.min(sx, sy); return Math.min(sx, sy);
} }
return getScreenHeight() / getGameWidth(); return getScreenHeight() / w;
} }
public float getYScale() { public float getYScale(int w, int h) {
if(isKeepScale()){ if(isKeepScale()){
//固定比例,取最小值 //固定比例,取最小值
float sx = getScreenHeight() / getGameWidth(); float sx = getScreenHeight() / w;
float sy = getScreenWidth() / getGameHeight(); float sy = getScreenWidth() / h;
return Math.min(sx, sy); return Math.min(sx, sy);
} }
return getScreenWidth() / getGameHeight(); return getScreenWidth() / h;
} }
public boolean isKeepScale(){ public boolean isKeepScale(){
......
...@@ -90,7 +90,6 @@ public interface Constants { ...@@ -90,7 +90,6 @@ public interface Constants {
String CORE_SKIN_AVATAR_OPPONENT = "opponent.jpg"; String CORE_SKIN_AVATAR_OPPONENT = "opponent.jpg";
String UNKNOWN_IMAGE = "unknown.jpg"; String UNKNOWN_IMAGE = "unknown.jpg";
String YDK_FILE_EX = ".ydk"; String YDK_FILE_EX = ".ydk";
int[] CORE_GAME_SIZE = new int[]{1024, 640};
int[] CORE_SKIN_BG_SIZE = new int[]{1280, 720}; int[] CORE_SKIN_BG_SIZE = new int[]{1280, 720};
int[] CORE_SKIN_CARD_COVER_SIZE = new int[]{177, 254}; int[] CORE_SKIN_CARD_COVER_SIZE = new int[]{177, 254};
int[] CORE_SKIN_AVATAR_SIZE = new int[]{128, 128}; int[] CORE_SKIN_AVATAR_SIZE = new int[]{128, 128};
......
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