2012-02-28 13:09:12 +01:00
|
|
|
/*! \file main.h
|
|
|
|
* \brief Headers of main file of SuperDerpy engine.
|
|
|
|
*
|
|
|
|
* Contains basic functions shared by all views.
|
|
|
|
*/
|
2012-03-04 13:32:42 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) Sebastian Krzyszkowiak <dos@dosowisko.net>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2016-07-03 00:43:32 +02:00
|
|
|
#ifndef LIBSUPERDERPY_MAIN_H
|
|
|
|
#define LIBSUPERDERPY_MAIN_H
|
2012-02-16 15:40:58 +01:00
|
|
|
|
|
|
|
#include <allegro5/allegro.h>
|
|
|
|
#include <allegro5/allegro_audio.h>
|
|
|
|
#include <allegro5/allegro_image.h>
|
|
|
|
#include <allegro5/allegro_font.h>
|
2016-08-21 21:58:47 +02:00
|
|
|
#include <allegro5/allegro_primitives.h>
|
|
|
|
#include <allegro5/allegro_acodec.h>
|
|
|
|
#include <allegro5/allegro_ttf.h>
|
2012-12-24 19:41:12 +01:00
|
|
|
#include "gamestate.h"
|
2016-07-03 00:43:32 +02:00
|
|
|
#include "config.h"
|
|
|
|
#include "timeline.h"
|
|
|
|
#include "utils.h"
|
2016-08-12 06:56:06 +02:00
|
|
|
#include "character.h"
|
2012-02-16 15:40:58 +01:00
|
|
|
|
2016-07-03 22:38:36 +02:00
|
|
|
#ifndef LIBSUPERDERPY_DATA_TYPE
|
|
|
|
#define LIBSUPERDERPY_DATA_TYPE void
|
|
|
|
#endif
|
|
|
|
|
2012-12-24 19:41:12 +01:00
|
|
|
struct Gamestate;
|
2012-05-03 13:20:25 +02:00
|
|
|
|
2016-08-15 04:37:27 +02:00
|
|
|
struct libsuperderpy_list {
|
|
|
|
void *data;
|
|
|
|
struct libsuperderpy_list *next;
|
|
|
|
};
|
|
|
|
|
2016-08-23 02:13:15 +02:00
|
|
|
struct libsuperderpy_viewport {
|
|
|
|
int width; /*!< Actual available width of the drawing canvas. */
|
|
|
|
int height; /*!< Actual available height of the drawing canvas. */
|
|
|
|
float aspect;
|
|
|
|
bool allow_non_integer;
|
|
|
|
};
|
|
|
|
|
2012-12-24 19:41:12 +01:00
|
|
|
/*! \brief Main struct of the game. */
|
|
|
|
struct Game {
|
|
|
|
ALLEGRO_DISPLAY *display; /*!< Main Allegro display. */
|
2012-03-07 22:06:19 +01:00
|
|
|
|
2016-07-03 00:43:32 +02:00
|
|
|
ALLEGRO_TRANSFORM projection; /*!< Projection of the game canvas into the actual game window. */
|
2016-06-27 21:20:02 +02:00
|
|
|
|
2016-08-23 02:13:15 +02:00
|
|
|
struct libsuperderpy_viewport viewport, viewport_config;
|
2012-02-16 15:40:58 +01:00
|
|
|
|
2012-12-24 19:41:12 +01:00
|
|
|
struct {
|
2016-07-02 23:23:08 +02:00
|
|
|
int fx; /*!< Effects volume. */
|
|
|
|
int music; /*!< Music volume. */
|
|
|
|
int voice; /*!< Voice volume. */
|
|
|
|
bool fullscreen; /*!< Fullscreen toggle. */
|
|
|
|
bool debug; /*!< Toggles debug mode. */
|
|
|
|
int width; /*!< Width of window as being set in configuration. */
|
|
|
|
int height; /*!< Height of window as being set in configuration. */
|
2012-12-24 19:41:12 +01:00
|
|
|
} config;
|
2012-02-18 04:14:35 +01:00
|
|
|
|
2012-09-03 02:25:32 +02:00
|
|
|
struct {
|
|
|
|
ALLEGRO_VOICE *v; /*!< Main voice used by the game. */
|
|
|
|
ALLEGRO_MIXER *mixer; /*!< Main mixer of the game. */
|
|
|
|
ALLEGRO_MIXER *music; /*!< Music mixer. */
|
|
|
|
ALLEGRO_MIXER *voice; /*!< Voice mixer. */
|
|
|
|
ALLEGRO_MIXER *fx; /*!< Effects mixer. */
|
|
|
|
} audio; /*!< Audio resources. */
|
2012-02-16 15:40:58 +01:00
|
|
|
|
2012-12-24 19:41:12 +01:00
|
|
|
struct {
|
2012-12-26 02:25:56 +01:00
|
|
|
struct Gamestate *gamestates; /*!< List of known gamestates. */
|
2016-08-16 18:41:50 +02:00
|
|
|
bool gamestate_scheduled; /*!< Whether there's some gamestate lifecycle management work to do. */
|
2012-12-24 19:41:12 +01:00
|
|
|
ALLEGRO_FONT *font_console; /*!< Font used in game console. */
|
2015-03-15 05:38:15 +01:00
|
|
|
ALLEGRO_FONT *font_bsod; /*!< Font used in Blue Screens of Derp. */
|
2012-12-24 19:41:12 +01:00
|
|
|
ALLEGRO_BITMAP *console; /*!< Bitmap with game console. */
|
2016-08-16 23:20:00 +02:00
|
|
|
ALLEGRO_BITMAP *console_tmp; /*!< Bitmap used for drawing game console. */
|
2012-12-24 19:41:12 +01:00
|
|
|
ALLEGRO_EVENT_QUEUE *event_queue; /*!< Main event queue. */
|
2016-07-03 00:43:32 +02:00
|
|
|
ALLEGRO_TIMER *timer; /*!< Main LPS (logic) timer. */
|
2012-12-24 19:41:12 +01:00
|
|
|
bool showconsole; /*!< If true, game console is rendered on screen. */
|
|
|
|
|
|
|
|
struct {
|
|
|
|
double old_time, fps;
|
|
|
|
int frames_done;
|
2016-07-03 00:43:32 +02:00
|
|
|
} fps_count; /*!< Used for counting the effective FPS. */
|
2012-12-24 19:41:12 +01:00
|
|
|
|
2016-07-03 00:43:32 +02:00
|
|
|
ALLEGRO_CONFIG *config; /*!< Configuration file interface. */
|
2012-12-25 00:22:03 +01:00
|
|
|
|
2012-12-28 03:42:59 +01:00
|
|
|
struct {
|
|
|
|
void (*Draw)(struct Game *game, void* data, float p);
|
|
|
|
void* (*Load)(struct Game *game);
|
|
|
|
void (*Start)(struct Game *game, void* data);
|
|
|
|
void (*Stop)(struct Game *game, void* data);
|
|
|
|
void (*Unload)(struct Game *game, void* data);
|
|
|
|
|
|
|
|
void* data;
|
2016-07-03 00:43:32 +02:00
|
|
|
} loading; /*!< Interface for accessing loading screen functions. */
|
2012-12-28 03:42:59 +01:00
|
|
|
|
2016-07-04 00:06:50 +02:00
|
|
|
int argc;
|
|
|
|
char** argv;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
int p;
|
|
|
|
struct Gamestate *tmp;
|
|
|
|
double t;
|
|
|
|
int loaded, toLoad;
|
2016-08-16 18:41:50 +02:00
|
|
|
} tmp_gamestate;
|
|
|
|
|
|
|
|
struct Gamestate *current_gamestate;
|
2016-07-04 00:06:50 +02:00
|
|
|
|
2016-08-15 04:37:27 +02:00
|
|
|
struct libsuperderpy_list *garbage;
|
|
|
|
|
2012-12-24 19:41:12 +01:00
|
|
|
} _priv; /*!< Private resources. Do not use in gamestates! */
|
2012-05-19 18:09:20 +02:00
|
|
|
|
2012-12-24 19:41:12 +01:00
|
|
|
bool shuttingdown; /*!< If true then shut down of the game is pending. */
|
|
|
|
bool restart; /*!< If true then restart of the game is pending. */
|
2012-03-08 22:21:02 +01:00
|
|
|
|
2016-08-20 03:32:32 +02:00
|
|
|
bool show_loading_on_launch;
|
|
|
|
|
2016-07-03 22:38:36 +02:00
|
|
|
const char* name;
|
|
|
|
|
2016-08-29 22:47:55 +02:00
|
|
|
ALLEGRO_EVENT_SOURCE event_source;
|
|
|
|
|
2016-07-03 22:38:36 +02:00
|
|
|
LIBSUPERDERPY_DATA_TYPE *data;
|
|
|
|
|
2012-12-24 19:41:12 +01:00
|
|
|
};
|
2012-08-04 20:58:24 +02:00
|
|
|
|
2016-08-23 02:13:15 +02:00
|
|
|
struct Game* libsuperderpy_init(int argc, char **argv, const char* name, struct libsuperderpy_viewport viewport);
|
2016-07-03 22:38:36 +02:00
|
|
|
int libsuperderpy_run(struct Game* game);
|
|
|
|
void libsuperderpy_destroy(struct Game* game);
|
2016-07-02 23:23:08 +02:00
|
|
|
|
2012-02-26 00:47:41 +01:00
|
|
|
#endif
|