2009-11-27 13:16:40 +00:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
|
|
|
|
// Copyright (C) 2009 Alistair Riddoch
|
|
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef TOOLS_INTERACTIVE_H
|
|
|
|
|
#define TOOLS_INTERACTIVE_H
|
|
|
|
|
|
2009-11-27 14:38:12 +00:00
|
|
|
#include "AdminClient.h"
|
|
|
|
|
|
2009-11-27 13:16:40 +00:00
|
|
|
#include "common/OperationRouter.h"
|
|
|
|
|
|
|
|
|
|
#include <sigc++/trackable.h>
|
|
|
|
|
|
2014-10-01 21:38:20 +02:00
|
|
|
#include <memory>
|
2012-05-30 10:06:34 +01:00
|
|
|
|
2012-05-31 00:50:52 +01:00
|
|
|
class ObjectContext;
|
2012-05-30 10:06:34 +01:00
|
|
|
|
2014-10-01 21:38:20 +02:00
|
|
|
typedef std::set<std::shared_ptr<ObjectContext> > ContextMap;
|
2012-05-30 10:06:34 +01:00
|
|
|
|
2009-11-27 13:16:40 +00:00
|
|
|
/// \brief Class template for clients used to connect to and administrate
|
|
|
|
|
/// a cyphesis server.
|
2009-11-27 14:38:12 +00:00
|
|
|
class Interactive : public AdminClient,
|
2009-11-27 13:16:40 +00:00
|
|
|
virtual public sigc::trackable
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-06-12 23:46:24 -07:00
|
|
|
bool m_server_flag;
|
2010-08-28 18:10:36 +01:00
|
|
|
std::string m_serverName;
|
|
|
|
|
std::string m_systemType;
|
|
|
|
|
std::string m_prompt;
|
2009-11-27 13:16:40 +00:00
|
|
|
|
2012-05-30 10:06:34 +01:00
|
|
|
/// \brief Map of context with which we can interact with the server
|
|
|
|
|
ContextMap m_contexts;
|
2014-10-01 21:38:20 +02:00
|
|
|
std::weak_ptr<ObjectContext> m_currentContext;
|
2012-05-30 10:06:34 +01:00
|
|
|
|
2009-11-27 13:16:40 +00:00
|
|
|
protected:
|
2012-05-30 09:56:30 +01:00
|
|
|
virtual void operation(const Operation &);
|
|
|
|
|
|
2009-11-27 14:02:58 +00:00
|
|
|
virtual void appearanceArrived(const Operation &);
|
|
|
|
|
virtual void disappearanceArrived(const Operation &);
|
|
|
|
|
virtual void infoArrived(const Operation &);
|
|
|
|
|
virtual void errorArrived(const Operation &);
|
|
|
|
|
virtual void soundArrived(const Operation &);
|
2009-11-27 13:16:40 +00:00
|
|
|
|
2012-05-30 09:49:15 +01:00
|
|
|
virtual void loginSuccess(const Atlas::Objects::Root & arg);
|
|
|
|
|
|
2009-11-27 13:16:40 +00:00
|
|
|
public:
|
|
|
|
|
Interactive();
|
|
|
|
|
~Interactive();
|
|
|
|
|
|
|
|
|
|
int setup();
|
|
|
|
|
void exec(const std::string & cmd, const std::string & arg);
|
|
|
|
|
void loop();
|
2012-07-27 10:04:57 +01:00
|
|
|
int select(bool rewrite_prompt = true);
|
2009-11-27 15:19:22 +00:00
|
|
|
void updatePrompt();
|
2009-11-27 13:16:40 +00:00
|
|
|
void runCommand(char *);
|
2012-05-23 22:32:05 +01:00
|
|
|
void switchContext(int, int);
|
2014-10-01 21:38:20 +02:00
|
|
|
const std::shared_ptr<ObjectContext> & addContext(
|
|
|
|
|
const std::shared_ptr<ObjectContext> &);
|
|
|
|
|
void addCurrentContext(const std::shared_ptr<ObjectContext> &);
|
2009-11-27 13:16:40 +00:00
|
|
|
|
|
|
|
|
static void gotCommand(char *);
|
2012-05-30 23:06:58 +01:00
|
|
|
|
2012-05-30 23:21:25 +01:00
|
|
|
int commandUnknown(struct command *, const std::string &);
|
2009-11-27 13:16:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // TOOLS_INTERACTIVE_H
|