Commit fe56a18c authored by fallenstardust's avatar fallenstardust

分享文件名加拓展名

BUTTON_SHARE_REPLAY
parent 43dd2bb9
......@@ -1002,11 +1002,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, 240 * yScale, 550 * xScale, 260 * yScale), false, true, wReplay);
ebRepStartTurn = CAndroidGUIEditBox::addAndroidEditBox(L"", true, env, rect<s32>(320 * xScale, 260 * yScale, 430 * xScale, 300 * yScale), wReplay, -1);
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);
//single play window
wSinglePlay = env->addWindow(rect<s32>(220 * xScale, 100 * yScale, 800 * xScale, 520 * yScale), false, dataManager.GetSysString(1201));
wSinglePlay->getCloseButton()->setVisible(false);
......
......@@ -384,6 +384,7 @@ public:
irr::gui::IGUIButton* btnRenameReplay;//
irr::gui::IGUIButton* btnReplayCancel;//
irr::gui::IGUIButton* btnExportDeck;//
irr::gui::IGUIButton* btnShareReplay;//
irr::gui::IGUIEditBox* ebRepStartTurn;
//single play
irr::gui::IGUIWindow* wSinglePlay;
......@@ -732,6 +733,7 @@ private:
#define BUTTON_DELETE_REPLAY 133
#define BUTTON_RENAME_REPLAY 134
#define BUTTON_EXPORT_DECK 135
#define BUTTON_SHARE_REPLAY 136
#define BUTTON_REPLAY_START 140
#define BUTTON_REPLAY_PAUSE 141
#define BUTTON_REPLAY_STEP 142
......
......@@ -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;
......
......@@ -273,6 +273,24 @@ 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();
wchar_t textBuffer[256];
char name[1024];
char* fname= name;
myswprintf(textBuffer, L"%ls", mainGame->lstReplayList->getListItem(sel));
BufferIO::EncodeUTF8(textBuffer,fname);
__android_log_print(ANDROID_LOG_DEBUG, "ygo", "1share replay file=%s", fname);
android::OnShareFile(mainGame->appMain, fname, "yrp");
__android_log_print(ANDROID_LOG_DEBUG, "ygo", "2after share replay file:index=%s", fname);
mainGame->gMutex.unlock();
prev_operation = id;
prev_sel = sel;
break;
}
case BUTTON_RENAME_REPLAY: {
int sel = mainGame->lstReplayList->getSelected();
if(sel == -1)
......
......@@ -807,7 +807,7 @@ int getLocalAddr(ANDROID_APP app) {
return addr;
}
void OnShareFile(ANDROID_APP app, char* title, char* path){
void OnShareFile(ANDROID_APP app, char* title, char* ext){
if (!app || !app->activity || !app->activity->vm)
return;
JNIEnv* jni = nullptr;
......@@ -817,10 +817,10 @@ void OnShareFile(ANDROID_APP app, char* title, char* path){
jmethodID MethodGetAddr = 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, MethodGetAddr, s_title, s_path);
jstring s_ext = jni->NewStringUTF(ext);
jni->CallVoidMethod(lNativeActivity, MethodGetAddr, s_title, s_ext);
jni->ReleaseStringUTFChars(s_title, title);
jni->ReleaseStringUTFChars(s_path, path);
jni->ReleaseStringUTFChars(s_ext, ext);
jni->DeleteLocalRef(ClassNativeActivity);
app->activity->vm->DetachCurrentThread();
}
......
......@@ -98,7 +98,7 @@ extern float getScreenWidth(ANDROID_APP app);
extern float getScreenHeight(ANDROID_APP app);
extern void OnShareFile(ANDROID_APP app, char* title, char* path);
extern void OnShareFile(ANDROID_APP app, char* title, char* ext);
// Get SDCard path.
extern irr::io::path getExternalStorageDir(ANDROID_APP app);
......
......@@ -530,20 +530,20 @@ public class YGOMobileActivity extends NativeActivity implements
}
@Override
public void shareFile(final String title, final String path) {
public void shareFile(final String title, final String ext) {
Log.i("看看", title +"." + ext);
//TODO 分享文件
runOnUiThread(new Runnable() {
@Override
public void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(YGOMobileActivity.this);
builder.setTitle(title);
builder.setMessage(path);
builder.setMessage(ext);
builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM,
Uri.fromFile(new File(path)));
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(ext)));
shareIntent.setType("*/*");//此处可发送多种文件
startActivity(Intent.createChooser(shareIntent, "分享到"));
dialog.dismiss();
......
......@@ -217,7 +217,7 @@ public final class IrrlichtBridge {
void showComboBoxCompat(String[] items, boolean isShow, int mode);
void shareFile(String title, String path);
void shareFile(String title, String ext);
void performHapticFeedback();
......
......@@ -410,6 +410,7 @@
!system 1365 重命名失败,可能存在同名文件
!system 1366 自动保存录像
!system 1367 录像已自动保存为%ls.yrp
!system 1368 分享录像
!system 1370 星数↑
!system 1371 攻击↑
!system 1372 守备↑
......
......@@ -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
......
......@@ -409,6 +409,7 @@
!system 1365 리플레이 이름을 바꾸는 중에 오류가 났습니다. 입력한 이름과 동일한 파일이 존재합니다.
!system 1366 자동으로 리플레이 저장
!system 1367 다음과 같이 저장되었습니다. %ls.yrp
!system 1368 함께 나누다
!system 1370 레벨↑
!system 1371 공격력↑
!system 1372 수비력↑
......
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