You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(44) |
Aug
(36) |
Sep
(5) |
Oct
|
Nov
(6) |
Dec
(2) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2008 |
Jan
|
Feb
|
Mar
|
Apr
(87) |
May
(54) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <dv...@us...> - 2006-11-21 18:47:33
|
Revision: 122 http://svn.sourceforge.net/dunelegacy/?rev=122&view=rev Author: dvalin Date: 2006-11-21 09:21:06 -0800 (Tue, 21 Nov 2006) Log Message: ----------- initialize closestPoint, from JttL Modified Paths: -------------- trunk/src/MapClass.cpp Modified: trunk/src/MapClass.cpp =================================================================== --- trunk/src/MapClass.cpp 2006-11-21 17:19:35 UTC (rev 121) +++ trunk/src/MapClass.cpp 2006-11-21 17:21:06 UTC (rev 122) @@ -414,9 +414,10 @@ { double closestDistance = 1000000000.0; COORDTYPE closestPoint, - size; + closestPoint.x = 0; + closestPoint.y = 0; UnitClass* unit = (UnitClass*)object; bool found = false, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2006-11-21 17:19:53
|
Revision: 121 http://svn.sourceforge.net/dunelegacy/?rev=121&view=rev Author: dvalin Date: 2006-11-21 09:19:35 -0800 (Tue, 21 Nov 2006) Log Message: ----------- fix my last screwup Modified Paths: -------------- trunk/src/Menu.cpp Modified: trunk/src/Menu.cpp =================================================================== --- trunk/src/Menu.cpp 2006-11-19 20:20:44 UTC (rev 120) +++ trunk/src/Menu.cpp 2006-11-21 17:19:35 UTC (rev 121) @@ -74,7 +74,7 @@ "Purple", "Orange", "Grey" -} +}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <shu...@us...> - 2006-09-28 11:21:21
|
Revision: 114 http://svn.sourceforge.net/dunelegacy/?rev=114&view=rev Author: shutdownrunner Date: 2006-09-28 04:21:14 -0700 (Thu, 28 Sep 2006) Log Message: ----------- - MapGenerator should load maps properly now. - Get a new archive with modified data(as the old one misses maps for Ordos). Just use the link from one of howtos. - I took missing maps from Dune 2 The Maker. Thank you Stefan and all the people participating in the project. Modified Paths: -------------- trunk/src/MapGenerator.cpp Modified: trunk/src/MapGenerator.cpp =================================================================== --- trunk/src/MapGenerator.cpp 2006-09-16 14:04:45 UTC (rev 113) +++ trunk/src/MapGenerator.cpp 2006-09-28 11:21:14 UTC (rev 114) @@ -841,7 +841,7 @@ { loc = strstr(line, "Seed=") ; if (loc) - { + { loc+=5; loc2 = strstr(loc, "\n"); loc2[0] = '\0'; @@ -854,8 +854,8 @@ for (z = 0; z < 4; z++) seedFileName[z] = temp[z];*/ char path[MAX_LINE] = "data/scenario/seed/"; - strncat(path, loc, MAX_LINE); - strncat(path, ".map", MAX_LINE); + strncat(path, loc, strlen(loc)-1); + strncat(path, ".map", 4); seedFile = fopen(path, "r"); if (!seedFile) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <shu...@us...> - 2006-09-16 14:04:58
|
Revision: 113 http://svn.sourceforge.net/dunelegacy/?rev=113&view=rev Author: shutdownrunner Date: 2006-09-16 07:04:45 -0700 (Sat, 16 Sep 2006) Log Message: ----------- - Added a rescaler for intro sequence (2x is enough, I guess) - A new function in gfx - scale2x(src surface, dst surface). Haven't given it a proper doxygen description yet. Modified Paths: -------------- branches/dunks/include/Gfx.h branches/dunks/include/IntroState.h branches/dunks/include/pakfile/Wsafile.h branches/dunks/src/Gfx.cpp branches/dunks/src/IntroState.cpp Modified: branches/dunks/include/Gfx.h =================================================================== --- branches/dunks/include/Gfx.h 2006-09-05 12:31:36 UTC (rev 112) +++ branches/dunks/include/Gfx.h 2006-09-16 14:04:45 UTC (rev 113) @@ -113,7 +113,7 @@ */ SDL_Surface* resizeSurface(SDL_Surface *surface, double ratio); - +void scale2x(SDL_Surface *src, SDL_Surface *dst); //@} //------------------------------------------------------------------------------ Modified: branches/dunks/include/IntroState.h =================================================================== --- branches/dunks/include/IntroState.h 2006-09-05 12:31:36 UTC (rev 112) +++ branches/dunks/include/IntroState.h 2006-09-16 14:04:45 UTC (rev 113) @@ -49,7 +49,7 @@ int m_currentFrame; float m_frametime; - SDL_Surface* m_animSurface; + SDL_Surface* m_animSurface, *m_scaledSurface; SDL_Color* m_transitionPalette; void setupTransitionIn(); @@ -90,4 +90,6 @@ Frame* m_currentFrame; }; + + #endif // DUNE_INTROSTATE_H Modified: branches/dunks/include/pakfile/Wsafile.h =================================================================== --- branches/dunks/include/pakfile/Wsafile.h 2006-09-05 12:31:36 UTC (rev 112) +++ branches/dunks/include/pakfile/Wsafile.h 2006-09-16 14:04:45 UTC (rev 113) @@ -17,7 +17,7 @@ inline int getNumFrames() { return (int) NumFrames; }; inline Uint32 getFramesPer1024ms() { return FramesPer1024ms; }; - inline float getFPS() { return fps; } + inline float getFPS() { return fps; } private: void decodeFrames(); Modified: branches/dunks/src/Gfx.cpp =================================================================== --- branches/dunks/src/Gfx.cpp 2006-09-05 12:31:36 UTC (rev 112) +++ branches/dunks/src/Gfx.cpp 2006-09-16 14:04:45 UTC (rev 113) @@ -310,13 +310,60 @@ return resized; } - SDL_Surface* resizeSurface(SDL_Surface *surface, double ratio) { assert(surface != NULL); return resizeSurface(surface, (Uint16)(surface->w*ratio), (Uint16)(surface->h*ratio)); } +// Defines used by scale2x + +#ifndef MAX +#define MAX(a,b) (((a) > (b)) ? (a) : (b)) +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) +#endif + + +#define READINT24(x) ((x)[0]<<16 | (x)[1]<<8 | (x)[2]) +#define WRITEINT24(x, i) {(x)[0]=i>>16; (x)[1]=(i>>8)&0xff; x[2]=i&0xff; } + + +void scale2x(SDL_Surface *src, SDL_Surface *dst) +{ + int looph, loopw; + + Uint8* srcpix = (Uint8*)src->pixels; + Uint8* dstpix = (Uint8*)dst->pixels; + + const int srcpitch = src->pitch; + const int dstpitch = dst->pitch; + const int width = src->w; + const int height = src->h; + + + Uint8 E0, E1, E2, E3, B, D, E, F, H; + for(looph = 0; looph < height; ++looph) + { + for(loopw = 0; loopw < width; ++ loopw) + { + B = *(Uint8*)(srcpix + (MAX(0,looph-1)*srcpitch) + (1*loopw)); + D = *(Uint8*)(srcpix + (looph*srcpitch) + (1*MAX(0,loopw-1))); + E = *(Uint8*)(srcpix + (looph*srcpitch) + (1*loopw)); + F = *(Uint8*)(srcpix + (looph*srcpitch) + (1*MIN(width-1,loopw+1))); + H = *(Uint8*)(srcpix + (MIN(height-1,looph+1)*srcpitch) + (1*loopw)); + + E0 = D == B && B != F && D != H ? D : E; + E1 = B == F && B != D && F != H ? F : E; + E2 = D == H && D != B && H != F ? D : E; + E3 = H == F && D != H && B != F ? F : E; + + *(Uint8*)(dstpix + looph*2*dstpitch + loopw*2*1) = E0; + *(Uint8*)(dstpix + looph*2*dstpitch + (loopw*2+1)*1) = E1; + *(Uint8*)(dstpix + (looph*2+1)*dstpitch + loopw*2*1) = E2; + *(Uint8*)(dstpix + (looph*2+1)*dstpitch + (loopw*2+1)*1) = E3; + } + } +} //------------------------------------------------------------------------------ // Color mapping //------------------------------------------------------------------------------ Modified: branches/dunks/src/IntroState.cpp =================================================================== --- branches/dunks/src/IntroState.cpp 2006-09-05 12:31:36 UTC (rev 112) +++ branches/dunks/src/IntroState.cpp 2006-09-16 14:04:45 UTC (rev 113) @@ -46,10 +46,24 @@ SDL_Palette* palette = Application::Instance()->Screen()->format->palette; m_animSurface = m_wsa->getPicture(m_currentFrame, palette); + + SDL_FreeSurface(m_scaledSurface); + + m_scaledSurface = + SDL_CreateRGBSurface(SDL_SWSURFACE, + m_animSurface->w*2, + m_animSurface->h*2, + 8, + 0,0,0,0); + + SDL_SetColors(m_scaledSurface, palette->colors, 0, palette->ncolors); + + scale2x(m_animSurface, m_scaledSurface); } bool IntroState::Frame::Execute(float dt) { + switch (m_state) { case TRANSITION_IN: @@ -69,8 +83,9 @@ break; }; - assert(m_animSurface != NULL); - Application::Instance()->BlitCentered(m_animSurface); + assert(m_scaledSurface != NULL); + + Application::Instance()->BlitCentered(m_scaledSurface); return mb_finished; } @@ -92,6 +107,19 @@ { SDL_Palette* palette = Application::Instance()->Screen()->format->palette; m_animSurface = m_wsa->getPicture(m_currentFrame, palette); + + SDL_FreeSurface(m_scaledSurface); + + m_scaledSurface = + SDL_CreateRGBSurface(SDL_SWSURFACE, + m_animSurface->w*2, + m_animSurface->h*2, + 8, + 0,0,0,0); + + SDL_SetColors(m_scaledSurface, palette->colors, 0, palette->ncolors); + + scale2x(m_animSurface, m_scaledSurface); }; }; } @@ -133,7 +161,7 @@ if (m_transitionPalette == NULL) setupTransitionOut(); bool done = true; - SDL_Surface* screen = m_animSurface; //Application::Instance()->Screen(); + SDL_Surface* screen = m_scaledSurface; //Application::Instance()->Screen(); SDL_Color* col = m_transitionPalette; const int fadeAmt = 3; @@ -176,7 +204,7 @@ Frame::NO_TRANSITION, Frame::FADE_OUT, false) ); - /*enque( new Frame("INTRO:INTRO2.WSA", + enque( new Frame("INTRO:INTRO2.WSA", Frame::NO_TRANSITION, Frame::FADE_OUT, false) ); @@ -195,7 +223,7 @@ enque( new Frame("INTRO:INTRO6.WSA", Frame::NO_TRANSITION, Frame::FADE_OUT, - false) ); + false) ); enque( new Frame("INTRO:INTRO7A.WSA", Frame::NO_TRANSITION, Frame::NO_TRANSITION, @@ -232,7 +260,7 @@ enque( new Frame("INTRO:INTRO1.WSA", Frame::NO_TRANSITION, Frame::FADE_OUT, - false) );*/ + false) ); next(); m_butIntro = new TranspButton(Settings::Instance()->GetWidth(), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <shu...@us...> - 2006-09-05 12:31:58
|
Revision: 112 http://svn.sourceforge.net/dunelegacy/?rev=112&view=rev Author: shutdownrunner Date: 2006-09-05 05:31:36 -0700 (Tue, 05 Sep 2006) Log Message: ----------- - Fixed what d1223m in revision 108(@d1233m any suggestions?) - Added redraw() to BoringButton::setSize and BoringButton::setCaption so that it doesn't have to be repeated in each state hundreds of times Revision Links: -------------- http://svn.sourceforge.net/dunelegacy/?rev=108&view=rev Modified Paths: -------------- branches/dunks/include/gui2/Button.h branches/dunks/include/gui2/Widget.h branches/dunks/src/Application.cpp branches/dunks/src/MainMenu.cpp branches/dunks/src/SingleMenu.cpp branches/dunks/src/gui2/Button.cpp branches/dunks/src/gui2/Widget.cpp Modified: branches/dunks/include/gui2/Button.h =================================================================== --- branches/dunks/include/gui2/Button.h 2006-09-05 08:32:36 UTC (rev 111) +++ branches/dunks/include/gui2/Button.h 2006-09-05 12:31:36 UTC (rev 112) @@ -42,7 +42,7 @@ BoringButton(std::string caption); ~BoringButton(); - //virtual void setSize(Uint16 w, Uint16 h); + virtual void setSize(SPoint p); std::string getCaption() { return m_caption;} ; void setCaption(std::string newcaption); virtual void redraw(); Modified: branches/dunks/include/gui2/Widget.h =================================================================== --- branches/dunks/include/gui2/Widget.h 2006-09-05 08:32:36 UTC (rev 111) +++ branches/dunks/include/gui2/Widget.h 2006-09-05 12:31:36 UTC (rev 112) @@ -33,14 +33,14 @@ @param p cursor location relative to the widget @return true if the event was handled */ - virtual bool handleButtonDown(Uint8 button, SPoint &p); + virtual bool handleButtonDown(Uint8 button, SPoint p); /*! called when a mouse button is released @param button button number. You can use SDL button constants. @param p cursor location relative to the widget @return true if the event was handled */ - virtual bool handleButtonUp(Uint8 button, SPoint &p); + virtual bool handleButtonUp(Uint8 button, SPoint p); /*! called when a key is pressed Modified: branches/dunks/src/Application.cpp =================================================================== --- branches/dunks/src/Application.cpp 2006-09-05 08:32:36 UTC (rev 111) +++ branches/dunks/src/Application.cpp 2006-09-05 12:31:36 UTC (rev 112) @@ -409,7 +409,6 @@ case SDL_MOUSEBUTTONDOWN: m_rootWidget->handleButtonDown( event.button.button, SPoint(event.button.x, event.button.y)); - printf("X:%d, Y:%d\n", event.button.x, event.button.y); break; case SDL_MOUSEBUTTONUP: m_rootWidget->handleButtonUp( event.button.button, Modified: branches/dunks/src/MainMenu.cpp =================================================================== --- branches/dunks/src/MainMenu.cpp 2006-09-05 08:32:36 UTC (rev 111) +++ branches/dunks/src/MainMenu.cpp 2006-09-05 12:31:36 UTC (rev 112) @@ -24,7 +24,6 @@ m_butSingle = new BoringButton("Single Player"); m_butSingle->setSize(SPoint(bw, bh)); - m_butSingle->redraw(); //m_butSingle = new GraphicButton((SDL_Surface*)(dataFile[UI_Single].dat), // (SDL_Surface*)(dataFile[UI_Single_Pressed].dat)); m_butSingle->onClick.connect( @@ -33,8 +32,7 @@ m_vbox->addChild(m_butSingle); m_butMulti = new BoringButton("Multi Player"); - m_butMulti->setSize(UPoint(bw, bh)); - m_butMulti->redraw(); + m_butMulti->setSize(SPoint(bw, bh)); //m_butMulti = new GraphicButton((SDL_Surface*)(dataFile[UI_Multi].dat), // (SDL_Surface*)(dataFile[UI_Multi_Pressed].dat)); m_butMulti->onClick.connect( @@ -43,8 +41,7 @@ m_vbox->addChild(m_butMulti); m_butMapEd = new BoringButton("Map Editor"); - m_butMapEd->setSize(UPoint(bw, bh)); - m_butMapEd->redraw(); + m_butMapEd->setSize(SPoint(bw, bh)); //m_butMapEd = new GraphicButton((SDL_Surface*)(dataFile[UI_MapEdit].dat), // (SDL_Surface*)(dataFile[UI_MapEdit_Pressed].dat)); m_butMapEd->onClick.connect( @@ -53,8 +50,7 @@ m_vbox->addChild(m_butMapEd); m_butOptions = new BoringButton("Options"); - m_butOptions->setSize(UPoint(bw, bh)); - m_butOptions->redraw(); + m_butOptions->setSize(SPoint(bw, bh)); //m_butOptions = new GraphicButton((SDL_Surface*)(dataFile[UI_OptionsMM].dat), // (SDL_Surface*)(dataFile[UI_OptionsMM_Pressed].dat)); m_butOptions->onClick.connect( @@ -63,8 +59,7 @@ m_vbox->addChild(m_butOptions); m_butAbout = new BoringButton("About"); - m_butAbout->setSize(UPoint(bw, bh)); - m_butAbout->redraw(); + m_butAbout->setSize(SPoint(bw, bh)); //m_butAbout = new GraphicButton((SDL_Surface*)(dataFile[UI_About].dat), // (SDL_Surface*)(dataFile[UI_About_Pressed].dat)); m_butAbout->onClick.connect( @@ -73,8 +68,7 @@ m_vbox->addChild(m_butAbout); m_butQuit = new BoringButton("Quit"); - m_butQuit->setSize(UPoint(bw, bh)); - m_butQuit->redraw(); + m_butQuit->setSize(SPoint(bw, bh)); //m_butQuit = new GraphicButton((SDL_Surface*)(dataFile[UI_Quit].dat), // (SDL_Surface*)(dataFile[UI_Quit_Pressed].dat)); m_butQuit->onClick.connect( Modified: branches/dunks/src/SingleMenu.cpp =================================================================== --- branches/dunks/src/SingleMenu.cpp 2006-09-05 08:32:36 UTC (rev 111) +++ branches/dunks/src/SingleMenu.cpp 2006-09-05 12:31:36 UTC (rev 112) @@ -10,40 +10,40 @@ SingleMenuState::SingleMenuState() { const int bw = 200; - const int bh = 20; + const int bh = 24; m_vbox = new VBox(); m_butCampaign = new BoringButton("Campaign"); - m_butCampaign->setSize(UPoint(bw, bh)); + m_butCampaign->setSize(SPoint(bw, bh)); m_butCampaign->onClick.connect( boost::bind(&SingleMenuState::doSkirmish, this) ); m_vbox->addChild(m_butCampaign); m_butCustom = new BoringButton("Custom Game"); - m_butCustom->setSize(UPoint(bw,bh)); + m_butCustom->setSize(SPoint(bw,bh)); m_butCustom->onClick.connect( boost::bind(&SingleMenuState::doSkirmish, this) ); m_vbox->addChild(m_butCustom); m_butSkirmish = new BoringButton("Skirmish"); - m_butSkirmish->setSize(UPoint(bw, bh)); + m_butSkirmish->setSize(SPoint(bw, bh)); m_butSkirmish->onClick.connect( boost::bind(&SingleMenuState::doSkirmish, this) ); m_vbox->addChild(m_butSkirmish); m_butLoad = new BoringButton("Load Game"); - m_butLoad->setSize(UPoint(bw, bh)); + m_butLoad->setSize(SPoint(bw, bh)); m_butLoad->onClick.connect( boost::bind(&SingleMenuState::doSkirmish, this) ); m_vbox->addChild(m_butLoad); m_butCancel = new BoringButton("Cancel"); - m_butCancel->setSize(UPoint(bw, bh)); + m_butCancel->setSize(SPoint(bw, bh)); m_butCancel->onClick.connect( boost::bind(&SingleMenuState::doCancel, this) ); Modified: branches/dunks/src/gui2/Button.cpp =================================================================== --- branches/dunks/src/gui2/Button.cpp 2006-09-05 08:32:36 UTC (rev 111) +++ branches/dunks/src/gui2/Button.cpp 2006-09-05 12:31:36 UTC (rev 112) @@ -43,7 +43,7 @@ void GraphicButton::draw(SDL_Surface* dest, SPoint off) { if (!m_visible) return; - + Rect destrect (off.x + x, off.y + y, 0, 0); if (m_pressed) @@ -92,14 +92,14 @@ SDL_FreeSurface(m_surfPressed); } -/* -void BoringButton::setSize(Uint16 w, Uint16 h) + +void BoringButton::setSize(SPoint p) { - GraphicButton::setSize(w, h); + Widget::setSize(p); redraw(); } -*/ + void BoringButton::setCaption(std::string newcaption) { m_caption = newcaption; @@ -159,25 +159,25 @@ * Button pressed */ // top lines -// drawHLine(m_surfPressed, 0, 0, w-1, 229, false); - // drawHLine(m_surfPressed, 0, 1, w-3, 226, false); + drawHLine(m_surfPressed, 0, 0, w-1, 229, false); + drawHLine(m_surfPressed, 0, 1, w-3, 226, false); // left lines -// drawVLine(m_surfPressed, 0, 0, h-1, 229, false); - // drawVLine(m_surfPressed, 1, 1, h-2, 226, false); + drawVLine(m_surfPressed, 0, 0, h-1, 229, false); + drawVLine(m_surfPressed, 1, 1, h-2, 226, false); // bottom lines -//drawHLine(m_surfPressed, 1, h-2, w-2, 226, false); -//drawHLine(m_surfPressed, 0, h-1, w-1, 229, false); + drawHLine(m_surfPressed, 1, h-2, w-2, 226, false); + drawHLine(m_surfPressed, 0, h-1, w-1, 229, false); // right lines - // drawVLine(m_surfPressed, w-1, 0, h-1, 229, false); - // drawVLine(m_surfPressed, w-2, 1, h-2, 226, false); + drawVLine(m_surfPressed, w-1, 0, h-1, 229, false); + drawVLine(m_surfPressed, w-2, 1, h-2, 226, false); // final pixels to make it look really duneish - // putPixel(m_surfPressed, 1, h-2, 227); - // putPixel(m_surfPressed, w-2, 1, 227); - // putPixel(m_surfPressed, w-2, h-2, 227); + putPixel(m_surfPressed, 1, h-2, 227); + putPixel(m_surfPressed, w-2, 1, 227); + putPixel(m_surfPressed, w-2, h-2, 227); Font* font = FontManager::Instance()->getFont("INTRO:INTRO.FNT"); Modified: branches/dunks/src/gui2/Widget.cpp =================================================================== --- branches/dunks/src/gui2/Widget.cpp 2006-09-05 08:32:36 UTC (rev 111) +++ branches/dunks/src/gui2/Widget.cpp 2006-09-05 12:31:36 UTC (rev 112) @@ -18,13 +18,13 @@ return false; } -bool Widget::handleButtonDown(Uint8 button, SPoint& p) +bool Widget::handleButtonDown(Uint8 button, SPoint p) { if (contains(p)) return true; return false; } -bool Widget::handleButtonUp(Uint8 button, SPoint& p) +bool Widget::handleButtonUp(Uint8 button, SPoint p) { if (contains(p)) return true; return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2006-09-05 08:32:48
|
Revision: 111 http://svn.sourceforge.net/dunelegacy/?rev=111&view=rev Author: dvalin Date: 2006-09-05 01:32:36 -0700 (Tue, 05 Sep 2006) Log Message: ----------- fix typo reported by SamChi Modified Paths: -------------- trunk/src/MentatClass.cpp Modified: trunk/src/MentatClass.cpp =================================================================== --- trunk/src/MentatClass.cpp 2006-09-02 16:28:26 UTC (rev 110) +++ trunk/src/MentatClass.cpp 2006-09-05 08:32:36 UTC (rev 111) @@ -822,7 +822,7 @@ LoadMentatEntry(Mentat_MCV, FRAMES_MCV, "mentat/data/mcv", "Mobile Construction Vehicle"); LoadMentatEntry(Mentat_Deviator, FRAMES_DEVIATOR, "mentat/data/ordrtank", "Deviator"); LoadMentatEntry(Mentat_Ornithopter, FRAMES_ORNI, "mentat/data/orni", "Ornithopter"); - LoadMentatEntry(Mentat_Raider, FRAMES_RADAR, "mentat/data/otrike", "Raider"); + LoadMentatEntry(Mentat_Raider, FRAMES_RAIDER, "mentat/data/otrike", "Raider"); LoadMentatEntry(Mentat_Palace, FRAMES_PALACE, "mentat/data/palace", "Palace"); LoadMentatEntry(Mentat_Quad, FRAMES_QUAD, "mentat/data/quad", "Quad"); LoadMentatEntry(Mentat_Refinery, FRAMES_REFINERY, "mentat/data/refinery", "Refinery"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <shu...@us...> - 2006-09-02 16:29:32
|
Revision: 110 http://svn.sourceforge.net/dunelegacy/?rev=110&view=rev Author: shutdownrunner Date: 2006-09-02 09:28:26 -0700 (Sat, 02 Sep 2006) Log Message: ----------- - Make dunelegacy compilable - No buttons are clickable. No idea why. Yet Modified Paths: -------------- branches/dunks/include/gui2/Widget.h branches/dunks/src/Application.cpp branches/dunks/src/IntroState.cpp branches/dunks/src/MainMenu.cpp branches/dunks/src/MenuBase.cpp branches/dunks/src/OptionsMenu.cpp branches/dunks/src/SConscript branches/dunks/src/SingleMenu.cpp branches/dunks/src/gui2/Button.cpp Modified: branches/dunks/include/gui2/Widget.h =================================================================== --- branches/dunks/include/gui2/Widget.h 2006-08-25 11:01:06 UTC (rev 109) +++ branches/dunks/include/gui2/Widget.h 2006-09-02 16:28:26 UTC (rev 110) @@ -15,7 +15,7 @@ virtual ~Widget(); //@} - virtual void draw(SDL_Surface* dest, SPoint &off) {} + virtual void draw(SDL_Surface* dest, SPoint off) {} //! @name Event handling functions //@{ Modified: branches/dunks/src/Application.cpp =================================================================== --- branches/dunks/src/Application.cpp 2006-08-25 11:01:06 UTC (rev 109) +++ branches/dunks/src/Application.cpp 2006-09-02 16:28:26 UTC (rev 110) @@ -22,7 +22,7 @@ #include "Settings.h" #include "Font.h" #include "TopLevelState.h" -#include "DataFile.h" +//#include "DataFile.h" #include "pakfile/Palette.h" #include "pakfile/Shpfile.h" @@ -409,6 +409,7 @@ case SDL_MOUSEBUTTONDOWN: m_rootWidget->handleButtonDown( event.button.button, SPoint(event.button.x, event.button.y)); + printf("X:%d, Y:%d\n", event.button.x, event.button.y); break; case SDL_MOUSEBUTTONUP: m_rootWidget->handleButtonUp( event.button.button, Modified: branches/dunks/src/IntroState.cpp =================================================================== --- branches/dunks/src/IntroState.cpp 2006-08-25 11:01:06 UTC (rev 109) +++ branches/dunks/src/IntroState.cpp 2006-09-02 16:28:26 UTC (rev 110) @@ -176,7 +176,7 @@ Frame::NO_TRANSITION, Frame::FADE_OUT, false) ); - enque( new Frame("INTRO:INTRO2.WSA", + /*enque( new Frame("INTRO:INTRO2.WSA", Frame::NO_TRANSITION, Frame::FADE_OUT, false) ); @@ -232,7 +232,7 @@ enque( new Frame("INTRO:INTRO1.WSA", Frame::NO_TRANSITION, Frame::FADE_OUT, - false) ); + false) );*/ next(); m_butIntro = new TranspButton(Settings::Instance()->GetWidth(), Modified: branches/dunks/src/MainMenu.cpp =================================================================== --- branches/dunks/src/MainMenu.cpp 2006-08-25 11:01:06 UTC (rev 109) +++ branches/dunks/src/MainMenu.cpp 2006-09-02 16:28:26 UTC (rev 110) @@ -1,7 +1,7 @@ #include "MainMenu.h" #include "Application.h" -#include "DataFile.h" +//#include "DataFile.h" #include "Settings.h" #include "SingleMenu.h" Modified: branches/dunks/src/MenuBase.cpp =================================================================== --- branches/dunks/src/MenuBase.cpp 2006-08-25 11:01:06 UTC (rev 109) +++ branches/dunks/src/MenuBase.cpp 2006-09-02 16:28:26 UTC (rev 110) @@ -1,7 +1,7 @@ #include "MainMenu.h" #include "Application.h" -#include "DataFile.h" +//#include "DataFile.h" #include "Settings.h" #include "SingleMenu.h" Modified: branches/dunks/src/OptionsMenu.cpp =================================================================== --- branches/dunks/src/OptionsMenu.cpp 2006-08-25 11:01:06 UTC (rev 109) +++ branches/dunks/src/OptionsMenu.cpp 2006-09-02 16:28:26 UTC (rev 110) @@ -1,7 +1,7 @@ #include "OptionsMenu.h" #include "Application.h" -#include "DataFile.h" +//#include "DataFile.h" #include "Settings.h" #include "boost/bind.hpp" Modified: branches/dunks/src/SConscript =================================================================== --- branches/dunks/src/SConscript 2006-08-25 11:01:06 UTC (rev 109) +++ branches/dunks/src/SConscript 2006-09-02 16:28:26 UTC (rev 110) @@ -17,7 +17,7 @@ "Settings.cpp", "Font.cpp", "State.cpp", - "DataFile.cpp", +# "DataFile.cpp", "TopLevelState.cpp", "MenuBase.cpp", Modified: branches/dunks/src/SingleMenu.cpp =================================================================== --- branches/dunks/src/SingleMenu.cpp 2006-08-25 11:01:06 UTC (rev 109) +++ branches/dunks/src/SingleMenu.cpp 2006-09-02 16:28:26 UTC (rev 110) @@ -1,7 +1,7 @@ #include "SingleMenu.h" #include "Application.h" -#include "DataFile.h" +//#include "DataFile.h" #include "Settings.h" #include "boost/bind.hpp" Modified: branches/dunks/src/gui2/Button.cpp =================================================================== --- branches/dunks/src/gui2/Button.cpp 2006-08-25 11:01:06 UTC (rev 109) +++ branches/dunks/src/gui2/Button.cpp 2006-09-02 16:28:26 UTC (rev 110) @@ -146,13 +146,13 @@ drawHLine(m_surfNormal, 0, h-1, w-1, 229, false); // right lines - drawVLine(m_surfNormal, w-1, 0, w-1, 229, false); - drawVLine(m_surfNormal, w-2, 1, w-2, 226, false); + drawVLine(m_surfNormal, w-1, 0, h-1, 229, false); + drawVLine(m_surfNormal, w-2, 1, h-2, 226, false); // final pixels to make it look really duneish - // putPixel(m_surfNormal, 1, h-2, 115); - // putPixel(m_surfNormal, w-2, 1, 115); - // putPixel(m_surfNormal, w-2, h-2, 227); + putPixel(m_surfNormal, 1, h-2, 115); + putPixel(m_surfNormal, w-2, 1, 115); + putPixel(m_surfNormal, w-2, h-2, 227); /* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dun...@us...> - 2006-08-16 08:21:38
|
Revision: 105 Author: dunkfordyce Date: 2006-08-16 01:21:30 -0700 (Wed, 16 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=105&view=rev Log Message: ----------- moving old files Added Paths: ----------- branches/dunks/old/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otp...@us...> - 2006-08-11 09:25:44
|
Revision: 103 Author: otpetrik Date: 2006-08-11 02:25:36 -0700 (Fri, 11 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=103&view=rev Log Message: ----------- - Settings.cpp fixed, config.txt no longer needed - removed config.txt from svn Modified Paths: -------------- branches/dunks/src/Settings.cpp Removed Paths: ------------- branches/dunks/config.txt Deleted: branches/dunks/config.txt =================================================================== --- branches/dunks/config.txt 2006-08-11 07:47:25 UTC (rev 102) +++ branches/dunks/config.txt 2006-08-11 09:25:36 UTC (rev 103) @@ -1,10 +0,0 @@ -{ - data_dir = "paks/"; - debug = false; - graphics = { - double_buffer = false; - fullscreen = false; - height = 480; - width = 640; - }; -} Modified: branches/dunks/src/Settings.cpp =================================================================== --- branches/dunks/src/Settings.cpp 2006-08-11 07:47:25 UTC (rev 102) +++ branches/dunks/src/Settings.cpp 2006-08-11 09:25:36 UTC (rev 103) @@ -28,10 +28,17 @@ void Settings::load() { const char* settingsfile = "CONFIG:config.txt"; - if (ResMan::Instance()->exists(settingsfile)) - { - String configText = ResMan::Instance()->readText(settingsfile); - configFile = ConfigFile::loadFile(configText.c_str()); + + // try loading config file + if (ResMan::Instance()->exists(settingsfile)) + { + String configText = ResMan::Instance()->readText(settingsfile); + configFile = ConfigFile::loadFile(configText.c_str()); + } + else + { + // just parse empty string... + configFile = ConfigFile::loadFile(""); }; ConfigFile::bind(".graphics.width", configFile, m_width, 640); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dun...@us...> - 2006-08-11 07:47:40
|
Revision: 102 Author: dunkfordyce Date: 2006-08-11 00:47:25 -0700 (Fri, 11 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=102&view=rev Log Message: ----------- - added ResMan::exists and Resource::exists to check if a file exists in a resource. ( otpetrik: added code to Settings.cpp but I think it needs more from you to make it work ) - fixed compiler warnings Modified Paths: -------------- branches/dunks/include/ResMan.h branches/dunks/include/pakfile/Pakfile.h branches/dunks/src/Application.cpp branches/dunks/src/ResMan.cpp branches/dunks/src/Settings.cpp Modified: branches/dunks/include/ResMan.h =================================================================== --- branches/dunks/include/ResMan.h 2006-08-10 22:28:09 UTC (rev 101) +++ branches/dunks/include/ResMan.h 2006-08-11 07:47:25 UTC (rev 102) @@ -82,6 +82,11 @@ */ inline bool isWritable() { return mb_writable; } + /*! + return true if the file exists + */ + virtual bool exists(std::string path) { return false; } + protected: boost::filesystem::path m_path; @@ -98,6 +103,7 @@ DIRResource(boost::filesystem::path path) ; unsigned char* readFile(std::string path, int *size); std::string readText(std::string path); + bool exists(std::string path); }; /*! @@ -119,7 +125,7 @@ PAKResource(boost::filesystem::path path) ; ~PAKResource(); unsigned char* readFile(std::string path, int *size); - + bool exists(std::string path); private: Pakfile *m_pakfile; }; @@ -188,6 +194,12 @@ */ virtual void writeText(std::string path, std::string text); //@} + + /*! + return true if the path exists + */ + bool exists(std::string path); + private: ResList m_resources; }; Modified: branches/dunks/include/pakfile/Pakfile.h =================================================================== --- branches/dunks/include/pakfile/Pakfile.h 2006-08-10 22:28:09 UTC (rev 101) +++ branches/dunks/include/pakfile/Pakfile.h 2006-08-11 07:47:25 UTC (rev 102) @@ -6,7 +6,7 @@ struct PakFileEntry { long StartOffset; long EndOffset; - char * Filename; + char* Filename; // dunk - better to be const char* ? ( or even std::string ? ) }; class Pakfile Modified: branches/dunks/src/Application.cpp =================================================================== --- branches/dunks/src/Application.cpp 2006-08-10 22:28:09 UTC (rev 101) +++ branches/dunks/src/Application.cpp 2006-08-11 07:47:25 UTC (rev 102) @@ -442,16 +442,16 @@ if (m_cursorFrame == CURSOR_RIGHT) { - dest.x -= dest.w/2; + dest.x -= surface->w/2; } else if (m_cursorFrame == CURSOR_DOWN) { - dest.y -= dest.h/2; + dest.y -= surface->w/2; } else if ((m_cursorFrame == CURSOR_TARGET) || (m_cursorFrame == CURSOR_SELECTION)) { - dest.x -= dest.w/2; - dest.y -= dest.h/2; + dest.x -= surface->w/2; + dest.y -= surface->h/2; } SDL_BlitSurface(surface, NULL, m_screen, &dest); Modified: branches/dunks/src/ResMan.cpp =================================================================== --- branches/dunks/src/ResMan.cpp 2006-08-10 22:28:09 UTC (rev 101) +++ branches/dunks/src/ResMan.cpp 2006-08-11 07:47:25 UTC (rev 102) @@ -99,6 +99,12 @@ return file_contents; }; +bool DIRResource::exists(std::string path) +{ + bfs::path fullpath(m_path); + fullpath /= path; + return bfs::exists(fullpath); +}; // ------------------------------------------------------------------ @@ -146,6 +152,15 @@ return buf; }; +bool PAKResource::exists(std::string path) +{ + for (int i=0; i!= m_pakfile->getNumFiles(); i++) + { + if (m_pakfile->getFilename(i) == path) return true; + }; + return false; +}; + // ------------------------------------------------------------------ ResMan::ResMan() @@ -227,6 +242,19 @@ return res; }; +bool ResMan::exists(std::string path) +{ + std::string filename; + Resource* res = getResource(path, filename); + + if (res == NULL) + { + return false; + }; + + return res->exists(filename); +}; + unsigned char* ResMan::readFile(std::string name, int *size) { std::string filename; Modified: branches/dunks/src/Settings.cpp =================================================================== --- branches/dunks/src/Settings.cpp 2006-08-10 22:28:09 UTC (rev 101) +++ branches/dunks/src/Settings.cpp 2006-08-11 07:47:25 UTC (rev 102) @@ -27,8 +27,13 @@ void Settings::load() { - String configText = ResMan::Instance()->readText("CONFIG:config.txt"); - configFile = ConfigFile::loadFile(configText.c_str()); + const char* settingsfile = "CONFIG:config.txt"; + if (ResMan::Instance()->exists(settingsfile)) + { + String configText = ResMan::Instance()->readText(settingsfile); + configFile = ConfigFile::loadFile(configText.c_str()); + }; + ConfigFile::bind(".graphics.width", configFile, m_width, 640); ConfigFile::bind(".graphics.height", configFile, m_height, 480); ConfigFile::bind(".graphics.fullscreen", configFile, m_fullscreen, false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otp...@us...> - 2006-08-10 22:28:18
|
Revision: 101 Author: otpetrik Date: 2006-08-10 15:28:09 -0700 (Thu, 10 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=101&view=rev Log Message: ----------- - config file fix, parts of file can be missing now - the file itself has to exist (even empty) ResMan fails while trying to load non-existent file and there is no way to query it... - make log more safer (and slower) by fflushing it after every line (usefull for crashes) Modified Paths: -------------- branches/dunks/include/ConfigFile.h branches/dunks/src/ConfigFile.cpp branches/dunks/src/Log.cpp branches/dunks/src/Settings.cpp Modified: branches/dunks/include/ConfigFile.h =================================================================== --- branches/dunks/include/ConfigFile.h 2006-08-10 17:27:06 UTC (rev 100) +++ branches/dunks/include/ConfigFile.h 2006-08-10 22:28:09 UTC (rev 101) @@ -194,6 +194,17 @@ typedef std::vector<NodePtr> ArrayNodeNodes; typedef std::map<const String, NodePtr> MapNodeNodes; + +//! vector of path elements +/*! + Holds parsed path, every string is name of a child. + (eg: "[3]" for array or ".test" for map) + + @note + It is possoble to determine the type of parent by the name of a child +*/ +typedef std::vector<String> ParsedPath; + //------------------------------------------------------------------------------ // Node class //------------------------------------------------------------------------------ @@ -236,11 +247,24 @@ //! @name Accessing child nodes //@{ - //! Save contents of current node + //! Return an node deeper in the tree /*! @param path input cache containing the path to the node (eg: something.another[2].thing) */ virtual NodePtr getNode(StringInputCache &path) = 0; + + //! Return an child node + /*! + @param child name of the child (eg. ".mychild" or "[2]") + */ + virtual NodePtr getChild(ConstString child) = 0; + + //! Add an child to this node + /*! + @param name name of the child (eg. ".mychild" or "[2]") + @param child the child node + */ + virtual void addChild(ConstString name, NodePtr child) = 0; //@} protected: @@ -260,6 +284,8 @@ virtual void save(StringOutputCache &cache); virtual NodePtr getNode(StringInputCache &path); + virtual NodePtr getChild(ConstString child); + virtual void addChild(ConstString name, NodePtr child); //! Return underlying std::vector /*! @@ -286,6 +312,8 @@ virtual void save(StringOutputCache &cache); virtual NodePtr getNode(StringInputCache &path); + virtual NodePtr getChild(ConstString child); + virtual void addChild(ConstString name, NodePtr child); //! Return underlying std::map /*! @@ -330,6 +358,8 @@ virtual void save(StringOutputCache &cache); virtual NodePtr getNode(StringInputCache &path); + virtual NodePtr getChild(ConstString child); + virtual void addChild(ConstString name, NodePtr child); //! @name Value access //@{ @@ -342,8 +372,8 @@ @warning It is your responsibility to set the string to a value, that can be parsed again - TODO: Remove this warning once there is protection agains special chars - (add escape & unescape to Strings) + TODO: Remove this warning once there is protection agains special chars (add escape & unescape to Strings) + (for now, it should be safe if not using " in value) */ void setValue(ConstString value); @@ -381,6 +411,68 @@ // Functions //------------------------------------------------------------------------------ +//! @name Path handling +//@{ + +//! Parse path +/* + Convert path from string to more useful format. + + @param path string containing path to be parsed + + @return parsed path +*/ +ParsedPath parsePath(ConstString path); + +//! assemblePath +/* + Convert path from the useful format to plain string. + + @param path parsed path to be assembled + + @return string containing the path +*/ +String assemblePath(const ParsedPath &path); + +//@} + +//! @name Node access +//@{ + +//! Return given node +/* + @param path path to the node + @param base node the path is relative to + + @return pointer to the given node (or NULL if node not found) +*/ +NodePtr getNode(ConstString path, NodePtr base); + +//! Create nodes on the way to given node +/* + @param begin first part of path to be constructed + @param end iterator pointing right beyon the last part of path to be constructed + @param targetNode node to be inserted as last part of the path + + @return pointer to the root node +*/ +NodePtr createPathToNode(ParsedPath::const_iterator begin, ParsedPath::const_iterator end, NodePtr targetNode); + +//! Make sure, there is a path to given node +/* + @param root root of the tree + @param path path to targetNode relative to the root + @param targetNode node requested to be accessible by path + + @node + Function will not assure the path if + - there is note of wrong type on the way (array expected, map found or the other way around + - there is another node accessible by given path +*/ +void assurePathToNode(NodePtr root, const ParsedPath &path, NodePtr targetNode); + +//@} + //! Return a new node /* Returns new node, type is guessed from contents of the cache @@ -391,6 +483,7 @@ Do not use this function, it will be probably removed in the future ! */ NodePtr newNode(StringInputCache &cache); +NodePtr createParent(ConstString child); //! @name Load & Save //@{ @@ -414,23 +507,6 @@ //! @name Get nodes by path //@{ -//! Return given node -/* - @param path path to the node - @param base node the path is relative to - - @return pointer to the given node (or NULL if node not found) -*/ -inline NodePtr getNode(ConstString path, NodePtr base) -{ - StringInputCache cache(path); - NodePtr node; - - // TODO: or silently return NULL if base is NULL ? - assert(base != NULL); - return base->getNode(cache); -}; - //! Return given node as array node (if possible) /* @param path path to the node @@ -467,6 +543,15 @@ inline ValueNodePtr getValueNode(ConstString path, NodePtr base) { NodePtr node = getNode(path, base); +/* try + { + return boost::dynamic_pointer_cast<ValueNode>(node); + } + catch(...) + { + return ValueNodePtr((ValueNode *)NULL); + }*/ + return (node != NULL) ? (boost::dynamic_pointer_cast<ValueNode>(node)) : ValueNodePtr((ValueNode *)NULL); } @@ -502,15 +587,19 @@ The order of parameters is different from set on purpose ! @note - It will crash if node is not found. - TODO: once the implemntation is changed, update this note - + Not existing node will be created. */ template <typename T> void set(ConstString path, const T &value, NodePtr base) { - // TODO: create node if possible ! - getValueNode(path,base)->setValue(toString(value)); + ValueNodePtr node = getValueNode(path,base); + if (node == NULL) + { + node = ValueNodePtr(new ValueNode); + assurePathToNode(base, parsePath(path), node); + } + + node->setValue(toString(value)); }; //@} @@ -527,14 +616,19 @@ @param defaultValue value to set newly created node to (if node is not found) !!! currently unused !!! @note - It will crash if node is not found. - TODO: once the implemntation is changed, update this note + Not existing node will be created. */ template <typename T> void bind(ConstString path, NodePtr base, T& variable, const T &defaultValue) { - // TODO: create node if possible ! (and set it to defaultValue) - getValueNode(path,base)->setBinder(BinderPtr(new Binder<T>(variable))); + ValueNodePtr node = getValueNode(path,base); + if (node == NULL) + { + node = ValueNodePtr(new ValueNode); + node->setValue(toString(variable)); + assurePathToNode(base, parsePath(path), node); + } + node->setBinder(BinderPtr(new Binder<T>(variable))); }; //@} Modified: branches/dunks/src/ConfigFile.cpp =================================================================== --- branches/dunks/src/ConfigFile.cpp 2006-08-10 17:27:06 UTC (rev 100) +++ branches/dunks/src/ConfigFile.cpp 2006-08-10 22:28:09 UTC (rev 101) @@ -1,13 +1,9 @@ /* -notes: node->load gets string that starts on the real value (= no whitespace on the beginning) -update Log to allow indentation !! (and use it !) +note: node->load gets string that starts on the real value (= no whitespace on the beginning) - - -todo: change to -map: -loading = get node, node->loadvalue - +TODO: +1) fix ValueNode to allow classic single word (see documentation of valuenode for delimiters) or " (drop ') string with ESCAPING !!! (extend Strings.cpp for escaping) +2) make an unified loading (see loading of map & array, it is a mess) */ #include "ConfigFile.h" @@ -25,20 +21,7 @@ Node::~Node() { }; - -void Node::load(StringInputCache &cache) -{ -}; -void Node::save(StringOutputCache &cache) -{ -}; -NodePtr Node::getNode(StringInputCache &path) -{ - return shared_from_this(); -}; - - //------------------------------------------------------------------------------ // ArrayNode class //------------------------------------------------------------------------------ @@ -207,8 +190,44 @@ return node->getNode(path); }; -// ArrayNodeNodes nodes; +NodePtr ArrayNode::getChild(ConstString child) +{ + unsigned index; + assert(child.size() != 0); + if (child[0] != '[') + LOG_ERROR("CfgFile", "ArrayNode::getChild - requested invalid child '%s'", child.c_str()); + index = fromString<unsigned>(child.substr(1, child.size() - 2)); + if (index >= nodes.size()) + LOG_ERROR("CfgFile", "ArrayNode::getChild - requested invalid index '%u'", index); + + return nodes[index]; +}; + +void ArrayNode::addChild(ConstString name, NodePtr child) +{ + unsigned index; + + assert(name.size() != 0); + + LOG_INFO("CfgFile", "ArrayNode::addChild - adding child '%s'...", name.c_str()); + LOG_INDENT(); + + if (name[0] != '[') + LOG_ERROR("CfgFile", "ArrayNode::addChild - requested to add an invalid child '%s'", name.c_str()); + index = fromString<unsigned>(name.substr(1, name.size() - 2)); + if (index < nodes.size()) + LOG_ERROR("CfgFile", "ArrayNode::addChild - child of that index (%u) is already present !", index); + if (index > nodes.size()) + LOG_ERROR("CfgFile", "ArrayNode::addChild - child of that index (%u) would create gap in indexes !", index); + + LOG_UNINDENT(); + LOG_INFO("CfgFile", "ArrayNode::addChild - done"); + + nodes.push_back(child); +}; + + //------------------------------------------------------------------------------ // MapNode class //------------------------------------------------------------------------------ @@ -242,14 +261,15 @@ // (this run can be an update called on this node) nodes.clear(); + // skip whitespace before name of child node + cache.skipWhitespace(); + // till the end of map while (cache.peekChar() != '}') { // skip whitespace before name of child node cache.skipWhitespace(); - - // TODO: skip possible comment (end by continue !) // load the child element (childelement = something) loadChild(cache); @@ -308,9 +328,7 @@ // skip possible leading '.' if (path.peekChar() == '.') path.advance(); - -// path.skipChars("."); - + path.skipWhitespace(); // am i requested ? @@ -329,13 +347,75 @@ if (i == nodes.end()) { // TODO: remove this warning, it would fill the log while querying the config file ! - LOG_WARNING("CfgFile", "MapNode::get - child unknown ('%s'), but not allowed to create it !", childName.c_str()); + LOG_WARNING("CfgFile", "MapNode::get - child unknown ('%s') !", childName.c_str()); return NodePtr((Node *)NULL); }; return (i->second)->getNode(path); }; +NodePtr MapNode::getChild(ConstString child) +{ + unsigned base; + String realChild; + assert(child.size() != 0); + base = child.find_first_not_of("."); + if (base == String::npos) + { + LOG_ERROR("CfgFile", "MapNode::getChild - requested non dot starting child '%s', this is not supported !", child.c_str()); + return NodePtr((Node *)NULL); + }; + realChild = child.substr(base, child.size() - base); + + MapNodeNodes::iterator i = nodes.find(realChild); + if (i == nodes.end()) + { + LOG_ERROR("CfgFile", "MapNode::getChild - requested non-existent child '%s'", realChild.c_str()); + return NodePtr((Node *)NULL); + } + return i->second; +}; + +// TODO: recode, looks like a mess +void MapNode::addChild(ConstString name, NodePtr child) +{ + unsigned base; + String realName; + + assert(name.size() != 0); + + LOG_INFO("CfgFile", "MapNode::addChild - adding child '%s'...", name.c_str()); + LOG_INDENT(); + + base = name.find_first_not_of("."); + if (base == String::npos) + { + LOG_ERROR("CfgFile", "MapNode::addChild - requested non dot starting child '%s', this is not supported !", name.c_str()); + LOG_UNINDENT(); + LOG_INFO("CfgFile", "MapNode::addChild - FAILED !"); + return; + }; + realName = name.substr(base, name.size() - base); + + MapNodeNodes::iterator i = nodes.find(realName); + if (i == nodes.end()) + { + LOG_INFO("CfgFile", "MapNode::addChild - requested non-existent child '%s'", realName.c_str()); + nodes[realName] = child; + } + else + { + LOG_ERROR("CfgFile", "ArrayNode::addChild - child of that name (%s) is already present !", realName.c_str()); + LOG_UNINDENT(); + LOG_INFO("CfgFile", "MapNode::addChild - FAILED !"); + return; + } + + LOG_UNINDENT(); + LOG_INFO("CfgFile", "MapNode::addChild - done"); + +} + void MapNode::loadChild(StringInputCache &cache) { String childName; @@ -469,6 +549,19 @@ return shared_from_this(); }; +NodePtr ValueNode::getChild(ConstString child) +{ + if (child.size() != 0) + { + LOG_ERROR("CfgFile", "ValueNode::getChild - requested a child on ValueNode, child '%s'", child.c_str()); + return NodePtr((Node *)NULL); + }; + return shared_from_this(); +}; +void ValueNode::addChild(ConstString name, NodePtr child) +{ + LOG_ERROR("CfgFile", "ValueNode::addChild - requested adding a child on ValueNode, child '%s'", name.c_str()); +}; // String value; @@ -476,6 +569,148 @@ // Functions //------------------------------------------------------------------------------ +ParsedPath parsePath(ConstString path) +{ + StringInputCache sic(path); + ParsedPath output; + bool inArray = false; // if not set, then in map + + LOG_INFO("CfgFile", "parsePath - parsing path: '%s'", path.c_str()); + + if (sic.peekChar() == '[') + { + inArray = true; + // skip '[' + sic.advance(); + } + else if (sic.peekChar() == '.') + { + // skip '.' + sic.advance(); + } + + while (sic.isEos() == false) + { + if (inArray) + { + // in array + output.push_back("[" + sic.getWord("]") + "]"); + + // skip ] + sic.advance(); + } + else + { + // in map + output.push_back("." + sic.getWord(".[")); + }; + + // check the end of path + if (sic.isEos()) + break; + + switch (sic.peekChar()) + { + case '.': + inArray = false; + break; + case '[': + inArray = true; + break; + default: + LOG_INFO("CfgFile", "parsePath - malformed path ! '%s' (part: '%s')", path.c_str(), sic.c_str() + sic.getPosition()); + return ParsedPath(); + }; + + // skip '.' or '[' + sic.advance(); + + }; + + for (ParsedPath::iterator i = output.begin(); i != output.end(); i++) + { + LOG_INFO("CfgFile", "path part: '%s'", i->c_str()); + }; + + return output; +}; + +String assemblePath(const ParsedPath &path) +{ + String output; + for (ParsedPath::const_iterator i = path.begin(); i != path.end(); i++) + { + output += *i; + } + return output; +}; + +NodePtr getNode(ConstString path, NodePtr base) +{ + assert(base != NULL); + + ParsedPath parsed = parsePath(path); + NodePtr currentNode = base; + + for (ParsedPath::iterator i = parsed.begin(); (i != parsed.end()) && (currentNode != NULL); i++) + currentNode = currentNode->getChild(*i); + + return currentNode; +}; + +NodePtr createPathToNode(ParsedPath::const_iterator begin, ParsedPath::const_iterator end, NodePtr targetNode) +{ + // the last link, just return the requested target + if (begin+1 == end) + return targetNode; + + // child node (begin+1) + NodePtr child = createPathToNode(begin+1, end, targetNode); + + // this node (begin) + NodePtr parent = createParent(*(begin+1)); + parent->addChild(*(begin+1), child); + return parent; +}; + +void assurePathToNode(NodePtr root, const ParsedPath &path, NodePtr targetNode) +{ + assert(root != NULL); + + LOG_INFO("CfgFile", "assurePathToNode for '%s'", assemblePath(path).c_str()); + + ParsedPath::const_iterator i = path.begin(); + NodePtr currentParent = root; + NodePtr currentChild = currentParent->getChild(*i); + i++; + + // go to the last existent node + while (currentChild != NULL && i != path.end()) + { + currentParent = currentChild; + currentChild = currentChild->getChild(*i); + i++; + }; + + + if (currentChild == NULL) + { + + // one step back, we need name of the chid + i--; + LOG_INFO("CfgFile", "creating path from '%s' ...", i->c_str()); + + // currentParent is the last existent node + // i points to name of child of currentParent that should exist + currentParent->addChild(*i, createPathToNode(i, path.end(), targetNode)); + } + else + { + LOG_INFO("CfgFile", "path found to '%s' ", i->c_str()); + }; +}; + + NodePtr newNode(StringInputCache &cache) { LOG_INFO("CfgFile", "newNode got '%c'", cache.peekChar()); @@ -492,11 +727,42 @@ } }; +NodePtr createParent(ConstString child) +{ + assert(child.size() != 0); + + LOG_INFO("CfgFile", "createParent for '%s'", child.c_str()); + + switch (child[0]) + { + case '[': // parent is an array + return NodePtr(new ArrayNode()); + case '.': // parent is a map + return NodePtr(new MapNode()); + default: + LOG_ERROR("CfgFile", "failed to create parent !"); + return NodePtr((Node *) NULL); + }; +}; + NodePtr loadFile(ConstString input) { StringInputCache c(input); - ConfigFile::NodePtr node = ConfigFile::newNode(c); - node->load(c); + c.skipWhitespace(); + ConfigFile::NodePtr node; + + switch (c.peekChar()) + { + case '{': // map config file + case '(': // array only config file + node = ConfigFile::newNode(c); + node->load(c); + break; + default: + // not guessable, probably bad file, default to map node... + LOG_ERROR("CfgFile", "loadFile - bad file !, contents: '%s'", input.c_str()); + node = NodePtr(new MapNode()); + } return node; }; Modified: branches/dunks/src/Log.cpp =================================================================== --- branches/dunks/src/Log.cpp 2006-08-10 17:27:06 UTC (rev 100) +++ branches/dunks/src/Log.cpp 2006-08-10 22:28:09 UTC (rev 101) @@ -30,6 +30,7 @@ void LogBackendStdout::log(const char *message) { printf("%s", message); + fflush(stdout); }; //------------------------------------------------------------------------------ Modified: branches/dunks/src/Settings.cpp =================================================================== --- branches/dunks/src/Settings.cpp 2006-08-10 17:27:06 UTC (rev 100) +++ branches/dunks/src/Settings.cpp 2006-08-10 22:28:09 UTC (rev 101) @@ -29,12 +29,12 @@ { String configText = ResMan::Instance()->readText("CONFIG:config.txt"); configFile = ConfigFile::loadFile(configText.c_str()); - ConfigFile::bind("graphics.width", configFile, m_width, 640); - ConfigFile::bind("graphics.height", configFile, m_height, 480); - ConfigFile::bind("graphics.fullscreen", configFile, m_fullscreen, false); - ConfigFile::bind("graphics.double_buffer", configFile, m_doubleBuffered, false); - ConfigFile::bind("debug", configFile, m_debug, true); - ConfigFile::bind("data_dir", configFile, m_dataDir, String("paks/")); + ConfigFile::bind(".graphics.width", configFile, m_width, 640); + ConfigFile::bind(".graphics.height", configFile, m_height, 480); + ConfigFile::bind(".graphics.fullscreen", configFile, m_fullscreen, false); + ConfigFile::bind(".graphics.double_buffer", configFile, m_doubleBuffered, false); + ConfigFile::bind(".debug", configFile, m_debug, true); + ConfigFile::bind(".data_dir", configFile, m_dataDir, String("paks/")); /* root = ConfigFile::loadFile((const char *)data); std::string config = ResMan::Instance()->readText("CONFIG:config.txt"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2006-08-10 17:27:19
|
Revision: 100 Author: dvalin Date: 2006-08-10 10:27:06 -0700 (Thu, 10 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=100&view=rev Log Message: ----------- fix typo Modified Paths: -------------- branches/dunks/README trunk/README Modified: branches/dunks/README =================================================================== --- branches/dunks/README 2006-08-10 15:14:07 UTC (rev 99) +++ branches/dunks/README 2006-08-10 17:27:06 UTC (rev 100) @@ -7,7 +7,7 @@ The Dune Legacy project was originally started by Anthony Cole, then helped out by Raal Goff and Martin Reichl before it was abandoned by them. It cointains small segments of code greatfully borrowed from Olaf van der Spek's Mixer (dune2 data extraction), and -Stefen Hendriks' Ultra Dune2(random map generator). +Stefan Hendriks' Ultra Dune2(random map generator). Current situation: This project was picked up again by Per Øyvind Karlsen (Dvalin) in 2005 after being Modified: trunk/README =================================================================== --- trunk/README 2006-08-10 15:14:07 UTC (rev 99) +++ trunk/README 2006-08-10 17:27:06 UTC (rev 100) @@ -7,7 +7,7 @@ The Dune Legacy project was originally started by Anthony Cole, then helped out by Raal Goff and Martin Reichl before it was abandoned by them. It cointains small segments of code greatfully borrowed from Olaf van der Spek's Mixer (dune2 data extraction), and -Stefen Hendriks' Ultra Dune2(random map generator). +Stefan Hendriks' Ultra Dune2(random map generator). Current situation: This project was picked up again by Per Øyvind Karlsen (Dvalin) in 2005 after being This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dun...@us...> - 2006-08-10 15:14:13
|
Revision: 99 Author: dunkfordyce Date: 2006-08-10 08:14:07 -0700 (Thu, 10 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=99&view=rev Log Message: ----------- - added RTTI for windows build - added new files to vcproj Modified Paths: -------------- branches/dunks/SConstruct branches/dunks/dunelegacy.vcproj Modified: branches/dunks/SConstruct =================================================================== --- branches/dunks/SConstruct 2006-08-10 14:20:09 UTC (rev 98) +++ branches/dunks/SConstruct 2006-08-10 15:14:07 UTC (rev 99) @@ -34,7 +34,7 @@ else: env.Append(LIBS = ["zzipdll", "zdll", "SDLmain"]) env.Append(LINKFLAGS = ["/SUBSYSTEM:CONSOLE", "/DEBUG"]) - env.Append(CCFLAGS = ["/O2", "/EHsc", "/MD", "/Op", "/DEBUG", "/Zi"]) + env.Append(CCFLAGS = ["/O2", "/EHsc", "/MD", "/Op", "/DEBUG", "/Zi", "/GR"]) env.Append(LIBS = [ "SDL", "SDL_mixer", Modified: branches/dunks/dunelegacy.vcproj =================================================================== --- branches/dunks/dunelegacy.vcproj 2006-08-10 14:20:09 UTC (rev 98) +++ branches/dunks/dunelegacy.vcproj 2006-08-10 15:14:07 UTC (rev 99) @@ -306,6 +306,12 @@ RelativePath=".\include\State.h"> </File> <File + RelativePath=".\src\Strings.cpp"> + </File> + <File + RelativePath=".\include\Strings.h"> + </File> + <File RelativePath=".\src\TerrainClass.cpp"> </File> <File This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otp...@us...> - 2006-08-10 14:20:16
|
Revision: 98 Author: otpetrik Date: 2006-08-10 07:20:09 -0700 (Thu, 10 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=98&view=rev Log Message: ----------- - minor settings fix Modified Paths: -------------- branches/dunks/config.txt branches/dunks/src/Application.cpp branches/dunks/src/Settings.cpp Modified: branches/dunks/config.txt =================================================================== --- branches/dunks/config.txt 2006-08-10 14:12:30 UTC (rev 97) +++ branches/dunks/config.txt 2006-08-10 14:20:09 UTC (rev 98) @@ -4,7 +4,7 @@ graphics = { double_buffer = false; fullscreen = false; - height = 600; - width = 800; + height = 480; + width = 640; }; } Modified: branches/dunks/src/Application.cpp =================================================================== --- branches/dunks/src/Application.cpp 2006-08-10 14:12:30 UTC (rev 97) +++ branches/dunks/src/Application.cpp 2006-08-10 14:20:09 UTC (rev 98) @@ -125,6 +125,7 @@ //MentatClass* m = new MentatClass(); //setMentat( m ); //MentatClass::Instance(); + Settings::Instance()->load(); InitVideo(); @@ -264,10 +265,6 @@ void Application::LoadData() { - // for config files - // set to the current directory for the moment - ResMan::Instance()->addRes("CONFIG", new WritableDIRResource("") ); - printf("loading resources\n"); ResMan::Instance()->addRes("ATRE"); ResMan::Instance()->addRes("DUNE"); @@ -286,8 +283,6 @@ ResMan::Instance()->addRes("XTRE"); printf("done loading resources\n"); - Settings::Instance()->load(); - SetPalette(); int len; Modified: branches/dunks/src/Settings.cpp =================================================================== --- branches/dunks/src/Settings.cpp 2006-08-10 14:12:30 UTC (rev 97) +++ branches/dunks/src/Settings.cpp 2006-08-10 14:20:09 UTC (rev 98) @@ -8,6 +8,10 @@ Settings::Settings() { + // for config files + // set to the current directory for the moment + ResMan::Instance()->addRes("CONFIG", new WritableDIRResource("") ); + m_width = 640; m_height = 480; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otp...@us...> - 2006-08-10 14:12:50
|
Revision: 97 Author: otpetrik Date: 2006-08-10 07:12:30 -0700 (Thu, 10 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=97&view=rev Log Message: ----------- - basic settings load & save Modified Paths: -------------- branches/dunks/include/ConfigFile.h branches/dunks/include/Settings.h branches/dunks/include/Strings.h branches/dunks/src/Application.cpp branches/dunks/src/ConfigFile.cpp branches/dunks/src/Settings.cpp branches/dunks/src/Strings.cpp Added Paths: ----------- branches/dunks/config.txt Added: branches/dunks/config.txt =================================================================== --- branches/dunks/config.txt (rev 0) +++ branches/dunks/config.txt 2006-08-10 14:12:30 UTC (rev 97) @@ -0,0 +1,10 @@ +{ + data_dir = "paks/"; + debug = false; + graphics = { + double_buffer = false; + fullscreen = false; + height = 600; + width = 800; + }; +} Modified: branches/dunks/include/ConfigFile.h =================================================================== --- branches/dunks/include/ConfigFile.h 2006-08-10 09:14:20 UTC (rev 96) +++ branches/dunks/include/ConfigFile.h 2006-08-10 14:12:30 UTC (rev 97) @@ -306,7 +306,12 @@ //------------------------------------------------------------------------------ //! Value node /*! - Leaf node containg a string + Leaf node containg a string. + + @note + The string cannot contain any of the following characters: '\n', '\t', ' ', '/', '*', ',', ')', ';' + String containing those characters can be escaped by ' or ", but escaped string cannot contain '"' ! + */ class ValueNode : public Node { Modified: branches/dunks/include/Settings.h =================================================================== --- branches/dunks/include/Settings.h 2006-08-10 09:14:20 UTC (rev 96) +++ branches/dunks/include/Settings.h 2006-08-10 14:12:30 UTC (rev 97) @@ -55,6 +55,8 @@ #include "singleton.h" +#include "ConfigFile.h" + class Settings: public Singleton<Settings> { friend class Singleton<Settings>; @@ -70,8 +72,13 @@ bool m_doubleBuffered; std::string m_dataDir; + + ConfigFile::NodePtr configFile; public: + void load(); + void save(); + void ParseFile(char* fn); void ParseOptions(int argc, char* argv[]); Modified: branches/dunks/include/Strings.h =================================================================== --- branches/dunks/include/Strings.h 2006-08-10 09:14:20 UTC (rev 96) +++ branches/dunks/include/Strings.h 2006-08-10 14:12:30 UTC (rev 97) @@ -29,12 +29,22 @@ Tries to convert value to string (uses std::ostringstream). */ template <typename T> -String toString(const T &something) +inline String toString(const T &something) { std::ostringstream s; s << something; return s.str(); }; +template <> +inline String toString(const bool &something) +{ + std::ostringstream s; + if (something) + s << "true"; + else + s << "false"; + return s.str(); +}; //! Convert string to something /* @@ -46,13 +56,24 @@ @endcode */ template <typename T> -T fromString(ConstString string) +inline T fromString(ConstString string) { T something; std::istringstream s(string); s >> something; return something; }; +template <> +inline bool fromString(ConstString string) +{ + String something; + std::istringstream s(string); + s >> something; + if (something == "true") + return true; + else + return false; +}; //@} Modified: branches/dunks/src/Application.cpp =================================================================== --- branches/dunks/src/Application.cpp 2006-08-10 09:14:20 UTC (rev 96) +++ branches/dunks/src/Application.cpp 2006-08-10 14:12:30 UTC (rev 97) @@ -46,6 +46,9 @@ Application::~Application() { + // TODO: not sure where this belongs... (otpetrik) + Settings::Instance()->save(); + delete m_rootState; delete m_rootWidget; @@ -283,13 +286,8 @@ ResMan::Instance()->addRes("XTRE"); printf("done loading resources\n"); - // example of reading the config file - remove me - std::string config = ResMan::Instance()->readText("CONFIG:config.txt"); - printf("%s\n", config.c_str()); - - config += "newline\n"; - ResMan::Instance()->writeText("CONFIG:config.txt", config); - + Settings::Instance()->load(); + SetPalette(); int len; Modified: branches/dunks/src/ConfigFile.cpp =================================================================== --- branches/dunks/src/ConfigFile.cpp 2006-08-10 09:14:20 UTC (rev 96) +++ branches/dunks/src/ConfigFile.cpp 2006-08-10 14:12:30 UTC (rev 97) @@ -439,6 +439,8 @@ { if (binder != NULL) value = binder->getString(); + if (value.find_first_of("\n\t /*,);") != String::npos) + value = "\"" + value + "\""; cache.add(value); }; @@ -505,7 +507,10 @@ assert(root != NULL); root->save(c); + // file should end with a newline + c.add("\n"); + return c.getString(); }; - + } // namespace ConfigFile Modified: branches/dunks/src/Settings.cpp =================================================================== --- branches/dunks/src/Settings.cpp 2006-08-10 09:14:20 UTC (rev 96) +++ branches/dunks/src/Settings.cpp 2006-08-10 14:12:30 UTC (rev 97) @@ -1,6 +1,9 @@ #include "Settings.h" #include <fstream> +#include "Strings.h" +#include "ResMan.h" + SETTINGSTYPE settings; Settings::Settings() @@ -18,6 +21,32 @@ }; +void Settings::load() +{ + String configText = ResMan::Instance()->readText("CONFIG:config.txt"); + configFile = ConfigFile::loadFile(configText.c_str()); + ConfigFile::bind("graphics.width", configFile, m_width, 640); + ConfigFile::bind("graphics.height", configFile, m_height, 480); + ConfigFile::bind("graphics.fullscreen", configFile, m_fullscreen, false); + ConfigFile::bind("graphics.double_buffer", configFile, m_doubleBuffered, false); + ConfigFile::bind("debug", configFile, m_debug, true); + ConfigFile::bind("data_dir", configFile, m_dataDir, String("paks/")); + +/* root = ConfigFile::loadFile((const char *)data); + std::string config = ResMan::Instance()->readText("CONFIG:config.txt"); + printf("%s\n", config.c_str()); + + config += "newline\n"; + ResMan::Instance()->writeText("CONFIG:config.txt", config); + +*/ +}; +void Settings::save() +{ + String configText = ConfigFile::saveFile(configFile); + ResMan::Instance()->writeText("CONFIG:config.txt", configText); +}; + void Settings::ParseFile(char* fn) { /* Modified: branches/dunks/src/Strings.cpp =================================================================== --- branches/dunks/src/Strings.cpp 2006-08-10 09:14:20 UTC (rev 96) +++ branches/dunks/src/Strings.cpp 2006-08-10 14:12:30 UTC (rev 97) @@ -196,7 +196,7 @@ { data += str.substr(index, nlIndex-index); data += '\n'; - for (int i = 0; i <= indentLevel; i++) + for (int i = 0; i < indentLevel; i++) data += " "; // 4 spaces for one indent level // start next search after the newline index = nlIndex+1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dun...@us...> - 2006-08-10 09:14:36
|
Revision: 96 Author: dunkfordyce Date: 2006-08-10 02:14:20 -0700 (Thu, 10 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=96&view=rev Log Message: ----------- - added some documentation to State.h - Moved OptionsMenuState and SingleMenuState to use MenuBaseState - fixed some documentation probs in ResMan.h Modified Paths: -------------- branches/dunks/include/MainMenu.h branches/dunks/include/OptionsMenu.h branches/dunks/include/ResMan.h branches/dunks/include/SingleMenu.h branches/dunks/include/State.h branches/dunks/src/OptionsMenu.cpp branches/dunks/src/ResMan.cpp branches/dunks/src/SingleMenu.cpp Modified: branches/dunks/include/MainMenu.h =================================================================== --- branches/dunks/include/MainMenu.h 2006-08-09 10:29:53 UTC (rev 95) +++ branches/dunks/include/MainMenu.h 2006-08-10 09:14:20 UTC (rev 96) @@ -11,10 +11,6 @@ MainMenuState(); ~MainMenuState(); - //void JustMadeActive(); - //void JustMadeInactive(); - - //int Execute(float dt); void doOptions(); void doSkirmish(); void doSingle(); @@ -23,13 +19,6 @@ private: VBox* m_vbox; - - //GraphicButton* m_butSingle; - //GraphicButton* m_butMulti; - //GraphicButton* m_butMapEd; - //GraphicButton* m_butOptions; - //GraphicButton* m_butAbout; - //GraphicButton* m_butQuit; BoringButton* m_butSingle; BoringButton* m_butMulti; Modified: branches/dunks/include/OptionsMenu.h =================================================================== --- branches/dunks/include/OptionsMenu.h 2006-08-09 10:29:53 UTC (rev 95) +++ branches/dunks/include/OptionsMenu.h 2006-08-10 09:14:20 UTC (rev 96) @@ -1,23 +1,19 @@ #ifndef DUNE_OPTIONSMENU_H #define DUNE_OPTIONSMENU_H -#include "State.h" +#include "MenuBase.h" #include "gui2/Button.h" #include "gui2/VBox.h" #include "SDL.h" -class OptionsMenuState : public State +class OptionsMenuState : public MenuBaseState { public: OptionsMenuState(); ~OptionsMenuState(); - void JustMadeActive(); - void JustMadeInactive(); - - int Execute(float dt); void doOptions(); void doOk(); void doResolution(); @@ -26,9 +22,6 @@ virtual const char* GetName() { return "OptionsMenuState"; } private: - SDL_Surface* m_menuBackground; - //Window* m_menu; - VBox* m_vbox; BoringButton* m_butResolution; Modified: branches/dunks/include/ResMan.h =================================================================== --- branches/dunks/include/ResMan.h 2006-08-09 10:29:53 UTC (rev 95) +++ branches/dunks/include/ResMan.h 2006-08-10 09:14:20 UTC (rev 96) @@ -24,8 +24,7 @@ //@} //! @name FileLike methods - //@{ - + //@{ /*! read data from the buffer @param buf buffer to read data into @@ -76,7 +75,7 @@ @param path path to write the file @param text text to write to file */ - virtual void writeText(std::string, std::string text) {} + virtual void writeText(std::string path, std::string text) {} /*! return true if the resource can be written to @@ -91,7 +90,7 @@ }; /*! - Directory Resource - all files are read/written from a directory. Supports writing. + Directory Resource - all files are read from a directory */ class DIRResource : public Resource { @@ -112,7 +111,7 @@ }; /*! - PAK file resource - all files are read from a PAK file. Does not support writing. + PAK file resource - all files are read from a PAK file */ class PAKResource : public Resource { @@ -165,7 +164,7 @@ @param size if not NULL the file size is put here @return file data */ - unsigned char* readFile(std::string name, int *size); + unsigned char* readFile(std::string path, int *size); /*! read a file from the resource. @param path path to the file to read @@ -181,13 +180,13 @@ @param path path to the file to open @return text from the file */ - virtual std::string readText(std::string name); + virtual std::string readText(std::string path); /*! write a text file to a resource @param path path to write the file @param text text to write to file */ - virtual void writeText(std::string name, std::string text); + virtual void writeText(std::string path, std::string text); //@} private: ResList m_resources; Modified: branches/dunks/include/SingleMenu.h =================================================================== --- branches/dunks/include/SingleMenu.h 2006-08-09 10:29:53 UTC (rev 95) +++ branches/dunks/include/SingleMenu.h 2006-08-10 09:14:20 UTC (rev 96) @@ -1,33 +1,25 @@ #ifndef DUNE_SINGLEMENU_H #define DUNE_SINGLEMENU_H -#include "State.h" +#include "MenuBase.h" #include "gui2/Button.h" #include "gui2/VBox.h" #include "SDL.h" -class SingleMenuState : public State +class SingleMenuState : public MenuBaseState { public: SingleMenuState(); ~SingleMenuState(); - void JustMadeActive(); - void JustMadeInactive(); - - int Execute(float dt); - void doSkirmish(); void doCancel(); virtual const char* GetName() { return "SingleMenuState"; } private: - SDL_Surface* m_menuBackground; - //Window* m_menu; - VBox* m_vbox; BoringButton* m_butCampaign; Modified: branches/dunks/include/State.h =================================================================== --- branches/dunks/include/State.h 2006-08-09 10:29:53 UTC (rev 95) +++ branches/dunks/include/State.h 2006-08-10 09:14:20 UTC (rev 96) @@ -3,43 +3,87 @@ #include <list> +// fwd dec class StateMachine; +/*! + Base State class used with StateMachine. +*/ class State { public: + //! @name Constructors & Destructor + //@{ State(); virtual ~State(); + //@} + //! @name Parent methods + //@{ StateMachine* GetParent() { return mp_parent; } void SetParent(StateMachine* sm) { mp_parent = sm; } + //@} + /*! + Called once per frame when the state is active. + @param dt time in seconds since last frame + */ virtual int Execute(float dt) = 0; + /*! + Called just before the state is made the current state + */ virtual void JustMadeActive(); + /*! + Called just after the state is no-longer the current + */ virtual void JustMadeInactive(); + /*! + Pops this state. + */ virtual void PopState(); - virtual const char* GetName() { return "Unknown"; } + /*! + Returns the state name. Used internally for debug information. + @return the state name + */ + virtual const char* GetName() { return "UnknownState"; } protected: StateMachine* mp_parent; }; - +/* + StateMachine class. Derived from State so it can be used as a state + in another StateMachine +*/ class StateMachine : public State { typedef std::list<State*> StateList; public: + //! @name Constructors & Destructor + //@{ StateMachine(); virtual ~StateMachine(); + //@} + /*! + Push a state onto the stack. The state will become the current state. + @param state the state to push onto the state stack + */ virtual void PushState(State* state); + /*! + Pop the current child state. If there are no child states left, pop + this statemachine from its parent + */ virtual void PopState(); //virtual void ReplaceState(State* state); + /*! + Return the current child state + */ State* GetCurrentState() { return *(m_stateStack.begin()); }; int Execute(float dt); Modified: branches/dunks/src/OptionsMenu.cpp =================================================================== --- branches/dunks/src/OptionsMenu.cpp 2006-08-09 10:29:53 UTC (rev 95) +++ branches/dunks/src/OptionsMenu.cpp 2006-08-10 09:14:20 UTC (rev 96) @@ -9,11 +9,6 @@ OptionsMenuState::OptionsMenuState() { - //m_menuBackground = (SDL_Surface*)(dataFile[UI_Menu].dat); - //m_menu = new Window(); - //m_menu->setHeight(m_menuBackground->h); - //m_menu->setWidth(m_menuBackground->w); - const int bw = 200; const int bh = 20; @@ -65,11 +60,13 @@ m_vbox->addChild(m_butOk); - m_vbox->fit(2); - Uint16 x = (Settings::Instance()->GetWidth() / 2) - + m_vbox->fit(2); + Uint16 x = (set->GetWidth() / 2) - (m_vbox->getWidth() / 2); m_vbox->setPos(x - 5, 312); m_vbox->reshape(); + + m_container->addChild(m_vbox); }; OptionsMenuState::~OptionsMenuState() @@ -129,21 +126,3 @@ m_butWindowMode->setCaption("Window mode"); } -void OptionsMenuState::JustMadeActive() -{ - State::JustMadeActive(); - Application::Instance()->RootWidget()->addChild(m_vbox); -}; - -void OptionsMenuState::JustMadeInactive() -{ - State::JustMadeInactive(); - Application::Instance()->RootWidget()->deleteChild(m_vbox); -}; - -int OptionsMenuState::Execute(float dt) -{ - //Application::Instance()->BlitCentered(m_menuBackground); - - return 0; -}; Modified: branches/dunks/src/ResMan.cpp =================================================================== --- branches/dunks/src/ResMan.cpp 2006-08-09 10:29:53 UTC (rev 95) +++ branches/dunks/src/ResMan.cpp 2006-08-10 09:14:20 UTC (rev 96) @@ -60,7 +60,6 @@ unsigned char* DIRResource::readFile(std::string path, int *size) { - // TODO: seems to work now, tested on linux, please test it on windows. (otpetrik) bfs::path fullpath (m_path); fullpath /= path; Modified: branches/dunks/src/SingleMenu.cpp =================================================================== --- branches/dunks/src/SingleMenu.cpp 2006-08-09 10:29:53 UTC (rev 95) +++ branches/dunks/src/SingleMenu.cpp 2006-08-10 09:14:20 UTC (rev 96) @@ -9,11 +9,6 @@ SingleMenuState::SingleMenuState() { - //m_menuBackground = (SDL_Surface*)(dataFile[UI_Menu].dat); - //m_menu = new Window(); - //m_menu->setHeight(m_menuBackground->h); - //m_menu->setWidth(m_menuBackground->w); - const int bw = 200; const int bh = 20; @@ -55,10 +50,12 @@ m_vbox->addChild(m_butCancel); m_vbox->fit(2); - Uint16 x = (Settings::Instance()->GetWidth() / 2) - + Uint16 x = (Settings::Instance()->GetWidth() / 2) - (m_vbox->getWidth() / 2); m_vbox->setPos(x - 5, 312); m_vbox->reshape(); + + m_container->addChild(m_vbox); }; SingleMenuState::~SingleMenuState() @@ -83,21 +80,3 @@ PopState(); }; -void SingleMenuState::JustMadeActive() -{ - State::JustMadeActive(); - Application::Instance()->RootWidget()->addChild(m_vbox); -}; - -void SingleMenuState::JustMadeInactive() -{ - State::JustMadeInactive(); - Application::Instance()->RootWidget()->deleteChild(m_vbox); -}; - -int SingleMenuState::Execute(float dt) -{ - //Application::Instance()->BlitCentered(m_menuBackground); - - return 0; -}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dun...@us...> - 2006-08-09 10:29:00
|
Revision: 94 Author: dunkfordyce Date: 2006-08-09 03:28:51 -0700 (Wed, 09 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=94&view=rev Log Message: ----------- - replaced misused boost::filesystem::path with std::string - updated vcproj to include ConfigFile Modified Paths: -------------- branches/dunks/dunelegacy.vcproj branches/dunks/include/ResMan.h branches/dunks/src/ResMan.cpp Modified: branches/dunks/dunelegacy.vcproj =================================================================== --- branches/dunks/dunelegacy.vcproj 2006-08-09 09:46:55 UTC (rev 93) +++ branches/dunks/dunelegacy.vcproj 2006-08-09 10:28:51 UTC (rev 94) @@ -66,6 +66,12 @@ RelativePath=".\include\CommViewClass.h"> </File> <File + RelativePath=".\src\ConfigFile.cpp"> + </File> + <File + RelativePath=".\include\ConfigFile.h"> + </File> + <File RelativePath=".\src\CutScene.cpp"> </File> <File Modified: branches/dunks/include/ResMan.h =================================================================== --- branches/dunks/include/ResMan.h 2006-08-09 09:46:55 UTC (rev 93) +++ branches/dunks/include/ResMan.h 2006-08-09 10:28:51 UTC (rev 94) @@ -63,20 +63,20 @@ @param size if not NULL the file size is put here @return file data */ - virtual unsigned char* readFile(boost::filesystem::path path, int *size) { return NULL; } + virtual unsigned char* readFile(std::string path, int *size) { return NULL; } /*! read a text file from resource @param path path to the file to open @return text from the file */ - virtual std::string readText(boost::filesystem::path path) { return ""; } + virtual std::string readText(std::string path) { return ""; } /*! write a text file to a resource @param path path to write the file @param text text to write to file */ - virtual void writeText(boost::filesystem::path path, std::string text) {} + virtual void writeText(std::string, std::string text) {} /*! return true if the resource can be written to @@ -97,8 +97,8 @@ { public: DIRResource(boost::filesystem::path path) ; - unsigned char* readFile(boost::filesystem::path path, int *size); - std::string readText(boost::filesystem::path path); + unsigned char* readFile(std::string path, int *size); + std::string readText(std::string path); }; /*! @@ -107,8 +107,8 @@ class WritableDIRResource : public DIRResource { public: - WritableDIRResource(boost::filesystem::path path); - void writeText(boost::filesystem::path path, std::string text); + WritableDIRResource(std::string path); + void writeText(std::string path, std::string text); }; /*! @@ -119,7 +119,7 @@ public: PAKResource(boost::filesystem::path path) ; ~PAKResource(); - unsigned char* readFile(boost::filesystem::path path, int *size); + unsigned char* readFile(std::string path, int *size); private: Pakfile *m_pakfile; Modified: branches/dunks/src/ResMan.cpp =================================================================== --- branches/dunks/src/ResMan.cpp 2006-08-09 09:46:55 UTC (rev 93) +++ branches/dunks/src/ResMan.cpp 2006-08-09 10:28:51 UTC (rev 94) @@ -58,7 +58,7 @@ m_path = path; }; -unsigned char* DIRResource::readFile(bfs::path path, int *size) +unsigned char* DIRResource::readFile(std::string path, int *size) { // TODO: seems to work now, tested on linux, please test it on windows. (otpetrik) bfs::path fullpath (m_path); @@ -81,7 +81,7 @@ return buf; }; -std::string DIRResource::readText(boost::filesystem::path path) +std::string DIRResource::readText(std::string path) { bfs::path fullpath (m_path); fullpath /= path; @@ -103,12 +103,12 @@ // ------------------------------------------------------------------ -WritableDIRResource::WritableDIRResource(boost::filesystem::path path) : DIRResource(path) +WritableDIRResource::WritableDIRResource(std::string path) : DIRResource(path) { mb_writable = true; }; -void WritableDIRResource::writeText(boost::filesystem::path path, std::string text) +void WritableDIRResource::writeText(std::string path, std::string text) { bfs::path fullpath(m_path); fullpath /= path; @@ -132,10 +132,10 @@ delete m_pakfile; }; -unsigned char* PAKResource::readFile(bfs::path path, int *size) +unsigned char* PAKResource::readFile(std::string path, int *size) { int filesize; - unsigned char *buf = m_pakfile->getFile(path.string().c_str(), &filesize); + unsigned char *buf = m_pakfile->getFile(path.c_str(), &filesize); //RESMAN_LOG_INFO(boost::format("read pak %s size %d\n") % path.string().c_str() % filesize); @@ -270,10 +270,17 @@ Resource* res = getResource(name, filename); if (res == NULL) { - printf("resource not found!\n"); + printf("resource not found!\n"); + assert(0); + return; }; - assert(res != NULL); + if (!res->isWritable()) + { + printf("resource not writable!\n"); + assert(0); + return; + }; res->writeText(filename, text); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dun...@us...> - 2006-08-09 09:47:10
|
Revision: 93 Author: dunkfordyce Date: 2006-08-09 02:46:55 -0700 (Wed, 09 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=93&view=rev Log Message: ----------- - updated doxygen.conf to include non doc'd methods - added readText and writeText functions to Resource and ResMan. These read and write std::string's - added WritableDIRResource class for config files etc - added resource CONFIG. currently set to use the current directory. ( otpetrik see Application.cpp for example read/write usage ) Modified Paths: -------------- branches/dunks/doxygen.conf branches/dunks/include/ResMan.h branches/dunks/src/Application.cpp branches/dunks/src/ResMan.cpp Modified: branches/dunks/doxygen.conf =================================================================== --- branches/dunks/doxygen.conf 2006-08-08 18:09:59 UTC (rev 92) +++ branches/dunks/doxygen.conf 2006-08-09 09:46:55 UTC (rev 93) @@ -1,1237 +1,225 @@ -# Doxyfile 1.4.6 +# Doxyfile 1.4.7 -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = Dune Legacy - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - +PROJECT_NAME = DuneLegacy PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - OUTPUT_DIRECTORY = doc - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - CREATE_SUBDIRS = YES - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, -# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, -# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, -# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, -# Swedish, and Ukrainian. - OUTPUT_LANGUAGE = English - -# This tag can be used to specify the encoding used in the generated output. -# The encoding is not always determined by the language that is chosen, -# but also whether or not the output is meant for Windows or non-Windows users. -# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES -# forces the Windows encoding (this is the default for the Windows binary), -# whereas setting the tag to NO uses a Unix-style encoding (the default for -# all platforms other than Windows). - USE_WINDOWS_ENCODING = NO - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - JAVADOC_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - OPTIMIZE_OUTPUT_JAVA = NO - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - BUILTIN_STL_SUPPORT = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - SUBGROUPING = YES - #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_STATIC = YES EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - EXTRACT_LOCAL_METHODS = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - SHOW_DIRECTORIES = NO - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command <command> <input-file>, where <command> is the value of -# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - FILE_VERSION_FILTER = - #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - WARN_LOGFILE = - #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - INPUT = include/ - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py - FILE_PATTERNS = *.h - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - EXCLUDE_PATTERNS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command <filter> <input-file>, where <filter> -# is the value of the INPUT_FILTER tag, and <input-file> is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - FILTER_SOURCE_FILES = NO - #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - +SOURCE_BROWSER = YES INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - REFERENCES_RELATION = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - +REFERENCES_LINK_SOURCE = YES USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - VERBATIM_HEADERS = YES - #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 4 IGNORE_PREFIX = - #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - TREEVIEW_WIDTH = 250 - #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - LATEX_HIDE_INDICES = NO - #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - RTF_EXTENSIONS_FILE = - #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - MAN_LINKS = NO - #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - XML_PROGRAMLISTING = YES - #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - GENERATE_AUTOGEN_DEF = NO - #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - PERLMOD_MAKEVAR_PREFIX = - #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - SKIP_FUNCTION_MACROS = YES - #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - PERL_PATH = /usr/bin/perl - #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - CLASS_DIAGRAMS = YES - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - CALL_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - +CALLER_GRAPH = NO GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - MAX_DOT_GRAPH_WIDTH = 1024 - -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - MAX_DOT_GRAPH_HEIGHT = 1024 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that a graph may be further truncated if the graph's -# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH -# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), -# the graph is not depth-constrained. - MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). - DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - DOT_CLEANUP = YES - #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - SEARCHENGINE = NO Modified: branches/dunks/include/ResMan.h =================================================================== --- branches/dunks/include/ResMan.h 2006-08-08 18:09:59 UTC (rev 92) +++ branches/dunks/include/ResMan.h 2006-08-09 09:46:55 UTC (rev 93) @@ -11,14 +11,33 @@ //#include "Log.h" +/*! + Class to emulate a file object using an unsigned char* buffer +*/ class FileLike { public: + //! @name Constructors & Destructor + //@{ FileLike(unsigned char* buf, int size); ~FileLike(); - + //@} + + //! @name FileLike methods + //@{ + + /*! + read data from the buffer + @param buf buffer to read data into + @param size amount of bytes to read + */ void read(void* buf, int size); + /*! + seek to a position in the buffer + @param offset offset from the beginning of the buffer in bytes + */ void seek(int offset); + //@} private: unsigned char* m_buf; @@ -26,26 +45,75 @@ int m_pos; }; +/*! + Base class for all resources. +*/ class Resource { public: - Resource() {}; + //! @name Constructors & Destructor + //@{ + Resource(); virtual ~Resource(); + //@} + + /*! + read a file from the resource. + @param path path to the file to read + @param size if not NULL the file size is put here + @return file data + */ virtual unsigned char* readFile(boost::filesystem::path path, int *size) { return NULL; } + + /*! + read a text file from resource + @param path path to the file to open + @return text from the file + */ + virtual std::string readText(boost::filesystem::path path) { return ""; } + /*! + write a text file to a resource + @param path path to write the file + @param text text to write to file + */ + virtual void writeText(boost::filesystem::path path, std::string text) {} + + /*! + return true if the resource can be written to + */ + inline bool isWritable() { return mb_writable; } + protected: boost::filesystem::path m_path; - bool mb_writable; + + bool mb_writable; + }; - +/*! + Directory Resource - all files are read/written from a directory. Supports writing. +*/ class DIRResource : public Resource { public: DIRResource(boost::filesystem::path path) ; unsigned char* readFile(boost::filesystem::path path, int *size); + std::string readText(boost::filesystem::path path); }; +/*! + Writable directory resource for storing config files +*/ +class WritableDIRResource : public DIRResource +{ + public: + WritableDIRResource(boost::filesystem::path path); + void writeText(boost::filesystem::path path, std::string text); +}; +/*! + PAK file resource - all files are read from a PAK file. Does not support writing. +*/ class PAKResource : public Resource { public: @@ -57,7 +125,9 @@ Pakfile *m_pakfile; }; - +/*! + Class to simplify reading and writing from different resource files. +*/ class ResMan : public Singleton<ResMan> { friend class Singleton<ResMan>; @@ -69,14 +139,58 @@ ~ResMan(); public: + //! @name resource management + //@{ + /*! + add a resource to the manager. the resource will be searched for + in the directory pointed to by Settings::GetDataDir. It will + first search for a directory and then for the pak file + @ param name name of the resource to open + @ return true on success + */ bool addRes(std::string name); + /*! + add an existing resource to the resource manager. + */ + bool addRes(std::string name, Resource *res); + Resource* getResource(std::string name, std::string& filename); + //@} + + //! @name binary functions + //@{ + /*! + read a file from the resource. + @param path path to the file to read + @param size if not NULL the file size is put here + @return file data + */ unsigned char* readFile(std::string name, int *size); - FileLike* readFile(std::string name); + /*! + read a file from the resource. + @param path path to the file to read + @return FileLike object + */ + FileLike* readFile(std::string path); + //@} + //! @name textmode functions + //@{ + /*! + read a text file from resource + @param path path to the file to open + @return text from the file + */ + virtual std::string readText(std::string name); + /*! + write a text file to a resource + @param path path to write the file + @param text text to write to file + */ + virtual void writeText(std::string name, std::string text); + //@} private: ResList m_resources; - }; #endif // DUNE_RESMAN_H Modified: branches/dunks/src/Application.cpp =================================================================== --- branches/dunks/src/Application.cpp 2006-08-08 18:09:59 UTC (rev 92) +++ branches/dunks/src/Application.cpp 2006-08-09 09:46:55 UTC (rev 93) @@ -261,6 +261,10 @@ void Application::LoadData() { + // for config files + // set to the current directory for the moment + ResMan::Instance()->addRes("CONFIG", new WritableDIRResource("") ); + printf("loading resources\n"); ResMan::Instance()->addRes("ATRE"); ResMan::Instance()->addRes("DUNE"); @@ -279,6 +283,13 @@ ResMan::Instance()->addRes("XTRE"); printf("done loading resources\n"); + // example of reading the config file - remove me + std::string config = ResMan::Instance()->readText("CONFIG:config.txt"); + printf("%s\n", config.c_str()); + + config += "newline\n"; + ResMan::Instance()->writeText("CONFIG:config.txt", config); + SetPalette(); int len; @@ -354,7 +365,6 @@ #if 0 fnt->render("ABCDEFGHIJKLMOPQRSTUVWXYZ", m_screen, 10, 10, gpaloff); fnt->render("abcdefghijklmnopqrstuvwxz", m_screen, 10, 30, gpaloff); - #endif #if 1 Modified: branches/dunks/src/ResMan.cpp =================================================================== --- branches/dunks/src/ResMan.cpp 2006-08-08 18:09:59 UTC (rev 92) +++ branches/dunks/src/ResMan.cpp 2006-08-09 09:46:55 UTC (rev 93) @@ -2,6 +2,10 @@ #include "boost/filesystem/operations.hpp" #include "boost/format.hpp" +#include <fstream> +#include <sstream> +#include <iostream> + #include "ResMan.h" #include "Settings.h" //#include "Log.h" @@ -37,6 +41,11 @@ // ------------------------------------------------------------------ +Resource::Resource() +{ + mb_writable = false; +}; + Resource::~Resource() { @@ -52,7 +61,8 @@ unsigned char* DIRResource::readFile(bfs::path path, int *size) { // TODO: seems to work now, tested on linux, please test it on windows. (otpetrik) - bfs::path fullpath (m_path.string() + "/" + path.string()); + bfs::path fullpath (m_path); + fullpath /= path; FILE *file = fopen (fullpath.string().c_str(), "rb"); fseek(file, 0, SEEK_END); @@ -71,8 +81,46 @@ return buf; }; +std::string DIRResource::readText(boost::filesystem::path path) +{ + bfs::path fullpath (m_path); + fullpath /= path; + std::string file_contents; + printf("openin... [truncated message content] |
From: <otp...@us...> - 2006-08-08 18:10:29
|
Revision: 92 Author: otpetrik Date: 2006-08-08 11:09:59 -0700 (Tue, 08 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=92&view=rev Log Message: ----------- - added config file (preview version ;-) ) Modified Paths: -------------- branches/dunks/include/Strings.h branches/dunks/src/SConscript branches/dunks/src/Strings.cpp Added Paths: ----------- branches/dunks/include/ConfigFile.h branches/dunks/src/ConfigFile.cpp Added: branches/dunks/include/ConfigFile.h =================================================================== --- branches/dunks/include/ConfigFile.h (rev 0) +++ branches/dunks/include/ConfigFile.h 2006-08-08 18:09:59 UTC (rev 92) @@ -0,0 +1,539 @@ +/*! + \file ConfigFile.h + \brief Config file parsing & saving stuff + + @warning + Be sure that your config file is in proper format, there are not many checks. + + @warning + Although current implementation might process some paths with whitespace + (eg: node.justanarray [5] . foo), the future ones won't !! + + @note + The code is quite crude, so if you encounter any problem, let me know. (otpetrik) + + TODO: rewrite it to provide help for correcting input files + (depends on: input caches providing current position (row & column) and free time) + + @note + Example of use: + + @code + // root node of config file tree + ConfigFile::NodePtr root; + + if (data != NULL) + { + // load the config file from a string (use data.c_str() if you have real String) + root = ConfigFile::loadFile((const char *)data); + } + + // + // make sure that requred nodes exist + // - this is simple version, it would fail if the config file exists but + // it doesn't have the required nodes... + // + // note: this won't be necessary once config file is fully finished... + // (set & bind functions will create the necessary nodes) + + if (root == NULL) + { + root = ConfigFile::NodePtr(new ConfigFile::MapNode()); + ConfigFile::MapNodePtr mapNode; + ConfigFile::MapNodeNodes *map; + mapNode = ConfigFile::getMapNode("", root); + + map = mapNode->getNodes(); + map->insert(std::make_pair("graphics_settings", new ConfigFile::MapNode())); + map->insert(std::make_pair("game_settings", new ConfigFile::MapNode())); + + mapNode = ConfigFile::getMapNode("graphics_settings", root); + map = mapNode->getNodes(); + + map->insert(std::make_pair("width", new ConfigFile::ValueNode("640"))); + map->insert(std::make_pair("height", new ConfigFile::ValueNode("480"))); + map->insert(std::make_pair("fullscreen", new ConfigFile::ValueNode("0"))); + + mapNode = ConfigFile::getMapNode("game_settings", root); + map = mapNode->getNodes(); + + map->insert(std::make_pair("difficulty", new ConfigFile::ValueNode("Easy"))); + map->insert(std::make_pair("player_name", new ConfigFile::ValueNode("Player"))); + }; + + // variables to use + int screen_width, screen_height; + int fullscreen; + String playerName; + String difficulty; + + // bind the variables to config file + // + // or you can use get & set + // + ConfigFile::bind("graphics_settings.width", root, screen_width, 640); + ConfigFile::bind("graphics_settings.height", root, screen_height, 480); + ConfigFile::bind("graphics_settings.fullscreen", root, fullscreen, 0); + + ConfigFile::bind("game_settings.player_name", root, playerName, String("Player")); + ConfigFile::bind("game_settings.difficulty", root, difficulty, String("Easy")); + + // do whatever you need with variables + fullscreen = 1; + screen_width = 1024; + screen_height = 768; + difficulty = "Hard"; + + // save the config file to a string + String output = ConfigFile::saveFile(root); + + @endcode +*/ + +#ifndef DUNE_CONFIGFILE_H +#define DUNE_CONFIGFILE_H + +#include "Strings.h" + +#include <vector> +#include <map> +#include <set> +#include <boost/shared_ptr.hpp> +#include <boost/enable_shared_from_this.hpp> + +namespace ConfigFile +{ + +//------------------------------------------------------------------------------ +// Binders +//------------------------------------------------------------------------------ + +//! Generic binder +/*! + Common ancestor of different binders +*/ +class GenericBinder +{ +public: + //! @name Constructors & Destructor + //@{ + + //! Constructor + GenericBinder() { } + + //! Destructor + virtual ~GenericBinder() { }; + + //@} + + //! @name Access + //@{ + + //! Return value of target variable as string + virtual String getString() = 0; + + //! Set value of target variable from given string + virtual void setString(ConstString value) = 0; + + //@} +}; + +//! Binder specific to type T +/*! + Allows binding of (almost) any variable. + + @note + It doesnt work well with bool, don't know why :( (otpetrik) + + @see ValueNode +*/ +template <typename T> +class Binder : public GenericBinder +{ +public: + //! @name Constructors & Destructor + //@{ + + //! Constructor + /*! + @param variable variable to bind to + */ + Binder(T &variable) : variable(variable) + { + }; + //@} + + virtual String getString() + { + return toString<T>(variable); + }; + virtual void setString(ConstString value) + { + variable = fromString<T>(value); + }; +protected: + T &variable; +}; + +typedef boost::shared_ptr<GenericBinder> BinderPtr; + +//------------------------------------------------------------------------------ +// Nodes +//------------------------------------------------------------------------------ + +class Node; +class ArrayNode; +class MapNode; +class ValueNode; + +typedef boost::shared_ptr<Node> NodePtr; +typedef boost::shared_ptr<ArrayNode> ArrayNodePtr; +typedef boost::shared_ptr<MapNode> MapNodePtr; +typedef boost::shared_ptr<ValueNode> ValueNodePtr; + +typedef std::vector<NodePtr> ArrayNodeNodes; +typedef std::map<const String, NodePtr> MapNodeNodes; + +//------------------------------------------------------------------------------ +// Node class +//------------------------------------------------------------------------------ +//! Generic node +/*! + Common ancestor of all nodes. +*/ +class Node : public boost::enable_shared_from_this<Node> +{ + public: + //! @name Constructors & Destructor + //@{ + + //! Constructor + Node(); + //! Destructor + virtual ~Node(); + + //@} + + //! @name Loading & Saving + //@{ + + //! Load contents of current node + /*! + @param cache cache to load from + + @note + There is possibility, to call load more than once (for updates) ! + */ + virtual void load(StringInputCache &cache) = 0; + //! Save contents of current node + /*! + @param cache cache to save to + */ + virtual void save(StringOutputCache &cache) = 0; + + //@} + + //! @name Accessing child nodes + //@{ + + //! Save contents of current node + /*! + @param path input cache containing the path to the node (eg: something.another[2].thing) + */ + virtual NodePtr getNode(StringInputCache &path) = 0; + + //@} + protected: +}; + +//------------------------------------------------------------------------------ +// ArrayNode class +//------------------------------------------------------------------------------ +//! Array node +/*! + Contains child nodes indexed by an unsigned integer +*/ +class ArrayNode : public Node +{ + public: + virtual void load(StringInputCache &cache); + virtual void save(StringOutputCache &cache); + + virtual NodePtr getNode(StringInputCache &path); + + //! Return underlying std::vector + /*! + @note + Although it breaks encapsulation, it allows the most powerfull access + to child nodes... + */ + ArrayNodeNodes *getNodes() { return &nodes; }; + protected: + ArrayNodeNodes nodes; +}; + +//------------------------------------------------------------------------------ +// MapNode class +//------------------------------------------------------------------------------ +//! Map node +/*! + Contains child nodes indexed by a string +*/ +class MapNode : public Node +{ + public: + virtual void load(StringInputCache &cache); + virtual void save(StringOutputCache &cache); + + virtual NodePtr getNode(StringInputCache &path); + + //! Return underlying std::map + /*! + @note + Although it breaks encapsulation, it allows the most powerfull access + to child nodes... + */ + MapNodeNodes *getNodes() { return &nodes; }; + protected: + MapNodeNodes nodes; + + void loadChild(StringInputCache &cache); + void loadChildValue(ConstString childName, StringInputCache &cache); +}; + +//------------------------------------------------------------------------------ +// ValueNode class +//------------------------------------------------------------------------------ +//! Value node +/*! + Leaf node containg a string +*/ +class ValueNode : public Node +{ + public: + //! @name Constructors & Destructor + //@{ + + //! Constructor + /*! + @param value initial value of the node + */ + ValueNode(ConstString value = "") : value(value), binder((GenericBinder *)NULL) { }; + + //@} + virtual void load(StringInputCache &cache); + virtual void save(StringOutputCache &cache); + + virtual NodePtr getNode(StringInputCache &path); + + //! @name Value access + //@{ + + //! Return current value + ConstString getValue(); + + //! Set current string + /*! + @warning + It is your responsibility to set the string to a value, that can be parsed again + + TODO: Remove this warning once there is protection agains special chars + (add escape & unescape to Strings) + */ + void setValue(ConstString value); + + //@} + + //! @name Binding + //@{ + + //! Get current binder + BinderPtr getBinder() + { + return binder; + } + + //! Set binder + /* + @note + NULL is allowed. + */ + void setBinder(BinderPtr binder) + { + this->binder = binder; + if (binder != NULL) + binder->setString(value); + } + + //@} + + protected: + String value; + BinderPtr binder; +}; + +//------------------------------------------------------------------------------ +// Functions +//------------------------------------------------------------------------------ + +//! Return a new node +/* + Returns new node, type is guessed from contents of the cache + + @param cache cache to use for guessing + + @note + Do not use this function, it will be probably removed in the future ! +*/ +NodePtr newNode(StringInputCache &cache); + +//! @name Load & Save +//@{ + +//! Load a config file +/* + @param input string to be used for assembling the tree + @return root of the config file node tree +*/ +NodePtr loadFile(ConstString input); + +//! Save a config file +/* + @param root of the config file node tree + @return string containg the config file +*/ +String saveFile(NodePtr root); + +//@} + +//! @name Get nodes by path +//@{ + +//! Return given node +/* + @param path path to the node + @param base node the path is relative to + + @return pointer to the given node (or NULL if node not found) +*/ +inline NodePtr getNode(ConstString path, NodePtr base) +{ + StringInputCache cache(path); + NodePtr node; + + // TODO: or silently return NULL if base is NULL ? + assert(base != NULL); + return base->getNode(cache); +}; + +//! Return given node as array node (if possible) +/* + @param path path to the node + @param base node the path is relative to + + @return pointer to the given node (or NULL if node not found) +*/ +inline ArrayNodePtr getArrayNode(ConstString path, NodePtr base) +{ + NodePtr node = getNode(path, base); + return (node != NULL) ? (boost::dynamic_pointer_cast<ArrayNode>(node)) : ArrayNodePtr((ArrayNode *)NULL); +} + +//! Return given node as map node (if possible) +/* + @param path path to the node + @param base node the path is relative to + + @return pointer to the given node (or NULL if node not found) +*/ +inline MapNodePtr getMapNode(ConstString path, NodePtr base) +{ + NodePtr node = getNode(path, base); + return (node != NULL) ? (boost::dynamic_pointer_cast<MapNode>(node)) : MapNodePtr((MapNode *)NULL); +} + +//! Return given node as value node (if possible) +/* + @param path path to the node + @param base node the path is relative to + + @return pointer to the given node (or NULL if node not found) +*/ +inline ValueNodePtr getValueNode(ConstString path, NodePtr base) +{ + NodePtr node = getNode(path, base); + return (node != NULL) ? (boost::dynamic_pointer_cast<ValueNode>(node)) : ValueNodePtr((ValueNode *)NULL); +} + +//@} + +//! @name Get & set node values by path +//@{ + +//! Get value of given node +/* + @param path path to the node + @param base node the path is relative to + @param defaultValue value to return if node is not found + + @return node value of defaultValue +*/ +template <typename T> +T get(ConstString path, NodePtr base, const T &defaultValue) +{ + ValueNodePtr valueNode = getValueNode(path,base); + if (valueNode == NULL) + return defaultValue; + return fromString<T>(valueNode->getValue()); +}; + +//! Set value of given node +/* + @param path path to the node + @param value value to set node to + @param base node the path is relative to + + @note + The order of parameters is different from set on purpose ! + + @note + It will crash if node is not found. + TODO: once the implemntation is changed, update this note + +*/ +template <typename T> +void set(ConstString path, const T &value, NodePtr base) +{ + // TODO: create node if possible ! + getValueNode(path,base)->setValue(toString(value)); +}; + +//@} + +//! @name Binding +//@{ + +//! Bind node to given variable +/* + @param path path to the node + @param base node the path is relative to + @param variable reference to variable to bind to (the variable has to exist + till the destruction of the node in question) + @param defaultValue value to set newly created node to (if node is not found) !!! currently unused !!! + + @note + It will crash if node is not found. + TODO: once the implemntation is changed, update this note +*/ +template <typename T> +void bind(ConstString path, NodePtr base, T& variable, const T &defaultValue) +{ + // TODO: create node if possible ! (and set it to defaultValue) + getValueNode(path,base)->setBinder(BinderPtr(new Binder<T>(variable))); +}; + +//@} + +} // namespace ConfigFile + +#endif Modified: branches/dunks/include/Strings.h =================================================================== --- branches/dunks/include/Strings.h 2006-08-07 21:45:52 UTC (rev 91) +++ branches/dunks/include/Strings.h 2006-08-08 18:09:59 UTC (rev 92) @@ -2,8 +2,7 @@ \file Strings.h \brief String related stuff - @note - There are only typedefs for now, but soon there will be caches to parse strings easier. + TODO: add something to get position from the input caches (row & column) ! */ #ifndef DUNE_STRINGS_H #define DUNE_STRINGS_H @@ -57,4 +56,185 @@ //@} +//------------------------------------------------------------------------------ +// StringInputCache class +//------------------------------------------------------------------------------ +//! Cache for reading strings +/*! + Allows easier way to read a string by parts. +*/ +class StringInputCache +{ + public: + + //! @name Constructors & Destructor + //@{ + + //! Constructor + /* + @param input string to parse + + @note Local copy of input is made. + */ + StringInputCache(const char *input); + //! Constructor + /* + @param input string to parse + + @note Local copy of input is made. + */ + StringInputCache(ConstString input); + + //! Destructor + ~StringInputCache(); + + //@} + + //! @name Get & Peek + //@{ + + //! Return string from the cache and advance position + /*! + @note The delimiter is not part of returned string. + */ + String getWord(ConstString delimiters = "\n\t /*,.[="); + //! Return string from the cache and do NOT advance position + /*! + @note The delimiter is not part of returned string. + */ + String peekWord(ConstString delimiters = "\n\t /*,.[="); + //! Return char from the cache and advance position + char getChar(); + //! Return char from the cache and do NOT advance position + char peekChar(); + + //@} + + //! @name Skipping + //@{ + + //! Skip given characters + /*! + While current character is one of the chars, advance. + + @param chars characters to skip + + @note Defaults to whitespace + */ + void skipChars(ConstString chars = "\n\t "); + //! Skip anything but given characters + /*! + While current character is NOT one of the chars, advance. + + @param chars characters to stop on + */ + void skipCharsUntil(ConstString chars); + + //! Skip whitespace and comments + /*! + Advance till non-whitespace and non-comment is encountered. + + @note + Two types of comments are recognized, C and C++. + The C comments cannot be nested. + */ + void skipWhitespace(); + + //@} + + //! @name Seeking + //@{ + + //! Is end of string reached ? + bool isEos(); // end of string ;-) + + //! Get current position in cache + int getPosition(); + + //! Seek to given position + void seek(int position); + + //! Advance number of characters + /*! + Move number characters forward. + + @param number number of characters to move forvard (defaults to 1) + + @note + Negative number is allowed for backward movement; + */ + void advance(int number = 1); + + //@} + + // returns rest of the string (make your own copy !) + //! return C-like string + /*! + @note + Inner copy is returned, do not modify ! + */ + const char *c_str(); + + protected: + char *data; + int length; + int index; +}; + +//------------------------------------------------------------------------------ +// StringOutputCache class +//------------------------------------------------------------------------------ +//! Cache for writing strings +/*! + Allows easier way to write strings. +*/ +class StringOutputCache +{ + public: + //! @name Constructors & Destructor + //@{ + + //! Constructor + StringOutputCache(); + //! Destructor + ~StringOutputCache(); + + //@{ + + //! @name Indentation + //@{ + + //! Indent one level more + void indent() + { + indentLevel++; + }; + //! Indent one level less + void unindent() + { + if (indentLevel > 0) + indentLevel--; + }; + //@} + + //! Add given string + /*! + @param str string to add + + @note + After each newline character, a number of spaces is added + (depending on current indentation) + */ + void add(ConstString str); + + //! Get resulting string + inline String getString() + { + return data; + } + protected: + String data; + int indentLevel; +}; + #endif // DUNE_STRINGS_H Added: branches/dunks/src/ConfigFile.cpp =================================================================== --- branches/dunks/src/ConfigFile.cpp (rev 0) +++ branches/dunks/src/ConfigFile.cpp 2006-08-08 18:09:59 UTC (rev 92) @@ -0,0 +1,511 @@ +/* +notes: node->load gets string that starts on the real value (= no whitespace on the beginning) +update Log to allow indentation !! (and use it !) + + + +todo: change to +map: +loading = get node, node->loadvalue + +*/ +#include "ConfigFile.h" + +#include "Log.h" + +namespace ConfigFile +{ + +//------------------------------------------------------------------------------ +// Node class +//------------------------------------------------------------------------------ +Node::Node() +{ +}; +Node::~Node() +{ +}; + +void Node::load(StringInputCache &cache) +{ +}; +void Node::save(StringOutputCache &cache) +{ +}; + +NodePtr Node::getNode(StringInputCache &path) +{ + return shared_from_this(); +}; + + +//------------------------------------------------------------------------------ +// ArrayNode class +//------------------------------------------------------------------------------ +void ArrayNode::load(StringInputCache &cache) +{ + /* + got: + a) |(*) -> '()' mode + b) |[index] = -> 'index' mode + c) something other -> error + */ +// cache.skipCharsUntil("(["); + + switch (cache.peekChar()) + { + case '(': + // '()' mode + LOG_INFO("CfgFile", "ArrayNode::load - '()' mode"); + + // skip '(' + cache.advance(); + + // skip whitespace before element child value or ')' + cache.skipWhitespace(); + + // load elements + while (cache.peekChar() != ')') + { + // skip whitespace here + cache.skipWhitespace(); + + // load the child element + NodePtr child = newNode(cache); + child->load(cache); + nodes.push_back(child); + + cache.skipCharsUntil(",)"); + + if (cache.peekChar() == ')') + break; + + // skip , + cache.advance(); + + // skip whitespace + cache.skipWhitespace(); + } + + // skip ')' + cache.advance(); + + break; + case '[': + // 'index' mode + LOG_INFO("CfgFile", "ArrayNode::load - 'index' mode"); + + // to avoid error about skipping inicialization of indexString & index + { + + // skip '[' + cache.advance(); + + // skip whitespace + cache.skipWhitespace(); + + // load the index + String indexString; + unsigned index; + NodePtr childNode; + + indexString = cache.getWord("]/*"); + LOG_INFO("CfgFile", "ArrayNode::load - 'index string' = '%s'", indexString.c_str()); + + // skip whitespace + cache.skipWhitespace(); + + // skip ']' + cache.advance(); + + // and convert it to number + index = atoi(indexString.c_str()); + + // if the index is good enough, then load the value + if (index < nodes.size()) + { + // good, update existing node + nodes[index]->load(cache); + } + else if (index == nodes.size()) + { + // good, create new node + NodePtr child = newNode(cache); // guess type of child + nodes.push_back(child); + child->load(cache); + } + else + { + // bad, ignore too big index + LOG_ERROR("CfgFile", "ArrayNode::load - invalid index (%d) of child node for array (%d)", index, nodes.size()); + }; + }; + break; + default: + // this should not happen + LOG_ERROR("CfgFile", "ArrayNode::load - tried to load array in unknown mode (char '%c') !", cache.peekChar()); + }; + LOG_INFO("CfgFile", "ArrayNode::load - done"); +}; +void ArrayNode::save(StringOutputCache &cache) +{ + cache.add("("); + for (ArrayNodeNodes::iterator i = nodes.begin(); i != nodes.end(); i++) + { + if (i != nodes.begin()) + cache.add(", "); + (*i)->save(cache); + } + cache.add(")"); +}; + +// understands [something] +NodePtr ArrayNode::getNode(StringInputCache &path) +{ + String indexString; + unsigned index; + MapNodeNodes::iterator i; + NodePtr node; + + // skip possible whitespace + path.skipWhitespace(); + + // am i requested ? + if (path.isEos()) + return shared_from_this(); // smartpointer to this + + // skip to opening '[' + path.skipCharsUntil("["); + path.skipChars("["); + path.skipWhitespace(); + + // get name index (stop by whitespace, comment, = or sub-child delimiter) + indexString = path.getWord("\n\t ]/"); + + // skip possible whitespace after the index + path.skipWhitespace(); + path.skipChars("]"); + path.skipWhitespace(); + + // and convert it to number + index = atoi(indexString.c_str()); + + LOG_INFO("CfgFile", "ArrayNode::get - request index '%s' -> %d (array size %d)", indexString.c_str(), index, nodes.size()); + + // if the index is good enough, then retrieve the node + if (index < nodes.size()) + { + node = nodes[index]; + } + else + { + // bad, ignore too big index + LOG_ERROR("CfgFile", "ArrayNode::get - invalid index ('%s' -> %d) of child node for array (%d)", indexString.c_str(), index, nodes.size()); + return NodePtr((Node *)NULL); + }; + + return node->getNode(path); +}; + +// ArrayNodeNodes nodes; + +//------------------------------------------------------------------------------ +// MapNode class +//------------------------------------------------------------------------------ +void MapNode::load(StringInputCache &cache) +{ + /* + method can get: + a) |{*} -> '{}' mode + b) |.mychild* -> '.subchild' mode + c) something other -> error + */ + MapNodeNodes::iterator i; + String childName; + NodePtr childNode; + + // skip whitespace before name of child node + // (actually requred only if there is whitespace before the toplevevel map) + cache.skipWhitespace(); + + // determine the mode + switch(cache.peekChar()) + { + case '{': + // '{}' mode + LOG_INFO("CfgFile", "MapNode::load - '{}' mode"); + + // skip '{' + cache.advance(); //skip '{' + + // remove all children nodes + // (this run can be an update called on this node) + nodes.clear(); + + // till the end of map + while (cache.peekChar() != '}') + { + + // skip whitespace before name of child node + cache.skipWhitespace(); + + // TODO: skip possible comment (end by continue !) + + // load the child element (childelement = something) + loadChild(cache); + + // skip (possible text left after child loading) to ';' + cache.skipCharsUntil(";"); + + // skip ';' + cache.advance(); + + // skip whitespace (next is either new pair of 'item = value', '}' or comment + cache.skipWhitespace(); + }; + break; + case '.': + LOG_INFO("CfgFile", "MapNode::load - '.subchild' mode"); + + // skip '.' + cache.advance(); + + // load the child element (childelement = something) + loadChild(cache); + + // NOTE: do not check for ';' ! It will be ckecked by the topmost mapnode (the one processed in '{}' mode) + break; + default: + // this should not happen + LOG_ERROR("CfgFile", "MapNode::load - tried to load map in unknown mode !"); + }; + LOG_INFO("CfgFile", "MapNode::load - done"); +}; +void MapNode::save(StringOutputCache &cache) +{ + cache.add("{"); + cache.indent(); + for (MapNodeNodes::iterator i = nodes.begin(); i != nodes.end(); i++) + { + cache.add("\n"); + cache.add(i->first); + cache.add(" = "); + i->second->save(cache); + cache.add(";"); + } + cache.unindent(); + cache.add("\n}"); +}; + +NodePtr MapNode::getNode(StringInputCache &path) +{ + String childName; + MapNodeNodes::iterator i; + + // skip possible whitespace + path.skipWhitespace(); + + // skip possible leading '.' + if (path.peekChar() == '.') + path.advance(); + +// path.skipChars("."); + + path.skipWhitespace(); + + // am i requested ? + if (path.isEos()) + return shared_from_this(); // smartpointer to this + + // get name of child node (stop by whitespace, comment, = or sub-child delimiter) + childName = path.getWord("\n\t /*.[="); + LOG_INFO("CfgFile", "MapNode::get - requested child ('%s') !", childName.c_str()); + + // skip possible whitespace after child name + path.skipWhitespace(); + + // find it + i = nodes.find(childName); + if (i == nodes.end()) + { + // TODO: remove this warning, it would fill the log while querying the config file ! + LOG_WARNING("CfgFile", "MapNode::get - child unknown ('%s'), but not allowed to create it !", childName.c_str()); + return NodePtr((Node *)NULL); + }; + + return (i->second)->getNode(path); +}; + +void MapNode::loadChild(StringInputCache &cache) +{ + String childName; + + // get name of child node (stop by whitespace, comment, = or sub-child delimiter) + childName = cache.getWord("\n\t /*.[="); + + // and read possible whitespace after it (-> next is '.[' for subchild updates or '=' for child update) + cache.skipWhitespace(); + + // log name of the child + LOG_INFO("CfgFile", "MapNode::loadChild - loading child '%s'", childName.c_str()); + + // is child name is followed by delimiter ? + if (cache.peekChar() == '.' || cache.peekChar() == '[') + { + // yes, then delegate parsing to the child - it is an child's update + // (means: update called on child (= subchild nodes are inserted/replaced)) + LOG_INFO("CfgFile", "MapNode::loadChild - delegating to child of type '%s'", (cache.peekChar() == '.' ) ? "map" : "array"); + + // load the value + loadChildValue(childName, cache); + } + else + { + // no, it is change of one of this node childs, handle here + LOG_INFO("CfgFile", "MapNode::loadChild - handling myself"); + + // skip to '=' + cache.skipCharsUntil("="); + + // skip '=' + cache.advance(); + + // skip whitespace before the actual value; + cache.skipWhitespace(); + + // load the value + loadChildValue(childName, cache); + }; + LOG_INFO("CfgFile", "MapNode::loadChild - child '%s' loaded", childName.c_str()); +}; + + +void MapNode::loadChildValue(ConstString childName, StringInputCache &cache) +{ + NodePtr child; + /* + got the part after | : + itemA = |value + itemB|[2] = value + itemC| = value + itemC|.subitem = value + */ + MapNodeNodes::iterator i; + i = nodes.find(childName); + + cache.skipChars("\n\t "); // get to the word + if (i == nodes.end()) + { + LOG_INFO("CfgFile", "loadChildValue NEW CHILD '%s'", childName.c_str()); + child = newNode(cache); // get new node of guessed type + nodes[childName] = child; + } + else + { + LOG_INFO("CfgFile", "loadChildValue KNOWN CHILD'%s'", childName.c_str()); + child = i->second; // get alredy existing node of same name + } + + child->load(cache); + LOG_INFO("CfgFile", "loadChildValue DONE '%s'", childName.c_str()); +} + + +// MapNodeNodes nodes; + +//------------------------------------------------------------------------------ +// ValueNode class +//------------------------------------------------------------------------------ +void ValueNode::load(StringInputCache &cache) +{ + char c; + + c = cache.peekChar(); + if ((c == '"') || (c == '\'')) + { + cache.advance(); // skip opening + value = cache.getWord(String("")+c); // TODO: is there a better way ? + cache.advance(); // skip closing + } + else + value = cache.getWord("\n\t /*,);"); + + if (binder != NULL) + binder->setString(value); + + LOG_INFO("CfgFile", "ValueNode::load - value: '%s'", value.c_str()); +}; +void ValueNode::save(StringOutputCache &cache) +{ + if (binder != NULL) + value = binder->getString(); + cache.add(value); +}; + +ConstString ValueNode::getValue() +{ + LOG_WARNING("CfgFile", "ValueNode::getValue - returned ('%s') !", value.c_str()); + return value; +}; +void ValueNode::setValue(ConstString value) +{ + this->value = value; +}; + +NodePtr ValueNode::getNode(StringInputCache &path) +{ + // skip possible whitespace + path.skipWhitespace(); + + // warn if next char is not = + #ifndef DISABLE_LOG + if (path.isEos() == false) + { + LOG_WARNING("CfgFile", "ValueNode::get - got non empty path ('%s') !", path.peekWord().c_str()); + } + #endif + + return shared_from_this(); +}; + +// String value; + +//------------------------------------------------------------------------------ +// Functions +//------------------------------------------------------------------------------ + +NodePtr newNode(StringInputCache &cache) +{ + LOG_INFO("CfgFile", "newNode got '%c'", cache.peekChar()); + switch (cache.peekChar()) + { + case '(': // normal mode + case '[': // update mode + return NodePtr(new ArrayNode()); + case '{': // normal mode + case '.': // update mode + return NodePtr(new MapNode()); + default: + return NodePtr(new ValueNode()); + } +}; + +NodePtr loadFile(ConstString input) +{ + StringInputCache c(input); + ConfigFile::NodePtr node = ConfigFile::newNode(c); + node->load(c); + return node; +}; + +String saveFile(NodePtr root) +{ + StringOutputCache c; + + assert(root != NULL); + root->save(c); + + return c.getString(); +}; + +} // namespace ConfigFile Modified: branches/dunks/src/SConscript =================================================================== --- branches/dunks/src/SConscript 2006-08-07 21:45:52 UTC (rev 91) +++ branches/dunks/src/SConscript 2006-08-08 18:09:59 UTC (rev 92) @@ -29,6 +29,7 @@ "houses.cpp", # just for colors, hope there will be a better place for these (otpetrik) "Strings.cpp", "Log.cpp", + "ConfigFile.cpp", "ResMan.cpp", ] Modified: branches/dunks/src/Strings.cpp =================================================================== --- branches/dunks/src/Strings.cpp 2006-08-07 21:45:52 UTC (rev 91) +++ branches/dunks/src/Strings.cpp 2006-08-08 18:09:59 UTC (rev 92) @@ -1,8 +1,205 @@ #include "Strings.h" #include "Log.h" +/* +NOTE: +LOG lines are commented out (the log would be one big mess), to debug code using +string caches, just uncomment the lines you need... +(and remebmer to comment them again before you commit) + +*/ + #include <string.h> -// there will be code, soon... (otpetrik) +//------------------------------------------------------------------------------ +// StringInputCache class +//------------------------------------------------------------------------------ +StringInputCache::StringInputCache(const char *input) : data(NULL), length(0), index(0) +{ + assert(input != NULL); + length = strlen(input) + 1; + data = (char *) malloc(length); + strncpy(data, input, length); // copy with NULL character from source +// LOG_INFO("String", "StringInputCache: initialized !!! '%s' !!!", data); +}; +StringInputCache::StringInputCache(ConstString input) : data(NULL), length(0), index(0) +{ + const char *chars = input.c_str(); + length = strlen(chars) + 1; + data = (char *) malloc(length); + strncpy(data, chars, length); // copy with NULL character from source +// LOG_INFO("String", "StringInputCache: initialized '%s'", data); +}; +StringInputCache::~StringInputCache() +{ + free(data); +}; + +String StringInputCache::getWord(ConstString delimiters) +{ + int wordLength; // relative to current position + wordLength = strcspn(data + index, delimiters.c_str()); // stops on NULL + + index += wordLength; +// LOG_INFO("String", "getWord: '%c' | '%c' '%c'", *(data+index-1), *(data+index), *(data+index+1)); + return String(data + index - wordLength, wordLength);; +}; +String StringInputCache::peekWord(ConstString delimiters) +{ + int wordLength; // relative to current position + wordLength = strcspn(data + index, delimiters.c_str()); // stops on NULL + +// LOG_INFO("String", "peekWord: '%c' | '%c' '%c'", *(data+index-1-wordLength), *(data+index-wordLength), *(data+index+1-wordLength)); + return String(data + index, wordLength);; +}; + +char StringInputCache::getChar() +{ +// LOG_INFO("String", "getChar: '%c'", *(data+index)); + return *(data + (index++)); // TODO: remove this todo once sure that it really works ;-) +}; + +char StringInputCache::peekChar() +{ +// LOG_INFO("String", "peekChar: '%c'", *(data+index)); + return *(data + index); +}; + +void StringInputCache::skipChars(ConstString chars) +{ + while ((*(data + index) != 0) && (chars.find((char)*(data+index), 0) != String::npos)) + { +// LOG_INFO("String", "StringInputCache: skipping(normal = '%s') '%c'", chars.c_str(), *(data+index)); + index++; + } +}; + +void StringInputCache::skipCharsUntil(ConstString chars) +{ + while ((*(data + index) != 0) && (chars.find((char)*(data+index), 0) == String::npos)) + { +// LOG_INFO("String", "StringInputCache: skipping(until = '%s') '%c'", chars.c_str(), *(data+index)); + index++; + } +}; + +void StringInputCache::skipWhitespace() +{ + skipChars(); + while (peekChar() == '/') + { + advance(); + switch (peekChar()) + { + // C++ style comment + case '/': + // skip '/' + advance(); + + // get to the end of line + skipCharsUntil(String("")+'\n'); + + // skip it + advance(); + + break; + // C style comment + case '*': + // skip '*' + advance(); + + do { + + // get to the end of line + skipCharsUntil(String("")+'*'); + + // skip * + advance(); + + // TODO: check also for EOF !!! + + } while (peekChar() != '/'); + + // skip '/' + advance(); + + break; + // not a comment, we're done here... + default: + // put that char ('/') back to the cache + advance(-1); + return; + }; + + // remove whitespace that might be before next comment + skipChars(); + }; + + // remove whitespace after comment + skipChars(); +}; + +bool StringInputCache::isEos() +{ + // NOTE: if this assert fails, then some method crossed the EOS boundary !!! + assert(index < length); + return (index == length-1); +}; + +int StringInputCache::getPosition() +{ + return index; +}; +void StringInputCache::seek(int position) +{ + index = position; + if (index < 0) + index = 0; + if (index >= length) + index = length - 1; +}; + +void StringInputCache::advance(int number) +{ + // TODO: this probably won't work on windows while skipping '\n' character :( + // if the file was read in binary mode !!! + // otpetrik: need someone with Windows to check and fix somehow if possible... + + seek(index + number); +}; + +// returns rest of the string (make your own copy !) +const char *StringInputCache::c_str() +{ + return (data + index); +}; + + +//------------------------------------------------------------------------------ +// StringOutputCache class +//------------------------------------------------------------------------------ +StringOutputCache::StringOutputCache() : indentLevel(0) +{ +}; +StringOutputCache::~StringOutputCache() +{ +}; + +void StringOutputCache::add(ConstString str) +{ + unsigned index = 0; // where to start searching form + unsigned nlIndex = 0; + + while ((nlIndex = str.find('\n', index)) != String::npos) + { + data += str.substr(index, nlIndex-index); + data += '\n'; + for (int i = 0; i <= indentLevel; i++) + data += " "; // 4 spaces for one indent level + // start next search after the newline + index = nlIndex+1; + } + data += str.substr(index); +}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <shu...@us...> - 2006-08-07 21:46:04
|
Revision: 91 Author: shutdownrunner Date: 2006-08-07 14:45:52 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=91&view=rev Log Message: ----------- - Make boring buttons really interesting Modified Paths: -------------- branches/dunks/src/gui2/Button.cpp Modified: branches/dunks/src/gui2/Button.cpp =================================================================== --- branches/dunks/src/gui2/Button.cpp 2006-08-07 18:22:16 UTC (rev 90) +++ branches/dunks/src/gui2/Button.cpp 2006-08-07 21:45:52 UTC (rev 91) @@ -128,19 +128,57 @@ SDL_SetColors(m_surfPressed, pal->colors, 0, pal->ncolors); SDL_FillRect(m_surfNormal, NULL, 115); - SDL_FillRect(m_surfPressed, NULL, 115); + SDL_FillRect(m_surfPressed, NULL, 116); + /* + * Button normal + */ + // top lines + drawHLine(m_surfNormal, 0, 0, m_width-1, 229, false); + drawHLine(m_surfNormal, 0, 1, m_width-3, 108, false); + + // left lines + drawVLine(m_surfNormal, 0, 0, m_height-1, 229, false); + drawVLine(m_surfNormal, 1, 1, m_height-2, 108, false); - // dark brown box - SDL_Rect r = {0, 0, m_width -1, m_height -1}; - drawRect(m_surfNormal, r, 229, false); + // bottom lines + drawHLine(m_surfNormal, 1, m_height-2, m_width-2, 226, false); + drawHLine(m_surfNormal, 0, m_height-1, m_width-1, 229, false); + + // right lines + drawVLine(m_surfNormal, m_width-1, 0, m_height-1, 229, false); + drawVLine(m_surfNormal, m_width-2, 1, m_height-2, 226, false); + + // final pixels to make it look really duneish + putPixel(m_surfNormal, 1, m_height-2, 115); + putPixel(m_surfNormal, m_width-2, 1, 115); + putPixel(m_surfNormal, m_width-2, m_height-2, 227); - // bottom line - drawHLine(m_surfNormal, 0, m_height-1, m_width-1, 226, false); - // far right line - drawVLine(m_surfNormal, m_width-1, 0, m_height-1, 226, false); + + /* + * Button pressed + */ + // top lines + drawHLine(m_surfPressed, 0, 0, m_width-1, 229, false); + drawHLine(m_surfPressed, 0, 1, m_width-3, 226, false); + + // left lines + drawVLine(m_surfPressed, 0, 0, m_height-1, 229, false); + drawVLine(m_surfPressed, 1, 1, m_height-2, 226, false); - + // bottom lines + drawHLine(m_surfPressed, 1, m_height-2, m_width-2, 226, false); + drawHLine(m_surfPressed, 0, m_height-1, m_width-1, 229, false); + + // right lines + drawVLine(m_surfPressed, m_width-1, 0, m_height-1, 229, false); + drawVLine(m_surfPressed, m_width-2, 1, m_height-2, 226, false); + + // final pixels to make it look really duneish + putPixel(m_surfPressed, 1, m_height-2, 227); + putPixel(m_surfPressed, m_width-2, 1, 227); + putPixel(m_surfPressed, m_width-2, m_height-2, 227); + Font* font = FontManager::Instance()->getFont("INTRO:INTRO.FNT"); Uint16 textw, texth; @@ -148,10 +186,10 @@ font->render(m_caption.c_str(), m_surfNormal, (m_width / 2) - (textw / 2), - (m_height / 2) - (texth / 2), 31); + (m_height / 2) - (texth / 2), 49); font->render(m_caption.c_str(), m_surfPressed, (m_width / 2) - (textw / 2), - (m_height / 2) - (texth / 2), 47); + (m_height / 2) - (texth / 2), 49); SDL_UnlockSurface(m_surfNormal); SDL_UnlockSurface(m_surfPressed); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dun...@us...> - 2006-08-07 18:22:23
|
Revision: 90 Author: dunkfordyce Date: 2006-08-07 11:22:16 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=90&view=rev Log Message: ----------- - temporarily disable libs and build as one monolithic app again until libs can be properly implemented Modified Paths: -------------- branches/dunks/include/ResMan.h branches/dunks/src/SConscript Modified: branches/dunks/include/ResMan.h =================================================================== --- branches/dunks/include/ResMan.h 2006-08-07 15:38:49 UTC (rev 89) +++ branches/dunks/include/ResMan.h 2006-08-07 18:22:16 UTC (rev 90) @@ -34,6 +34,7 @@ virtual unsigned char* readFile(boost::filesystem::path path, int *size) { return NULL; } protected: boost::filesystem::path m_path; + bool mb_writable; }; Modified: branches/dunks/src/SConscript =================================================================== --- branches/dunks/src/SConscript 2006-08-07 15:38:49 UTC (rev 89) +++ branches/dunks/src/SConscript 2006-08-07 18:22:16 UTC (rev 90) @@ -50,13 +50,13 @@ "pakfile/Palette.cpp", ] -gamelib = env.StaticLibrary("dune_game", all_sources) -guilib = env.StaticLibrary("dune_gui", gui_sources + gamelib) -paklib = env.StaticLibrary("dune_pak", pak_sources) +#gamelib = env.StaticLibrary("dune_game", all_sources) +#guilib = env.StaticLibrary("dune_gui", gui_sources + gamelib) +#paklib = env.StaticLibrary("dune_pak", pak_sources) -dunelegacy = env.Program("../dunelegacy", ["main.cpp", gamelib, guilib, paklib] ) -pakview = env.Program("../pakview", ["pakview.cpp", gamelib, guilib, paklib] ) +dunelegacy = env.Program("../dunelegacy", ["main.cpp"] + all_sources + gui_sources + pak_sources ) +#pakview = env.Program("../pakview", ["pakview.cpp", gamelib, guilib, paklib] ) Default(dunelegacy) -Default(pakview) +#Default(pakview) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otp...@us...> - 2006-08-07 15:39:05
|
Revision: 89 Author: otpetrik Date: 2006-08-07 08:38:49 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=89&view=rev Log Message: ----------- String.h/cpp -> Strings.h/cpp Modified Paths: -------------- branches/dunks/include/Log.h branches/dunks/src/SConscript Added Paths: ----------- branches/dunks/include/Strings.h branches/dunks/src/Strings.cpp Removed Paths: ------------- branches/dunks/include/String.h branches/dunks/src/String.cpp Modified: branches/dunks/include/Log.h =================================================================== --- branches/dunks/include/Log.h 2006-08-07 15:26:09 UTC (rev 88) +++ branches/dunks/include/Log.h 2006-08-07 15:38:49 UTC (rev 89) @@ -28,7 +28,7 @@ #define DUNE_LOG_H #include "singleton.h" -#include "String.h" +#include "Strings.h" #include <map> #include <boost/shared_ptr.hpp> Deleted: branches/dunks/include/String.h =================================================================== --- branches/dunks/include/String.h 2006-08-07 15:26:09 UTC (rev 88) +++ branches/dunks/include/String.h 2006-08-07 15:38:49 UTC (rev 89) @@ -1,60 +0,0 @@ -/*! - \file String.h - \brief String related stuff - - @note - There are only typedefs for now, but soon there will be caches to parse strings easier. -*/ -#ifndef DUNE_STRING_H -#define DUNE_STRING_H - -#include <string> -#include <sstream> - -//! Shortcut to std::string -typedef std::string String; -//! Shortcut to const std::string & -/* - @warning It is reference, thus you cannot create array,map,... of type ConstString ! -*/ -typedef const std::string &ConstString; - -//------------------------------------------------------------------------------ -// Misc functions -//------------------------------------------------------------------------------ -//! @name Misc functions -//@{ - -//! Convert something to string -/* -Tries to convert value to string (uses std::ostringstream). -*/ -template <typename T> -String toString(const T &something) -{ - std::ostringstream s; - s << something; - return s.str(); -}; - -//! Convert string to something -/* -Tries to convert string to something (uses std::ostringstream). - -@note Use this way: -@code - myvariable = fromStrint<mytype>(mystring); -@endcode -*/ -template <typename T> -T fromString(ConstString string) -{ - T something; - std::istringstream s(string); - s >> something; - return something; -}; - -//@} - -#endif // DUNE_STRING_H Copied: branches/dunks/include/Strings.h (from rev 88, branches/dunks/include/String.h) =================================================================== --- branches/dunks/include/Strings.h (rev 0) +++ branches/dunks/include/Strings.h 2006-08-07 15:38:49 UTC (rev 89) @@ -0,0 +1,60 @@ +/*! + \file Strings.h + \brief String related stuff + + @note + There are only typedefs for now, but soon there will be caches to parse strings easier. +*/ +#ifndef DUNE_STRINGS_H +#define DUNE_STRINGS_H + +#include <string> +#include <sstream> + +//! Shortcut to std::string +typedef std::string String; +//! Shortcut to const std::string & +/* + @warning It is reference, thus you cannot create array,map,... of type ConstString ! +*/ +typedef const std::string &ConstString; + +//------------------------------------------------------------------------------ +// Misc functions +//------------------------------------------------------------------------------ +//! @name Misc functions +//@{ + +//! Convert something to string +/* +Tries to convert value to string (uses std::ostringstream). +*/ +template <typename T> +String toString(const T &something) +{ + std::ostringstream s; + s << something; + return s.str(); +}; + +//! Convert string to something +/* +Tries to convert string to something (uses std::ostringstream). + +@note Use this way: +@code + myvariable = fromStrint<mytype>(mystring); +@endcode +*/ +template <typename T> +T fromString(ConstString string) +{ + T something; + std::istringstream s(string); + s >> something; + return something; +}; + +//@} + +#endif // DUNE_STRINGS_H Modified: branches/dunks/src/SConscript =================================================================== --- branches/dunks/src/SConscript 2006-08-07 15:26:09 UTC (rev 88) +++ branches/dunks/src/SConscript 2006-08-07 15:38:49 UTC (rev 89) @@ -27,7 +27,7 @@ "OptionsMenu.cpp", "Gfx.cpp", "houses.cpp", # just for colors, hope there will be a better place for these (otpetrik) - "String.cpp", + "Strings.cpp", "Log.cpp", "ResMan.cpp", Deleted: branches/dunks/src/String.cpp =================================================================== --- branches/dunks/src/String.cpp 2006-08-07 15:26:09 UTC (rev 88) +++ branches/dunks/src/String.cpp 2006-08-07 15:38:49 UTC (rev 89) @@ -1,8 +0,0 @@ -#include "String.h" - -#include "Log.h" - -#include <string.h> - -// there will be code, soon... (otpetrik) - Copied: branches/dunks/src/Strings.cpp (from rev 88, branches/dunks/src/String.cpp) =================================================================== --- branches/dunks/src/Strings.cpp (rev 0) +++ branches/dunks/src/Strings.cpp 2006-08-07 15:38:49 UTC (rev 89) @@ -0,0 +1,8 @@ +#include "Strings.h" + +#include "Log.h" + +#include <string.h> + +// there will be code, soon... (otpetrik) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otp...@us...> - 2006-08-07 15:31:59
|
Revision: 88 Author: otpetrik Date: 2006-08-07 08:26:09 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=88&view=rev Log Message: ----------- log fix Modified Paths: -------------- branches/dunks/include/Log.h branches/dunks/src/Log.cpp branches/dunks/src/SConscript Added Paths: ----------- branches/dunks/include/String.h branches/dunks/src/String.cpp Modified: branches/dunks/include/Log.h =================================================================== --- branches/dunks/include/Log.h 2006-08-07 08:52:30 UTC (rev 87) +++ branches/dunks/include/Log.h 2006-08-07 15:26:09 UTC (rev 88) @@ -11,45 +11,28 @@ @note Do not add new log verbosity levels to this file, instead create your own - enum in file in question. Use LOG_LEVEL_AVAILABLE as basis for your enum: + enum in file in question. Use LV_AVAILABLE as basis for your enum: @code enum LogAiVerbosity { - LOG_AI_WORLDWIDE = LOG_VERBOSITY_AVAILABLE, - LOG_AI_PLATOON, - LOG_AI_SQUAD + LV_AI_WORLDWIDE = LV_AVAILABLE, + LV_AI_PLATOON, + LV_AI_SQUAD }; @endcode - - @note - To make logging easier for subsystem SOMETHING, define your own macros: - - @code - - #define SOMETHING_LOG(level,...) S_LOG("something", level, __VA_ARGS__) - #define SOMETHING_LOG_ERROR(...) SOMETHING_LOG(LOG_ERROR, __VA_ARGS__) - #define SOMETHING_LOG_FATAL(...) SOMETHING_LOG(LOG_FATAL, __VA_ARGS__) - #define SOMETHING_LOG_WARNING(...) SOMETHING_LOG(LOG_WARNING, __VA_ARGS__) - #define SOMETHING_LOG_INFO(...) SOMETHING_LOG(LOG_INFO, __VA_ARGS__) - - @endcode - + */ #ifndef DUNE_LOG_H #define DUNE_LOG_H #include "singleton.h" +#include "String.h" -#include <string> #include <map> #include <boost/shared_ptr.hpp> -// TODO: not sure where these belong, mayby separate file Types.h ? (otpetrik) -typedef std::string String; -typedef const std::string &ConstString; - #ifndef LOG_DISABLED //! Log verbosity level @@ -59,17 +42,17 @@ enum LogVerbosity { //! bye, bye ! - LOG_FATAL = 0, + LV_FATAL = 0, //! that hurt... - LOG_ERROR, + LV_ERROR, //! i can handle that - LOG_WARNING, + LV_WARNING, //! look what's happening - LOG_INFO, + LV_INFO, //! first user loglevel - LOG_VERBOSITY_AVAILABLE, + LV_AVAILABLE, //! last loglevel (used to set full logging) - LOG_VERBOSITY_MAX = 255 + LV_MAX = 255 }; class LogBackend; @@ -124,8 +107,7 @@ @note: For logging itself, do not use this class, use macros ! - @see S_LOG, S_LOG_FATAL, S_LOG_ERROR, S_LOG_WARNING, S_LOG_INFO - @see G_LOG, G_LOG_FATAL, G_LOG_ERROR, G_LOG_WARNING, G_LOG_INFO + @see LOG, LOG_FATAL, LOG_ERROR, LOG_WARNING, LOG_INFO */ class Log : public Singleton<Log> { @@ -150,10 +132,29 @@ @param format printf-type message string */ void log(ConstString logSystem, LogVerbosity verbosity, const char *format, ...); + void logFatal(ConstString logSystem, const char *format, ...); + void logError(ConstString logSystem, const char *format, ...); + void logWarning(ConstString logSystem, const char *format, ...); + void logInfo(ConstString logSystem, const char *format, ...); //@} + //! @name Indentation + //@{ + + void indent() + { + indentLevel++; + }; + void unindent() + { + if (indentLevel > 0) + indentLevel--; + }; + + //@} + //! @name Verbosity setting //@{ @@ -194,8 +195,10 @@ LogVerbosity defaultVerbosity; LogBackendPtr backend; std::map<const String, LogVerbosity> verbosities; + int indentLevel; - void doLog(ConstString logSystem, LogVerbosity verbosity, const char *message); + bool checkMessageVerbosity(ConstString logSystem, LogVerbosity verbosity); + void doLog(ConstString logSystem, LogVerbosity verbosity, const char *format, va_list args); }; @@ -206,50 +209,37 @@ //@{ //! Log message of given verbosity emitted by given system -#define S_LOG(system,verbosity,...) Log::Instance()->log(system, verbosity, __VA_ARGS__) +#define LOG Log::Instance()->log //! Log fatal message emitted by given system -#define S_LOG_FATAL(system,...) Log::Instance()->log(system, LOG_FATAL, __VA_ARGS__) +#define LOG_FATAL Log::Instance()->logFatal //! Log error message emitted by given system -#define S_LOG_ERROR(system,...) Log::Instance()->log(system, LOG_ERROR, __VA_ARGS__) +#define LOG_ERROR Log::Instance()->logError //! Log warning message emitted by given system -#define S_LOG_WARNING(system,...) Log::Instance()->log(system, LOG_WARNING, __VA_ARGS__) +#define LOG_WARNING Log::Instance()->logWarning //! Log info message emitted by given system -#define S_LOG_INFO(system,...) Log::Instance()->log(system, LOG_INFO, __VA_ARGS__) +#define LOG_INFO Log::Instance()->logInfo -//@} +//! Increase indentation for following messages +#define LOG_INDENT Log::Instance()->indent -//! @name Global log -//! Messages not bound to any given system -//@{ +//! Decrease indentation for following messages +#define LOG_UNINDENT Log::Instance()->unindent -//! Log message of given verbosity -#define G_LOG(level,...) S_LOG("", level, __VA_ARGS__) -//! Log fatal message -#define G_LOG_FATAL(...) G_LOG(LOG_FATAL, __VA_ARGS__) -//! Log error message -#define G_LOG_ERROR(...) G_LOG(LOG_ERROR, __VA_ARGS__) -//! Log warning message -#define G_LOG_WARNING(...) G_LOG(LOG_WARNING, __VA_ARGS__) -//! Log info message -#define G_LOG_INFO(...) G_LOG(LOG_INFO, __VA_ARGS__) - //@} #else // LOG_DISABLED // few useless macros +// TODO: not sure what to do with these, they raise some warnings... (otpetrik) -#define S_LOG(system,verbosity,...) ((void)(0)) -#define S_LOG_FATAL(system,...) ((void)(0)) -#define S_LOG_ERROR(system,...) ((void)(0)) -#define S_LOG_WARNING(system,...) ((void)(0)) -#define S_LOG_INFO(system,...) ((void)(0)) -#define G_LOG(level,...) ((void)(0)) -#define G_LOG_FATAL(...) ((void)(0)) -#define G_LOG_ERROR(...) ((void)(0)) -#define G_LOG_WARNING(...) ((void)(0)) -#define G_LOG_INFO(...) ((void)(0)) +#define LOG ((void)(0)) +#define LOG_FATAL ((void)(0)) +#define LOG_ERROR ((void)(0)) +#define LOG_WARNING ((void)(0)) +#define LOG_INFO ((void)(0)) +#define LOG_INDENT ((void)(0)) +#define LOG_UNINDENT ((void)(0)) #endif // LOG_DISABLED Added: branches/dunks/include/String.h =================================================================== --- branches/dunks/include/String.h (rev 0) +++ branches/dunks/include/String.h 2006-08-07 15:26:09 UTC (rev 88) @@ -0,0 +1,60 @@ +/*! + \file String.h + \brief String related stuff + + @note + There are only typedefs for now, but soon there will be caches to parse strings easier. +*/ +#ifndef DUNE_STRING_H +#define DUNE_STRING_H + +#include <string> +#include <sstream> + +//! Shortcut to std::string +typedef std::string String; +//! Shortcut to const std::string & +/* + @warning It is reference, thus you cannot create array,map,... of type ConstString ! +*/ +typedef const std::string &ConstString; + +//------------------------------------------------------------------------------ +// Misc functions +//------------------------------------------------------------------------------ +//! @name Misc functions +//@{ + +//! Convert something to string +/* +Tries to convert value to string (uses std::ostringstream). +*/ +template <typename T> +String toString(const T &something) +{ + std::ostringstream s; + s << something; + return s.str(); +}; + +//! Convert string to something +/* +Tries to convert string to something (uses std::ostringstream). + +@note Use this way: +@code + myvariable = fromStrint<mytype>(mystring); +@endcode +*/ +template <typename T> +T fromString(ConstString string) +{ + T something; + std::istringstream s(string); + s >> something; + return something; +}; + +//@} + +#endif // DUNE_STRING_H Modified: branches/dunks/src/Log.cpp =================================================================== --- branches/dunks/src/Log.cpp 2006-08-07 08:52:30 UTC (rev 87) +++ branches/dunks/src/Log.cpp 2006-08-07 15:26:09 UTC (rev 88) @@ -2,12 +2,11 @@ #ifndef LOG_DISABLED -#include -<stdio.h> +#include <stdio.h> #include <stdarg.h> -#define LOG_DEFAULT_VERBOSITY LOG_VERBOSITY_MAX -#define LOG_MAX_STRING_LENGTH 100 +#define LOG_DEFAULT_VERBOSITY LV_MAX +#define LOG_MAX_STRING_LENGTH 1000 //------------------------------------------------------------------------------ // LogBackend class @@ -39,40 +38,64 @@ void Log::log(ConstString logSystem, LogVerbosity verbosity, ConstString message) { - doLog(logSystem, verbosity, message.c_str()); + doLog(logSystem, verbosity, "%s", (char *)message.c_str()); }; void Log::log(ConstString logSystem, LogVerbosity verbosity, const char *format, ...) { - std::map<const String, LogVerbosity>::iterator i; - LogVerbosity systemVerbosity; - static char message[LOG_MAX_STRING_LENGTH]; + va_list args; + va_start(args, format); - // find verbosity level applicable to this message - i = verbosities.find(logSystem); - if (i != verbosities.end()) - { - systemVerbosity = i->second; - } - else - { - systemVerbosity = defaultVerbosity; - } + // try to log it + if (checkMessageVerbosity(logSystem, verbosity)) + doLog(logSystem, verbosity, format, args); + + va_end(args); +}; +void Log::logFatal(ConstString logSystem, const char *format, ...) +{ + va_list args; + va_start(args, format); - // check that level - if (verbosity > systemVerbosity) - return; + // try to log it + if (checkMessageVerbosity(logSystem, LV_FATAL)) + doLog(logSystem, LV_FATAL, format, args); + + va_end(args); +}; +void Log::logError(ConstString logSystem, const char *format, ...) +{ + va_list args; + va_start(args, format); + // try to log it + if (checkMessageVerbosity(logSystem, LV_ERROR)) + doLog(logSystem, LV_ERROR, format, args); + + va_end(args); +}; +void Log::logWarning(ConstString logSystem, const char *format, ...) +{ + va_list args; + va_start(args, format); - // assemble the message + // try to log it + if (checkMessageVerbosity(logSystem, LV_WARNING)) + doLog(logSystem, LV_WARNING, format, args); + + va_end(args); +}; +void Log::logInfo(ConstString logSystem, const char *format, ...) +{ va_list args; va_start(args, format); - vsnprintf(message, LOG_MAX_STRING_LENGTH, format, args); + + // try to log it + if (checkMessageVerbosity(logSystem, LV_INFO)) + doLog(logSystem, LV_INFO, format, args); + va_end(args); - - // log it - doLog(logSystem, verbosity, message); }; - + void Log::setVerbosity(ConstString logSystem, LogVerbosity verbosity) { verbosities[logSystem] = verbosity; @@ -84,40 +107,85 @@ this->backend = backend; }; -Log::Log() : defaultVerbosity(LOG_DEFAULT_VERBOSITY), backend(new LogBackendStdout()) +Log::Log() : defaultVerbosity(LOG_DEFAULT_VERBOSITY), backend(new LogBackendStdout()), indentLevel(0) { }; Log::~Log() { }; -void Log::doLog(ConstString logSystem, LogVerbosity verbosity, const char *message) +bool Log::checkMessageVerbosity(ConstString logSystem, LogVerbosity verbosity) { + std::map<const String, LogVerbosity>::iterator i; + LogVerbosity systemVerbosity; + + // find verbosity level applicable to this message + i = verbosities.find(logSystem); + if (i != verbosities.end()) + { + systemVerbosity = i->second; + } + else + { + systemVerbosity = defaultVerbosity; + } + + // check that level + if (verbosity > systemVerbosity) + return false; + + return true; +} + +void Log::doLog(ConstString logSystem, LogVerbosity verbosity, const char *format, va_list args) +{ + static char message[LOG_MAX_STRING_LENGTH]; static char formated[LOG_MAX_STRING_LENGTH]; const char *verb; switch (verbosity) { - case LOG_FATAL: + case LV_FATAL: verb = "[FATAL]"; break; - case LOG_ERROR: + case LV_ERROR: verb = "[ERROR]"; break; - case LOG_WARNING: + case LV_WARNING: verb = "[WARNING]"; break; - case LOG_INFO: + case LV_INFO: default: verb = ""; break; }; + + for (int i = 0; i < indentLevel; i++) + message[i] = ' '; + // Windows are inherently insecure (no vsnprintf & snprintf) + // TODO: if you are using mingw, tell us whether you have snprintf & vsnprint available, thanks ! + #if defined(_WIN32) || defined(WIN32) || defined(_MSC_VER) + + vsprintf(&message[indentLevel], format, args); + // do not print ':' unless there is a logSystem string if (logSystem.size() != 0) + sprintf(formated, "%s%s: %s\n", verb, logSystem.c_str(), message); + else + sprintf(formated, "%s%s\n", verb, message); + + #else + + vsnprintf(&message[indentLevel], LOG_MAX_STRING_LENGTH - indentLevel, format, args); + + // do not print ':' unless there is a logSystem string + if (logSystem.size() != 0) snprintf(formated, LOG_MAX_STRING_LENGTH, "%s%s: %s\n", verb, logSystem.c_str(), message); else snprintf(formated, LOG_MAX_STRING_LENGTH, "%s%s\n", verb, message); + + #endif backend->log(formated); } Modified: branches/dunks/src/SConscript =================================================================== --- branches/dunks/src/SConscript 2006-08-07 08:52:30 UTC (rev 87) +++ branches/dunks/src/SConscript 2006-08-07 15:26:09 UTC (rev 88) @@ -27,8 +27,9 @@ "OptionsMenu.cpp", "Gfx.cpp", "houses.cpp", # just for colors, hope there will be a better place for these (otpetrik) - #"Log.cpp", - + "String.cpp", + "Log.cpp", + "ResMan.cpp", ] Added: branches/dunks/src/String.cpp =================================================================== --- branches/dunks/src/String.cpp (rev 0) +++ branches/dunks/src/String.cpp 2006-08-07 15:26:09 UTC (rev 88) @@ -0,0 +1,8 @@ +#include "String.h" + +#include "Log.h" + +#include <string.h> + +// there will be code, soon... (otpetrik) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dun...@us...> - 2006-08-07 08:52:54
|
Revision: 87 Author: dunkfordyce Date: 2006-08-07 01:52:30 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=87&view=rev Log Message: ----------- - added MSVS soloution and project - set compiler to include debug info for win32 builds - temporary fix for undefined symbols in Buttons when using Gfx - bit of drawing code for the buttons ( shutdownrunner has more i think ) - commented out Log.cpp in SConscript as it still doesnt work on win32. need to replace vsnprintf - added clear color setting to application Modified Paths: -------------- branches/dunks/SConstruct branches/dunks/include/Application.h branches/dunks/include/ResMan.h branches/dunks/src/Application.cpp branches/dunks/src/IntroState.cpp branches/dunks/src/Log.cpp branches/dunks/src/ResMan.cpp branches/dunks/src/SConscript branches/dunks/src/gui2/Button.cpp Added Paths: ----------- branches/dunks/dunelegacy.sln branches/dunks/dunelegacy.vcproj Modified: branches/dunks/SConstruct =================================================================== --- branches/dunks/SConstruct 2006-08-07 07:18:33 UTC (rev 86) +++ branches/dunks/SConstruct 2006-08-07 08:52:30 UTC (rev 87) @@ -33,8 +33,8 @@ env.Append(CCFLAGS=["-ggdb"]) else: env.Append(LIBS = ["zzipdll", "zdll", "SDLmain"]) - env.Append(LINKFLAGS = ["/SUBSYSTEM:CONSOLE"]) - env.Append(CCFLAGS = ["/O2", "/EHsc", "/MD", "/Op"]) + env.Append(LINKFLAGS = ["/SUBSYSTEM:CONSOLE", "/DEBUG"]) + env.Append(CCFLAGS = ["/O2", "/EHsc", "/MD", "/Op", "/DEBUG", "/Zi"]) env.Append(LIBS = [ "SDL", "SDL_mixer", Added: branches/dunks/dunelegacy.sln =================================================================== --- branches/dunks/dunelegacy.sln (rev 0) +++ branches/dunks/dunelegacy.sln 2006-08-07 08:52:30 UTC (rev 87) @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dunelegacy", "dunelegacy.vcproj", "{4E0B6F5C-ECCE-6CC6-4AF7-7AF481BEAF22}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {4E0B6F5C-ECCE-6CC6-4AF7-7AF481BEAF22}.Release.ActiveCfg = Release|Win32 + {4E0B6F5C-ECCE-6CC6-4AF7-7AF481BEAF22}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal +fXEAVQdSZWxlYXNlcQEoY1NDb25zLlRvb2wubXN2cwpDb25maWcKcQJvcQN9cQRVB3ZhcmlhbnRx +BWgBc2JzLg== + Added: branches/dunks/dunelegacy.vcproj =================================================================== --- branches/dunks/dunelegacy.vcproj (rev 0) +++ branches/dunks/dunelegacy.vcproj 2006-08-07 08:52:30 UTC (rev 87) @@ -0,0 +1,414 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="dunelegacy" + SccProjectName="" + SccLocalPath="" + Keyword="MakeFileProj"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Release|Win32" + OutputDirectory="E:\projects\dunelegacy-dunks" + IntermediateDirectory="E:\projects\dunelegacy-dunks" + ConfigurationType="0" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE"> + <Tool + Name="VCNMakeTool" + BuildCommandLine=""C:\Python24\python.exe" -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-0.96.1'), join(sys.prefix, 'scons-0.96.1'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()" -C E:\projects\dunelegacy-dunks -f SConstruct E:\projects\dunelegacy-dunks\dunelegacy.exe" + ReBuildCommandLine=""C:\Python24\python.exe" -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-0.96.1'), join(sys.prefix, 'scons-0.96.1'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()" -C E:\projects\dunelegacy-dunks -f SConstruct E:\projects\dunelegacy-dunks\dunelegacy.exe" + CleanCommandLine=""C:\Python24\python.exe" -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-0.96.1'), join(sys.prefix, 'scons-0.96.1'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()" -C E:\projects\dunelegacy-dunks -f SConstruct -c E:\projects\dunelegacy-dunks\dunelegacy.exe" + Output="E:\projects\dunelegacy-dunks\dunelegacy.exe"/> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name=" Source Files" + Filter="cpp;c;cxx;l;y;def;odl;idl;hpj;bat"> + <File + RelativePath=".\src\AiPlayerClass.cpp"> + </File> + <File + RelativePath=".\include\AiPlayerClass.h"> + </File> + <File + RelativePath=".\src\Application.cpp"> + </File> + <File + RelativePath=".\include\Application.h"> + </File> + <File + RelativePath=".\src\BuildItemClass.cpp"> + </File> + <File + RelativePath=".\include\BuildItemClass.h"> + </File> + <File + RelativePath=".\src\BulletClass.cpp"> + </File> + <File + RelativePath=".\include\BulletClass.h"> + </File> + <File + RelativePath=".\include\Colours.h"> + </File> + <File + RelativePath=".\src\CommViewClass.cpp"> + </File> + <File + RelativePath=".\include\CommViewClass.h"> + </File> + <File + RelativePath=".\src\CutScene.cpp"> + </File> + <File + RelativePath=".\include\CutScene.h"> + </File> + <File + RelativePath=".\include\data.h"> + </File> + <File + RelativePath=".\src\DataFile.cpp"> + </File> + <File + RelativePath=".\include\DataFile.h"> + </File> + <File + RelativePath=".\include\dMath.h"> + </File> + <File + RelativePath=".\include\DuneConstants.h"> + </File> + <File + RelativePath=".\src\editor.cpp"> + </File> + <File + RelativePath=".\include\Editor.h"> + </File> + <File + RelativePath=".\src\Font.cpp"> + </File> + <File + RelativePath=".\include\Font.h"> + </File> + <File + RelativePath=".\src\Game.cpp"> + </File> + <File + RelativePath=".\include\Game.h"> + </File> + <File + RelativePath=".\src\GameNet.cpp"> + </File> + <File + RelativePath=".\include\GameNet.h"> + </File> + <File + RelativePath=".\src\Gfx.cpp"> + </File> + <File + RelativePath=".\include\Gfx.h"> + </File> + <File + RelativePath=".\src\globals.cpp"> + </File> + <File + RelativePath=".\include\globals.h"> + </File> + <File + RelativePath=".\include\gui.h"> + </File> + <File + RelativePath=".\src\houses.cpp"> + </File> + <File + RelativePath=".\include\houses.h"> + </File> + <File + RelativePath=".\src\IntroState.cpp"> + </File> + <File + RelativePath=".\include\IntroState.h"> + </File> + <File + RelativePath=".\include\Items.h"> + </File> + <File + RelativePath=".\src\Link.cpp"> + </File> + <File + RelativePath=".\include\Link.h"> + </File> + <File + RelativePath=".\src\LinkedList.cpp"> + </File> + <File + RelativePath=".\include\LinkedList.h"> + </File> + <File + RelativePath=".\src\ListIterator.cpp"> + </File> + <File + RelativePath=".\include\ListIterator.h"> + </File> + <File + RelativePath=".\src\listStuff.cpp"> + </File> + <File + RelativePath=".\include\listStuff.h"> + </File> + <File + RelativePath=".\src\Log.cpp"> + </File> + <File + RelativePath=".\include\Log.h"> + </File> + <File + RelativePath=".\src\main.cpp"> + </File> + <File + RelativePath=".\src\MainMenu.cpp"> + </File> + <File + RelativePath=".\include\MainMenu.h"> + </File> + <File + RelativePath=".\src\MapClass.cpp"> + </File> + <File + RelativePath=".\include\MapClass.h"> + </File> + <File + RelativePath=".\src\MapGenerator.cpp"> + </File> + <File + RelativePath=".\include\MapGenerator.h"> + </File> + <File + RelativePath=".\src\MentatClass.cpp"> + </File> + <File + RelativePath=".\include\MentatClass.h"> + </File> + <File + RelativePath=".\src\Menu.cpp"> + </File> + <File + RelativePath=".\include\Menu.h"> + </File> + <File + RelativePath=".\src\MenuBase.cpp"> + </File> + <File + RelativePath=".\include\MenuBase.h"> + </File> + <File + RelativePath=".\src\mmath.cpp"> + </File> + <File + RelativePath=".\include\mmath.h"> + </File> + <File + RelativePath=".\src\Music.cpp"> + </File> + <File + RelativePath=".\include\Music.h"> + </File> + <File + RelativePath=".\src\Net.cpp"> + </File> + <File + RelativePath=".\include\Net.h"> + </File> + <File + RelativePath=".\src\ObjectClass.cpp"> + </File> + <File + RelativePath=".\include\ObjectClass.h"> + </File> + <File + RelativePath=".\src\OptionsMenu.cpp"> + </File> + <File + RelativePath=".\include\OptionsMenu.h"> + </File> + <File + RelativePath=".\src\pakview.cpp"> + </File> + <File + RelativePath=".\src\PlayerClass.cpp"> + </File> + <File + RelativePath=".\include\PlayerClass.h"> + </File> + <File + RelativePath=".\src\PriorityQ.cpp"> + </File> + <File + RelativePath=".\include\PriorityQ.h"> + </File> + <File + RelativePath=".\src\ResMan.cpp"> + </File> + <File + RelativePath=".\include\ResMan.h"> + </File> + <File + RelativePath=".\include\resource.h"> + </File> + <File + RelativePath=".\src\SConscript"> + </File> + <File + RelativePath=".\src\SDL_rwops_zzip.c"> + </File> + <File + RelativePath=".\include\SDL_rwops_zzip.h"> + </File> + <File + RelativePath=".\src\Settings.cpp"> + </File> + <File + RelativePath=".\include\Settings.h"> + </File> + <File + RelativePath=".\src\SingleMenu.cpp"> + </File> + <File + RelativePath=".\include\SingleMenu.h"> + </File> + <File + RelativePath=".\include\singleton.h"> + </File> + <File + RelativePath=".\src\SoundPlayerClass.cpp"> + </File> + <File + RelativePath=".\include\SoundPlayerClass.h"> + </File> + <File + RelativePath=".\src\State.cpp"> + </File> + <File + RelativePath=".\include\State.h"> + </File> + <File + RelativePath=".\src\TerrainClass.cpp"> + </File> + <File + RelativePath=".\include\TerrainClass.h"> + </File> + <File + RelativePath=".\include\terrainData.h"> + </File> + <File + RelativePath=".\src\TopLevelState.cpp"> + </File> + <File + RelativePath=".\include\TopLevelState.h"> + </File> + <File + RelativePath=".\src\ui.cpp"> + </File> + <File + RelativePath=".\include\ui.h"> + </File> + <Filter + Name="pakfile" + Filter=""> + <File + RelativePath=".\src\pakfile\Cpsfile.cpp"> + </File> + <File + RelativePath=".\include\pakfile\Cpsfile.h"> + </File> + <File + RelativePath=".\src\pakfile\Decode.cpp"> + </File> + <File + RelativePath=".\include\pakfile\Decode.h"> + </File> + <File + RelativePath=".\src\pakfile\Icnfile.cpp"> + </File> + <File + RelativePath=".\include\pakfile\Icnfile.h"> + </File> + <File + RelativePath=".\src\pakfile\main.cpp"> + </File> + <File + RelativePath=".\src\pakfile\Pakfile.cpp"> + </File> + <File + RelativePath=".\include\pakfile\Pakfile.h"> + </File> + <File + RelativePath=".\src\pakfile\Palette.cpp"> + </File> + <File + RelativePath=".\include\pakfile\Palette.h"> + </File> + <File + RelativePath=".\src\pakfile\Shpfile.cpp"> + </File> + <File + RelativePath=".\include\pakfile\Shpfile.h"> + </File> + <File + RelativePath=".\src\pakfile\Wsafile.cpp"> + </File> + <File + RelativePath=".\include\pakfile\Wsafile.h"> + </File> + </Filter> + <Filter + Name="gui2" + Filter=""> + <File + RelativePath=".\src\gui2\Button.cpp"> + </File> + <File + RelativePath=".\include\gui2\Button.h"> + </File> + <File + RelativePath=".\src\gui2\Container.cpp"> + </File> + <File + RelativePath=".\include\gui2\Container.h"> + </File> + <File + RelativePath=".\src\gui2\VBox.cpp"> + </File> + <File + RelativePath=".\include\gui2\VBox.h"> + </File> + <File + RelativePath=".\src\gui2\Widget.cpp"> + </File> + <File + RelativePath=".\include\gui2\Widget.h"> + </File> + </Filter> + </Filter> + <Filter + Name="Other Files" + Filter=""> + <File + RelativePath="Changelog"> + </File> + </Filter> + <File + RelativePath=".\SConstruct"> + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> Modified: branches/dunks/include/Application.h =================================================================== --- branches/dunks/include/Application.h 2006-08-07 07:18:33 UTC (rev 86) +++ branches/dunks/include/Application.h 2006-08-07 08:52:30 UTC (rev 87) @@ -49,6 +49,8 @@ void SetPalette(); SDL_Palette* GetCurrentPalette() { return m_currentPalette; } + void SetClearColor(Uint32 palIndex) { m_clearColor = palIndex; } + void UpdateVideoMode(bool fullscreen); void UpdateVideoMode(Uint16 w, Uint16 h); void UpdateVideoMode(Uint16 w, Uint16 h, bool fullscreen); @@ -77,6 +79,8 @@ Uint16 m_cursorX, m_cursorY; Cursor m_cursorFrame; SDL_Surface* m_cursor; + + Uint32 m_clearColor; }; Modified: branches/dunks/include/ResMan.h =================================================================== --- branches/dunks/include/ResMan.h 2006-08-07 07:18:33 UTC (rev 86) +++ branches/dunks/include/ResMan.h 2006-08-07 08:52:30 UTC (rev 87) @@ -9,6 +9,8 @@ #include <map> #include <string> +//#include "Log.h" + class FileLike { public: Modified: branches/dunks/src/Application.cpp =================================================================== --- branches/dunks/src/Application.cpp 2006-08-07 07:18:33 UTC (rev 86) +++ branches/dunks/src/Application.cpp 2006-08-07 08:52:30 UTC (rev 87) @@ -328,7 +328,7 @@ while (m_running) { - SDL_FillRect(m_screen, NULL, 0); + SDL_FillRect(m_screen, NULL, m_clearColor); HandleEvents(); Modified: branches/dunks/src/IntroState.cpp =================================================================== --- branches/dunks/src/IntroState.cpp 2006-08-07 07:18:33 UTC (rev 86) +++ branches/dunks/src/IntroState.cpp 2006-08-07 08:52:30 UTC (rev 87) @@ -170,7 +170,7 @@ IntroState::IntroState() { - Frame* tf; + m_currentFrame = NULL; enque( new Frame("INTRO:INTRO1.WSA", Frame::NO_TRANSITION, @@ -253,7 +253,7 @@ void IntroState::JustMadeActive() { - + Application::Instance()->SetClearColor(0); Application::Instance()->RootWidget()->addChild(m_butIntro); State::JustMadeActive(); }; Modified: branches/dunks/src/Log.cpp =================================================================== --- branches/dunks/src/Log.cpp 2006-08-07 07:18:33 UTC (rev 86) +++ branches/dunks/src/Log.cpp 2006-08-07 08:52:30 UTC (rev 87) @@ -2,7 +2,8 @@ #ifndef LOG_DISABLED -#include <stdio.h> +#include +<stdio.h> #include <stdarg.h> #define LOG_DEFAULT_VERBOSITY LOG_VERBOSITY_MAX Modified: branches/dunks/src/ResMan.cpp =================================================================== --- branches/dunks/src/ResMan.cpp 2006-08-07 07:18:33 UTC (rev 86) +++ branches/dunks/src/ResMan.cpp 2006-08-07 08:52:30 UTC (rev 87) @@ -1,8 +1,10 @@ #include "boost/filesystem/path.hpp" #include "boost/filesystem/operations.hpp" +#include "boost/format.hpp" #include "ResMan.h" #include "Settings.h" +//#include "Log.h" //#include "boost/filesystem/fstream.hpp" // ditto @@ -87,7 +89,7 @@ int filesize; unsigned char *buf = m_pakfile->getFile(path.string().c_str(), &filesize); - printf("read pak %s size %d\n", path.string().c_str(), filesize); + //RESMAN_LOG_INFO(boost::format("read pak %s size %d\n") % path.string().c_str() % filesize); assert(buf != NULL); assert(filesize != 0); Modified: branches/dunks/src/SConscript =================================================================== --- branches/dunks/src/SConscript 2006-08-07 07:18:33 UTC (rev 86) +++ branches/dunks/src/SConscript 2006-08-07 08:52:30 UTC (rev 87) @@ -27,7 +27,7 @@ "OptionsMenu.cpp", "Gfx.cpp", "houses.cpp", # just for colors, hope there will be a better place for these (otpetrik) - "Log.cpp", + #"Log.cpp", "ResMan.cpp", ] @@ -50,7 +50,7 @@ ] gamelib = env.StaticLibrary("dune_game", all_sources) -guilib = env.StaticLibrary("dune_gui", gui_sources) +guilib = env.StaticLibrary("dune_gui", gui_sources + gamelib) paklib = env.StaticLibrary("dune_pak", pak_sources) dunelegacy = env.Program("../dunelegacy", ["main.cpp", gamelib, guilib, paklib] ) @@ -59,4 +59,3 @@ Default(dunelegacy) Default(pakview) - Modified: branches/dunks/src/gui2/Button.cpp =================================================================== --- branches/dunks/src/gui2/Button.cpp 2006-08-07 07:18:33 UTC (rev 86) +++ branches/dunks/src/gui2/Button.cpp 2006-08-07 08:52:30 UTC (rev 87) @@ -130,16 +130,16 @@ SDL_FillRect(m_surfNormal, NULL, 115); SDL_FillRect(m_surfPressed, NULL, 115); - /* + // dark brown box SDL_Rect r = {0, 0, m_width -1, m_height -1}; drawRect(m_surfNormal, r, 229, false); // bottom line - drawHLine(m_surfNormal, 1, m_height, m_width, 226); + drawHLine(m_surfNormal, 0, m_height-1, m_width-1, 226, false); // far right line - drawVLine(m_surfNormal, m_width, 0, m_height, 226); - */ + drawVLine(m_surfNormal, m_width-1, 0, m_height-1, 226, false); + Font* font = FontManager::Instance()->getFont("INTRO:INTRO.FNT"); @@ -152,6 +152,9 @@ font->render(m_caption.c_str(), m_surfPressed, (m_width / 2) - (textw / 2), (m_height / 2) - (texth / 2), 47); + + SDL_UnlockSurface(m_surfNormal); + SDL_UnlockSurface(m_surfPressed); }; // ------------------------------------------------------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dun...@us...> - 2006-08-07 07:18:38
|
Revision: 86 Author: dunkfordyce Date: 2006-08-07 00:18:33 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=86&view=rev Log Message: ----------- committing button so i can fix undef'd symbols Modified Paths: -------------- branches/dunks/src/gui2/Button.cpp Modified: branches/dunks/src/gui2/Button.cpp =================================================================== --- branches/dunks/src/gui2/Button.cpp 2006-08-07 00:38:12 UTC (rev 85) +++ branches/dunks/src/gui2/Button.cpp 2006-08-07 07:18:33 UTC (rev 86) @@ -3,6 +3,7 @@ #include "Colours.h" #include "Font.h" #include "Application.h" +#include "Gfx.h" bool Button::handleButtonUp(Uint8 button, Uint16 x, Uint16 y) { @@ -49,7 +50,7 @@ if (m_pressed) { - assert(m_pressed != NULL); + assert(m_surfPressed != NULL); SDL_BlitSurface(m_surfPressed, NULL, dest, &destrect); } else @@ -118,14 +119,28 @@ 0, 0, 0, 0); assert(m_surfPressed != NULL); + SDL_LockSurface(m_surfNormal); + SDL_LockSurface(m_surfPressed); + SDL_Palette* pal = Application::Instance()->Screen()->format->palette; SDL_SetColors(m_surfNormal, pal->colors, 0, pal->ncolors); SDL_SetColors(m_surfPressed, pal->colors, 0, pal->ncolors); - SDL_FillRect(m_surfNormal, NULL, 30); - SDL_FillRect(m_surfPressed, NULL, 30); + SDL_FillRect(m_surfNormal, NULL, 115); + SDL_FillRect(m_surfPressed, NULL, 115); + + /* + // dark brown box + SDL_Rect r = {0, 0, m_width -1, m_height -1}; + drawRect(m_surfNormal, r, 229, false); + // bottom line + drawHLine(m_surfNormal, 1, m_height, m_width, 226); + // far right line + drawVLine(m_surfNormal, m_width, 0, m_height, 226); + */ + Font* font = FontManager::Instance()->getFont("INTRO:INTRO.FNT"); Uint16 textw, texth; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |