Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
FadeView.cpp
Go to the documentation of this file.
1
/* Project nGenEx
2
Destroyer Studios LLC
3
Copyright © 1997-2004. All Rights Reserved.
4
5
SUBSYSTEM: nGenEx.lib
6
FILE: FadeView.cpp
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Fading Bitmap "billboard" Image View class
13
*/
14
15
#include "
MemDebug.h
"
16
#include "
FadeView.h
"
17
#include "
Color.h
"
18
#include "
Window.h
"
19
#include "
Video.h
"
20
#include "
Screen.h
"
21
#include "
Game.h
"
22
23
// +--------------------------------------------------------------------+
24
25
FadeView::FadeView
(
Window
* c,
double
in,
double
out,
double
hold)
26
:
View
(c),
27
fade_in(in * 1000),
28
fade_out(out * 1000),
29
hold_time(hold * 1000),
30
step_time(0),
31
fast(1),
32
time(0)
33
{
34
state
=
StateStart
;
35
}
36
37
FadeView::~FadeView
()
38
{ }
39
40
// +--------------------------------------------------------------------+
41
42
void
FadeView::FadeIn
(
double
in) {
fade_in
= in * 1000; }
43
void
FadeView::FadeOut
(
double
out) {
fade_out
= out * 1000; }
44
void
FadeView::FastFade
(
int
fade_fast) {
fast
= fade_fast; }
45
void
FadeView::StopHold
()
46
{
47
//Print(" FadeView::StopHold()\n");
48
hold_time
= 0;
49
}
50
51
// +--------------------------------------------------------------------+
52
53
void
54
FadeView::Refresh
()
55
{
56
double
msec = 0;
57
58
if
(
state
==
StateStart
) {
59
time
=
Game::RealTime
();
60
}
61
else
if
(
state
!=
StateDone
) {
62
double
new_time =
Game::RealTime
();
63
msec = new_time -
time
;
64
time = new_time;
65
}
66
67
switch
(
state
) {
68
case
StateStart
:
69
if
(
fade_in
) {
70
//Print(" * FadeView: %f, %f, %f\n", fade_in, fade_out, hold_time);
71
Color::SetFade
(0);
72
//Print(" 1. FadeView SetFade to 0 (%6.1f)\n", time);
73
}
74
75
step_time
= 0;
76
state
=
State2
;
77
break
;
78
79
case
State2
:
80
if
(
fade_in
) {
81
Color::SetFade
(0);
82
//Print(" 1. FadeView SetFade to 0 (%6.1f)\n", time);
83
}
84
85
step_time
= 0;
86
state
=
StateIn
;
87
break
;
88
89
case
StateIn
:
90
if
(
step_time
<
fade_in
) {
91
double
fade =
step_time
/
fade_in
;
92
Color::SetFade
(fade);
93
//Print(" 2. FadeView SetFade to %3d (%6.1f) %6.1f\n", (int) (fade * 100), time, step_time);
94
step_time
+= msec;
95
}
96
else
{
97
Color::SetFade
(1);
98
//Print(" 2. FadeView SetFade to %3d (%6.1f) %6.1f => HOLDING\n", 100, time, step_time);
99
step_time
= 0;
100
state
=
StateHold
;
101
}
102
break
;
103
104
case
StateHold
:
105
if
(
step_time
<
hold_time
) {
106
step_time
+= msec;
107
//Print(" 3. FadeView holding at %3d (%6.1f) %6.1f\n", 100, time, step_time);
108
}
109
else
{
110
//Print(" 3. FadeView HOLD COMPLETE (%6.1f) %6.1f\n", time, step_time);
111
step_time
= 0;
112
state
=
StateOut
;
113
}
114
break
;
115
116
case
StateOut
:
117
if
(
fade_out
> 0) {
118
if
(
step_time
<
fade_out
) {
119
double
fade = 1 -
step_time
/
fade_out
;
120
Color::SetFade
(fade);
121
//Print(" 4. FadeView SetFade to %3d (%6.1f) %6.1f\n", (int) (fade*100), time, step_time);
122
step_time
+= msec;
123
}
124
else
{
125
Color::SetFade
(0);
126
//Print(" 4. FadeView SetFade to %3d (%6.1f) %6.1f\n", 0, time, step_time);
127
step_time
= 0;
128
state
=
StateDone
;
129
}
130
}
131
else
{
132
Color::SetFade
(1);
133
//Print(" 4. FadeView SetFade to %3d (%6.1f) %6.1f\n", 0, time, step_time);
134
step_time
= 0;
135
state
=
StateDone
;
136
}
137
break
;
138
139
default
:
140
case
StateDone
:
141
//Print(" 5. FadeView done (%6.1f) %6.1f\n", time, step_time);
142
break
;
143
}
144
}
145
nGenEx
FadeView.cpp
Generated on Tue Jun 5 2012 20:46:21 for Starshatter_Open by
1.8.1