Commit c09ec283 authored by gerstrong@gmail.com's avatar gerstrong@gmail.com

VirtualPad Macro fixes and more general cleanups

parent 4108ac3e
......@@ -7,13 +7,16 @@ Project(CommanderGenius)
set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
option(USE_VIRTUALPAD "Enable Onscreen Virtual Gamepad support " yes)
if(USE_VIRTUALPAD)
ADD_DEFINITIONS(-DVIRTUALPAD)
endif(USE_VIRTUALPAD)
# Use COmpile TIme REducer
include(cotire)
if(USE_SDL2S)
include(FindSDL2_mixer)
endif()
option(USE_PYTHON3 "Use Python3 scripts" yes)
set (CMAKE_CXX_STANDARD 14)
......
......@@ -7,18 +7,11 @@ Project(GsKit)
OPTION(USE_SDL2 "SDL2 support" Yes)
option(USE_PYTHON3 "Use Python3 scripts" yes)
option(USE_VIRTUALPAD "Enable Onscreen Virtual Gamepad support " yes)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(USE_VIRTUALPAD)
ADD_DEFINITIONS(-DVIRTUALPAD)
endif(USE_VIRTUALPAD)
IF(WIN32)
ADD_DEFINITIONS(-DWIN32)
ENDIF(WIN32)
......
......@@ -258,7 +258,7 @@ void CInput::loadControlconfig(void)
else
{
for(size_t c=1 ; c<= NUM_INPUTS ; c++)
resetControls(c);
resetControls(int(c));
}
}
......@@ -275,25 +275,29 @@ void CInput::saveControlconfig()
for(size_t i=0 ; i<NUM_INPUTS ; i++)
{
section = "input" + itoa(i);
Configuration.WriteString(section, "Left", getEventName(IC_LEFT, i));
Configuration.WriteString(section, "Up", getEventName(IC_UP, i));
Configuration.WriteString(section, "Right", getEventName(IC_RIGHT, i));
Configuration.WriteString(section, "Down", getEventName(IC_DOWN, i));
Configuration.WriteString(section, "Upper-Left", getEventName(IC_UPPERLEFT, i));
Configuration.WriteString(section, "Upper-Right", getEventName(IC_UPPERRIGHT, i));
Configuration.WriteString(section, "Lower-Left", getEventName(IC_LOWERLEFT, i));
Configuration.WriteString(section, "Lower-Right", getEventName(IC_LOWERRIGHT, i));
Configuration.WriteString(section, "Jump", getEventName(IC_JUMP, i));
Configuration.WriteString(section, "Pogo", getEventName(IC_POGO, i));
Configuration.WriteString(section, "Fire", getEventName(IC_FIRE, i));
Configuration.WriteString(section, "Run", getEventName(IC_RUN, i));
Configuration.WriteString(section, "Status", getEventName(IC_STATUS, i));
Configuration.WriteString(section, "Camlead", getEventName(IC_CAMLEAD, i));
Configuration.WriteString(section, "Help", getEventName(IC_HELP, i));
Configuration.WriteString(section, "Back", getEventName(IC_BACK, i));
const auto inputVal = static_cast<unsigned char>(i);
Configuration.WriteString(section, "Left", getEventName(IC_LEFT, inputVal));
Configuration.WriteString(section, "Up", getEventName(IC_UP, inputVal));
Configuration.WriteString(section, "Right", getEventName(IC_RIGHT, inputVal));
Configuration.WriteString(section, "Down", getEventName(IC_DOWN, inputVal));
Configuration.WriteString(section, "Upper-Left", getEventName(IC_UPPERLEFT, inputVal));
Configuration.WriteString(section, "Upper-Right", getEventName(IC_UPPERRIGHT, inputVal));
Configuration.WriteString(section, "Lower-Left", getEventName(IC_LOWERLEFT, inputVal));
Configuration.WriteString(section, "Lower-Right", getEventName(IC_LOWERRIGHT, inputVal));
Configuration.WriteString(section, "Jump", getEventName(IC_JUMP, inputVal));
Configuration.WriteString(section, "Pogo", getEventName(IC_POGO, inputVal));
Configuration.WriteString(section, "Fire", getEventName(IC_FIRE, inputVal));
Configuration.WriteString(section, "Run", getEventName(IC_RUN, inputVal));
Configuration.WriteString(section, "Status", getEventName(IC_STATUS, inputVal));
Configuration.WriteString(section, "Camlead", getEventName(IC_CAMLEAD, inputVal));
Configuration.WriteString(section, "Help", getEventName(IC_HELP, inputVal));
Configuration.WriteString(section, "Back", getEventName(IC_BACK, inputVal));
Configuration.SetKeyword(section, "TwoButtonFiring", TwoButtonFiring[i]);
Configuration.SetKeyword(section, "Analog", mAnalogAxesMovement[i]);
}
Configuration.saveCfgFile();
}
......
......@@ -160,7 +160,7 @@ class CInput : public GsSingleton<CInput>
public:
CInput();
~CInput();
virtual ~CInput();
/**
* @brief transMouseRelCoord transforms a mouse click from the screen coordinates to the relative coordinates
......
......@@ -253,7 +253,6 @@ void GsApp::runMainCycle()
if(gTimer.resetLogicSignal())
start = curr;
if(vsyncEnabled)
{
start = timerTicks();
......
......@@ -5,8 +5,8 @@
* Author: gerstrong
*/
#ifndef __GSAPP_H_
#define GSAPP_H
#ifndef GSAPP_H_
#define GSAPP_H_
#include <base/GsEvent.h>
#include <base/GsEngine.h>
......
......@@ -56,9 +56,9 @@ public:
stInputCommand* cmd = nullptr;
//stInputCommand* cmd = nullptr;
int immediateIndex = 0;
//int x = 0, y = 0, w = 0, h = 0;
float x = 0.0f, y = 0.0f, w = 0.0f, h = 0.0f;
bool invisible = true;
......@@ -77,8 +77,6 @@ public:
return !mFingerSet.empty();
}
//private:
std::set<SDL_FingerID> mFingerSet;
#endif
......@@ -98,7 +96,7 @@ public:
/**
* @brief GsVirtualInput basic constructor, just setup some variables.
*/
GsVirtualInput() {}
//GsVirtualInput() {}
virtual ~GsVirtualInput() {}
......@@ -186,8 +184,6 @@ protected:
bool mEnabled = true;
//GsSurface mOverlay;
float mTranslucency = 0.5f;
};
......
......@@ -18,47 +18,56 @@
///////////////////
// If you want to use the adress of some Uint32 directly with memcpy or similar, use this
inline Uint32 SDLColourToNativeColour(Uint32 pixel, short bpp) {
/*
inline Uint32 SDLColourToNativeColour(Uint32 pixel, short bpp)
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
return (pixel << (32 - 8 * bpp));
#else
return pixel;
#endif
}
*/
/////////////////
// If you copied some data directly with memcpy into an Uint32, use this
inline Uint32 NativeColourToSDLColour(Uint32 pixel, short bpp) {
/*
inline Uint32 NativeColourToSDLColour(Uint32 pixel, short bpp)
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
return (pixel >> (32 - 8 * bpp));
#else
return pixel;
#endif
}
*/
///////////////
// Get the specified component from the pixel (grabbed from SDL)
inline Uint8 GetR(Uint32 pixel, SDL_PixelFormat *fmt) {
/*
inline Uint8 GetR(Uint32 pixel, SDL_PixelFormat *fmt)
{
return (Uint8)((((pixel & fmt->Rmask) >> fmt->Rshift) << fmt->Rloss) +
(((pixel & fmt->Rmask) >> fmt->Rshift) >> (8 - (fmt->Rloss << 1))));
}
inline Uint8 GetG(Uint32 pixel, SDL_PixelFormat *fmt) {
inline Uint8 GetG(Uint32 pixel, SDL_PixelFormat *fmt)
{
return (Uint8)((((pixel & fmt->Gmask) >> fmt->Gshift) << fmt->Gloss) +
(((pixel & fmt->Gmask) >> fmt->Gshift) >> (8 - (fmt->Gloss << 1))));
}
inline Uint8 GetB(Uint32 pixel, SDL_PixelFormat *fmt) {
inline Uint8 GetB(Uint32 pixel, SDL_PixelFormat *fmt)
{
return (Uint8)((((pixel & fmt->Bmask) >> fmt->Bshift) << fmt->Bloss) +
(((pixel & fmt->Bmask) >> fmt->Bshift) >> (8 - (fmt->Bloss << 1))));
}
inline Uint8 GetA(Uint32 pixel, SDL_PixelFormat *fmt) {
inline Uint8 GetA(Uint32 pixel, SDL_PixelFormat *fmt)
{
return (Uint8)((((pixel & fmt->Amask) >> fmt->Ashift) << fmt->Aloss) +
(((pixel & fmt->Amask) >> fmt->Ashift) >> (8 - (fmt->Aloss << 1))));
}
*/
//extern SDL_PixelFormat* mainPixelFormat;
/*inline SDL_PixelFormat* getMainPixelFormat()
......@@ -136,14 +145,16 @@ struct GsColor
*/
void converge(GsColor &&c)
{
r = (Uint16(r) + Uint16(c.r))/2;
g = (Uint16(g) + Uint16(c.g))/2;
b = (Uint16(b) + Uint16(c.b))/2;
a = (Uint16(a) + Uint16(c.a))/2;
r = Uint8((Uint16(r) + Uint16(c.r))/2);
g = Uint8((Uint16(g) + Uint16(c.g))/2);
b = Uint8((Uint16(b) + Uint16(c.b))/2);
a = Uint8((Uint16(a) + Uint16(c.a))/2);
}
Uint8& operator[](int i) { switch(i) { case 0: return r; case 1: return g; case 2: return b; case 3: return a; default: assert(false); } return *((Uint8*)NULL); }
/*
Uint8& operator[](int i) { switch(i) { case 0: return r; case 1: return g; case 2: return b; case 3: return a; default: assert(false); } return *(reinterpret_cast<Uint8*>(0)); }
Uint8 operator[](int i) const { switch(i) { case 0: return r; case 1: return g; case 2: return b; case 3: return a; default: assert(false); } return 0; }
*/
};
#endif // COLOR_H
......@@ -111,6 +111,7 @@ static inline void scale2x_8_def_whole(scale2x_uint8* restrict dst0, scale2x_uin
}
}
#ifndef USE_SCALE_RANDOMWRITE
static inline void scale2x_8_def_border(scale2x_uint8* restrict dst, const scale2x_uint8* restrict src0, const scale2x_uint8* restrict src1, const scale2x_uint8* restrict src2, unsigned count)
{
assert(count >= 2);
......@@ -155,6 +156,7 @@ static inline void scale2x_8_def_border(scale2x_uint8* restrict dst, const scale
dst[1] = src1[0];
}
}
#endif
static inline void scale2x_8_def_center(scale2x_uint8* restrict dst, const scale2x_uint8* restrict src0, const scale2x_uint8* restrict src1, const scale2x_uint8* restrict src2, unsigned count)
{
......@@ -409,6 +411,8 @@ static inline void scale2x_32_def_whole(scale2x_uint32* restrict dst0, scale2x_u
}
}
#ifndef USE_SCALE_RANDOMWRITE
static inline void scale2x_32_def_border(scale2x_uint32* restrict dst, const scale2x_uint32* restrict src0, const scale2x_uint32* restrict src1, const scale2x_uint32* restrict src2, unsigned count)
{
assert(count >= 2);
......@@ -453,6 +457,7 @@ static inline void scale2x_32_def_border(scale2x_uint32* restrict dst, const sca
dst[1] = src1[0];
}
}
#endif
static inline void scale2x_32_def_center(scale2x_uint32* restrict dst, const scale2x_uint32* restrict src0, const scale2x_uint32* restrict src1, const scale2x_uint32* restrict src2, unsigned count)
{
......
......@@ -15,7 +15,7 @@
#include <graphics/GsGraphics.h>
#include <base/GsLogging.h>
const unsigned int MAX_ELEMENTS_PER_PAGE = 7;
//const unsigned int MAX_ELEMENTS_PER_PAGE = 7;
const unsigned int MAX_STEPS = 20;
......
......@@ -35,7 +35,7 @@
#ifdef ANDROID
#include <SDL_main.h>
#include <SDL_main.h>
#endif
#include <base/utils/FindFile.h>
......@@ -64,9 +64,9 @@ int main(int argc, char *argv[])
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
#ifdef ANDROID
#ifdef ANDROID
SDL_SetMainReady( );
#endif
#endif
#endif
// Check if CG should look into a given directory
......
......@@ -661,19 +661,19 @@ void CGameLauncher::pumpEvent(const CEvent *evPtr)
if( const MouseWheelEvent *mwe = dynamic_cast<const MouseWheelEvent*>(evPtr) )
{
// Wrapper for the simple mouse scroll event
if(mwe->amount.y > 0.0)
if(mwe->amount.y > 0.0f)
{
mLauncherDialog.sendEvent(new CommandEvent( IC_UP ));
}
else if(mwe->amount.y < 0.0)
else if(mwe->amount.y < 0.0f)
{
mLauncherDialog.sendEvent(new CommandEvent( IC_DOWN ));
}
if(mwe->amount.x < 0.0)
if(mwe->amount.x < 0.0f)
{
mLauncherDialog.sendEvent(new CommandEvent( IC_RIGHT ));
}
else if(mwe->amount.x > 0.0)
else if(mwe->amount.x > 0.0f)
{
mLauncherDialog.sendEvent(new CommandEvent( IC_LEFT ));
}
......
......@@ -20,8 +20,8 @@ size_t bulletActionMap[] =
namespace galaxy
{
const Uint32 speed = 10;
const Uint32 hittime = 100;
//const Uint32 speed = 10;
//const Uint32 hittime = 100;
CBullet::CBullet(CMap *pmap, const Uint16 foeID, const Uint32 x, const Uint32 y,
const int xDir, const int yDir, const int sprVar) :
......
......@@ -73,55 +73,55 @@ namespace galaxy
{
enum PLAYER_ACTIONS
{
A_KEEN_STAND = 0,
A_KEEN_ON_PLAT,
A_KEEN_BORED,
A_KEEN_QUESTION,
A_KEEN_MOON,
A_KEEN_BOOK_OPEN,
A_KEEN_BOOK_READ,
A_KEEN_BOOK_CLOSE,
A_KEEN_LOOKUP,
A_KEEN_LOOKDOWN,
A_KEEN_ACTION_1,
A_KEEN_ACTION_2,
A_KEEN_ACTION_3,
A_KEEN_DIE,
A_KEEN_DIE_ALT,
A_KEEN_SHOOT,
A_KEE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TDOWN,
A_KEEN_HANG,
A_KEEN_CLIMB,
A_KEEN_RIDING_ON_FOOT,
A_KEEN_STUNNED,
NUM_KEEN_ACTIONS
};
class CPlayerBase : public CGalaxySpriteObject
{
public:
/**
* \description Basic Constructor. An Object always need the pointer to the Map of the level,
* Coordinates as also the type of the Object
......@@ -236,11 +236,11 @@ public:
bool mDying = false;
bool mExitTouched = false;
protected:
protected:
bool checkMapBoundaryL(const int x1);
bool checkMapBoundaryR(const int x2);
bool checkMapBoundaryU(const int y1);
bool checkMapBoundaryL(const int x1) override;
bool checkMapBoundaryR(const int x2) override;
bool checkMapBoundaryU(const int y1) override;
const int mPlayerNum;
int mPlayerCtrlNum; // For the control input
......
......@@ -22,9 +22,7 @@ const int MAX_BOUNCE_BOOST = -115;
const int HOR_SPEED = 40;
CBounder::CBounder(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y) :
CStunnable(pmap, foeID, x, y),
bounceboost(0),
mpInteractPlayer(NULL)
CStunnable(pmap, foeID, x, y)
{
mActionMap[A_BOUNDER_BOUNCE] = (GASOFctr) &CBounder::processBounce;
mActionMap[A_BOUNDER_MOVE] = (GASOFctr) &CBounder::processBounce;
......
......@@ -35,9 +35,9 @@ public:
void process();
private:
int bounceboost;
int bounceboost = 0;
CPlayerLevel *mpInteractPlayer;
CPlayerLevel *mpInteractPlayer = nullptr;
};
};
......
......@@ -27,9 +27,9 @@ mInchWormContacts(0)
}
const int CSF_MIN_DISTANCE_TO_FOLLOW = 8<<CSF;
//const int CSF_MIN_DISTANCE_TO_FOLLOW = 8<<CSF;
const int CSF_DISTANCE_TO_FOLLOW_TOLERANCE = 1<<CSF;
const int INCHWORM_SPEED = 2;
//const int INCHWORM_SPEED = 2;
bool CInchWorm::isNearby(CSpriteObject &theObject)
......
......@@ -32,8 +32,7 @@ constexpr int MOVE_SPEED = 50;
CVolteface::CVolteface(CMap *pmap, const Uint16 foeID, const Uint32 x, const Uint32 y) :
CStunnable(pmap, foeID, x, y),
CMoveTarget(m_Pos, xDirection, yDirection),
mTimer(0)
CMoveTarget(m_Pos, xDirection, yDirection)
{
mActionMap[A_VOLTFACE_MOVE] = (GASOFctr) &CVolteface::processMoving;
mActionMap[A_VOLTFACE_STUNNED] = (GASOFctr) &CVolteface::processStunned;
......
......@@ -37,7 +37,7 @@ public:
private:
int mTimer;
// int mTimer = 0;
};
}
......
......@@ -16,7 +16,7 @@ A_BIP_SQUISHED = 5
constexpr int WALK_SPEED = 30;
constexpr int STAND_TIME = 30;
//constexpr int STAND_TIME = 30;
constexpr int WALK_TIME = 300;
......
......@@ -24,7 +24,7 @@ A_GIK_LAND = 4,
A_GIK_SLIDE = 5
};
constexpr int MAX_BOUNCE_BOOST = -115;
//constexpr int MAX_BOUNCE_BOOST = -115;
constexpr int WALK_SPEED = 20;
constexpr int JUMP_X_SPEED = 40;
......
......@@ -22,6 +22,9 @@ mpMap(pMap),
m_Object(Object)
{}
CFinale::~CFinale()
{}
void CFinale::addMsgBoxString(const std::string &text)
{
std::unique_ptr<CMessageBoxVort> msg( new CMessageBoxVort(gBehaviorEngine.getString(text), true) );
......
......@@ -22,6 +22,8 @@ public:
const std::shared_ptr<CMap> &pMap,
std::vector< std::unique_ptr<CVorticonSpriteObject> > &Object);
virtual ~CFinale();
void addMsgBoxString(const std::string &text);
void showEndingText();
......
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