mode.h 2.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
/** A mode is a specific mode in which the game can be.
* for example, menu mode, play mode, main screen, edit mode, etc. 
* In every mode, inputs and drawing may work in a different way.
*/
#ifndef MODE_H
#define MODE_H

#include "eruta.h"



/** Planned modes. */
enum ErutaModes_ {
  ERUTA_MODE_INTRO      = 1,
  ERUTA_MODE_MAINMENU   = 2,
  ERUTA_MODE_EXPLORE    = 3,
  ERUTA_MODE_BATTLE     = 4,
  ERUTA_MODE_DIALOG     = 5,
  ERUTA_MODE_MENU       = 6,
  ERUTA_MODE_LOAD       = 7,
  ERUTA_MODE_SAVE       = 8,
  ERUTA_MODE_NEW        = 9,
  ERUTA_MODE_TEST       = 10,
  ERUTA_MODE_MAX        = 16,
};

/**
* A Mode is a mode of the program in which the display and controls may 
* be different. Examples of this may be a menu mode, play mode,
* edit mode, intro mode, etc.
* 
*/
struct Mode_;
typedef struct Mode_ Mode;


/**
* ModeActs contains the actions , that is the function poMode *ers of a mode.
* These consist of start, enter, leave, done, event and paMode *
*/
struct ModeActs_;
typedef struct ModeActs_ ModeActs;


typedef Mode * (ModeActEvent)(Mode * self, ALLEGRO_EVENT   * event);
typedef Mode * (ModeActPaint)(Mode * self, ALLEGRO_DISPLAY * display);
typedef Mode * (ModeActMove)(Mode * self, Mode * other);
typedef Mode * (ModeActSelf)(Mode * self);

struct ModeActs_ {
  ModeActSelf   * start;
  ModeActMove   * enter;
  ModeActMove   * leave;
  ModeActPaint  * paint;
  ModeActEvent  * event;
  ModeActSelf   * stop;
};

#include "state.h"
#include "react.h"



Mode * mode_start (Mode * self );

Mode * mode_enter (Mode * self , Mode * other );

Mode * mode_leave (Mode * self , Mode * other );

Mode * mode_stop (Mode * self );

Mode * mode_paint (Mode * self , ALLEGRO_DISPLAY * display );

Mode * mode_event (Mode * self , ALLEGRO_EVENT * event );

Mode * mode_init (Mode * self , State * state , ModeActs * acts , int id );

Mode * elsemode_start (Mode * self );

Mode * elsemode_enter (Mode * self , Mode * other );

Mode * elsemode_leave (Mode * self , Mode * other );

Mode * elsemode_stop (Mode * self );

Mode * elsemode_paint (Mode * self , ALLEGRO_DISPLAY * display );

Mode * elsemode_event (Mode * self , ALLEGRO_EVENT * event );

extern ModeActs elsemode_acts_;
ModeActs * elsemode_getacts(void);

React * mode_react (Mode * self );




#endif