~rabbits/hiversaires

48e00fcdd82d1c3e02fabb9c29dceaf4d461f02c — Rezmason 11 months ago fe206bf
Remade the splash animation sequence
6 files changed, 83 insertions(+), 62 deletions(-)

M src/gui.c
M src/gui.h
M src/play.c
M src/stage.c
M src/stage.h
M src/stageregions.c
M src/gui.c => src/gui.c +65 -43
@@ 4,6 4,8 @@
#include <stdio.h>
#include "datatypes.h"
#include "stage.h"
#include "delays.h"
#include "util.h"

/*
Copyright (c) 2013-2021 Devine Lu Linvega


@@ 73,6 75,11 @@ static int nodeImageIndex = 0;
static Image *nodeImages[2];
static char nodeImagePaths[2][PATH_LENGTH];

static int splash1Delay;
static int splash2Delay;
static int splash3Delay;
static int splash4Delay;

int
GUI_PreloadAssets()
{


@@ 173,9 180,7 @@ GUI_Init()
	Stage_SetAlpha(BILLBOARD_VIGNETTE, 0);
	Stage_SetAlpha(BILLBOARD_MENU_LOGO, 0);
	Stage_SetAlpha(BILLBOARD_MENU_CONTROLS, 0);
	Stage_SetAlpha(BILLBOARD_SPLASH_TOP, 0);
	Stage_SetAlpha(BILLBOARD_SPLASH_LEFT, 0);
	Stage_SetAlpha(BILLBOARD_SPLASH_RIGHT, 0);
	Stage_SetAlpha(BILLBOARD_SPLASH, 0);

	/* Most HUD elements occupy a Stage region for the whole game */
	nodeImageIndex = 0;


@@ 193,9 198,6 @@ GUI_Init()
	Stage_SetImage(BILLBOARD_MENU_BLACK, black);
	Stage_SetImage(BILLBOARD_MENU_LOGO, menuLogo);
	Stage_SetImage(BILLBOARD_MENU_CONTROLS, menuControls);
	Stage_SetImage(BILLBOARD_SPLASH_TOP, hundredRabbitsLogo);
	Stage_SetImage(BILLBOARD_SPLASH_LEFT, xxiivvLogo);
	Stage_SetImage(BILLBOARD_SPLASH_RIGHT, rezmasonLogo);

	SDL_SetCursor(cursorsByType[currentCursorType][cursorPressed]);



@@ 351,8 353,8 @@ GUI_ShowClockFace(int state, int refresh)
{
	Stage_SetImage(BILLBOARD_CLOCK, clocksByType[CLOCKTYPE_STATE_0 + state]);
	if(!refresh) {
		Stage_Fade(BILLBOARD_CLOCK_SHADOW, 0, 0.23, 1.5, 0.5, NULL);
		Stage_Fade(BILLBOARD_CLOCK, 0, 1, 0.5, 0.5, NULL);
		Stage_Fade(BILLBOARD_CLOCK_SHADOW, 0, 0.23, 1.5, 0.5);
		Stage_Fade(BILLBOARD_CLOCK, 0, 1, 0.5, 0.5);
	} else {
		Stage_SetAlpha(BILLBOARD_CLOCK_SHADOW, 0.23);
		Stage_SetAlpha(BILLBOARD_CLOCK, 1);


@@ 363,13 365,13 @@ void
GUI_ShowClock(int state)
{
	Stage_SetImage(BILLBOARD_HUD_CLOCK, iconsByType[ICONTYPE_CLOCK_0 + state]);
	Stage_Fade(BILLBOARD_HUD_CLOCK, 1, 0, 0.5, 3, NULL);
	Stage_Fade(BILLBOARD_HUD_CLOCK, 1, 0, 0.5, 3);
}

void
GUI_ShowClockAlert()
{
	Stage_Fade(BILLBOARD_HUD_CLOCK_ALERT, 1, 0, 0.5, 0.5, NULL);
	Stage_Fade(BILLBOARD_HUD_CLOCK_ALERT, 1, 0, 0.5, 0.5);
}

void


@@ 391,34 393,34 @@ GUI_ShowSeals(Zone zoneP, Zone zoneQ)
	Stage_SetImage(BILLBOARD_HUD_SEAL_1, sealsByZone[zone1]);
	Stage_SetImage(BILLBOARD_HUD_SEAL_2, sealsByZone[zone2]);

	Stage_Fade(BILLBOARD_HUD_SEAL_1, 1, 0, 0.5, 3, NULL);
	Stage_Fade(BILLBOARD_HUD_SEAL_2, 1, 0, 0.5, 3, NULL);
	Stage_Fade(BILLBOARD_HUD_SEAL_1, 1, 0, 0.5, 3);
	Stage_Fade(BILLBOARD_HUD_SEAL_2, 1, 0, 0.5, 3);
}

void
GUI_ShowSealAlert()
{
	Stage_Fade(BILLBOARD_HUD_SEAL_ALERT, 1, 0, 0.5, 0.5, NULL);
	Stage_Fade(BILLBOARD_HUD_SEAL_ALERT, 1, 0, 0.5, 0.5);
}

void
GUI_ShowEnergy(int level)
{
	Stage_SetImage(BILLBOARD_HUD_FUSE, iconsByType[ICONTYPE_FUSE_0 + level]);
	Stage_Fade(BILLBOARD_HUD_FUSE, 1, 0, 0.5, 3, NULL);
	Stage_Fade(BILLBOARD_HUD_FUSE, 1, 0, 0.5, 3);
}

void
GUI_ShowEnergyAlert()
{
	Stage_Fade(BILLBOARD_HUD_FUSE_ALERT, 1, 0, 1.5, 0.5, NULL);
	Stage_Fade(BILLBOARD_HUD_FUSE_ALERT, 1, 0, 1.5, 0.5);
}

void
GUI_ShowAudio(int enabled)
{
	Stage_SetImage(BILLBOARD_HUD_AUDIO, iconsByType[ICONTYPE_MUSIC_OFF + enabled]);
	Stage_Fade(BILLBOARD_HUD_AUDIO, 1, 0, 0.5, 3, NULL);
	Stage_Fade(BILLBOARD_HUD_AUDIO, 1, 0, 0.5, 3);
}

void


@@ 431,9 433,7 @@ GUI_HideMenu()
	Stage_SetAlpha(BILLBOARD_MENU_CREDIT4, 0.);
	Stage_SetAlpha(BILLBOARD_MENU_LOGO, 0.);
	Stage_SetAlpha(BILLBOARD_MENU_CONTROLS, 0.);
	Stage_SetAlpha(BILLBOARD_SPLASH_TOP, 0.);
	Stage_SetAlpha(BILLBOARD_SPLASH_LEFT, 0.);
	Stage_SetAlpha(BILLBOARD_SPLASH_RIGHT, 0.);
	Stage_SetAlpha(BILLBOARD_SPLASH, 0.);
}

void


@@ 445,16 445,16 @@ GUI_ShowHomeMenu()
	Stage_SetAlpha(BILLBOARD_HUD_SAVE, 0);
	Stage_SetAlpha(BILLBOARD_NODE, 1);

	Stage_Fade(BILLBOARD_MENU_BLACK, 1, 0, 2, 0, NULL);
	Stage_Fade(BILLBOARD_MENU_LOGO, 1, 0, 2, 3, NULL);
	Stage_Fade(BILLBOARD_MENU_CONTROLS, 1, 0, 1, 8, NULL);
	Stage_Fade(BILLBOARD_MENU_BLACK, 1, 0, 2, 0);
	Stage_Fade(BILLBOARD_MENU_LOGO, 1, 0, 2, 3);
	Stage_Fade(BILLBOARD_MENU_CONTROLS, 1, 0, 1, 8);
}

void
GUI_ShowMovement(int nudgeX, int nudgeY)
{
	Stage_Nudge(nudgeX * NUDGE_MULT, nudgeY * NUDGE_MULT, 0.2);
	Stage_Fade(BILLBOARD_NODE, 0.5, 1, 0.2, 0, NULL);
	Stage_Fade(BILLBOARD_NODE, 0.5, 1, 0.2, 0);
	Stage_SetAlpha(BILLBOARD_LAST_NODE_FADE, 0);
}



@@ 482,71 482,93 @@ GUI_ShowNode(char *nodeName, Orientation orientation, NodeModifier modifier, dou
	Stage_SwapImages(BILLBOARD_LAST_NODE_FADE, BILLBOARD_NODE);
	Stage_SetImage(BILLBOARD_NODE, nodeImages[nodeImageIndex]);
	Stage_SetAlpha(BILLBOARD_NODE, 1);
	Stage_Fade(BILLBOARD_LAST_NODE_FADE, 1, 0, fadeDuration, fadeDelay, NULL);
	Stage_Fade(BILLBOARD_LAST_NODE_FADE, 1, 0, fadeDuration, fadeDelay);
}

static void
splashNext(void *data)
{
	Image *image = data;
	Stage_SetImage(BILLBOARD_SPLASH, image);
	Stage_Fade(BILLBOARD_SPLASH, 1, 0, 0.125, 0.875);
}

static void
splashEnd(void *data)
{
	FuncWrapper *wrapper = data;
	Stage_SetAlpha(BILLBOARD_SPLASH, 0);
	wrapper->f();
	free(wrapper);
}

void
GUI_ShowSplash(float delay, void (*onComplete)())
GUI_RunSplash(void (*onComplete)())
{
	Stage_SetAlpha(BILLBOARD_MENU_BLACK, 1);
	Stage_Fade(BILLBOARD_SPLASH_TOP, 0, 1, 2, 0 + delay, NULL);
	Stage_Fade(BILLBOARD_SPLASH_LEFT, 0, 1, 1.5, 1 + delay, NULL);
	Stage_Fade(BILLBOARD_SPLASH_RIGHT, 0, 1, 1.5, 1.75 + delay, onComplete);
	Stage_SetAlpha(BILLBOARD_SPLASH, 1);
	splash1Delay = Delays_Add(0.5, splashNext, hundredRabbitsLogo);
	splash2Delay = Delays_Add(1.5, splashNext, xxiivvLogo);
	splash3Delay = Delays_Add(2.5, splashNext, rezmasonLogo);
	splash4Delay = Delays_Add(3.5, splashEnd, wrapFunction(onComplete));
}

void
GUI_HideSplash(float delay, void (*onComplete)())
GUI_SkipSplash()
{
	Stage_SetAlpha(BILLBOARD_MENU_BLACK, 1);
	Stage_Fade(BILLBOARD_SPLASH_TOP, 1, 0, 2, 0. + delay, NULL);
	Stage_Fade(BILLBOARD_SPLASH_LEFT, 1, 0, 1.5, 1. + delay, NULL);
	Stage_Fade(BILLBOARD_SPLASH_RIGHT, 1, 0, 1.5, 1.75 + delay, onComplete);
	Stage_SetAlpha(BILLBOARD_SPLASH, 0);

	Delays_Cancel(splash1Delay, 0);
	Delays_Cancel(splash2Delay, 0);
	Delays_Cancel(splash3Delay, 0);
	Delays_Cancel(splash4Delay, 1);
}

void
GUI_ShowCreditsMenu(int showSecret)
{
	Stage_Fade(BILLBOARD_MENU_BLACK, 0, 1, 1, 1, NULL);
	Stage_Fade(BILLBOARD_MENU_CREDIT1, 0, 1, 1, 6, NULL);
	Stage_Fade(BILLBOARD_MENU_CREDIT2, 0, 1, 1, 10, NULL);
	Stage_Fade(BILLBOARD_MENU_CREDIT3, 0, 1, 1, 16, NULL);
	Stage_Fade(BILLBOARD_MENU_BLACK, 0, 1, 1, 1);
	Stage_Fade(BILLBOARD_MENU_CREDIT1, 0, 1, 1, 6);
	Stage_Fade(BILLBOARD_MENU_CREDIT2, 0, 1, 1, 10);
	Stage_Fade(BILLBOARD_MENU_CREDIT3, 0, 1, 1, 16);

	if(showSecret) {
		Stage_Fade(BILLBOARD_MENU_CREDIT4, 0, 1, 1, 24, NULL);
		Stage_Fade(BILLBOARD_MENU_CREDIT4, 0, 1, 1, 24);
	}
}

void
GUI_FlashVignette()
{
	Stage_Fade(BILLBOARD_VIGNETTE, 1., 0., 1., 0., NULL);
	Stage_Fade(BILLBOARD_VIGNETTE, 1., 0., 1., 0.);
}

void
GUI_ShowSave()
{
	Stage_Fade(BILLBOARD_HUD_SAVE, 1, 0, 0.5, 3, NULL);
	Stage_Fade(BILLBOARD_HUD_SAVE, 1, 0, 0.5, 3);
}

void
GUI_ShowProgressScreen(Chapter chapter)
{
	Stage_SetImage(BILLBOARD_PROGRESS_PANE, progressPanesByChapter[chapter]);
	Stage_Fade(BILLBOARD_PROGRESS_PANE, 0, 1, 0.5, 0.3, NULL);
	Stage_Fade(BILLBOARD_PROGRESS_PANE, 0, 1, 0.5, 0.3);
}

void
GUI_ShowEntenteScreen()
{
	Stage_SetImage(BILLBOARD_ENTENTE_SCREEN, ententeProgressPane);
	Stage_Fade(BILLBOARD_PROGRESS_PANE, 0, 1, 0.5, 0.3, NULL);
	Stage_Fade(BILLBOARD_PROGRESS_PANE, 0, 1, 0.5, 0.3);
}

void
GUI_ShowMazeInstruction(MazeAxis axis, MazeInstruction instruction)
{
	Stage_SetImage(BILLBOARD_ENTENTE_SCREEN, mazeIconsByAxisAndInstruction[axis][instruction]);
	Stage_Fade(BILLBOARD_ENTENTE_SCREEN, 0, 1, 1, 0, NULL);
	Stage_Fade(BILLBOARD_ENTENTE_SCREEN, 0, 1, 1, 0);
}

void


@@ 564,7 586,7 @@ GUI_ShowFootstep(Footstep step)
		name = BILLBOARD_HUD_STEP_FORWARD;
		break;
	}
	Stage_Fade(name, 1, 0, 0.5, 0, NULL);
	Stage_Fade(name, 1, 0, 0.5, 0);
}

void

M src/gui.h => src/gui.h +2 -2
@@ 106,8 106,8 @@ void GUI_ShowHomeMenu();
void GUI_ShowMovement(int nudgeX, int nudgeY);
void GUI_ShowNode(char *nodeName, Orientation orientation, NodeModifier modifier, double fadeDuration, double fadeDelay);
void GUI_ShowCreditsMenu(int showSecret);
void GUI_ShowSplash(float delay, void (*onComplete)());
void GUI_HideSplash(float delay, void (*onComplete)());
void GUI_RunSplash(void (*onComplete)());
void GUI_SkipSplash();
void GUI_FlashVignette();
void GUI_ShowSave();
void GUI_ShowProgressScreen(Chapter chapter);

M src/play.c => src/play.c +10 -3
@@ 34,6 34,7 @@ static char *orientationNames = "NESW";
static GameState *_state = NULL;
static Node *currentNode = NULL;
static Subject *currentSubject = NULL;
static int begun = 0;
static double _totalTime = 0;
static double resetTime = -1;
static double walkthroughStartTime = -1;


@@ 187,9 188,10 @@ reset()
}

static void
hideSplash()
enterGame()
{
	GUI_HideSplash(3, GUI_ShowHomeMenu);
	begun = 1;
	GUI_ShowHomeMenu();
}

void


@@ 209,7 211,7 @@ Play_Init(GameState *state)
	currentNode = Nodes_Get(_state->nodeName);
	refreshNode(0, 0);

	GUI_ShowSplash(0.5, hideSplash);
	GUI_RunSplash(enterGame);

	printf(
		"		\n\n"


@@ 233,6 235,11 @@ Play_Quit()
void
Play_ProcessInput(InputType type, int down)
{
	if(!begun) {
		GUI_SkipSplash();
		return;
	}

	if(_state->completed) {
		return;
	}

M src/stage.c => src/stage.c +2 -2
@@ 240,14 240,14 @@ Stage_SwapImages(RegionName name1, RegionName name2)
}

void
Stage_Fade(RegionName name, double startAlpha, double endAlpha, double duration, double delay, void (*onComplete)())
Stage_Fade(RegionName name, double startAlpha, double endAlpha, double duration, double delay)
{
	if(duration <= 0) {
		Stage_StopFade(name, 0);
		Stage_SetAlpha(name, endAlpha);
	} else {
		Region *region = &regions[name];
		Tween_Start(&region->alphaTween, startAlpha, endAlpha, _totalTime + delay, duration, onComplete);
		Tween_Start(&region->alphaTween, startAlpha, endAlpha, _totalTime + delay, duration, NULL);
		Tween_Update(&region->alphaTween, _totalTime);
		updateLazierImage(region);
	}

M src/stage.h => src/stage.h +2 -4
@@ 80,9 80,7 @@ typedef enum {
	BILLBOARD_MENU_LOGO,
	BILLBOARD_MENU_CONTROLS,

	BILLBOARD_SPLASH_TOP,
	BILLBOARD_SPLASH_LEFT,
	BILLBOARD_SPLASH_RIGHT,
	BILLBOARD_SPLASH,

	TRIGGER_ACTION,
	TRIGGER_MOVE_FORWARD,


@@ 112,7 110,7 @@ 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 (*onComplete)());
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);

M src/stageregions.c => src/stageregions.c +2 -8
@@ 117,14 117,8 @@ Region regions[] =
		/* BILLBOARD_MENU_CONTROLS */
		region(0., 0., 1., 1., LAYOUTMODE_CONTAIN),

		/* BILLBOARD_SPLASH_TOP */
		region(0.2, 0.2, 0.6, 0.4, LAYOUTMODE_CONTAIN),

		/* BILLBOARD_SPLASH_LEFT */
		region(0.35, 0.7, 0.15, 0.3, LAYOUTMODE_CONTAIN),

		/* BILLBOARD_SPLASH_RIGHT */
		region(0.50, 0.7, 0.15, 0.3, LAYOUTMODE_CONTAIN),
		/* BILLBOARD_SPLASH */
		region(0.3, 0.3, 0.4, 0.4, LAYOUTMODE_CONTAIN),

		/* TRIGGER_ACTION */
		region(1. / 3., 1. / 3., 1. / 3., 1. / 3., LAYOUTMODE_STRETCH),