From b1981055e1b1f8e54bfce89d66caffa870d1fc2e Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Thu, 28 Aug 2014 19:07:29 +0200 Subject: [PATCH] Core: Remove ifdefs that don't influence RGSS specific behavior This is the first step in eliminating the build time RGSS versioning. --- src/audio.cpp | 26 ++++----------------- src/audio.h | 16 ++++--------- src/bitmap.cpp | 4 ++-- src/bitmap.h | 3 +-- src/font.cpp | 12 ---------- src/font.h | 12 ---------- src/graphics.cpp | 22 ----------------- src/graphics.h | 5 +--- src/sprite.cpp | 61 ++++++++++++++---------------------------------- src/sprite.h | 21 +++++++---------- src/viewport.cpp | 8 ------- src/viewport.h | 10 +------- 12 files changed, 40 insertions(+), 160 deletions(-) diff --git a/src/audio.cpp b/src/audio.cpp index 793c447..aa418e5 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -249,17 +249,10 @@ Audio::Audio(const Config &conf) void Audio::bgmPlay(const char *filename, int volume, - int pitch - #ifdef RGSS3 - ,float pos - #endif - ) + int pitch, + float pos) { -#ifdef RGSS3 p->bgm.play(filename, volume, pitch, pos); -#else - p->bgm.play(filename, volume, pitch); -#endif } void Audio::bgmStop() @@ -275,17 +268,10 @@ void Audio::bgmFade(int time) void Audio::bgsPlay(const char *filename, int volume, - int pitch - #ifdef RGSS3 - ,float pos - #endif - ) + int pitch, + float pos) { -#ifdef RGSS3 p->bgs.play(filename, volume, pitch, pos); -#else - p->bgs.play(filename, volume, pitch); -#endif } void Audio::bgsStop() @@ -329,8 +315,6 @@ void Audio::seStop() p->se.stop(); } -#ifdef RGSS3 - void Audio::setupMidi() { #ifdef MIDI @@ -348,6 +332,4 @@ float Audio::bgsPos() return p->bgs.playingOffset(); } -#endif - Audio::~Audio() { delete p; } diff --git a/src/audio.h b/src/audio.h index cb3e9fb..b600f54 100644 --- a/src/audio.h +++ b/src/audio.h @@ -40,21 +40,15 @@ class Audio public: void bgmPlay(const char *filename, int volume = 100, - int pitch = 100 -#ifdef RGSS3 - ,float pos = 0 -#endif - ); + int pitch = 100, + float pos = 0); void bgmStop(); void bgmFade(int time); void bgsPlay(const char *filename, int volume = 100, - int pitch = 100 -#ifdef RGSS3 - ,float pos = 0 -#endif - ); + int pitch = 100, + float pos = 0); void bgsStop(); void bgsFade(int time); @@ -69,11 +63,9 @@ public: int pitch = 100); void seStop(); -#ifdef RGSS3 void setupMidi(); float bgmPos(); float bgsPos(); -#endif private: Audio(const Config &conf); diff --git a/src/bitmap.cpp b/src/bitmap.cpp index 8899238..4cafda7 100644 --- a/src/bitmap.cpp +++ b/src/bitmap.cpp @@ -488,8 +488,6 @@ void Bitmap::fillRect(const IntRect &rect, const Vec4 &color) p->onModified(); } -#ifdef RGSS2 - void Bitmap::gradientFillRect(int x, int y, int width, int height, const Vec4 &color1, const Vec4 &color2, @@ -553,6 +551,8 @@ void Bitmap::clearRect(const IntRect &rect) p->onModified(); } +#ifdef RGSS2 + void Bitmap::blur() { GUARD_MEGA; diff --git a/src/bitmap.h b/src/bitmap.h index d481fd5..612d11f 100644 --- a/src/bitmap.h +++ b/src/bitmap.h @@ -61,7 +61,6 @@ public: const Vec4 &color); void fillRect(const IntRect &rect, const Vec4 &color); -#ifdef RGSS2 void gradientFillRect(int x, int y, int width, int height, const Vec4 &color1, const Vec4 &color2, @@ -74,8 +73,8 @@ public: int width, int height); void clearRect(const IntRect &rect); +#ifdef RGSS2 void blur(); - void radialBlur(int angle, int divisions); #endif diff --git a/src/font.cpp b/src/font.cpp index 46ff50a..aca1de0 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -335,29 +335,17 @@ DEF_ATTR_RD_SIMPLE(Font, Size, int, p->size) DEF_ATTR_SIMPLE(Font, Bold, bool, p->bold) DEF_ATTR_SIMPLE(Font, Italic, bool, p->italic) DEF_ATTR_SIMPLE(Font, Color, Color*, p->color) - -#ifdef RGSS2 DEF_ATTR_SIMPLE(Font, Shadow, bool, p->shadow) -#endif - -#ifdef RGSS3 DEF_ATTR_SIMPLE(Font, Outline, bool, p->outline) DEF_ATTR_SIMPLE(Font, OutColor, Color*, p->outColor) -#endif DEF_ATTR_SIMPLE_STATIC(Font, DefaultSize, int, FontPrivate::defaultSize) DEF_ATTR_SIMPLE_STATIC(Font, DefaultBold, bool, FontPrivate::defaultBold) DEF_ATTR_SIMPLE_STATIC(Font, DefaultItalic, bool, FontPrivate::defaultItalic) DEF_ATTR_SIMPLE_STATIC(Font, DefaultColor, Color*, FontPrivate::defaultColor) - -#ifdef RGSS2 DEF_ATTR_SIMPLE_STATIC(Font, DefaultShadow, bool, FontPrivate::defaultShadow) -#endif - -#ifdef RGSS3 DEF_ATTR_SIMPLE_STATIC(Font, DefaultOutline, bool, FontPrivate::defaultOutline) DEF_ATTR_SIMPLE_STATIC(Font, DefaultOutColor, Color*, FontPrivate::defaultOutColor) -#endif const char *Font::getDefaultName() { diff --git a/src/font.h b/src/font.h index f992ce3..0e90385 100644 --- a/src/font.h +++ b/src/font.h @@ -89,30 +89,18 @@ public: DECL_ATTR( Bold, bool ) DECL_ATTR( Italic, bool ) DECL_ATTR( Color, Color* ) - -#ifdef RGSS2 DECL_ATTR( Shadow, bool ) -#endif - -#ifdef RGSS3 DECL_ATTR( Outline, bool ) DECL_ATTR( OutColor, Color* ) -#endif DECL_ATTR_STATIC( DefaultName, const char* ) DECL_ATTR_STATIC( DefaultSize, int ) DECL_ATTR_STATIC( DefaultBold, bool ) DECL_ATTR_STATIC( DefaultItalic, bool ) DECL_ATTR_STATIC( DefaultColor, Color* ) - -#ifdef RGSS2 DECL_ATTR_STATIC( DefaultShadow, bool ) -#endif - -#ifdef RGSS3 DECL_ATTR_STATIC( DefaultOutline, bool ) DECL_ATTR_STATIC( DefaultOutColor, Color* ) -#endif /* internal */ _TTF_Font *getSdlFont(); diff --git a/src/graphics.cpp b/src/graphics.cpp index 58b4576..d7e38f2 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -126,10 +126,8 @@ public: { updateReso(width, height); -#ifdef RGSS2 brightEffect = false; brightnessQuad.setColor(Vec4()); -#endif } void composite() @@ -147,7 +145,6 @@ public: Scene::composite(); -#ifdef RGSS2 if (brightEffect) { SimpleColorShader &shader = shState->shaders().simpleColor; @@ -157,7 +154,6 @@ public: brightnessQuad.draw(); } -#endif } void requestViewportRender(Vec4 &c, Vec4 &f, Vec4 &t) @@ -194,14 +190,12 @@ public: glState.blend.pop(); } -#ifdef RGSS2 void setBrightness(float norm) { brightnessQuad.setColor(Vec4(0, 0, 0, 1.0 - norm)); brightEffect = norm < 1.0; } -#endif void updateReso(int width, int height) { @@ -209,10 +203,7 @@ public: geometry.rect.h = height; screenQuad.setTexPosRect(geometry.rect, geometry.rect); - -#ifdef RGSS2 brightnessQuad.setTexPosRect(geometry.rect, geometry.rect); -#endif notifyGeometryChange(); } @@ -232,10 +223,8 @@ private: PingPong pp; Quad screenQuad; -#ifdef RGSS2 Quad brightnessQuad; bool brightEffect; -#endif }; /* Nanoseconds per second */ @@ -391,10 +380,7 @@ struct GraphicsPrivate int frameRate; int frameCount; - -#ifdef RGSS2 int brightness; -#endif FPSLimiter fpsLimiter; @@ -412,9 +398,7 @@ struct GraphicsPrivate threadData(rtData), frameRate(DEF_FRAMERATE), frameCount(0), -#ifdef RGSS2 brightness(255), -#endif fpsLimiter(frameRate), frozen(false) { @@ -606,9 +590,7 @@ void Graphics::transition(int duration, vague = clamp(vague, 0, 512); Bitmap *transMap = filename ? new Bitmap(filename) : 0; -#ifdef RGSS2 setBrightness(255); -#endif /* Capture new scene */ p->compositeToBuffer(p->currentScene); @@ -714,8 +696,6 @@ void Graphics::setFrameRate(int value) p->fpsLimiter.setDesiredFPS(p->frameRate); } -#ifdef RGSS2 - void Graphics::wait(int duration) { for (int i = 0; i < duration; ++i) @@ -849,8 +829,6 @@ void Graphics::setBrightness(int value) p->screen.setBrightness(value / 255.0); } -#endif - bool Graphics::getFullscreen() const { return p->threadData->ethread->getFullscreen(); diff --git a/src/graphics.h b/src/graphics.h index 7d3bfb6..b1ce016 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -41,8 +41,8 @@ public: DECL_ATTR( FrameRate, int ) DECL_ATTR( FrameCount, int ) + DECL_ATTR( Brightness, int ) -#ifdef RGSS2 void wait(int duration); void fadeout(int duration); void fadein(int duration); @@ -53,9 +53,6 @@ public: int height() const; void resizeScreen(int width, int height); - DECL_ATTR( Brightness, int ) -#endif - /* Non-standard extension */ DECL_ATTR( Fullscreen, bool ) DECL_ATTR( ShowCursor, bool ) diff --git a/src/sprite.cpp b/src/sprite.cpp index 9aa99ca..6c5b184 100644 --- a/src/sprite.cpp +++ b/src/sprite.cpp @@ -67,7 +67,6 @@ struct SpritePrivate Color *color; Tone *tone; -#ifdef RGSS2 struct { int amp; @@ -81,7 +80,6 @@ struct SpritePrivate bool dirty; SimpleQuadArray qArray; } wave; -#endif EtcTemps tmp; @@ -109,13 +107,11 @@ struct SpritePrivate prepareCon = shState->prepareDraw.connect (sigc::mem_fun(this, &SpritePrivate::prepare)); -#ifdef RGSS2 wave.amp = 0; wave.length = 180; wave.speed = 360; wave.phase = 0.0; wave.dirty = false; -#endif } ~SpritePrivate() @@ -147,9 +143,7 @@ struct SpritePrivate quad.setPosRect(IntRect(0, 0, srcRect->width, srcRect->height)); recomputeBushDepth(); -#ifdef RGSS2 wave.dirty = true; -#endif } void updateSrcRectCon() @@ -171,7 +165,6 @@ struct SpritePrivate if (!opacity) return; -#ifdef RGSS2 if (wave.active) { /* Don't do expensive wave bounding box @@ -179,7 +172,6 @@ struct SpritePrivate isVisible = true; return; } -#endif /* Compare sprite bounding box against the scene */ @@ -201,7 +193,6 @@ struct SpritePrivate isVisible = SDL_HasIntersection(&self, &sceneRect); } -#ifdef RGSS2 void emitWaveChunk(SVertex *&vert, float phase, int width, float zoomY, int chunkY, int chunkLength) { @@ -285,17 +276,14 @@ struct SpritePrivate wave.qArray.commit(); } -#endif void prepare() { -#ifdef RGSS2 if (wave.dirty) { updateWave(); wave.dirty = false; } -#endif updateVisibility(); } @@ -315,33 +303,30 @@ Sprite::~Sprite() delete p; } -DEF_ATTR_RD_SIMPLE(Sprite, Bitmap, Bitmap*, p->bitmap) -DEF_ATTR_RD_SIMPLE(Sprite, SrcRect, Rect*, p->srcRect) -DEF_ATTR_RD_SIMPLE(Sprite, X, int, p->trans.getPosition().x) -DEF_ATTR_RD_SIMPLE(Sprite, Y, int, p->trans.getPosition().y) -DEF_ATTR_RD_SIMPLE(Sprite, OX, int, p->trans.getOrigin().x) -DEF_ATTR_RD_SIMPLE(Sprite, OY, int, p->trans.getOrigin().y) -DEF_ATTR_RD_SIMPLE(Sprite, ZoomX, float, p->trans.getScale().x) -DEF_ATTR_RD_SIMPLE(Sprite, ZoomY, float, p->trans.getScale().y) -DEF_ATTR_RD_SIMPLE(Sprite, Angle, float, p->trans.getRotation()) -DEF_ATTR_RD_SIMPLE(Sprite, Mirror, bool, p->mirrored) -DEF_ATTR_RD_SIMPLE(Sprite, BushDepth, int, p->bushDepth) -DEF_ATTR_RD_SIMPLE(Sprite, BlendType, int, p->blendType) +DEF_ATTR_RD_SIMPLE(Sprite, Bitmap, Bitmap*, p->bitmap) +DEF_ATTR_RD_SIMPLE(Sprite, SrcRect, Rect*, p->srcRect) +DEF_ATTR_RD_SIMPLE(Sprite, X, int, p->trans.getPosition().x) +DEF_ATTR_RD_SIMPLE(Sprite, Y, int, p->trans.getPosition().y) +DEF_ATTR_RD_SIMPLE(Sprite, OX, int, p->trans.getOrigin().x) +DEF_ATTR_RD_SIMPLE(Sprite, OY, int, p->trans.getOrigin().y) +DEF_ATTR_RD_SIMPLE(Sprite, ZoomX, float, p->trans.getScale().x) +DEF_ATTR_RD_SIMPLE(Sprite, ZoomY, float, p->trans.getScale().y) +DEF_ATTR_RD_SIMPLE(Sprite, Angle, float, p->trans.getRotation()) +DEF_ATTR_RD_SIMPLE(Sprite, Mirror, bool, p->mirrored) +DEF_ATTR_RD_SIMPLE(Sprite, BushDepth, int, p->bushDepth) +DEF_ATTR_RD_SIMPLE(Sprite, BlendType, int, p->blendType) +DEF_ATTR_RD_SIMPLE(Sprite, Width, int, p->srcRect->width) +DEF_ATTR_RD_SIMPLE(Sprite, Height, int, p->srcRect->height) +DEF_ATTR_RD_SIMPLE(Sprite, WaveAmp, int, p->wave.amp) +DEF_ATTR_RD_SIMPLE(Sprite, WaveLength, int, p->wave.length) +DEF_ATTR_RD_SIMPLE(Sprite, WaveSpeed, int, p->wave.speed) +DEF_ATTR_RD_SIMPLE(Sprite, WavePhase, float, p->wave.phase) DEF_ATTR_SIMPLE(Sprite, BushOpacity, int, p->bushOpacity) DEF_ATTR_SIMPLE(Sprite, Opacity, int, p->opacity) DEF_ATTR_SIMPLE(Sprite, Color, Color*, p->color) DEF_ATTR_SIMPLE(Sprite, Tone, Tone*, p->tone) -#ifdef RGSS2 -DEF_ATTR_RD_SIMPLE(Sprite, Width, int, p->srcRect->width) -DEF_ATTR_RD_SIMPLE(Sprite, Height, int, p->srcRect->height) -DEF_ATTR_RD_SIMPLE(Sprite, WaveAmp, int, p->wave.amp) -DEF_ATTR_RD_SIMPLE(Sprite, WaveLength, int, p->wave.length) -DEF_ATTR_RD_SIMPLE(Sprite, WaveSpeed, int, p->wave.speed) -DEF_ATTR_RD_SIMPLE(Sprite, WavePhase, float, p->wave.phase) -#endif - void Sprite::setBitmap(Bitmap *bitmap) { if (p->bitmap == bitmap) @@ -359,9 +344,7 @@ void Sprite::setBitmap(Bitmap *bitmap) p->onSrcRectChange(); p->quad.setPosRect(p->srcRect->toFloatRect()); -#ifdef RGSS2 p->wave.dirty = true; -#endif } void Sprite::setSrcRect(Rect *rect) @@ -478,8 +461,6 @@ void Sprite::setBlendType(int type) } } -#ifdef RGSS2 - #define DEF_WAVE_SETTER(Name, name, type) \ void Sprite::setWave##Name(type value) \ { \ @@ -505,8 +486,6 @@ void Sprite::update() p->wave.dirty = true; } -#endif - /* SceneElement */ void Sprite::draw() { @@ -560,14 +539,10 @@ void Sprite::draw() p->bitmap->bindTex(*base); -#ifdef RGSS2 if (p->wave.active) p->wave.qArray.draw(); else p->quad.draw(); -#else - p->quad.draw(); -#endif glState.blendMode.pop(); } diff --git a/src/sprite.h b/src/sprite.h index ea1b440..3783f90 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -41,6 +41,11 @@ public: Sprite(Viewport *viewport = 0); ~Sprite(); + int getWidth() const; + int getHeight() const; + + void update(); + DECL_ATTR( Bitmap, Bitmap* ) DECL_ATTR( SrcRect, Rect* ) DECL_ATTR( X, int ) @@ -57,18 +62,10 @@ public: DECL_ATTR( BlendType, int ) DECL_ATTR( Color, Color* ) DECL_ATTR( Tone, Tone* ) - -#ifdef RGSS2 - int getWidth() const; - int getHeight() const; - - DECL_ATTR( WaveAmp, int ) - DECL_ATTR( WaveLength, int ) - DECL_ATTR( WaveSpeed, int ) - DECL_ATTR( WavePhase, float ) - - void update(); -#endif + DECL_ATTR( WaveAmp, int ) + DECL_ATTR( WaveLength, int ) + DECL_ATTR( WaveSpeed, int ) + DECL_ATTR( WavePhase, float ) private: SpritePrivate *p; diff --git a/src/viewport.cpp b/src/viewport.cpp index a579507..96fd50b 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -113,8 +113,6 @@ Viewport::Viewport(Rect *rect) initViewport(rect->x, rect->y, rect->width, rect->height); } -#ifdef RGSS3 - Viewport::Viewport() : SceneElement(*shState->screen()), sceneLink(this) @@ -123,8 +121,6 @@ Viewport::Viewport() initViewport(0, 0, graphics.width(), graphics.height()); } -#endif - void Viewport::initViewport(int x, int y, int width, int height) { p = new ViewportPrivate(x, y, width, height, this); @@ -232,8 +228,6 @@ Viewport *ViewportElement::getViewport() const return m_viewport; } -#ifdef RGSS2 - void ViewportElement::setViewport(Viewport *viewport) { m_viewport = viewport; @@ -241,5 +235,3 @@ void ViewportElement::setViewport(Viewport *viewport) onViewportChange(); onGeometryChange(scene->getGeometry()); } - -#endif diff --git a/src/viewport.h b/src/viewport.h index 45c8965..ecb646a 100644 --- a/src/viewport.h +++ b/src/viewport.h @@ -34,11 +34,7 @@ class Viewport : public Scene, public SceneElement, public Flashable, public Dis public: Viewport(int x, int y, int width, int height); Viewport(Rect *rect); - -#ifdef RGSS3 Viewport(); -#endif - ~Viewport(); DECL_ATTR( Rect, Rect* ) @@ -68,11 +64,7 @@ public: ViewportElement(Viewport *viewport = 0, int z = 0, bool isSprite = false); ViewportElement(Viewport *viewport, int z, unsigned int cStamp); - Viewport *getViewport() const; - -#ifdef RGSS2 - void setViewport(Viewport *viewport = 0); -#endif + DECL_ATTR( Viewport, Viewport* ) protected: virtual void onViewportChange() {}