Sigrid Solveig Haflínudóttirwip Plan 9 port8024a895 years agoHistory
121 lines · 3.3 KB · C
RawDownload
#ifndef _stage_h_#define _stage_h_ #include <SDL2/SDL.h>#include "loader.h"#include "tween.h" /*Copyright (c) 2013-2021 Devine Lu Linvega2018 web port by rezmason2021 C89 port by rezmason Permission to use, copy, modify, and distribute this software for anypurpose with or without fee is hereby granted, provided that the abovecopyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIESWITH 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);void Stage_Quit(void);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);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); #endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t