Skip to content

Commit

Permalink
Refactor|libcommon: Reimplemented EventSequence handling in C++
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Sep 5, 2012
1 parent 2a72a26 commit d08e181
Show file tree
Hide file tree
Showing 7 changed files with 385 additions and 371 deletions.
2 changes: 1 addition & 1 deletion doomsday/plugins/common/common.pri
Expand Up @@ -72,7 +72,7 @@ SOURCES += \
$$common_src/fi_lib.c \
$$common_src/g_controls.c \
$$common_src/g_defs.c \
$$common_src/g_eventsequence.c \
$$common_src/g_eventsequence.cpp \
$$common_src/g_game.c \
$$common_src/g_update.c \
$$common_src/gl_drawpatch.c \
Expand Down
83 changes: 54 additions & 29 deletions doomsday/plugins/common/include/g_eventsequence.h
@@ -1,49 +1,74 @@
/**\file g_eventsequence.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
/**
* @file g_eventsequence.h
* Input (keyboard) event sequences. @ingroup libcommon
*
*\author Copyright © 2003-2012 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2012 Daniel Swanson <danij@dengine.net>
*\author Copyright © 1999 Activision
*\author Copyright © 1993-1996 by id Software, Inc.
* An "event sequence" is a chain of two or more keyboard input events which
* when entered in-sequence trigger a callback when the last event of that
* sequence is received.
*
* 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.
* @author Copyright &copy; 2003-2012 Jaakko Keränen <jaakko.keranen@iki.fi>
* @author Copyright &copy; 2005-2012 Daniel Swanson <danij@dengine.net>
* @author Copyright &copy; 1999 Activision
* @author Copyright &copy; 1993-1996 by id Software, Inc.
*
* 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.
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* 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 St, Fifth Floor,
* Boston, MA 02110-1301 USA
* <small>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 St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/

#ifndef LIBCOMMON_EVENTSEQUENCE_H
#define LIBCOMMON_EVENTSEQUENCE_H

#include "doomsday.h"

#if __cplusplus
extern "C" {
#endif

/**
* Event Sequences for user input.
* Event sequence arguments (passed to the callback handler).
*/
typedef int EventSequenceArg;

#ifndef LIBCOMMON_EVENTSEQUENCE_H
#define LIBCOMMON_EVENTSEQUENCE_H
/**
* Event sequence callback handler.
*/
typedef int (*eventsequencehandler_t) (int player, const EventSequenceArg* args, int numArgs);

// Initialize this subsystem.
void G_InitEventSequences(void);

// Shutdown this subsystem.
void G_ShutdownEventSequences(void);

/**
* Responds to an input event if determined to be part of a known event
* sequence.
*
* @param ev Ptr to the event to be checked.
* Responds to an input event if determined to be part of a known event sequence.
*
* @return @c true, if the event was 'eaten'.
* @param ev Input event to be processed.
* @return @c true= input event @a ev was 'eaten'.
*/
int G_EventSequenceResponder(event_t* ev);

void G_AddEventSequence(const char* sequence, size_t sequenceLength, int (*callback) (const int*, int));
/**
* Add a new event sequence.
*
* @param sequence Text description of the sequence.
* @param callback Handler function to be called upon sequence completion.
*/
void G_AddEventSequence(const char* sequence, eventsequencehandler_t callback);

#if __cplusplus
} // extern "C"
#endif

#endif /* LIBCOMMON_EVENTSEQUENCE_H */
170 changes: 0 additions & 170 deletions doomsday/plugins/common/src/g_eventsequence.c

This file was deleted.

0 comments on commit d08e181

Please sign in to comment.