Renamed AnimationSettings -> AnimationManager.
[tagua/yd.git] / src / engineinfo.cpp
blob99babed163f146106c61187feed8f641ef8a0e20
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #include "engineinfo.h"
12 #include "xboardengine.h"
13 #include "gnushogiengine.h"
14 #include "ui.h"
15 #include <iostream>
17 using namespace boost;
19 void EngineDetails::load(Settings s) {
20 s["name"] >> name;
21 s["path"] >> path;
22 type = typeFromName(s["type"].value<QString>());
23 if (s["work-path"])
24 s["work-path"] >> workPath;
27 void EngineDetails::save(Settings s) {
28 s["name"] = name;
29 s["path"] = path;
30 s["type"] = typeName(type);
31 s["work-path"] = workPath;
34 void EngineInfo::playAs(Components* components, const IColor* player) {
35 if (m_token[player].valid()) {
36 m_ui.removeEntity(m_token[player]);
37 m_token[player] = EntityToken();
39 else {
40 m_token[player] = m_ui.addPlayingEngine(player, engine(components));
44 // void EngineInfo::analyze() {
45 // if (m_token.valid()) {
46 // m_ui.removeAnalysingEngine(m_token);
47 // m_token = EntityToken();
48 // }
49 // else
50 // m_token = m_ui.addAnalysingEngine(engine());
51 // }
53 EngineInfo::EngineInfo(const EngineDetails& details, UI& ui)
54 : QObject(&ui)
55 , m_details(details)
56 , m_ui(ui) { }
58 shared_ptr<Engine> EngineInfo::engine(Components* components) {
59 shared_ptr<Engine> res;
60 if (m_details.type == EngineDetails::XBoard)
61 res = shared_ptr<Engine>(new XBoardEngine(components, m_details.path, QStringList()));
62 else if (m_details.type == EngineDetails::GNUShogi)
63 res = shared_ptr<Engine>(new GNUShogiEngine(components, m_details.path, QStringList()));
64 else {
65 ERROR("Unimplemented engine type " << EngineDetails::typeName(m_details.type));
66 return shared_ptr<Engine>();
69 if (res)
70 res->setWorkingPath(m_details.workPath);
72 return res;