2015-03-15 20:51:56 +01:00
|
|
|
/*! \file utils.h
|
|
|
|
* \brief Headers of helper functions.
|
2012-05-19 18:28:19 +02:00
|
|
|
*/
|
2012-05-18 13:12:58 +02: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
|
2017-07-22 18:22:12 +02:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2012-05-18 13:12:58 +02:00
|
|
|
* (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
|
2017-07-22 18:22:12 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2012-05-18 13:12:58 +02:00
|
|
|
*/
|
2016-07-03 00:43:32 +02:00
|
|
|
|
|
|
|
#ifndef LIBSUPERDERPY_UTILS_H
|
|
|
|
#define LIBSUPERDERPY_UTILS_H
|
|
|
|
|
2017-09-10 21:35:14 +02:00
|
|
|
#include "libsuperderpy.h"
|
2012-05-09 10:58:45 +02:00
|
|
|
#include <allegro5/allegro.h>
|
|
|
|
#include <allegro5/allegro_font.h>
|
|
|
|
|
2016-06-27 21:20:02 +02:00
|
|
|
#ifdef ALLEGRO_WINDOWS
|
2016-06-28 00:17:49 +02:00
|
|
|
#define LIBRARY_EXTENSION ".dll"
|
2016-07-05 01:30:06 +02:00
|
|
|
#elif defined(ALLEGRO_MACOSX)
|
|
|
|
#define LIBRARY_EXTENSION ".dylib"
|
2017-08-22 21:54:58 +02:00
|
|
|
#elif defined(__EMSCRIPTEN__)
|
|
|
|
#define LIBRARY_EXTENSION ".js"
|
2016-06-27 21:20:02 +02:00
|
|
|
#else
|
2016-06-28 00:17:49 +02:00
|
|
|
#define LIBRARY_EXTENSION ".so"
|
2016-06-27 21:20:02 +02:00
|
|
|
#endif
|
|
|
|
|
2016-09-08 00:32:21 +02:00
|
|
|
struct Viewport;
|
2018-02-03 02:13:24 +01:00
|
|
|
struct Gamestate;
|
2016-08-23 02:13:15 +02:00
|
|
|
|
2012-05-19 18:09:20 +02:00
|
|
|
/*! \brief Draws rectangle filled with vertical gradient. */
|
2012-12-24 19:41:12 +01:00
|
|
|
void DrawVerticalGradientRect(float x, float y, float w, float h, ALLEGRO_COLOR top, ALLEGRO_COLOR bottom);
|
2012-05-19 18:09:20 +02:00
|
|
|
/*! \brief Draws rectangle filled with horizontal gradient. */
|
2012-12-24 19:41:12 +01:00
|
|
|
void DrawHorizontalGradientRect(float x, float y, float w, float h, ALLEGRO_COLOR left, ALLEGRO_COLOR right);
|
2012-05-19 18:09:20 +02:00
|
|
|
/*! \brief Draws text with shadow.
|
|
|
|
*
|
|
|
|
* Draws given text two times: once with color (0,0,0,128) and 1px off in both x and y axis,
|
|
|
|
* and second time with actual given color and position.
|
|
|
|
*/
|
2017-09-10 21:35:14 +02:00
|
|
|
void DrawTextWithShadow(ALLEGRO_FONT* font, ALLEGRO_COLOR color, float x, float y, int flags, char const* text);
|
2012-12-24 19:41:12 +01:00
|
|
|
|
2017-09-10 21:35:14 +02:00
|
|
|
int DrawWrappedText(ALLEGRO_FONT* font, ALLEGRO_COLOR color, float x, float y, int width, int flags, char const* text);
|
|
|
|
int DrawWrappedTextWithShadow(ALLEGRO_FONT* font, ALLEGRO_COLOR color, float x, float y, int width, int flags, char const* text);
|
2016-09-08 00:32:21 +02:00
|
|
|
|
2017-09-09 00:11:43 +02:00
|
|
|
ALLEGRO_COLOR InterpolateColor(ALLEGRO_COLOR c1, ALLEGRO_COLOR c2, float frac);
|
|
|
|
void ScaleBitmap(ALLEGRO_BITMAP* source, int width, int height);
|
|
|
|
|
2012-12-24 19:41:12 +01:00
|
|
|
/*! \brief Loads bitmap into memory and scales it with software linear filtering. */
|
2017-09-10 21:35:14 +02:00
|
|
|
ALLEGRO_BITMAP* LoadScaledBitmap(struct Game* game, char* filename, int width, int height);
|
2012-12-24 19:41:12 +01:00
|
|
|
|
|
|
|
/*! \brief Finds path for data file. */
|
2017-09-10 21:35:14 +02:00
|
|
|
char* GetDataFilePath(struct Game* game, char* filename);
|
2012-12-24 19:41:12 +01:00
|
|
|
|
2017-09-10 21:35:14 +02:00
|
|
|
char* GetGameName(struct Game* game, char* format);
|
2016-06-27 21:20:02 +02:00
|
|
|
|
2012-12-24 19:41:12 +01:00
|
|
|
/*! \brief Print some message on game console.
|
|
|
|
*
|
|
|
|
* Draws message on console bitmap, so it'll be displayed when calling DrawConsole.
|
|
|
|
* If game->debug is true, then it also prints given message on stdout.
|
|
|
|
* It needs to be called in printf style.
|
|
|
|
*/
|
2017-09-10 21:35:14 +02:00
|
|
|
void PrintConsole(struct Game* game, char* format, ...);
|
2012-12-28 02:55:52 +01:00
|
|
|
|
2017-09-10 21:35:14 +02:00
|
|
|
void FatalError(struct Game* game, bool exit, char* format, ...);
|
2016-06-27 21:20:02 +02:00
|
|
|
|
2017-09-10 21:35:14 +02:00
|
|
|
void SetupViewport(struct Game* game, struct Viewport config);
|
2016-08-15 04:41:54 +02:00
|
|
|
|
2017-09-10 21:35:14 +02:00
|
|
|
void WindowCoordsToViewport(struct Game* game, int* x, int* y);
|
2017-05-07 01:30:22 +02:00
|
|
|
|
2017-11-23 22:08:05 +01:00
|
|
|
ALLEGRO_BITMAP* GetFramebuffer(struct Game* game);
|
|
|
|
|
|
|
|
void SetFramebufferAsTarget(struct Game* game);
|
|
|
|
|
2017-05-07 01:30:22 +02:00
|
|
|
ALLEGRO_BITMAP* CreateNotPreservedBitmap(int width, int height);
|
2017-11-23 22:08:05 +01:00
|
|
|
|
2018-02-03 02:13:24 +01:00
|
|
|
void EnableCompositor(struct Game* game, void compositor(struct Game* game, struct Gamestate* gamestates));
|
2017-11-23 22:08:05 +01:00
|
|
|
void DisableCompositor(struct Game* game);
|
|
|
|
|
2016-07-03 00:43:32 +02:00
|
|
|
#endif
|