summaryrefslogtreecommitdiffhomepage
path: root/Stars45/DisplayView.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Stars45/DisplayView.cpp')
-rw-r--r--Stars45/DisplayView.cpp272
1 files changed, 136 insertions, 136 deletions
diff --git a/Stars45/DisplayView.cpp b/Stars45/DisplayView.cpp
index 64088df..3387c1b 100644
--- a/Stars45/DisplayView.cpp
+++ b/Stars45/DisplayView.cpp
@@ -1,15 +1,15 @@
/* Project Starshatter 4.5
- Destroyer Studios LLC
- Copyright © 1997-2004. All Rights Reserved.
+ Destroyer Studios LLC
+ Copyright © 1997-2004. All Rights Reserved.
- SUBSYSTEM: Stars.exe
- FILE: DisplayView.cpp
- AUTHOR: John DiCamillo
+ SUBSYSTEM: Stars.exe
+ FILE: DisplayView.cpp
+ AUTHOR: John DiCamillo
- OVERVIEW
- ========
- View class for Quantum Destination HUD Overlay
+ OVERVIEW
+ ========
+ View class for Quantum Destination HUD Overlay
*/
#include "MemDebug.h"
@@ -40,19 +40,19 @@
class DisplayElement
{
public:
- static const char* TYPENAME() { return "DisplayElement"; }
-
- DisplayElement() : image(0), font(0), blend(0), hold(0), fade_in(0), fade_out(0) { }
-
- Text text;
- Bitmap* image;
- Font* font;
- Color color;
- Rect rect;
- int blend;
- double hold;
- double fade_in;
- double fade_out;
+ static const char* TYPENAME() { return "DisplayElement"; }
+
+ DisplayElement() : image(0), font(0), blend(0), hold(0), fade_in(0), fade_out(0) { }
+
+ Text text;
+ Bitmap* image;
+ Font* font;
+ Color color;
+ Rect rect;
+ int blend;
+ double hold;
+ double fade_in;
+ double fade_out;
};
// +====================================================================+
@@ -60,38 +60,38 @@ public:
DisplayView* display_view = 0;
DisplayView::DisplayView(Window* c)
- : View(c), width(0), height(0), xcenter(0), ycenter(0)
+: View(c), width(0), height(0), xcenter(0), ycenter(0)
{
- display_view = this;
- DisplayView::OnWindowMove();
+ display_view = this;
+ DisplayView::OnWindowMove();
}
DisplayView::~DisplayView()
{
- if (display_view == this)
- display_view = 0;
+ if (display_view == this)
+ display_view = 0;
- elements.destroy();
+ elements.destroy();
}
DisplayView*
DisplayView::GetInstance()
{
- if (display_view == 0)
- display_view = new DisplayView(0);
+ if (display_view == 0)
+ display_view = new DisplayView(0);
- return display_view;
+ return display_view;
}
void
DisplayView::OnWindowMove()
{
- if (window) {
- width = window->Width();
- height = window->Height();
- xcenter = (width / 2.0) - 0.5;
- ycenter = (height / 2.0) + 0.5;
- }
+ if (window) {
+ width = window->Width();
+ height = window->Height();
+ xcenter = (width / 2.0) - 0.5;
+ ycenter = (height / 2.0) + 0.5;
+ }
}
// +--------------------------------------------------------------------+
@@ -99,58 +99,58 @@ DisplayView::OnWindowMove()
void
DisplayView::Refresh()
{
- ListIter<DisplayElement> iter = elements;
- while (++iter) {
- DisplayElement* elem = iter.value();
-
- // convert relative rect to window rect:
- Rect elem_rect = elem->rect;
- if (elem_rect.x == 0 && elem_rect.y == 0 && elem_rect.w == 0 && elem_rect.h == 0) {
- // stretch to fit
- elem_rect.w = width;
- elem_rect.h = height;
- }
- else if (elem_rect.w < 0 && elem_rect.h < 0) {
- // center image in window
- elem_rect.w *= -1;
- elem_rect.h *= -1;
-
- elem_rect.x = (width - elem_rect.w)/2;
- elem_rect.y = (height - elem_rect.h)/2;
- }
- else {
- // offset from right or bottom
- if (elem_rect.x < 0) elem_rect.x += width;
- if (elem_rect.y < 0) elem_rect.y += height;
- }
-
- // compute current fade,
- // assumes fades are 1 second or less:
- double fade = 0;
- if (elem->fade_in > 0) fade = 1 - elem->fade_in;
- else if (elem->hold > 0) fade = 1;
- else if (elem->fade_out > 0) fade = elem->fade_out;
-
- // draw text:
- if (elem->text.length() && elem->font) {
- elem->font->SetColor(elem->color);
- elem->font->SetAlpha(fade);
- window->SetFont(elem->font);
- window->DrawText(elem->text, elem->text.length(), elem_rect, DT_WORDBREAK);
- }
-
- // draw image:
- else if (elem->image) {
- window->FadeBitmap( elem_rect.x,
- elem_rect.y,
- elem_rect.x + elem_rect.w,
- elem_rect.y + elem_rect.h,
- elem->image,
- elem->color * fade,
- elem->blend );
-
- }
- }
+ ListIter<DisplayElement> iter = elements;
+ while (++iter) {
+ DisplayElement* elem = iter.value();
+
+ // convert relative rect to window rect:
+ Rect elem_rect = elem->rect;
+ if (elem_rect.x == 0 && elem_rect.y == 0 && elem_rect.w == 0 && elem_rect.h == 0) {
+ // stretch to fit
+ elem_rect.w = width;
+ elem_rect.h = height;
+ }
+ else if (elem_rect.w < 0 && elem_rect.h < 0) {
+ // center image in window
+ elem_rect.w *= -1;
+ elem_rect.h *= -1;
+
+ elem_rect.x = (width - elem_rect.w)/2;
+ elem_rect.y = (height - elem_rect.h)/2;
+ }
+ else {
+ // offset from right or bottom
+ if (elem_rect.x < 0) elem_rect.x += width;
+ if (elem_rect.y < 0) elem_rect.y += height;
+ }
+
+ // compute current fade,
+ // assumes fades are 1 second or less:
+ double fade = 0;
+ if (elem->fade_in > 0) fade = 1 - elem->fade_in;
+ else if (elem->hold > 0) fade = 1;
+ else if (elem->fade_out > 0) fade = elem->fade_out;
+
+ // draw text:
+ if (elem->text.length() && elem->font) {
+ elem->font->SetColor(elem->color);
+ elem->font->SetAlpha(fade);
+ window->SetFont(elem->font);
+ window->DrawText(elem->text, elem->text.length(), elem_rect, DT_WORDBREAK);
+ }
+
+ // draw image:
+ else if (elem->image) {
+ window->FadeBitmap( elem_rect.x,
+ elem_rect.y,
+ elem_rect.x + elem_rect.w,
+ elem_rect.y + elem_rect.h,
+ elem->image,
+ elem->color * fade,
+ elem->blend );
+
+ }
+ }
}
// +--------------------------------------------------------------------+
@@ -158,24 +158,24 @@ DisplayView::Refresh()
void
DisplayView::ExecFrame()
{
- double seconds = Game::GUITime();
+ double seconds = Game::GUITime();
- ListIter<DisplayElement> iter = elements;
- while (++iter) {
- DisplayElement* elem = iter.value();
+ ListIter<DisplayElement> iter = elements;
+ while (++iter) {
+ DisplayElement* elem = iter.value();
- if (elem->fade_in > 0)
- elem->fade_in -= seconds;
+ if (elem->fade_in > 0)
+ elem->fade_in -= seconds;
- else if (elem->hold > 0)
- elem->hold -= seconds;
+ else if (elem->hold > 0)
+ elem->hold -= seconds;
- else if (elem->fade_out > 0)
- elem->fade_out -= seconds;
+ else if (elem->fade_out > 0)
+ elem->fade_out -= seconds;
- else
- delete iter.removeItem();
- }
+ else
+ delete iter.removeItem();
+ }
}
// +--------------------------------------------------------------------+
@@ -183,57 +183,57 @@ DisplayView::ExecFrame()
void
DisplayView::ClearDisplay()
{
- elements.destroy();
+ elements.destroy();
}
// +--------------------------------------------------------------------+
void
DisplayView::AddText( const char* text,
- Font* font,
- Color color,
- const Rect& rect,
- double hold,
- double fade_in,
- double fade_out)
+Font* font,
+Color color,
+const Rect& rect,
+double hold,
+double fade_in,
+double fade_out)
{
- DisplayElement* elem = new(__FILE__,__LINE__) DisplayElement;
+ DisplayElement* elem = new(__FILE__,__LINE__) DisplayElement;
- if (fade_in == 0 && fade_out == 0 && hold == 0)
- hold = 300;
+ if (fade_in == 0 && fade_out == 0 && hold == 0)
+ hold = 300;
- elem->text = text;
- elem->font = font;
- elem->color = color;
- elem->rect = rect;
- elem->hold = hold;
- elem->fade_in = fade_in;
- elem->fade_out = fade_out;
+ elem->text = text;
+ elem->font = font;
+ elem->color = color;
+ elem->rect = rect;
+ elem->hold = hold;
+ elem->fade_in = fade_in;
+ elem->fade_out = fade_out;
- elements.append(elem);
+ elements.append(elem);
}
void
DisplayView::AddImage(Bitmap* bmp,
- Color color,
- int blend,
- const Rect& rect,
- double hold,
- double fade_in,
- double fade_out)
+Color color,
+int blend,
+const Rect& rect,
+double hold,
+double fade_in,
+double fade_out)
{
- DisplayElement* elem = new(__FILE__,__LINE__) DisplayElement;
+ DisplayElement* elem = new(__FILE__,__LINE__) DisplayElement;
- if (fade_in == 0 && fade_out == 0 && hold == 0)
- hold = 300;
+ if (fade_in == 0 && fade_out == 0 && hold == 0)
+ hold = 300;
- elem->image = bmp;
- elem->rect = rect;
- elem->color = color;
- elem->blend = blend;
- elem->hold = hold;
- elem->fade_in = fade_in;
- elem->fade_out = fade_out;
+ elem->image = bmp;
+ elem->rect = rect;
+ elem->color = color;
+ elem->blend = blend;
+ elem->hold = hold;
+ elem->fade_in = fade_in;
+ elem->fade_out = fade_out;
- elements.append(elem);
+ elements.append(elem);
}