[Gcblue-commits] gcb_wx/src/common simmath.cpp,1.4,1.4.2.1 tcOptions.cpp,1.5,1.5.2.1 tcOptionsView.c
Status: Alpha
Brought to you by:
ddcforge
From: <ddc...@us...> - 2004-02-17 14:35:57
|
Update of /cvsroot/gcblue/gcb_wx/src/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32097/src/common Modified Files: Tag: v0_5_0 simmath.cpp tcOptions.cpp tcOptionsView.cpp tcSound.cpp Log Message: Index: simmath.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/simmath.cpp,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** simmath.cpp 8 Jan 2004 23:54:27 -0000 1.4 --- simmath.cpp 17 Feb 2004 14:27:02 -0000 1.4.2.1 *************** *** 194,197 **** --- 194,203 ---- } + bool tcGeoRect::operator==(const tcGeoRect& r) + { + return ((left == r.left)&&(right == r.right)&& + (top == r.top)&&(bottom == r.bottom)); + } + /******************************* tcTrack *******************************/ /** Index: tcOptions.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/tcOptions.cpp,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -C2 -d -r1.5 -r1.5.2.1 *** tcOptions.cpp 9 Dec 2003 00:36:03 -0000 1.5 --- tcOptions.cpp 17 Feb 2004 14:27:02 -0000 1.5.2.1 *************** *** 116,120 **** oi.meType = tsOptionInfo::OT_RADIOBUTTON; oi.mnStateCount = 3; ! oi.mnValue = 1; oi.mpAssociated = &renderSkipCount; oi.mzCaption[0] = "2D skip off"; --- 116,120 ---- oi.meType = tsOptionInfo::OT_RADIOBUTTON; oi.mnStateCount = 3; ! oi.mnValue = 0; oi.mpAssociated = &renderSkipCount; oi.mzCaption[0] = "2D skip off"; *************** *** 123,126 **** --- 123,135 ---- AddOption(oi); + oi.meType = tsOptionInfo::OT_RADIOBUTTON; + oi.mnStateCount = 3; + oi.mnValue = 1; + oi.mpAssociated = &graphicsDetail; + oi.mzCaption[0] = "Graphics Level 0"; + oi.mzCaption[1] = "Graphics Level 1"; + oi.mzCaption[2] = "Graphics Level 2"; + AddOption(oi); + Serialize(true); // read option state from file (options.dat) Index: tcOptionsView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/tcOptionsView.cpp,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -C2 -d -r1.3 -r1.3.2.1 *** tcOptionsView.cpp 30 Nov 2003 17:23:52 -0000 1.3 --- tcOptionsView.cpp 17 Feb 2004 14:27:02 -0000 1.3.2.1 *************** *** 35,244 **** bool tcOptionsView::Init() { ! char zBuff[96]; ! strcpy(zBuff,IMAGE_PATH); ! strcat(zBuff,"options_bk.jpg"); ! MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); ! mpiBackground = new Image(mzwchar,false); ! strcpy(zBuff,IMAGE_PATH); ! strcat(zBuff,"options_bon.bmp"); ! MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); ! mpiButtonOn = new Image(mzwchar,false); ! strcpy(zBuff,IMAGE_PATH); ! strcat(zBuff,"options_boff.bmp"); ! MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); ! mpiButtonOff = new Image(mzwchar,false); ! if (mpiBackground == NULL) { ! WTL("tcOptions - background bitmap (options_bk.jpg) load error"); ! return false; ! } ! if (mpiButtonOn == NULL) { ! WTL("tcOptions - background bitmap (options_bon.bmp) load error"); ! return false; ! } ! if (mpiButtonOff == NULL) { ! WTL("tcOptions - background bitmap (options_boff.bmp) load error"); ! return false; ! } ! FontFamily ff(L"Arial"); ! mpFont = new Font(&ff,12,FontStyleBold,UnitPixel); ! if (mpFont == NULL) { ! WTL("tcOptionsView - mpFont creation failed\n"); ! return false; ! } ! mpBrush = new SolidBrush(Color(0xFEFFFFFF)); // color is ARGB ! if (mpBrush == NULL) { ! WTL("tcOptionsView - mpBrush creation failed\n"); ! return false; ! } ! mpPen = new Pen(Color(255,200,200,200),2); ! if (mpPen == NULL) { ! WTL("tcTOptionsView - mpPen creation failed\n"); ! return false; ! } ! // Get dimensions and limit to window dimensions ! // mpiButtonOn dimensions are used for all buttons ! mnBackgroundWidth = mpiBackground->GetWidth(); ! if (mnBackgroundWidth > mnWidth) {mnBackgroundWidth = mnWidth;} ! mnBackgroundHeight = mpiBackground->GetHeight(); ! if (mnBackgroundHeight > mnHeight) {mnBackgroundHeight = mnHeight;} ! mnButtonWidth = mpiButtonOn->GetWidth(); ! if (mnButtonWidth > mnWidth) {mnButtonWidth = mnWidth;} //limit dimensions to window ! mnButtonHeight = mpiButtonOn->GetHeight(); ! if (mnButtonHeight > mnHeight) {mnButtonHeight = mnHeight;} ! return true; } /*******************************************************************************/ int tcOptionsView::Draw() { ! static nTestCount = 0; ! static WCHAR szwchar[256]; // wide char array buffer for string conversion ! Graphics *pGraphics; ! Erase(); ! if (!GetGraphics(pGraphics)) { ! return false; ! } ! if (mpiBackground == NULL) {return false;} ! if (mpOptions == NULL) {return false;} ! pGraphics->DrawImage(mpiBackground,0,0,mnWidth,mnHeight); ! ! mpBrush->SetColor(Color(0xFEFFFFFF)); ! ! /*** Draw test text **/ ! ! tcString sText; ! int xpos,ypos; ! ypos = mnYStart; ! RectF rstring; ! for(int i=0;i<mpOptions->mnNumOptions;i++) { ! xpos = mnXStart; ! int nBoxWidth = maButtonPosition[i][mpOptions->maOptionInfo[i].mnStateCount-1].mnButtonX - maButtonPosition[i][0].mnTextX + 2*mnButtonWidth; ! mpBrush->SetColor(Color(0x60FFFFFF)); ! pGraphics->FillRectangle(mpBrush, ! maButtonPosition[i][0].mnTextX - mnButtonHeight/2, ypos - 3*mnButtonHeight/2, ! nBoxWidth, 2*mnButtonHeight); ! mpBrush->SetColor(Color(255,255,220,220)); ! for(int j=0;j<mpOptions->maOptionInfo[i].mnStateCount;j++) { ! sText = mpOptions->maOptionInfo[i].mzCaption[j]; ! MultiByteToWideChar(CP_ACP, 0, sText.GetBuffer(), -1, szwchar, 255); ! pGraphics->MeasureString(szwchar,-1,mpFont,PointF(0,0),&rstring); ! maButtonPosition[i][j].mnTextX = xpos; ! maButtonPosition[i][j].mnTextY = ypos-mnButtonHeight+2; ! xpos += (int)(rstring.Width) + 1; ! maButtonPosition[i][j].mnButtonX = xpos; ! maButtonPosition[i][j].mnButtonY = ypos-mnButtonHeight-mnButtonHeight/6; ! xpos += 3*mnButtonWidth; ! } ! pGraphics->DrawRectangle(mpPen, ! maButtonPosition[i][0].mnTextX - mnButtonHeight/2, ypos - 3*mnButtonHeight/2, ! nBoxWidth, 2*mnButtonHeight); ! ypos += 3*mnButtonHeight; ! } ! ! for(i=0;i<mpOptions->mnNumOptions;i++) { ! for(int j=0;j<mpOptions->maOptionInfo[i].mnStateCount;j++) { ! sText = mpOptions->maOptionInfo[i].mzCaption[j]; ! MultiByteToWideChar(CP_ACP, 0, sText.GetBuffer(), -1, szwchar, 255); ! pGraphics->DrawString(szwchar, -1, mpFont, ! PointF((float)maButtonPosition[i][j].mnTextX, (float)maButtonPosition[i][j].mnTextY), ! mpBrush); ! ! ! if (mpOptions->maOptionInfo[i].mnValue == j) { ! DrawButton(pGraphics,maButtonPosition[i][j].mnButtonX, ! maButtonPosition[i][j].mnButtonY,1); ! } ! else { ! DrawButton(pGraphics,maButtonPosition[i][j].mnButtonX, ! maButtonPosition[i][j].mnButtonY,0); ! } ! } ! } ! ! ReleaseGraphics(pGraphics); ! DrawBorder(); ! return true; } /*******************************************************************************/ void tcOptionsView::DrawButton(Graphics *apGraphics, int x, int y, int abOn) { ! Image *pButton; ! if (apGraphics == NULL) {return;} ! pButton = (abOn == 1) ? mpiButtonOn : mpiButtonOff; ! if (pButton == NULL) {return;} ! apGraphics->DrawImage(pButton,x,y); } /******************************************************************************/ void tcOptionsView::OnLButtonDown(wxMouseEvent& event) { ! bool bButtonClicked; ! int nOption, nValue; ! if (!mbActive) ! { ! event.Skip(); ! return; ! } - // TranslatePoint(point); // adjust for flipped up/down - bButtonClicked = ButtonContainingPoint(event.GetPosition(), nOption, nValue); - if (bButtonClicked) { - if ((nOption >= mpOptions->mnNumOptions)|| - (nValue >= mpOptions->maOptionInfo[nOption].mnStateCount)) { - WTL("tcOptionsView::OnLButtonDown error"); - return; - } - mpOptions->maOptionInfo[nOption].mnValue = nValue; - if (mpOptions->maOptionInfo[nOption].mpAssociated != NULL) { - *mpOptions->maOptionInfo[nOption].mpAssociated = nValue; - } - mpOptions->Serialize(false); // create new options file - if (mpSound != NULL) { - mpSound->PlayEffect(SEFFECT_BEEP2); - } - } - else - { - // switch back to start view if no buttons clicked (for now) - wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, ID_STARTVIEW) ; - command.SetEventObject(this); - AddPendingEvent(command); - } - } /******************************************************************************/ bool tcOptionsView::ButtonContainingPoint(wxPoint point, int& rnOption, int& rnValue) { ! int i,j; ! int nx, ny; ! for(i=0;i<mpOptions->mnNumOptions;i++) { ! for(j=0;j<mpOptions->maOptionInfo[i].mnStateCount;j++) { ! nx = maButtonPosition[i][j].mnButtonX; ! ny = maButtonPosition[i][j].mnButtonY; ! wxRect cr(nx,ny,mnButtonWidth,mnButtonHeight); ! if (cr.Inside(point)) { ! rnOption = i; ! rnValue = j; ! return true; ! } ! } ! } ! return false; } --- 35,246 ---- bool tcOptionsView::Init() { ! char zBuff[96]; ! strcpy(zBuff,IMAGE_PATH); ! strcat(zBuff,"options_bk.jpg"); ! MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); ! mpiBackground = new Image(mzwchar,false); ! strcpy(zBuff,IMAGE_PATH); ! strcat(zBuff,"options_bon.bmp"); ! MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); ! mpiButtonOn = new Image(mzwchar,false); ! strcpy(zBuff,IMAGE_PATH); ! strcat(zBuff,"options_boff.bmp"); ! MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); ! mpiButtonOff = new Image(mzwchar,false); ! if (mpiBackground == NULL) { ! WTL("tcOptions - background bitmap (options_bk.jpg) load error"); ! return false; ! } ! if (mpiButtonOn == NULL) { ! WTL("tcOptions - background bitmap (options_bon.bmp) load error"); ! return false; ! } ! if (mpiButtonOff == NULL) { ! WTL("tcOptions - background bitmap (options_boff.bmp) load error"); ! return false; ! } ! FontFamily ff(L"Arial"); ! mpFont = new Font(&ff,12,FontStyleBold,UnitPixel); ! if (mpFont == NULL) { ! WTL("tcOptionsView - mpFont creation failed\n"); ! return false; ! } ! mpBrush = new SolidBrush(Color(0xFEFFFFFF)); // color is ARGB ! if (mpBrush == NULL) { ! WTL("tcOptionsView - mpBrush creation failed\n"); ! return false; ! } ! mpPen = new Pen(Color(255,200,200,200),2); ! if (mpPen == NULL) { ! WTL("tcTOptionsView - mpPen creation failed\n"); ! return false; ! } ! // Get dimensions and limit to window dimensions ! // mpiButtonOn dimensions are used for all buttons ! mnBackgroundWidth = mpiBackground->GetWidth(); ! if (mnBackgroundWidth > mnWidth) {mnBackgroundWidth = mnWidth;} ! mnBackgroundHeight = mpiBackground->GetHeight(); ! if (mnBackgroundHeight > mnHeight) {mnBackgroundHeight = mnHeight;} ! mnButtonWidth = mpiButtonOn->GetWidth(); ! if (mnButtonWidth > mnWidth) {mnButtonWidth = mnWidth;} //limit dimensions to window ! mnButtonHeight = mpiButtonOn->GetHeight(); ! if (mnButtonHeight > mnHeight) {mnButtonHeight = mnHeight;} ! return true; } /*******************************************************************************/ int tcOptionsView::Draw() { ! static nTestCount = 0; ! static WCHAR szwchar[256]; // wide char array buffer for string conversion ! Graphics *pGraphics; ! Erase(); ! if (!GetGraphics(pGraphics)) { ! return false; ! } ! if (mpiBackground == NULL) {return false;} ! if (mpOptions == NULL) {return false;} ! pGraphics->DrawImage(mpiBackground,0,0,mnWidth,mnHeight); ! mpBrush->SetColor(Color(0xFEFFFFFF)); ! /*** Draw test text **/ ! tcString sText; ! ! ! int xpos,ypos; ! ypos = mnYStart; ! RectF rstring; ! int buttonRowSpacing = (mnWidth < 1000)? (5*mnButtonHeight)/2 : 3*mnButtonHeight; ! ! for(int i=0;i<mpOptions->mnNumOptions;i++) { ! xpos = mnXStart; ! ! int nBoxWidth = maButtonPosition[i][mpOptions->maOptionInfo[i].mnStateCount-1].mnButtonX - maButtonPosition[i][0].mnTextX + 2*mnButtonWidth; ! mpBrush->SetColor(Color(0x60FFFFFF)); ! pGraphics->FillRectangle(mpBrush, ! maButtonPosition[i][0].mnTextX - mnButtonHeight/2, ypos - 3*mnButtonHeight/2, ! nBoxWidth, 2*mnButtonHeight); ! mpBrush->SetColor(Color(255,255,220,220)); ! for(int j=0;j<mpOptions->maOptionInfo[i].mnStateCount;j++) { ! sText = mpOptions->maOptionInfo[i].mzCaption[j]; ! MultiByteToWideChar(CP_ACP, 0, sText.GetBuffer(), -1, szwchar, 255); ! pGraphics->MeasureString(szwchar,-1,mpFont,PointF(0,0),&rstring); ! maButtonPosition[i][j].mnTextX = xpos; ! maButtonPosition[i][j].mnTextY = ypos-mnButtonHeight+2; ! xpos += (int)(rstring.Width) + 1; ! maButtonPosition[i][j].mnButtonX = xpos; ! maButtonPosition[i][j].mnButtonY = ypos-mnButtonHeight-mnButtonHeight/6; ! xpos += 3*mnButtonWidth; ! } ! pGraphics->DrawRectangle(mpPen, ! maButtonPosition[i][0].mnTextX - mnButtonHeight/2, ypos - 3*mnButtonHeight/2, ! nBoxWidth, 2*mnButtonHeight); ! ypos += buttonRowSpacing; ! } ! ! for(i=0;i<mpOptions->mnNumOptions;i++) { ! for(int j=0;j<mpOptions->maOptionInfo[i].mnStateCount;j++) { ! sText = mpOptions->maOptionInfo[i].mzCaption[j]; ! MultiByteToWideChar(CP_ACP, 0, sText.GetBuffer(), -1, szwchar, 255); ! pGraphics->DrawString(szwchar, -1, mpFont, ! PointF((float)maButtonPosition[i][j].mnTextX, (float)maButtonPosition[i][j].mnTextY), ! mpBrush); ! ! ! if (mpOptions->maOptionInfo[i].mnValue == j) { ! DrawButton(pGraphics,maButtonPosition[i][j].mnButtonX, ! maButtonPosition[i][j].mnButtonY,1); ! } ! else { ! DrawButton(pGraphics,maButtonPosition[i][j].mnButtonX, ! maButtonPosition[i][j].mnButtonY,0); ! } ! } ! } ! ! ReleaseGraphics(pGraphics); ! DrawBorder(); ! return true; } /*******************************************************************************/ void tcOptionsView::DrawButton(Graphics *apGraphics, int x, int y, int abOn) { ! Image *pButton; ! if (apGraphics == NULL) {return;} ! pButton = (abOn == 1) ? mpiButtonOn : mpiButtonOff; ! if (pButton == NULL) {return;} ! apGraphics->DrawImage(pButton,x,y); } /******************************************************************************/ void tcOptionsView::OnLButtonDown(wxMouseEvent& event) { ! bool bButtonClicked; ! int nOption, nValue; ! if (!mbActive) ! { ! event.Skip(); ! return; ! } ! ! // TranslatePoint(point); // adjust for flipped up/down ! bButtonClicked = ButtonContainingPoint(event.GetPosition(), nOption, nValue); ! if (bButtonClicked) { ! if ((nOption >= mpOptions->mnNumOptions)|| ! (nValue >= mpOptions->maOptionInfo[nOption].mnStateCount)) { ! WTL("tcOptionsView::OnLButtonDown error"); ! return; ! } ! mpOptions->maOptionInfo[nOption].mnValue = nValue; ! if (mpOptions->maOptionInfo[nOption].mpAssociated != NULL) { ! *mpOptions->maOptionInfo[nOption].mpAssociated = nValue; ! } ! mpOptions->Serialize(false); // create new options file ! if (mpSound != NULL) { ! mpSound->PlayEffect(SEFFECT_BEEP2); ! } ! } ! else ! { ! // switch back to start view if no buttons clicked (for now) ! wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, ID_STARTVIEW) ; ! command.SetEventObject(this); ! AddPendingEvent(command); ! } } /******************************************************************************/ bool tcOptionsView::ButtonContainingPoint(wxPoint point, int& rnOption, int& rnValue) { ! int i,j; ! int nx, ny; ! for(i=0;i<mpOptions->mnNumOptions;i++) { ! for(j=0;j<mpOptions->maOptionInfo[i].mnStateCount;j++) { ! nx = maButtonPosition[i][j].mnButtonX; ! ny = maButtonPosition[i][j].mnButtonY; ! wxRect cr(nx,ny,mnButtonWidth,mnButtonHeight); ! if (cr.Inside(point)) { ! rnOption = i; ! rnValue = j; ! return true; ! } ! } ! } ! return false; } *************** *** 248,282 **** tcOptionsView::tcOptionsView(wxWindow *parent, ! const wxPoint& pos, const wxSize& size, ! const wxString& name) : ! tcWindow(parent, pos, size, name) { ! mpiBackground = NULL; ! mpiButtonOn = NULL; ! mpiButtonOff = NULL; ! mpOptions = NULL; ! mpFont = NULL; ! mpBrush = NULL; ! mpSound = NULL; ! mnXStart = 100; ! mnYStart = 100; ! for(int i=0;i<N_OPTIONS;i++) ! { ! for(int k=0;k<N_OPTION_VALUES;k++) ! { ! maButtonPosition[i][k].mnButtonX = -100; ! maButtonPosition[i][k].mnButtonY = -100; ! maButtonPosition[i][k].mnTextX = -100; ! maButtonPosition[i][k].mnTextY = -100; ! } ! } } tcOptionsView::~tcOptionsView() { ! if (mpiBackground != NULL) {delete mpiBackground;} ! if (mpiButtonOn != NULL) {delete mpiButtonOn;} ! if (mpiButtonOff != NULL) {delete mpiButtonOff;} ! if (mpFont != NULL) {delete mpFont;} ! if (mpBrush != NULL) {delete mpBrush;} ! if (mpPen != NULL) {delete mpPen;} } --- 250,284 ---- tcOptionsView::tcOptionsView(wxWindow *parent, ! const wxPoint& pos, const wxSize& size, ! const wxString& name) : ! tcWindow(parent, pos, size, name) { ! mpiBackground = NULL; ! mpiButtonOn = NULL; ! mpiButtonOff = NULL; ! mpOptions = NULL; ! mpFont = NULL; ! mpBrush = NULL; ! mpSound = NULL; ! mnXStart = (size.GetWidth() < 1000) ? 60 : 100; ! mnYStart = (size.GetWidth() < 1000) ? 80 : 100; ! for(int i=0;i<N_OPTIONS;i++) ! { ! for(int k=0;k<N_OPTION_VALUES;k++) ! { ! maButtonPosition[i][k].mnButtonX = -100; ! maButtonPosition[i][k].mnButtonY = -100; ! maButtonPosition[i][k].mnTextX = -100; ! maButtonPosition[i][k].mnTextY = -100; ! } ! } } tcOptionsView::~tcOptionsView() { ! if (mpiBackground != NULL) {delete mpiBackground;} ! if (mpiButtonOn != NULL) {delete mpiButtonOn;} ! if (mpiButtonOff != NULL) {delete mpiButtonOff;} ! if (mpFont != NULL) {delete mpFont;} ! if (mpBrush != NULL) {delete mpBrush;} ! if (mpPen != NULL) {delete mpPen;} } Index: tcSound.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/tcSound.cpp,v retrieving revision 1.10 retrieving revision 1.10.2.1 diff -C2 -d -r1.10 -r1.10.2.1 *** tcSound.cpp 1 Jan 2004 23:44:46 -0000 1.10 --- tcSound.cpp 17 Feb 2004 14:27:02 -0000 1.10.2.1 *************** *** 91,95 **** LoadWavDataFromFile("Beep2.wav",SEFFECT_BEEP2); LoadWavDataFromFile("RejectBeep.wav",SEFFECT_REJECTBEEP); ! LoadWavDataFromFile("LightSaber.wav",SEFFECT_LIGHTSABER); LoadWavDataFromFile("Ping.wav",SEFFECT_PING); LoadWavDataFromFile("Ping2.wav",SEFFECT_PING2); --- 91,95 ---- LoadWavDataFromFile("Beep2.wav",SEFFECT_BEEP2); LoadWavDataFromFile("RejectBeep.wav",SEFFECT_REJECTBEEP); ! LoadWavDataFromFile("Ping.wav",SEFFECT_LIGHTSABER); LoadWavDataFromFile("Ping.wav",SEFFECT_PING); LoadWavDataFromFile("Ping2.wav",SEFFECT_PING2); *************** *** 149,153 **** --- 149,159 ---- strcat(zFilePath,azFileName); + fprintf(stdout," Loading effect: %d, wav: %s\n", anEffectID, zFilePath); alutLoadWAVFile((ALbyte*)zFilePath,&format,&wave,&size,&freq,&loop); + if (wave == NULL) + { + fprintf(stderr,"File not found, wav file %s\n",azFileName); + return false; + } if((err=alGetError())!=AL_NO_ERROR) { *************** *** 158,161 **** --- 164,172 ---- alutUnloadWAV(format,wave,size,freq); + if((err=alGetError())!=AL_NO_ERROR) + { + fprintf(stderr,"Error buffering wav file %s\n",azFileName); + return false; + } return true; } |