[Gcblue-commits] gcb_wx/src/graphics tc3DWindow.cpp,1.18,1.19 tcChatBox.cpp,1.2,1.3 tcConsoleBox.cpp
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-04-16 20:44:52
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11335/src/graphics Modified Files: tc3DWindow.cpp tcChatBox.cpp tcConsoleBox.cpp tcEditBox.cpp tcMapView.cpp tcNetworkView.cpp tcTerrainView.cpp Log Message: housekeeping, networking upgrades, fixed wrapping problems with world map Index: tcNetworkView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcNetworkView.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcNetworkView.cpp 8 Apr 2005 01:54:11 -0000 1.6 --- tcNetworkView.cpp 16 Apr 2005 20:44:42 -0000 1.7 *************** *** 45,48 **** --- 45,50 ---- EVT_COMMAND(1, wxEVT_COMMAND_TEXT_UPDATED, tcNetworkView::SetIPText) EVT_COMMAND(2, wxEVT_COMMAND_TEXT_UPDATED, tcNetworkView::SendChatText) + EVT_COMMAND(3, wxEVT_COMMAND_TEXT_UPDATED, tcNetworkView::SetUsername) + EVT_COMMAND(4, wxEVT_COMMAND_TEXT_UPDATED, tcNetworkView::SetPassword) END_EVENT_TABLE() *************** *** 77,86 **** CENTER_CENTER); - unsigned nConnections = tcMultiplayerInterface::Get()->GetNumConnections(); x = (float)statusBoxBounds.x + 10.0f; ! for (unsigned n=0;n<nConnections;n++) ! { y += 14.0f; ! std::string connectionStatus = tcMultiplayerInterface::Get()->GetConnectionStatus(n); DrawTextR(connectionStatus.c_str(), x, y, defaultFont.get(), color, 12.0f, --- 79,90 ---- CENTER_CENTER); x = (float)statusBoxBounds.x + 10.0f; ! ! const std::list<int>& connectionList = tcMultiplayerInterface::Get()->GetConnectionList(); ! std::list<int>::const_iterator iter = connectionList.begin(); ! for ( ; iter != connectionList.end(); ++iter) ! { y += 14.0f; ! std::string connectionStatus = tcMultiplayerInterface::Get()->GetConnectionStatus(*iter); DrawTextR(connectionStatus.c_str(), x, y, defaultFont.get(), color, 12.0f, *************** *** 92,99 **** LEFT_CENTER); ! } /** * Only applies in client mode when already connected --- 96,107 ---- LEFT_CENTER); + } ! int tcNetworkView::GetNetworkMode() const ! { ! return networkMode; } + /** * Only applies in client mode when already connected *************** *** 160,171 **** } ! unsigned nConnections = multiplayerInterface->GetNumConnections(); ! ! for (unsigned n=0;n<nConnections;n++) ! { ! int connId = tcMultiplayerInterface::Get()->GetConnectionId(n); ! tcMultiplayerInterface::Get()->SendChatText(connId, chatText); ! } ! // if server, print chat text locally since no echo comes back --- 168,172 ---- } ! tcMultiplayerInterface::Get()->BroadcastChatText(chatText); // if server, print chat text locally since no echo comes back *************** *** 195,204 **** int mode = event.m_extraLong; if (networkMode == mode) return; - // switching to client mode also terminates all connections if (mode == MULTIPLAYER_OFF) { ! tcMultiplayerInterface::Get()->MakeClient(); tcSimState::Get()->SetMultiplayerOff(); } --- 196,212 ---- int mode = event.m_extraLong; + SetNetworkMode(mode); + + event.Skip(); // send event on to application + } + + void tcNetworkView::SetNetworkMode(int mode) + { if (networkMode == mode) return; if (mode == MULTIPLAYER_OFF) { ! // terminate all connections ! tcMultiplayerInterface::Get()->Reset(); tcSimState::Get()->SetMultiplayerOff(); } *************** *** 224,236 **** } - //tcMultiplayerInterface::Get().OpenConnection("192.168.0.101"); - networkMode = mode; ! event.Skip(); // send event on to application } void tcNetworkView::SendTest(wxCommandEvent& event) { std::string testText = "Test text for UDP"; --- 232,255 ---- } networkMode = mode; + } ! void tcNetworkView::SetUsername(wxCommandEvent& event) ! { ! std::string s = event.GetString().c_str(); ! ! tcMultiplayerInterface::Get()->SetName(s); ! } ! ! void tcNetworkView::SetPassword(wxCommandEvent& event) ! { ! std::string s = event.GetString().c_str(); ! ! tcMultiplayerInterface::Get()->SetPassword(s); } void tcNetworkView::SendTest(wxCommandEvent& event) { + /* std::string testText = "Test text for UDP"; *************** *** 250,253 **** --- 269,273 ---- chatBox->Print(localText.c_str()); } + */ } *************** *** 286,289 **** --- 306,321 ---- ipEdit->SetClearOnReturn(false); + // add username edit box + current = root->FirstChild("EditName"); + usernameEdit = new tcEditBox(this, current); + usernameEdit->SetCommand(3); + usernameEdit->SetClearOnReturn(false); + + // add password edit box + current = root->FirstChild("EditPassword"); + passwordEdit = new tcEditBox(this, current); + passwordEdit->SetCommand(4); + passwordEdit->SetClearOnReturn(false); + if (!tcOptions::Get()->OptionStringExists("HostAddress")) { Index: tcConsoleBox.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcConsoleBox.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tcConsoleBox.cpp 2 Mar 2005 22:28:43 -0000 1.12 --- tcConsoleBox.cpp 16 Apr 2005 20:44:42 -0000 1.13 *************** *** 151,155 **** y = nyzero-(int)i*nlinespace; ! if (y<0) break; --- 151,155 ---- y = nyzero-(int)i*nlinespace; ! if (y<15) break; Index: tcChatBox.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcChatBox.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcChatBox.cpp 21 Oct 2004 04:10:59 -0000 1.2 --- tcChatBox.cpp 16 Apr 2005 20:44:42 -0000 1.3 *************** *** 86,97 **** } ! unsigned nConnections = multiplayerInterface->GetNumConnections(); ! ! for (unsigned n=0;n<nConnections;n++) ! { ! int connId = tcMultiplayerInterface::Get()->GetConnectionId(n); ! tcMultiplayerInterface::Get()->SendChatText(connId, chatText); ! } ! // if server, print chat text locally since no echo comes back --- 86,90 ---- } ! tcMultiplayerInterface::Get()->BroadcastChatText(chatText); // if server, print chat text locally since no echo comes back Index: tcTerrainView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcTerrainView.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcTerrainView.cpp 19 Mar 2005 15:31:09 -0000 1.5 --- tcTerrainView.cpp 16 Apr 2005 20:44:42 -0000 1.6 *************** *** 44,49 **** if (!redraw) return; ! DrawZoomedImage(mapImage.get(), 0, 0, (float)mnWidth, (float)mnHeight, ! displayRegion, ALIGN_BOTTOM_LEFT); FinishDraw(); --- 44,61 ---- if (!redraw) return; ! // if displayRegion is wrapped, draw two images ! ! if (!isWrapped) ! { ! DrawZoomedImage(mapImage.get(), 0, 0, (float)mnWidth, (float)mnHeight, ! displayRegion, ALIGN_BOTTOM_LEFT); ! } ! else ! { ! DrawZoomedImage(mapImage.get(), 0, 0, wrapWidth*(float)mnWidth, (float)mnHeight, ! displayRegion, ALIGN_BOTTOM_LEFT); ! DrawZoomedImage(mapImage.get(), wrapWidth*(float)mnWidth, 0, (1.0f-wrapWidth)*(float)mnWidth, (float)mnHeight, ! displayRegionWrapped, ALIGN_BOTTOM_LEFT); ! } FinishDraw(); *************** *** 88,107 **** mrectCurrentView = r; ! /* ! float surfaceWidth, surfaceHeight; // surface coordinate dimensions ! osg::Image* image = mapImage->getImage(); ! wxASSERT(image); ! ! surfaceWidth = (float)image->s(); ! surfaceHeight = (float)image->t(); ! */ ! // assumes longitude is within [-pi,pi) and lat within [-pi/2,pi/2] ! displayRegion.left = (r.left - mrectMap.left)/mrectMap.Width(); ! displayRegion.right = (r.right - mrectMap.left)/mrectMap.Width(); ! displayRegion.bottom = (r.bottom - mrectMap.bottom)/mrectMap.Height(); ! displayRegion.top = (r.top - mrectMap.bottom)/mrectMap.Height(); ! redraw = true; } --- 100,131 ---- mrectCurrentView = r; ! isWrapped = r.left > r.right; ! if (!isWrapped) ! { ! // assumes longitude is within [-pi,pi) and lat within [-pi/2,pi/2] ! displayRegion.left = (r.left - mrectMap.left)/mrectMap.Width(); ! displayRegion.right = (r.right - mrectMap.left)/mrectMap.Width(); ! displayRegion.bottom = (r.bottom - mrectMap.bottom)/mrectMap.Height(); ! displayRegion.top = (r.top - mrectMap.bottom)/mrectMap.Height(); ! wrapWidth = 1.0f; ! } ! else ! { ! displayRegion.left = (r.left - mrectMap.left)/mrectMap.Width(); ! displayRegion.right = 1.0f; ! displayRegion.bottom = (r.bottom - mrectMap.bottom)/mrectMap.Height(); ! displayRegion.top = (r.top - mrectMap.bottom)/mrectMap.Height(); ! ! displayRegionWrapped.left = 0; ! displayRegionWrapped.right = (r.right - mrectMap.left)/mrectMap.Width(); ! displayRegionWrapped.bottom = (r.bottom - mrectMap.bottom)/mrectMap.Height(); ! displayRegionWrapped.top = (r.top - mrectMap.bottom)/mrectMap.Height(); ! ! wrapWidth = (1.0f - displayRegion.left) / (1.0f - displayRegion.left + displayRegionWrapped.right); ! ! } ! redraw = true; } Index: tc3DWindow.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DWindow.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** tc3DWindow.cpp 31 Mar 2005 03:51:12 -0000 1.18 --- tc3DWindow.cpp 16 Apr 2005 20:44:42 -0000 1.19 *************** *** 2018,2022 **** } ! defaultFont = osgText::readFontFile("fonts/arial.ttf"); InitGraphicsObjects(); --- 2018,2022 ---- } ! defaultFont = osgText::readFontFile("fonts/times.ttf"); InitGraphicsObjects(); Index: tcEditBox.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcEditBox.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcEditBox.cpp 2 Nov 2004 04:23:56 -0000 1.9 --- tcEditBox.cpp 16 Apr 2005 20:44:42 -0000 1.10 *************** *** 73,85 **** // draw text DrawTextInRect(mzBuffer, mrectTextBar, defaultFont.get(), ! osg::Vec4(0, 0, 0, 1), 12.0f, LEFT_BASE_LINE); // draw caption DrawTextInRectR(mzCaption, mrectTextBar, defaultFont.get(), ! osg::Vec4(1, 1, 1, 1), 12.0f, CENTER_CENTER); // draw cursor wxSize size; ! MeasureText(defaultFont.get(), 12.0f, mzBuffer, size); osg::Vec4 cursorColor(0, 0, 0, 1); --- 73,85 ---- // draw text DrawTextInRect(mzBuffer, mrectTextBar, defaultFont.get(), ! osg::Vec4(0, 0, 0, 1), fontSize, LEFT_BASE_LINE); // draw caption DrawTextInRectR(mzCaption, mrectTextBar, defaultFont.get(), ! osg::Vec4(1, 1, 1, 1), fontSize, CENTER_CENTER); // draw cursor wxSize size; ! MeasureText(defaultFont.get(), fontSize, mzBuffer, size); osg::Vec4 cursorColor(0, 0, 0, 1); *************** *** 91,95 **** if (isFocused) { ! float xcursor = mrectTextBar.left + size.GetWidth() + 1.0f; float xcursorMax = mrectTextBar.right - 2.0f; --- 91,95 ---- if (isFocused) { ! float xcursor = mrectTextBar.left + size.GetWidth() + 2.0f; float xcursorMax = mrectTextBar.right - 2.0f; *************** *** 115,119 **** if (keycode == WXK_RETURN) { ! if ((textChanged)&&(clearOnReturn)) { wxCommandEvent command(wxEVT_COMMAND_TEXT_UPDATED, command) ; --- 115,119 ---- if (keycode == WXK_RETURN) { ! if (textChanged) { wxCommandEvent command(wxEVT_COMMAND_TEXT_UPDATED, command) ; *************** *** 121,126 **** command.SetString(mzBuffer); AddPendingEvent(command); // TODO add handler added in tcGame for this event ! strcpy(mzBuffer,""); ! textChanged = false; } } --- 121,130 ---- command.SetString(mzBuffer); AddPendingEvent(command); // TODO add handler added in tcGame for this event ! ! textChanged = false; ! if (clearOnReturn) ! { ! strcpy(mzBuffer,""); ! } } } *************** *** 274,277 **** --- 278,285 ---- drawBackground = (mrectTextBar.Width() < (float)width); + + double xmlFontSize = 0; + current->Attribute("FontSize", &xmlFontSize); + if (xmlFontSize > 0) fontSize = xmlFontSize; } Index: tcMapView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapView.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** tcMapView.cpp 31 Mar 2005 03:51:12 -0000 1.22 --- tcMapView.cpp 16 Apr 2005 20:44:42 -0000 1.23 *************** *** 2698,2709 **** p1 = GeoToScreen(p1); p2 = GeoToScreen(p2); width = p2.x - p1.x; height = p1.y - p2.y; - //Pen* pen = (width > 16.0f) ? mpPen : mpPenThin; - osg::Vec4 color(1, 1, 1, 1); ! DrawRectangleR(p1.x, p2.y, width, height, color); } /** --- 2698,2725 ---- p1 = GeoToScreen(p1); p2 = GeoToScreen(p2); + + float fWidth = (float)mnWidth; + float fHeight = (float)mnHeight; + + if ((p1.x > fWidth) || (p2.x < 0) || + (p2.y > fHeight) || (p1.y < 0)) + { + return; + } + + + if (p1.x < 0) p1.x = 0; + if (p2.y < 0) p2.y = 0; + if (p2.x > fWidth) p2.x = fWidth; + if (p1.y > fHeight) p1.y = fHeight; + + width = p2.x - p1.x; height = p1.y - p2.y; osg::Vec4 color(1, 1, 1, 1); ! DrawRectangleR(p1.x, p2.y, width, height, color); ! } /** *************** *** 2780,2784 **** { wxPoint point = event.GetPosition(); ! if (event.ShiftDown()) { tcSound::Get()->PlayEffect("Beep2"); --- 2796,2800 ---- { wxPoint point = event.GetPosition(); ! if (event.AltDown()) { tcSound::Get()->PlayEffect("Beep2"); |