Adds essentially nothing. Some convenience functions. That is all
This commit is contained in:
parent
5e0bbe423d
commit
d564a559dc
|
@ -4,6 +4,12 @@ SET(CMAKE_COLOR_MAKEFILE ON)
|
||||||
|
|
||||||
project(breakhack C)
|
project(breakhack C)
|
||||||
|
|
||||||
|
set(breakhack_GAME_TITLE "BreakHack")
|
||||||
|
set(breakhack_MAJOR_VERSION 0)
|
||||||
|
set(breakhack_MINOR_VERSION 1)
|
||||||
|
set(breakhack_PATCH_VERSION 1)
|
||||||
|
set(breakhack_RELEASE_TYPE "(early access)")
|
||||||
|
|
||||||
include(FindLua)
|
include(FindLua)
|
||||||
include(FindPhysFS)
|
include(FindPhysFS)
|
||||||
include(cmake/FindSDL2.cmake)
|
include(cmake/FindSDL2.cmake)
|
||||||
|
|
|
@ -21,4 +21,10 @@
|
||||||
|
|
||||||
#cmakedefine _WIN32 ${WIN32}
|
#cmakedefine _WIN32 ${WIN32}
|
||||||
|
|
||||||
|
#define GAME_TITLE "@breakhack_GAME_TITLE@"
|
||||||
|
#define MAJOR_VERSION @breakhack_MAJOR_VERSION@
|
||||||
|
#define MINOR_VERSION @breakhack_MINOR_VERSION@
|
||||||
|
#define PATCH_VERSION @breakhack_PATCH_VERSION@
|
||||||
|
#define RELEASE_TYPE "@breakhack_RELEASE_TYPE@"
|
||||||
|
|
||||||
#endif // CONFIG_H_
|
#endif // CONFIG_H_
|
||||||
|
|
|
@ -499,7 +499,7 @@ gui_render_log(Gui *gui, unsigned int width, unsigned int height, Camera *cam)
|
||||||
void
|
void
|
||||||
gui_render_event_message(Gui *gui, Camera *cam)
|
gui_render_event_message(Gui *gui, Camera *cam)
|
||||||
{
|
{
|
||||||
static SDL_Color color = { 255, 255, 255, 255 };
|
static SDL_Color fg_color = { 255, 255, 255, 255 };
|
||||||
static SDL_Rect box = { 0, 0, 150, 50 };
|
static SDL_Rect box = { 0, 0, 150, 50 };
|
||||||
|
|
||||||
if (timer_started(gui->event_message_timer)
|
if (timer_started(gui->event_message_timer)
|
||||||
|
@ -512,7 +512,7 @@ gui_render_event_message(Gui *gui, Camera *cam)
|
||||||
if (event_messages.count > 0) {
|
if (event_messages.count > 0) {
|
||||||
texture_load_from_text(gui->event_message,
|
texture_load_from_text(gui->event_message,
|
||||||
event_messages.messages[0],
|
event_messages.messages[0],
|
||||||
color,
|
fg_color,
|
||||||
cam->renderer);
|
cam->renderer);
|
||||||
|
|
||||||
box.x = (GAME_VIEW_WIDTH/2) - (gui->event_message->dim.width/2);
|
box.x = (GAME_VIEW_WIDTH/2) - (gui->event_message->dim.width/2);
|
||||||
|
|
|
@ -122,7 +122,9 @@ bool initSDL(void)
|
||||||
|
|
||||||
mixer_init();
|
mixer_init();
|
||||||
|
|
||||||
gWindow = SDL_CreateWindow("Breakhack",
|
char title_buffer[100];
|
||||||
|
m_sprintf(title_buffer, 100, "%s %d.%d.%d %s", GAME_TITLE, MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION, RELEASE_TYPE);
|
||||||
|
gWindow = SDL_CreateWindow(title_buffer,
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
(int)(SCREEN_WIDTH * renderScale),
|
(int)(SCREEN_WIDTH * renderScale),
|
||||||
|
|
|
@ -84,20 +84,9 @@ texture_load_font(Texture *t, const char *path, unsigned int size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
texture_load_from_text(Texture *t,
|
load_from_surface(Texture *t, SDL_Surface *surface, SDL_Renderer *renderer)
|
||||||
const char *text,
|
|
||||||
SDL_Color c,
|
|
||||||
SDL_Renderer *renderer)
|
|
||||||
{
|
{
|
||||||
SDL_Surface *surface = TTF_RenderText_Solid( t->font, text, c );
|
|
||||||
if (surface == NULL)
|
|
||||||
{
|
|
||||||
error("Unable to create texture from rendered text: %s",
|
|
||||||
IMG_GetError());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t->texture) {
|
if (t->texture) {
|
||||||
SDL_DestroyTexture(t->texture);
|
SDL_DestroyTexture(t->texture);
|
||||||
t->texture = NULL;
|
t->texture = NULL;
|
||||||
|
@ -116,6 +105,51 @@ texture_load_from_text(Texture *t,
|
||||||
SDL_FreeSurface(surface);
|
SDL_FreeSurface(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
texture_load_from_text(Texture *t,
|
||||||
|
const char *text,
|
||||||
|
SDL_Color c,
|
||||||
|
SDL_Renderer *renderer)
|
||||||
|
{
|
||||||
|
SDL_Surface *surface = TTF_RenderText_Solid( t->font, text, c );
|
||||||
|
if (surface == NULL)
|
||||||
|
{
|
||||||
|
error("Unable to create texture from rendered text: %s",
|
||||||
|
IMG_GetError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
load_from_surface(t, surface, renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
texture_load_from_text_shaded(Texture *t, const char * text, SDL_Color fg, SDL_Color bg, SDL_Renderer *renderer)
|
||||||
|
{
|
||||||
|
SDL_Surface *surface = TTF_RenderText_Shaded( t->font, text, fg, bg );
|
||||||
|
if (surface == NULL)
|
||||||
|
{
|
||||||
|
error("Unable to create texture from rendered text: %s",
|
||||||
|
IMG_GetError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
load_from_surface(t, surface, renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
texture_load_from_text_blended(Texture *t, const char * text, SDL_Color fg, SDL_Renderer *renderer)
|
||||||
|
{
|
||||||
|
SDL_Surface *surface = TTF_RenderText_Blended( t->font, text, fg );
|
||||||
|
if (surface == NULL)
|
||||||
|
{
|
||||||
|
error("Unable to create texture from rendered text: %s",
|
||||||
|
IMG_GetError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
load_from_surface(t, surface, renderer);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
texture_render(Texture *texture, SDL_Rect *box, Camera *cam)
|
texture_render(Texture *texture, SDL_Rect *box, Camera *cam)
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,6 +46,19 @@ texture_load_from_text(Texture*,
|
||||||
SDL_Color,
|
SDL_Color,
|
||||||
SDL_Renderer*);
|
SDL_Renderer*);
|
||||||
|
|
||||||
|
void
|
||||||
|
texture_load_from_text_shaded(Texture*,
|
||||||
|
const char *text,
|
||||||
|
SDL_Color,
|
||||||
|
SDL_Color,
|
||||||
|
SDL_Renderer*);
|
||||||
|
|
||||||
|
void
|
||||||
|
texture_load_from_text_blended(Texture*,
|
||||||
|
const char *text,
|
||||||
|
SDL_Color,
|
||||||
|
SDL_Renderer*);
|
||||||
|
|
||||||
void
|
void
|
||||||
texture_render(Texture*, SDL_Rect*, Camera*);
|
texture_render(Texture*, SDL_Rect*, Camera*);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue