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 "OptionsDialog.h"
00027
#include "MainWindow.h"
00028
#include "MenuDialog.h"
00029
00030
00031 MenuDialog::MenuDialog(Surface *s)
00032 :Dialog(s, 160, 140, 320, 200)
00033 ,m_b1(this, 5, 5, 300, 25)
00034 ,m_b2(this, 5, 35, 300, 25)
00035 ,m_b3(this, 5, 65, 300, 25)
00036 ,m_b4(this, 5, 95, 300, 25)
00037 {
00038 Uint32 bgcolor = SDL_MapRGBA(GetScreen() -> format, 192, 192, 192, 128);
00039 Uint32 txtcolor = SDL_MapRGBA(GetScreen() -> format, 255, 192, 64, 255);
00040
00041 SetText(
"MenuDialog");
00042
00043
00044 SetTransparent(
true);
00045
00046
00047
00048
m_b1.SetText(
"Connect");
00049
m_b2.SetText(
"Options");
00050
m_b3.SetText(
"Exit");
00051
m_b3.SetUICommand(
UICOMMAND_QUIT);
00052
m_b4.SetText(
"Test");
00053 AddChild(&
m_b1);
00054 AddChild(&
m_b2);
00055 AddChild(&
m_b3);
00056 AddChild(&
m_b4);
00057 }
00058
00059
00060 MenuDialog::~MenuDialog()
00061 {
00062 }
00063
00064
00065 void MenuDialog::OnEvent(surface_event_t *pstEvent)
00066 {
00067
if (pstEvent -> type == GUI_EVENT_BUTTON)
00068 {
00069
if (pstEvent -> local_id ==
m_b1.GetLocalID())
00070 {
00071
00072
MainWindow *pcl = dynamic_cast<MainWindow *>(GetParent());
00073
if (pcl)
00074 {
00075 SetVisible(
false);
00076 InvalidateEv();
00077 pcl -> Connect();
00078 }
00079 }
00080
else
00081
if (pstEvent -> local_id ==
m_b2.GetLocalID())
00082 {
00083
00084
MainWindow *pcl = dynamic_cast<MainWindow *>(GetParent());
00085
if (pcl)
00086 {
00087 pcl -> ShowOptions();
00088 }
00089 }
00090
else
00091
00092
00093
00094
00095
00096
00097
00098
00099
if (pstEvent -> local_id ==
m_b4.GetLocalID())
00100 {
00101
pprintf(
"Test button pressed\n");
00102 }
00103 }
00104 }
00105
00106
00107 void MenuDialog::Connected(
const string &str)
00108 {
00109
m_b1.SetText(str);
00110 }