This commit is contained in:
parent
dedfcd680b
commit
333f1ca479
3 changed files with 63 additions and 29 deletions
|
@ -141,6 +141,8 @@ void sendMenuItemCommand(int menuItem) {
|
||||||
(*jniEnv)->CallVoidMethod(jniEnv, mainActivity, midStr, menuItem);
|
(*jniEnv)->CallVoidMethod(jniEnv, mainActivity, midStr, menuItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TCHAR lastKMLFilename[MAX_PATH];
|
||||||
|
|
||||||
BOOL getFirstKMLFilenameForType(BYTE chipsetType, TCHAR * firstKMLFilename, size_t firstKMLFilenameSize) {
|
BOOL getFirstKMLFilenameForType(BYTE chipsetType, TCHAR * firstKMLFilename, size_t firstKMLFilenameSize) {
|
||||||
if(firstKMLFilename) {
|
if(firstKMLFilename) {
|
||||||
JNIEnv *jniEnv = getJNIEnvironment();
|
JNIEnv *jniEnv = getJNIEnvironment();
|
||||||
|
@ -149,6 +151,11 @@ BOOL getFirstKMLFilenameForType(BYTE chipsetType, TCHAR * firstKMLFilename, size
|
||||||
jobject resultString = (*jniEnv)->CallObjectMethod(jniEnv, mainActivity, midStr, (char)chipsetType);
|
jobject resultString = (*jniEnv)->CallObjectMethod(jniEnv, mainActivity, midStr, (char)chipsetType);
|
||||||
if (resultString) {
|
if (resultString) {
|
||||||
const char *strReturn = (*jniEnv)->GetStringUTFChars(jniEnv, resultString, 0);
|
const char *strReturn = (*jniEnv)->GetStringUTFChars(jniEnv, resultString, 0);
|
||||||
|
if(_tcscmp(lastKMLFilename, strReturn) == 0) {
|
||||||
|
(*jniEnv)->ReleaseStringUTFChars(jniEnv, resultString, strReturn);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
_tcscpy(lastKMLFilename, strReturn);
|
||||||
_tcsncpy(firstKMLFilename, strReturn, firstKMLFilenameSize);
|
_tcsncpy(firstKMLFilename, strReturn, firstKMLFilenameSize);
|
||||||
(*jniEnv)->ReleaseStringUTFChars(jniEnv, resultString, strReturn);
|
(*jniEnv)->ReleaseStringUTFChars(jniEnv, resultString, strReturn);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -416,6 +423,7 @@ JNIEXPORT jint JNICALL Java_org_emulator_forty_eight_NativeLib_onFileOpen(JNIEnv
|
||||||
_tcscpy(szBufferFilename, stateFilenameUTF8);
|
_tcscpy(szBufferFilename, stateFilenameUTF8);
|
||||||
|
|
||||||
chooseCurrentKmlMode = ChooseKmlMode_FILE_OPEN;
|
chooseCurrentKmlMode = ChooseKmlMode_FILE_OPEN;
|
||||||
|
lastKMLFilename[0] = '\0';
|
||||||
BOOL result = OpenDocument(szBufferFilename);
|
BOOL result = OpenDocument(szBufferFilename);
|
||||||
if (result)
|
if (result)
|
||||||
MruAdd(szBufferFilename);
|
MruAdd(szBufferFilename);
|
||||||
|
|
|
@ -94,22 +94,38 @@ HANDLE CreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
||||||
if(!settingsPort2wr && (dwDesiredAccess & GENERIC_WRITE))
|
if(!settingsPort2wr && (dwDesiredAccess & GENERIC_WRITE))
|
||||||
return (HANDLE) INVALID_HANDLE_VALUE;
|
return (HANDLE) INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
// if(chooseCurrentKmlMode == ChooseKmlMode_FILE_OPEN && lpFileName[0] == '/') {
|
|
||||||
// TCHAR * fileExtension = _tcsrchr(lpFileName, _T('.'));
|
|
||||||
// if(fileExtension && ((fileExtension[1] == 'K' && fileExtension[2] == 'M' && fileExtension[3] == 'L') ||
|
|
||||||
// (fileExtension[1] == 'k' && fileExtension[2] == 'm' && fileExtension[3] == 'l')
|
|
||||||
// )) {
|
|
||||||
// _tcscpy(szEmuDirectory, lpFileName);
|
|
||||||
// TCHAR * filename = _tcsrchr(szEmuDirectory, _T('/'));
|
|
||||||
// if(filename) {
|
|
||||||
// *filename = _T('\0');
|
|
||||||
// }
|
|
||||||
// _tcscpy(szRomDirectory, szEmuDirectory);
|
|
||||||
// SetCurrentDirectory(szEmuDirectory);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
TCHAR * foundDocumentScheme = _tcsstr(lpFileName, documentScheme);
|
TCHAR * foundDocumentScheme = _tcsstr(lpFileName, documentScheme);
|
||||||
|
|
||||||
|
if(chooseCurrentKmlMode == ChooseKmlMode_FILE_OPEN) {
|
||||||
|
// When we open a new E48 state document
|
||||||
|
TCHAR * fileExtension = _tcsrchr(lpFileName, _T('.'));
|
||||||
|
if(fileExtension && ((fileExtension[1] == 'K' && fileExtension[2] == 'M' && fileExtension[3] == 'L') ||
|
||||||
|
(fileExtension[1] == 'k' && fileExtension[2] == 'm' && fileExtension[3] == 'l')
|
||||||
|
)) {
|
||||||
|
// And opening a KML file
|
||||||
|
if(lpFileName[0] == '/') {
|
||||||
|
// With a recorded standard file
|
||||||
|
_tcscpy(szEmuDirectory, lpFileName);
|
||||||
|
TCHAR * filename = _tcsrchr(szEmuDirectory, _T('/'));
|
||||||
|
if(filename) {
|
||||||
|
*filename = _T('\0');
|
||||||
|
}
|
||||||
|
_tcscpy(szRomDirectory, szEmuDirectory);
|
||||||
|
SetCurrentDirectory(szEmuDirectory);
|
||||||
|
} else if(foundDocumentScheme) {
|
||||||
|
// With a recorded "document:" scheme, extract the folder URL with content:// scheme
|
||||||
|
_tcscpy(szEmuDirectory, lpFileName + _tcslen(documentScheme) * sizeof(TCHAR));
|
||||||
|
TCHAR * filename = _tcschr(szEmuDirectory, _T('|'));
|
||||||
|
if(filename) {
|
||||||
|
*filename = _T('\0');
|
||||||
|
}
|
||||||
|
_tcscpy(szRomDirectory, szEmuDirectory);
|
||||||
|
SetCurrentDirectory(szEmuDirectory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!forceNormalFile && (szCurrentAssetDirectory || _tcsncmp(lpFileName, assetsPrefix, assetsPrefixLength) == 0) && foundDocumentScheme == NULL) {
|
if(!forceNormalFile && (szCurrentAssetDirectory || _tcsncmp(lpFileName, assetsPrefix, assetsPrefixLength) == 0) && foundDocumentScheme == NULL) {
|
||||||
// Asset file
|
// Asset file
|
||||||
TCHAR szFileName[MAX_PATH];
|
TCHAR szFileName[MAX_PATH];
|
||||||
|
@ -2009,15 +2025,18 @@ INT_PTR DialogBoxParam(HINSTANCE hInstance, LPCTSTR lpTemplateName, HWND hWndPar
|
||||||
} else if(chooseCurrentKmlMode == ChooseKmlMode_FILE_NEW) {
|
} else if(chooseCurrentKmlMode == ChooseKmlMode_FILE_NEW) {
|
||||||
lstrcpy(szCurrentKml, szChosenCurrentKml);
|
lstrcpy(szCurrentKml, szChosenCurrentKml);
|
||||||
} else if(chooseCurrentKmlMode == ChooseKmlMode_FILE_OPEN) {
|
} else if(chooseCurrentKmlMode == ChooseKmlMode_FILE_OPEN) {
|
||||||
if(getFirstKMLFilenameForType(Chipset.type, szCurrentKml, sizeof(szCurrentKml) / sizeof(szCurrentKml[0])))
|
if(!getFirstKMLFilenameForType(Chipset.type, szCurrentKml, sizeof(szCurrentKml) / sizeof(szCurrentKml[0]))) {
|
||||||
showAlert(_T("Cannot find the KML template file, so, try another one."), 0);
|
|
||||||
else
|
|
||||||
showAlert(_T("Cannot find the KML template file, sorry."), 0);
|
showAlert(_T("Cannot find the KML template file, sorry."), 0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
// else {
|
||||||
|
// showAlert(_T("Cannot find the KML template file, so, try another one."), 0); //TODO is it right?
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
} else if(lpTemplateName == MAKEINTRESOURCE(IDD_KMLLOG)) {
|
} else if(lpTemplateName == MAKEINTRESOURCE(IDD_KMLLOG)) {
|
||||||
lpDialogFunc(NULL, WM_INITDIALOG, 0, 0);
|
lpDialogFunc(NULL, WM_INITDIALOG, 0, 0);
|
||||||
}
|
}
|
||||||
return NULL;
|
return IDOK;
|
||||||
}
|
}
|
||||||
HCURSOR SetCursor(HCURSOR hCursor) {
|
HCURSOR SetCursor(HCURSOR hCursor) {
|
||||||
//TODO
|
//TODO
|
||||||
|
|
|
@ -984,9 +984,12 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
|
|
||||||
private int onFileOpen(String url) {
|
private int onFileOpen(String url) {
|
||||||
int result = NativeLib.onFileOpen(url);
|
int result = NativeLib.onFileOpen(url);
|
||||||
|
if(result > 0) {
|
||||||
setPort1Settings(NativeLib.getPort1Plugged(), NativeLib.getPort1Writable());
|
setPort1Settings(NativeLib.getPort1Plugged(), NativeLib.getPort1Writable());
|
||||||
displayFilename(url);
|
displayFilename(url);
|
||||||
showKMLLog();
|
showKMLLog();
|
||||||
|
} else
|
||||||
|
showKMLLogForce();
|
||||||
updateNavigationDrawerItems();
|
updateNavigationDrawerItems();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1020,6 +1023,11 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
|
|
||||||
private void showKMLLog() {
|
private void showKMLLog() {
|
||||||
if(sharedPreferences.getBoolean("settings_alwaysdisplog", true)) {
|
if(sharedPreferences.getBoolean("settings_alwaysdisplog", true)) {
|
||||||
|
showKMLLogForce();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showKMLLogForce() {
|
||||||
String kmlLog = NativeLib.getKMLLog();
|
String kmlLog = NativeLib.getKMLLog();
|
||||||
new AlertDialog.Builder(this)
|
new AlertDialog.Builder(this)
|
||||||
.setTitle("KML Script Compilation Result")
|
.setTitle("KML Script Compilation Result")
|
||||||
|
@ -1029,7 +1037,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
}
|
}
|
||||||
}).show();
|
}).show();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
final int GENERIC_READ = 1;
|
final int GENERIC_READ = 1;
|
||||||
final int GENERIC_WRITE = 2;
|
final int GENERIC_WRITE = 2;
|
||||||
|
|
Loading…
Reference in a new issue