|
0
|
1 |
/*
|
|
|
2 |
Copyright (c) 2023 MCL Software
|
|
|
3 |
|
|
|
4 |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”),
|
|
|
5 |
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
6 |
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
|
7 |
|
|
|
8 |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
|
9 |
|
|
|
10 |
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
11 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
12 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
13 |
*/
|
|
|
14 |
|
|
|
15 |
#include "common.h"
|
|
|
16 |
|
|
|
17 |
SDL_Texture* titleBackground = 0;
|
|
|
18 |
SDL_Texture* buttons = 0;
|
|
|
19 |
|
|
|
20 |
void initTitleScreenGraphics()
|
|
|
21 |
{
|
|
|
22 |
SDL_Surface* titleBackgroundSurface = IMG_Load("./img/titlebg.png");
|
|
|
23 |
SDL_Surface* buttonsSurface = IMG_Load("./img/buttons.png");
|
|
|
24 |
|
|
|
25 |
titleBackground = SDL_CreateTextureFromSurface(renderer, titleBackgroundSurface);
|
|
|
26 |
buttons = SDL_CreateTextureFromSurface(renderer, buttonsSurface);
|
|
|
27 |
|
|
|
28 |
SDL_FreeSurface(buttonsSurface);
|
|
|
29 |
SDL_FreeSurface(titleBackgroundSurface);
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
void freeTitleScreenGraphics()
|
|
|
33 |
{
|
|
|
34 |
SDL_DestroyTexture(titleBackground);
|
|
|
35 |
SDL_DestroyTexture(buttons);
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
void drawTitleScreen(int selectedItem)
|
|
|
39 |
{
|
|
|
40 |
SDL_RenderClear(renderer);
|
|
|
41 |
SDL_RenderCopy(renderer, titleBackground, 0, 0);
|
|
|
42 |
drawTitleMenuText();
|
|
|
43 |
SDL_RenderCopy(renderer, logo, 0, &(SDL_Rect){SCREEN_WIDTH / 2 - 300, 100, 300 * 2, 36 * 2});
|
|
|
44 |
|
|
|
45 |
for(int i = 0; i < 4; i++)
|
|
|
46 |
{
|
|
|
47 |
SDL_RenderCopy(renderer, buttons, &(SDL_Rect){0, 65 * i, 377, 65}, &(SDL_Rect){SCREEN_WIDTH / 2 - (selectedMenuItem != i ? 377 : 400) / 2, 200 + 70 * i, selectedMenuItem != i ? 377 : 400, 65});
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
SDL_RenderPresent(renderer);
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
void drawCreditsScreen()
|
|
|
54 |
{
|
|
|
55 |
|
|
|
56 |
}
|
|
|
57 |
|