|
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: <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: <dv...@us...> - 2006-11-23 18:31:09
|
Revision: 123
http://svn.sourceforge.net/dunelegacy/?rev=123&view=rev
Author: dvalin
Date: 2006-11-23 10:30:57 -0800 (Thu, 23 Nov 2006)
Log Message:
-----------
x86_64 build fix from JttL
Modified Paths:
--------------
branches/dunks/include/Log.h
branches/dunks/src/Log.cpp
Modified: branches/dunks/include/Log.h
===================================================================
--- branches/dunks/include/Log.h 2006-11-21 17:21:06 UTC (rev 122)
+++ branches/dunks/include/Log.h 2006-11-23 18:30:57 UTC (rev 123)
@@ -198,7 +198,7 @@
int indentLevel;
bool checkMessageVerbosity(ConstString logSystem, LogVerbosity verbosity);
- void doLog(ConstString logSystem, LogVerbosity verbosity, const char *format, va_list args);
+ void doLog(ConstString logSystem, LogVerbosity verbosity, const char *format, ...);
};
Modified: branches/dunks/src/Log.cpp
===================================================================
--- branches/dunks/src/Log.cpp 2006-11-21 17:21:06 UTC (rev 122)
+++ branches/dunks/src/Log.cpp 2006-11-23 18:30:57 UTC (rev 123)
@@ -138,8 +138,9 @@
return true;
}
-void Log::doLog(ConstString logSystem, LogVerbosity verbosity, const char *format, va_list args)
+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;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <shu...@us...> - 2006-11-23 22:37:28
|
Revision: 124
http://svn.sourceforge.net/dunelegacy/?rev=124&view=rev
Author: shutdownrunner
Date: 2006-11-23 14:37:25 -0800 (Thu, 23 Nov 2006)
Log Message:
-----------
- Added label. It will be useful I hope
- And a small test of my image cropping skills. Could someone with a bit of free time make a list of how to cut
images to make menus, in-game panels, etc. ?
Modified Paths:
--------------
branches/dunks/include/Gfx.h
branches/dunks/include/MainMenu.h
branches/dunks/include/OptionsMenu.h
branches/dunks/src/Gfx.cpp
branches/dunks/src/IntroState.cpp
branches/dunks/src/MainMenu.cpp
branches/dunks/src/OptionsMenu.cpp
branches/dunks/src/SConscript
Modified: branches/dunks/include/Gfx.h
===================================================================
--- branches/dunks/include/Gfx.h 2006-11-23 18:30:57 UTC (rev 123)
+++ branches/dunks/include/Gfx.h 2006-11-23 22:37:25 UTC (rev 124)
@@ -113,7 +113,6 @@
*/
SDL_Surface* resizeSurface(SDL_Surface *surface, double ratio);
-void scale2x(SDL_Surface *src, SDL_Surface *dst);
//@}
//------------------------------------------------------------------------------
Modified: branches/dunks/include/MainMenu.h
===================================================================
--- branches/dunks/include/MainMenu.h 2006-11-23 18:30:57 UTC (rev 123)
+++ branches/dunks/include/MainMenu.h 2006-11-23 22:37:25 UTC (rev 124)
@@ -4,6 +4,8 @@
#include "MenuBase.h"
#include "gui2/Button.h"
#include "gui2/VBox.h"
+#include "Gfx.h"
+#include "SDL.h"
class MainMenuState : public MenuBaseState
{
@@ -15,11 +17,13 @@
void doSkirmish();
void doSingle();
void doQuit();
+ int Execute(float dt);
virtual const char* GetName() { return "MainMenuState"; }
private:
VBox* m_vbox;
-
+ Rect m_rect;
+ SDL_Surface * m_surf;
BoringButton* m_butSingle;
BoringButton* m_butMulti;
BoringButton* m_butMapEd;
Modified: branches/dunks/include/OptionsMenu.h
===================================================================
--- branches/dunks/include/OptionsMenu.h 2006-11-23 18:30:57 UTC (rev 123)
+++ branches/dunks/include/OptionsMenu.h 2006-11-23 22:37:25 UTC (rev 124)
@@ -4,7 +4,6 @@
#include "MenuBase.h"
#include "gui2/Button.h"
#include "gui2/VBox.h"
-
#include "SDL.h"
@@ -23,7 +22,6 @@
private:
VBox* m_vbox;
-
BoringButton* m_butResolution;
BoringButton* m_butWindowMode;
BoringButton* m_butOk;
Modified: branches/dunks/src/Gfx.cpp
===================================================================
--- branches/dunks/src/Gfx.cpp 2006-11-23 18:30:57 UTC (rev 123)
+++ branches/dunks/src/Gfx.cpp 2006-11-23 22:37:25 UTC (rev 124)
@@ -316,54 +316,6 @@
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-11-23 18:30:57 UTC (rev 123)
+++ branches/dunks/src/IntroState.cpp 2006-11-23 22:37:25 UTC (rev 124)
@@ -1,6 +1,7 @@
#include "IntroState.h"
#include "ResMan.h"
#include "Application.h"
+#include "Gfx.h"
#include "Settings.h"
#include "pakfile/Palette.h"
#include "boost/bind.hpp"
@@ -58,7 +59,7 @@
SDL_SetColors(m_scaledSurface, palette->colors, 0, palette->ncolors);
- scale2x(m_animSurface, m_scaledSurface);
+ m_scaledSurface = resizeSurface(m_animSurface, 2);
}
bool IntroState::Frame::Execute(float dt)
@@ -119,7 +120,7 @@
SDL_SetColors(m_scaledSurface, palette->colors, 0, palette->ncolors);
- scale2x(m_animSurface, m_scaledSurface);
+ m_scaledSurface = resizeSurface(m_animSurface, 2);
};
};
}
Modified: branches/dunks/src/MainMenu.cpp
===================================================================
--- branches/dunks/src/MainMenu.cpp 2006-11-23 18:30:57 UTC (rev 123)
+++ branches/dunks/src/MainMenu.cpp 2006-11-23 22:37:25 UTC (rev 124)
@@ -3,13 +3,13 @@
#include "Application.h"
//#include "DataFile.h"
#include "Settings.h"
-
+#include "ResMan.h"
#include "SingleMenu.h"
#include "OptionsMenu.h"
#include "boost/bind.hpp"
+#include "pakfile/Wsafile.h"
-
MainMenuState::MainMenuState()
{
//m_menuBackground = (SDL_Surface*)(dataFile[UI_Menu].dat);
@@ -83,6 +83,53 @@
m_vbox->reshape();
m_container->addChild(m_vbox);
+
+//TODO:I guess that most of this should be wrapped into some function as
+//we'll be doing a lot of image cropping like this
+
+ int len;
+ unsigned char * data = ResMan::Instance()->readFile("MENTAT:FARTR.WSA", &len);
+
+ SDL_Palette* palette = Application::Instance()->Screen()->format->palette;
+
+ Wsafile * m_wsa = new Wsafile(data, len);
+
+ SDL_Surface * tmp = copySurface(m_wsa->getPicture(1, palette));
+
+ m_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, 258, 65, 8,0,0,0,0);
+
+ SDL_SetColors(m_surf, palette->colors, 0, palette->ncolors);
+
+ Rect src (6,31, 82, 65);
+
+ Rect cp(0, 0, 82, 65);
+
+ SDL_BlitSurface(tmp, &src, m_surf, &cp);
+
+
+ data = ResMan::Instance()->readFile("MENTAT:FHARK.WSA", &len);
+
+ m_wsa = new Wsafile(data, len);
+ tmp = copySurface(m_wsa->getPicture(1, palette));
+
+ cp.setPosition(SPoint(88, 0));
+
+ SDL_BlitSurface(tmp, &src, m_surf, &cp);
+
+ data = ResMan::Instance()->readFile("MENTAT:FORDOS.WSA", &len);
+
+ m_wsa = new Wsafile(data, len);
+ tmp = copySurface(m_wsa->getPicture(1, palette));
+
+ cp.setPosition(SPoint(176, 0));
+ SDL_BlitSurface(tmp, &src, m_surf, &cp);
+
+ m_surf = resizeSurface(m_surf, 2);
+
+ m_rect.setPosition(SPoint(Settings::Instance()->GetWidth() / 2 - m_surf->w/2,
+ Settings::Instance()->GetHeight() / 4));
+
+ m_rect.setSize(UPoint(m_surf->w, m_surf->h));
}
MainMenuState::~MainMenuState()
@@ -128,13 +175,12 @@
{
Application::Instance()->RootWidget()->deleteChild(m_vbox);
State::JustMadeInactive();
-}
+}*/
int MainMenuState::Execute(float dt)
{
- Application::Instance()->BlitCentered(m_menuBackground);
+ Application::Instance()->Blit(m_surf, NULL, &m_rect);
return 0;
}
-*/
Modified: branches/dunks/src/OptionsMenu.cpp
===================================================================
--- branches/dunks/src/OptionsMenu.cpp 2006-11-23 18:30:57 UTC (rev 123)
+++ branches/dunks/src/OptionsMenu.cpp 2006-11-23 22:37:25 UTC (rev 124)
@@ -2,6 +2,9 @@
#include "Application.h"
//#include "DataFile.h"
+#include "ResMan.h"
+#include "Gfx.h"
+#include "pakfile/Wsafile.h"
#include "Settings.h"
#include "boost/bind.hpp"
@@ -65,8 +68,8 @@
(m_vbox->w / 2);
m_vbox->setPosition(UPoint(x - 5, 312));
m_vbox->reshape();
-
m_container->addChild(m_vbox);
+
}
OptionsMenuState::~OptionsMenuState()
@@ -125,4 +128,3 @@
else
m_butWindowMode->setCaption("Window mode");
}
-
Modified: branches/dunks/src/SConscript
===================================================================
--- branches/dunks/src/SConscript 2006-11-23 18:30:57 UTC (rev 123)
+++ branches/dunks/src/SConscript 2006-11-23 22:37:25 UTC (rev 124)
@@ -39,6 +39,7 @@
"gui2/Container.cpp",
"gui2/Button.cpp",
"gui2/VBox.cpp",
+ "gui2/Label.cpp",
]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <shu...@us...> - 2006-11-28 20:33:56
|
Revision: 125
http://svn.sourceforge.net/dunelegacy/?rev=125&view=rev
Author: shutdownrunner
Date: 2006-11-28 12:33:50 -0800 (Tue, 28 Nov 2006)
Log Message:
-----------
- Added label(somehow didn't do it the previous time)
Added Paths:
-----------
branches/dunks/include/gui2/Label.h
branches/dunks/src/gui2/Label.cpp
Added: branches/dunks/include/gui2/Label.h
===================================================================
--- branches/dunks/include/gui2/Label.h (rev 0)
+++ branches/dunks/include/gui2/Label.h 2006-11-28 20:33:50 UTC (rev 125)
@@ -0,0 +1,33 @@
+#ifndef DUNE_GUI2_LABEL_H
+#define DUNE_GUI2_LABEL_H
+
+#include "gui2/Widget.h"
+#include <string>
+
+/* Label widget using dune's fonts
+*/
+class Label : public Widget
+{
+public:
+ //! @name Constructors & Destructor
+ //@{
+
+ /*!
+ Caption of label should always be set when constructing label
+ @param caption std::string a caption of label
+ @param bgcolour sets background colour of label. 115(dune yellow) by default
+ */
+ Label(std::string caption, int bgcolour = 115);
+
+ ~Label();
+ //@}
+
+ virtual void draw(SDL_Surface* dest, SPoint off);
+
+protected:
+
+ SDL_Surface * m_surface;
+ std::string m_caption;
+};
+
+#endif //DUNE_GUI2_LABEL_H
Added: branches/dunks/src/gui2/Label.cpp
===================================================================
--- branches/dunks/src/gui2/Label.cpp (rev 0)
+++ branches/dunks/src/gui2/Label.cpp 2006-11-28 20:33:50 UTC (rev 125)
@@ -0,0 +1,54 @@
+#include "gui2/Label.h"
+#include <stdio.h>
+#include "Colours.h"
+#include "Font.h"
+#include "Application.h"
+#include "Gfx.h"
+
+Label::Label(std::string caption, int bgcolour)
+{
+ m_caption = caption;
+ Font* font = FontManager::Instance()->getFont("INTRO:INTRO.FNT");
+
+ Uint16 textw, texth;
+
+ font->extents(m_caption.c_str(), textw, texth);
+
+ /*If surface width was not %4 == 0 then you'd get a text in italics */
+ m_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, textw + 4-(textw%4) , texth, 8,
+ 0, 0, 0, 0);
+
+ assert(m_surface != NULL);
+
+ SDL_LockSurface(m_surface);
+
+ SDL_Palette* pal = Application::Instance()->Screen()->format->palette;
+
+ SDL_SetColors(m_surface, pal->colors, 0, pal->ncolors);
+
+ SDL_FillRect(m_surface, NULL, bgcolour);
+
+ font->render(m_caption.c_str(), m_surface,
+ m_surface->w/2 - textw/2,
+ m_surface->h/2 - texth/2, 49);
+ SDL_UnlockSurface(m_surface);
+
+// Is it needed in case of label. It's not clickable or anything.
+// Widget::setSize(SPoint(textw, texth));
+};
+
+Label::~Label()
+{
+
+};
+
+void Label::draw(SDL_Surface* dest, SPoint off)
+{
+ if (!m_visible) return;
+
+ Rect destrect (off.x + x, off.y + y, 0, 0);
+
+ assert(m_surface != NULL);
+ SDL_BlitSurface(m_surface, NULL, dest, &destrect);
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <shu...@us...> - 2007-08-14 18:24:13
|
Revision: 131
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=131&view=rev
Author: shutdownrunner
Date: 2007-08-14 11:24:08 -0700 (Tue, 14 Aug 2007)
Log Message:
-----------
* Forgot to send these. Sorry
Modified Paths:
--------------
branches/dunks/SConstruct
branches/dunks/include/Application.h
branches/dunks/include/Log.h
branches/dunks/include/pakfile/Icnfile.h
branches/dunks/include/pakfile/Shpfile.h
Added Paths:
-----------
branches/dunks/include/DataCache.h
branches/dunks/include/pakview.h
Modified: branches/dunks/SConstruct
===================================================================
--- branches/dunks/SConstruct 2007-08-14 18:21:25 UTC (rev 130)
+++ branches/dunks/SConstruct 2007-08-14 18:24:08 UTC (rev 131)
@@ -43,9 +43,12 @@
"SDL_ttf",
])
+
+# If boost fails for you make sure you remove -mt from lines 49 and 50
+# It's a debian fix.
if sys.platform != 'win32':
- env.Append(LIBS=[ "boost_signals",
- "boost_filesystem",
+ env.Append(LIBS=[ "boost_signals-mt",
+ "boost_filesystem-mt",
])
env.Append(CPPPATH = [ "${SDL_INCLUDE_PATH}",
Modified: branches/dunks/include/Application.h
===================================================================
--- branches/dunks/include/Application.h 2007-08-14 18:21:25 UTC (rev 130)
+++ branches/dunks/include/Application.h 2007-08-14 18:24:08 UTC (rev 131)
@@ -6,6 +6,8 @@
#include "SDL.h"
#include "gui2/Container.h"
+#include "State.h"
+#include "TopLevelState.h"
typedef enum
{
CURSOR_NORMAL,
@@ -54,7 +56,7 @@
void UpdateVideoMode(bool fullscreen);
void UpdateVideoMode(Uint16 w, Uint16 h);
void UpdateVideoMode(Uint16 w, Uint16 h, bool fullscreen);
-
+
private:
void InitSettings();
void InitAudio();
Added: branches/dunks/include/DataCache.h
===================================================================
--- branches/dunks/include/DataCache.h (rev 0)
+++ branches/dunks/include/DataCache.h 2007-08-14 18:24:08 UTC (rev 131)
@@ -0,0 +1,112 @@
+#ifndef DUNE_DATACACHE_H
+#define DUNE_DATACACHE_H
+
+#include "Application.h"
+#include "Gfx.h"
+#include "Settings.h"
+#include "ResMan.h"
+#include "singleton.h"
+
+#include "pakfile/Cpsfile.h"
+#include "pakfile/Icnfile.h"
+#include "pakfile/Palette.h"
+#include "pakfile/Shpfile.h"
+#include "pakfile/Wsafile.h"
+
+#include "houses.h"
+
+#include <map>
+#include <vector>
+
+typedef enum {
+ ObjImg_Tank_Base,
+ ObjImg_Tank_Gun,
+ ObjImg_Siegetank_Base,
+ ObjImg_Siegetank_Gun,
+ ObjImg_Devastator_Base,
+ ObjImg_Devastator_Gun,
+ ObjImg_Sonictank_Gun,
+ ObjImg_Launcher_Gun,
+ ObjImg_Quad,
+ ObjImg_Trike,
+ ObjImg_Harvester,
+ ObjImg_Harvester_Sand,
+ ObjImg_MCV,
+ ObjImg_Carryall,
+ ObjImg_Frigate,
+ ObjImg_Ornithopter,
+ ObjImg_Trooper,
+ ObjImg_Infantry,
+ ObjImg_Saboteur,
+ ObjImg_Sandworm,
+ ObjImg_ConstructionYard,
+ ObjImg_Windtrap,
+ ObjImg_Refinery,
+ ObjImg_Barracks,
+ ObjImg_WOR,
+ ObjImg_Radar,
+ ObjImg_LightFactory,
+ ObjImg_Silo,
+ ObjImg_HeavyFactory,
+ ObjImg_HighTechFactory,
+ ObjImg_IX,
+ ObjImg_Palace,
+ ObjImg_RepairYard,
+ ObjImg_Starport,
+ ObjImg_GunTurret,
+ ObjImg_RocketTurret,
+ ObjImg_Wall,
+ ObjImg_Bullet_SmallRocket,
+ ObjImg_Bullet_MediumRocket,
+ ObjImg_Bullet_LargeRocket,
+ ObjImg_Bullet_Small,
+ ObjImg_Bullet_Medium,
+ ObjImg_Bullet_Sonic,
+ ObjImg_Hit_Gas,
+ ObjImg_Hit_Shell,
+ ObjImg_ExplosionSmall,
+ ObjImg_ExplosionMedium1,
+ ObjImg_ExplosionMedium2,
+ ObjImg_ExplosionLarge1,
+ ObjImg_ExplosionLarge2,
+ ObjImg_ExplosionSmallUnit,
+ ObjImg_DeadInfantry,
+ ObjImg_Smoke,
+ ObjImg_SandwormShimmerMask,
+ ObjImg_Terrain,
+ ObjImg_RockDamage,
+ ObjImg_SandDamage,
+ ObjImg_Terrain_Hidden,
+ NUM_OBJIMGS
+} ObjImg_enum;
+
+#define GROUNDUNIT_ROW(i) (i+2)|TILE_NORMAL,(i+1)|TILE_NORMAL,i|TILE_NORMAL,(i+1)|TILE_FLIPV,(i+2)|TILE_FLIPV,(i+3)|TILE_FLIPV, (i+4)|TILE_NORMAL,(i+3)|TILE_NORMAL
+#define AIRUNIT_ROW(i) (i+2)|TILE_NORMAL,(i+1)|TILE_NORMAL,i|TILE_NORMAL,(i+1)|TILE_FLIPV,(i+2)|TILE_FLIPV,(i+1)|TILE_ROTATE, i|TILE_FLIPH,(i+1)|TILE_FLIPH
+#define ORNITHOPTER_ROW(i) (i+6)|TILE_NORMAL,(i+3)|TILE_NORMAL,i|TILE_NORMAL,(i+3)|TILE_FLIPV,(i+6)|TILE_FLIPV,(i+3)|TILE_ROTATE, i|TILE_FLIPH,(i+3)|TILE_FLIPH
+#define INFANTRY_ROW(i) (i+3)|TILE_NORMAL,i|TILE_NORMAL,(i+3)|TILE_FLIPV,(i+6)|TILE_NORMAL
+#define HARVESTERSAND_ROW(i) (i+6)|TILE_NORMAL,(i+3)|TILE_NORMAL,i|TILE_NORMAL,(i+3)|TILE_FLIPV,(i+6)|TILE_FLIPV,(i+9)|TILE_FLIPV,(i+12)|TILE_NORMAL,(i+9)|TILE_NORMAL
+#define ROCKET_ROW(i) (i+4)|TILE_NORMAL,(i+3)|TILE_NORMAL,(i+2)|TILE_NORMAL,(i+1)|TILE_NORMAL,i|TILE_NORMAL,(i+1)|TILE_FLIPV,(i+2)|TILE_FLIPV,(i+3)|TILE_FLIPV, \
+ (i+4)|TILE_FLIPV,(i+3)|TILE_ROTATE,(i+2)|TILE_ROTATE, (i+1)|TILE_ROTATE,i|TILE_FLIPH,(i+1)|TILE_FLIPH,(i+2)|TILE_FLIPH,(i+3)|TILE_FLIPH
+
+
+typedef std::map <unsigned, ImagePtr> images;
+typedef std::vector <images*> remapped_images; //One for each house
+
+class DataCache : public Singleton<DataCache>
+{
+ friend class Singleton<DataCache>;
+
+ protected:
+ DataCache();
+ ~DataCache();
+
+ public:
+ void addObjImg(unsigned ID, SDL_Surface * tmp);
+ ImagePtr getObjImg(unsigned ID, unsigned house = HOUSE_HARKONNEN);
+ private:
+ bool addObjImg(unsigned ID) { return false;};
+ remapped_images m_objImg;
+ remapped_images m_guiImg;
+};
+
+#endif // DUNE_DATACACHE_H
Modified: branches/dunks/include/Log.h
===================================================================
--- branches/dunks/include/Log.h 2007-08-14 18:21:25 UTC (rev 130)
+++ branches/dunks/include/Log.h 2007-08-14 18:24:08 UTC (rev 131)
@@ -198,7 +198,7 @@
int indentLevel;
bool checkMessageVerbosity(ConstString logSystem, LogVerbosity verbosity);
- void doLog(ConstString logSystem, LogVerbosity verbosity, const char *format, ...);
+ void doLog(ConstString logSystem, LogVerbosity verbosity, const char *format, va_list args);
};
Modified: branches/dunks/include/pakfile/Icnfile.h
===================================================================
--- branches/dunks/include/pakfile/Icnfile.h 2007-08-14 18:21:25 UTC (rev 130)
+++ branches/dunks/include/pakfile/Icnfile.h 2007-08-14 18:24:08 UTC (rev 131)
@@ -3,16 +3,82 @@
#include "SDL.h"
+/*!
+ A class for loading a *.ICN-File and the corresponding *.MAP-File.
+
+ This class can read icn-Files and return the contained pictures as a SDL_Surface. An icn-File contains
+ small 16x16 pixel tiles. The map-file contains the information how to build up a complete picture with
+ this small tiles.
+*/
class Icnfile
{
+private:
+ //! Internal structure for the MAP-File.
+ struct MapfileEntry
+ {
+ Uint32 NumTiles;
+ Uint16* TileIndex;
+ };
public:
- Icnfile(unsigned char * bufFiledata, int bufsize);
+ Icnfile(unsigned char * bufFiledata, int bufsize,
+ unsigned char * bufMapdata, int mapsize);
~Icnfile();
- SDL_Surface * getPicture(Uint32 IndexOfFile, SDL_Palette *palette);
+ SDL_Surface * getPicture(Uint32 IndexOfFile);
+/// Returns an array of pictures in the icn-File
+/*!
+ This method returns a SDL_Surface containing multiple tiles/pictures. Which tiles to include is specified by MapfileIndex. The
+ MapfileIndex specifies the tileset. One tileset constists of multiple tiles of the icn-File.
+ The last 3 parameters specify how to arrange the tiles:
+ - If all 3 parameters are 0 then a "random" layout is choosen, which should look good.
+ - If tilesX and tilesY is set to non-zero values then the result surface contains tilesX*tilesY tiles and this tilesN-times side by side.
+ - If all there parameters are non-zero then the result surface is exactly in this arrangement.
+
+ tilesX*tilesY*tilesN must always the number of tiles in this tileset. Otherwise NULL is returned.<br><br>
+ Example:
+ @code
+ Tileset = 10,11,12,13,14,15,16,17,18,19,20,21
+ tilesX = 2; tilesY = 2; tilesN = 3
+
+ returned picture:
+ 10 11 14 15 18 19
+ 12 13 16 17 20 21
+ @endcode
+ <br>
+ The returned SDL_Surface should be freed with SDL_FreeSurface() if no longer needed.
+ @param MapfileIndex specifies which tileset to use (zero based)
+ @param tilesX how many tiles in x direction
+ @param tilesY how many tiles in y direction
+ @param tilesN how many tilesX*tilesY blocks in a row
+ @return the result surface with tilesX*tilesY*tilesN tiles
+*/
+ SDL_Surface * getPictureArray(Uint32 MapfileIndex, int tilesX = 0, int tilesY = 0, int tilesN = 0);
+
+/*!
+ This method returns a SDL_Surface containing multiple tiles/pictures. The returned surface contains all
+ tiles from StartIndex to EndIndex.
+ The returned SDL_Surface should be freed with SDL_FreeSurface() if no longer needed.
+ @param StartIndex The first tile to use
+ @param EndIndex The last tile to use
+ @return the result surface with (EndIndex-StartIndex+1) tiles. NULL on errors.
+*/
+ SDL_Surface * getPictureRow(Uint32 StartIndex, Uint32 EndIndex);
+
+ /// Returns the number of tiles
+/*!
+ Returns the number of tiles in the icn-File.
+ @return Number of tiles
+*/
int getNumFiles();
+
+ /// Returns the number of tilesets
+/*!
+ Returns the number of tilesets in the map-File.
+ @return Number of tilesets
+*/
+ int getNumTilesets() { return NumTilesets; };
private:
unsigned char* Filedata;
@@ -20,6 +86,9 @@
Uint32 NumFiles;
+ Uint16 NumTilesets;
+ MapfileEntry* Tileset;
+
unsigned char* SSET;
Uint32 SSET_Length;
unsigned char* RPAL;
Modified: branches/dunks/include/pakfile/Shpfile.h
===================================================================
--- branches/dunks/include/pakfile/Shpfile.h 2007-08-14 18:21:25 UTC (rev 130)
+++ branches/dunks/include/pakfile/Shpfile.h 2007-08-14 18:24:08 UTC (rev 131)
@@ -4,6 +4,14 @@
#include "SDL.h"
#include "pakfile/Decode.h"
+#define TILE_NORMAL 0x00010000
+#define TILE_FLIPH 0x00100000
+#define TILE_FLIPV 0x01000000
+#define TILE_ROTATE 0x10000000
+
+#define TILE_GETINDEX(x) (x & 0x0000FFFF)
+#define TILE_GETTYPE(x) (x & 0xFFFF0000)
+
struct ShpfileEntry
{
Uint32 StartOffset;
@@ -16,8 +24,38 @@
Shpfile(unsigned char * bufFiledata, int bufsize);
~Shpfile();
- SDL_Surface* getPicture(Uint32 IndexOfFile, SDL_Palette *palette);
+/*!
+ This method returns a SDL_Surface containing the nth picture in this shp-File.
+ The returned SDL_Surface should be freed with SDL_FreeSurface() if no longer needed.
+ @param IndexOfFile specifies which picture to return (zero based)
+ @return nth picture in this shp-File
+*/
+ SDL_Surface* getPicture(Uint32 IndexOfFile);
+/*!
+ This method returns a SDL_Surface containing an array of pictures from this shp-File.
+ All pictures must be of the same size. tilesX/tilesY specifies how many pictures are in this row/column.
+ Afterwards there must be tilesX*tilesY many parameters. Every parameter specifies which picture
+ of this shp-File should be used. This indices must be ORed with a parameter specifing hwo they should
+ be in the result surface. There are 4 modes and you must OR exactly one:
+ - TILE_NORMAL Normal
+ - TILE_FLIPH mirrored horizontally
+ - TILE_FLIPV mirrored vertically
+ - TILE_ROTATE Rotated by 180 degress
+
+ Example:
+ @code
+ picture = myShpfile->getPictureArray(4,1, TILE_NORMAL | 20, TILE_FLIPH | 23, TILE_ROTATE | 67, TILE_NORMAL | 68);
+ @endcode
+ This example would create a surface with four pictures in it. From the left to the right there are
+ picture 20,23,67 and 68. picture 23 is mirrored horizontally, 67 is rotated.<br><br>
+ The returned SDL_Surface should be freed with SDL_FreeSurface() if no longer needed.
+ @param tilesX how many pictures in one row
+ @param tilesY how many pictures in one column
+ @return picture in this shp-File containing all specified pictures
+*/
+ SDL_Surface* getPictureArray(unsigned int tilesX, unsigned int tilesY, ...);
+
inline int getNumFiles() {return (int) NumFiles;};
private:
Added: branches/dunks/include/pakview.h
===================================================================
--- branches/dunks/include/pakview.h (rev 0)
+++ branches/dunks/include/pakview.h 2007-08-14 18:24:08 UTC (rev 131)
@@ -0,0 +1,6 @@
+#ifndef DUNE_PAKVIEW_H
+#define DUNE_PAKVIEW_H
+
+
+
+#endif // DUNE_PAKVIEW_H
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <shu...@us...> - 2007-12-08 16:05:05
|
Revision: 132
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=132&view=rev
Author: shutdownrunner
Date: 2007-12-08 08:04:58 -0800 (Sat, 08 Dec 2007)
Log Message:
-----------
* Used shared_ptr more frequently to avoid memory leaks
* Nothing more, apart from being less leaky
Modified Paths:
--------------
branches/dunks/SConstruct
branches/dunks/include/Application.h
branches/dunks/include/Font.h
branches/dunks/include/Gfx.h
branches/dunks/include/IntroState.h
branches/dunks/include/MainMenu.h
branches/dunks/include/gui2/Button.h
branches/dunks/include/gui2/Container.h
branches/dunks/include/gui2/Label.h
branches/dunks/include/gui2/Widget.h
branches/dunks/include/pakfile/Wsafile.h
branches/dunks/src/Application.cpp
branches/dunks/src/Font.cpp
branches/dunks/src/Gfx.cpp
branches/dunks/src/IntroState.cpp
branches/dunks/src/MainMenu.cpp
branches/dunks/src/ResMan.cpp
branches/dunks/src/SConscript
branches/dunks/src/gui2/Button.cpp
branches/dunks/src/gui2/Container.cpp
branches/dunks/src/gui2/Label.cpp
branches/dunks/src/pakfile/Cpsfile.cpp
branches/dunks/src/pakfile/Icnfile.cpp
branches/dunks/src/pakfile/Shpfile.cpp
branches/dunks/src/pakfile/Wsafile.cpp
branches/dunks/src/pakview.cpp
Modified: branches/dunks/SConstruct
===================================================================
--- branches/dunks/SConstruct 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/SConstruct 2007-12-08 16:04:58 UTC (rev 132)
@@ -25,7 +25,7 @@
if sys.platform != "win32":
env.ParseConfig('sdl-config --cflags --libs')
env.ParseConfig('pkg-config --cflags --libs zziplib')
- env.Append(CCFLAGS=["-Wall"]) #, "-Werror"])
+ env.Append(CCFLAGS=["-Wall", "-O0"]) #, "-Werror"])
#env.Append(CCFLAGS=["-Wall", "-Werror", "-O2", "-ffast-math", "-funroll-loops"])
#env.Append(LINKFLAGS = ["-ffast-math"])
Modified: branches/dunks/include/Application.h
===================================================================
--- branches/dunks/include/Application.h 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/include/Application.h 2007-12-08 16:04:58 UTC (rev 132)
@@ -34,7 +34,7 @@
void Die();
- inline SDL_Surface* Screen() { return m_screen; }
+ inline Image * Screen() { return m_screen; }
inline Uint16 CursorX() { return m_cursorX; }
inline Uint16 CursorY() { return m_cursorY; }
@@ -45,9 +45,6 @@
Container* RootWidget() { return m_rootWidget; }
- void Blit(SDL_Surface* surface, SDL_Rect* src, SDL_Rect* dest);
- void BlitCentered(SDL_Surface* surface, SDL_Rect* src=NULL);
-
void SetPalette();
SDL_Palette* GetCurrentPalette() { return m_currentPalette; }
@@ -69,7 +66,7 @@
void HandleEvents();
void BlitCursor();
- SDL_Surface* m_screen;
+ Image * m_screen;
SDL_Palette* m_currentPalette;
StateMachine* m_rootState;
@@ -80,7 +77,7 @@
Uint16 m_cursorX, m_cursorY;
Cursor m_cursorFrame;
- SDL_Surface* m_cursor;
+ ImagePtr m_cursor;
Uint32 m_clearColor;
};
Modified: branches/dunks/include/Font.h
===================================================================
--- branches/dunks/include/Font.h 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/include/Font.h 2007-12-08 16:04:58 UTC (rev 132)
@@ -1,6 +1,7 @@
#ifndef DUNE_FONT_H
#define DUNE_FONT_H
+#include "Gfx.h"
#include "singleton.h"
#include "SDL.h"
#include "SDL_ttf.h"
@@ -46,7 +47,7 @@
~Font();
void extents(const char* text, Uint16& w, Uint16& h);
- void render(const char* text, SDL_Surface* surface, int x, int y, Uint8 paloff);
+ void render(const char* text, ImagePtr image, int x, int y, Uint8 paloff);
private:
FNTHeader* m_header;
Modified: branches/dunks/include/Gfx.h
===================================================================
--- branches/dunks/include/Gfx.h 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/include/Gfx.h 2007-12-08 16:04:58 UTC (rev 132)
@@ -633,11 +633,11 @@
/*!
@param size size of the new image
*/
- ImagePtr getResized(ConstUPoint size)
+/* ImagePtr getResized(ConstUPoint size)
{
return ImagePtr(new Image(resizeSurface(surface, size.x, size.y)));
};
-
+*/
//! Set colorkey
/*!
Modified: branches/dunks/include/IntroState.h
===================================================================
--- branches/dunks/include/IntroState.h 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/include/IntroState.h 2007-12-08 16:04:58 UTC (rev 132)
@@ -1,6 +1,7 @@
#ifndef DUNE_INTROSTATE_H
#define DUNE_INTROSTATE_H
+#include "Gfx.h"
#include "State.h"
#include "gui2/Button.h"
#include "pakfile/Wsafile.h"
@@ -45,11 +46,11 @@
Transition m_transition_out;
bool mb_finished;
- Wsafile *m_wsa;
+ WsafilePtr m_wsa;
int m_currentFrame;
float m_frametime;
- SDL_Surface* m_animSurface, *m_scaledSurface;
+ ImagePtr m_animSurface, m_scaledSurface;
SDL_Color* m_transitionPalette;
void setupTransitionIn();
Modified: branches/dunks/include/MainMenu.h
===================================================================
--- branches/dunks/include/MainMenu.h 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/include/MainMenu.h 2007-12-08 16:04:58 UTC (rev 132)
@@ -23,7 +23,7 @@
private:
VBox* m_vbox;
Rect m_rect;
- SDL_Surface * m_surf;
+ ImagePtr m_surf;
BoringButton* m_butSingle;
BoringButton* m_butMulti;
BoringButton* m_butMapEd;
Modified: branches/dunks/include/gui2/Button.h
===================================================================
--- branches/dunks/include/gui2/Button.h 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/include/gui2/Button.h 2007-12-08 16:04:58 UTC (rev 132)
@@ -18,19 +18,18 @@
{
public:
GraphicButton();
- GraphicButton(SDL_Surface* normal, SDL_Surface* pressed=NULL);
+ GraphicButton(ImagePtr normal, ImagePtr pressed);
- void setGraphics(SDL_Surface* normal,
- SDL_Surface* pressed = NULL);
+ void setGraphics(ImagePtr normal, ImagePtr pressed);
- virtual void draw(SDL_Surface* dest, SPoint off);
+ virtual void draw(Image * dest, SPoint off);
virtual bool handleButtonDown(Uint8 button, SPoint p);
virtual bool handleButtonUp(Uint8 button, SPoint p);
protected:
- SDL_Surface* m_surfNormal;
- SDL_Surface* m_surfPressed;
+ ImagePtr m_surfNormal;
+ ImagePtr m_surfPressed;
bool m_pressed;
};
Modified: branches/dunks/include/gui2/Container.h
===================================================================
--- branches/dunks/include/gui2/Container.h 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/include/gui2/Container.h 2007-12-08 16:04:58 UTC (rev 132)
@@ -9,7 +9,7 @@
public:
typedef std::list<Widget*> WidgetList;
- virtual void draw(SDL_Surface* dest, SPoint offset);
+ virtual void draw(Image * dest, SPoint offset);
virtual bool handleMotion(SPoint p);
virtual bool handleButtonDown(Uint8 button, SPoint p);
Modified: branches/dunks/include/gui2/Label.h
===================================================================
--- branches/dunks/include/gui2/Label.h 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/include/gui2/Label.h 2007-12-08 16:04:58 UTC (rev 132)
@@ -22,11 +22,11 @@
~Label();
//@}
- virtual void draw(SDL_Surface* dest, SPoint off);
+ virtual void draw(Image * dest, SPoint off);
protected:
- SDL_Surface * m_surface;
+ ImagePtr m_surface;
std::string m_caption;
};
Modified: branches/dunks/include/gui2/Widget.h
===================================================================
--- branches/dunks/include/gui2/Widget.h 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/include/gui2/Widget.h 2007-12-08 16:04:58 UTC (rev 132)
@@ -15,7 +15,7 @@
virtual ~Widget();
//@}
- virtual void draw(SDL_Surface* dest, SPoint off) {}
+ virtual void draw(Image * dest, SPoint off) {}
//! @name Event handling functions
//@{
Modified: branches/dunks/include/pakfile/Wsafile.h
===================================================================
--- branches/dunks/include/pakfile/Wsafile.h 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/include/pakfile/Wsafile.h 2007-12-08 16:04:58 UTC (rev 132)
@@ -1,11 +1,16 @@
#ifndef WSAFILE_H_INCLUDED
#define WSAFILE_H_INCLUDED
+#include "Gfx.h"
#include "pakfile/Decode.h"
#include "SDL.h"
-//extern SDL_Palette* palette;
+#include <boost/shared_ptr.hpp>
+class Wsafile;
+
+typedef boost::shared_ptr<Wsafile> WsafilePtr;
+
class Wsafile : public Decode
{
public:
@@ -13,7 +18,7 @@
SDL_Surface* lastframe = NULL);
~Wsafile();
- SDL_Surface * getPicture(Uint32 FrameNumber, SDL_Palette *palette);
+ Image * getPicture(Uint32 FrameNumber, SDL_Palette *palette);
inline int getNumFrames() { return (int) NumFrames; };
inline Uint32 getFramesPer1024ms() { return FramesPer1024ms; };
@@ -32,7 +37,7 @@
Uint16 SizeX;
Uint16 SizeY;
Uint32 FramesPer1024ms;
- float fps;
+ float fps;
};
#endif // WSAFILE_H_INCLUDED
Modified: branches/dunks/src/Application.cpp
===================================================================
--- branches/dunks/src/Application.cpp 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/src/Application.cpp 2007-12-08 16:04:58 UTC (rev 132)
@@ -23,7 +23,7 @@
#include "Font.h"
#include "TopLevelState.h"
//#include "DataFile.h"
-
+#include "Gfx.h"
#include "pakfile/Palette.h"
#include "pakfile/Shpfile.h"
#include "pakfile/Cpsfile.h"
@@ -40,7 +40,6 @@
{
m_running = false;
m_rootState = NULL;
- m_screen = NULL;
m_cursorX = 0;
m_cursorY = 0;
@@ -55,13 +54,13 @@
delete m_rootState;
delete m_rootWidget;
- FontManager::Destroy();
+ //FontManager::Destroy();
//destroyDataFile();
//MentatClass::Destroy();
//Mix_CloseAudio();
//SDLNet_Quit();
- SDL_Quit();
+ //SDL_Quit();
}
void Application::Init()
@@ -213,10 +212,10 @@
assert(pal != NULL);
printf("setting palette %d colors\n", pal->ncolors);
- assert( SDL_SetColors(m_screen, pal->colors, 0, pal->ncolors) == 1 );
+ assert( SDL_SetColors(m_screen->getSurface(), pal->colors, 0, pal->ncolors) == 1 );
m_currentPalette = pal;
- SDL_Palette* palette = m_screen->format->palette;
+ SDL_Palette* palette = m_screen->getSurface()->format->palette;
palette = m_currentPalette;
}
@@ -231,13 +230,15 @@
if (set->m_fullscreen)
videoFlags |= SDL_FULLSCREEN;
- m_screen = SDL_SetVideoMode(set->m_width, set->m_height,
- 8, videoFlags);
- if(!m_screen)
+ SDL_Surface * surf = SDL_SetVideoMode(set->m_width, set->m_height, 8, videoFlags);
+
+ if(!surf)
{
fprintf(stderr, "ERROR: Couldn't set video mode: %s\n", SDL_GetError());
Die();
};
+
+ m_screen = new Image(surf);
// reset the palette if we've got one
if (m_currentPalette != NULL)
@@ -299,7 +300,7 @@
Shpfile mouse (data, len);
- m_cursor = mouse.getPicture(0);
+ m_cursor.reset(new Image(mouse.getPicture(0)));
/*
@@ -340,7 +341,7 @@
while (m_running)
{
- SDL_FillRect(m_screen, NULL, m_clearColor);
+ SDL_FillRect(m_screen->getSurface(), NULL, m_clearColor);
HandleEvents();
@@ -378,7 +379,7 @@
}
#endif
- SDL_Flip(m_screen);
+ SDL_Flip(m_screen->getSurface());
fps_frames ++;
@@ -405,7 +406,7 @@
switch (event.type)
{
case SDL_QUIT:
- printf("QUIT!\n");
+ fprintf(stderr,"QUIT!\n");
m_running = false;
break;
case SDL_MOUSEMOTION:
@@ -435,8 +436,8 @@
void Application::BlitCursor()
{
- SDL_Rect dest;
- SDL_Surface* surface = m_cursor; // being lazy, rename me
+ UPoint dest;
+ SDL_Surface * surface = m_cursor->getSurface(); // being lazy, rename me
dest.x = m_cursorX;
dest.y = m_cursorY;
@@ -461,31 +462,8 @@
dest.y -= surface->h/2;
}
- SDL_BlitSurface(surface, NULL, m_screen, &dest);
-}
+ m_screen->blitFrom(m_cursor.get(), dest);
-
-void Application::Blit(SDL_Surface* surface, SDL_Rect* src, SDL_Rect* dest)
-{
- assert( SDL_BlitSurface(surface, src, m_screen, dest) == 0 );
+ //SDL_BlitSurface(surface, NULL, m_screen, &dest);
}
-void Application::BlitCentered(SDL_Surface* surface, SDL_Rect* src)
-{
- SDL_Rect dest;
- if (src == NULL)
- {
- dest.x = (Settings::Instance()->m_width / 2) - (surface->w / 2);
- dest.y = (Settings::Instance()->m_height / 2) - (surface->h / 2);
- }
- else
- {
- dest.x = (Settings::Instance()->m_width / 2) - (src->w / 2);
- dest.y = (Settings::Instance()->m_height / 2) - (src->h / 2);
- };
-
- //printf("blitting %d %d %d %d\n", dest.x, dest.y, surface->w, surface->h);
- Blit(surface, src, &dest);
-}
-
-
Modified: branches/dunks/src/Font.cpp
===================================================================
--- branches/dunks/src/Font.cpp 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/src/Font.cpp 2007-12-08 16:04:58 UTC (rev 132)
@@ -32,10 +32,13 @@
};
}
-void Font::render(const char* text, SDL_Surface* surface, int offx, int offy, Uint8 paloff)
+void Font::render(const char* text, ImagePtr image, int offx, int offy, Uint8 paloff)
{
FNTCharacter* ch;
byte* bitmap;
+
+ SDL_Surface * surface = image->getSurface();
+
Uint8* pixels = (Uint8*)surface->pixels;
for (unsigned int c=0; c!=strlen(text); c++)
Modified: branches/dunks/src/Gfx.cpp
===================================================================
--- branches/dunks/src/Gfx.cpp 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/src/Gfx.cpp 2007-12-08 16:04:58 UTC (rev 132)
@@ -38,7 +38,7 @@
};
// copy palette from the screen (otherwise you'll get only black image)
- SDL_SetColors(surface, Application::Instance()->Screen()->format->palette->colors, 0, 256);
+ SDL_SetColors(surface, Application::Instance()->Screen()->getSurface()->format->palette->colors, 0, 256);
}
Image::~Image()
{
@@ -53,26 +53,21 @@
return surface;
}
-// TODO: once Application::Instance()->Screen() returns ImagePtr, change
-// these methods to use Image::blitTo !
void Image::blitToScreen(ConstRect srcRect, ConstUPoint dstPoint) const
{
- Rect dstRect(Rect(dstPoint, getSize()));
- SDL_BlitSurface(surface, const_cast<SDL_Rect *>(static_cast<const SDL_Rect *>(&srcRect)), Application::Instance()->Screen(), &dstRect);
+ blitTo(Application::Instance()->Screen(), srcRect, dstPoint);
}
void Image::blitToScreen(ConstUPoint dstPoint) const
{
- Rect dstRect(Rect(dstPoint, getSize()));
- SDL_BlitSurface(surface, NULL, Application::Instance()->Screen(), &dstRect);
+ blitTo(Application::Instance()->Screen(), dstPoint);
}
void Image::blitToScreen() const
{
- SDL_BlitSurface(surface, NULL, Application::Instance()->Screen(), NULL);
+ blitTo(Application::Instance()->Screen());
}
void Image::blitToScreenCentered() const
{
- Rect dstRect(Rect(UPoint(Application::Instance()->Screen()->w, Application::Instance()->Screen()->h)/2 - getSize()/2, getSize()));
- SDL_BlitSurface(surface, NULL, Application::Instance()->Screen(), &dstRect);
+ blitToCentered(Application::Instance()->Screen());
}
@@ -134,7 +129,7 @@
void putPixel(SDL_Surface *surface, int x, int y, Uint32 color)
{
assert(surface != NULL);
- SDL_Surface *screen = Application::Instance()->Screen();
+ SDL_Surface *screen = Application::Instance()->Screen()->getSurface();
if (x >= 0 && x < screen->w && y >=0 && y < screen->h)
{
int bpp = surface->format->BytesPerPixel;
Modified: branches/dunks/src/IntroState.cpp
===================================================================
--- branches/dunks/src/IntroState.cpp 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/src/IntroState.cpp 2007-12-08 16:04:58 UTC (rev 132)
@@ -25,6 +25,8 @@
void IntroState::Frame::Load(Frame* lastframe)
{
+ SDL_Palette* palette = Application::Instance()->Screen()->getSurface()->format->palette;
+
printf("intro loading %s\n", m_filename.c_str());
int len;
@@ -34,32 +36,20 @@
if (m_continuation)
{
- m_wsa = new Wsafile(data, len, lastframe->m_animSurface);
+ m_wsa.reset(new Wsafile(data, len, lastframe->m_animSurface->getSurface()));
}
else
{
- m_wsa = new Wsafile(data, len);
+ m_wsa.reset(new Wsafile(data, len));
}
m_frametime = 0;
m_currentFrame = 0;
mb_finished = false;
- SDL_Palette* palette = Application::Instance()->Screen()->format->palette;
- m_animSurface = m_wsa->getPicture(m_currentFrame, palette);
+ m_animSurface.reset(m_wsa->getPicture(m_currentFrame, palette));
+ m_scaledSurface = m_animSurface->getResized(2.0);
- 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);
-
- m_scaledSurface = resizeSurface(m_animSurface, 2);
}
bool IntroState::Frame::Execute(float dt)
@@ -84,16 +74,16 @@
break;
};
- assert(m_scaledSurface != NULL);
-
- Application::Instance()->BlitCentered(m_scaledSurface);
-
+ m_scaledSurface->blitToScreenCentered();
+
return mb_finished;
}
void IntroState::Frame::doPlaying(float dt)
{
+ SDL_Palette* palette = Application::Instance()->Screen()->getSurface()->format->palette;
+
m_frametime += dt;
if (m_frametime > m_wsa->getFPS())
@@ -106,21 +96,8 @@
}
else
{
- 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);
-
- m_scaledSurface = resizeSurface(m_animSurface, 2);
+ m_animSurface.reset(m_wsa->getPicture(m_currentFrame, palette));
+ m_scaledSurface = m_animSurface->getResized(2.0);
};
};
}
@@ -142,7 +119,7 @@
{
m_transitionPalette = new SDL_Color[256];
memcpy((unsigned char*)m_transitionPalette,
- Application::Instance()->Screen()->format->palette->colors,
+ Application::Instance()->Screen()->getSurface()->format->palette->colors,
sizeof(SDL_Color) * 256);
}
@@ -162,7 +139,7 @@
if (m_transitionPalette == NULL) setupTransitionOut();
bool done = true;
- SDL_Surface* screen = m_scaledSurface; //Application::Instance()->Screen();
+ SDL_Surface* screen = m_scaledSurface->getSurface(); //Application::Instance()->Screen();
SDL_Color* col = m_transitionPalette;
const int fadeAmt = 3;
@@ -278,6 +255,7 @@
void IntroState::SkipIntro()
{
mp_parent->PopState();
+
}
void IntroState::JustMadeActive()
@@ -296,7 +274,7 @@
bool IntroState::next()
{
- printf("loading next..\n");
+ fprintf(stderr, "loading next..\n");
IntroList::iterator it = m_wsaNames.begin();
if (it == m_wsaNames.end() )
{
Modified: branches/dunks/src/MainMenu.cpp
===================================================================
--- branches/dunks/src/MainMenu.cpp 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/src/MainMenu.cpp 2007-12-08 16:04:58 UTC (rev 132)
@@ -1,6 +1,7 @@
#include "MainMenu.h"
#include "Application.h"
+#include "Gfx.h"
//#include "DataFile.h"
#include "Settings.h"
#include "ResMan.h"
@@ -90,46 +91,27 @@
int len;
unsigned char * data = ResMan::Instance()->readFile("MENTAT:FARTR.WSA", &len);
- SDL_Palette* palette = Application::Instance()->Screen()->format->palette;
+ SDL_Palette* palette = Application::Instance()->Screen()->getSurface()->format->palette;
- Wsafile * m_wsa = new Wsafile(data, len);
+ WsafilePtr m_wsa (new Wsafile(data, len));
- SDL_Surface * tmp = copySurface(m_wsa->getPicture(1, palette));
-
- m_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, 258, 65, 8,0,0,0,0);
-
- SDL_SetColors(m_surf, palette->colors, 0, palette->ncolors);
-
+ ImagePtr tmp (m_wsa->getPicture(1, palette));
+ m_surf.reset(new Image(UPoint(258, 65)));
Rect src (6,31, 82, 65);
+ m_surf->blitFrom(tmp.get(), src, UPoint(0, 0));
- Rect cp(0, 0, 82, 65);
-
- SDL_BlitSurface(tmp, &src, m_surf, &cp);
-
-
data = ResMan::Instance()->readFile("MENTAT:FHARK.WSA", &len);
+ m_wsa.reset(new Wsafile(data, len));
+ tmp.reset(m_wsa->getPicture(1, palette));
+ m_surf->blitFrom(tmp.get(), src, UPoint(88, 0));
- m_wsa = new Wsafile(data, len);
- tmp = copySurface(m_wsa->getPicture(1, palette));
-
- cp.setPosition(SPoint(88, 0));
-
- SDL_BlitSurface(tmp, &src, m_surf, &cp);
-
data = ResMan::Instance()->readFile("MENTAT:FORDOS.WSA", &len);
+ m_wsa.reset(new Wsafile(data, len));
+ tmp.reset(m_wsa->getPicture(1, palette));
+ m_surf->blitFrom(tmp.get(), src, UPoint(176, 0));
- m_wsa = new Wsafile(data, len);
- tmp = copySurface(m_wsa->getPicture(1, palette));
+ m_surf = m_surf->getResized(2);
- cp.setPosition(SPoint(176, 0));
- SDL_BlitSurface(tmp, &src, m_surf, &cp);
-
- m_surf = resizeSurface(m_surf, 2);
-
- m_rect.setPosition(SPoint(Settings::Instance()->GetWidth() / 2 - m_surf->w/2,
- Settings::Instance()->GetHeight() / 4));
-
- m_rect.setSize(UPoint(m_surf->w, m_surf->h));
}
MainMenuState::~MainMenuState()
@@ -180,7 +162,8 @@
int MainMenuState::Execute(float dt)
{
- Application::Instance()->Blit(m_surf, NULL, &m_rect);
+ m_surf.get()->blitToScreen(SPoint(Settings::Instance()->GetWidth() / 2 - m_surf->getSurface()->w/2,
+ Settings::Instance()->GetHeight() / 4));
return 0;
}
Modified: branches/dunks/src/ResMan.cpp
===================================================================
--- branches/dunks/src/ResMan.cpp 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/src/ResMan.cpp 2007-12-08 16:04:58 UTC (rev 132)
@@ -225,8 +225,7 @@
assert(p != std::string::npos);
std::string fsname = std::string(name, 0, p);
- filename = std::string(name, p+1,
- name.length() - fsname.length() - 1);
+ filename = std::string(name, p+1, name.length() - fsname.length() - 1);
printf("opening file from %s named %s...\n", fsname.c_str(), filename.c_str());
@@ -262,15 +261,15 @@
if (res == NULL)
{
- if (size != NULL) size = 0;
+ if (size != NULL) size = 0;
return NULL;
- };
-
+ };
+
unsigned char *buf = res->readFile(filename.c_str(), size);
assert(buf != NULL);
-
- return buf;
+
+ return buf;
}
FileLike* ResMan::readFile(std::string name)
Modified: branches/dunks/src/SConscript
===================================================================
--- branches/dunks/src/SConscript 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/src/SConscript 2007-12-08 16:04:58 UTC (rev 132)
@@ -18,7 +18,7 @@
"Font.cpp",
"State.cpp",
# "DataFile.cpp",
- "PictureFactory.cpp",
+# "PictureFactory.cpp",
"TopLevelState.cpp",
"MenuBase.cpp",
"MainMenu.cpp",
@@ -73,6 +73,6 @@
dunelegacy = env.Program("../dunelegacy", ["main.cpp"] + all_sources + gui_sources + pak_sources )
pakview = env.Program("../test", ["pakview.cpp"] + pakview_sources + gui_sources + pak_sources )
-#Default(dunelegacy)
-Default(pakview)
+Default(dunelegacy)
+#Default(pakview)
Modified: branches/dunks/src/gui2/Button.cpp
===================================================================
--- branches/dunks/src/gui2/Button.cpp 2007-08-14 18:24:08 UTC (rev 131)
+++ branches/dunks/src/gui2/Button.cpp 2007-12-08 16:04:58 UTC (rev 132)
@@ -17,44 +17,39 @@
GraphicButton::GraphicButton()
{
- m_surfNormal = NULL;
- m_surfPressed = NULL;
m_pressed = false;
}
-GraphicButton::GraphicButton(SDL_Surface* normal, SDL_Surface* pressed)
+GraphicButton::GraphicButton(ImagePtr normal, ImagePtr pressed)
{
setGraphics(normal, pressed);
m_pressed = false;
}
-void GraphicButton::setGraphics(SDL_Surface* normal, SDL_Surface* pressed)
+void GraphicButton::setGraphics(ImagePtr normal, ImagePtr pressed)
{
- assert(pressed != NULL && ((normal->w == pressed->w) &&
- (normal->h == pressed->h)));
+ assert(pressed != NULL && ((normal->getSurface()->w == pressed->getSurface()->w) &&
+ (normal->getSurface()->h == pressed->getSurface()->h)));
- m_surfNormal = normal;
- m_surfPressed = pressed;
+ m_surfNormal.reset(normal.get());
+ m_surfPressed.reset(pressed.get());
- w = normal->w;
- h = normal->h;
+ setSize(normal->getSize());
+ //w = normal->getSurfacew;
+ //h = normal->h;
}
-void GraphicButton::draw(SDL_Surface* dest, SPoint off)
+void GraphicButton::draw(Image * dest, SPoint off)
{
if (!m_visible) return;
- Rect destrect (off.x + x, off.y + y, 0, 0);
-
if (m_pressed)
{
- assert(m_surfPressed != NULL);
- SDL_BlitSurface(m_surfPressed, NULL, dest, &destrect);
+ m_surfPressed->blitTo(dest, UPoint(off.x + x, off.y + y));
}
else
{
- assert(m_surfNormal != NULL);
- SDL_BlitSurface(m_surfNormal, NULL, dest, &destrect);
+ m_surfNormal->blitTo(dest, UPoint(off.x + x, off.y + y));
};
}
@@ -88,8 +83,7 @@
BoringButton::~BoringButton()
{
- SDL_FreeSurface(m_surfNormal);
- SDL_FreeSurface(m_surfPressed);
+
}
@@ -108,82 +102,68 @@
void BoringButton::redraw()
{
- if (m_surfNormal != NULL) SDL_FreeSurface(m_surfNormal);
- if (m_surfPressed != NULL) SDL_FreeSurface(m_surfPressed);
+ m_surfNormal.reset(new Image(UPoint(w,h)));
+ m_surfPressed.reset(new Image(UPoint(w,h)));
- m_surfNormal = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 8,
- 0, 0, 0, 0);
- assert(m_surfNormal != NULL);
-
- m_surfPressed = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 8,
- 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, 115);
- SDL_FillRect(m_surfPressed, NULL, 116);
+ m_surfNormal->fillRect(115);
+ m_surfPressed->fillRect(116);
/*
* Button normal
*/
// top lines
- drawHLine(m_surfNormal, 0, 0, w-1, 229, false);
- drawHLine(m_surfNormal, 0, 1, w-3, 108, false);
+ m_surfNormal->drawHLine(UPoint(0, 0), w-1, 229, false);
+ m_surfNormal->drawHLine(UPoint(0, 1), w-3, 108, false);
// left lines
- drawVLine(m_surfNormal, 0, 0, h-1, 229, false);
- drawVLine(m_surfNormal, 1, 1, h-2, 108, false);
+ m_surfNormal->drawVLine(UPoint(0, 0), h-1, 229, false);
+ m_surfNormal->drawVLine(UPoint(1, 1), h-2, 108, false);
// bottom lines
- drawHLine(m_surfNormal, 1, h-2, w-2, 226, false);
- drawHLine(m_surfNormal, 0, h-1, w-1, 229, false);
+ m_surfNormal->drawHLine(UPoint(1, h-2), w-2, 226, false);
+ m_surfNormal->drawHLine(UPoint(0, h-1), w-1, 229, false);
// right lines
- drawVLine(m_surfNormal, w-1, 0, h-1, 229, false);
- drawVLine(m_surfNormal, w-2, 1, h-2, 226, false);
+ m_surfNormal->drawVLine(UPoint(w-1, 0), h-1, 229, false);
+ m_surfNormal->drawVLine(UPoint(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);
+ m_surfNormal->putPixel(UPoint(1, h-2), 115);
+ m_surfNormal->putPixel(UPoint(w-2, 1), 115);
+ m_surfNormal->putPixel(UPoint(w-2, h-2), 227);
/*
* Button pressed
*/
// top lines
- drawHLine(m_surfPressed, 0, 0, w-1, 229, false);
- drawHLine(m_surfPressed, 0, 1, w-3, 226, false);
+ m_surfPressed->drawHLine(UPoint(0, 0), w-1, 229, false);
+ m_surfPressed->drawHLine(UPoint(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);
+ m_surfPressed->drawVLine(UPoint(0, 0), h-1, 229, false);
+ m_surfPressed->drawVLine(UPoint(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);
+ m_surfPressed->drawHLine(UPoint(1, h-2), w-2, 226, false);
+ m_surfPressed->drawHLine(UPoint(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);
+ m_surfPressed->drawVLine(UPoint(w-1, 0), h-1, 229, false)...
[truncated message content] |
|
From: <dv...@us...> - 2008-04-17 18:06:12
|
Revision: 141
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=141&view=rev
Author: dvalin
Date: 2008-04-17 11:05:50 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
fix deprecated conversion from string constant to 'char*'
Modified Paths:
--------------
branches/dunks/include/Settings.h
branches/dunks/src/Settings.cpp
Modified: branches/dunks/include/Settings.h
===================================================================
--- branches/dunks/include/Settings.h 2008-04-17 18:04:51 UTC (rev 140)
+++ branches/dunks/include/Settings.h 2008-04-17 18:05:50 UTC (rev 141)
@@ -79,7 +79,7 @@
void load();
void save();
- void ParseFile(char* fn);
+ void ParseFile(const char* fn);
void ParseOptions(int argc, char* argv[]);
inline int GetWidth()
Modified: branches/dunks/src/Settings.cpp
===================================================================
--- branches/dunks/src/Settings.cpp 2008-04-17 18:04:51 UTC (rev 140)
+++ branches/dunks/src/Settings.cpp 2008-04-17 18:05:50 UTC (rev 141)
@@ -64,7 +64,7 @@
ResMan::Instance()->writeText("CONFIG:config.txt", configText);
}
-void Settings::ParseFile(char* fn)
+void Settings::ParseFile(const char* fn)
{
/*
ifstream file(fn);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dv...@us...> - 2008-04-20 22:03:20
|
Revision: 148
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=148&view=rev
Author: dvalin
Date: 2008-04-20 15:03:12 -0700 (Sun, 20 Apr 2008)
Log Message:
-----------
rename to avoid backslash escape annoyance on *NIX
Added Paths:
-----------
branches/dunks/old_include/
branches/dunks/old_src/
Removed Paths:
-------------
branches/dunks/old\include/
branches/dunks/old\src/
Copied: branches/dunks/old_include (from rev 138, branches/dunks/old\include)
Copied: branches/dunks/old_src (from rev 138, branches/dunks/old\src)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dv...@us...> - 2008-04-20 22:04:03
|
Revision: 149
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=149&view=rev
Author: dvalin
Date: 2008-04-20 15:04:00 -0700 (Sun, 20 Apr 2008)
Log Message:
-----------
start on merging sound stuff from richie's branch
Modified Paths:
--------------
branches/dunks/include/DataCache.h
branches/dunks/include/ResMan.h
branches/dunks/src/Application.cpp
branches/dunks/src/DataCache.cpp
branches/dunks/src/SConscript
Modified: branches/dunks/include/DataCache.h
===================================================================
--- branches/dunks/include/DataCache.h 2008-04-20 22:03:12 UTC (rev 148)
+++ branches/dunks/include/DataCache.h 2008-04-20 22:04:00 UTC (rev 149)
@@ -6,6 +6,7 @@
#include "Settings.h"
#include "ResMan.h"
#include "singleton.h"
+#include "SDL_mixer.h"
#include "pakfile/Cpsfile.h"
#include "pakfile/Icnfile.h"
@@ -290,7 +291,7 @@
HouseHarkonnen,
PlaceStructure,
ButtonClick,
- InvalidAction,
+// InvalidAction,
CreditsTick,
RadarNoise,
Sound_ExplosionGas,
@@ -309,8 +310,64 @@
Sound_Scream4,
Sound_Scream5,
Sound_MachineGun,
- Sound_Sonic,
+// Sound_Sonic,
Sound_RocketSmall,
+ Intro_3Houses,
+ Intro_AndNow,
+ Intro_Battle,
+ Intro_Begins,
+ Intro_Blaster,
+ Intro_TheBuilding,
+ Intro_Blowup_1,
+ Intro_Blowup_2,
+ Intro_Brakes_2p,
+ Intro_Clank,
+ Intro_Click,
+ Intro_ControlsDune,
+ Intro_ControlsTheSpice,
+ Intro_ForControl,
+ Intro_Controls,
+ Intro_Dune,
+ Intro_OfADynasty,
+ Intro_ToEachOfTheHouses,
+ Intro_AndNo,
+ Intro_WillControlDune,
+ Intro_TheHouse,
+ Intro_TheMostSpice,
+ Intro_TheEmpire,
+ Intro_ThereAreNoSetTerritories,
+ Intro_ThatProduces,
+ Intro_RulesOfEngagement,
+ Intro_Territories,
+ Intro_AndThe,
+// Intro_Filler,
+ Intro_Flesh,
+ Intro_Glass_6,
+ Intro_Glass,
+ Intro_GunShot,
+ Intro_EvilHarkonnen,
+ Intro_Home,
+ Intro_OnlyOneHouse,
+ Intro_TheInsideous,
+ Intro_TheEmperor,
+ Intro_KnownAsDune,
+ Intro_Worm,
+ Intro_Melange,
+ Intro_Missile_8,
+ Intro_TheNobleAtreides,
+ Intro_Now,
+ Intro_OfDune,
+ Intro_Ordos,
+ Intro_ThePlanetArrakis,
+ Intro_WillPrevail,
+ Intro_HasProposedAChallenge,
+ Intro_LandOfSand,
+ Intro_OfTheSpice,
+ Intro_TheSpice,
+ Intro_VastArmies,
+ Intro_WhoEver,
+ Intro_Wind_2bp,
+ Intro_Your,
NUM_SOUNDCHUNK
} Sound_enum;
@@ -327,13 +384,22 @@
public:
void addObjPic(unsigned ID, SDL_Surface * tmp);
- void addVoice(unsigned ID, std::string vocFile);
+ void addSoundChunk(unsigned ID, Mix_Chunk* tmp);
ImagePtr getObjPic(unsigned ID, unsigned house = HOUSE_HARKONNEN);
+ Mix_Chunk* getSoundChunk(unsigned ID);
private:
bool addObjPic(unsigned ID) { return false;};
remapped_images m_objImg;
remapped_images m_guiImg;
+
+ Mix_Chunk* getChunkFromFile(std::string fileName);
+ Mix_Chunk* concat2Chunks(Mix_Chunk* sound1, Mix_Chunk* sound2);
+ Mix_Chunk* concat3Chunks(Mix_Chunk* sound1, Mix_Chunk* sound2, Mix_Chunk* sound3);
+ Mix_Chunk* createEmptyChunk();
+
+ Mix_Chunk* soundChunk[NUM_SOUNDCHUNK];
+
};
#endif // DUNE_DATACACHE_H
Modified: branches/dunks/include/ResMan.h
===================================================================
--- branches/dunks/include/ResMan.h 2008-04-20 22:03:12 UTC (rev 148)
+++ branches/dunks/include/ResMan.h 2008-04-20 22:04:00 UTC (rev 149)
@@ -1,27 +1,27 @@
-#ifndef DUNE_RESMAN_H
-#define DUNE_RESMAN_H
-
-#include "singleton.h"
-#include "pakfile/Pakfile.h"
-
-#include "boost/filesystem/path.hpp"
-
-#include <map>
-#include <string>
-
-//#include "Log.h"
-
-/*!
- Class to emulate a file object using an unsigned char* buffer
-*/
-class FileLike
-{
- public:
+#ifndef DUNE_RESMAN_H
+#define DUNE_RESMAN_H
+
+#include "singleton.h"
+#include "pakfile/Pakfile.h"
+
+#include "boost/filesystem/path.hpp"
+
+#include <map>
+#include <string>
+
+//#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();
- //@}
+ //@{
+ FileLike(unsigned char* buf, int size);
+ ~FileLike();
+ //@}
//! @name FileLike methods
//@{
@@ -29,182 +29,182 @@
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;
- int m_size;
- int m_pos;
-};
-
-/*!
- Base class for all resources.
-*/
-class Resource
-{
- public:
+ */
+ 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;
+ int m_size;
+ int m_pos;
+};
+
+/*!
+ Base class for all resources.
+*/
+class Resource
+{
+ public:
//! @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(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(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(std::string path, std::string text) {}
-
- /*!
- return true if the resource can be written to
- */
- 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;
+ //@{
+ Resource();
+ virtual ~Resource();
+ //@}
- bool mb_writable;
+ /*!
+ 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(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(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(std::string path, std::string text) {}
-};
-
-/*!
- Directory Resource - all files are read from a directory
-*/
-class DIRResource : public Resource
-{
- public:
- DIRResource(boost::filesystem::path path) ;
- unsigned char* readFile(std::string path, int *size);
- std::string readText(std::string path);
- bool exists(std::string path);
-};
-
-/*!
- Writable directory resource for storing config files
-*/
-class WritableDIRResource : public DIRResource
-{
- public:
- WritableDIRResource(std::string path);
- void writeText(std::string path, std::string text);
-};
-
-/*!
- PAK file resource - all files are read from a PAK file
-*/
-class PAKResource : public Resource
-{
- public:
- PAKResource(boost::filesystem::path path) ;
- ~PAKResource();
- unsigned char* readFile(std::string path, int *size);
- bool exists(std::string path);
- private:
- Pakfile *m_pakfile;
-};
-
-/*!
- Class to simplify reading and writing from different resource files.
-*/
-class ResMan : public Singleton<ResMan>
-{
- friend class Singleton<ResMan>;
-
- typedef std::map<std::string, Resource*> ResList;
-
- protected:
- ResMan();
- ~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);
- //@}
-
+ /*!
+ return true if the resource can be written to
+ */
+ 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;
+
+ bool mb_writable;
+
+};
+
+/*!
+ Directory Resource - all files are read from a directory
+*/
+class DIRResource : public Resource
+{
+ public:
+ DIRResource(boost::filesystem::path path) ;
+ unsigned char* readFile(std::string path, int *size);
+ std::string readText(std::string path);
+ bool exists(std::string path);
+};
+
+/*!
+ Writable directory resource for storing config files
+*/
+class WritableDIRResource : public DIRResource
+{
+ public:
+ WritableDIRResource(std::string path);
+ void writeText(std::string path, std::string text);
+};
+
+/*!
+ PAK file resource - all files are read from a PAK file
+*/
+class PAKResource : public Resource
+{
+ public:
+ PAKResource(boost::filesystem::path path) ;
+ ~PAKResource();
+ unsigned char* readFile(std::string path, int *size);
+ bool exists(std::string path);
+ private:
+ Pakfile *m_pakfile;
+};
+
+/*!
+ Class to simplify reading and writing from different resource files.
+*/
+class ResMan : public Singleton<ResMan>
+{
+ friend class Singleton<ResMan>;
+
+ typedef std::map<std::string, Resource*> ResList;
+
+ protected:
+ ResMan();
+ ~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 path, int *size);
- /*!
- read a file from the resource.
- @param path path to the file to read
- @return FileLike object
- */
- FileLike* readFile(std::string path);
- //@}
-
+ //@{
+ /*!
+ 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 path, int *size);
+ /*!
+ 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 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 path, std::string text);
- //@}
-
- /*!
- return true if the path exists
- */
- bool exists(std::string path);
-
- private:
- ResList m_resources;
-};
-
-#endif // DUNE_RESMAN_H
-
-
-
+ //@{
+ /*!
+ 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 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 path, std::string text);
+ //@}
+
+ /*!
+ return true if the path exists
+ */
+ bool exists(std::string path);
+
+ private:
+ ResList m_resources;
+};
+
+#endif // DUNE_RESMAN_H
+
+
+
Modified: branches/dunks/src/Application.cpp
===================================================================
--- branches/dunks/src/Application.cpp 2008-04-20 22:03:12 UTC (rev 148)
+++ branches/dunks/src/Application.cpp 2008-04-20 22:04:00 UTC (rev 149)
@@ -3,7 +3,7 @@
#include "SDL.h"
//#include "SDL_ttf.h"
//#include "SDL_net.h"
-//#include "SDL_mixer.h"
+#include "SDL_mixer.h"
#include <stdio.h>
#include <stdlib.h>
@@ -17,12 +17,12 @@
//#include "Net.h"
//#include "data.h"
//#include "ui.h"
-//#include "SoundPlayerClass.h"
+#include "SoundPlayerClass.h"
#include "Colours.h"
#include "Settings.h"
#include "Font.h"
#include "TopLevelState.h"
-//#include "DataFile.h"
+#include "DataCache.h"
#include "Gfx.h"
#include "pakfile/Palette.h"
#include "pakfile/Shpfile.h"
@@ -65,7 +65,7 @@
void Application::Init()
{
- /*
+ int lookDist[11];
lookDist[0] = 10;
lookDist[1] = 10;
lookDist[2] = 9;
@@ -82,7 +82,6 @@
InitSettings();
srand(time(NULL));
- */
Uint32 flags = SDL_INIT_AUDIO | \
SDL_INIT_TIMER | \
@@ -100,7 +99,7 @@
// replace NULL with a path to a 32x32 icon
SDL_WM_SetCaption("Dune Legacy", NULL);
- //InitAudio();
+ InitAudio();
//InitNet();
// force font manager to be loaded
@@ -147,7 +146,6 @@
void Application::InitSettings()
{
- /*
settings.concreteRequired = true;
settings.gameType = ORIGINAL;
settings.playerType = SINGLE;
@@ -159,12 +157,11 @@
settings.playerHouse[settings.playerNum] = settings.playerNum;
strcpy(settings.localPlayerName, "Player");
- */
}
void Application::InitAudio()
{
- /*
+
printf("initialising sound.....\n");
if ( Mix_OpenAudio(11025, MIX_DEFAULT_FORMAT, 2, 512) < 0 )
@@ -177,7 +174,6 @@
{
printf("allocated %d channels.\n", Mix_AllocateChannels(16));
};
- */
}
void Application::InitNet()
@@ -277,6 +273,7 @@
ResMan::Instance()->addRes("ATRE");
ResMan::Instance()->addRes("DUNE");
ResMan::Instance()->addRes("ENGLISH");
+ ResMan::Instance()->addRes("GERMAN");
ResMan::Instance()->addRes("FINALE");
ResMan::Instance()->addRes("HARK");
ResMan::Instance()->addRes("HERC");
@@ -303,17 +300,16 @@
m_cursor.reset(new Image(mouse.getPicture(0)));
- /*
+
fprintf(stdout, "starting sound...\n");
- soundPlayer = new SoundPlayerClass();
- */
+ SoundPlayerClass* soundPlayer = new SoundPlayerClass();
}
void Application::Die()
{
FontManager::Destroy();
//TTF_Quit();
- //Mix_CloseAudio();
+ Mix_CloseAudio();
//SDLNet_Quit();
SDL_Quit();
exit(1);
Modified: branches/dunks/src/DataCache.cpp
===================================================================
--- branches/dunks/src/DataCache.cpp 2008-04-20 22:03:12 UTC (rev 148)
+++ branches/dunks/src/DataCache.cpp 2008-04-20 22:04:00 UTC (rev 149)
@@ -1,8 +1,6 @@
#include "DataCache.h"
+#include "pakfile/Vocfile.h"
-
-using namespace std;
-
DataCache::DataCache() {
for (int i=0; i< NUM_HOUSES; i++)
{
@@ -95,11 +93,105 @@
addObjPic(ObjPic_RockDamage, icon->getPictureRow(1,6));
addObjPic(ObjPic_SandDamage, units1->getPictureArray(3,1,5|TILE_NORMAL,6|TILE_NORMAL,7|TILE_NORMAL));
addObjPic(ObjPic_Terrain_Hidden, icon->getPictureRow(108,123));
-}
+ addSoundChunk(YesSir, getChunkFromFile("VOC:ZREPORT1.VOC"));
+ addSoundChunk(Reporting, getChunkFromFile("VOC:ZREPORT2.VOC"));
+ addSoundChunk(Acknowledged, getChunkFromFile("VOC:ZREPORT3.VOC"));
+ addSoundChunk(Affirmative, getChunkFromFile("VOC:ZAFFIRM.VOC"));
+ addSoundChunk(MovingOut, getChunkFromFile("VOC:ZMOVEOUT.VOC"));
+ addSoundChunk(InfantryOut, getChunkFromFile("VOC:ZOVEROUT.VOC"));
+ addSoundChunk(SomethingUnderTheSand, getChunkFromFile("VOC:SANDBUG.VOC"));
+ addSoundChunk(HouseAtreides, getChunkFromFile("GERMAN:GATRE.VOC"));
+ addSoundChunk(HouseOrdos, getChunkFromFile("GERMAN:GORDOS.VOC"));
+ addSoundChunk(HouseHarkonnen, getChunkFromFile("GERMAN:GHARK.VOC"));
+
+ addSoundChunk(PlaceStructure, getChunkFromFile("VOC:EXDUD.VOC"));
+ addSoundChunk(ButtonClick, getChunkFromFile("VOC:BUTTON.VOC"));
+// addSoundChunk(InvalidAction, Mix_LoadWAV_RW(pFileManager->OpenFile("CANNOT.WAV"),1));
+ // probably incorrect?
+ addSoundChunk(CreditsTick, getChunkFromFile("INTROVOC:CLICK.VOC"));
+ addSoundChunk(RadarNoise, getChunkFromFile("VOC:STATICP.VOC"));
+ addSoundChunk(Sound_ExplosionGas, getChunkFromFile("VOC:EXGAS.VOC"));
+ addSoundChunk(Sound_ExplosionTiny, getChunkFromFile("VOC:EXTINY.VOC"));
+ addSoundChunk(Sound_ExplosionSmall, getChunkFromFile("VOC:EXSMALL.VOC"));
+ addSoundChunk(Sound_ExplosionMedium, getChunkFromFile("VOC:EXMED.VOC"));
+ addSoundChunk(Sound_ExplosionLarge, getChunkFromFile("VOC:EXLARGE.VOC"));
+ addSoundChunk(Sound_ExplosionStructure, getChunkFromFile("VOC:CRUMBLE.VOC"));
+ addSoundChunk(Sound_WormAttack, getChunkFromFile("VOC:WORMET3P.VOC"));
+ addSoundChunk(Sound_Gun, getChunkFromFile("VOC:GUN.VOC"));
+ addSoundChunk(Sound_Rocket, getChunkFromFile("VOC:ROCKET.VOC"));
+ addSoundChunk(Sound_Bloom, getChunkFromFile("VOC:EXSAND.VOC"));
+ addSoundChunk(Sound_Scream1, getChunkFromFile("VOC:VSCREAM1.VOC"));
+ addSoundChunk(Sound_Scream2, getChunkFromFile("VOC:VSCREAM1.VOC"));
+ addSoundChunk(Sound_Scream3, getChunkFromFile("VOC:VSCREAM1.VOC"));
+ addSoundChunk(Sound_Scream4, getChunkFromFile("VOC:VSCREAM1.VOC"));
+ addSoundChunk(Sound_Scream5, getChunkFromFile("VOC:VSCREAM1.VOC"));
+ addSoundChunk(Sound_MachineGun, getChunkFromFile("VOC:GUNMULTI.VOC"));
+// addSoundChunk(Sound_Sonic, Mix_LoadWAV_RW(pFileManager->OpenFile("SONIC.WAV"),1);
+ addSoundChunk(Sound_RocketSmall, getChunkFromFile("VOC:MISLTINP.VOC"));
+
+ addSoundChunk(Intro_3Houses, getChunkFromFile("INTROVOC:3HOUSES.VOC"));
+ addSoundChunk(Intro_AndNow, getChunkFromFile("INTROVOC:ANDNOW.VOC"));
+ addSoundChunk(Intro_Battle, getChunkFromFile("INTROVOC:ARRIVED.VOC"));
+ addSoundChunk(Intro_Begins, getChunkFromFile("INTROVOC:BEGINS.VOC"));
+ addSoundChunk(Intro_Blaster, getChunkFromFile("INTROVOC:BLASTER.VOC"));
+ addSoundChunk(Intro_TheBuilding, getChunkFromFile("INTROVOC:BLDING.VOC"));
+ addSoundChunk(Intro_Blowup_1, getChunkFromFile("INTROVOC:BLOWUP1.VOC"));
+ addSoundChunk(Intro_Blowup_2, getChunkFromFile("INTROVOC:BLOWUP2.VOC"));
+ addSoundChunk(Intro_Brakes_2p, getChunkFromFile("INTROVOC:BRAKES2P.VOC"));
+ addSoundChunk(Intro_Clank, getChunkFromFile("INTROVOC:CLANK.VOC"));
+ addSoundChunk(Intro_Click, getChunkFromFile("INTROVOC:CLICK.VOC"));
+ addSoundChunk(Intro_ControlsDune, getChunkFromFile("INTROVOC:CONTROL2.VOC"));
+ addSoundChunk(Intro_ControlsTheSpice, getChunkFromFile("INTROVOC:CONTROL3.VOC"));
+ addSoundChunk(Intro_ForControl, getChunkFromFile("INTROVOC:CONTROL4.VOC"));
+ addSoundChunk(Intro_Controls, getChunkFromFile("INTROVOC:CONTROLS.VOC"));
+ addSoundChunk(Intro_Dune, getChunkFromFile("INTROVOC:DUNE.VOC"));
+ addSoundChunk(Intro_OfADynasty, getChunkFromFile("INTROVOC:DYNASTY.VOC"));
+ addSoundChunk(Intro_ToEachOfTheHouses, getChunkFromFile("INTROVOC:EACHHOME.VOC"));
+ addSoundChunk(Intro_AndNo, getChunkFromFile("INTROVOC:EANDNO.VOC"));
+ addSoundChunk(Intro_WillControlDune, getChunkFromFile("INTROVOC:ECONTROL.VOC"));
+ addSoundChunk(Intro_TheHouse, getChunkFromFile("INTROVOC:EHOUSE.VOC"));
+ addSoundChunk(Intro_TheMostSpice, getChunkFromFile("INTROVOC:EMOST.VOC"));
+ addSoundChunk(Intro_TheEmpire, getChunkFromFile("INTROVOC:EMPIRE.VOC"));
+ addSoundChunk(Intro_ThereAreNoSetTerritories, getChunkFromFile("INTROVOC:ENOSET.VOC"));
+ addSoundChunk(Intro_ThatProduces, getChunkFromFile("INTROVOC:EPRODUCE.VOC"));
+ addSoundChunk(Intro_RulesOfEngagement, getChunkFromFile("INTROVOC:ERULES.VOC"));
+ addSoundChunk(Intro_Territories, getChunkFromFile("INTROVOC:ETERRIT.VOC"));
+ addSoundChunk(Intro_AndThe, getChunkFromFile("INTROVOC:EVIL.VOC"));
+// addSoundChunk(Intro_Filler, getChunkFromFile("INTROVOC:FILLER.VOC"));
+ addSoundChunk(Intro_Flesh, getChunkFromFile("INTROVOC:FLESH.VOC"));
+ addSoundChunk(Intro_Glass_6, getChunkFromFile("INTROVOC:GLASS6.VOC"));
+ addSoundChunk(Intro_Glass, getChunkFromFile("INTROVOC:GLASS.VOC"));
+ addSoundChunk(Intro_GunShot, getChunkFromFile("INTROVOC:GUNSHOT.VOC"));
+ addSoundChunk(Intro_EvilHarkonnen, getChunkFromFile("INTROVOC:HARK.VOC"));
+ addSoundChunk(Intro_Home, getChunkFromFile("INTROVOC:HOME.VOC"));
+ addSoundChunk(Intro_OnlyOneHouse, getChunkFromFile("INTROVOC:HOUSE2.VOC"));
+ addSoundChunk(Intro_TheInsideous, getChunkFromFile("INTROVOC:INSID.VOC"));
+ addSoundChunk(Intro_TheEmperor, getChunkFromFile("INTROVOC:KING.VOC"));
+ addSoundChunk(Intro_KnownAsDune, getChunkFromFile("INTROVOC:KNOWN.VOC"));
+ addSoundChunk(Intro_Worm, getChunkFromFile("INTROVOC:LIZARD1.VOC"));
+ addSoundChunk(Intro_Melange, getChunkFromFile("INTROVOC:MELANGE.VOC"));
+ addSoundChunk(Intro_Missile_8, getChunkFromFile("INTROVOC:MISSLE8.VOC"));
+ addSoundChunk(Intro_TheNobleAtreides, getChunkFromFile("INTROVOC:NOBLE.VOC"));
+ addSoundChunk(Intro_Now, getChunkFromFile("INTROVOC:NOW.VOC"));
+ addSoundChunk(Intro_OfDune, getChunkFromFile("INTROVOC:OFDUNE.VOC"));
+ addSoundChunk(Intro_Ordos, getChunkFromFile("INTROVOC:ORD.VOC"));
+ addSoundChunk(Intro_ThePlanetArrakis, getChunkFromFile("INTROVOC:PLANET.VOC"));
+ addSoundChunk(Intro_WillPrevail, getChunkFromFile("INTROVOC:PREVAIL.VOC"));
+ addSoundChunk(Intro_HasProposedAChallenge, getChunkFromFile("INTROVOC:PROPOSED.VOC"));
+ addSoundChunk(Intro_LandOfSand, getChunkFromFile("INTROVOC:SANDLAND.VOC"));
+ addSoundChunk(Intro_OfTheSpice, getChunkFromFile("INTROVOC:SPICE.VOC"));
+ addSoundChunk(Intro_TheSpice, getChunkFromFile("INTROVOC:SPICE2.VOC"));
+ addSoundChunk(Intro_VastArmies, getChunkFromFile("INTROVOC:VAST.VOC"));
+ addSoundChunk(Intro_WhoEver, getChunkFromFile("INTROVOC:WHOEVER.VOC"));
+ addSoundChunk(Intro_Wind_2bp, getChunkFromFile("INTROVOC:WIND2BP.VOC"));
+ addSoundChunk(Intro_Your, getChunkFromFile("INTROVOC:YOUR.VOC"));
+
+};
+
void DataCache::addObjPic(unsigned ID, SDL_Surface * tmp) {
- m_objImg[HOUSE_HARKONNEN]->insert(pair<unsigned, ImagePtr>(ID,
+ m_objImg[HOUSE_HARKONNEN]->insert(std::pair<unsigned, ImagePtr>(ID,
ImagePtr(new Image(tmp))));
}
@@ -114,15 +206,39 @@
{
ImagePtr source = m_objImg[HOUSE_HARKONNEN]->find(ID)->second;
ImagePtr copy = source->getRecoloredByHouse(house);
- m_objImg[HOUSE_HARKONNEN]->insert(pair<unsigned, ImagePtr>(ID, copy));
+ m_objImg[HOUSE_HARKONNEN]->insert(std::pair<unsigned, ImagePtr>(ID, copy));
return copy;
}
}
-/*void DataCache::addVoice(unsigned ID, std::string){
+void DataCache::addSoundChunk(unsigned ID, Mix_Chunk* tmp){
+ soundChunk[ID] = tmp;
+}
+
+Mix_Chunk* DataCache::getSoundChunk(unsigned ID){
+ return soundChunk[ID];
+}
+Mix_Chunk* DataCache::getChunkFromFile(std::string fileName) {
+ Mix_Chunk* returnChunk;
+ SDL_RWops* rwop;
+ unsigned char * data;
+
+ int len;
+ data = ResMan::Instance()->readFile(fileName.c_str(), &len);
+ if((rwop = SDL_RWFromMem(data, len)) ==NULL) {
+ fprintf(stderr,"DataManager::getChunkFromFile(): Cannot open %s!\n",fileName.c_str());
+ exit(EXIT_FAILURE);
+ }
-}*/
+ if((returnChunk = LoadVOC_RW(rwop, 0)) == NULL) {
+ fprintf(stderr,"DataManager::getChunkFromFile(): Cannot load %s!\n",fileName.c_str());
+ exit(EXIT_FAILURE);
+ }
+
+ SDL_RWclose(rwop);
+ return returnChunk;
+}
DataCache::~DataCache() {
Modified: branches/dunks/src/SConscript
===================================================================
--- branches/dunks/src/SConscript 2008-04-20 22:03:12 UTC (rev 148)
+++ branches/dunks/src/SConscript 2008-04-20 22:04:00 UTC (rev 149)
@@ -17,7 +17,7 @@
"Settings.cpp",
"Font.cpp",
"State.cpp",
-# "DataFile.cpp",
+ "DataCache.cpp",
# "PictureFactory.cpp",
"TopLevelState.cpp",
"MenuBase.cpp",
@@ -32,6 +32,12 @@
"ConfigFile.cpp",
"ResMan.cpp",
+ "SoundPlayerClass.cpp",
+ "pakfile/Vocfile.cpp",
+ "pakfile/IntegratedLibSampleRate/samplerate.c",
+ "pakfile/IntegratedLibSampleRate/src_linear.c",
+ "pakfile/IntegratedLibSampleRate/src_sinc.c",
+ "pakfile/IntegratedLibSampleRate/src_zoh.c"
]
gui_sources = [
@@ -64,6 +70,12 @@
"Strings.cpp",
"State.cpp",
"TopLevelState.cpp",
+ "SoundPlayerClass.cpp",
+ "pakfile/Vocfile.cpp",
+ "pakfile/IntegratedLibSampleRate/samplerate.c",
+ "pakfile/IntegratedLibSampleRate/src_linear.c",
+ "pakfile/IntegratedLibSampleRate/src_sinc.c",
+ "pakfile/IntegratedLibSampleRate/src_zoh.c"
]
#gamelib = env.StaticLibrary("dune_game", all_sources)
@@ -74,5 +86,5 @@
pakview = env.Program("../test", ["pakview.cpp"] + pakview_sources + gui_sources + pak_sources )
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: <dv...@us...> - 2008-04-20 22:08:22
|
Revision: 150
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=150&view=rev
Author: dvalin
Date: 2008-04-20 15:08:19 -0700 (Sun, 20 Apr 2008)
Log Message:
-----------
merge soundplayer from richie's branch
Added Paths:
-----------
branches/dunks/include/SoundPlayerClass.h
branches/dunks/src/SoundPlayerClass.cpp
Added: branches/dunks/include/SoundPlayerClass.h
===================================================================
--- branches/dunks/include/SoundPlayerClass.h (rev 0)
+++ branches/dunks/include/SoundPlayerClass.h 2008-04-20 22:08:19 UTC (rev 150)
@@ -0,0 +1,116 @@
+#ifndef SOUNDPLAYERCLASS_H_INCLUDED
+#define SOUNDPLAYERCLASS_H_INCLUDED
+
+#include <string>
+#include <vector>
+#include "ResMan.h"
+#include "dMath.h"
+#include "SDL_mixer.h"
+using namespace std;
+
+//! \enum MUSICTYPE
+/*! Types of music available in the game*/
+typedef enum { MUSIC_ATTACK, /*!<Played when at least one of player's units was hit. */
+ MUSIC_INTRO, /*!<Background music for intro. */
+ MUSIC_LOSE, /*!<Failure screen background music. */
+ MUSIC_PEACE, /*!<Played most of the time when the enemy is not attacking. */
+ MUSIC_WIN, /*!<Victory screen background music.. */
+ MUSIC_RANDOM /*!<Player used key combination to change current music. */
+ } MUSICTYPE;
+
+/*!
+ Class that handles sounds and music.
+*/
+class SoundPlayerClass
+{
+public:
+ //! @name Constructor & Destructor
+ //@{
+ SoundPlayerClass(/*SETTINGSTYPE* settings*/);
+ ~SoundPlayerClass();
+ //@}
+
+ /*!
+ change type of current music
+ @param musicType type of music to be played
+ */
+ void changeMusic(MUSICTYPE musicType);
+
+ /*!
+ sets current music to MUSIC_PEACE if there's no
+ other song being played
+ */
+ void musicCheck();
+
+ /*!
+ plays a certain sound at certain coordinates.
+ the volume of sound depends on the difference between
+ location of the sound and location of the view window
+ (the thing you see units in)
+ @param soundID id of the sound to be played
+ @param location coordinates where the sound is to be played
+ */
+ void playSoundAt(int soundID, COORDTYPE* location);
+
+ /*!
+ turns music playing on or off
+ @param value when true the function turns music on
+ */
+ void setMusic(bool value);
+ void toggleSound();
+
+ void playVoice(int id, int house);
+ void playSound(int soundID);
+
+ inline int GetSfxVolume() { return sfxVolume; };
+ void SetSfxVolume(int newVolume) {
+ if(newVolume >= 0 && newVolume <= MIX_MAX_VOLUME) {
+ sfxVolume = newVolume;
+ }
+ }
+
+ inline int GetMusicVolume() { return Mix_VolumeMusic(-1); };
+ void SetMusicVolume(int newVolume) {
+ if(newVolume >= 0 && newVolume <= MIX_MAX_VOLUME) {
+ musicVolume = newVolume;
+ Mix_VolumeMusic(newVolume);
+ }
+ }
+
+private:
+ /*!
+ the function plays a sound with a given volume
+ @param soundID id of a sound to be played
+ @param volume sound will be played with this volume
+ */
+ void playSound(int soundID, int volume);
+ vector<string> getMusicFileNames(string dir);
+
+ vector<string> AttackMusic;
+ vector<string> IntroMusic;
+ vector<string> LoseMusic;
+ vector<string> PeaceMusic;
+ vector<string> WinMusic;
+
+ //! whether sound should be played
+ bool soundOn;
+ //! whether music should be played
+ bool musicOn;
+
+ //! volume of unit responses played when a unit is selected
+ int responseVolume;
+ //! volume of sound effects
+ int sfxVolume;
+ //! music volume
+ int musicVolume;
+ //! id of currently played music
+ int thisMusicID;
+ //! volume of voice over sounds
+ int voiceVolume;
+
+ MUSICTYPE currentMusicType;
+ int currentMusicNum;
+
+ Mix_Music* music;
+};
+#endif //SOUNDPLAYERCLASS_H_INCLUDED
Property changes on: branches/dunks/include/SoundPlayerClass.h
___________________________________________________________________
Name: svn:eol-style
+ native
Added: branches/dunks/src/SoundPlayerClass.cpp
===================================================================
--- branches/dunks/src/SoundPlayerClass.cpp (rev 0)
+++ branches/dunks/src/SoundPlayerClass.cpp 2008-04-20 22:08:19 UTC (rev 150)
@@ -0,0 +1,334 @@
+#include <stdlib.h>
+#include <math.h>
+
+#include "pakfile/Vocfile.h"
+#include "SoundPlayerClass.h"
+#include "SDL_mixer.h"
+#include "DuneConstants.h"
+#include "mmath.h"
+#include "gui/Graphics.h"
+#include "DataCache.h"
+
+#include <algorithm>
+
+
+Mix_Chunk* curVoiceChunk = NULL;
+int voiceChannel = 0;
+bool PlayingVoiceATM = false;
+
+void VoiceChunkFinishedCallback(int channel) {
+ if(channel == voiceChannel) {
+ PlayingVoiceATM = false;
+ }
+}
+
+SoundPlayerClass::SoundPlayerClass() {
+
+/* AttackMusic = getMusicFileNames("./data/" + settings.Audio.MusicDirectory + "/attack/");
+ IntroMusic = getMusicFileNames("./data/" + settings.Audio.MusicDirectory + "/intro/");
+ LoseMusic = getMusicFileNames("./data/" + settings.Audio.MusicDirectory + "/lose/");
+ PeaceMusic = getMusicFileNames("./data/" + settings.Audio.MusicDirectory + "/peace/");
+ WinMusic = getMusicFileNames("./data/" + settings.Audio.MusicDirectory + "/win/");
+*/
+ sfxVolume = MIX_MAX_VOLUME/2;
+
+ musicVolume = MIX_MAX_VOLUME/2;
+ responseVolume = 100;
+ voiceVolume = 128;
+
+ Mix_Volume(-1, MIX_MAX_VOLUME);
+ Mix_VolumeMusic(musicVolume);
+
+ music = NULL;
+ thisMusicID = NONE;
+ currentMusicType = MUSIC_RANDOM;
+ currentMusicNum = 0;
+
+ // init global variables
+ curVoiceChunk = NULL;
+ PlayingVoiceATM = false;
+
+ voiceChannel = Mix_ReserveChannels(1); //Reserve a channel for voice over
+ Mix_ChannelFinished(VoiceChunkFinishedCallback);
+
+ soundOn = true;
+ //soundOn = false;
+// musicOn = true;
+ musicOn = false;
+// changeMusic(MUSIC_INTRO);
+}
+SoundPlayerClass::~SoundPlayerClass() {
+ if(music != NULL) {
+ Mix_FreeMusic(music);
+ music = NULL;
+ }
+}
+
+#if 0
+void SoundPlayerClass::changeMusic(MUSICTYPE musicType)
+{
+ int musicNum = -1;
+ string filename = "";
+
+ if(currentMusicType == musicType) {
+ return;
+ }
+
+ switch(musicType)
+ {
+ case MUSIC_ATTACK:
+ if (currentMusicType != MUSIC_ATTACK)
+ {
+ if(AttackMusic.size() > 0) {
+ musicNum = getRandomInt(0, AttackMusic.size()-1);
+ filename = AttackMusic[musicNum];
+ }
+ }
+ break;
+ case MUSIC_INTRO:
+ if (currentMusicType != MUSIC_INTRO)
+ {
+ if(IntroMusic.size() > 0) {
+ musicNum = getRandomInt(0, IntroMusic.size()-1);
+ filename = IntroMusic[musicNum];
+ }
+ }
+ break;
+ case MUSIC_LOSE:
+ if (currentMusicType != MUSIC_LOSE)
+ {
+ if(LoseMusic.size() > 0) {
+ musicNum = getRandomInt(0, LoseMusic.size()-1);
+ filename = LoseMusic[musicNum];
+ }
+ }
+ break;
+ case MUSIC_PEACE:
+ if (currentMusicType != MUSIC_PEACE)
+ {
+ if(PeaceMusic.size() > 0) {
+ musicNum = getRandomInt(0, PeaceMusic.size()-1);
+ filename = PeaceMusic[musicNum];
+ }
+ }
+ break;
+ case MUSIC_WIN:
+ if (currentMusicType != MUSIC_WIN)
+ {
+ if(WinMusic.size() > 0) {
+ musicNum = getRandomInt(0, WinMusic.size()-1);
+ filename = WinMusic[musicNum];
+ }
+ }
+ break;
+ case MUSIC_RANDOM:
+ default:
+ int maxnum = AttackMusic.size() + IntroMusic.size() + LoseMusic.size() + PeaceMusic.size() + WinMusic.size();
+
+ if(maxnum > 0) {
+ unsigned int randnum = getRandomInt(0, maxnum-1);
+
+ if(randnum < AttackMusic.size()) {
+ musicNum = randnum;
+ filename = AttackMusic[musicNum];
+ } else if(randnum < IntroMusic.size()) {
+ musicNum = randnum - AttackMusic.size();
+ filename = IntroMusic[musicNum];
+ } else if(randnum < LoseMusic.size()) {
+ musicNum = randnum - AttackMusic.size() - IntroMusic.size();
+ filename = LoseMusic[musicNum];
+ } else if(randnum < PeaceMusic.size()) {
+ musicNum = randnum - AttackMusic.size() - IntroMusic.size() - LoseMusic.size();
+ filename = PeaceMusic[musicNum];
+ } else {
+ musicNum = randnum - AttackMusic.size() - IntroMusic.size() - LoseMusic.size() - PeaceMusic.size();
+ filename = WinMusic[musicNum];
+ }
+ }
+ break;
+ }
+ currentMusicType = musicType;
+
+ if((musicOn == true) && (filename != "")) {
+
+ Mix_HaltMusic();
+
+ if(music != NULL) {
+ Mix_FreeMusic(music);
+ music = NULL;
+ }
+
+ music = Mix_LoadMUS(filename.c_str());
+ if(music != NULL) {
+ printf("Now playing %s!\n",filename.c_str());
+ Mix_PlayMusic(music, -1);
+ } else {
+ printf("Unable to play %s!\n",filename.c_str());
+ }
+
+ /*
+ Mix_Chunk *sample;
+ sample=Mix_LoadWAV(filename.c_str());
+ Mix_PlayChannel(-1, sample, 0);*/
+ }
+}
+/*void SoundPlayerClass::musicCheck()
+{
+ if (musicOn)
+ {
+ if ( ! Mix_PlayingMusic() )
+ changeMusic(MUSIC_PEACE);
+ }
+}*/
+#endif
+#if 0
+void SoundPlayerClass::playSoundAt(int soundID, COORDTYPE* location)
+{
+ if (soundOn)
+ {
+ int volume = sfxVolume,
+ panning = 128,
+ xOffset = 0,
+ yOffset = 0;
+
+ if (location->x > dborder->maxX/BLOCKSIZE)
+ {
+ xOffset = location->x - dborder->maxX/BLOCKSIZE;
+ panning += xOffset;
+ }
+ else if (location->x < dborder->minX/BLOCKSIZE)
+ {
+ xOffset = dborder->minX/BLOCKSIZE - location->x;
+ panning -= xOffset;
+ }
+
+ if (location->y > dborder->maxY/BLOCKSIZE)
+ yOffset = location->y - dborder->maxY/BLOCKSIZE;
+ else if (location->y < dborder->minY/BLOCKSIZE)
+ yOffset = dborder->minY/BLOCKSIZE - location->y;
+
+ volume -= (int)(10*(sqrt((double)(xOffset*xOffset + yOffset*yOffset))));
+ if (volume < 15) volume = 15;
+
+ playSound(soundID, volume);
+ }
+}
+#endif
+#if 0
+void SoundPlayerClass::setMusic(bool value)
+{
+ musicOn = value;
+
+ if (musicOn)
+ changeMusic(MUSIC_RANDOM);
+ else if (music != NULL)
+ Mix_HaltMusic();
+}
+#endif
+
+void SoundPlayerClass::toggleSound()
+{
+ if (!soundOn && !musicOn)
+ {
+ soundOn = true;
+// currentGame->AddToNewsTicker("sound on, music off");
+ }
+ else if (soundOn && !musicOn)
+ {
+ musicOn = true;
+ soundOn = false;
+// currentGame->AddToNewsTicker("sound off, music on");
+ currentMusicType = MUSIC_RANDOM;
+// changeMusic(MUSIC_PEACE);
+ }
+ else if (!soundOn && musicOn)
+ {
+ soundOn = true;
+// currentGame->AddToNewsTicker("sound on, music on");
+ }
+ else if (soundOn && musicOn)
+ {
+ soundOn = false;
+ musicOn = false;
+// currentGame->AddToNewsTicker("sound off, music off");
+
+ if (music != NULL)
+ Mix_HaltMusic();
+ }
+}
+
+void SoundPlayerClass::playSound(int soundID, int volume)
+{
+ if (soundOn)
+ {
+ Mix_Chunk* tmp;
+
+ if((tmp = DataCache::Instance()->getSoundChunk(soundID)) == NULL) {
+ return;
+ }
+
+ int channel = Mix_PlayChannel(-1,tmp, 0);
+ if (channel != -1)
+ Mix_Volume(channel, (volume*sfxVolume)/MIX_MAX_VOLUME);
+ }
+}
+
+#if 0
+void SoundPlayerClass::playVoice(int id, int house) {
+ if (soundOn)
+ {
+ Mix_Chunk* tmp;
+
+ if((tmp = pDataManager->GetVoice(id,house)) == NULL) {
+ fprintf(stderr,"There is no voice with id %d!\n",id);
+ exit(EXIT_FAILURE);
+ }
+
+ int channel = Mix_PlayChannel(-1, tmp, 0);
+ Mix_Volume(channel,sfxVolume);
+ }
+}
+#endif
+
+void SoundPlayerClass::playSound(int soundID) {
+ if (soundOn)
+ {
+ Mix_Chunk* tmp;
+
+ if((tmp = DataCache::Instance()->getSoundChunk(soundID)) == NULL) {
+ fprintf(stderr,"There is no sound with id %d!\n",soundID);
+ exit(EXIT_FAILURE);
+ }
+
+ Mix_PlayChannel(-1, tmp, 0);
+ }
+}
+#if 0
+vector<string> SoundPlayerClass::getMusicFileNames(string dir) {
+ vector<string> Files;
+ std::list<std::string> tmp;
+ std::list<std::string>::const_iterator iter;
+
+ tmp = GetFileNames(dir,"mp3",true);
+ for(iter = tmp.begin(); iter != tmp.end(); iter++) {
+ Files.push_back(dir + *iter);
+ }
+
+ tmp = GetFileNames(dir,"ogg",true);
+ for(iter = tmp.begin(); iter != tmp.end(); iter++) {
+ Files.push_back(dir + *iter);
+ }
+
+ tmp = GetFileNames(dir,"wav",true);
+ for(iter = tmp.begin(); iter != tmp.end(); iter++) {
+ Files.push_back(dir + *iter);
+ }
+
+ tmp = GetFileNames(dir,"mid",true);
+ for(iter = tmp.begin(); iter != tmp.end(); iter++) {
+ Files.push_back(dir + *iter);
+ }
+
+ return Files;
+}
+#endif
Property changes on: branches/dunks/src/SoundPlayerClass.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dv...@us...> - 2008-04-24 22:22:35
|
Revision: 156
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=156&view=rev
Author: dvalin
Date: 2008-04-24 15:22:22 -0700 (Thu, 24 Apr 2008)
Log Message:
-----------
merge string reading code from richie's branch
Modified Paths:
--------------
branches/dunks/src/SConscript
Added Paths:
-----------
branches/dunks/include/pakfile/StringFile.h
branches/dunks/src/pakfile/StringFile.cpp
Added: branches/dunks/include/pakfile/StringFile.h
===================================================================
--- branches/dunks/include/pakfile/StringFile.h (rev 0)
+++ branches/dunks/include/pakfile/StringFile.h 2008-04-24 22:22:22 UTC (rev 156)
@@ -0,0 +1,50 @@
+#ifndef STRINGFILE_H_INCLUDED
+#define STRINGFILE_H_INCLUDED
+
+#include <string>
+
+
+#define MISSION_DESCRIPTION 0
+#define MISSION_WIN 1
+#define MISSION_LOSE 2
+#define MISSION_ADVICE 3
+
+
+/// A class for loading a encoded textfiles.
+/**
+ This class can read encoded textfiles and return their content in decoded ANSI Code.
+*/
+class StringFile
+{
+public:
+ StringFile(unsigned char * bufFiledata, int bufsize);
+ ~StringFile();
+
+ /// This method returns the briefing/debriefing text.
+ /**
+ This method returns the briefing/debriefing text for the mission specified by the parameter mission. The second
+ parameter specifies the kind of briefing/debriefing.
+ \param mission the mission number (0=House description; 1,2,...,9 = mission description).
+ \param texttype one of MISSION_DESCRIPTION, MISSION_WIN, MISSION_LOSE, MISSION_ADVICE
+ \return the text for this mission and of this type.
+ */
+ std::string getString(unsigned int mission, unsigned int texttype) {
+ int index = mission*4+texttype;
+
+ if(index < numStrings) {
+ return stringArray[index];
+ } else {
+ return "StringFile::getString(): mission number or text type is invalid!\n";
+ }
+ }
+ std::string getString(int i){
+ return stringArray[i];
+ }
+
+private:
+ std::string decodeString(std::string text);
+ std::string *stringArray;
+ int numStrings;
+};
+
+#endif // STRINGFILE_H_INCLUDED
Property changes on: branches/dunks/include/pakfile/StringFile.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/dunks/src/SConscript
===================================================================
--- branches/dunks/src/SConscript 2008-04-24 18:52:12 UTC (rev 155)
+++ branches/dunks/src/SConscript 2008-04-24 22:22:22 UTC (rev 156)
@@ -30,9 +30,9 @@
"Strings.cpp",
"Log.cpp",
"ConfigFile.cpp",
-
"ResMan.cpp",
"SoundPlayerClass.cpp",
+ "pakfile/StringFile.cpp",
"pakfile/Vocfile.cpp",
"pakfile/IntegratedLibSampleRate/samplerate.c",
"pakfile/IntegratedLibSampleRate/src_linear.c",
@@ -86,5 +86,5 @@
pakview = env.Program("../test", ["pakview.cpp"] + pakview_sources + gui_sources + pak_sources )
Default(dunelegacy)
-Default(pakview)
+#Default(pakview)
Added: branches/dunks/src/pakfile/StringFile.cpp
===================================================================
--- branches/dunks/src/pakfile/StringFile.cpp (rev 0)
+++ branches/dunks/src/pakfile/StringFile.cpp 2008-04-24 22:22:22 UTC (rev 156)
@@ -0,0 +1,258 @@
+#include "pakfile/StringFile.h"
+#include <SDL_endian.h>
+#include <SDL.h>
+#include <SDL_rwops.h>
+#include <iostream>
+#include <string>
+
+StringFile::StringFile(unsigned char * bufFiledata, int bufsize){
+ Uint16* index;
+ SDL_RWops* RWop = SDL_RWFromMem(bufFiledata, bufsize);
+
+ if(RWop == NULL) {
+ fprintf(stderr, "StringFile: RWop == NULL!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if(bufsize <= 0) {
+ fprintf(stderr,"StringFile: Cannot determine size!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if(bufsize < 2) {
+ fprintf(stderr, "StringFile: Invalid string file: File too small!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if(SDL_RWseek(RWop,0,SEEK_SET) != 0) {
+ fprintf(stderr,"StringFile: Seeking string file failed!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if( (bufFiledata = (unsigned char*) malloc(bufsize)) == NULL) {
+ fprintf(stderr,"StringFile: Allocating memory failed!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if(SDL_RWread(RWop, bufFiledata, bufsize, 1) != 1) {
+ fprintf(stderr,"StringFile: Reading string file failed!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ numStrings = ((int)SDL_SwapLE16(((Uint16*) bufFiledata)[0]))/2 - 1;
+ index = (Uint16*) bufFiledata;
+ for(int i=0; i <= numStrings; i++) {
+ index[i] = SDL_SwapLE16(index[i]);
+ }
+
+ stringArray = new std::string[numStrings];
+
+ for(int i=0; i < numStrings;i++) {
+ std::string tmp = (const char*) (bufFiledata+index[i]);
+ stringArray[i] = decodeString(tmp);
+ }
+
+ free(bufFiledata);
+ SDL_RWclose(RWop);
+}
+
+StringFile::~StringFile() {
+ delete [] stringArray;
+}
+
+/// This methode decodes a string to ANSI Code
+/**
+ The parameter text is decoded to ANSI Code and returned
+ \param text Text to decode
+ \return The decoded text
+*/
+std::string StringFile::decodeString(std::string text) {
+ std::string out = "";
+ unsigned char databyte;
+
+ for(unsigned int i = 0; i < text.length(); i++) {
+ databyte = text[i];
+
+ switch(databyte) {
+ case 0x00: break;
+ case 0x0C: out += "\n"; break;
+ case 0x0D: out += "\n"; break;
+
+ case 0x80: out += " t"; break;
+ case 0x81: out += " a"; break;
+ case 0x82: out += " s"; break;
+ case 0x83: out += " i"; break;
+ case 0x84: out += " o"; break;
+ case 0x85: out += " "; break; // maybe something else
+ case 0x86: out += " w"; break;
+ case 0x87: out += " b"; break;
+ case 0x88: out += "e "; break;
+ case 0x89: out += "er"; break;
+ case 0x8A: out += "en"; break;
+ case 0x8B: out += "es"; break;
+ case 0x8C: out += "ed"; break;
+ case 0x8D: out += "ea"; break;
+ case 0x8E: out += "el"; break;
+ case 0x8F: out += "em"; break;
+
+ case 0x90: out += "th"; break;
+ case 0x91: out += "t "; break;
+ case 0x92: out += "ti"; break;
+ case 0x93: out += "te"; break;
+ case 0x94: out += "to"; break;
+ case 0x95: out += "tr"; break;
+ case 0x96: out += "ta"; break;
+ case 0x97: out += "ts"; break;
+ case 0x98: out += "an"; break;
+ case 0x99: out += "ar"; break;
+ case 0x9A: out += "at"; break;
+ case 0x9B: out += "al"; break;
+ case 0x9C: out += "ac"; break;
+ case 0x9D: out += "a "; break;
+ case 0x9E: out += "as"; break;
+ case 0x9F: out += "ay"; break;
+
+ case 0xA0: out += "in"; break;
+ case 0xA1: out += "is"; break;
+ case 0xA2: out += "it"; break;
+ case 0xA3: out += "ic"; break;
+ case 0xA4: out += "il"; break;
+ case 0xA5: out += "io"; break;
+ case 0xA6: out += "ie"; break;
+ case 0xA7: out += "ir"; break;
+ case 0xA8: out += "n "; break;
+ case 0xA9: out += "nd"; break;
+ case 0xAA: out += "nt"; break;
+ case 0xAB: out += "ng"; break;
+ case 0xAC: out += "ne"; break;
+ case 0xAD: out += "ns"; break;
+ case 0xAE: out += "ni"; break;
+ case 0xAF: out += "no"; break;
+
+ case 0xB0: out += "on"; break;
+ case 0xB1: out += "or"; break;
+ case 0xB2: out += "o "; break;
+ case 0xB3: out += "ou"; break;
+ case 0xB4: out += "of"; break;
+ case 0xB5: out += "om"; break;
+ case 0xB6: out += "os"; break;
+ case 0xB7: out += "ow"; break;
+ case 0xB8: out += "s "; break;
+ case 0xB9: out += "st"; break;
+ case 0xBA: out += "se"; break;
+ case 0xBB: out += "sp"; break;
+ case 0xBC: out += "s."; break;
+ case 0xBD: out += "si"; break;
+ case 0xBE: out += "sc"; break;
+ case 0xBF: out += "sa"; break;
+
+ case 0xC0: out += "re"; break;
+ case 0xC1: out += "r "; break;
+ case 0xC2: out += "ro"; break;
+ case 0xC3: out += "ri"; break;
+ case 0xC4: out += "ra"; break;
+ case 0xC5: out += "rd"; break;
+ case 0xC6: out += "ru"; break;
+ case 0xC7: out += "rr"; break;
+ case 0xC8: out += "l "; break;
+ case 0xC9: out += "ll"; break;
+ case 0xCA: out += "la"; break;
+ case 0xCB: out += "le"; break;
+ case 0xCC: out += "li"; break;
+ case 0xCD: out += "le"; break;
+ case 0xCE: out += "lo"; break;
+ case 0xCF: out += "ld"; break;
+
+ case 0xD0: out += "he"; break;
+ case 0xD1: out += "hi"; break;
+ case 0xD2: out += "ha"; break;
+ case 0xD3: out += "h "; break;
+ case 0xD4: out += "ho"; break;
+ case 0xD5: out += "ht"; break;
+ case 0xD6: out += "hr"; break;
+ case 0xD7: out += "hu"; break;
+ case 0xD8: out += "ce"; break;
+ case 0xD9: out += "ct"; break;
+ case 0xDA: out += "co"; break;
+ case 0xDB: out += "ca"; break;
+ case 0xDC: out += "ck"; break;
+ case 0xDD: out += "ch"; break;
+ case 0xDE: out += "cl"; break;
+ case 0xDF: out += "cr"; break;
+
+ case 0xE0: out += "d "; break;
+ case 0xE1: out += "de"; break;
+ case 0xE2: out += "di"; break;
+ case 0xE3: out += "du"; break;
+ case 0xE4: out += "d,"; break;
+ case 0xE5: out += "d."; break;
+ case 0xE6: out += "do"; break;
+ case 0xE7: out += "da"; break;
+ case 0xE8: out += "un"; break;
+ case 0xE9: out += "us"; break;
+ case 0xEA: out += "ur"; break;
+ case 0xEB: out += "uc"; break;
+ case 0xEC: out += "ut"; break;
+ case 0xED: out += "ul"; break;
+ case 0xEE: out += "ua"; break;
+ case 0xEF: out += "ui"; break;
+
+ case 0xF0: out += "pl"; break;
+ case 0xF1: out += "pe"; break;
+ case 0xF2: out += "po"; break;
+ case 0xF3: out += "pi"; break;
+ case 0xF4: out += "pr"; break;
+ case 0xF5: out += "pa"; break;
+ case 0xF6: out += "pt"; break;
+ case 0xF7: out += "pp"; break;
+ case 0xF8: out += "me"; break;
+ case 0xF9: out += "ma"; break;
+ case 0xFA: out += "mo"; break;
+ case 0xFB: out += "mi"; break;
+ case 0xFC: out += "mp"; break;
+ case 0xFD: out += "m "; break;
+ case 0xFE: out += "mb"; break;
+ case 0xFF: out += "mm"; break;
+
+ case 0x1B: {
+ // special character
+ i++;
+ if(i == text.length()) {
+ fprintf(stderr,"StringFile:decodeString: Special character escape sequence at end of string!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ unsigned char special = text[i];
+ switch(special) {
+ // e.g. german "umlaute"
+ case 0x02: out += (unsigned char) 252 /*"ue"*/; break;
+ case 0x05: out += (unsigned char) 228 /*"ae"*/; break;
+ case 0x0F: out += (unsigned char) 197 /*"Ae"*/; break;
+ case 0x15: out += (unsigned char) 246 /*"oe"*/; break;
+ case 0x1B: out += (unsigned char) 220 /*"Ue"*/; break;
+ case 0x62: out += (unsigned char) 223 /*"ss"*/; break;
+ default: {
+ char tmp[20];
+ sprintf(tmp,"---Unknown char:%X---",special);
+ out += tmp;
+ } break;
+ };
+
+ } break;
+
+ case 0x1F: out += "."; break;
+
+ default: {
+ if((databyte & 0x80) == 0x80) {
+ char tmp[20];
+ sprintf(tmp,"---Unknown char:%X---",databyte);
+ out += tmp;
+ } else {
+ out += databyte;
+ }
+ } break;
+ }
+ }
+
+ return out;
+}
Property changes on: branches/dunks/src/pakfile/StringFile.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dv...@us...> - 2008-04-25 22:18:26
|
Revision: 157
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=157&view=rev
Author: dvalin
Date: 2008-04-25 15:18:04 -0700 (Fri, 25 Apr 2008)
Log Message:
-----------
use shared ptr
Modified Paths:
--------------
branches/dunks/include/pakfile/Cpsfile.h
branches/dunks/src/pakfile/Cpsfile.cpp
Modified: branches/dunks/include/pakfile/Cpsfile.h
===================================================================
--- branches/dunks/include/pakfile/Cpsfile.h 2008-04-24 22:22:22 UTC (rev 156)
+++ branches/dunks/include/pakfile/Cpsfile.h 2008-04-25 22:18:04 UTC (rev 157)
@@ -1,9 +1,15 @@
#ifndef CPSFILE_H_INCLUDED
#define CPSFILE_H_INCLUDED
+#include "Gfx.h"
#include "pakfile/Decode.h"
#include "SDL.h"
+#include <boost/shared_ptr.hpp>
+
+class Cpsfile;
+typedef boost::shared_ptr<Cpsfile> CpsfilePtr;
+
class Cpsfile : public Decode
{
public:
@@ -11,7 +17,7 @@
~Cpsfile();
- SDL_Surface * getPicture();
+ Image * getPicture();
private:
unsigned char* Filedata;
Modified: branches/dunks/src/pakfile/Cpsfile.cpp
===================================================================
--- branches/dunks/src/pakfile/Cpsfile.cpp 2008-04-24 22:22:22 UTC (rev 156)
+++ branches/dunks/src/pakfile/Cpsfile.cpp 2008-04-25 22:18:04 UTC (rev 157)
@@ -20,7 +20,7 @@
;
}
-SDL_Surface* Cpsfile::getPicture()
+Image * Cpsfile::getPicture()
{
unsigned char * ImageOut;
SDL_Surface *pic = NULL;
@@ -61,8 +61,10 @@
}
SDL_UnlockSurface(pic);
+
+ Image * img = new Image(pic);
+
+// free(ImageOut);
- free(ImageOut);
-
- return pic;
+ return img;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dv...@us...> - 2008-04-25 23:18:48
|
Revision: 159
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=159&view=rev
Author: dvalin
Date: 2008-04-25 16:18:46 -0700 (Fri, 25 Apr 2008)
Log Message:
-----------
add getDoublePicture & getSubPicture (merged from richies branch)
Modified Paths:
--------------
branches/dunks/include/pakfile/Cpsfile.h
branches/dunks/src/pakfile/Cpsfile.cpp
Modified: branches/dunks/include/pakfile/Cpsfile.h
===================================================================
--- branches/dunks/include/pakfile/Cpsfile.h 2008-04-25 22:20:03 UTC (rev 158)
+++ branches/dunks/include/pakfile/Cpsfile.h 2008-04-25 23:18:46 UTC (rev 159)
@@ -18,7 +18,10 @@
Image * getPicture();
+ Image * getDoublePicture();
+ Image * getSubPicture(unsigned int left, unsigned int top, unsigned int width, unsigned int height);
+
private:
unsigned char* Filedata;
Uint32 CpsFilesize;
Modified: branches/dunks/src/pakfile/Cpsfile.cpp
===================================================================
--- branches/dunks/src/pakfile/Cpsfile.cpp 2008-04-25 22:20:03 UTC (rev 158)
+++ branches/dunks/src/pakfile/Cpsfile.cpp 2008-04-25 23:18:46 UTC (rev 159)
@@ -68,3 +68,66 @@
return img;
}
+
+Image * Cpsfile::getDoublePicture() {
+ SDL_Surface *inputPic = getPicture()->getSurface();
+ SDL_Surface *returnPic;
+
+ // create new picture surface
+ if((returnPic = SDL_CreateRGBSurface(SDL_HWSURFACE,inputPic->w * 2,inputPic->h * 2,8,0,0,0,0))== NULL) {
+ fprintf(stderr,"DoublePicture: Cannot create new Picture!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ SDL_SetColors(returnPic, inputPic->format->palette->colors, 0, inputPic->format->palette->ncolors);
+ SDL_LockSurface(returnPic);
+ SDL_LockSurface(inputPic);
+
+ //Now we can copy pixel by pixel
+ for(int y = 0; y < inputPic->h;y++) {
+ for(int x = 0; x < inputPic->w; x++) {
+ char val = *( ((char*) (inputPic->pixels)) + y*inputPic->pitch + x);
+ *( ((char*) (returnPic->pixels)) + 2*y*returnPic->pitch + 2*x) = val;
+ *( ((char*) (returnPic->pixels)) + 2*y*returnPic->pitch + 2*x+1) = val;
+ *( ((char*) (returnPic->pixels)) + (2*y+1)*returnPic->pitch + 2*x) = val;
+ *( ((char*) (returnPic->pixels)) + (2*y+1)*returnPic->pitch + 2*x+1) = val;
+ }
+ }
+
+ SDL_UnlockSurface(inputPic);
+ SDL_UnlockSurface(returnPic);
+
+ SDL_FreeSurface(inputPic);
+ Image * img = new Image(returnPic);
+
+ return img;
+}
+
+Image * Cpsfile::getSubPicture(unsigned int left, unsigned int top, unsigned int width, unsigned int height)
+{
+ SDL_Surface *Pic = getPicture()->getSurface();
+ if(Pic == NULL) {
+ return NULL;
+ }
+
+ if(((int) (left+width) > Pic->w) || ((int) (top+height) > Pic->h)) {
+ return NULL;
+ }
+
+ SDL_Surface *returnPic;
+
+ // create new picture surface
+ if((returnPic = SDL_CreateRGBSurface(SDL_HWSURFACE,width,height,8,0,0,0,0))== NULL) {
+ fprintf(stderr,"GetSubPicture: Cannot create new Picture!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ SDL_SetColors(returnPic, Pic->format->palette->colors, 0, Pic->format->palette->ncolors);
+
+ SDL_Rect srcRect = {left,top,width,height};
+ SDL_BlitSurface(Pic,&srcRect,returnPic,NULL);
+
+ Image * img = new Image(returnPic);
+
+ return img;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dv...@us...> - 2008-04-26 00:48:43
|
Revision: 160
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=160&view=rev
Author: dvalin
Date: 2008-04-25 17:48:39 -0700 (Fri, 25 Apr 2008)
Log Message:
-----------
start on adding campaign menu stuff..
Modified Paths:
--------------
branches/dunks/src/SConscript
Added Paths:
-----------
branches/dunks/include/CampaignMenu.h
branches/dunks/src/CampaignMenu.cpp
Added: branches/dunks/include/CampaignMenu.h
===================================================================
--- branches/dunks/include/CampaignMenu.h (rev 0)
+++ branches/dunks/include/CampaignMenu.h 2008-04-26 00:48:39 UTC (rev 160)
@@ -0,0 +1,30 @@
+#ifndef DUNE_CAMPAIGNMENU_H
+#define DUNE_CAMPAIGNMENU_H
+
+#include "MenuBase.h"
+#include "gui2/Button.h"
+#include "gui2/VBox.h"
+
+#include "SDL.h"
+
+
+class CampaignMenuState : public MenuBaseState
+{
+ public:
+ CampaignMenuState();
+ ~CampaignMenuState();
+
+ void doCancel();
+
+ int Execute(float dt);
+ virtual const char* GetName() { return "CampaignMenuState"; }
+
+ private:
+ VBox* m_vbox;
+
+ BoringButton* m_butCancel;
+ ImagePtr m_surf;
+
+};
+
+#endif // DUNE_CAMPAIGNMENU_H
Property changes on: branches/dunks/include/CampaignMenu.h
___________________________________________________________________
Name: svn:eol-style
+ native
Added: branches/dunks/src/CampaignMenu.cpp
===================================================================
--- branches/dunks/src/CampaignMenu.cpp (rev 0)
+++ branches/dunks/src/CampaignMenu.cpp 2008-04-26 00:48:39 UTC (rev 160)
@@ -0,0 +1,39 @@
+#include "CampaignMenu.h"
+
+#include "Application.h"
+#include "Settings.h"
+#include "DataCache.h"
+#include "pakfile/Cpsfile.h"
+#include "boost/bind.hpp"
+
+
+CampaignMenuState::CampaignMenuState()
+{
+ int len;
+ unsigned char * data = ResMan::Instance()->readFile("ENGLISH:HERALD.ENG", &len);
+
+ CpsfilePtr m_cps (new Cpsfile(data, len));
+
+ m_surf.reset(m_cps->getPicture());
+ m_surf = m_surf->getResized(2);
+
+}
+
+CampaignMenuState::~CampaignMenuState()
+{
+}
+
+void CampaignMenuState::doCancel()
+{
+ assert(mp_parent != NULL);
+ PopState();
+}
+
+int CampaignMenuState::Execute(float dt)
+{
+ m_surf.get()->blitToScreen(SPoint(Settings::Instance()->GetWidth() / 2 - m_surf->getSurface()->w/2,
+ Settings::Instance()->GetHeight() / 8));
+
+ return 0;
+}
+
Property changes on: branches/dunks/src/CampaignMenu.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/dunks/src/SConscript
===================================================================
--- branches/dunks/src/SConscript 2008-04-25 23:18:46 UTC (rev 159)
+++ branches/dunks/src/SConscript 2008-04-26 00:48:39 UTC (rev 160)
@@ -24,6 +24,7 @@
"MainMenu.cpp",
"IntroState.cpp",
"SingleMenu.cpp",
+ "CampaignMenu.cpp",
"OptionsMenu.cpp",
"Gfx.cpp",
"houses.cpp", # just for colors, hope there will be a better place for these (otpetrik)
@@ -46,6 +47,7 @@
"gui2/Button.cpp",
"gui2/VBox.cpp",
"gui2/Label.cpp",
+ "gui2/Window.cpp"
]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dv...@us...> - 2008-04-26 17:39:20
|
Revision: 162
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=162&view=rev
Author: dvalin
Date: 2008-04-26 10:38:55 -0700 (Sat, 26 Apr 2008)
Log Message:
-----------
make it possible to specify palette used (ie. bene gesserit mentat graphics requires custom palette)
Modified Paths:
--------------
branches/dunks/include/pakfile/Cpsfile.h
branches/dunks/src/pakfile/Cpsfile.cpp
Modified: branches/dunks/include/pakfile/Cpsfile.h
===================================================================
--- branches/dunks/include/pakfile/Cpsfile.h 2008-04-26 00:53:46 UTC (rev 161)
+++ branches/dunks/include/pakfile/Cpsfile.h 2008-04-26 17:38:55 UTC (rev 162)
@@ -4,6 +4,7 @@
#include "Gfx.h"
#include "pakfile/Decode.h"
#include "SDL.h"
+#include "Application.h"
#include <boost/shared_ptr.hpp>
@@ -16,8 +17,9 @@
Cpsfile(unsigned char * bufFiledata, int bufsize);
~Cpsfile();
+ Image * getPicture(SDL_Palette* palette = Application::Instance()->Screen()->getSurface()->format->palette);
+ Image * getSubPicture(unsigned int left, unsigned int top, unsigned int width, unsigned int height);
- Image * getPicture();
private:
unsigned char* Filedata;
Modified: branches/dunks/src/pakfile/Cpsfile.cpp
===================================================================
--- branches/dunks/src/pakfile/Cpsfile.cpp 2008-04-26 00:53:46 UTC (rev 161)
+++ branches/dunks/src/pakfile/Cpsfile.cpp 2008-04-26 17:38:55 UTC (rev 162)
@@ -1,5 +1,4 @@
#include "pakfile/Cpsfile.h"
-#include "Application.h"
#include <SDL_endian.h>
#include <stdlib.h>
#include <string.h>
@@ -7,8 +6,6 @@
#define SIZE_X 320
#define SIZE_Y 240
-//extern SDL_Palette* palette;
-
Cpsfile::Cpsfile(unsigned char * bufFiledata, int bufsize) : Decode()
{
Filedata = bufFiledata;
@@ -20,7 +17,7 @@
;
}
-Image * Cpsfile::getPicture()
+Image * Cpsfile::getPicture(SDL_Palette* palette)
{
unsigned char * ImageOut;
SDL_Surface *pic = NULL;
@@ -50,7 +47,6 @@
}
- SDL_Palette* palette = Application::Instance()->Screen()->getSurface()->format->palette;
SDL_SetColors(pic, palette->colors, 0, palette->ncolors);
SDL_LockSurface(pic);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dv...@us...> - 2008-04-27 17:34:07
|
Revision: 163
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=163&view=rev
Author: dvalin
Date: 2008-04-27 10:32:34 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
use enum data types
Modified Paths:
--------------
branches/dunks/include/DataCache.h
branches/dunks/include/SoundPlayerClass.h
branches/dunks/src/DataCache.cpp
branches/dunks/src/SoundPlayerClass.cpp
Modified: branches/dunks/include/DataCache.h
===================================================================
--- branches/dunks/include/DataCache.h 2008-04-26 17:38:55 UTC (rev 162)
+++ branches/dunks/include/DataCache.h 2008-04-27 17:32:34 UTC (rev 163)
@@ -13,7 +13,7 @@
#include "pakfile/Palette.h"
#include "pakfile/Shpfile.h"
#include "pakfile/Wsafile.h"
-
+//#include "pakfile/BriefingText.h"
#include "houses.h"
#include <map>
@@ -135,7 +135,7 @@
Picture_WindTrap,
Picture_WOR,
NUM_SMALLDETAILPICS
-} SmallDetailPics_Enum;
+} SmallDetailPics_enum;
// UI Graphics
typedef enum {
@@ -199,7 +199,7 @@
UI_MapChoiceMap,
UI_MapChoiceClickMap,
NUM_UIGRAPHICS
-} UIGraphics_Enum;
+} GuiPic_enum;
//Animation
typedef enum {
@@ -371,7 +371,7 @@
NUM_SOUNDCHUNK
} Sound_enum;
-typedef std::map <unsigned, ImagePtr> images;
+typedef std::map <ObjPic_enum, ImagePtr> images;
typedef std::vector <images*> remapped_images; //One for each house
class DataCache : public Singleton<DataCache>
@@ -383,13 +383,20 @@
~DataCache();
public:
- void addObjPic(unsigned ID, SDL_Surface * tmp);
- void addSoundChunk(unsigned ID, Mix_Chunk* tmp);
- ImagePtr getObjPic(unsigned ID, unsigned house = HOUSE_HARKONNEN);
- Mix_Chunk* getSoundChunk(unsigned ID);
+ void addObjPic(ObjPic_enum ID, SDL_Surface * tmp, HOUSETYPE house = HOUSE_HARKONNEN);
+// void addGuiPic(GuiPic_enum ID, SDL_Surface * tmp, HOUSETYPE house = HOUSE_HARKONNEN);
+ void addSoundChunk(Sound_enum ID, Mix_Chunk* tmp);
+ ImagePtr getObjPic(ObjPic_enum ID, HOUSETYPE house = HOUSE_HARKONNEN);
+ ImagePtr getGuiPic(GuiPic_enum ID, HOUSETYPE house = HOUSE_HARKONNEN);
+ Mix_Chunk* getSoundChunk(Sound_enum ID);
+ Mix_Chunk* concat2Chunks(Sound_enum ID1, Sound_enum ID2);
+// std::string getBriefingText(ObjPic_enum mission, ObjPic_enum texttype, ObjPic_enum house);
+// std::string getBriefingText(ObjPic_enum i);
+
+
private:
- bool addObjPic(unsigned ID) { return false;};
+ bool addObjPic(ObjPic_enum ID) { return false;};
remapped_images m_objImg;
remapped_images m_guiImg;
@@ -398,6 +405,7 @@
Mix_Chunk* concat3Chunks(Mix_Chunk* sound1, Mix_Chunk* sound2, Mix_Chunk* sound3);
Mix_Chunk* createEmptyChunk();
+// BriefingText* BriefingStrings[1];
Mix_Chunk* soundChunk[NUM_SOUNDCHUNK];
};
Modified: branches/dunks/include/SoundPlayerClass.h
===================================================================
--- branches/dunks/include/SoundPlayerClass.h 2008-04-26 17:38:55 UTC (rev 162)
+++ branches/dunks/include/SoundPlayerClass.h 2008-04-27 17:32:34 UTC (rev 163)
@@ -4,9 +4,9 @@
#include <string>
#include <vector>
#include "ResMan.h"
+#include "DataCache.h"
#include "dMath.h"
#include "SDL_mixer.h"
-using namespace std;
//! \enum MUSICTYPE
/*! Types of music available in the game*/
@@ -50,7 +50,7 @@
@param soundID id of the sound to be played
@param location coordinates where the sound is to be played
*/
- void playSoundAt(int soundID, COORDTYPE* location);
+ void playSoundAt(Sound_enum soundID, COORDTYPE* location);
/*!
turns music playing on or off
@@ -59,8 +59,9 @@
void setMusic(bool value);
void toggleSound();
- void playVoice(int id, int house);
- void playSound(int soundID);
+ void playVoice(Sound_enum id, HOUSETYPE house);
+ void playSound(Sound_enum soundID);
+ void playSound(Mix_Chunk* sound);
inline int GetSfxVolume() { return sfxVolume; };
void SetSfxVolume(int newVolume) {
@@ -83,14 +84,14 @@
@param soundID id of a sound to be played
@param volume sound will be played with this volume
*/
- void playSound(int soundID, int volume);
- vector<string> getMusicFileNames(string dir);
+ void playSound(Sound_enum soundID, int volume);
+ vector<std::string> getMusicFileNames(std::string dir);
- vector<string> AttackMusic;
- vector<string> IntroMusic;
- vector<string> LoseMusic;
- vector<string> PeaceMusic;
- vector<string> WinMusic;
+ vector<std::string> AttackMusic;
+ vector<std::string> IntroMusic;
+ vector<std::string> LoseMusic;
+ vector<std::string> PeaceMusic;
+ vector<std::string> WinMusic;
//! whether sound should be played
bool soundOn;
Modified: branches/dunks/src/DataCache.cpp
===================================================================
--- branches/dunks/src/DataCache.cpp 2008-04-26 17:38:55 UTC (rev 162)
+++ branches/dunks/src/DataCache.cpp 2008-04-27 17:32:34 UTC (rev 163)
@@ -14,6 +14,7 @@
Shpfile* units;
Shpfile* units1;
Shpfile* units2;
+ Cpsfile* herald;
//LOADING FILES
data = ResMan::Instance()->readFile("DUNE:UNITS.SHP", &len);
@@ -24,8 +25,10 @@
data = ResMan::Instance()->readFile("DUNE:UNITS2.SHP", &len);
units2 = new Shpfile(data, len);
+
+ data = ResMan::Instance()->readFile("ENGLISH:HERALD.ENG", &len);
+ herald = new Cpsfile(data, len);
-
int maplen;
unsigned char * mapdata;
@@ -94,6 +97,14 @@
addObjPic(ObjPic_SandDamage, units1->getPictureArray(3,1,5|TILE_NORMAL,6|TILE_NORMAL,7|TILE_NORMAL));
addObjPic(ObjPic_Terrain_Hidden, icon->getPictureRow(108,123));
+ //addGuiPic(UI_HouseChoiceBackground, herald->getPicture());
+
+/* UIGraphic[UI_MentatYes][HOUSE_HARKONNEN] = DoublePicture(mentat->getPicture(0));
+ UIGraphic[UI_MentatYes_Pressed][HOUSE_HARKONNEN] = DoublePicture(mentat->getPicture(1));
+ UIGraphic[UI_MentatNo][HOUSE_HARKONNEN] = DoublePicture(mentat->getPicture(2));
+ UIGraphic[UI_MentatNo_Pressed][HOUSE_HARKONNEN] = DoublePicture(mentat->getPicture(3));*/
+
+
addSoundChunk(YesSir, getChunkFromFile("VOC:ZREPORT1.VOC"));
addSoundChunk(Reporting, getChunkFromFile("VOC:ZREPORT2.VOC"));
addSoundChunk(Acknowledged, getChunkFromFile("VOC:ZREPORT3.VOC"));
@@ -186,17 +197,38 @@
addSoundChunk(Intro_WhoEver, getChunkFromFile("INTROVOC:WHOEVER.VOC"));
addSoundChunk(Intro_Wind_2bp, getChunkFromFile("INTROVOC:WIND2BP.VOC"));
addSoundChunk(Intro_Your, getChunkFromFile("INTROVOC:YOUR.VOC"));
+#if 0
+ SDL_RWops* text_lng[1];
+ data = ResMan::Instance()->readFile("ENGLISH:INTRO.ENG", &len);
+ text_lng[0] = SDL_RWFromMem(data, len);
+/* data = ResMan::Instance()->readFile("ENGLISH:TEXTO.ENG", &len);
+ text_lng[1] = SDL_RWFromMem(data, len);
+ data = ResMan::Instance()->readFile("ENGLISH:TEXTH.ENG", &len);
+ text_lng[2] = SDL_RWFromMem(data, len);*/
+ int i = 0;
+ for(i = 0; i < 1; i++){
+ BriefingStrings[i] = new BriefingText(text_lng[i]);
+ SDL_RWclose(text_lng[i]);
+ }
+#endif
}
-void DataCache::addObjPic(unsigned ID, SDL_Surface * tmp) {
+void DataCache::addObjPic(ObjPic_enum ID, SDL_Surface * tmp, HOUSETYPE house) {
- m_objImg[HOUSE_HARKONNEN]->insert(std::pair<unsigned, ImagePtr>(ID,
+ m_objImg[HOUSE_HARKONNEN]->insert(std::pair<ObjPic_enum, ImagePtr>(ID,
ImagePtr(new Image(tmp))));
}
-ImagePtr DataCache::getObjPic(unsigned ID, unsigned house) {
+/*void DataCache::addGuiPic(GuiPic_enum ID, SDL_Surface * tmp, HOUSETYPE house) {
+ m_guiImg[HOUSE_HARKONNEN]->insert(std::pair<GuiPic_enum, ImagePtr>(ID,
+ ImagePtr(new Image(tmp))));
+}*/
+
+
+ImagePtr DataCache::getObjPic(ObjPic_enum ID, HOUSETYPE house) {
+
images::iterator iter = m_objImg[house]->find(ID);
if (iter != m_objImg[house]->end())
{
@@ -206,17 +238,34 @@
{
ImagePtr source = m_objImg[HOUSE_HARKONNEN]->find(ID)->second;
ImagePtr copy = source->getRecoloredByHouse(house);
- m_objImg[HOUSE_HARKONNEN]->insert(std::pair<unsigned, ImagePtr>(ID, copy));
+ m_objImg[HOUSE_HARKONNEN]->insert(std::pair<ObjPic_enum, ImagePtr>(ID, copy));
return copy;
}
}
-void DataCache::addSoundChunk(unsigned ID, Mix_Chunk* tmp){
+/*ImagePtr DataCache::getGuiPic(GuiPic_enum ID, HOUSETYPE house) {
+
+ images::iterator iter = m_guiImg[house]->find(ID);
+ if (iter != m_guiImg[house]->end())
+ {
+ return m_guiImg[house]->find(ID)->second;
+ }
+ else
+ {
+ ImagePtr source = m_guiImg[HOUSE_HARKONNEN]->find(ID)->second;
+ ImagePtr copy = source->getRecoloredByHouse(house);
+ m_guiImg[HOUSE_HARKONNEN]->insert(std::pair<GuiPic_enum, ImagePtr>(ID, copy));
+ return copy;
+ }
+
+}*/
+
+void DataCache::addSoundChunk(Sound_enum ID, Mix_Chunk* tmp){
soundChunk[ID] = tmp;
}
-Mix_Chunk* DataCache::getSoundChunk(unsigned ID){
+Mix_Chunk* DataCache::getSoundChunk(Sound_enum ID){
return soundChunk[ID];
}
Mix_Chunk* DataCache::getChunkFromFile(std::string fileName) {
@@ -240,6 +289,41 @@
return returnChunk;
}
+Mix_Chunk* DataCache::concat2Chunks(Mix_Chunk* sound1, Mix_Chunk* sound2)
+{
+ Mix_Chunk* returnChunk;
+ if((returnChunk = (Mix_Chunk*) malloc(sizeof(Mix_Chunk))) == NULL) {
+ return NULL;
+ }
+
+ returnChunk->allocated = 1;
+ returnChunk->volume = sound1->volume;
+ returnChunk->alen = sound1->alen + sound2->alen;
+
+ if((returnChunk->abuf = (Uint8 *)malloc(returnChunk->alen)) == NULL) {
+ free(returnChunk);
+ return NULL;
+ }
+
+ memcpy(returnChunk->abuf, sound1->abuf, sound1->alen);
+ memcpy(returnChunk->abuf + sound1->alen, sound2->abuf, sound2->alen);
+
+ return returnChunk;
+}
+/*
+std::string DataCache::getBriefingText(ObjPic_enum mission, ObjPic_enum texttype, int house) {
+ return BriefingStrings[0]->getString(0,0);
+}
+
+std::string DataCache::getBriefingText(int i){
+ return BriefingStrings[0]->getString(i);
+}
+*/
+Mix_Chunk* DataCache::concat2Chunks(Sound_enum ID1, Sound_enum ID2)
+{
+ return concat2Chunks(soundChunk[ID1], soundChunk[ID2]);
+}
+
DataCache::~DataCache() {
}
Modified: branches/dunks/src/SoundPlayerClass.cpp
===================================================================
--- branches/dunks/src/SoundPlayerClass.cpp 2008-04-26 17:38:55 UTC (rev 162)
+++ branches/dunks/src/SoundPlayerClass.cpp 2008-04-27 17:32:34 UTC (rev 163)
@@ -257,7 +257,7 @@
}
}
-void SoundPlayerClass::playSound(int soundID, int volume)
+void SoundPlayerClass::playSound(Sound_enum soundID, int volume)
{
if (soundOn)
{
@@ -290,7 +290,7 @@
}
#endif
-void SoundPlayerClass::playSound(int soundID) {
+void SoundPlayerClass::playSound(Sound_enum soundID) {
if (soundOn)
{
Mix_Chunk* tmp;
@@ -303,6 +303,14 @@
Mix_PlayChannel(-1, tmp, 0);
}
}
+
+void SoundPlayerClass::playSound(Mix_Chunk* sound) {
+ if (soundOn)
+ {
+ Mix_PlayChannel(-1, sound, 0);
+ }
+}
+
#if 0
vector<string> SoundPlayerClass::getMusicFileNames(string dir) {
vector<string> Files;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dv...@us...> - 2008-04-27 20:07:47
|
Revision: 168
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=168&view=rev
Author: dvalin
Date: 2008-04-27 13:07:24 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
consistently use Image in stead of SDL_Surface
Modified Paths:
--------------
branches/dunks/include/DataCache.h
branches/dunks/include/pakfile/Icnfile.h
branches/dunks/include/pakfile/Shpfile.h
branches/dunks/src/Application.cpp
branches/dunks/src/DataCache.cpp
branches/dunks/src/pakfile/Icnfile.cpp
branches/dunks/src/pakfile/Shpfile.cpp
branches/dunks/src/pakfile/Wsafile.cpp
Modified: branches/dunks/include/DataCache.h
===================================================================
--- branches/dunks/include/DataCache.h 2008-04-27 20:04:24 UTC (rev 167)
+++ branches/dunks/include/DataCache.h 2008-04-27 20:07:24 UTC (rev 168)
@@ -191,6 +191,7 @@
UI_MentatProcced_Pressed,
UI_MentatRepeat,
UI_MentatRepeat_Pressed,
+ UI_Mentat_BeneGesserit,
UI_PlanetBackground,
UI_MenuButtonBorder,
UI_DuneLegacy,
@@ -383,8 +384,8 @@
~DataCache();
public:
- void addObjPic(ObjPic_enum ID, SDL_Surface * tmp, HOUSETYPE house = HOUSE_HARKONNEN);
- void addGuiPic(GuiPic_enum ID, SDL_Surface * tmp, HOUSETYPE house = HOUSE_HARKONNEN);
+ void addObjPic(ObjPic_enum ID, Image * tmp, HOUSETYPE house = HOUSE_HARKONNEN);
+ void addGuiPic(GuiPic_enum ID, Image * tmp, HOUSETYPE house = HOUSE_HARKONNEN);
void addSoundChunk(Sound_enum ID, Mix_Chunk* tmp);
ImagePtr getObjPic(ObjPic_enum ID, HOUSETYPE house = HOUSE_HARKONNEN);
ImagePtr getGuiPic(GuiPic_enum ID, HOUSETYPE house = HOUSE_HARKONNEN);
Modified: branches/dunks/include/pakfile/Icnfile.h
===================================================================
--- branches/dunks/include/pakfile/Icnfile.h 2008-04-27 20:04:24 UTC (rev 167)
+++ branches/dunks/include/pakfile/Icnfile.h 2008-04-27 20:07:24 UTC (rev 168)
@@ -25,7 +25,7 @@
~Icnfile();
- SDL_Surface * getPicture(Uint32 IndexOfFile);
+ Image * getPicture(Uint32 IndexOfFile);
/// Returns an array of pictures in the icn-File
/*!
@@ -54,7 +54,7 @@
@param tilesN how many tilesX*tilesY blocks in a row
@return the result surface with tilesX*tilesY*tilesN tiles
*/
- SDL_Surface * getPictureArray(Uint32 MapfileIndex, int tilesX = 0, int tilesY = 0, int tilesN = 0);
+ Image * getPictureArray(Uint32 MapfileIndex, int tilesX = 0, int tilesY = 0, int tilesN = 0);
/*!
This method returns a SDL_Surface containing multiple tiles/pictures. The returned surface contains all
@@ -64,7 +64,7 @@
@param EndIndex The last tile to use
@return the result surface with (EndIndex-StartIndex+1) tiles. NULL on errors.
*/
- SDL_Surface * getPictureRow(Uint32 StartIndex, Uint32 EndIndex);
+ Image * getPictureRow(Uint32 StartIndex, Uint32 EndIndex);
/// Returns the number of tiles
/*!
Modified: branches/dunks/include/pakfile/Shpfile.h
===================================================================
--- branches/dunks/include/pakfile/Shpfile.h 2008-04-27 20:04:24 UTC (rev 167)
+++ branches/dunks/include/pakfile/Shpfile.h 2008-04-27 20:07:24 UTC (rev 168)
@@ -30,7 +30,7 @@
@param IndexOfFile specifies which picture to return (zero based)
@return nth picture in this shp-File
*/
- SDL_Surface* getPicture(Uint32 IndexOfFile);
+ Image * getPicture(Uint32 IndexOfFile);
/*!
This method returns a SDL_Surface containing an array of pictures from this shp-File.
@@ -54,7 +54,7 @@
@param tilesY how many pictures in one column
@return picture in this shp-File containing all specified pictures
*/
- SDL_Surface* getPictureArray(unsigned int tilesX, unsigned int tilesY, ...);
+ Image * getPictureArray(unsigned int tilesX, unsigned int tilesY, ...);
inline int getNumFiles() {return (int) NumFiles;};
Modified: branches/dunks/src/Application.cpp
===================================================================
--- branches/dunks/src/Application.cpp 2008-04-27 20:04:24 UTC (rev 167)
+++ branches/dunks/src/Application.cpp 2008-04-27 20:07:24 UTC (rev 168)
@@ -8,7 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
-
+#include <iostream>
//#include "globals.h"
//#include "houses.h"
//#include "MentatClass.h"
@@ -297,12 +297,12 @@
Shpfile mouse (data, len);
- m_cursor.reset(new Image(mouse.getPicture(0)));
+ m_cursor.reset(mouse.getPicture(0));
-
-
fprintf(stdout, "starting sound...\n");
SoundPlayerClass* soundPlayer = new SoundPlayerClass();
+// Mix_Chunk* sound = DataCache::Instance()->concat2Chunks(Intro_TheBuilding, Intro_OfADynasty);
+// soundPlayer->playSound(sound);
}
void Application::Die()
Modified: branches/dunks/src/DataCache.cpp
===================================================================
--- branches/dunks/src/DataCache.cpp 2008-04-27 20:04:24 UTC (rev 167)
+++ branches/dunks/src/DataCache.cpp 2008-04-27 20:07:24 UTC (rev 168)
@@ -14,8 +14,12 @@
Shpfile* units;
Shpfile* units1;
Shpfile* units2;
- Cpsfile* herald;
+ Cpsfile* herald;
+ Shpfile* mentat;
+// CpsfilePtr mentatm;
+
+
//LOADING FILES
data = ResMan::Instance()->readFile("DUNE:UNITS.SHP", &len);
units = new Shpfile(data, len);
@@ -28,7 +32,16 @@
data = ResMan::Instance()->readFile("ENGLISH:HERALD.ENG", &len);
herald = new Cpsfile(data, len);
+
+ data = ResMan::Instance()->readFile("ENGLISH:MENTAT.ENG", &len);
+ mentat = new Shpfile(data, len);
+
+ data = ResMan::Instance()->readFile("DUNE:BENE.PAL", &len);
+ data = ResMan::Instance()->readFile("DUNE:MENTATM.CPS", &len);
+
+ CpsfilePtr mentatm (new Cpsfile(data, len));
+
int maplen;
unsigned char * mapdata;
@@ -99,11 +112,14 @@
//addGuiPic(UI_HouseChoiceBackground, herald->getPicture());
-/* UIGraphic[UI_MentatYes][HOUSE_HARKONNEN] = DoublePicture(mentat->getPicture(0));
- UIGraphic[UI_MentatYes_Pressed][HOUSE_HARKONNEN] = DoublePicture(mentat->getPicture(1));
- UIGraphic[UI_MentatNo][HOUSE_HARKONNEN] = DoublePicture(mentat->getPicture(2));
- UIGraphic[UI_MentatNo_Pressed][HOUSE_HARKONNEN] = DoublePicture(mentat->getPicture(3));*/
+ /*addGuiPic(UI_MentatYes, mentat->getPicture(0));
+ addGuiPic(UI_MentatYes_Pressed, mentat->getPicture(1));
+ addGuiPic(UI_MentatNo, mentat->getPicture(2));
+ addGuiPic(UI_MentatNo_Pressed, mentat->getPicture(3));*/
+/* Palettefile tmp (data, len);
+ SDL_Palette * pal = tmp.getPalette();
+ addGuiPic(UI_Mentat_BeneGesserit, mentatm->getPicture(pal)); */
addSoundChunk(YesSir, getChunkFromFile("VOC:ZREPORT1.VOC"));
addSoundChunk(Reporting, getChunkFromFile("VOC:ZREPORT2.VOC"));
@@ -197,33 +213,18 @@
addSoundChunk(Intro_WhoEver, getChunkFromFile("INTROVOC:WHOEVER.VOC"));
addSoundChunk(Intro_Wind_2bp, getChunkFromFile("INTROVOC:WIND2BP.VOC"));
addSoundChunk(Intro_Your, getChunkFromFile("INTROVOC:YOUR.VOC"));
-#if 0
- SDL_RWops* text_lng[1];
- data = ResMan::Instance()->readFile("ENGLISH:INTRO.ENG", &len);
- text_lng[0] = SDL_RWFromMem(data, len);
-/* data = ResMan::Instance()->readFile("ENGLISH:TEXTO.ENG", &len);
- text_lng[1] = SDL_RWFromMem(data, len);
- data = ResMan::Instance()->readFile("ENGLISH:TEXTH.ENG", &len);
- text_lng[2] = SDL_RWFromMem(data, len);*/
-
- int i = 0;
- for(i = 0; i < 1; i++){
- BriefingStrings[i] = new BriefingText(text_lng[i]);
- SDL_RWclose(text_lng[i]);
- }
-#endif
}
-void DataCache::addObjPic(ObjPic_enum ID, SDL_Surface * tmp, HOUSETYPE house) {
+void DataCache::addObjPic(ObjPic_enum ID, Image * tmp, HOUSETYPE house) {
m_objImg[HOUSE_HARKONNEN]->insert(std::pair<ObjPic_enum, ImagePtr>(ID,
- ImagePtr(new Image(tmp))));
+ ImagePtr(tmp)));
}
-void DataCache::addGuiPic(GuiPic_enum ID, SDL_Surface * tmp, HOUSETYPE house) {
+void DataCache::addGuiPic(GuiPic_enum ID, Image * tmp, HOUSETYPE house) {
m_guiImg[HOUSE_HARKONNEN]->insert(std::pair<GuiPic_enum, ImagePtr>(ID,
- ImagePtr(new Image(tmp))));
+ ImagePtr(tmp)));
}
ImagePtr DataCache::getObjPic(ObjPic_enum ID, HOUSETYPE house) {
Modified: branches/dunks/src/pakfile/Icnfile.cpp
===================================================================
--- branches/dunks/src/pakfile/Icnfile.cpp 2008-04-27 20:04:24 UTC (rev 167)
+++ branches/dunks/src/pakfile/Icnfile.cpp 2008-04-27 20:07:24 UTC (rev 168)
@@ -152,7 +152,7 @@
;
}
-SDL_Surface* Icnfile::getPicture(Uint32 IndexOfFile) {
+Image * Icnfile::getPicture(Uint32 IndexOfFile) {
SDL_Palette* palette = Application::Instance()->Screen()->getSurface()->format->palette;
SDL_Surface * pic;
@@ -196,11 +196,13 @@
SDL_UnlockSurface(pic);
printf("File Nr.: %d (Size: %dx%d)\n",IndexOfFile,SIZE_X,SIZE_Y);
+
+ Image * img = new Image(pic);
- return pic;
+ return img;
}
-SDL_Surface* Icnfile::getPictureArray(Uint32 MapfileIndex, int tilesX, int tilesY, int tilesN) {
+Image * Icnfile::getPictureArray(Uint32 MapfileIndex, int tilesX, int tilesY, int tilesN) {
SDL_Palette* palette = Application::Instance()->Screen()->getSurface()->format->palette;
SDL_Surface * pic;
@@ -311,11 +313,13 @@
}
SDL_UnlockSurface(pic);
+
+ Image * img = new Image(pic);
- return pic;
+ return img;
}
-SDL_Surface* Icnfile::getPictureRow(Uint32 StartIndex, Uint32 EndIndex) {
+Image * Icnfile::getPictureRow(Uint32 StartIndex, Uint32 EndIndex) {
SDL_Palette* palette = Application::Instance()->Screen()->getSurface()->format->palette;
SDL_Surface * pic;
@@ -363,7 +367,9 @@
}
SDL_UnlockSurface(pic);
- return pic;
+ Image * img = new Image(pic);
+
+ return img;
}
int Icnfile::getNumFiles()
Modified: branches/dunks/src/pakfile/Shpfile.cpp
===================================================================
--- branches/dunks/src/pakfile/Shpfile.cpp 2008-04-27 20:04:24 UTC (rev 167)
+++ branches/dunks/src/pakfile/Shpfile.cpp 2008-04-27 20:07:24 UTC (rev 168)
@@ -22,7 +22,7 @@
}
}
-SDL_Surface *Shpfile::getPicture(Uint32 IndexOfFile)
+Image * Shpfile::getPicture(Uint32 IndexOfFile)
{
SDL_Palette *palette = Application::Instance()->Screen()->getSurface()->format->palette;
SDL_Surface *pic = NULL;
@@ -131,10 +131,12 @@
if(ImageOut != NULL) {
free(ImageOut);
}
- return pic;
+ Image * img = new Image(pic);
+
+ return img;
}
-SDL_Surface* Shpfile::getPictureArray(unsigned int tilesX, unsigned int tilesY, ...) {
+Image * Shpfile::getPictureArray(unsigned int tilesX, unsigned int tilesY, ...) {
SDL_Palette *palette = Application::Instance()->Screen()->getSurface()->format->palette;
SDL_Surface *pic = NULL;
unsigned char *DecodeDestination = NULL;
@@ -310,7 +312,10 @@
free(tiles);
SDL_UnlockSurface(pic);
- return pic;
+ Image * img = new Image(pic);
+
+ return img;
+
}
void Shpfile::readIndex()
Modified: branches/dunks/src/pakfile/Wsafile.cpp
===================================================================
--- branches/dunks/src/pakfile/Wsafile.cpp 2008-04-27 20:04:24 UTC (rev 167)
+++ branches/dunks/src/pakfile/Wsafile.cpp 2008-04-27 20:07:24 UTC (rev 168)
@@ -105,7 +105,7 @@
SDL_UnlockSurface(pic);
Image * img = new Image(pic);
-
+
return img;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dv...@us...> - 2008-04-28 00:37:51
|
Revision: 174
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=174&view=rev
Author: dvalin
Date: 2008-04-27 17:37:49 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
start on adding the menus for house selection
Modified Paths:
--------------
branches/dunks/src/SingleMenu.cpp
Added Paths:
-----------
branches/dunks/include/HouseChoiceInfoMenu.h
branches/dunks/include/HouseChoiceMenu.h
branches/dunks/include/MentatMenu.h
branches/dunks/src/HouseChoiceInfoMenu.cpp
branches/dunks/src/HouseChoiceMenu.cpp
branches/dunks/src/MentatMenu.cpp
Added: branches/dunks/include/HouseChoiceInfoMenu.h
===================================================================
--- branches/dunks/include/HouseChoiceInfoMenu.h (rev 0)
+++ branches/dunks/include/HouseChoiceInfoMenu.h 2008-04-28 00:37:49 UTC (rev 174)
@@ -0,0 +1,18 @@
+#ifndef HOUSECHOICEINFOMENU_H_INCLUDED
+#define HOUSECHOICEINFOMENU_H_INCLUDED
+
+#include "MentatMenu.h"
+class HouseChoiceInfoMenuState : public MentatMenuState {
+ public:
+ HouseChoiceInfoMenuState(HOUSETYPE newHouse);
+ ~HouseChoiceInfoMenuState();
+
+ virtual const char* GetName() { return "HouseChoiceInfoMenuState"; }
+
+ private:
+ GraphicButton* m_butYes;
+ GraphicButton* m_butNo;
+};
+
+#endif // HOUSECHOICEINFOMENU_H_INCLUDED
+
Property changes on: branches/dunks/include/HouseChoiceInfoMenu.h
___________________________________________________________________
Name: svn:eol-style
+ native
Added: branches/dunks/include/HouseChoiceMenu.h
===================================================================
--- branches/dunks/include/HouseChoiceMenu.h (rev 0)
+++ branches/dunks/include/HouseChoiceMenu.h 2008-04-28 00:37:49 UTC (rev 174)
@@ -0,0 +1,29 @@
+#ifndef HOUSECHOICEMENU_H_INCLUDED
+#define HOUSECHOICEMENU_H_INCLUDED
+
+#include "MenuBase.h"
+
+class TranspButton;
+class VBox;
+
+class HouseChoiceMenuState : public MenuBaseState {
+public:
+ HouseChoiceMenuState();
+ ~HouseChoiceMenuState();
+
+ int Execute(float dt);
+ virtual const char* GetName() { return "HouseChoiceMenuState"; }
+
+
+private:
+ void doAtreides();
+ void doOrdos();
+ void doHarkonnen();
+ VBox* m_vbox;
+
+ TranspButton* m_butAtreides;
+ TranspButton* m_butOrdos;
+ TranspButton* m_butHarkonnen;
+};
+
+#endif // HOUSECHOICEMENU_H_INCLUDED
Property changes on: branches/dunks/include/HouseChoiceMenu.h
___________________________________________________________________
Name: svn:eol-style
+ native
Added: branches/dunks/include/MentatMenu.h
===================================================================
--- branches/dunks/include/MentatMenu.h (rev 0)
+++ branches/dunks/include/MentatMenu.h 2008-04-28 00:37:49 UTC (rev 174)
@@ -0,0 +1,43 @@
+#ifndef MENTATMENU_H_INCLUDED
+#define MENTATMENU_H_INCLUDED
+
+#include "MenuBase.h"
+#include "houses.h"
+#include "gui2/Button.h"
+#include "gui2/VBox.h"
+
+#include "SDL.h"
+
+class MentatMenuState : public MenuBaseState
+{
+ public:
+ MentatMenuState(HOUSETYPE newHouse);
+ ~MentatMenuState();
+
+/* void DrawSpecificStuff();
+
+ void setText(std::string text) {
+ TextLabel.SetText(text.c_str());
+ TextLabel.SetVisible(true);
+ TextLabel.Resize(620,120);
+ }*/
+ int Execute(float dt);
+ virtual const char* GetName() { return "MentatMenuState"; }
+
+ protected:
+ HOUSETYPE house;
+ ImagePtr m_surf;
+ VBox* m_vbox;
+// void initMenuState(HOUSETYPE newHouse);
+
+/* StaticContainer WindowWidget;
+ AnimationLabel eyesAnim;
+ AnimationLabel mouthAnim;
+ AnimationLabel specialAnim;
+ AnimationLabel shoulderAnim;
+ Label TextLabel;
+*/
+};
+
+#endif // MENTATMENU_H_INCLUDED
+
Property changes on: branches/dunks/include/MentatMenu.h
___________________________________________________________________
Name: svn:eol-style
+ native
Added: branches/dunks/src/HouseChoiceInfoMenu.cpp
===================================================================
--- branches/dunks/src/HouseChoiceInfoMenu.cpp (rev 0)
+++ branches/dunks/src/HouseChoiceInfoMenu.cpp 2008-04-28 00:37:49 UTC (rev 174)
@@ -0,0 +1,35 @@
+#include "HouseChoiceInfoMenu.h"
+
+#include "Application.h"
+#include "Settings.h"
+#include "DataCache.h"
+#include "pakfile/Cpsfile.h"
+#include "boost/bind.hpp"
+
+HouseChoiceInfoMenuState::HouseChoiceInfoMenuState(HOUSETYPE newHouse) : MentatMenuState(HOUSE_SARDAUKAR)
+{
+
+ m_butYes = new GraphicButton(DataCache::Instance()->getGuiPic(UI_MentatYes)->getResized(2), DataCache::Instance()->getGuiPic(UI_MentatYes_Pressed)->getResized(2));
+ m_vbox->addChild(m_butYes);
+
+ m_vbox->fit(2);
+ m_vbox->setPosition(UPoint(336,366));
+ m_vbox->reshape();
+
+ m_container->addChild(m_vbox);
+
+ m_vbox = new VBox();
+
+ m_butNo = new GraphicButton(DataCache::Instance()->getGuiPic(UI_MentatNo)->getResized(2), DataCache::Instance()->getGuiPic(UI_MentatNo_Pressed)->getResized(2));
+ m_vbox->addChild(m_butNo);
+
+ m_vbox->fit(2);
+ m_vbox->setPosition(UPoint(480,366));
+ m_vbox->reshape();
+
+ m_container->addChild(m_vbox);
+}
+
+HouseChoiceInfoMenuState::~HouseChoiceInfoMenuState()
+{
+}
Property changes on: branches/dunks/src/HouseChoiceInfoMenu.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Added: branches/dunks/src/HouseChoiceMenu.cpp
===================================================================
--- branches/dunks/src/HouseChoiceMenu.cpp (rev 0)
+++ branches/dunks/src/HouseChoiceMenu.cpp 2008-04-28 00:37:49 UTC (rev 174)
@@ -0,0 +1,120 @@
+#include "HouseChoiceMenu.h"
+#include "HouseChoiceInfoMenu.h"
+
+#include "DataCache.h"
+#include "Application.h"
+#include "DataCache.h"
+#include "boost/bind.hpp"
+#include <iostream>
+#include "gui2/Button.h"
+#include "gui2/VBox.h"
+HouseChoiceMenuState::HouseChoiceMenuState() : MenuBaseState()
+{
+ m_menuBackground.reset(DataCache::Instance()->getGuiPic(UI_HouseChoiceBackground).get());
+ m_menuBackground = m_menuBackground->getResized(2);
+
+ m_vbox = new VBox();
+
+ m_butAtreides = new TranspButton(163,182);
+ m_butAtreides->onClick.connect(
+ boost::bind(&HouseChoiceMenuState::doAtreides, this) );
+
+ m_vbox->addChild(m_butAtreides);
+
+ m_vbox->fit(2);
+ m_vbox->setPosition(UPoint(40,135));
+ m_vbox->reshape();
+
+ m_container->addChild(m_vbox);
+
+ m_vbox = new VBox();
+
+ m_butOrdos = new TranspButton(163,182);
+ m_butOrdos->onClick.connect(
+ boost::bind(&HouseChoiceMenuState::doOrdos, this) );
+
+ m_vbox->addChild(m_butOrdos);
+
+ m_vbox->fit(2);
+ m_vbox->setPosition(UPoint(235,135));
+ m_vbox->reshape();
+
+ m_container->addChild(m_vbox);
+
+ m_vbox = new VBox();
+
+ m_butHarkonnen = new TranspButton(163,182);
+ m_butHarkonnen->onClick.connect(
+ boost::bind(&HouseChoiceMenuState::doHarkonnen, this) );
+
+ m_vbox->addChild(m_butHarkonnen);
+
+ m_vbox->fit(2);
+ m_vbox->setPosition(UPoint(430,135));
+ m_vbox->reshape();
+
+ m_container->addChild(m_vbox);
+
+}
+
+HouseChoiceMenuState::~HouseChoiceMenuState() {
+}
+
+int HouseChoiceMenuState::Execute(float dt)
+{
+ m_menuBackground.get()->blitToScreen(SPoint(Settings::Instance()->GetWidth() / 2 - m_menuBackground->getSurface()->w/2,
+ Settings::Instance()->GetHeight() / 16));
+
+ return 0;
+}
+
+void HouseChoiceMenuState::doAtreides() {
+ std::cout << "ATREIDES!!" << std::endl;
+ mp_parent->PushState( new HouseChoiceInfoMenuState(HOUSE_ATREIDES) );
+/* HouseChoiceInfoMenu* myHouseChoiceInfoMenu = new HouseChoiceInfoMenu(HOUSE_ATREIDES);
+ if(myHouseChoiceInfoMenu == NULL) {
+ perror("HouseChoiceMenu::OnAtreides()");
+ exit(EXIT_FAILURE);
+ }
+ if(myHouseChoiceInfoMenu->showMenu() == -1) {
+ quit(-1);
+ } else {
+ quit(HOUSE_ATREIDES);
+ }
+ delete myHouseChoiceInfoMenu;*/
+}
+
+void HouseChoiceMenuState::doOrdos() {
+ std::cout << "ORDOS!!" << std::endl;
+
+ mp_parent->PushState( new HouseChoiceInfoMenuState(HOUSE_ORDOS) );
+/* HouseChoiceInfoMenu* myHouseChoiceInfoMenu = new HouseChoiceInfoMenu(HOUSE_ORDOS);
+ if(myHouseChoiceInfoMenu == NULL) {
+ perror("HouseChoiceMenu::OnOrdos()");
+ exit(EXIT_FAILURE);
+ }
+ if(myHouseChoiceInfoMenu->showMenu() == -1) {
+ quit(-1);
+ } else {
+ quit(HOUSE_ORDOS);
+ }
+ delete myHouseChoiceInfoMenu;*/
+}
+
+void HouseChoiceMenuState::doHarkonnen() {
+ std::cout << "HARKONNEN!!" << std::endl;
+
+ mp_parent->PushState( new HouseChoiceInfoMenuState(HOUSE_HARKONNEN) );
+/* HouseChoiceInfoMenu* myHouseChoiceInfoMenu = new HouseChoiceInfoMenu(HOUSE_HARKONNEN);
+ if(myHouseChoiceInfoMenu == NULL) {
+ perror("HouseChoiceMenu::OnHarkonnen()");
+ exit(EXIT_FAILURE);
+ }
+ if(myHouseChoiceInfoMenu->showMenu() == -1) {
+ quit(-1);
+ } else {
+ quit(HOUSE_HARKONNEN);
+ }
+ delete myHouseChoiceInfoMenu;*/
+}
+
Property changes on: branches/dunks/src/HouseChoiceMenu.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Added: branches/dunks/src/MentatMenu.cpp
===================================================================
--- branches/dunks/src/MentatMenu.cpp (rev 0)
+++ branches/dunks/src/MentatMenu.cpp 2008-04-28 00:37:49 UTC (rev 174)
@@ -0,0 +1,139 @@
+#include "MentatMenu.h"
+
+#include "Application.h"
+#include "Settings.h"
+#include "DataCache.h"
+#include "pakfile/Cpsfile.h"
+#include "boost/bind.hpp"
+
+MentatMenuState::MentatMenuState(HOUSETYPE newHouse)
+{
+ house = newHouse;
+ Image * mentat = DataCache::Instance()->getGuiPic(UI_MentatBackground, newHouse).get();
+ m_surf.reset(mentat);
+ m_surf = m_surf->getResized(2);
+
+ m_vbox = new VBox();
+/* m_butYes = new GraphicButton(DataCache::Instance()->getGuiPic(UI_MentatYes)->getResized(2), DataCache::Instance()->getGuiPic(UI_MentatYes_Pressed)->getResized(2));
+ m_vbox->addChild(m_butYes);
+
+ m_vbox->fit(2);
+ m_vbox->setPosition(UPoint(336,366));
+ m_vbox->reshape();
+
+ m_container->addChild(m_vbox);
+
+ m_vbox = new VBox();
+ m_butNo = new GraphicButton(DataCache::Instance()->getGuiPic(UI_MentatNo)->getResized(2), DataCache::Instance()->getGuiPic(UI_MentatNo_Pressed)->getResized(2));
+ m_vbox->addChild(m_butNo);
+
+ m_vbox->fit(2);
+ m_vbox->setPosition(UPoint(480,366));
+ m_vbox->reshape();
+
+ m_container->addChild(m_vbox);*/
+
+/*
+ // set up window
+ SDL_Surface *surf;
+ surf = pDataManager->getUIGraphic(UI_MentatBackground,house);
+
+ SetBackground(surf,false);
+
+ int xpos = std::max(0,(screen->w - surf->w)/2);
+ int ypos = std::max(0,(screen->h - surf->h)/2);
+
+ SetCurrentPosition(xpos,ypos,surf->w,surf->h);
+
+ SetWindowWidget(&WindowWidget);
+
+ switch(house) {
+ case HOUSE_ATREIDES:
+ case HOUSE_FREMEN:
+ anim = pDataManager->getAnimation(Anim_AtreidesEyes);
+ eyesAnim.SetAnimation(anim);
+ WindowWidget.AddWidget(&eyesAnim,Point(80,160),Point(anim->getFrame()->w,anim->getFrame()->h));
+
+ anim = pDataManager->getAnimation(Anim_AtreidesMouth);
+ mouthAnim.SetAnimation(anim);
+ WindowWidget.AddWidget(&mouthAnim,Point(80,192),Point(anim->getFrame()->w,anim->getFrame()->h));
+
+ anim = pDataManager->getAnimation(Anim_AtreidesBook);
+ specialAnim.SetAnimation(anim);
+ WindowWidget.AddWidget(&specialAnim,Point(145,305),Point(anim->getFrame()->w,anim->getFrame()->h));
+
+ anim = pDataManager->getAnimation(Anim_AtreidesShoulder);
+ shoulderAnim.SetAnimation(anim);
+ // don't add shoulderAnim, draw it in DrawSpecificStuff
+ break;
+ case HOUSE_ORDOS:
+ case HOUSE_MERCENARY:
+ anim = pDataManager->getAnimation(Anim_OrdosEyes);
+ eyesAnim.SetAnimation(anim);
+ WindowWidget.AddWidget(&eyesAnim,Point(32,160),Point(anim->getFrame()->w,anim->getFrame()->h));
+
+ anim = pDataManager->getAnimation(Anim_OrdosMouth);
+ mouthAnim.SetAnimation(anim);
+ WindowWidget.AddWidget(&mouthAnim,Point(32,192),Point(anim->getFrame()->w,anim->getFrame()->h));
+
+ anim = pDataManager->getAnimation(Anim_OrdosRing);
+ specialAnim.SetAnimation(anim);
+ WindowWidget.AddWidget(&specialAnim,Point(178,289),Point(anim->getFrame()->w,anim->getFrame()->h));
+
+ anim = pDataManager->getAnimation(Anim_OrdosShoulder);
+ shoulderAnim.SetAnimation(anim);
+ // don't add shoulderAnim, draw it in DrawSpecificStuff
+ break;
+ case HOUSE_HARKONNEN:
+ case HOUSE_SARDAUKAR:
+ default:
+ anim = pDataManager->getAnimation(Anim_HarkonnenEyes);
+ eyesAnim.SetAnimation(anim);
+ WindowWidget.AddWidget(&eyesAnim,Point(64,176),Point(anim->getFrame()->w,anim->getFrame()->h));
+
+ anim = pDataManager->getAnimation(Anim_HarkonnenMouth);
+ mouthAnim.SetAnimation(anim);
+ WindowWidget.AddWidget(&mouthAnim,Point(64,208),Point(anim->getFrame()->w,anim->getFrame()->h));
+
+ anim = pDataManager->getAnimation(Anim_HarkonnenShoulder);
+ shoulderAnim.SetAnimation(anim);
+ // don't add shoulderAnim, draw it in DrawSpecificStuff
+ break;
+ }
+
+ TextLabel.SetTextColor(255);
+ TextLabel.SetVisible(false);*/
+}
+
+MentatMenuState::~MentatMenuState() {
+}
+
+int MentatMenuState::Execute(float dt)
+{
+ m_surf.get()->blitToScreen(SPoint(Settings::Instance()->GetWidth() / 2 - m_surf->getSurface()->w/2,
+ Settings::Instance()->GetHeight() / 16));
+
+ return 0;
+}
+
+/*void MentatMenu::DrawSpecificStuff() {
+ Point shoulderPos;
+ switch(house) {
+ case HOUSE_ATREIDES:
+ case HOUSE_FREMEN: {
+ shoulderPos = Point(256,257) + GetPosition();
+ } break;
+ case HOUSE_ORDOS:
+ case HOUSE_MERCENARY: {
+ shoulderPos = Point(256,257) + GetPosition();
+ } break;
+ case HOUSE_HARKONNEN:
+ case HOUSE_SARDAUKAR:
+ default: {
+ shoulderPos = Point(256,209) + GetPosition();
+ } break;
+ }
+
+ shoulderAnim.Draw(screen,shoulderPos);
+ TextLabel.Draw(screen,Point(10,5) + GetPosition());
+}*/
Property changes on: branches/dunks/src/MentatMenu.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/dunks/src/SingleMenu.cpp
===================================================================
--- branches/dunks/src/SingleMenu.cpp 2008-04-27 23:47:23 UTC (rev 173)
+++ branches/dunks/src/SingleMenu.cpp 2008-04-28 00:37:49 UTC (rev 174)
@@ -1,8 +1,10 @@
#include "SingleMenu.h"
#include "Application.h"
+#include "houses.h"
//#include "DataFile.h"
#include "Settings.h"
+#include "HouseChoiceMenu.h"
#include "boost/bind.hpp"
@@ -17,7 +19,7 @@
m_butCampaign = new BoringButton("Campaign");
m_butCampaign->setSize(SPoint(bw, bh));
m_butCampaign->onClick.connect(
- boost::bind(&SingleMenuState::doSkirmish, this) );
+ boost::bind(&SingleMenuState::doCampaign, this) );
m_vbox->addChild(m_butCampaign);
@@ -69,6 +71,12 @@
delete m_vbox;
}
+void SingleMenuState::doCampaign()
+{
+ printf("Campaign\n");
+ mp_parent->PushState( new HouseChoiceMenuState() );
+
+}
void SingleMenuState::doSkirmish()
{
printf("Skirmish\n");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dv...@us...> - 2008-04-28 00:38:31
|
Revision: 175
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=175&view=rev
Author: dvalin
Date: 2008-04-27 17:38:26 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
remove these in favour of new house choice menus..
Removed Paths:
-------------
branches/dunks/include/CampaignMenu.h
branches/dunks/src/CampaignMenu.cpp
Deleted: branches/dunks/include/CampaignMenu.h
===================================================================
--- branches/dunks/include/CampaignMenu.h 2008-04-28 00:37:49 UTC (rev 174)
+++ branches/dunks/include/CampaignMenu.h 2008-04-28 00:38:26 UTC (rev 175)
@@ -1,30 +0,0 @@
-#ifndef DUNE_CAMPAIGNMENU_H
-#define DUNE_CAMPAIGNMENU_H
-
-#include "MenuBase.h"
-#include "gui2/Button.h"
-#include "gui2/VBox.h"
-
-#include "SDL.h"
-
-
-class CampaignMenuState : public MenuBaseState
-{
- public:
- CampaignMenuState();
- ~CampaignMenuState();
-
- void doCancel();
-
- int Execute(float dt);
- virtual const char* GetName() { return "CampaignMenuState"; }
-
- private:
- VBox* m_vbox;
-
- BoringButton* m_butCancel;
- ImagePtr m_surf;
-
-};
-
-#endif // DUNE_CAMPAIGNMENU_H
Deleted: branches/dunks/src/CampaignMenu.cpp
===================================================================
--- branches/dunks/src/CampaignMenu.cpp 2008-04-28 00:37:49 UTC (rev 174)
+++ branches/dunks/src/CampaignMenu.cpp 2008-04-28 00:38:26 UTC (rev 175)
@@ -1,39 +0,0 @@
-#include "CampaignMenu.h"
-
-#include "Application.h"
-#include "Settings.h"
-#include "DataCache.h"
-#include "pakfile/Cpsfile.h"
-#include "boost/bind.hpp"
-
-
-CampaignMenuState::CampaignMenuState()
-{
- int len;
- unsigned char * data = ResMan::Instance()->readFile("ENGLISH:HERALD.ENG", &len);
-
- CpsfilePtr m_cps (new Cpsfile(data, len));
-
- m_surf.reset(m_cps->getPicture());
- m_surf = m_surf->getResized(2);
-
-}
-
-CampaignMenuState::~CampaignMenuState()
-{
-}
-
-void CampaignMenuState::doCancel()
-{
- assert(mp_parent != NULL);
- PopState();
-}
-
-int CampaignMenuState::Execute(float dt)
-{
- m_surf.get()->blitToScreen(SPoint(Settings::Instance()->GetWidth() / 2 - m_surf->getSurface()->w/2,
- Settings::Instance()->GetHeight() / 8));
-
- return 0;
-}
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dv...@us...> - 2008-04-28 18:01:26
|
Revision: 176
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=176&view=rev
Author: dvalin
Date: 2008-04-28 11:00:53 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
add support for animations (merged from richies branch)
Modified Paths:
--------------
branches/dunks/include/pakfile/Wsafile.h
branches/dunks/src/pakfile/Wsafile.cpp
Added Paths:
-----------
branches/dunks/include/pakfile/Animation.h
branches/dunks/src/pakfile/Animation.cpp
Added: branches/dunks/include/pakfile/Animation.h
===================================================================
--- branches/dunks/include/pakfile/Animation.h (rev 0)
+++ branches/dunks/include/pakfile/Animation.h 2008-04-28 18:00:53 UTC (rev 176)
@@ -0,0 +1,33 @@
+#ifndef ANIMATION_H_INCLUDED
+#define ANIMATION_H_INCLUDED
+
+#include <SDL.h>
+#include "Gfx.h"
+
+class Animation
+{
+public:
+ Animation();
+ ~Animation();
+
+ Image * getFrame();
+ void setFrameRate(double FrameRate) {
+ if(FrameRate == 0.0) {
+ FrameDurationTime = 1;
+ } else {
+ FrameDurationTime = (int) (1000.0/FrameRate);
+ }
+ }
+
+ void addFrame(Image * newFrame, bool SetColorKey = false);
+
+private:
+ Uint32 CurFrameStartTime;
+ Uint32 FrameDurationTime;
+ int curFrame;
+ int NumFrames;
+ Image ** Frame;
+};
+
+#endif // ANIMATION_H_INCLUDED
+
Property changes on: branches/dunks/include/pakfile/Animation.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/dunks/include/pakfile/Wsafile.h
===================================================================
--- branches/dunks/include/pakfile/Wsafile.h 2008-04-28 00:38:26 UTC (rev 175)
+++ branches/dunks/include/pakfile/Wsafile.h 2008-04-28 18:00:53 UTC (rev 176)
@@ -3,6 +3,7 @@
#include "Gfx.h"
#include "pakfile/Decode.h"
+#include "pakfile/Animation.h"
#include "SDL.h"
#include <boost/shared_ptr.hpp>
@@ -20,6 +21,8 @@
Image * getPicture(Uint32 FrameNumber, SDL_Palette *palette);
+ Animation* getAnimation(unsigned int startindex, unsigned int endindex, SDL_Palette *palette, bool SetColorKey=true);
+
inline int getNumFrames() { return (int) NumFrames; };
inline Uint32 getFramesPer1024ms() { return FramesPer1024ms; };
inline float getFPS() { return fps; }
Added: branches/dunks/src/pakfile/Animation.cpp
===================================================================
--- branches/dunks/src/pakfile/Animation.cpp (rev 0)
+++ branches/dunks/src/pakfile/Animation.cpp 2008-04-28 18:00:53 UTC (rev 176)
@@ -0,0 +1,49 @@
+#include "pakfile/Animation.h"
+#include <stdio.h>
+#include <stdlib.h>
+Animation::Animation() {
+ CurFrameStartTime = SDL_GetTicks();
+ FrameDurationTime = 1;
+ NumFrames = 0;
+ curFrame = 0;
+ Frame = NULL;
+}
+
+Animation::~Animation() {
+ if(Frame != NULL) {
+ for(int i=0; i < NumFrames; i++) {
+ SDL_FreeSurface(Frame[i]->getSurface());
+// Frame[i] = NULL;
+ }
+ free(Frame);
+ }
+}
+
+Image * Animation::getFrame() {
+ if(Frame == NULL) {
+ return NULL;
+ }
+
+ if((SDL_GetTicks() - CurFrameStartTime) > FrameDurationTime) {
+ CurFrameStartTime = SDL_GetTicks();
+ curFrame++;
+ if(curFrame >= NumFrames) {
+ curFrame = 0;
+ }
+ }
+ return Frame[curFrame];
+}
+
+void Animation::addFrame(Image * newFrame, bool SetColorKey) {
+ if((Frame = (Image **) realloc(Frame,sizeof(Image *) * (NumFrames+1))) == NULL) {
+ perror("Animation::addFrame()");
+ exit(EXIT_FAILURE);
+ }
+
+ Frame[NumFrames] = newFrame;
+
+ if(SetColorKey == true) {
+ SDL_SetColorKey((Frame[NumFrames])->getSurface(), SDL_SRCCOLORKEY | SDL_RLEACCEL, 0);
+ }
+ NumFrames++;
+}
Property changes on: branches/dunks/src/pakfile/Animation.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/dunks/src/pakfile/Wsafile.cpp
===================================================================
--- branches/dunks/src/pakfile/Wsafile.cpp 2008-04-28 00:38:26 UTC (rev 175)
+++ branches/dunks/src/pakfile/Wsafile.cpp 2008-04-28 18:00:53 UTC (rev 176)
@@ -110,6 +110,36 @@
}
+/// Returns an animation
+/**
+ This method returns a new animation object with all pictures from startindex to endindex
+ in it. The returned pointer should be freed with delete if no longer needed. If an error
+ occured, NULL is returned.
+ \param startindex index of the first picture
+ \param endindex index of the last picture
+ \param DoublePic if true, the picture is scaled up by a factor of 2
+ \param SetColorKey if true, black is set as transparency
+ \return a new animation object or NULL on error
+*/
+Animation* Wsafile::getAnimation(unsigned int startindex, unsigned int endindex, SDL_Palette *palette, bool SetColorKey)
+{
+ Animation* tmpAnimation;
+ Image* tmp;
+
+ if((tmpAnimation = new Animation()) == NULL) {
+ return NULL;
+ }
+
+ for(unsigned int i = startindex; i <= endindex; i++) {
+ if((tmp = getPicture(i, palette)) == NULL) {
+ delete tmpAnimation;
+ return NULL;
+ }
+ tmpAnimation->addFrame(tmp,SetColorKey);
+ }
+ return tmpAnimation;
+}
+
void Wsafile::decodeFrames()
{
unsigned char *dec80;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dv...@us...> - 2008-04-28 18:17:20
|
Revision: 177
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=177&view=rev
Author: dvalin
Date: 2008-04-28 11:15:06 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
add animation label
Modified Paths:
--------------
branches/dunks/include/gui2/Label.h
branches/dunks/src/gui2/Label.cpp
Modified: branches/dunks/include/gui2/Label.h
===================================================================
--- branches/dunks/include/gui2/Label.h 2008-04-28 18:00:53 UTC (rev 176)
+++ branches/dunks/include/gui2/Label.h 2008-04-28 18:15:06 UTC (rev 177)
@@ -1,7 +1,8 @@
-#ifndef DUNE_GUI2_LABEL_H
+#ifndef DUNE_GUI2_LABEL_H
#define DUNE_GUI2_LABEL_H
#include "gui2/Widget.h"
+#include "pakfile/Animation.h"
#include <string>
/* Label widget using dune's fonts
@@ -30,4 +31,18 @@
std::string m_caption;
};
+class AnimationLabel : public Widget
+{
+ public:
+ AnimationLabel(Animation* pAnim);
+
+ ~AnimationLabel();
+
+
+ virtual void draw(Image * dest, SPoint off);
+
+ private:
+ Animation* m_anim;
+
+};
#endif //DUNE_GUI2_LABEL_H
Modified: branches/dunks/src/gui2/Label.cpp
===================================================================
--- branches/dunks/src/gui2/Label.cpp 2008-04-28 18:00:53 UTC (rev 176)
+++ branches/dunks/src/gui2/Label.cpp 2008-04-28 18:15:06 UTC (rev 177)
@@ -39,3 +39,21 @@
m_surface->blitTo(dest, UPoint(off.x + x, off.y + y));
}
+
+AnimationLabel::AnimationLabel(Animation* pAnim)
+{
+ m_anim = pAnim;
+}
+
+AnimationLabel::~AnimationLabel()
+{
+
+}
+void AnimationLabel::draw(Image * screen, SPoint off)
+{
+ if (!m_visible) return;
+
+ Image * surface = m_anim->getFrame();
+
+ screen->blitFrom(surface->getResized(2).get(), UPoint(off.x + x, off.y + y));
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dv...@us...> - 2008-04-28 18:20:26
|
Revision: 178
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=178&view=rev
Author: dvalin
Date: 2008-04-28 11:19:15 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
add animated planet graphic
Modified Paths:
--------------
branches/dunks/include/HouseChoiceInfoMenu.h
branches/dunks/src/HouseChoiceInfoMenu.cpp
Modified: branches/dunks/include/HouseChoiceInfoMenu.h
===================================================================
--- branches/dunks/include/HouseChoiceInfoMenu.h 2008-04-28 18:15:06 UTC (rev 177)
+++ branches/dunks/include/HouseChoiceInfoMenu.h 2008-04-28 18:19:15 UTC (rev 178)
@@ -2,6 +2,8 @@
#define HOUSECHOICEINFOMENU_H_INCLUDED
#include "MentatMenu.h"
+class GraphicButton;
+class AnimationLabel;
class HouseChoiceInfoMenuState : public MentatMenuState {
public:
HouseChoiceInfoMenuState(HOUSETYPE newHouse);
@@ -11,7 +13,8 @@
private:
GraphicButton* m_butYes;
- GraphicButton* m_butNo;
+ GraphicButton* m_butNo;
+ AnimationLabel* m_planetAnimation;
};
#endif // HOUSECHOICEINFOMENU_H_INCLUDED
Modified: branches/dunks/src/HouseChoiceInfoMenu.cpp
===================================================================
--- branches/dunks/src/HouseChoiceInfoMenu.cpp 2008-04-28 18:15:06 UTC (rev 177)
+++ branches/dunks/src/HouseChoiceInfoMenu.cpp 2008-04-28 18:19:15 UTC (rev 178)
@@ -5,29 +5,39 @@
#include "DataCache.h"
#include "pakfile/Cpsfile.h"
#include "boost/bind.hpp"
+#include "pakfile/Animation.h"
+#include "gui2/Label.h"
+#include "gui2/Button.h"
HouseChoiceInfoMenuState::HouseChoiceInfoMenuState(HOUSETYPE newHouse) : MentatMenuState(HOUSE_SARDAUKAR)
{
+ int len;
+ uint8_t * data;
+ if (newHouse == HOUSE_ATREIDES)
+ data = ResMan::Instance()->readFile("MENTAT:FARTR.WSA", &len);
+ else if (newHouse == HOUSE_ORDOS)
+ data = ResMan::Instance()->readFile("MENTAT:FORDOS.WSA", &len);
+ else if (newHouse == HOUSE_HARKONNEN)
+ data = ResMan::Instance()->readFile("MENTAT:FHARK.WSA", &len);
+ SDL_Palette* palette = Application::Instance()->Screen()->getSurface()->format->palette;
- m_butYes = new GraphicButton(DataCache::Instance()->getGuiPic(UI_MentatYes)->getResized(2), DataCache::Instance()->getGuiPic(UI_MentatYes_Pressed)->getResized(2));
- m_vbox->addChild(m_butYes);
+ WsafilePtr m_wsa (new Wsafile(data, len));
- m_vbox->fit(2);
- m_vbox->setPosition(UPoint(336,366));
- m_vbox->reshape();
-
- m_container->addChild(m_vbox);
+ Animation* ret = m_wsa->getAnimation(0, m_wsa->getNumFrames() - 1, palette, false);
+ ret->setFrameRate(12);
+
+ m_planetAnimation = new AnimationLabel(ret);
+ m_planetAnimation->setPosition(UPoint(256,127));
+ m_container->addChild(m_planetAnimation);
- m_vbox = new VBox();
+ m_butYes = new GraphicButton(DataCache::Instance()->getGuiPic(UI_MentatYes)->getResized(2), DataCache::Instance()->getGuiPic(UI_MentatYes_Pressed)->getResized(2));
+ m_butYes->setPosition(UPoint(336,366));
+ m_container->addChild(m_butYes);
m_butNo = new GraphicButton(DataCache::Instance()->getGuiPic(UI_MentatNo)->getResized(2), DataCache::Instance()->getGuiPic(UI_MentatNo_Pressed)->getResized(2));
- m_vbox->addChild(m_butNo);
+ m_butNo->setPosition(UPoint(480,366));
+ m_container->addChild(m_butNo);
- m_vbox->fit(2);
- m_vbox->setPosition(UPoint(480,366));
- m_vbox->reshape();
-
- m_container->addChild(m_vbox);
}
HouseChoiceInfoMenuState::~HouseChoiceInfoMenuState()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dv...@us...> - 2008-04-28 18:33:32
|
Revision: 179
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=179&view=rev
Author: dvalin
Date: 2008-04-28 11:32:48 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
rename to more consistent name
Added Paths:
-----------
branches/dunks/include/pakfile/Stringfile.h
branches/dunks/src/pakfile/Stringfile.cpp
Copied: branches/dunks/include/pakfile/Stringfile.h (from rev 167, branches/dunks/include/pakfile/StringFile.h)
===================================================================
--- branches/dunks/include/pakfile/Stringfile.h (rev 0)
+++ branches/dunks/include/pakfile/Stringfile.h 2008-04-28 18:32:48 UTC (rev 179)
@@ -0,0 +1,50 @@
+#ifndef STRINGFILE_H_INCLUDED
+#define STRINGFILE_H_INCLUDED
+
+#include <string>
+
+
+#define MISSION_DESCRIPTION 0
+#define MISSION_WIN 1
+#define MISSION_LOSE 2
+#define MISSION_ADVICE 3
+
+
+/// A class for loading a encoded textfiles.
+/**
+ This class can read encoded textfiles and return their content in decoded ANSI Code.
+*/
+class StringFile
+{
+public:
+ StringFile(std::string stringFileName);
+ ~StringFile();
+
+ /// This method returns the briefing/debriefing text.
+ /**
+ This method returns the briefing/debriefing text for the mission specified by the parameter mission. The second
+ parameter specifies the kind of briefing/debriefing.
+ \param mission the mission number (0=House description; 1,2,...,9 = mission description).
+ \param texttype one of MISSION_DESCRIPTION, MISSION_WIN, MISSION_LOSE, MISSION_ADVICE
+ \return the text for this mission and of this type.
+ */
+ std::string getString(unsigned int mission, unsigned int texttype) {
+ int index = mission*4+texttype;
+
+ if(index < numStrings) {
+ return stringArray[index];
+ } else {
+ return "StringFile::getString(): mission number or text type is invalid!\n";
+ }
+ }
+ std::string getString(int i){
+ return stringArray[i];
+ }
+
+private:
+ std::string decodeString(std::string text);
+ std::string *stringArray;
+ int numStrings;
+};
+
+#endif // STRINGFILE_H_INCLUDED
Copied: branches/dunks/src/pakfile/Stringfile.cpp (from rev 167, branches/dunks/src/pakfile/StringFile.cpp)
===================================================================
--- branches/dunks/src/pakfile/Stringfile.cpp (rev 0)
+++ branches/dunks/src/pakfile/Stringfile.cpp 2008-04-28 18:32:48 UTC (rev 179)
@@ -0,0 +1,261 @@
+#include "pakfile/StringFile.h"
+#include "ResMan.h"
+#include <SDL_endian.h>
+#include <SDL.h>
+#include <SDL_rwops.h>
+#include <iostream>
+#include <string>
+
+StringFile::StringFile(std::string stringFileName) {
+ int bufsize;
+ unsigned char* bufFiledata = ResMan::Instance()->readFile(stringFileName.c_str(), &bufsize);
+ Uint16* index;
+ SDL_RWops* RWop = SDL_RWFromMem(bufFiledata, bufsize);
+
+ if(RWop == NULL) {
+ fprintf(stderr, "StringFile: RWop == NULL!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if(bufsize <= 0) {
+ fprintf(stderr,"StringFile: Cannot determine size!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if(bufsize < 2) {
+ fprintf(stderr, "StringFile: Invalid string file: File too small!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if(SDL_RWseek(RWop,0,SEEK_SET) != 0) {
+ fprintf(stderr,"StringFile: Seeking string file failed!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if( (bufFiledata = (unsigned char*) malloc(bufsize)) == NULL) {
+ fprintf(stderr,"StringFile: Allocating memory failed!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if(SDL_RWread(RWop, bufFiledata, bufsize, 1) != 1) {
+ fprintf(stderr,"StringFile: Reading string file failed!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ numStrings = ((int)SDL_SwapLE16(((Uint16*) bufFiledata)[0]))/2 - 1;
+ index = (Uint16*) bufFiledata;
+ for(int i=0; i <= numStrings; i++) {
+ index[i] = SDL_SwapLE16(index[i]);
+ }
+
+ stringArray = new std::string[numStrings];
+
+ for(int i=0; i < numStrings;i++) {
+ std::string tmp = (const char*) (bufFiledata+index[i]);
+ stringArray[i] = decodeString(tmp);
+ }
+
+ free(bufFiledata);
+ SDL_RWclose(RWop);
+}
+
+StringFile::~StringFile() {
+ delete [] stringArray;
+}
+
+/// This methode decodes a string to ANSI Code
+/**
+ The parameter text is decoded to ANSI Code and returned
+ \param text Text to decode
+ \return The decoded text
+*/
+std::string StringFile::decodeString(std::string text) {
+ std::string out = "";
+ unsigned char databyte;
+
+ for(unsigned int i = 0; i < text.length(); i++) {
+ databyte = text[i];
+
+ switch(databyte) {
+ case 0x00: break;
+ case 0x0C: out += "\n"; break;
+ case 0x0D: out += "\n"; break;
+
+ case 0x80: out += " t"; break;
+ case 0x81: out += " a"; break;
+ case 0x82: out += " s"; break;
+ case 0x83: out += " i"; break;
+ case 0x84: out += " o"; break;
+ case 0x85: out += " "; break; // maybe something else
+ case 0x86: out += " w"; break;
+ case 0x87: out += " b"; break;
+ case 0x88: out += "e "; break;
+ case 0x89: out += "er"; break;
+ case 0x8A: out += "en"; break;
+ case 0x8B: out += "es"; break;
+ case 0x8C: out += "ed"; break;
+ case 0x8D: out += "ea"; break;
+ case 0x8E: out += "el"; break;
+ case 0x8F: out += "em"; break;
+
+ case 0x90: out += "th"; break;
+ case 0x91: out += "t "; break;
+ case 0x92: out += "ti"; break;
+ case 0x93: out += "te"; break;
+ case 0x94: out += "to"; break;
+ case 0x95: out += "tr"; break;
+ case 0x96: out += "ta"; break;
+ case 0x97: out += "ts"; break;
+ case 0x98: out += "an"; break;
+ case 0x99: out += "ar"; break;
+ case 0x9A: out += "at"; break;
+ case 0x9B: out += "al"; break;
+ case 0x9C: out += "ac"; break;
+ case 0x9D: out += "a "; break;
+ case 0x9E: out += "as"; break;
+ case 0x9F: out += "ay"; break;
+
+ case 0xA0: out += "in"; break;
+ case 0xA1: out += "is"; break;
+ case 0xA2: out += "it"; break;
+ case 0xA3: out += "ic"; break;
+ case 0xA4: out += "il"; break;
+ case 0xA5: out += "io"; break;
+ case 0xA6: out += "ie"; break;
+ case 0xA7: out += "ir"; break;
+ case 0xA8: out += "n "; break;
+ case 0xA9: out += "nd"; break;
+ case 0xAA: out += "nt"; break;
+ case 0xAB: out += "ng"; break;
+ case 0xAC: out += "ne"; break;
+ case 0xAD: out += "ns"; break;
+ case 0xAE: out += "ni"; break;
+ case 0xAF: out += "no"; break;
+
+ case 0xB0: out += "on"; break;
+ case 0xB1: out += "or"; break;
+ case 0xB2: out += "o "; break;
+ case 0xB3: out += "ou"; break;
+ case 0xB4: out += "of"; break;
+ case 0xB5: out += "om"; break;
+ case 0xB6: out += "os"; break;
+ case 0xB7: out += "ow"; break;
+ case 0xB8: out += "s "; break;
+ case 0xB9: out += "st"; break;
+ case 0xBA: out += "se"; break;
+ case 0xBB: out += "sp"; break;
+ case 0xBC: out += "s."; break;
+ case 0xBD: out += "si"; break;
+ case 0xBE: out += "sc"; break;
+ case 0xBF: out += "sa"; break;
+
+ case 0xC0: out += "re"; break;
+ case 0xC1: out += "r "; break;
+ case 0xC2: out += "ro"; break;
+ case 0xC3: out += "ri"; break;
+ case 0xC4: out += "ra"; break;
+ case 0xC5: out += "rd"; break;
+ case 0xC6: out += "ru"; break;
+ case 0xC7: out += "rr"; break;
+ case 0xC8: out += "l "; break;
+ case 0xC9: out += "ll"; break;
+ case 0xCA: out += "la"; break;
+ case 0xCB: out += "le"; break;
+ case 0xCC: out += "li"; break;
+ case 0xCD: out += "le"; break;
+ case 0xCE: out += "lo"; break;
+ case 0xCF: out += "ld"; break;
+
+ case 0xD0: out += "he"; break;
+ case 0xD1: out += "hi"; break;
+ case 0xD2: out += "ha"; break;
+ case 0xD3: out += "h "; break;
+ case 0xD4: out += "ho"; break;
+ case 0xD5: out += "ht"; break;
+ case 0xD6: out += "hr"; break;
+ case 0xD7: out += "hu"; break;
+ case 0xD8: out += "ce"; break;
+ case 0xD9: out += "ct"; break;
+ case 0xDA: out += "co"; break;
+ case 0xDB: out += "ca"; break;
+ case 0xDC: out += "ck"; break;
+ case 0xDD: out += "ch"; break;
+ case 0xDE: out += "cl"; break;
+ case 0xDF: out += "cr"; break;
+
+ case 0xE0: out += "d "; break;
+ case 0xE1: out += "de"; break;
+ case 0xE2: out += "di"; break;
+ case 0xE3: out += "du"; break;
+ case 0xE4: out += "d,"; break;
+ case 0xE5: out += "d."; break;
+ case 0xE6: out += "do"; break;
+ case 0xE7: out += "da"; break;
+ case 0xE8: out += "un"; break;
+ case 0xE9: out += "us"; break;
+ case 0xEA: out += "ur"; break;
+ case 0xEB: out += "uc"; break;
+ case 0xEC: out += "ut"; break;
+ case 0xED: out += "ul"; break;
+ case 0xEE: out += "ua"; break;
+ case 0xEF: out += "ui"; break;
+
+ case 0xF0: out += "pl"; break;
+ case 0xF1: out += "pe"; break;
+ case 0xF2: out += "po"; break;
+ case 0xF3: out += "pi"; break;
+ case 0xF4: out += "pr"; break;
+ case 0xF5: out += "pa"; break;
+ case 0xF6: out += "pt"; break;
+ case 0xF7: out += "pp"; break;
+ case 0xF8: out += "me"; break;
+ case 0xF9: out += "ma"; break;
+ case 0xFA: out += "mo"; break;
+ case 0xFB: out += "mi"; break;
+ case 0xFC: out += "mp"; break;
+ case 0xFD: out += "m "; break;
+ case 0xFE: out += "mb"; break;
+ case 0xFF: out += "mm"; break;
+
+ case 0x1B: {
+ // special character
+ i++;
+ if(i == text.length()) {
+ fprintf(stderr,"StringFile:decodeString: Special character escape sequence at end of string!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ unsigned char special = text[i];
+ switch(special) {
+ // e.g. german "umlaute"
+ case 0x02: out += (unsigned char) 252 /*"ue"*/; break;
+ case 0x05: out += (unsigned char) 228 /*"ae"*/; break;
+ case 0x0F: out += (unsigned char) 197 /*"Ae"*/; break;
+ case 0x15: out += (unsigned char) 246 /*"oe"*/; break;
+ case 0x1B: out += (unsigned char) 220 /*"Ue"*/; break;
+ case 0x62: out += (unsigned char) 223 /*"ss"*/; break;
+ default: {
+ char tmp[20];
+ sprintf(tmp,"---Unknown char:%X---",special);
+ out += tmp;
+ } break;
+ };
+
+ } break;
+
+ case 0x1F: out += "."; break;
+
+ default: {
+ if((databyte & 0x80) == 0x80) {
+ char tmp[20];
+ sprintf(tmp,"---Unknown char:%X---",databyte);
+ out += tmp;
+ } else {
+ out += databyte;
+ }
+ } break;
+ }
+ }
+
+ return out;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dv...@us...> - 2008-04-28 18:37:02
|
Revision: 180
http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=180&view=rev
Author: dvalin
Date: 2008-04-28 11:36:29 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
d'oh, actually rename class name as well
Modified Paths:
--------------
branches/dunks/include/pakfile/Stringfile.h
branches/dunks/src/pakfile/Stringfile.cpp
Modified: branches/dunks/include/pakfile/Stringfile.h
===================================================================
--- branches/dunks/include/pakfile/Stringfile.h 2008-04-28 18:32:48 UTC (rev 179)
+++ branches/dunks/include/pakfile/Stringfile.h 2008-04-28 18:36:29 UTC (rev 180)
@@ -14,11 +14,11 @@
/**
This class can read encoded textfiles and return their content in decoded ANSI Code.
*/
-class StringFile
+class Stringfile
{
public:
- StringFile(std::string stringFileName);
- ~StringFile();
+ Stringfile(std::string stringfileName);
+ ~Stringfile();
/// This method returns the briefing/debriefing text.
/**
@@ -34,7 +34,7 @@
if(index < numStrings) {
return stringArray[index];
} else {
- return "StringFile::getString(): mission number or text type is invalid!\n";
+ return "Stringfile::getString(): mission number or text type is invalid!\n";
}
}
std::string getString(int i){
Modified: branches/dunks/src/pakfile/Stringfile.cpp
===================================================================
--- branches/dunks/src/pakfile/Stringfile.cpp 2008-04-28 18:32:48 UTC (rev 179)
+++ branches/dunks/src/pakfile/Stringfile.cpp 2008-04-28 18:36:29 UTC (rev 180)
@@ -1,4 +1,4 @@
-#include "pakfile/StringFile.h"
+#include "pakfile/Stringfile.h"
#include "ResMan.h"
#include <SDL_endian.h>
#include <SDL.h>
@@ -6,39 +6,39 @@
#include <iostream>
#include <string>
-StringFile::StringFile(std::string stringFileName) {
+Stringfile::Stringfile(std::string stringfileName) {
int bufsize;
unsigned char* bufFiledata = ResMan::Instance()->readFile(stringFileName.c_str(), &bufsize);
Uint16* index;
SDL_RWops* RWop = SDL_RWFromMem(bufFiledata, bufsize);
if(RWop == NULL) {
- fprintf(stderr, "StringFile: RWop == NULL!\n");
+ fprintf(stderr, "Stringfile: RWop == NULL!\n");
exit(EXIT_FAILURE);
}
if(bufsize <= 0) {
- fprintf(stderr,"StringFile: Cannot determine size!\n");
+ fprintf(stderr,"Stringfile: Cannot determine size!\n");
exit(EXIT_FAILURE);
}
if(bufsize < 2) {
- fprintf(stderr, "StringFile: Invalid string file: File too small!\n");
+ fprintf(stderr, "Stringfile: Invalid string file: File too small!\n");
exit(EXIT_FAILURE);
}
if(SDL_RWseek(RWop,0,SEEK_SET) != 0) {
- fprintf(stderr,"StringFile: Seeking string file failed!\n");
+ fprintf(stderr,"Stringfile: Seeking string file failed!\n");
exit(EXIT_FAILURE);
}
if( (bufFiledata = (unsigned char*) malloc(bufsize)) == NULL) {
- fprintf(stderr,"StringFile: Allocating memory failed!\n");
+ fprintf(stderr,"Stringfile: Allocating memory failed!\n");
exit(EXIT_FAILURE);
}
if(SDL_RWread(RWop, bufFiledata, bufsize, 1) != 1) {
- fprintf(stderr,"StringFile: Reading string file failed!\n");
+ fprintf(stderr,"Stringfile: Reading string file failed!\n");
exit(EXIT_FAILURE);
}
@@ -59,7 +59,7 @@
SDL_RWclose(RWop);
}
-StringFile::~StringFile() {
+Stringfile::~Stringfile() {
delete [] stringArray;
}
@@ -69,7 +69,7 @@
\param text Text to decode
\return The decoded text
*/
-std::string StringFile::decodeString(std::string text) {
+std::string Stringfile::decodeString(std::string text) {
std::string out = "";
unsigned char databyte;
@@ -221,7 +221,7 @@
// special character
i++;
if(i == text.length()) {
- fprintf(stderr,"StringFile:decodeString: Special character escape sequence at end of string!\n");
+ fprintf(stderr,"Stringfile:decodeString: Special character escape sequence at end of string!\n");
exit(EXIT_FAILURE);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|