Google
Web alhem.net
Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

MainWindow Class Reference

#include <MainWindow.h>

Collaboration diagram for MainWindow:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MainWindow (SDLControl *)
 ~MainWindow ()
void Draw ()
void AddLine (const string &)
void ShowMenu ()
void ShowOptions ()
void ShowLogin (Form::Form *)
void ShowPlayers (Form::Form *, vector< string > &)
void ShowText ()
void OnEvent (surface_event_t *)
void OnMouseMove (coord_t, coord_t, coord_t, coord_t)
void OnRightClick (coord_t, coord_t)
void Connect ()
void Disconnect ()
Surface * GetInput ()
void SetAngles (double, double)
void IncreaseBase ()
void DecreaseBase ()
void Redraw ()

Static Public Attributes

Grid m_grid

Private Member Functions

int Get_h (long, long)
int Get_t_left (long, long)
int Get_t_up (long, long)

Private Attributes

TTFont courier8
Edit m_guiInput
MenuDialogm_pclMenuDialog
OptionsDialogm_pclOptionsDialog
LoginDialogm_pclLoginDialog
PlayerDialogm_pclPlayerDialog
TextDialogm_pclTextDialog
ConnectThreadm_pclConnectThread
TestMenum_pclTestMenu
DotMenum_dotMenu
double m_test_v
double m_test_v_vertikal
mapdots_t m_dots
MAPDOTm_dot
DotCursor m_dc

Constructor & Destructor Documentation

MainWindow::MainWindow SDLControl *   ) 
 

Definition at line 66 of file MainWindow.cpp.

References courier8, m_dc, m_grid, m_guiInput, MainWindow(), Grid::SetBase(), Grid::SetSize(), and WARP.

Referenced by MainWindow().

00067 :gui::Surface(pclControl, 0 + WARP, 0 + WARP, pclControl -> GetScreen() -> w - WARP * 2, pclControl -> GetScreen() -> h - WARP * 2) 00068 // colors 00069 // fonts 00070 #ifdef WIN32 00071 ,courier8("font.ttf", 15) 00072 #else 00073 ,courier8("../gui/fonts/font.ttf", 15) //TIMES.TTF", 12) 00074 #endif 00075 // children 00076 ,m_guiInput(this, 0, 455, 640, 25) 00077 // bmp 00078 #ifdef USE_IMAGE 00079 ,m_image(SDL_LoadBMP("screenshots_big_7.bmp")) 00080 ,m_image_x(0) 00081 ,m_image_y(0) 00082 #endif 00083 ,m_pclMenuDialog(NULL) 00084 ,m_pclOptionsDialog(NULL) 00085 ,m_pclLoginDialog(NULL) 00086 ,m_pclPlayerDialog(NULL) 00087 ,m_pclTextDialog(NULL) 00088 ,m_pclConnectThread(NULL) 00089 ,m_pclTestMenu(NULL) 00090 ,m_dotMenu(NULL) 00091 ,m_test_v(90) 00092 ,m_test_v_vertikal(90) 00093 ,m_dot(NULL) 00094 ,m_dc(this,0,0) 00095 { 00096 // Grid calculation 00097 m_grid.SetSize(pclControl -> GetScreen() -> w,pclControl -> GetScreen() -> h); 00098 m_grid.SetBase( 50 ); 00099 00100 // Update palette if 8bpp 00101 // DEB(printf("Update8bitPalette()\n");) 00102 // pclControl -> Update8bitPalette(); 00103 00104 // Surface name 00105 SetText("Main Window"); 00106 00107 // Surface defaults 00108 SetBgColor(DEFAULT_BG_R,DEFAULT_BG_G,DEFAULT_BG_B); 00109 SetFgColor(DEFAULT_FG_R,DEFAULT_FG_G,DEFAULT_FG_B); 00110 SetTTFont(&courier8); 00111 SetFrameWidth(0); 00112 SetFrameColor(DEFAULT_BG_R,DEFAULT_BG_G,DEFAULT_BG_B); 00113 00114 // init children 00115 // 00116 m_guiInput.SetBgColor( 255,255,255,0 ); 00117 m_guiInput.SetFgColor( 0,0,0 ); 00118 m_guiInput.SetFrameWidth(0); 00119 00120 m_dc.SetVisible(false); 00121 00122 // Add children to surface 00123 AddChild(&m_guiInput); 00124 AddChild(&m_dc); 00125 00126 // 8-bit palett till alla ytor 00127 // DEB(printf("8-bit palett till alla ytor\n");) 00128 // Update8bitPalette(); 00129 00130 // Alpha 00131 SetAlpha(255); 00132 SetAlpha(SDL_ALPHA_OPAQUE, false); 00133 #ifdef USE_IMAGE 00134 SDL_SetAlpha(m_image, SDL_RLEACCEL, SDL_ALPHA_OPAQUE); 00135 #endif 00136 }

MainWindow::~MainWindow  ) 
 

Definition at line 139 of file MainWindow.cpp.

References m_dotMenu, m_dots, m_pclConnectThread, m_pclLoginDialog, m_pclMenuDialog, m_pclOptionsDialog, m_pclTestMenu, and m_pclTextDialog.

00140 { 00141 if (m_pclMenuDialog) 00142 { 00143 delete m_pclMenuDialog; 00144 } 00145 if (m_pclOptionsDialog) 00146 { 00147 delete m_pclOptionsDialog; 00148 } 00149 if (m_pclLoginDialog) 00150 { 00151 delete m_pclLoginDialog; 00152 } 00153 if (m_pclTextDialog) 00154 { 00155 delete m_pclTextDialog; 00156 } 00157 if (m_pclConnectThread) 00158 { 00159 delete m_pclConnectThread; 00160 } 00161 if (m_pclTestMenu) 00162 { 00163 delete m_pclTestMenu; 00164 } 00165 if (m_dotMenu) 00166 { 00167 delete m_dotMenu; 00168 } 00169 while (m_dots.size() > 0) 00170 { 00171 mapdots_t::iterator it = m_dots.begin(); 00172 MAPDOT *x = *it; 00173 m_dots.erase(it); 00174 delete x; 00175 } 00176 }


Member Function Documentation

void MainWindow::AddLine const string &   ) 
 

Definition at line 179 of file MainWindow.cpp.

References AddLine(), and m_pclTextDialog.

Referenced by AddLine().

00180 { 00181 if (m_pclTextDialog) 00182 { 00183 m_pclTextDialog -> AddLine(str); 00184 } 00185 }

void MainWindow::Connect  ) 
 

Definition at line 530 of file MainWindow.cpp.

References Disconnect(), m_pclConnectThread, and pprintf().

00531 { 00532 if (m_pclConnectThread) 00533 { 00534 printf("Already connected - disconnecting...\n"); 00535 Disconnect(); 00536 return; 00537 } 00538 if (!m_pclConnectThread) 00539 { 00540 printf("Creating connect thread\n"); 00541 m_pclConnectThread = new ConnectThread( (char *)Globals::m_host.c_str(), Globals::m_port); 00542 } 00543 else 00544 { 00545 pprintf("Already connected.\n"); 00546 } 00547 }

void MainWindow::DecreaseBase  ) 
 

Definition at line 597 of file MainWindow.cpp.

References Grid::GetBase(), m_grid, and Grid::SetBase().

00598 { 00599 int b = m_grid.GetBase(); 00600 00601 b--; 00602 if (b > 0) 00603 { 00604 m_grid.SetBase(b); 00605 } 00606 00607 // Draw(); 00608 // Invalidate(); 00609 SetDirty(true); 00610 }

void MainWindow::Disconnect  ) 
 

Definition at line 550 of file MainWindow.cpp.

References m_pclConnectThread, and pprintf().

Referenced by Connect().

00551 { 00552 if (m_pclConnectThread) 00553 { 00554 printf("Deleteing connect thread\n"); 00555 m_pclConnectThread -> SetRunning(false); 00556 SDL_Delay(1000); 00557 delete m_pclConnectThread; 00558 m_pclConnectThread = NULL; 00559 } 00560 else 00561 { 00562 pprintf("Not connected.\n"); 00563 } 00564 }

void MainWindow::Draw  ) 
 

Definition at line 639 of file MainWindow.cpp.

References CHUNKSIZE, GAP, Get_h(), Grid::GetBase(), Grid::GetHBase(), Grid::GetHeight(), Grid::GetWidth(), Grid::GetXY(), GLOW, m_dc, m_dot, m_dots, m_grid, m_pclConnectThread, m_test_v, m_test_v_vertikal, and Grid::Sin().

00640 { 00641 #pragma warning("remember to reset m_self when disconnected from server") 00642 #pragma warning("and player cache") 00643 #pragma warning("and map cache") 00644 #pragma warning("etc etc cache") 00645 Player *self = NULL; 00646 00647 printf("MainWindow::Draw()\n"); 00648 if (!m_pclConnectThread || (self = m_pclConnectThread -> GetSelf()) == NULL) 00649 { 00650 printf("Not drawing background, because..\n"); 00651 if (!m_pclConnectThread) 00652 { 00653 printf(" * not connected\n"); 00654 } 00655 else 00656 if (!self) 00657 { 00658 printf(" * self is NULL\n"); 00659 } 00660 SDL_FillRect(GetScreen(), GetClientRectPtr(), SDL_MapRGB(GetScreen() -> format, 224, 224, 192)); 00661 return; 00662 } 00663 else 00664 { 00665 printf("Drawing background!\n"); 00666 } 00667 00668 long xpos = self -> GetX(); 00669 long ypos = self -> GetY(); 00670 #define CHUNKSIZE MAPSIZE 00671 long chunkx = xpos / CHUNKSIZE; 00672 long chunky = ypos / CHUNKSIZE; 00673 for (long x = chunkx - 1; x <= chunkx + 1; x++) 00674 { 00675 long cx = x * CHUNKSIZE; 00676 for (long y = chunky - 1; y <= chunky + 1; y++) 00677 { 00678 long cy = y * CHUNKSIZE; 00679 Map *map = m_pclConnectThread -> GetMap(cx, cy); 00680 printf(" . map @ [%ld,%ld] is %s\n",cx,cy,map ? "ok" : "NULL"); 00681 if (!map) 00682 { 00683 // send request for version 0 always if not in cache 00684 Command::Map cmd(cx,cy,0); 00685 m_pclConnectThread -> BufMessage(&cmd); 00686 //#pragma warning("add an empty map section (chunk) for [cx,cy] in map cache to avoid") 00687 //#pragma warning("multiple requests for same section") 00688 printf("adding empty section\n"); 00689 fflush(stdout); 00690 m_pclConnectThread -> AddMap(cx, cy); 00691 #pragma warning("how to re-request this section if we don't get it?") 00692 } 00693 else 00694 { 00695 // bra bra, vi har den redan - kanske.. 00696 } 00697 } 00698 } 00699 00700 printf(" * done requesting map parts\n"); 00701 00702 { 00703 #ifdef WIREFRAME 00704 Uint32 color = GetFgColor(); 00705 #endif 00706 Uint32 light; 00707 int w = m_grid.GetWidth() / 2 + 2; 00708 int h = m_grid.GetHeight() / 2 + 2; 00709 double base = m_grid.GetBase(); // triangel sida horisontell 00710 double hbase = m_grid.GetHBase(); // triangel höjd 00711 int xpos1; 00712 int ypos1; 00713 int xpos2; 00714 int ypos2; 00715 int xpos3; 00716 int ypos3; 00717 int xpos4; 00718 int ypos4; 00719 int h1; 00720 int h2; 00721 int h3; 00722 int h4; 00723 double dh1,dh2,dh3,dh4; 00724 double hmitt; 00725 // horisontell infallsvinkel 00726 // double test_r = 2 * M_PI * m_test_v / 360; 00727 double r; 00728 double v; 00729 double aa; 00730 // vertikal infallsvinkel 00731 // double test_r_vertikal = 2 * M_PI * m_test_v_vertikal / 360; 00732 double r_vertikal; 00733 double v_vertikal; 00734 double aa_vertikal; 00735 // 00736 double aa2; 00737 double aa2_vertikal; 00738 00739 if (SDL_MUSTLOCK(m_screen)) 00740 { 00741 SDL_LockSurface(m_screen); 00742 } 00743 00744 SDL_FillRect(m_screen, GetClientRectPtr(), GetBgColor()); 00745 00746 00747 // 0,0 1,0 2,0 3,0 00748 // 0,1 1,1 2,1 3,1 00749 // 0,2 1,2 2,2 3,2 00750 // 0,3 1,3 2,3 3,3 00751 00752 while (m_dots.size() > 0) 00753 { 00754 mapdots_t::iterator it = m_dots.begin(); 00755 MAPDOT *x = *it; 00756 m_dots.erase(it); 00757 delete x; 00758 } 00759 m_dot = NULL; 00760 m_dc.SetVisible(false); 00761 m_dc.InvalidateEv(); 00762 00763 for (int y = -h; y <= h; y++) 00764 { 00765 long cy = ypos + y; 00766 00767 for (int x = -w; x <= w; x++) 00768 { 00769 long cx = xpos + x; 00770 00771 m_grid.GetXY(x,y,&xpos1,&ypos1,&h1); 00772 h1 = Get_h(cx,cy); 00773 ypos1 += h1; 00774 dh1 = h1; 00775 { 00776 MAPDOT *dot = new MAPDOT; 00777 dot -> x = xpos1; 00778 dot -> y = ypos1; 00779 dot -> cx = cx; 00780 dot -> cy = cy; 00781 m_dots.insert(m_dots.end(), dot); 00782 } 00783 00784 if (y % 2) 00785 { 00786 m_grid.GetXY(x,y - 1,&xpos2,&ypos2,&h2); 00787 h2 = Get_h(cx,cy - 1); 00788 } 00789 else 00790 { 00791 m_grid.GetXY(x - 1,y - 1,&xpos2,&ypos2,&h2); 00792 h2 = Get_h(cx - 1,cy - 1); 00793 } 00794 ypos2 += h2; 00795 dh2 = h2; 00796 00798 // vänster triangel - sittande 00799 // 2 00800 // 3 1 00801 if (y % 2) // xpos ett halvt steg till höger 00802 { 00803 m_grid.GetXY(x - 1,y,&xpos3,&ypos3,&h3); 00804 h3 = Get_h(cx - 1,cy); 00805 } 00806 else 00807 { 00808 m_grid.GetXY(x - 1,y,&xpos3,&ypos3,&h3); 00809 h3 = Get_h(cx - 1,cy); 00810 } 00811 ypos3 += h3; 00812 dh3 = h3; 00813 00814 // beräkna horisontell triangelvinkel 00815 if (h3 > h1) // vadd+ 00816 { 00817 r = atan((dh3 - dh1) / base); 00818 v = 360 * r / (2 * M_PI); 00819 } 00820 else 00821 if (h3 < h1) // vadd- 00822 { 00823 r = -atan((dh1 - dh3) / base); 00824 v = 360 * r / (2 * M_PI); 00825 } 00826 else 00827 { 00828 r = 0; 00829 v = 0; 00830 } 00831 // beräkna vertikal triangelvinkel 00832 hmitt = (dh2 + dh3) / 2; 00833 if (hmitt > h2) 00834 { 00835 r_vertikal = atan((hmitt - dh2) / hbase); 00836 v_vertikal = 360 * r_vertikal / (2 * M_PI); 00837 } 00838 else 00839 if (hmitt < h2) 00840 { 00841 r_vertikal = -atan((dh2 - hmitt) / hbase); 00842 v_vertikal = 360 * r_vertikal / (2 * M_PI); 00843 } 00844 else 00845 { 00846 r_vertikal = 0; 00847 v_vertikal = 0; 00848 } 00849 // beräkna infallsvinklar 00850 aa = m_grid.Sin(m_test_v + v); 00851 aa2 = m_grid.Sin(90 + v_vertikal); 00852 aa_vertikal = m_grid.Sin(m_test_v_vertikal + v_vertikal); 00853 aa2_vertikal = m_grid.Sin(90 + v); 00854 // night glow 00855 if (aa < GLOW) 00856 { 00857 aa = GLOW; 00858 } 00859 if (aa_vertikal < GLOW) 00860 { 00861 aa_vertikal = GLOW; 00862 } 00863 light = SDL_MapRGB(m_screen -> format, 00864 0, 00865 (int)(255 * aa * aa2 * aa_vertikal * aa2_vertikal), 00866 0); 00867 00868 #ifdef WIREFRAME 00869 SDL_drawLine(m_screen, xpos1, ypos1, xpos2, ypos2, color); 00870 SDL_drawLine(m_screen, xpos1, ypos1, xpos3, ypos3, color); 00871 SDL_drawLine(m_screen, xpos2, ypos2, xpos3, ypos3, color); 00872 #else 00873 SDL_fillTriangle(m_screen, xpos1-GAP, ypos1-GAP, xpos2, ypos2+GAP, xpos3+GAP, ypos3-GAP, light); 00874 #endif 00875 00877 // höger triangel - stående 00878 // 2 4 00879 // 1 00880 if (y % 2) // xpos ett halvt steg till höger 00881 { 00882 m_grid.GetXY(x + 1,y - 1,&xpos4,&ypos4,&h4); 00883 h4 = Get_h(cx + 1,cy - 1); 00884 } 00885 else 00886 { 00887 m_grid.GetXY(x,y - 1,&xpos4,&ypos4,&h4); 00888 h4 = Get_h(cx, cy - 1); 00889 } 00890 ypos4 += h4; 00891 dh4 = h4; 00892 00893 // beräkna horisontell triangelvinkel 00894 if (h2 > h4) // vadd+ 00895 { 00896 r = atan((dh2 - dh4) / base); 00897 v = 360 * r / (2 * M_PI); 00898 } 00899 else 00900 if (h2 < h4) // vadd- 00901 { 00902 r = -atan((dh4 - dh2) / base); 00903 v = 360 * r / (2 * M_PI); 00904 } 00905 else 00906 { 00907 r = 0; 00908 v = 0; 00909 } 00910 // beräkna vertikal triangelvinkel 00911 hmitt = (dh2 + dh4) / 2; 00912 if (hmitt > h1) 00913 { 00914 r_vertikal = -atan((hmitt - dh1) / hbase); 00915 v_vertikal = 360 * r_vertikal / (2 * M_PI); 00916 } 00917 else 00918 if (hmitt < h1) 00919 { 00920 r_vertikal = atan((dh1 - hmitt) / hbase); 00921 v_vertikal = 360 * r_vertikal / (2 * M_PI); 00922 } 00923 else 00924 { 00925 r_vertikal = 0; 00926 v_vertikal = 0; 00927 } 00928 // beräkna infallsvinklar 00929 aa = m_grid.Sin(m_test_v + v); 00930 aa2 = m_grid.Sin(90 + v_vertikal); 00931 aa_vertikal = m_grid.Sin(m_test_v_vertikal + v_vertikal); 00932 aa2_vertikal = m_grid.Sin(90 + v); 00933 // night glow 00934 if (aa < GLOW) 00935 { 00936 aa = GLOW; 00937 } 00938 if (aa_vertikal < GLOW) 00939 { 00940 aa_vertikal = GLOW; 00941 } 00942 light = SDL_MapRGB(m_screen -> format, 00943 0, 00944 (int)(255 * aa * aa2 * aa_vertikal * aa2_vertikal), 00945 0); 00946 #ifdef WIREFRAME 00947 SDL_drawLine(m_screen, xpos1, ypos1, xpos2, ypos2, color); 00948 SDL_drawLine(m_screen, xpos1, ypos1, xpos4, ypos4, color); 00949 SDL_drawLine(m_screen, xpos2, ypos2, xpos4, ypos4, color); 00950 #else 00951 SDL_fillTriangle(m_screen, xpos1, ypos1-GAP, xpos2+GAP, ypos2+GAP, xpos4-GAP, ypos4+GAP, light); 00952 #endif 00953 00954 } // for (x...) 00955 } // for (y...) 00956 for (mapdots_t::iterator it = m_dots.begin(); it != m_dots.end(); it++) 00957 { 00958 MAPDOT *dot = *it; 00959 // En liten cirkel vid varje punkt 00960 //#define WIREFRAME 00961 #ifdef WIREFRAME 00962 SDL_fillCircle(m_screen, dot -> x, dot -> y, 2, SDL_MapRGB(m_screen -> format, 255, 255, 255)); 00963 #endif 00964 } 00965 if (SDL_MUSTLOCK(m_screen)) 00966 { 00967 SDL_UnlockSurface(m_screen); 00968 } 00969 } 00970 }

int MainWindow::Get_h long  ,
long 
[private]
 

Definition at line 973 of file MainWindow.cpp.

References Get_h(), and m_pclConnectThread.

Referenced by Draw(), and Get_h().

00974 { 00975 Map *map = m_pclConnectThread -> GetMap(x,y); 00976 return map ? map -> Get_h(x,y) : 0; 00977 }

int MainWindow::Get_t_left long  ,
long 
[private]
 

Definition at line 980 of file MainWindow.cpp.

References Get_t_left(), and m_pclConnectThread.

Referenced by Get_t_left().

00981 { 00982 Map *map = m_pclConnectThread -> GetMap(x,y); 00983 return map -> Get_t_left(x,y); 00984 }

int MainWindow::Get_t_up long  ,
long 
[private]
 

Definition at line 987 of file MainWindow.cpp.

References Get_t_up(), and m_pclConnectThread.

Referenced by Get_t_up().

00988 { 00989 Map *map = m_pclConnectThread -> GetMap(x,y); 00990 return map -> Get_t_up(x,y); 00991 }

Surface * MainWindow::GetInput  ) 
 

Definition at line 567 of file MainWindow.cpp.

References m_guiInput.

00568 { 00569 return &m_guiInput; 00570 }

void MainWindow::IncreaseBase  ) 
 

Definition at line 584 of file MainWindow.cpp.

References Grid::GetBase(), m_grid, and Grid::SetBase().

00585 { 00586 int b = m_grid.GetBase(); 00587 00588 b++; 00589 m_grid.SetBase(b); 00590 00591 // Draw(); 00592 // Invalidate(); 00593 SetDirty(true); 00594 }

void MainWindow::OnEvent surface_event_t *   ) 
 

Definition at line 316 of file MainWindow.cpp.

References DEB, m_guiInput, m_pclConnectThread, m_pclLoginDialog, m_pclPlayerDialog, and OnEvent().

Referenced by OnEvent().

00317 { 00318 if (pstEvent -> type == GUI_EVENT_CLOSE) 00319 { 00320 /* 00321 if (m_pclMenuDialog && pstEvent -> id == m_pclMenuDialog -> GetID()) 00322 { 00323 m_pclMenuDialog -> SetVisible(false); 00324 m_pclMenuDialog -> InvalidateEv(); 00325 } 00326 else 00327 if (m_pclOptionsDialog && pstEvent -> id == m_pclOptionsDialog -> GetID()) 00328 { 00329 m_pclOptionsDialog -> SetVisible(false); 00330 m_pclOptionsDialog -> InvalidateEv(); 00331 } 00332 else 00333 */ 00334 if (m_pclLoginDialog && pstEvent -> id == m_pclLoginDialog -> GetID()) 00335 { 00336 Form::Form *pclForm = m_pclLoginDialog -> GetForm(); 00337 if (pclForm) 00338 { 00339 if (dynamic_cast<Form::Login *>(pclForm)) 00340 { 00341 DEB( printf("SEND_LOGIN: pclForm is a Login\n");) 00342 } 00343 else 00344 { 00345 DEB( printf("SEND_LOGIN: pclForm is NOT a Login\n");) 00346 } 00347 } 00348 else 00349 { 00350 DEB( printf("SEND_LOGIN: pclForm is NULL\n");) 00351 } 00352 if (m_pclConnectThread) 00353 { 00354 DEB( printf("SEND_LOGIN: BufMessage()\n");) 00355 m_pclConnectThread -> BufMessage(pclForm); 00356 } 00357 else 00358 { 00359 DEB( printf("SEND_LOGIN: m_pclConnectThread is NULL\n");) 00360 } 00361 m_pclLoginDialog -> SetVisible(false); 00362 m_pclLoginDialog -> InvalidateEv(); 00363 } 00364 else 00365 if (m_pclPlayerDialog && pstEvent -> id == m_pclPlayerDialog -> GetID()) 00366 { 00367 if (m_pclConnectThread) 00368 { 00369 Form::Form *pclForm = m_pclPlayerDialog -> GetForm(); 00370 m_pclConnectThread -> BufMessage(pclForm); 00371 } 00372 m_pclPlayerDialog -> SetVisible(false); 00373 m_pclPlayerDialog -> InvalidateEv(); 00374 } 00375 else 00376 /* 00377 if (m_pclTextDialog && pstEvent -> id == m_pclTextDialog -> GetID()) 00378 { 00379 m_pclTextDialog -> SetVisible(false); 00380 m_pclTextDialog -> InvalidateEv(); 00381 } 00382 else 00383 if (m_pclTestMenu && pstEvent -> id == m_pclTestMenu -> GetID()) 00384 { 00385 m_pclTestMenu -> SetVisible(false); 00386 m_pclTestMenu -> InvalidateEv(); 00387 } 00388 else 00389 */ 00390 { 00391 // Auto... 00392 for (surfacevector_t::iterator it = m_ChildList.begin(); it != m_ChildList.end(); it++) 00393 { 00394 if (pstEvent -> id == (*it) -> GetID()) 00395 { 00396 (*it) -> SetVisible(false); 00397 (*it) -> InvalidateEv(); 00398 } 00399 } 00400 } 00401 } 00402 else 00403 if (pstEvent -> type == GUI_EVENT_EDIT) 00404 { 00405 if (pstEvent -> id == m_guiInput.GetID()) 00406 { 00407 if (m_pclConnectThread) 00408 { 00409 Command::Say cmd(m_guiInput.GetLine()); 00410 m_pclConnectThread -> BufMessage(&cmd); 00411 } 00412 DEB(printf("Input: '%s'\n", m_guiInput.GetLine());) 00413 m_guiInput.SetLine(""); 00414 m_guiInput.InvalidateEv(); 00415 } 00416 } 00417 }

void MainWindow::OnMouseMove coord_t  ,
coord_t  ,
coord_t  ,
coord_t 
 

Definition at line 420 of file MainWindow.cpp.

References m_dc, m_dot, m_dots, and OnMouseMove().

Referenced by OnMouseMove().

00421 { 00422 // find intersection or triangle 00423 mapdots_t::iterator it; 00424 MAPDOT *dot = NULL; 00425 00426 for (it = m_dots.begin(); it != m_dots.end(); it++) 00427 { 00428 MAPDOT *d = *it; 00429 long xx = abs(d -> x - x); 00430 long yy = abs(d -> y - y); 00431 if (xx < 10 && yy < 10) 00432 { 00433 dot = d; 00434 } 00435 } 00436 if (dot != m_dot) 00437 { 00438 if (m_dc.IsVisible()) 00439 { 00440 SDL_Rect a = m_dc.GetAbsoluteRect(); 00441 InvalidateRectEv(a); 00442 } 00443 } 00444 m_dot = dot; 00445 if (m_dot) 00446 { 00447 m_dc.MoveTo(this, m_dot -> x - 5, m_dot -> y - 5); 00448 } 00449 else 00450 { 00451 m_dc.MoveTo(this, 0, 0, false); 00452 } 00453 if (dot) 00454 { 00455 m_dot = dot; 00456 m_dc.SetX(m_dot -> x - 5); 00457 m_dc.SetY(m_dot -> y - 5); 00458 m_dc.GetParent() -> CalculateAbsolute(); 00459 m_dc.SetVisible(true); 00460 m_dc.InvalidateEv(); 00461 } 00462 else 00463 { 00464 m_dot = dot; 00465 m_dc.SetVisible(false); 00466 } 00467 }

void MainWindow::OnRightClick coord_t  ,
coord_t 
 

Definition at line 470 of file MainWindow.cpp.

References m_dc, m_dot, m_dotMenu, m_pclTestMenu, and OnRightClick().

Referenced by OnRightClick().

00471 { 00472 if (m_dot) 00473 { 00474 if (!m_dotMenu) 00475 { 00476 m_dotMenu = new DotMenu( this ); 00477 m_dotMenu -> SetX( m_dot -> x ); 00478 m_dotMenu -> SetY( m_dot -> y ); 00479 AddChild(m_dotMenu); 00480 m_dotMenu -> InvalidateEv(); 00481 m_dc.Bond( m_dotMenu ); 00482 } 00483 else 00484 { 00485 if (m_dotMenu -> IsVisible()) 00486 { 00487 SDL_Rect a = m_dotMenu -> GetAbsoluteRect(); 00488 InvalidateRectEv(a); 00489 } 00490 else 00491 { 00492 m_dotMenu -> SetVisible(true); 00493 } 00494 m_dotMenu -> SetX( m_dot -> x ); 00495 m_dotMenu -> SetY( m_dot -> y ); 00496 CalculateAbsolute(); 00497 m_dotMenu -> InvalidateEv(); 00498 } 00499 } 00500 else 00501 { 00502 if (!m_pclTestMenu) 00503 { 00504 m_pclTestMenu = new TestMenu( this ); 00505 m_pclTestMenu -> SetX( x ); 00506 m_pclTestMenu -> SetY( y ); 00507 AddChild(m_pclTestMenu); 00508 m_pclTestMenu -> InvalidateEv(); 00509 } 00510 else 00511 { 00512 if (m_pclTestMenu -> IsVisible()) 00513 { 00514 SDL_Rect a = m_pclTestMenu -> GetAbsoluteRect(); 00515 InvalidateRectEv(a); 00516 } 00517 else 00518 { 00519 m_pclTestMenu -> SetVisible(true); 00520 } 00521 m_pclTestMenu -> SetX( x ); 00522 m_pclTestMenu -> SetY( y ); 00523 CalculateAbsolute(); 00524 m_pclTestMenu -> InvalidateEv(); 00525 } 00526 } 00527 }

void MainWindow::Redraw  ) 
 

Definition at line 613 of file MainWindow.cpp.

00614 { 00615 // Draw(); 00616 // Invalidate(); 00617 SetDirty(true); 00618 }

void MainWindow::SetAngles double  ,
double 
 

Definition at line 573 of file MainWindow.cpp.

References m_test_v, m_test_v_vertikal, and SetAngles().

Referenced by SetAngles().

00574 { 00575 m_test_v = a1; 00576 m_test_v_vertikal = a2; 00577 00578 // Draw(); 00579 // InvalidateEv(); 00580 SetDirty(true); 00581 }

void MainWindow::ShowLogin Form::Form *   ) 
 

Definition at line 256 of file MainWindow.cpp.

References m_pclLoginDialog, and ShowLogin().

Referenced by ShowLogin().

00257 { 00258 if (!m_pclLoginDialog) 00259 { 00260 m_pclLoginDialog = new LoginDialog( this ); 00261 AddChild(m_pclLoginDialog); 00262 } 00263 else 00264 { 00265 m_pclLoginDialog -> SetVisible(true); 00266 m_pclLoginDialog -> BringToTop(); 00267 } 00268 m_pclLoginDialog -> SetForm(pclForm); 00269 m_pclLoginDialog -> UpdateData(false); 00270 // m_pclLoginDialog -> DrawAll(); 00271 m_pclLoginDialog -> InvalidateEv(); 00272 }

void MainWindow::ShowMenu  ) 
 

Definition at line 220 of file MainWindow.cpp.

References m_pclConnectThread, and m_pclMenuDialog.

00221 { 00222 if (!m_pclMenuDialog) 00223 { 00224 m_pclMenuDialog = new MenuDialog( this ); 00225 AddChild(m_pclMenuDialog); 00226 } 00227 else 00228 { 00229 m_pclMenuDialog -> SetVisible(true); 00230 m_pclMenuDialog -> BringToTop(); 00231 } 00232 m_pclMenuDialog -> Connected(m_pclConnectThread ? "Disconnect" : "Connect"); 00233 // m_pclMenuDialog -> DrawAll(); 00234 m_pclMenuDialog -> InvalidateEv(); 00235 }

void MainWindow::ShowOptions  ) 
 

Definition at line 238 of file MainWindow.cpp.

References m_pclOptionsDialog.

00239 { 00240 if (!m_pclOptionsDialog) 00241 { 00242 m_pclOptionsDialog = new OptionsDialog( this ); 00243 AddChild(m_pclOptionsDialog); 00244 } 00245 else 00246 { 00247 m_pclOptionsDialog -> SetVisible(true); 00248 m_pclOptionsDialog -> BringToTop(); 00249 } 00250 m_pclOptionsDialog -> UpdateData(false); 00251 // m_pclOptionsDialog -> DrawAll(); 00252 m_pclOptionsDialog -> InvalidateEv(); 00253 }

void MainWindow::ShowPlayers Form::Form *  ,
vector< string > & 
 

Definition at line 275 of file MainWindow.cpp.

References m_pclPlayerDialog, and ShowPlayers().

Referenced by ShowPlayers().

00276 { 00277 vector<string>::iterator it; 00278 if (!m_pclPlayerDialog) 00279 { 00280 m_pclPlayerDialog = new PlayerDialog(this); 00281 AddChild(m_pclPlayerDialog); 00282 } 00283 else 00284 { 00285 m_pclPlayerDialog -> SetVisible(true); 00286 m_pclPlayerDialog -> BringToTop(); 00287 } 00288 m_pclPlayerDialog -> SetForm(pclForm); 00289 m_pclPlayerDialog -> Clear(); 00290 for (it = players.begin(); it != players.end(); it++) 00291 { 00292 m_pclPlayerDialog -> AddButton(*it); 00293 } 00294 // m_pclPlayerDialog -> DrawAll(); 00295 m_pclPlayerDialog -> InvalidateEv(); 00296 }

void MainWindow::ShowText  ) 
 

Definition at line 299 of file MainWindow.cpp.

References m_pclTextDialog.

00300 { 00301 if (!m_pclTextDialog) 00302 { 00303 m_pclTextDialog = new TextDialog( this ); 00304 AddChild(m_pclTextDialog); 00305 } 00306 else 00307 { 00308 m_pclTextDialog -> SetVisible(true); 00309 m_pclTextDialog -> BringToTop(); 00310 } 00311 // m_pclTextDialog -> DrawAll(); 00312 m_pclTextDialog -> InvalidateEv(); 00313 }


Member Data Documentation

TTFont MainWindow::courier8 [private]
 

Definition at line 101 of file MainWindow.h.

Referenced by MainWindow().

DotCursor MainWindow::m_dc [private]
 

Definition at line 120 of file MainWindow.h.

Referenced by Draw(), MainWindow(), OnMouseMove(), and OnRightClick().

MAPDOT* MainWindow::m_dot [private]
 

Definition at line 119 of file MainWindow.h.

Referenced by Draw(), OnMouseMove(), and OnRightClick().

DotMenu* MainWindow::m_dotMenu [private]
 

Definition at line 110 of file MainWindow.h.

Referenced by OnRightClick(), and ~MainWindow().

mapdots_t MainWindow::m_dots [private]
 

Definition at line 118 of file MainWindow.h.

Referenced by Draw(), OnMouseMove(), and ~MainWindow().

Grid MainWindow::m_grid [static]
 

Definition at line 63 of file MainWindow.cpp.

Referenced by DecreaseBase(), Draw(), IncreaseBase(), and MainWindow().

Edit MainWindow::m_guiInput [private]
 

Definition at line 102 of file MainWindow.h.

Referenced by GetInput(), MainWindow(), and OnEvent().

ConnectThread* MainWindow::m_pclConnectThread [private]
 

Definition at line 108 of file MainWindow.h.

Referenced by Connect(), Disconnect(), Draw(), Get_h(), Get_t_left(), Get_t_up(), OnEvent(), ShowMenu(), and ~MainWindow().

LoginDialog* MainWindow::m_pclLoginDialog [private]
 

Definition at line 105 of file MainWindow.h.

Referenced by OnEvent(), ShowLogin(), and ~MainWindow().

MenuDialog* MainWindow::m_pclMenuDialog [private]
 

Definition at line 103 of file MainWindow.h.

Referenced by ShowMenu(), and ~MainWindow().

OptionsDialog* MainWindow::m_pclOptionsDialog [private]
 

Definition at line 104 of file MainWindow.h.

Referenced by ShowOptions(), and ~MainWindow().

PlayerDialog* MainWindow::m_pclPlayerDialog [private]
 

Definition at line 106 of file MainWindow.h.

Referenced by OnEvent(), and ShowPlayers().

TestMenu* MainWindow::m_pclTestMenu [private]
 

Definition at line 109 of file MainWindow.h.

Referenced by OnRightClick(), and ~MainWindow().

TextDialog* MainWindow::m_pclTextDialog [private]
 

Definition at line 107 of file MainWindow.h.

Referenced by AddLine(), ShowText(), and ~MainWindow().

double MainWindow::m_test_v [private]
 

Definition at line 116 of file MainWindow.h.

Referenced by Draw(), and SetAngles().

double MainWindow::m_test_v_vertikal [private]
 

Definition at line 117 of file MainWindow.h.

Referenced by Draw(), and SetAngles().


The documentation for this class was generated from the following files:
Generated for SDL C++ GUI by doxygen 1.3.6