, blinds(0)
, color(color)
, duration(duration)
+, leadIn(0)
+, leadOut(0)
+, leadInDone(true)
+, fadeDone(false)
, in(in)
, interactive(interactive) {
}
void ColorFade::EnterState(Application &c, SDL_Surface *screen) {
- timer = GraphicsTimers().StartCountdown(duration);
ctrl = &c;
+ if (leadIn > 0) {
+ timer = GraphicsTimers().StartCountdown(leadIn);
+ } else {
+ timer = GraphicsTimers().StartCountdown(duration);
+
+ }
}
void ColorFade::ExitState(Application &, SDL_Surface *screen) {
}
Uint8 ColorFade::GetAlpha() const {
- if (in) {
- return timer.Remaining() * 255 / duration;
+ if (!leadInDone) {
+ return in ? 255 : 0;
+ } else if (!fadeDone) {
+ return (in ? timer.Remaining() : timer.Elapsed()) * 255 / duration;
} else {
- return timer.Elapsed() * 255 / duration;
+ return in ? 0 : 255;
}
}
slave->HandleEvents(input);
}
if (timer.Finished()) {
- ctrl->PopState();
+ if (!leadInDone) {
+ leadInDone = true;
+ timer = GraphicsTimers().StartCountdown(duration);
+ } else if (!fadeDone) {
+ fadeDone = true;
+ if (leadOut > 0) {
+ timer = GraphicsTimers().StartCountdown(leadOut);
+ } else {
+ ctrl->PopState();
+ }
+ } else {
+ ctrl->PopState();
+ }
}
}