00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
#include <stdincl.h>
00024
00025
#include "forms/PlayerSelect.h"
00026
#include "MainWindow.h"
00027
#include "PlayerDialog.h"
00028
00029
using Form::PlayerSelect;
00030
00031
00032 PlayerDialog::PlayerDialog(Surface *s)
00033 :
FormSurface(s,220,100,200,200)
00034 ,y(5)
00035 {
00036 Uint32 bgcolor = SDL_MapRGBA(GetScreen() -> format,192,192,192,SDL_ALPHA_OPAQUE);
00037 Uint32 fgcolor = SDL_MapRGBA(GetScreen() -> format,255,192,64,SDL_ALPHA_OPAQUE);
00038
00039 SetText(
"PlayerDialog");
00040 CreateTemporaryScreen();
00041 SetMoveable(
true);
00042
00043
00044
00045 }
00046
00047
00048 PlayerDialog::~PlayerDialog()
00049 {
00050 surfacevector_t::iterator it;
00051
for (it = m_ChildList.begin(); it != m_ChildList.end(); it++)
00052 {
00053
delete *it;
00054 }
00055 }
00056
00057
00058 void PlayerDialog::OnEvent(surface_event_t *pstEvent)
00059 {
00060 PlayerSelect *pcf = dynamic_cast<PlayerSelect *>(
GetForm());
00061 Button *pcb = dynamic_cast<Button *>(pstEvent -> ptr);
00062
00063
if (pcf && pcb)
00064 {
00065 pcf -> SelectPlayer(pcb -> GetText());
00066 }
00067 OnClose();
00068 }
00069
00070
00071 void PlayerDialog::Draw()
00072 {
00073 SDL_Rect *area = GetClientRectPtr();
00074 Uint32 color = GetBgColor();
00075
00076 SDL_FillRect(m_screen, area, color);
00077 }
00078
00079
00080 void PlayerDialog::AddButton(
const string &str)
00081 {
00082 Button *pclButton;
00083
00084 pclButton =
new Button(
this, 5,
y, 190, 25);
00085 pclButton -> SetText(str);
00086 pclButton -> SetBgColor( 160, 160, 160 );
00087 pclButton -> SetMustBeDeleted(
true);
00088 AddChild(pclButton);
00089
y += 30;
00090 }
00091
00092
00093 void PlayerDialog::Clear()
00094 {
00095 surfacevector_t::iterator it;
00096 Surface *s;
00097
bool repeat =
true;
00098
00099
while (repeat)
00100 {
00101 repeat =
false;
00102
for (it = m_ChildList.begin(); it != m_ChildList.end(); it++)
00103 {
00104 s = *it;
00105
if (dynamic_cast<Button *>(s))
00106 {
00107 Remove(s);
00108 repeat =
true;
00109
break;
00110 }
00111 }
00112 }
00113
y = 5;
00114 }