Commit 0c352741 authored by Gerhard Stein's avatar Gerhard Stein

Some SDL 1.2 fixes

parent ce6a2de2
......@@ -64,7 +64,7 @@ public:
GsTexture mTexture;
#if SDL_VERSION_ATLEAST(2, 0, 0)
#if SDL_VERSION_ATLEAST(2, 0, 0)
void clearFingers();
......
......@@ -58,7 +58,7 @@ bool COpenGL::resizeDisplayScreen(const GsRect<Uint16>& newDim)
updateActiveArea(newDim, w, h);
setUpViewPort(mActiceAreaRect);
setUpViewPort(mActiveAreaRect);
#endif
......@@ -190,7 +190,7 @@ bool COpenGL::init()
}
#else // not SDL 2.0
// Setup the view port for the first time
setUpViewPort(mActiceAreaRect);
setUpViewPort(mActiveAreaRect);
// Set clear colour
glClearColor(0,0,0,0);
......
......@@ -126,8 +126,8 @@ bool CSDLVideo::resizeDisplayScreen(const GsRect<Uint16>& newDim)
SDL_RenderSetViewport(renderer, nullptr);
}
#else
mDisplaySfc.setPtr(SDL_SetVideoMode( mActiceAreaRect.w,
mActiceAreaRect.h,
mDisplaySfc.setPtr(SDL_SetVideoMode( mActiveAreaRect.w,
mActiveAreaRect.h,
32, m_Mode ));
#endif
......
......@@ -35,7 +35,7 @@ CVideoDriver::~CVideoDriver()
}
}
#if SDL_VERSION_ATLEAST(2, 0, 0)
void CVideoDriver::addTextureRefToRender(GsTexture& textureRef, const GsRect<float> &dstRect)
{
const GsRect<Uint16> clickGameArea = mpVideoEngine->getActiveAreaRect();
......@@ -54,6 +54,7 @@ void CVideoDriver::addTextureRefToRender(GsTexture& textureRef, const GsRect<flo
mpVideoEngine->mRenderTexturePtrs.push(triple);
}
#endif
bool CVideoDriver::init()
......
......@@ -12,7 +12,6 @@
* @note: This is SDL 2.0 or above only right now
*/
#if SDL_VERSION_ATLEAST(2, 0, 0)
class GsTexture
{
......@@ -28,11 +27,15 @@ public:
*/
virtual ~GsTexture()
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
if(mpTexture)
unload();
#endif
}
#if SDL_VERSION_ATLEAST(2, 0, 0)
/**
* @brief loadTexture Will try to load the texture
* @param fname filename to load
......@@ -41,6 +44,7 @@ public:
*/
bool load(const std::string &fname, SDL_Renderer *renderer)
{
// Do we have an old texture? Unload it
if(mpTexture)
unload();
......@@ -160,8 +164,9 @@ public:
private:
SDL_Texture* mpTexture = nullptr;
};
#endif
};
#endif // GSTEXTURE_H
......@@ -20,10 +20,15 @@
bool TouchButton::loadEmdbeddedPicture(const unsigned char *data,
const unsigned int size)
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
return mTexture.loadFromMem(data, size,
gVideoDriver.Renderer());
#else
return false;
#endif
}
#if SDL_VERSION_ATLEAST(2, 0, 0)
void TouchButton::clearFingers()
{
mFingerSet.clear();
......@@ -43,9 +48,11 @@ void TouchButton::removeFingerId(const SDL_FingerID fid)
}
}
#endif
bool TouchButton::loadPicture(const std::string &picFile)
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
const std::string buttonFname = getResourceFilename(picFile, "", true, true);
if(buttonFname == "") return false;
......@@ -56,8 +63,11 @@ bool TouchButton::loadPicture(const std::string &picFile)
return false;
}
mTexture.setBlendMode(SDL_BLENDMODE_BLEND);
mTexture.setBlendMode(SDL_BLENDMODE_BLEND);
return true;
#else
return false;
#endif
}
VirtualKeenControl::~VirtualKeenControl()
......@@ -236,6 +246,7 @@ void VirtualKeenControl::renderConfig()
void VirtualKeenControl::hideEverything()
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
mPadBackground.invisible = true;
mDPad.invisible = true;
mConfirmButton.invisible = true;
......@@ -245,10 +256,12 @@ void VirtualKeenControl::hideEverything()
mShootButton.invisible = true;
mPogoButton.invisible = true;
mStatusButton.invisible = true;
#endif
}
void VirtualKeenControl::hideAllButtons()
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
mPadBackground.invisible = false;
mConfirmButton.invisible = true;
mStartButton.invisible = true;
......@@ -257,6 +270,7 @@ void VirtualKeenControl::hideAllButtons()
mShootButton.invisible = true;
mPogoButton.invisible = true;
mStatusButton.invisible = true;
#endif
}
......@@ -294,6 +308,7 @@ void VirtualKeenControl::render(GsWeakSurface &sfc)
void VirtualKeenControl::flush()
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
mConfirmButton.clearFingers();
mStartButton.clearFingers();
mStatusButton.clearFingers();
......@@ -301,14 +316,16 @@ void VirtualKeenControl::flush()
mJumpButton.clearFingers();
mPogoButton.clearFingers();
mDPad.clearFingers();
#endif
}
#if SDL_VERSION_ATLEAST(2, 0, 0)
bool VirtualKeenControl::mouseFingerState(const Vector2D<float> &Pos,
const SDL_TouchFingerEvent &touchFingerEvent,
const bool down)
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
/*
auto unbindButtonCommand = [&](const TouchButton &button,
const InputCommand &cmd)
......@@ -476,10 +493,10 @@ bool VirtualKeenControl::mouseFingerState(const Vector2D<float> &Pos,
ok |= bindButtonCommand(mJumpButton, IC_JUMP);
ok |= bindButtonCommand(mPogoButton, IC_POGO);
#endif
return ok;
}
#endif
bool VirtualKeenControl::mouseState(const Vector2D<float> &Pos, const bool down)
{
......
......@@ -10,7 +10,7 @@ class VirtualKeenControl : public GsVirtualInput
{
public:
virtual ~VirtualKeenControl();
virtual ~VirtualKeenControl() override;
// OK => Only show Ok Button
// WMAP => Shows Enter Button for the world map and another one for the item box and one for the main menu
......@@ -86,18 +86,23 @@ public:
const SDL_TouchFingerEvent &touchFingerEvent,
const bool down) override;
#endif
#endif
/**
* @brief active Checks if click events happened in the virtual dpad
* @return
*/
bool isInside(const Vector2D<float> &Pos) const override
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
return mPadBackground.isInside(Pos.x, Pos.y);
#else
return false;
#endif
}
/**
* @brief hideAllButtons Hide all the virtual button
*/
......@@ -109,8 +114,6 @@ public:
void hideEverything();
#if SDL_VERSION_ATLEAST(2, 0, 0)
TouchButton mPadBackground;
TouchButton mDPad;
TouchButton mConfirmButton;
......@@ -122,8 +125,8 @@ public:
TouchButton mPogoButton;
TouchButton mStatusButton;
#if SDL_VERSION_ATLEAST(2, 0, 0)
std::set< SDL_FingerID > mFingerSet;
#endif
};
......
......@@ -98,6 +98,7 @@ bool CLevelPlay::loadLevel(const Uint16 level)
void CLevelPlay::ponder(const float deltaT)
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
if( gVideoDriver.VGamePadEnabled() )
{
VirtualKeenControl *vkc = dynamic_cast<VirtualKeenControl*>(gInput.mpVirtPad.get());
......@@ -110,6 +111,7 @@ void CLevelPlay::ponder(const float deltaT)
vkc->mShootButton.invisible = false;
vkc->mStatusButton.invisible = false;
}
#endif
ponderBase(deltaT);
}
......
......@@ -128,9 +128,11 @@ bool CPassiveGalaxy::init()
gInput.mpVirtPad.reset(new VirtualKeenControl);
gInput.mpVirtPad->init();
#if SDL_VERSION_ATLEAST(2, 0, 0)
VirtualKeenControl *vkc = dynamic_cast<VirtualKeenControl*>(gInput.mpVirtPad.get());
assert(vkc);
vkc->mDPad.invisible = true;
#endif
const auto &storyText = gBehaviorEngine.getString("STORY_TEXT");
mStoryTextVector = explode(storyText, "\n");
......@@ -369,9 +371,11 @@ void CPassiveGalaxy::processTitle()
{
gInput.flushAll();
#if SDL_VERSION_ATLEAST(2, 0, 0)
VirtualKeenControl *vkc = dynamic_cast<VirtualKeenControl*>(gInput.mpVirtPad.get());
assert(vkc);
vkc->mDPad.invisible = false;
#endif
gEventManager.add(new OpenMainMenuEvent());
mSkipSection = false;
......@@ -467,9 +471,11 @@ void CPassiveGalaxy::processStarWars()
{
gInput.flushAll();
#if SDL_VERSION_ATLEAST(2, 0, 0)
VirtualKeenControl *vkc = dynamic_cast<VirtualKeenControl*>(gInput.mpVirtPad.get());
assert(vkc);
vkc->mDPad.invisible = false;
#endif
gEventManager.add(new OpenMainMenuEvent());
mSkipSection = false;
......
......@@ -675,6 +675,8 @@ void CPlayGameGalaxy::render()
void CPlayGameGalaxy::processInput()
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
VirtualKeenControl *vkc = dynamic_cast<VirtualKeenControl*>(gInput.mpVirtPad.get());
if(!vkc)
......@@ -686,6 +688,7 @@ void CPlayGameGalaxy::processInput()
assert(vkc);
vkc->mDPad.invisible = false;
#endif
}
......
......@@ -62,7 +62,7 @@ mounted(false)
CGalaxySpriteObject::setActionForce(0);
setActionSprite();
walkBaseFrame = mSpriteIdx;
walkBaseFrame = Uint16(mSpriteIdx);
wavingBaseFrame = walkBaseFrame + 22;
swimBaseFrame = walkBaseFrame + 24;
climbBaseFrame = walkBaseFrame + (gBehaviorEngine.isDemo() ? 26 : 37);
......@@ -471,12 +471,14 @@ void CPlayerWM::processMoving()
const int ep = gBehaviorEngine.getEpisode();
const int shipLevel = (ep < 6) ? 18 : 17;
#if SDL_VERSION_ATLEAST(2, 0, 0)
if(mpMap->findTile(flag_dest, &x, &y, 2) ||
gBehaviorEngine.mOptions[GameOption::LVLREPLAYABILITY].value ||
level >= shipLevel)
{
vkc->mStartButton.invisible = false;
}
#endif
}
// Try to start a level
......@@ -489,6 +491,7 @@ void CPlayerWM::processMoving()
}
else
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
if( gVideoDriver.VGamePadEnabled() )
{
VirtualKeenControl *vkc = dynamic_cast<VirtualKeenControl*>(gInput.mpVirtPad.get());
......@@ -496,6 +499,7 @@ void CPlayerWM::processMoving()
vkc->mStatusButton.invisible = false;
vkc->mStartButton.invisible = true;
}
#endif
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment