import: Tip what string cannot be imported
This commit is contained in:
parent
037444d1d9
commit
b49ab4ff20
|
@ -220,6 +220,10 @@
|
|||
"@gameImported": {
|
||||
"description": "Game imported from clipboard."
|
||||
},
|
||||
"cannotImport": "Kann nicht importieren",
|
||||
"@cannotImport": {
|
||||
"description": "Cannot import"
|
||||
},
|
||||
"startRecording": "Starte die Aufnahme",
|
||||
"@startRecording": {
|
||||
"description": "Start recording"
|
||||
|
|
|
@ -220,6 +220,10 @@
|
|||
"@gameImported": {
|
||||
"description": "Game imported from clipboard."
|
||||
},
|
||||
"cannotImport": "Cannot import",
|
||||
"@cannotImport": {
|
||||
"description": "Cannot import"
|
||||
},
|
||||
"startRecording": "Start recording",
|
||||
"@startRecording": {
|
||||
"description": "Start recording"
|
||||
|
|
|
@ -220,6 +220,10 @@
|
|||
"@gameImported": {
|
||||
"description": "Game imported from clipboard."
|
||||
},
|
||||
"cannotImport": "وارد کردن امکان پذیر نیست",
|
||||
"@cannotImport": {
|
||||
"description": "Cannot import"
|
||||
},
|
||||
"startRecording": "شروع به ضبط کنید",
|
||||
"@startRecording": {
|
||||
"description": "Start recording"
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
"importGame": "导入棋局",
|
||||
"exportGame": "导出棋局",
|
||||
"gameImported": "棋谱已从剪贴板导入",
|
||||
"cannotImport": "无法导入",
|
||||
"startRecording": "开始录制",
|
||||
"recording": "录制中...",
|
||||
"stopRecording": "停止录制",
|
||||
|
|
|
@ -66,7 +66,7 @@ class GameRecorder {
|
|||
return move;
|
||||
}
|
||||
|
||||
void import(String moveList) {
|
||||
String import(String moveList) {
|
||||
List<Move> newHistory = [];
|
||||
List<String> list = moveList.toLowerCase().replaceAll('\n', ' ').split(' ');
|
||||
|
||||
|
@ -78,26 +78,41 @@ class GameRecorder {
|
|||
String m1 = parseNotation(i.substring(0, 2));
|
||||
if (m1 != "") {
|
||||
newHistory.add(Move(m1));
|
||||
} else {
|
||||
print("Cannot import $i");
|
||||
return i;
|
||||
}
|
||||
String m2 = parseNotation(i.substring(2));
|
||||
if (m2 != "") {
|
||||
newHistory.add(Move(m2));
|
||||
} else {
|
||||
print("Cannot import $i");
|
||||
return i;
|
||||
}
|
||||
} else if (i.length == 8 && i[2] == '-' && i[5] == 'x') {
|
||||
// "a1-b2xc3"
|
||||
String m1 = parseNotation(i.substring(0, 5));
|
||||
if (m1 != "") {
|
||||
newHistory.add(Move(m1));
|
||||
} else {
|
||||
print("Cannot import $i");
|
||||
return i;
|
||||
}
|
||||
String m2 = parseNotation(i.substring(5));
|
||||
if (m2 != "") {
|
||||
newHistory.add(Move(m2));
|
||||
} else {
|
||||
print("Cannot import $i");
|
||||
return i;
|
||||
}
|
||||
} else {
|
||||
// no x
|
||||
String m = parseNotation(i);
|
||||
if (m != "") {
|
||||
newHistory.add(Move(m));
|
||||
} else {
|
||||
print("Cannot import $i");
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,6 +121,8 @@ class GameRecorder {
|
|||
if (newHistory.length > 0) {
|
||||
setHistory(newHistory);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void jumpToHead() {
|
||||
|
|
|
@ -565,7 +565,13 @@ class _GamePageState extends State<GamePage>
|
|||
|
||||
await onTakeBackAllButtonPressed(pop: false);
|
||||
await Game.instance.position.recorder.clear();
|
||||
await Game.instance.position.recorder.import(text);
|
||||
var importFailedStr = await Game.instance.position.recorder.import(text);
|
||||
|
||||
if (importFailedStr != "") {
|
||||
showTip(S.of(context).cannotImport + " " + importFailedStr);
|
||||
return;
|
||||
}
|
||||
|
||||
await onStepForwardAllButtonPressed(pop: false);
|
||||
|
||||
showTip(S.of(context).gameImported);
|
||||
|
|
Loading…
Reference in New Issue