This repository has been archived on 2020-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
gnoemoe/gnoemoe/gm-world.h

145 lines
4.6 KiB
C
Raw Normal View History

2005-11-07 10:56:25 +01:00
#ifndef __GM_WORLD_H__
#define __GM_WORLD_H__
#include <gtk/gtk.h>
2006-01-02 18:55:40 +01:00
#include <regex.h>
2005-11-07 10:56:25 +01:00
#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
*/
2006-01-02 18:55:40 +01:00
#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))
2005-11-07 10:56:25 +01:00
/** \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 {
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);
2006-01-02 18:55:40 +01:00
void (* highlight) (GmWorld *world, gint start, gint end,
gchar const *color);
void (* notify_message) (GmWorld *world, gchar const *message);
2005-11-07 10:56:25 +01:00
};
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 const *host, gchar const *port);
2005-11-07 10:56:25 +01:00
void gm_world_disconnect(GmWorld *world);
void gm_world_prepare_disconnect(GmWorld *world);
2005-11-07 10:56:25 +01:00
void gm_world_add_editor(GmWorld *world, GmEditor *editor);
void gm_world_remove_editor(GmWorld *world, GmEditor *editor);
GSList const *gm_world_editors(GmWorld *world);
void gm_world_sendln_log(GmWorld *world, gchar const *text, GmLogType logtype);
void gm_world_sendln(GmWorld *world, gchar const *text);
void gm_world_writeln(GmWorld *world, gchar const *text);
void gm_world_status(GmWorld *world, gchar const *text);
void gm_world_process_input(GmWorld *world, gchar const *text);
void gm_world_log(GmWorld *world, GmLogType type, gchar const *text);
2006-01-02 18:55:40 +01:00
void gm_world_apply_trigger(GmWorld *world, GmTrigger *trigger,
2006-02-20 23:31:21 +01:00
gchar const *text, regmatch_t *matches, gint nummatches);
2005-11-07 10:56:25 +01:00
G_END_DECLS
#endif /* __GM_WORLD_H__ */