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 "client.h"
00026
#include "Globals.h"
00027
#include "OptionsDialog.h"
00028
00029
00030 OptionsDialog::OptionsDialog(Surface *s)
00031 :Dialog(s, 200, 200, 200, 200)
00032 ,m_st1 (this, 5, 5, 150, 25)
00033 ,m_host(this, 5, 35, 150, 25)
00034 ,m_st2 (this, 5, 65, 150, 25)
00035 ,m_port(this, 5, 95, 150, 25)
00036 ,m_ok (this, 5, 125, 90, 25)
00037 ,m_cancel(this,105,125, 90, 25)
00038 {
00039 Uint32 bgcolor = SDL_MapRGBA(GetScreen() -> format, 192, 192, 192, 255);
00040 Uint32 bgcolor2 = SDL_MapRGBA(GetScreen() -> format, 192, 192, 255, 255);
00041 Uint32 txtcolor = SDL_MapRGBA(GetScreen() -> format, 255, 192, 64, 255);
00042
00043 SetText(
"OptionsDialog");
00044 CreateTemporaryScreen();
00045
00046
00047
00048 SetMoveable(
true);
00049
00050
m_st1.SetText(
"Host");
00051
00052
m_st2.SetText(
"Port");
00053
00054
m_ok.SetText(
"OK");
00055
m_ok.SetAnchorDown(
true);
00056
00057
m_cancel.SetText(
"Cancel");
00058
m_cancel.SetAnchorDown(
true);
00059
m_cancel.SetAnchorRight(
true);
00060
00061
00062
UpdateData(
false);
00063
00064 AddChild(&
m_st1);
00065 AddChild(&
m_host);
00066 AddChild(&
m_st2);
00067 AddChild(&
m_port);
00068 AddChild(&
m_ok);
00069 AddChild(&
m_cancel);
00070 }
00071
00072
00073 OptionsDialog::~OptionsDialog()
00074 {
00075 }
00076
00077
00078 void OptionsDialog::OnEvent(surface_event_t *pstEvent)
00079 {
00080
if (pstEvent -> type == GUI_EVENT_BUTTON)
00081 {
00082
if (pstEvent -> local_id ==
m_ok.GetLocalID())
00083 {
00084
UpdateData();
00085 OnClose();
00086 }
00087
else
00088
if (pstEvent -> local_id ==
m_cancel.GetLocalID())
00089 {
00090 OnClose();
00091 }
00092 }
00093 }
00094
00095
00096 void OptionsDialog::Draw()
00097 {
00098 SDL_Rect *area = GetClientRectPtr();
00099 Uint32 color = GetBgColor();
00100
00101 SDL_FillRect(m_screen, area, color);
00102 }
00103
00104
00105 void OptionsDialog::UpdateData(
bool dlg2vars)
00106 {
00107
if (dlg2vars)
00108 {
00109 Globals::m_host =
m_host.GetLine();
00110 Globals::m_port = atoi(
m_port.GetLine());
00111 }
00112
else
00113 {
00114
char slask[200];
00115
m_host.SetLine(Globals::m_host.c_str());
00116 sprintf(slask,
"%d",Globals::m_port);
00117
m_port.SetLine(slask);
00118 }
00119 }
00120