aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CGUIInOutFader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CGUIInOutFader.cpp')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CGUIInOutFader.cpp358
1 files changed, 179 insertions, 179 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CGUIInOutFader.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CGUIInOutFader.cpp
index 3f63662..d4b5dc8 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CGUIInOutFader.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CGUIInOutFader.cpp
@@ -1,179 +1,179 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt 1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine". 2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h 3// For conditions of distribution and use, see copyright notice in irrlicht.h
4 4
5#include "CGUIInOutFader.h" 5#include "CGUIInOutFader.h"
6#ifdef _IRR_COMPILE_WITH_GUI_ 6#ifdef _IRR_COMPILE_WITH_GUI_
7 7
8#include "IGUIEnvironment.h" 8#include "IGUIEnvironment.h"
9#include "IVideoDriver.h" 9#include "IVideoDriver.h"
10#include "os.h" 10#include "os.h"
11 11
12namespace irr 12namespace irr
13{ 13{
14namespace gui 14namespace gui
15{ 15{
16 16
17 17
18//! constructor 18//! constructor
19CGUIInOutFader::CGUIInOutFader(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) 19CGUIInOutFader::CGUIInOutFader(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
20: IGUIInOutFader(environment, parent, id, rectangle) 20: IGUIInOutFader(environment, parent, id, rectangle)
21{ 21{
22 #ifdef _DEBUG 22 #ifdef _DEBUG
23 setDebugName("CGUIInOutFader"); 23 setDebugName("CGUIInOutFader");
24 #endif 24 #endif
25 25
26 Action = EFA_NOTHING; 26 Action = EFA_NOTHING;
27 StartTime = 0; 27 StartTime = 0;
28 EndTime = 0; 28 EndTime = 0;
29 29
30 setColor(video::SColor(0,0,0,0)); 30 setColor(video::SColor(0,0,0,0));
31} 31}
32 32
33 33
34//! draws the element and its children 34//! draws the element and its children
35void CGUIInOutFader::draw() 35void CGUIInOutFader::draw()
36{ 36{
37 if (!IsVisible || !Action) 37 if (!IsVisible || !Action)
38 return; 38 return;
39 39
40 u32 now = os::Timer::getTime(); 40 u32 now = os::Timer::getTime();
41 if (now > EndTime && Action == EFA_FADE_IN) 41 if (now > EndTime && Action == EFA_FADE_IN)
42 { 42 {
43 Action = EFA_NOTHING; 43 Action = EFA_NOTHING;
44 return; 44 return;
45 } 45 }
46 46
47 video::IVideoDriver* driver = Environment->getVideoDriver(); 47 video::IVideoDriver* driver = Environment->getVideoDriver();
48 48
49 if (driver) 49 if (driver)
50 { 50 {
51 f32 d; 51 f32 d;
52 52
53 if (now > EndTime) 53 if (now > EndTime)
54 d = 0.0f; 54 d = 0.0f;
55 else 55 else
56 d = (EndTime - now) / (f32)(EndTime - StartTime); 56 d = (EndTime - now) / (f32)(EndTime - StartTime);
57 57
58 video::SColor newCol = FullColor.getInterpolated(TransColor, d); 58 video::SColor newCol = FullColor.getInterpolated(TransColor, d);
59 driver->draw2DRectangle(newCol, AbsoluteRect, &AbsoluteClippingRect); 59 driver->draw2DRectangle(newCol, AbsoluteRect, &AbsoluteClippingRect);
60 } 60 }
61 61
62 IGUIElement::draw(); 62 IGUIElement::draw();
63} 63}
64 64
65 65
66//! Gets the color to fade out to or to fade in from. 66//! Gets the color to fade out to or to fade in from.
67video::SColor CGUIInOutFader::getColor() const 67video::SColor CGUIInOutFader::getColor() const
68{ 68{
69 return Color[1]; 69 return Color[1];
70} 70}
71 71
72 72
73//! Sets the color to fade out to or to fade in from. 73//! Sets the color to fade out to or to fade in from.
74void CGUIInOutFader::setColor(video::SColor color) 74void CGUIInOutFader::setColor(video::SColor color)
75{ 75{
76 video::SColor s = color; 76 video::SColor s = color;
77 video::SColor d = color; 77 video::SColor d = color;
78 78
79 s.setAlpha ( 255 ); 79 s.setAlpha ( 255 );
80 d.setAlpha ( 0 ); 80 d.setAlpha ( 0 );
81 setColor ( s,d ); 81 setColor ( s,d );
82 82
83/* 83/*
84 Color[0] = color; 84 Color[0] = color;
85 85
86 FullColor = Color[0]; 86 FullColor = Color[0];
87 TransColor = Color[0]; 87 TransColor = Color[0];
88 88
89 if (Action == EFA_FADE_OUT) 89 if (Action == EFA_FADE_OUT)
90 { 90 {
91 FullColor.setAlpha(0); 91 FullColor.setAlpha(0);
92 TransColor.setAlpha(255); 92 TransColor.setAlpha(255);
93 } 93 }
94 else 94 else
95 if (Action == EFA_FADE_IN) 95 if (Action == EFA_FADE_IN)
96 { 96 {
97 FullColor.setAlpha(255); 97 FullColor.setAlpha(255);
98 TransColor.setAlpha(0); 98 TransColor.setAlpha(0);
99 } 99 }
100*/ 100*/
101} 101}
102 102
103 103
104void CGUIInOutFader::setColor(video::SColor source, video::SColor dest) 104void CGUIInOutFader::setColor(video::SColor source, video::SColor dest)
105{ 105{
106 Color[0] = source; 106 Color[0] = source;
107 Color[1] = dest; 107 Color[1] = dest;
108 108
109 if (Action == EFA_FADE_OUT) 109 if (Action == EFA_FADE_OUT)
110 { 110 {
111 FullColor = Color[1]; 111 FullColor = Color[1];
112 TransColor = Color[0]; 112 TransColor = Color[0];
113 } 113 }
114 else 114 else
115 if (Action == EFA_FADE_IN) 115 if (Action == EFA_FADE_IN)
116 { 116 {
117 FullColor = Color[0]; 117 FullColor = Color[0];
118 TransColor = Color[1]; 118 TransColor = Color[1];
119 } 119 }
120 120
121} 121}
122 122
123 123
124//! Returns if the fade in or out process is done. 124//! Returns if the fade in or out process is done.
125bool CGUIInOutFader::isReady() const 125bool CGUIInOutFader::isReady() const
126{ 126{
127 u32 now = os::Timer::getTime(); 127 u32 now = os::Timer::getTime();
128 bool ret = (now > EndTime); 128 bool ret = (now > EndTime);
129 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; 129 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
130 return ret; 130 return ret;
131} 131}
132 132
133 133
134//! Starts the fade in process. 134//! Starts the fade in process.
135void CGUIInOutFader::fadeIn(u32 time) 135void CGUIInOutFader::fadeIn(u32 time)
136{ 136{
137 StartTime = os::Timer::getTime(); 137 StartTime = os::Timer::getTime();
138 EndTime = StartTime + time; 138 EndTime = StartTime + time;
139 Action = EFA_FADE_IN; 139 Action = EFA_FADE_IN;
140 setColor(Color[0],Color[1]); 140 setColor(Color[0],Color[1]);
141} 141}
142 142
143 143
144//! Starts the fade out process. 144//! Starts the fade out process.
145void CGUIInOutFader::fadeOut(u32 time) 145void CGUIInOutFader::fadeOut(u32 time)
146{ 146{
147 StartTime = os::Timer::getTime(); 147 StartTime = os::Timer::getTime();
148 EndTime = StartTime + time; 148 EndTime = StartTime + time;
149 Action = EFA_FADE_OUT; 149 Action = EFA_FADE_OUT;
150 setColor(Color[0],Color[1]); 150 setColor(Color[0],Color[1]);
151} 151}
152 152
153 153
154//! Writes attributes of the element. 154//! Writes attributes of the element.
155void CGUIInOutFader::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const 155void CGUIInOutFader::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
156{ 156{
157 IGUIInOutFader::serializeAttributes(out,options); 157 IGUIInOutFader::serializeAttributes(out,options);
158 158
159 out->addColor ("FullColor", FullColor); 159 out->addColor ("FullColor", FullColor);
160 out->addColor ("TransColor", TransColor); 160 out->addColor ("TransColor", TransColor);
161 161
162} 162}
163 163
164 164
165//! Reads attributes of the element 165//! Reads attributes of the element
166void CGUIInOutFader::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) 166void CGUIInOutFader::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
167{ 167{
168 IGUIInOutFader::deserializeAttributes(in,options); 168 IGUIInOutFader::deserializeAttributes(in,options);
169 169
170 FullColor = in->getAttributeAsColor("FullColor"); 170 FullColor = in->getAttributeAsColor("FullColor");
171 TransColor = in->getAttributeAsColor("TransColor"); 171 TransColor = in->getAttributeAsColor("TransColor");
172} 172}
173 173
174 174
175} // end namespace gui 175} // end namespace gui
176} // end namespace irr 176} // end namespace irr
177 177
178#endif // _IRR_COMPILE_WITH_GUI_ 178#endif // _IRR_COMPILE_WITH_GUI_
179 179