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