Commit 7a8a5849 authored by 247321453's avatar 247321453

Merge branch 'master' into cc

parents 15edc972 ae187ac6
......@@ -192,10 +192,10 @@ const wchar_t* DataManager::GetText(int code) {
return unknown_string;
}
const wchar_t* DataManager::GetDesc(int strCode) {
if(strCode < 10000)
if((unsigned int)strCode < 10000u)
return GetSysString(strCode);
int code = strCode >> 4;
int offset = strCode & 0xf;
unsigned int code = strCode >> 4;
unsigned int offset = strCode & 0xf;
auto csit = _strings.find(code);
if(csit == _strings.end())
return unknown_string;
......
......@@ -1059,17 +1059,13 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
ChangeToIGUIImageButton(btnReplayCancel, imageManager.tButton_S, imageManager.tButton_S_pressed);
env->addStaticText(dataManager.GetSysString(1349), rect<s32>(320 * xScale, 30 * yScale, 550 * xScale, 50 * yScale), false, true, wReplay);
stReplayInfo = env->addStaticText(L"", rect<s32>(320 * xScale, 60 * yScale, 570 * xScale, 315 * yScale), false, true, wReplay);
env->addStaticText(dataManager.GetSysString(1353), rect<s32>(320 * xScale, 180 * yScale, 550 * xScale, 200 * yScale), false, true, wReplay);
ebRepStartTurn = CAndroidGUIEditBox::addAndroidEditBox(L"", true, env, rect<s32>(320 * xScale, 210 * yScale, 430 * xScale, 250 * yScale), wReplay, -1);
ebRepStartTurn->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
btnExportDeck = env->addButton(rect<s32>(440 * xScale, 260 * yScale, 550 * xScale, 300 * yScale), wReplay, BUTTON_EXPORT_DECK, dataManager.GetSysString(1282));
ChangeToIGUIImageButton(btnExportDeck, imageManager.tButton_S, imageManager.tButton_S_pressed);
btnShareReplay = env->addButton(rect<s32>(320 * xScale, 260 * yScale, 430 * xScale, 300 * yScale), wReplay, BUTTON_SHARE_REPLAY, dataManager.GetSysString(1368));
ChangeToIGUIImageButton(btnShareReplay, imageManager.tButton_S, imageManager.tButton_S_pressed);
ChangeToIGUIImageButton(btnShareReplay, imageManager.tButton_S, imageManager.tButton_S_pressed);
//single play window
wSinglePlay = env->addWindow(rect<s32>(220 * xScale, 100 * yScale, 800 * xScale, 520 * yScale), false, dataManager.GetSysString(1201));
wSinglePlay->getCloseButton()->setVisible(false);
......@@ -1348,6 +1344,7 @@ void Game::MainLoop() {
}
#endif
while(device->run()) {
ALOGV("game draw frame");
linePatternD3D = (linePatternD3D + 1) % 30;
linePatternGL = (linePatternGL << 1) | (linePatternGL >> 15);
atkframe += 0.1f;
......
......@@ -394,8 +394,8 @@ public:
irr::gui::IGUIButton* btnRenameReplay;//
irr::gui::IGUIButton* btnReplayCancel;//
irr::gui::IGUIButton* btnExportDeck;//
irr::gui::IGUIButton* btnShareReplay;//
irr::gui::IGUIEditBox* ebRepStartTurn;
irr::gui::IGUIButton* btnShareReplay;
//single play
irr::gui::IGUIWindow* wSinglePlay;
irr::gui::IGUIImage* bgSinglePlay;
......
......@@ -15,7 +15,7 @@ void ClickButton(irr::gui::IGUIElement* btn) {
event.GUIEvent.Caller = btn;
ygo::mainGame->device->postEventFromUser(event);
}
char* sub_string(const char* str, int start, int count=-1){
char* sub_string(const char* str, int start, int count = -1){
char* tmp = new char[1024];
int len = strlen(str);
int index = 0;
......@@ -61,6 +61,7 @@ int main(int argc, char* argv[]) {
* -j: join host (host info from system.conf)
* -d: deck edit
* -r: replay
* -s:single
*/
bool keep_on_return = false;
#ifdef _IRR_ANDROID_PLATFORM_
......@@ -94,12 +95,12 @@ int main(int argc, char* argv[]) {
break;
} else if(!strcmp(arg, "-r")) { // Replay
exit_on_return = !keep_on_return;
//显示录像窗口
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
ygo::mainGame->ShowElement(ygo::mainGame->wReplay);
ygo::mainGame->ebRepStartTurn->setText(L"1");
ygo::mainGame->stReplayInfo->setText(L"");
ygo::mainGame->RefreshReplay();
//显示录像窗口
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
ygo::mainGame->ShowElement(ygo::mainGame->wReplay);
ygo::mainGame->ebRepStartTurn->setText(L"1");
ygo::mainGame->stReplayInfo->setText(L"");
ygo::mainGame->RefreshReplay();
int index = -1;
if((i+1) < argc){//下一个参数是录像名
#ifdef _IRR_ANDROID_PLATFORM_
......@@ -115,7 +116,7 @@ int main(int argc, char* argv[]) {
}
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
ClickButton(ygo::mainGame->btnReplayMode);
if (index >= 0) {
if (index >= 0) {
ygo::mainGame->lstReplayList->setSelected(index);
ClickButton(ygo::mainGame->btnLoadReplay);
}
......@@ -123,12 +124,12 @@ int main(int argc, char* argv[]) {
break;//只播放一个
} else if(!strcmp(arg, "-s")) { // Single
exit_on_return = !keep_on_return;
//显示单人模式窗口
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
ygo::mainGame->ShowElement(ygo::mainGame->wSinglePlay);
ygo::mainGame->RefreshSingleplay();
ygo::mainGame->RefreshBot();
int index = -1;
//显示残局窗口
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
ygo::mainGame->ShowElement(ygo::mainGame->wSinglePlay);
ygo::mainGame->RefreshSingleplay();
ygo::mainGame->RefreshBot();
int index = -1;
if((i+1) < argc){//下一个参数是文件名
#ifdef _IRR_ANDROID_PLATFORM_
const char* name = argv[i+1].c_str();
......
......@@ -273,24 +273,23 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
prev_sel = sel;
break;
}
case BUTTON_SHARE_REPLAY: {
int sel = mainGame->lstReplayList->getSelected();
if(sel == -1)
break;
mainGame->gMutex.lock();
char name[1024];
BufferIO::EncodeUTF8(mainGame->lstReplayList->getListItem(sel), name);
mainGame->gMutex.unlock();
prev_operation = id;
prev_sel = sel;
#if defined(_IRR_ANDROID_PLATFORM_)
ALOGD("1share replay file=%s", name);
android::OnShareFile(mainGame->appMain, "yrp", name);
ALOGD("2after share replay file:index=%d", sel);
case BUTTON_SHARE_REPLAY: {
int sel = mainGame->lstReplayList->getSelected();
if(sel == -1)
break;
mainGame->gMutex.lock();
char name[1024];
BufferIO::EncodeUTF8(mainGame->lstReplayList->getListItem(sel), name);
mainGame->gMutex.unlock();
prev_operation = id;
prev_sel = sel;
#ifdef _IRR_ANDROID_PLATFORM_
ALOGD("1share replay file=%s", name);
android::OnShareFile(mainGame->appMain, "yrp", name);
ALOGD("2after share replay file:index=%d", sel);
#endif
break;
}
break;
}
case BUTTON_RENAME_REPLAY: {
int sel = mainGame->lstReplayList->getSelected();
if(sel == -1)
......
......@@ -23,17 +23,17 @@ InitOptions::InitOptions(void*data) :
char* rawdata = (char*)data;
int tmplength = 0;
m_opengles_version = BufferIO::ReadInt32(rawdata);
m_card_quality = BufferIO::ReadInt32(rawdata);
m_font_aa_enabled = BufferIO::ReadInt32(rawdata) > 0;
m_ps_enabled = BufferIO::ReadInt32(rawdata) > 0;
//cache dir
ReadString(m_work_dir, rawdata);
//cdbs
cdb_count = BufferIO::ReadInt32(rawdata);
m_db_files = new io::path[cdb_count];
for(int i = 0;i < cdb_count; i++){
io::path tmp_path;
ReadString(tmp_path, rawdata);
......@@ -64,7 +64,7 @@ irr::io::path getExternalStorageDir(ANDROID_APP app) {
return ret;
JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL);
app->activity->vm->AttachCurrentThread(&jni, nullptr);
if (!jni)
return ret;
jclass classEnvironment = jni->FindClass("android/os/Environment");
......@@ -807,6 +807,30 @@ int getLocalAddr(ANDROID_APP app) {
return addr;
}
void OnShareFile(ANDROID_APP app, const char* _type, const char* name){
if (!app || !app->activity || !app->activity->vm)
return;
JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, nullptr);
if (!jni)
return;
jobject lNativeActivity = app->activity->clazz;
jclass ClassNativeActivity = jni->GetObjectClass(lNativeActivity);
jmethodID methodId = jni->GetMethodID(ClassNativeActivity, "shareFile", "(Ljava/lang/String;Ljava/lang/String;)V");
jstring s_title = jni->NewStringUTF(_type);
jstring s_ext = jni->NewStringUTF(name);
jni->CallVoidMethod(lNativeActivity, methodId, s_title, s_ext);
if (s_title) {
//不需要用ReleaseStringUTFChars,因为是c变量,函数外面自己释放
jni->DeleteLocalRef(s_title);
}
if (s_ext) {
jni->DeleteLocalRef(s_ext);
}
jni->DeleteLocalRef(ClassNativeActivity);
app->activity->vm->DetachCurrentThread();
}
void showAndroidComboBoxCompat(ANDROID_APP app, bool pShow, char** pContents,
int count, int mode) {
if (!app || !app->activity || !app->activity->vm)
......@@ -967,31 +991,6 @@ bool android_deck_delete(const char* deck_name) {
return status == 0;
}
void OnShareFile(ANDROID_APP app,const char* title,const char* path){
if (!app || !app->activity || !app->activity->vm)
return;
JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, nullptr);
if (!jni)
return;
jobject lNativeActivity = app->activity->clazz;
jclass ClassNativeActivity = jni->GetObjectClass(lNativeActivity);
jmethodID methodId = jni->GetMethodID(ClassNativeActivity, "shareFile", "(Ljava/lang/String;Ljava/lang/String;)V");
jstring s_title = jni->NewStringUTF(title);
jstring s_path = jni->NewStringUTF(path);
jni->CallVoidMethod(lNativeActivity, methodId, s_title, s_path);
if (s_title) {
//不需要用ReleaseStringUTFChars,因为是c变量,函数外面自己释放
jni->DeleteLocalRef(s_title);
}
if (s_path) {
jni->DeleteLocalRef(s_path);
}
jni->DeleteLocalRef(ClassNativeActivity);
app->activity->vm->DetachCurrentThread();
}
void runWindbot(ANDROID_APP app, const char* args) {
if (!app || !app->activity || !app->activity->vm)
return;
......
......@@ -99,7 +99,7 @@ extern float getScreenWidth(ANDROID_APP app);
extern float getScreenHeight(ANDROID_APP app);
extern void OnShareFile(ANDROID_APP app,const char* title,const char* path);
extern void OnShareFile(ANDROID_APP app, const char* _type, const char* name);
// Get SDCard path.
extern irr::io::path getExternalStorageDir(ANDROID_APP app);
......
......@@ -5,6 +5,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application>
<activity
......
......@@ -66,7 +66,6 @@ public class YGOMobileActivity extends NativeActivity implements
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) :
View.SYSTEM_UI_FLAG_LOW_PROFILE;
protected View mContentView;
protected ComboBoxCompat mGlobalComboBox;
protected EditWindowCompat mGlobalEditText;
......@@ -109,7 +108,7 @@ public class YGOMobileActivity extends NativeActivity implements
@SuppressWarnings("WrongConstant")
@Override
protected void onCreate(Bundle savedInstanceState) {
if(USE_SURFACE) {
if (USE_SURFACE) {
mSurfaceView = new SurfaceView(this);
}
mFullScreenUtils = new FullScreenUtils(this, app().isImmerSiveMode());
......@@ -119,7 +118,7 @@ public class YGOMobileActivity extends NativeActivity implements
mArgV = IrrlichtBridge.getArgs(getIntent());
//
super.onCreate(savedInstanceState);
Log.e("YGOStarter","跳转完成"+System.currentTimeMillis());
Log.e("YGOStarter", "跳转完成" + System.currentTimeMillis());
if (sChainControlXPostion < 0) {
initPostion();
}
......@@ -139,7 +138,7 @@ public class YGOMobileActivity extends NativeActivity implements
@Override
protected void onResume() {
super.onResume();
Log.e("YGOStarter","ygo显示"+System.currentTimeMillis());
Log.e("YGOStarter", "ygo显示" + System.currentTimeMillis());
if (mLock == null) {
if (mPM == null) {
mPM = (PowerManager) getSystemService(POWER_SERVICE);
......@@ -222,7 +221,7 @@ public class YGOMobileActivity extends NativeActivity implements
}
}
private int[] getGameSize(){
private int[] getGameSize() {
//调整padding
float xScale = app().getXScale();
float yScale = app().getYScale();
......@@ -272,7 +271,7 @@ public class YGOMobileActivity extends NativeActivity implements
}
}
private void changeGameSize(){
private void changeGameSize() {
//游戏大小
int[] size = getGameSize();
int w = (int) app().getScreenHeight();
......@@ -474,7 +473,7 @@ public class YGOMobileActivity extends NativeActivity implements
@Override
public void surfaceCreated(SurfaceHolder holder) {
if(USE_SURFACE) {
if (USE_SURFACE) {
if (!replaced) {
return;
}
......@@ -484,7 +483,7 @@ public class YGOMobileActivity extends NativeActivity implements
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
if(USE_SURFACE) {
if (USE_SURFACE) {
if (!replaced) {
return;
}
......@@ -494,7 +493,7 @@ public class YGOMobileActivity extends NativeActivity implements
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
if(USE_SURFACE) {
if (USE_SURFACE) {
if (!replaced) {
return;
}
......@@ -504,7 +503,7 @@ public class YGOMobileActivity extends NativeActivity implements
@Override
public void surfaceRedrawNeeded(SurfaceHolder holder) {
if(USE_SURFACE) {
if (USE_SURFACE) {
if (!replaced) {
return;
}
......@@ -513,14 +512,15 @@ public class YGOMobileActivity extends NativeActivity implements
}
@Override
public void shareFile(final String type, final String path) {
public void shareFile(final String type, final String name) {
//TODO 分享文件
runOnUiThread(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(ACTION_SHARE_FILE);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.putExtra(IrrlichtBridge.EXTRA_SHARE_TYPE, type);
intent.putExtra(IrrlichtBridge.EXTRA_SHARE_FILE, path);
intent.putExtra(IrrlichtBridge.EXTRA_SHARE_FILE, name);
intent.setPackage(getPackageName());
try {
startActivity(intent);
......
......@@ -34,6 +34,7 @@ public final class IrrlichtBridge {
public static final String ACTION_SHARE_FILE = "cn.garymb.ygomobile.game.shared.file";
public static final String EXTRA_SHARE_FILE = Intent.EXTRA_STREAM;
public static final String EXTRA_SHARE_TYPE = Intent.EXTRA_TITLE;
//
public static final String EXTRA_PID = "extras.mypid";
public static final String EXTRA_ARGV = "extras.argv";
public static final String EXTRA_ARGV_TIME_OUT = "extras.argv_timeout";
......@@ -43,10 +44,12 @@ public final class IrrlichtBridge {
public static final String TAG = "ygo-java";
public static int gPid;
public static long sNativeHandle;
static {
try {
System.loadLibrary("YGOMobile");
}catch (Throwable e){
} catch (Throwable e) {
//ignore
}
}
......@@ -55,17 +58,21 @@ public final class IrrlichtBridge {
}
public static long sNativeHandle;
//显示卡图
public static native byte[] nativeBpgImage(byte[] data);
//插入文本(大概是发送消息)
private static native void nativeInsertText(long handle, String text);
//刷新文字
private static native void nativeRefreshTexture(long handle);
//忽略时点
private static native void nativeIgnoreChain(long handle, boolean begin);
//强制时点
private static native void nativeReactChain(long handle, boolean begin);
//取消连锁
private static native void nativeCancelChain(long handle);
......@@ -148,7 +155,7 @@ public final class IrrlichtBridge {
}
}
public static void setInputFix(int x, int y){
public static void setInputFix(int x, int y) {
nativeSetInputFix(sNativeHandle, x, y);
}
......@@ -193,20 +200,20 @@ public final class IrrlichtBridge {
String getSetting(String key);
int getIntSetting(String key,int def);
int getIntSetting(String key, int def);
void saveIntSetting(String key,int value);
void saveIntSetting(String key, int value);
float getScreenWidth();
float getScreenHeight();
void runWindbot(String args);
float getXScale();
float getYScale();
// float getSmallerSize();
// float getXScale();
// float getYScale();
......@@ -224,7 +231,7 @@ public final class IrrlichtBridge {
void showComboBoxCompat(String[] items, boolean isShow, int mode);
void shareFile(String title, String path);
void shareFile(String type, String name);
void performHapticFeedback();
......
......@@ -4,6 +4,8 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application>
<activity
android:name="cn.garymb.ygomobile.YGOMobileActivity"
......
......@@ -13,16 +13,18 @@
本软件基于圆神开发组的电脑版源码,采用OpenGL适配安卓+安卓客户端ui开发而成。
注意:本软件使用图片音响素材仅供个人学习交流之用,本身不用于商业用途。
如果您是通过付费购买或者付费获得下载渠道而获得本软件的话,您已经上当受骗。本软件——免费!
特别感谢: 菜菜,尸体,废话多,大毛,龙道香姐,晓L,幻兽L 的支持与努力.
特别感谢: 尸体233,废话多,大毛,幻兽L 的支持与努力.
</pre>
<ul>
<li style="color:#ffff00">3.8.6</li>
<li style="color:#ffff00">3.8.7</li>
</ul>
<pre>
更新:
1.更新ygo内核;
2.新卡SD42;
3.TCG2021.7禁卡表
2.新卡1106+KICO+VJ;
3.新增残局lua文件用本app打开进入对局;
4.新增录像yrp文件用本app打开进入观看;
5.新增发送yrp文件到QQ微信等应用;
</pre>
<h3 style="color:#ff0000">注意</h3>
<pre>
......
......@@ -1082,6 +1082,7 @@
#setname 0x158 圣 サン
!setname 0x1158 圣蔓 サンヴァイン
!setname 0x2158 圣天树 サンアバロン
!setname 0x4158 圣种 サンシード
!setname 0x159 圣夜骑士 ホーリーナイツ
!setname 0x15a 人偶怪兽 ドール・モンスター
!setname 0x15b 惊乐 アメイズメント
......@@ -1101,3 +1102,7 @@
!setname 0x168 隐形水母怪 ステルス・クラーゲン
!setname 0x169 原数天灵 ヌメロニアス
!setname 0x16a 编号系 ナンバーズ
!setname 0x16b 相剑 相剣
!setname 0x16c 冰水 氷水
!setname 0x16d 随风旅鸟 ふわんだりぃず
!setname 0x16e 拓扑 トポロジック
......@@ -12,7 +12,7 @@
<server>
<player-name>Knight of Hanoi</player-name>
<name>决斗编年史</name>
<ip>2333.duelstart.com</ip>
<ip>duels.link</ip>
<port>2333</port>
<keep>true</keep>
</server>
......
......@@ -409,6 +409,7 @@
!system 1365 Fail to rename, maybe there're replay with same name.
!system 1366 Auto Save Replay
!system 1367 Replay already saved as %ls.yrp
!system 1368 Replay share
!system 1370 Level
!system 1371 ATK
!system 1372 DEF
......@@ -1072,6 +1073,7 @@
#setname 0x158 サン
!setname 0x1158 Sunvine
!setname 0x2158 Sunavalon
!setname 0x4158 Sunseed
!setname 0x159 Starry Knight
!setname 0x15a Doll Monster
!setname 0x15b Amazement
......@@ -1091,3 +1093,7 @@
!setname 0x168 Kragen
!setname 0x169 Numeronius
!setname 0x16a Number
!setname 0x16b Xiangjian
!setname 0x16c Icejade
!setname 0x16d Flundereeze
!setname 0x16e Topologic
......@@ -409,6 +409,7 @@
!system 1365 리플레이 이름을 바꾸는 중에 오류가 났습니다. 입력한 이름과 동일한 파일이 존재합니다.
!system 1366 자동으로 리플레이 저장
!system 1367 다음과 같이 저장되었습니다. %ls.yrp
!system 1368 리플레이 공유
!system 1370 레벨↑
!system 1371 공격력↑
!system 1372 수비력↑
......@@ -627,6 +628,7 @@
!counter 0x5b 카운터(베어루크티 빅디퍼)
!counter 0x105c 연소 카운터
!counter 0x5d 카운터(기교전-카미츠카와시메노키키에)
!counter 0x5e 황의 열쇠
#setnames, using tab for comment
!setname 0x1 얼리 오브 저스티스(정발명:A·O·J)
!setname 0x2 제넥스
......@@ -1079,6 +1081,7 @@
#setname 0x158 생
!setname 0x1158 생바인
!setname 0x2158 생아발론
!setname 0x4158 생시드
!setname 0x159 홀리나이츠
!setname 0x15a 돌 몬스터
!setname 0x15b 어메이즈먼트
......@@ -1097,3 +1100,8 @@
!setname 0x2167 숲의 성령
!setname 0x168 스텔스 크라겐
!setname 0x169 누메로니어스
!setname 0x16a 넘버즈
!setname 0x16b 상검
!setname 0x16c 히스이
!setname 0x16d 후완다리즈
!setname 0x16e 토폴로직
\ No newline at end of file
......@@ -9,8 +9,8 @@ android {
minSdkVersion 21
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 29
versionCode 380400630
versionName "3.8.6"
versionCode 380700801
versionName "3.8.7"
flavorDimensions "versionCode"
vectorDrawables.useSupportLibrary = true
ndk {
......
......@@ -189,7 +189,7 @@
android:windowSoftInputMode="stateHidden|adjustResize" />
<activity android:name="cn.garymb.ygomobile.ui.mycard.mcchat.SplashActivity" />
<activity android:name="cn.garymb.ygomobile.ui.activities.FileLogActivity" />
<activity
<activity
android:name="cn.garymb.ygomobile.ui.activities.PermissionsActivity"
android:theme="@style/TranslucentTheme"/>
<meta-data
......
......@@ -3,7 +3,6 @@ package cn.garymb.ygomobile;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Point;
import android.os.Environment;
import android.text.TextUtils;
import android.util.Log;
import android.view.WindowManager;
......@@ -49,11 +48,11 @@ import static cn.garymb.ygomobile.Constants.YDK_FILE_EX;
public class AppsSettings {
private static final String PREF_VERSION = "app_version";
private static AppsSettings sAppsSettings;
private final Point mScreenSize = new Point();
private final Point mRealScreenSize = new Point();
private Context context;
private PreferenceFragmentPlus.SharedPreferencesPlus mSharedPreferences;
private float mDensity;
private final Point mScreenSize = new Point();
private final Point mRealScreenSize = new Point();
private AppsSettings(Context context) {
this.context = context;
......
......@@ -90,7 +90,7 @@ public class GameUriManager {
int index = path.lastIndexOf("/");
if (index > 0) {
String name = path.substring(index + 1);
if(withOutEx) {
if (withOutEx) {
index = name.lastIndexOf(".");
if (index > 0) {
//1.ydk
......@@ -129,7 +129,7 @@ public class GameUriManager {
return TextUtils.equals(deck, file.getParentFile().getAbsolutePath());
}
private File toLocalFile(Uri uri){
private File toLocalFile(Uri uri) {
String path = uri.getPath();
File remoteFile = null;
if ("file".equals(uri.getScheme())) {
......@@ -156,7 +156,7 @@ public class GameUriManager {
}
String name = getPathName(path, false);
File local;
if(name.toLowerCase(Locale.US).endsWith(".ydk")){
if (name.toLowerCase(Locale.US).endsWith(".ydk")) {
File dir = Constants.COPY_YDK_FILE ? new File(AppsSettings.get().getDeckDir()) : new File(getActivity().getApplicationInfo().dataDir, "cache");
local = getDeckFile(dir, name);
} else if (name.toLowerCase(Locale.US).endsWith(".ypk")) {
......@@ -171,7 +171,7 @@ public class GameUriManager {
if (local.exists()) {
Log.w(Constants.TAG, "Overwrite file "+local.getAbsolutePath());
}
if(remoteFile != null && TextUtils.equals(remoteFile.getAbsolutePath(), local.getAbsolutePath())){
if (remoteFile != null && TextUtils.equals(remoteFile.getAbsolutePath(), local.getAbsolutePath())) {
//is same path
Log.i(Constants.TAG, "is same file " + remoteFile.getAbsolutePath() + "==" + local.getAbsolutePath());
return local;
......@@ -181,10 +181,10 @@ public class GameUriManager {
FileInputStream input = null;
try {
File dir = local.getParentFile();
if(!dir.exists()){
if (!dir.exists()) {
dir.mkdirs();
}
if(remoteFile != null){
if (remoteFile != null) {
FileUtils.copyFile(remoteFile, local);
} else {
pfd = getActivity().getContentResolver().openFileDescriptor(uri, "r");
......@@ -205,7 +205,7 @@ public class GameUriManager {
Intent startSeting = new Intent(activity, SettingsActivity.class);
if ("file".equals(uri.getScheme()) || "content".equals(uri.getScheme())) {
File file = toLocalFile(uri);
if(file == null || !file.exists()){
if (file == null || !file.exists()) {
Toast.makeText(activity, "open file error", Toast.LENGTH_LONG).show();
return;
}
......@@ -214,11 +214,11 @@ public class GameUriManager {
boolean isYrp = file.getName().toLowerCase(Locale.US).endsWith(".yrp");
boolean isLua = file.getName().toLowerCase(Locale.US).endsWith(".lua");
Log.i(Constants.TAG, "open file:" + uri + "->" + file.getAbsolutePath());
if(isYdk){
if (isYdk) {
Intent intent = new Intent(getActivity(), DeckManagerActivity.getDeckManager());
intent.putExtra(Intent.EXTRA_TEXT, file.getAbsolutePath());
activity.startActivity(intent);
} else if(isYpk){
} else if (isYpk) {
if (!AppsSettings.get().isReadExpansions()) {
activity.startActivity(startSeting);
Toast.makeText(activity, R.string.ypk_go_setting, Toast.LENGTH_LONG).show();
......@@ -226,14 +226,14 @@ public class GameUriManager {
DataManager.get().load(true);
Toast.makeText(activity, R.string.ypk_installed, Toast.LENGTH_LONG).show();
}
} else if(isYrp){
} else if (isYrp) {
if (!YGOStarter.isGameRunning(getActivity())) {
YGOStarter.startGame(getActivity(), null, "-r", file.getName());
Toast.makeText(activity, activity.getString(R.string.yrp_installed), Toast.LENGTH_LONG).show();
Toast.makeText(activity, activity.getString(R.string.file_installed), Toast.LENGTH_LONG).show();
} else {
Log.w(Constants.TAG, "game is running");
}
} else if(isLua){
} else if (isLua) {
if (!YGOStarter.isGameRunning(getActivity())) {
YGOStarter.startGame(getActivity(), null, "-s", file.getName());
Toast.makeText(activity, "load single lua file", Toast.LENGTH_LONG).show();
......
......@@ -24,7 +24,6 @@ import cn.garymb.ygomobile.AppsSettings;
import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.loader.CardLoader;
import cn.garymb.ygomobile.loader.ICardLoader;
import cn.garymb.ygomobile.ui.activities.BaseActivity;
import cn.garymb.ygomobile.ui.adapters.SimpleSpinnerAdapter;
import cn.garymb.ygomobile.ui.adapters.SimpleSpinnerItem;
import cn.garymb.ygomobile.ui.plus.DialogPlus;
......@@ -59,7 +58,8 @@ public class CardSearcher implements View.OnClickListener {
private Spinner typeSpinner;
private Spinner typeMonsterSpinner;
private Spinner typeMonsterSpinner2;
private Spinner typeSTSpinner;
private Spinner typeSpellSpinner;
private Spinner typeTrapSpinner;
private Spinner setcodeSpinner;
private Spinner categorySpinner;
private Spinner raceSpinner;
......@@ -104,7 +104,8 @@ public class CardSearcher implements View.OnClickListener {
typeSpinner = findViewById(R.id.sp_type_card);
typeMonsterSpinner = findViewById(R.id.sp_type_monster);
typeMonsterSpinner2 = findViewById(R.id.sp_type_monster2);
typeSTSpinner = findViewById(R.id.sp_type_st);
typeSpellSpinner = findViewById(R.id.sp_type_spell);
typeTrapSpinner = findViewById(R.id.sp_type_trap);
setcodeSpinner = findViewById(R.id.sp_setcode);
categorySpinner = findViewById(R.id.sp_category);
raceSpinner = findViewById(R.id.sp_race);
......@@ -251,28 +252,40 @@ public class CardSearcher implements View.OnClickListener {
if (value == 0) {
layout_monster.setVisibility(View.INVISIBLE);
raceSpinner.setVisibility(View.GONE);
typeSTSpinner.setVisibility(View.INVISIBLE);
typeSpellSpinner.setVisibility(View.GONE);
typeTrapSpinner.setVisibility(View.GONE);
pScale.setVisibility(View.INVISIBLE);
LinkMarkerButton.setVisibility(View.INVISIBLE);
resetMonster();
} else if (value == CardType.Spell.value() || value == CardType.Trap.value()) {
} else if (value == CardType.Spell.value()) {
layout_monster.setVisibility(View.INVISIBLE);
raceSpinner.setVisibility(View.GONE);
typeSTSpinner.setVisibility(View.VISIBLE);
typeSpellSpinner.setVisibility(View.VISIBLE);
typeTrapSpinner.setVisibility(View.GONE);
pScale.setVisibility(View.INVISIBLE);
LinkMarkerButton.setVisibility(View.INVISIBLE);
resetMonster();
} else if (value == CardType.Trap.value()) {
layout_monster.setVisibility(View.INVISIBLE);
raceSpinner.setVisibility(View.GONE);
typeSpellSpinner.setVisibility(View.GONE);
typeTrapSpinner.setVisibility(View.VISIBLE);
pScale.setVisibility(View.INVISIBLE);
LinkMarkerButton.setVisibility(View.INVISIBLE);
resetMonster();
} else {
layout_monster.setVisibility(View.VISIBLE);
raceSpinner.setVisibility(View.VISIBLE);
typeSTSpinner.setVisibility(View.GONE);
typeSpellSpinner.setVisibility(View.GONE);
typeTrapSpinner.setVisibility(View.GONE);
pScale.setVisibility(View.VISIBLE);
LinkMarkerButton.setVisibility(View.VISIBLE);
}
reset(pScale);
reset(raceSpinner);
reset(typeSTSpinner);
reset(typeSpellSpinner);
reset(typeTrapSpinner);
reset(typeMonsterSpinner);
reset(typeMonsterSpinner2);
}
......@@ -295,8 +308,10 @@ public class CardSearcher implements View.OnClickListener {
});
initTypeSpinners(typeMonsterSpinner2, new CardType[]{CardType.None, CardType.Pendulum, CardType.Tuner, CardType.Non_Effect
});
initTypeSpinners(typeSTSpinner, new CardType[]{CardType.None, CardType.Normal, CardType.QuickPlay, CardType.Ritual,
CardType.Continuous, CardType.Equip, CardType.Field, CardType.Counter
initTypeSpinners(typeSpellSpinner, new CardType[]{CardType.None, CardType.Normal, CardType.QuickPlay, CardType.Ritual,
CardType.Continuous, CardType.Equip, CardType.Field
});
initTypeSpinners(typeTrapSpinner, new CardType[]{CardType.None, CardType.Normal, CardType.Continuous, CardType.Counter
});
initLevelSpinners(levelSpinner);
initPscaleSpinners(pScale);
......@@ -545,7 +560,7 @@ public class CardSearcher implements View.OnClickListener {
text(atkText), text(defText),
getSelect(pScale),
getSelect(setcodeSpinner)
, getSelect(categorySpinner), getSelect(otSpinner), lineKey, getSelect(typeSpinner), getSelect(typeMonsterSpinner), getSelect(typeSTSpinner)
, getSelect(categorySpinner), getSelect(otSpinner), lineKey, getSelect(typeSpinner), getSelect(typeMonsterSpinner), getSelect(typeSpellSpinner), getSelect(typeTrapSpinner)
, getSelect(typeMonsterSpinner2));
lineKey = 0;
}
......@@ -566,7 +581,8 @@ public class CardSearcher implements View.OnClickListener {
}
reset(limitSpinner);
reset(typeSpinner);
reset(typeSTSpinner);
reset(typeSpellSpinner);
reset(typeTrapSpinner);
reset(setcodeSpinner);
reset(categorySpinner);
resetMonster();
......
......@@ -22,6 +22,7 @@ import cn.garymb.ygomobile.AppsSettings;
import cn.garymb.ygomobile.Constants;
import cn.garymb.ygomobile.GameUriManager;
import cn.garymb.ygomobile.YGOStarter;
import cn.garymb.ygomobile.core.IrrlichtBridge;
import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.ui.activities.WebActivity;
import cn.garymb.ygomobile.ui.plus.DialogPlus;
......@@ -49,13 +50,12 @@ public class MainActivity extends HomeActivity {
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE,
};
public ConfigManager favConf = DataManager.openConfig(AppsSettings.get().getSystemConfig());
ResCheckTask mResCheckTask;
private GameUriManager mGameUriManager;
private ImageUpdater mImageUpdater;
private boolean enableStart;
public ConfigManager favConf = DataManager.openConfig(AppsSettings.get().getSystemConfig());
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -176,7 +176,7 @@ public class MainActivity extends HomeActivity {
@Override
protected void onPermission(boolean isOk) {
super.onPermission(isOk);
if (isOk){
if (isOk) {
try {
FileUtils.copyDir(ORI_DECK, AppsSettings.get().getDeckDir(), false);
} catch (Throwable e) {
......@@ -299,7 +299,7 @@ public class MainActivity extends HomeActivity {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == Constants.REQUEST_SETTINGS_CODE){
if (requestCode == Constants.REQUEST_SETTINGS_CODE) {
//TODO
} else {
super.onActivityResult(requestCode, resultCode, data);
......
......@@ -25,8 +25,8 @@ import cn.garymb.ygomobile.Constants;
public class FileUtils {
public static Uri toUri(Context context, File file){
return FileProvider.getUriForFile(context, context.getPackageName()+".gamefiles", file);
public static Uri toUri(Context context, File file) {
return FileProvider.getUriForFile(context, context.getPackageName() + ".gamefiles", file);
}
public static boolean deleteFile(File file) {
......
......@@ -137,12 +137,19 @@
android:visibility="gone" />
<androidx.appcompat.widget.AppCompatSpinner
android:id="@+id/sp_type_st"
android:id="@+id/sp_type_spell"
style="@style/itemSpinnerStyle"
android:layout_width="0dp"
android:layout_height="@dimen/label_width_small"
android:layout_weight="1"
android:visibility="invisible" />
android:visibility="gone" />
<androidx.appcompat.widget.AppCompatSpinner
android:id="@+id/sp_type_trap"
style="@style/itemSpinnerStyle"
android:layout_width="0dp"
android:layout_height="@dimen/label_width_small"
android:layout_weight="1"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
......
......@@ -305,6 +305,6 @@
<string name="guide_search_result_count">여기에 검색 결과를 표시합니다</string>
<string name="about_delete_ex">만약 확장 카드를 사용하면서 문제가 발생했을 경우, 삭제하는 것도 좋은 선택이다</string>
<string name="title_delete_ex">확장 삭제</string>
<string name="yrp_installed">리플레이가 나왔습니다. 리플레이를 보려면 \"리플레이 보기\"를 누르십시오.</string>
<string name="file_installed">문건 나왔습니다.</string>
<string name="ask_delete_ex">지우려면 확인을 클릭하십시오.</string>
</resources>
......@@ -306,5 +306,5 @@
<string name="title_delete_ex">清空扩展卡包</string>
<string name="ask_delete_ex">点击确认以清空</string>
<string name="about_delete_ex">如果遇到拓展卡包问题时删除是个不错的办法</string>
<string name="yrp_installed">录像已导入,请在观看录像中选择查看</string>
<string name="file_installed">文件已导入</string>
</resources>
......@@ -308,6 +308,6 @@
<string name="guide_search_result_count">here shows search result count</string>
<string name="title_delete_ex">delete expansions</string>
<string name="about_delete_ex">if you need to delte all expansion cards</string>
<string name="yrp_installed">replay loaded, select it in \"\\Watch Replay\"\\</string>
<string name="file_installed">file loaded</string>
<string name="ask_delete_ex">Click OK to confirm the deletion</string>
</resources>
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