mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-03-11 15:58:08 +01:00
DroidFish: Moved error message to strings.xml.
This commit is contained in:
parent
da605aa225
commit
1d0dde26d0
@ -407,6 +407,7 @@ you are not actively using the program.\
|
||||
<string name="engine_error">Engine error</string>
|
||||
<string name="stockfish_engine">Stockfish</string>
|
||||
<string name="cuckoochess_engine">CuckooChess</string>
|
||||
<string name="failed_to_start_engine">Failed to start engine</string>
|
||||
|
||||
<string name="err_too_few_spaces">Too few spaces</string>
|
||||
<string name="err_invalid_piece">Invalid piece</string>
|
||||
|
@ -29,8 +29,13 @@ import java.nio.channels.FileChannel;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.petero.droidfish.R;
|
||||
import android.content.Context;
|
||||
|
||||
/** Engine running as a process started from an external resource. */
|
||||
public class ExternalEngine extends UCIEngineBase {
|
||||
protected final Context context;
|
||||
|
||||
private File engineFileName;
|
||||
protected static final String intSfPath = "/data/data/org.petero.droidfish/internal_sf";
|
||||
private static final String exePath = "/data/data/org.petero.droidfish/engine.exe";
|
||||
@ -42,7 +47,8 @@ public class ExternalEngine extends UCIEngineBase {
|
||||
private List<String> inLines;
|
||||
private boolean startedOk;
|
||||
|
||||
public ExternalEngine(String engine, Report report) {
|
||||
public ExternalEngine(Context context, String engine, Report report) {
|
||||
this.context = context;
|
||||
this.report = report;
|
||||
engineFileName = new File(engine);
|
||||
engineProc = null;
|
||||
@ -68,7 +74,7 @@ public class ExternalEngine extends UCIEngineBase {
|
||||
try {
|
||||
engineProc.waitFor();
|
||||
if (!startedOk)
|
||||
report.reportError("Failed to start engine");
|
||||
report.reportError(context.getString(R.string.failed_to_start_engine));
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
@ -29,12 +29,9 @@ import android.os.Build;
|
||||
|
||||
/** Stockfish engine running as process, started from assets resource. */
|
||||
public class InternalStockFish extends ExternalEngine {
|
||||
private Context context;
|
||||
|
||||
public InternalStockFish(Context context, Report report) {
|
||||
super("", report);
|
||||
this.context = context;
|
||||
|
||||
super(context, "", report);
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
|
@ -34,7 +34,7 @@ public abstract class UCIEngineBase implements UCIEngine {
|
||||
else if ("stockfish".equals(engine))
|
||||
return new InternalStockFish(context, report);
|
||||
else
|
||||
return new ExternalEngine(engine, report);
|
||||
return new ExternalEngine(context, engine, report);
|
||||
}
|
||||
|
||||
protected UCIEngineBase() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user