~rabbits/hiversaires

ref: 3e1627a4c505fa9109dd8d7d107a0b9946af8e5c hiversaires/src/stage.h -rw-r--r-- 3.3 KiB
3e1627a4Rezmason Implementing the credits as just a slower splash, with fading in mixed in, and click-through links to the logos' corresponding sites. Added Aliceffekt logo and the secret logo. Updated the credit trigger to only show the secret if the player has an extra fuse *and* didn't use the walkthrough. 1 year, 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#pragma once

#include <SDL2/SDL.h>
#include "loader.h"
#include "tween.h"

/*
Copyright (c) 2013-2021 Devine Lu Linvega
2018 web port by rezmason
2021 C89 port by rezmason

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/

/*
	Every image onscreen is positioned and scaled
	relative to some rectangular region, which in turn
	is positioned and scaled relative to the window dimensions.

	Stage manages these regions' screen coordinates, along with the
	images inside them, including loading and unloading the lazy ones.

	Stage also manages the regions' tinting, fading and "camera motion".
*/

/*
	A region can scale its image content in one of four ways:
	CONTAIN - preserve the image proportions, scaling it to fit inside the region
	COVER - preserve the image proportions, scaling it so the region fits inside it, and then cropping it
	STRETCH — match the image dimensions exactly to the region's, disregarding proportion
	STRETCH_NODE — like STRETCH, except the region is posiitoned and scaled relative to the node region, rather than the window
*/
typedef enum {
	LAYOUTMODE_CONTAIN,
	LAYOUTMODE_COVER,
	LAYOUTMODE_STRETCH,
	LAYOUTMODE_STRETCH_NODE
} LayoutMode;

/* SDL_Rect is all integers, but Stage's layout math is done in floating point */
typedef struct {
	double x, y, w, h;
} RegionRect;

typedef enum {
	BILLBOARD_NODE,
	BILLBOARD_LAST_NODE_FADE,

	BILLBOARD_ENTENTE_SCREEN,
	BILLBOARD_CLOCK,
	BILLBOARD_CLOCK_SHADOW,
	BILLBOARD_PROGRESS_PANE,

	BILLBOARD_VIGNETTE,

	BILLBOARD_HUD_FUSE,
	BILLBOARD_HUD_FUSE_ALERT,
	BILLBOARD_HUD_AUDIO,
	BILLBOARD_HUD_CLOCK,
	BILLBOARD_HUD_CLOCK_ALERT,
	BILLBOARD_HUD_SAVE,
	BILLBOARD_HUD_SEAL_1,
	BILLBOARD_HUD_SEAL_2,
	BILLBOARD_HUD_SEAL_ALERT,

	BILLBOARD_HUD_STEP_FORWARD,
	BILLBOARD_HUD_STEP_LEFT,
	BILLBOARD_HUD_STEP_RIGHT,

	BILLBOARD_BLACK,
	BILLBOARD_HIVERSAIRES_LOGO,
	BILLBOARD_CONTROLS,
	BILLBOARD_LOGO,

	TRIGGER_ACTION,
	TRIGGER_MOVE_FORWARD,
	TRIGGER_MOVE_LEFT,
	TRIGGER_MOVE_RIGHT,
	NumberOfRegions
} RegionName;

/*
	Each region contains all the data needed to reconstruct it,
	from the multiple intermediate steps that can be independently invalidated.
*/
typedef struct {
	short int line;
	RegionRect layout;
	LayoutMode layoutMode;
	RegionRect bounds;
	RegionRect contentRect;
	Tween alphaTween;
	Image *image;
	SDL_Rect dest;
} Region;

extern Region regions[];

void Stage_Init();
void Stage_Quit();
void Stage_SetImage(RegionName name, Image *image);
void Stage_SwapImages(RegionName name1, RegionName name2);
void Stage_Fade(RegionName name, double startAlpha, double endAlpha, double duration, double delay);
void Stage_StopFade(RegionName name, int complete);
void Stage_SetAlpha(RegionName name, double alpha);
void Stage_Tint(SDL_Color color, double duration, double delay);
void Stage_StopTint();
void Stage_Nudge(double x, double y, double duration);
void Stage_Update(double totalTime, double deltaTime);
void Stage_Resize(int windowW, int windowH);
void Stage_Render(SDL_Renderer *renderer);
int Stage_HitTest(RegionName name, int x, int y);
int Stage_PointNearBorder(int x, int y, int locus);