merge the formfield patch from ooo-build
[ooovba.git] / goodies / source / inv / score.cxx
blob7823b983fffdaa9eedd381e890dcc1bd7f76489b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: score.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_goodies.hxx"
33 #include "score.hxx"
34 #include "strings.hrc"
35 #include "invader.hxx"
37 ScoreWindow::ScoreWindow(Window* Parent, WinBits wBits, ResMgr* pP) :
38 Window(Parent, wBits),
39 nHero(-1),
40 nRockets(5),
41 nLives(3),
42 nScore(0L),
43 pRes(pP),
44 bPaintBack(FALSE)
46 SetBackground(Wallpaper( Color( COL_GRAY ) ) );
49 ScoreWindow::~ScoreWindow()
53 void ScoreWindow::Paint(const Rectangle&)
55 Font aFont = GetFont();
56 aFont.SetColor(COL_WHITE);
57 aFont.SetFillColor(COL_GRAY);
58 SetFont(*&aFont);
60 SetFillColor(COL_GRAY);
62 if(bPaintBack)
64 Push( PUSH_LINECOLOR );
65 SetLineColor();
66 DrawRect(Rectangle(Point(0,0),GetOutputSizePixel()));
67 Pop();
70 if(nHero)
71 DrawText(Point(0,0),String(ResId(nHero, *pRes)));
73 DrawText(Point(180,0),String(ResId(STR_ROCKETS, *pRes)));
75 DrawText(Point(300,0),String(ResId(STR_FIGHTER, *pRes)));
76 DrawText(Point(370,0),String::CreateFromInt32(nLives));
78 DrawText(Point(400,0),String(ResId(STR_LEVEL, *pRes)));
79 DrawText(Point(460,0),String::CreateFromInt32(nLevel));
81 DrawText(Point(500,0),String(ResId(STR_SCORE, *pRes)));
82 String aString = String::CreateFromInt32(nScore);
83 if ( aString.Len() < 7 )
85 for ( xub_StrLen i = aString.Len(); i < 7; ++i )
86 aString.Insert( '0', 0 );
88 DrawText(Point(560,0),aString);
90 for(long i=0; i<5;i++)
92 if(nRockets > i)
94 SetLineColor(COL_GREEN);
95 SetFillColor(COL_GREEN);
97 else
99 SetLineColor(COL_RED);
100 SetFillColor(COL_RED);
103 DrawRect(Rectangle(Point(250+i*8,5),Point(256+i*8,12)));
105 SetBackground(Wallpaper( Color( COL_GRAY ) ) );
107 bPaintBack = FALSE;
110 void ScoreWindow::SetHero(long nName)
112 nHero = nName;
114 SetBackground();
115 Invalidate();
118 void ScoreWindow::SetRockets(long nWert)
120 nRockets = nWert;
122 SetBackground();
123 Invalidate();
126 void ScoreWindow::SetLives(long nWert)
128 nLives = nWert;
130 // SetBackground();
131 Invalidate();
134 void ScoreWindow::SetScore(long nWert)
136 nScore = nWert;
138 SetBackground();
139 Invalidate();
142 void ScoreWindow::SetLevel(long nWert)
144 nLevel = nWert;
146 // SetBackground();
147 Invalidate();
150 void ScoreWindow::ShowMe()
152 bPaintBack = TRUE;
154 Window::Show();