2005-11-07 10:56:25 +01:00
|
|
|
#ifndef __GM_WORLD_H__
|
|
|
|
#define __GM_WORLD_H__
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "gm-options.h"
|
|
|
|
#include "gm-net.h"
|
|
|
|
#include "gm-editor.h"
|
|
|
|
#include "gm-triggers.h"
|
2005-11-15 12:59:34 +01:00
|
|
|
#include "mcp/gm-mcp-session.h"
|
2005-11-07 10:56:25 +01:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Type checking and casting macros
|
|
|
|
*/
|
|
|
|
#define GM_TYPE_WORLD (gm_world_get_type())
|
|
|
|
#define GM_WORLD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GM_TYPE_WORLD, GmWorld))
|
|
|
|
#define GM_WORLD_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GM_TYPE_WORLD, GmWorld const))
|
|
|
|
#define GM_WORLD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GM_TYPE_WORLD, GmWorldClass))
|
|
|
|
#define GM_IS_WORLD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GM_TYPE_WORLD))
|
|
|
|
#define GM_IS_WORLD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GM_TYPE_WORLD))
|
|
|
|
#define GM_WORLD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GM_TYPE_WORLD, GmWorldClass))
|
|
|
|
|
|
|
|
/** \ingroup world
|
|
|
|
* \brief struct for world editing information
|
|
|
|
*
|
|
|
|
* Struct which contains various fields for storing editing information. This
|
|
|
|
* is only used if editing via mcp_simpleedit can't be used.
|
|
|
|
*/
|
|
|
|
typedef struct _GmEditingInfo {
|
|
|
|
gboolean is_editing; /**< are we editing at the moment? */
|
|
|
|
GList *lines; /**< the lines to be edited */
|
|
|
|
gchar *name; /**< the name of the editor */
|
|
|
|
gchar *upload; /**< the command to send when sending the editor contents */
|
|
|
|
} GmEditingInfo;
|
|
|
|
|
|
|
|
/** \ingroup world
|
|
|
|
* \brief enum indicating log type
|
|
|
|
*
|
|
|
|
* Enumeration which indicates the log type
|
|
|
|
*/
|
|
|
|
typedef enum _GmLogType GmLogType;
|
|
|
|
enum _GmLogType {
|
2005-11-19 14:11:50 +01:00
|
|
|
LOG_NONE, /**< don't log */
|
2005-11-07 10:56:25 +01:00
|
|
|
LOG_IN, /**< incoming lines */
|
|
|
|
LOG_OUT, /**< outgoing lines */
|
2005-12-23 17:10:26 +01:00
|
|
|
LOG_STATUS, /**< status lines (such as connecting information) */
|
2005-11-07 10:56:25 +01:00
|
|
|
LOG_MCP_IN, /**< mcp incoming lines */
|
|
|
|
LOG_MCP_OUT, /**< mcp outgoing lines */
|
2005-12-23 17:10:26 +01:00
|
|
|
LOG_MCP_STATUS /**< mcp status lines */
|
2005-11-07 10:56:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Private structure type */
|
|
|
|
typedef struct _GmWorldPrivate GmWorldPrivate;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Main object structure
|
|
|
|
*/
|
|
|
|
typedef struct _GmWorld GmWorld;
|
|
|
|
|
|
|
|
struct _GmWorld {
|
|
|
|
GObject object;
|
|
|
|
|
|
|
|
/*< private > */
|
|
|
|
GmWorldPrivate *priv;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class definition
|
|
|
|
*/
|
|
|
|
typedef struct _GmWorldClass GmWorldClass;
|
|
|
|
|
|
|
|
struct _GmWorldClass {
|
|
|
|
GObjectClass parent_class;
|
|
|
|
|
|
|
|
/* Signals */
|
|
|
|
void (* activate_request) (GmWorld *world);
|
|
|
|
void (* load) (GmWorld *world);
|
|
|
|
void (* unload) (GmWorld *world);
|
|
|
|
void (* state_changing) (GmWorld *world, guint state);
|
|
|
|
void (* world_error) (GmWorld *world, gchar const *error, gint code);
|
|
|
|
void (* text_received) (GmWorld *world, gchar const *text);
|
|
|
|
void (* editor_added) (GmWorld *world, GObject *editor);
|
|
|
|
void (* editor_removed) (GmWorld *world, GObject *editor);
|
|
|
|
void (* name_changed) (GmWorld *world, gchar const *name);
|
|
|
|
void (* active_changed) (GmWorld *world, gboolean active);
|
|
|
|
void (* activity_changed) (GmWorld *world, gint activity);
|
|
|
|
};
|
|
|
|
|
|
|
|
GType gm_world_get_type(void) G_GNUC_CONST;
|
|
|
|
GmWorld *gm_world_new(gchar *path);
|
|
|
|
|
|
|
|
GmWorld *gm_world_dup(GmWorld *source);
|
|
|
|
void gm_world_load(GmWorld *world);
|
|
|
|
void gm_world_unload(GmWorld *world);
|
|
|
|
|
|
|
|
const gchar *gm_world_name(GmWorld *world);
|
|
|
|
GmOptions *gm_world_options(GmWorld *world);
|
|
|
|
const gchar *gm_world_path(GmWorld *world);
|
|
|
|
GList **gm_world_history(GmWorld *world);
|
|
|
|
gint gm_world_activity(GmWorld *world);
|
|
|
|
gboolean gm_world_active(GmWorld *world);
|
|
|
|
GmTriggers *gm_world_triggers(GmWorld *world);
|
|
|
|
|
|
|
|
const gchar *gm_world_current_host(GmWorld *world);
|
|
|
|
const gchar *gm_world_current_port(GmWorld *world);
|
|
|
|
|
|
|
|
void gm_world_set_name(GmWorld *world, const gchar *name);
|
|
|
|
void gm_world_set_activity(GmWorld *world, gint activity);
|
|
|
|
void gm_world_set_active(GmWorld *world, gboolean active);
|
2005-11-15 12:59:34 +01:00
|
|
|
|
|
|
|
GmMcpSession *gm_world_get_mcp_session(GmWorld *world);
|
2005-11-07 10:56:25 +01:00
|
|
|
|
|
|
|
gboolean gm_world_loaded(GmWorld *world);
|
|
|
|
GmNetState gm_world_state(GmWorld *world);
|
|
|
|
gboolean gm_world_connected(GmWorld *world);
|
|
|
|
gboolean gm_world_disconnected(GmWorld *world);
|
|
|
|
|
|
|
|
void gm_world_connect(GmWorld *world);
|
|
|
|
void gm_world_connect_to(GmWorld *world, gchar *host, gchar *port);
|
|
|
|
void gm_world_disconnect(GmWorld *world);
|
|
|
|
void gm_world_add_editor(GmWorld *world, GmEditor *editor);
|
|
|
|
void gm_world_remove_editor(GmWorld *world, GmEditor *editor);
|
2005-11-19 14:11:50 +01:00
|
|
|
void gm_world_sendln_log(GmWorld *world, gchar *text, GmLogType logtype);
|
2005-11-07 10:56:25 +01:00
|
|
|
void gm_world_sendln(GmWorld *world, gchar *text);
|
|
|
|
void gm_world_writeln(GmWorld *world, gchar *text);
|
|
|
|
void gm_world_process_input(GmWorld *world, gchar *text);
|
|
|
|
void gm_world_log(GmWorld *world, GmLogType type, gchar *text);
|
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
#endif /* __GM_WORLD_H__ */
|