Atrinik Client  4.0
credits.c
Go to the documentation of this file.
1 /*************************************************************************
2  * Atrinik, a Multiplayer Online Role Playing Game *
3  * *
4  * Copyright (C) 2009-2014 Alex Tokar and Atrinik Development Team *
5  * *
6  * Fork from Crossfire (Multiplayer game for X-windows). *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the Free Software *
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
21  * *
22  * The author can be reached at admin@atrinik.org *
23  ************************************************************************/
24 
32 #include <global.h>
33 
34 #define CREDITS_WIDTH 455
35 #define CREDITS_HEIGHT 250
36 #define CREDITS_SCROLL_TICKS 80
37 
45 static int credits_scroll;
49 static int credits_height;
53 static uint32_t credits_ticks;
54 
56 static int popup_draw_func(popup_struct *popup)
57 {
58  SDL_Rect box;
59 
60  box.w = popup->surface->w;
61  box.h = 38;
62  text_show(popup->surface, FONT_SERIF16, "Atrinik Credits", 0, 0, COLOR_HGOLD, TEXT_ALIGN_CENTER | TEXT_VALIGN_CENTER, &box);
63 
64  box.x = 0;
65  box.y = credits_scroll;
66  box.w = CREDITS_WIDTH;
67  box.h = CREDITS_HEIGHT;
68  text_show(popup->surface, FONT_ARIAL11, hfile_contributors->msg, 10, 40, COLOR_WHITE, TEXT_WORD_WRAP | TEXT_MARKUP | TEXT_HEIGHT, &box);
69 
70  if (SDL_GetTicks() - credits_ticks > CREDITS_SCROLL_TICKS) {
72  credits_ticks = SDL_GetTicks();
73  }
74 
76 }
77 
81 void credits_show(void)
82 {
83  SDL_Rect box;
84  popup_struct *popup;
85 
86  hfile_contributors = help_find("contributors");
87 
88  if (!hfile_contributors) {
89  LOG(BUG, "Could not find 'contributors' help file.");
90  return;
91  }
92 
93  credits_scroll = 0;
94  credits_ticks = SDL_GetTicks();
95 
96  /* Calculate the height. */
97  box.w = CREDITS_WIDTH;
98  box.h = CREDITS_HEIGHT;
99  text_show(NULL, FONT_ARIAL11, hfile_contributors->msg, 0, 0, COLOR_BLACK, TEXT_WORD_WRAP | TEXT_MARKUP | TEXT_HEIGHT, &box);
100  credits_height = box.h;
101 
102  popup = popup_create(texture_get(TEXTURE_TYPE_CLIENT, "popup"));
103  popup->draw_func = popup_draw_func;
104 }
static uint32_t credits_ticks
Definition: credits.c:53
#define COLOR_BLACK
Definition: text.h:323
#define TEXT_WORD_WRAP
Definition: text.h:226
int(* draw_func)(struct popup_struct *popup)
Definition: popup.h:127
hfile_struct * help_find(const char *name)
Definition: help.c:205
void text_show(SDL_Surface *surface, font_struct *font, const char *text, int x, int y, const char *color_notation, uint64_t flags, SDL_Rect *box)
Definition: text.c:1983
void credits_show(void)
Definition: credits.c:81
#define COLOR_HGOLD
Definition: text.h:319
texture_struct * texture_get(texture_type_t type, const char *name)
Definition: texture.c:279
#define TEXT_MARKUP
Definition: text.h:224
static int credits_scroll
Definition: credits.c:45
#define TEXT_ALIGN_CENTER
Definition: text.h:230
static int popup_draw_func(popup_struct *popup)
Definition: credits.c:56
static hfile_struct * hfile_contributors
Definition: credits.c:41
#define TEXT_HEIGHT
Definition: text.h:241
static int credits_height
Definition: credits.c:49
SDL_Surface * surface
Definition: popup.h:65
#define TEXT_VALIGN_CENTER
Definition: text.h:246
#define COLOR_WHITE
Definition: text.h:289