J :
* Create the subsystem for keybindings.
This commit is contained in:
@@ -110,6 +110,8 @@ install: $(TARGET_LIB) hge
|
||||
hge: $(TARGET_HGE)
|
||||
|
||||
ifeq ($(TARGET_ARCHITECTURE),linux)
|
||||
|
||||
|
||||
$(TARGET_LIB): $(OBJS)
|
||||
ar r $(TARGET_LIB) $(OBJS)
|
||||
|
||||
@@ -120,6 +122,9 @@ clean:
|
||||
$(RM) -f $(OBJS) $(HGE_OBJS) Makefile.$(TARGET_ARCHITECTURE)
|
||||
endif
|
||||
|
||||
Makefile.psp:
|
||||
@echo > $@
|
||||
|
||||
Makefile.linux:
|
||||
$(CXX) -o /dev/null src/testfeatures.c -L$(LIBDIR) -lfmod-3.75 > /dev/null 2>&1 ; if [ "0" = "$$?" ]; then echo 'FMOD=-DWITH_FMOD'; else echo 'FMOD=-DWITHOUT_FMOD'; fi > $@
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <queue>
|
||||
#include <map>
|
||||
|
||||
#include "JTypes.h"
|
||||
|
||||
@@ -23,27 +25,25 @@
|
||||
|
||||
//#define _MP3_ENABLED_
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <windows.h>
|
||||
|
||||
void JGEControl();
|
||||
BOOL JGEGetKeyState(int key);
|
||||
bool JGEGetButtonState(u32 button);
|
||||
bool JGEGetButtonClick(u32 button);
|
||||
u32 JGEReadKey();
|
||||
void JGEResetInput();
|
||||
|
||||
#elif LINUX
|
||||
|
||||
void JGEControl();
|
||||
BOOL JGEGetKeyState(int key);
|
||||
bool JGEGetButtonState(u32 button);
|
||||
bool JGEGetButtonClick(u32 button);
|
||||
u32 JGEReadKey();
|
||||
void JGEResetInput();
|
||||
|
||||
typedef WPARAM LocalKeySym;
|
||||
#elif defined(LINUX)
|
||||
#include <X11/XKBlib.h>
|
||||
typedef KeySym LocalKeySym;
|
||||
#else
|
||||
typedef u32 LocalKeySym;
|
||||
#endif
|
||||
|
||||
|
||||
bool JGEGetButtonState(const JButton button);
|
||||
bool JGEGetButtonClick(const JButton button);
|
||||
void JGECreateDefaultBindings();
|
||||
int JGEGetTime();
|
||||
u8 JGEGetAnalogX();
|
||||
u8 JGEGetAnalogY();
|
||||
|
||||
#if !defined(WIN32) && !defined(LINUX)
|
||||
|
||||
#include <pspgu.h>
|
||||
#include <pspkernel.h>
|
||||
@@ -77,46 +77,32 @@ class JGE
|
||||
{
|
||||
private:
|
||||
JApp *mApp;
|
||||
// JResourceManager *mResourceManager;
|
||||
// JFileSystem* mFileSystem;
|
||||
|
||||
// JParticleSystem* mParticleSystem;
|
||||
// JMotionSystem* mMotionSystem;
|
||||
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
float mDeltaTime;
|
||||
|
||||
JMusic *mCurrentMusic;
|
||||
|
||||
#else
|
||||
SceCtrlData mCtrlPad;
|
||||
u32 mOldButtons;
|
||||
u32 mVeryOldButtons;
|
||||
|
||||
u64 mLastTime;
|
||||
u32 mTickFrequency;
|
||||
|
||||
#endif
|
||||
|
||||
bool mDone;
|
||||
|
||||
float mDelta;
|
||||
|
||||
bool mDebug;
|
||||
|
||||
bool mPaused;
|
||||
|
||||
char mDebuggingMsg[256];
|
||||
|
||||
bool mCriticalAssert;
|
||||
const char *mAssertFile;
|
||||
int mAssertLine;
|
||||
u32 tickFrequency;
|
||||
|
||||
|
||||
static JGE* mInstance;
|
||||
|
||||
|
||||
static std::queue<JButton> keyBuffer;
|
||||
static std::multimap<LocalKeySym, JButton> keyBinds;
|
||||
typedef std::multimap<LocalKeySym, JButton>::iterator keycodes_it;
|
||||
|
||||
friend void Run();
|
||||
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -128,10 +114,9 @@ class JGE
|
||||
static void Destroy();
|
||||
|
||||
void Init();
|
||||
void Run();
|
||||
void End();
|
||||
|
||||
void Update();
|
||||
void Update(float);
|
||||
void Render();
|
||||
|
||||
void Pause();
|
||||
@@ -154,7 +139,7 @@ class JGE
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Return frame rate.
|
||||
///
|
||||
/// @note This is just 1.0f/GetDelat().
|
||||
/// @note This is just 1.0f/GetDelta().
|
||||
///
|
||||
/// @return Number of frames per second.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -167,29 +152,78 @@ class JGE
|
||||
///
|
||||
/// @return Button state.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool GetButtonState(u32 button);
|
||||
bool GetButtonState(JButton button);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Check if a button is down the first time.
|
||||
/// THIS DOES NOT WORK RELIABLY. DO NOT USE THIS.
|
||||
/// USE ReadButton() INSTEAD.
|
||||
///
|
||||
/// @param button - Button id.
|
||||
///
|
||||
/// @return Button state.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool GetButtonClick(u32 button);
|
||||
bool GetButtonClick(JButton button);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get the next keypress.
|
||||
///
|
||||
/// @return Next pressed button, or 0 if none.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
u32 ReadButton();
|
||||
JButton ReadButton();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Bind an actual key to a symbolic button. A key can be bound to
|
||||
/// several buttons and even several times to the same button (for
|
||||
/// double clicks on one button, for example.
|
||||
///
|
||||
/// @param keycode - The local code of the key
|
||||
/// @param button - The button to bind it to
|
||||
///
|
||||
/// @return The number of bound keys so far
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
u32 BindKey(LocalKeySym keycode, JButton button);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Undo a binding.
|
||||
/// If the second parameter is omitted, remove all bindings to this key ;
|
||||
/// else, remove exactly once the binding from this key to this button.
|
||||
///
|
||||
/// @param keycode - The local code of the key
|
||||
/// @param button - The button
|
||||
///
|
||||
/// @return The number of still bound keys
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
u32 UnbindKey(LocalKeySym keycode, JButton button);
|
||||
u32 UnbindKey(LocalKeySym keycode);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Clear bindings.
|
||||
/// This removes ALL bindings. Take care to re-bind keys after doing it.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void ClearBindings();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Reset bindings.
|
||||
/// This resets ALL bindings to their default value.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void ResetBindings();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Iterators for bindings.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
typedef std::multimap<LocalKeySym, JButton>::const_iterator keybindings_it;
|
||||
keybindings_it KeyBindings_begin();
|
||||
keybindings_it KeyBindings_end();
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Reset the input buffer.
|
||||
/// This is necessary because there might be phases when GetButtonState
|
||||
/// or GetButtonClick are used, thereby accumulating keypresses in the
|
||||
/// key buffer.
|
||||
/// This is necessary because there might be phases when only
|
||||
/// GetButtonState is used, thereby accumulating keypresses
|
||||
/// in the key buffer.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void ResetInput();
|
||||
@@ -208,13 +242,28 @@ class JGE
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
u8 GetAnalogY();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Simulate a keypress, or a keyhold/release.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void PressKey(const LocalKeySym);
|
||||
void PressKey(const JButton);
|
||||
void HoldKey(const LocalKeySym);
|
||||
void HoldKey(const JButton);
|
||||
void HoldKey_NoRepeat(const LocalKeySym);
|
||||
void HoldKey_NoRepeat(const JButton);
|
||||
void ReleaseKey(const LocalKeySym);
|
||||
void ReleaseKey(const JButton);
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get if the system is ended or not.
|
||||
/// Get if the system is ended/paused or not.
|
||||
///
|
||||
/// @return Status of the system.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool IsDone() { return mDone; }
|
||||
bool IsPaused() { return mPaused; }
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -235,7 +284,7 @@ class JGE
|
||||
void Assert(const char *filename, long lineNumber);
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
void SetDelta(int delta);
|
||||
void SetDelta(float delta);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
@@ -67,7 +67,7 @@ class JGuiController
|
||||
bool mActive;
|
||||
|
||||
|
||||
u32 mActionButton;
|
||||
JButton mActionButton;
|
||||
int mCurr;
|
||||
int mStyle;
|
||||
|
||||
@@ -94,14 +94,14 @@ class JGuiController
|
||||
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
virtual bool CheckUserInput(u32 key);
|
||||
virtual bool CheckUserInput(JButton key);
|
||||
|
||||
void Add(JGuiObject* ctrl);
|
||||
void RemoveAt(int i);
|
||||
void Remove(int id);
|
||||
void Remove(JGuiObject* ctrl);
|
||||
|
||||
void SetActionButton(u32 button);
|
||||
void SetActionButton(JButton button);
|
||||
void SetStyle(int style);
|
||||
void SetCursor(JSprite* cursor);
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
|
||||
typedef int8_t s8;
|
||||
typedef int16_t s16;
|
||||
@@ -111,25 +111,6 @@ typedef uint32_t u32;
|
||||
#define ARGB(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
|
||||
#define RGBA(r, g, b, a) (((a) << 24) | ((b) << 16) | ((g) << 8) | (r))
|
||||
|
||||
typedef enum PspCtrlButtons
|
||||
{
|
||||
PSP_CTRL_SELECT = 0x000001,
|
||||
PSP_CTRL_START = 0x000008,
|
||||
PSP_CTRL_UP = 0x000010,
|
||||
PSP_CTRL_RIGHT = 0x000020,
|
||||
PSP_CTRL_DOWN = 0x000040,
|
||||
PSP_CTRL_LEFT = 0x000080,
|
||||
PSP_CTRL_LTRIGGER = 0x000100,
|
||||
PSP_CTRL_RTRIGGER = 0x000200,
|
||||
PSP_CTRL_TRIANGLE = 0x001000,
|
||||
PSP_CTRL_CIRCLE = 0x002000,
|
||||
PSP_CTRL_CROSS = 0x004000,
|
||||
PSP_CTRL_SQUARE = 0x008000,
|
||||
PSP_CTRL_HOME = 0x010000,
|
||||
PSP_CTRL_HOLD = 0x020000,
|
||||
PSP_CTRL_NOTE = 0x800000
|
||||
} PspCtrlButtons;
|
||||
|
||||
#define TEXTURE_FORMAT 0
|
||||
#define GU_PSM_8888 0
|
||||
#define GU_PSM_5551 0
|
||||
@@ -228,6 +209,29 @@ typedef uint32_t u32;
|
||||
|
||||
|
||||
|
||||
typedef enum Buttons
|
||||
{
|
||||
JGE_BTN_NONE = 0, // No button pressed
|
||||
JGE_BTN_QUIT, // Home on PSP
|
||||
JGE_BTN_MENU, // Start on PSP
|
||||
JGE_BTN_CTRL, // Select
|
||||
JGE_BTN_POWER, // Hold
|
||||
JGE_BTN_SOUND, // Music note
|
||||
JGE_BTN_RIGHT,
|
||||
JGE_BTN_LEFT,
|
||||
JGE_BTN_UP,
|
||||
JGE_BTN_DOWN,
|
||||
JGE_BTN_OK, // Circle in Japan, Cross in Europe
|
||||
JGE_BTN_CANCEL, // Triangle
|
||||
JGE_BTN_PRI, // Square (primary)
|
||||
JGE_BTN_SEC, // Cross or Circle (secondary)
|
||||
JGE_BTN_PREV, // Left trigger
|
||||
JGE_BTN_NEXT, // Right trigger
|
||||
|
||||
JGE_BTN_MAX = JGE_BTN_NEXT + 1
|
||||
} JButton;
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
struct Vertex
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
|
||||
//
|
||||
// Licensed under the BSD license, see LICENSE in JGE root for details.
|
||||
//
|
||||
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#include "../include/JApp.h"
|
||||
#include "../include/JGE.h"
|
||||
|
||||
|
||||
JApp::JApp()
|
||||
{
|
||||
//mEngine = JGE::GetInstance();
|
||||
//mEngine->SetApp(this);
|
||||
}
|
||||
|
||||
|
||||
JApp::~JApp()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// JGE* JApp::GetJGE()
|
||||
// {
|
||||
// return mEngine;
|
||||
// }
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
|
||||
//
|
||||
// Licensed under the BSD license, see LICENSE in JGE root for details.
|
||||
//
|
||||
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#include "../include/JApp.h"
|
||||
#include "../include/JGE.h"
|
||||
|
||||
|
||||
JApp::JApp()
|
||||
{
|
||||
//mEngine = JGE::GetInstance();
|
||||
//mEngine->SetApp(this);
|
||||
}
|
||||
|
||||
|
||||
JApp::~JApp()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// JGE* JApp::GetJGE()
|
||||
// {
|
||||
// return mEngine;
|
||||
// }
|
||||
|
||||
928
JGE/src/JGE.cpp
928
JGE/src/JGE.cpp
@@ -1,475 +1,453 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
|
||||
//
|
||||
// Licensed under the BSD license, see LICENSE in JGE root for details.
|
||||
//
|
||||
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
#include "../include/JGE.h"
|
||||
#include "../include/JApp.h"
|
||||
#include "../include/JRenderer.h"
|
||||
#include "../include/JSoundSystem.h"
|
||||
#include "../include/Vector2D.h"
|
||||
#include "../include/JResourceManager.h"
|
||||
#include "../include/JFileSystem.h"
|
||||
//#include "../include/JParticleSystem.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#if defined (WIN32) // WIN32 specific code
|
||||
|
||||
int JGE::GetTime(void)
|
||||
{
|
||||
return (int)GetTickCount();
|
||||
}
|
||||
|
||||
u8 JGE::GetAnalogX()
|
||||
{
|
||||
if (JGEGetKeyState(VK_LEFT)) return 0;
|
||||
if (JGEGetKeyState(VK_RIGHT)) return 0xff;
|
||||
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
|
||||
u8 JGE::GetAnalogY()
|
||||
{
|
||||
if (JGEGetKeyState(VK_UP)) return 0;
|
||||
if (JGEGetKeyState(VK_DOWN)) return 0xff;
|
||||
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
#elif defined (LINUX) // Unix specific code
|
||||
#include <sys/time.h>
|
||||
#include "png.h"
|
||||
#include "../Dependencies/include/fmod.h"
|
||||
|
||||
int JGE::GetTime(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||
}
|
||||
|
||||
u8 JGE::GetAnalogX()
|
||||
{
|
||||
/* FIXME
|
||||
if (JGEGetKeyState(VK_LEFT)) return 0;
|
||||
if (JGEGetKeyState(VK_RIGHT)) return 0xff;
|
||||
*/
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
|
||||
u8 JGE::GetAnalogY()
|
||||
{
|
||||
/* FIXME
|
||||
if (JGEGetKeyState(VK_UP)) return 0;
|
||||
if (JGEGetKeyState(VK_DOWN)) return 0xff;
|
||||
*/
|
||||
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined (WIN32) || defined (LINUX) // Non-PSP code
|
||||
|
||||
JGE::JGE()
|
||||
{
|
||||
mApp = NULL;
|
||||
|
||||
strcpy(mDebuggingMsg, "");
|
||||
mCurrentMusic = NULL;
|
||||
Init();
|
||||
|
||||
}
|
||||
|
||||
|
||||
JGE::~JGE()
|
||||
{
|
||||
JRenderer::Destroy();
|
||||
JFileSystem::Destroy();
|
||||
JSoundSystem::Destroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void JGE::Init()
|
||||
{
|
||||
mDone = false;
|
||||
mPaused = false;
|
||||
mCriticalAssert = false;
|
||||
|
||||
JRenderer::GetInstance();
|
||||
JFileSystem::GetInstance();
|
||||
JSoundSystem::GetInstance();
|
||||
}
|
||||
|
||||
void JGE::Run()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void JGE::SetDelta(int delta)
|
||||
{
|
||||
mDeltaTime = (float)delta / 1000.0f; // change to second
|
||||
}
|
||||
|
||||
float JGE::GetDelta()
|
||||
{
|
||||
return mDeltaTime;
|
||||
//return hge->Timer_GetDelta()*1000;
|
||||
}
|
||||
|
||||
|
||||
float JGE::GetFPS()
|
||||
{
|
||||
//return (float)hge->Timer_GetFPS();
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
||||
bool JGE::GetButtonState(u32 button)
|
||||
{
|
||||
//return (gButtons&button)==button;
|
||||
return JGEGetButtonState(button);
|
||||
}
|
||||
|
||||
|
||||
bool JGE::GetButtonClick(u32 button)
|
||||
{
|
||||
//return (gButtons&button)==button && (gOldButtons&button)!=button;
|
||||
return JGEGetButtonClick(button);
|
||||
}
|
||||
|
||||
u32 JGE::ReadButton()
|
||||
{
|
||||
return JGEReadKey();
|
||||
}
|
||||
|
||||
void JGE::ResetInput()
|
||||
{
|
||||
JGEResetInput();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#else ///// PSP specified code
|
||||
|
||||
|
||||
|
||||
#include <queue>
|
||||
static queue<u32> gKeyBuffer;
|
||||
static const int gKeyCodeList[] = {
|
||||
PSP_CTRL_SELECT, // Select button.
|
||||
PSP_CTRL_START, // Start button.
|
||||
PSP_CTRL_UP, // Up D-Pad button.
|
||||
PSP_CTRL_RIGHT, // Right D-Pad button.
|
||||
PSP_CTRL_DOWN, // Down D-Pad button.
|
||||
PSP_CTRL_LEFT, // Left D-Pad button.
|
||||
PSP_CTRL_LTRIGGER, // Left trigger.
|
||||
PSP_CTRL_RTRIGGER, // Right trigger.
|
||||
PSP_CTRL_TRIANGLE, // Triangle button.
|
||||
PSP_CTRL_CIRCLE, // Circle button.
|
||||
PSP_CTRL_CROSS, // Cross button.
|
||||
PSP_CTRL_SQUARE, // Square button.
|
||||
PSP_CTRL_HOLD, // Hold button.
|
||||
/* Do not test keys we cannot get anyway, that's just wasted proc time
|
||||
PSP_CTRL_HOME, // Home button.
|
||||
PSP_CTRL_NOTE, // Music Note button.
|
||||
PSP_CTRL_SCREEN, // Screen button.
|
||||
PSP_CTRL_VOLUP, // Volume up button.
|
||||
PSP_CTRL_VOLDOWN, // Volume down button.
|
||||
PSP_CTRL_WLAN, // _UP Wlan switch up.
|
||||
PSP_CTRL_REMOTE, // Remote hold position.
|
||||
PSP_CTRL_DISC, // Disc present.
|
||||
PSP_CTRL_MS // Memory stick present.
|
||||
*/
|
||||
};
|
||||
static u32 gHolds = 0;
|
||||
|
||||
|
||||
JGE::JGE()
|
||||
{
|
||||
mApp = NULL;
|
||||
|
||||
Init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
JGE::~JGE()
|
||||
{
|
||||
JRenderer::Destroy();
|
||||
JSoundSystem::Destroy();
|
||||
JFileSystem::Destroy();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void JGE::Init()
|
||||
{
|
||||
|
||||
#ifdef DEBUG_PRINT
|
||||
mDebug = true;
|
||||
#else
|
||||
mDebug = false;
|
||||
#endif
|
||||
|
||||
if (mDebug)
|
||||
pspDebugScreenInit(); // do this so that we can use pspDebugScreenPrintf
|
||||
|
||||
strcpy(mDebuggingMsg, "");
|
||||
|
||||
sceCtrlSetSamplingCycle(0);
|
||||
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
|
||||
|
||||
JRenderer::GetInstance();
|
||||
JFileSystem::GetInstance();
|
||||
JSoundSystem::GetInstance();
|
||||
|
||||
mDone = false;
|
||||
mPaused = false;
|
||||
mCriticalAssert = false;
|
||||
mOldButtons = mVeryOldButtons = 0;
|
||||
|
||||
mTickFrequency = sceRtcGetTickResolution();
|
||||
sceRtcGetCurrentTick(&mLastTime);
|
||||
}
|
||||
|
||||
|
||||
// returns number of milliseconds since game started
|
||||
int JGE::GetTime(void)
|
||||
{
|
||||
|
||||
u64 curr;
|
||||
sceRtcGetCurrentTick(&curr);
|
||||
return (int)((curr * 1000) / mTickFrequency);
|
||||
}
|
||||
|
||||
|
||||
float JGE::GetDelta()
|
||||
{
|
||||
return mDelta;
|
||||
}
|
||||
|
||||
|
||||
float JGE::GetFPS()
|
||||
{
|
||||
return 1.0f / mDelta;
|
||||
}
|
||||
|
||||
|
||||
bool JGE::GetButtonState(u32 button)
|
||||
{
|
||||
return (mCtrlPad.Buttons&button)==button;
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool JGE::GetButtonClick(u32 button)
|
||||
{
|
||||
return (mCtrlPad.Buttons&button)==button && (mVeryOldButtons&button)!=button;
|
||||
}
|
||||
|
||||
u32 JGE::ReadButton()
|
||||
{
|
||||
if (gKeyBuffer.empty()) return 0;
|
||||
u32 val = gKeyBuffer.front();
|
||||
gHolds &= ~val;
|
||||
gKeyBuffer.pop();
|
||||
return val;
|
||||
}
|
||||
|
||||
void JGE::ResetInput()
|
||||
{
|
||||
while (!gKeyBuffer.empty()) gKeyBuffer.pop();
|
||||
}
|
||||
|
||||
u8 JGE::GetAnalogX()
|
||||
{
|
||||
return mCtrlPad.Lx;
|
||||
}
|
||||
|
||||
|
||||
u8 JGE::GetAnalogY()
|
||||
{
|
||||
return mCtrlPad.Ly;
|
||||
}
|
||||
|
||||
#define REPEAT_DELAY 0.5
|
||||
#define REPEAT_FREQUENCY 7
|
||||
void JGE::Run()
|
||||
{
|
||||
u64 curr;
|
||||
long long int nextInput = 0;
|
||||
|
||||
const u32 ticksPerSecond = sceRtcGetTickResolution();
|
||||
const u64 repeatDelay = REPEAT_DELAY * ticksPerSecond;
|
||||
const u64 repeatPeriod = ticksPerSecond / REPEAT_FREQUENCY;
|
||||
|
||||
while (!mDone)
|
||||
{
|
||||
if (!mPaused)
|
||||
{
|
||||
sceRtcGetCurrentTick(&curr);
|
||||
|
||||
mDelta = (curr-mLastTime) / (float)mTickFrequency;// * 1000.0f;
|
||||
|
||||
sceCtrlPeekBufferPositive(&mCtrlPad, 1);
|
||||
for (signed int i = sizeof(gKeyCodeList)/sizeof(gKeyCodeList[0]) - 1; i >= 0; --i)
|
||||
{
|
||||
if (gKeyCodeList[i] & mCtrlPad.Buttons)
|
||||
{
|
||||
if (!(gKeyCodeList[i] & mOldButtons))
|
||||
{
|
||||
if (!(gHolds & gKeyCodeList[i])) gKeyBuffer.push(gKeyCodeList[i]);
|
||||
nextInput = repeatDelay;
|
||||
gHolds |= gKeyCodeList[i];
|
||||
}
|
||||
else if (nextInput < 0)
|
||||
{
|
||||
if (!(gHolds & gKeyCodeList[i])) gKeyBuffer.push(gKeyCodeList[i]);
|
||||
nextInput = repeatPeriod;
|
||||
gHolds |= gKeyCodeList[i];
|
||||
}
|
||||
}
|
||||
if (!(gKeyCodeList[i] & mCtrlPad.Buttons))
|
||||
if (gKeyCodeList[i] & mOldButtons)
|
||||
gHolds &= ~gKeyCodeList[i];
|
||||
}
|
||||
mOldButtons = mCtrlPad.Buttons;
|
||||
|
||||
nextInput -= (curr - mLastTime);
|
||||
mLastTime = curr;
|
||||
|
||||
Update();
|
||||
Render();
|
||||
|
||||
if (mDebug)
|
||||
{
|
||||
if (strlen(mDebuggingMsg)>0)
|
||||
{
|
||||
pspDebugScreenSetXY(0, 0);
|
||||
pspDebugScreenPrintf(mDebuggingMsg);
|
||||
}
|
||||
}
|
||||
mVeryOldButtons = mCtrlPad.Buttons;
|
||||
}
|
||||
else
|
||||
{
|
||||
sceKernelDelayThread(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif ///// PSP specified code
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JGE* JGE::mInstance = NULL;
|
||||
//static int gCount = 0;
|
||||
|
||||
JGE* JGE::GetInstance()
|
||||
{
|
||||
if (mInstance == NULL)
|
||||
{
|
||||
mInstance = new JGE();
|
||||
}
|
||||
|
||||
//gCount++;
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
|
||||
void JGE::Destroy()
|
||||
{
|
||||
//gCount--;
|
||||
if (mInstance)
|
||||
{
|
||||
delete mInstance;
|
||||
mInstance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void JGE::SetApp(JApp *app)
|
||||
{
|
||||
mApp = app;
|
||||
}
|
||||
|
||||
|
||||
void JGE::Update()
|
||||
{
|
||||
if (mApp != NULL)
|
||||
mApp->Update();
|
||||
}
|
||||
|
||||
void JGE::Render()
|
||||
{
|
||||
JRenderer* renderer = JRenderer::GetInstance();
|
||||
|
||||
renderer->BeginScene();
|
||||
|
||||
if (mApp != NULL)
|
||||
mApp->Render();
|
||||
|
||||
renderer->EndScene();
|
||||
}
|
||||
|
||||
|
||||
void JGE::End()
|
||||
{
|
||||
mDone = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void JGE::printf(const char *format, ...)
|
||||
{
|
||||
va_list list;
|
||||
|
||||
va_start(list, format);
|
||||
vsprintf(mDebuggingMsg, format, list);
|
||||
va_end(list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void JGE::Pause()
|
||||
{
|
||||
if (mPaused) return;
|
||||
|
||||
mPaused = true;
|
||||
if (mApp != NULL)
|
||||
mApp->Pause();
|
||||
}
|
||||
|
||||
|
||||
void JGE::Resume()
|
||||
{
|
||||
if (mPaused)
|
||||
{
|
||||
mPaused = false;
|
||||
if (mApp != NULL)
|
||||
mApp->Resume();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void JGE::Assert(const char *filename, long lineNumber)
|
||||
{
|
||||
mAssertFile = filename;
|
||||
mAssertLine = lineNumber;
|
||||
mCriticalAssert = true;
|
||||
|
||||
|
||||
}
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
|
||||
//
|
||||
// Licensed under the BSD license, see LICENSE in JGE root for details.
|
||||
//
|
||||
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
#include "../include/JGE.h"
|
||||
#include "../include/JApp.h"
|
||||
#include "../include/JRenderer.h"
|
||||
#include "../include/JSoundSystem.h"
|
||||
#include "../include/Vector2D.h"
|
||||
#include "../include/JResourceManager.h"
|
||||
#include "../include/JFileSystem.h"
|
||||
//#include "../include/JParticleSystem.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#if defined (WIN32) // WIN32 specific code
|
||||
#include "../../Dependencies/include/png.h"
|
||||
#include "../../Dependencies/include/fmod.h"
|
||||
|
||||
u8 JGE::GetAnalogX()
|
||||
{
|
||||
if (JGEGetKeyState(VK_LEFT)) return 0;
|
||||
if (JGEGetKeyState(VK_RIGHT)) return 0xff;
|
||||
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
|
||||
u8 JGE::GetAnalogY()
|
||||
{
|
||||
if (JGEGetKeyState(VK_UP)) return 0;
|
||||
if (JGEGetKeyState(VK_DOWN)) return 0xff;
|
||||
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
#elif defined (LINUX) // Unix specific code
|
||||
#include <sys/time.h>
|
||||
#include "png.h"
|
||||
#include "../Dependencies/include/fmod.h"
|
||||
|
||||
|
||||
u8 JGE::GetAnalogX()
|
||||
{
|
||||
/* FIXME
|
||||
if (JGEGetKeyState(VK_LEFT)) return 0;
|
||||
if (JGEGetKeyState(VK_RIGHT)) return 0xff;
|
||||
*/
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
|
||||
u8 JGE::GetAnalogY()
|
||||
{
|
||||
/* FIXME
|
||||
if (JGEGetKeyState(VK_UP)) return 0;
|
||||
if (JGEGetKeyState(VK_DOWN)) return 0xff;
|
||||
*/
|
||||
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static map<JButton, float> holds;
|
||||
static map<JButton, float> oldHolds;
|
||||
#define REPEAT_DELAY 0.5
|
||||
#define REPEAT_PERIOD 0.07
|
||||
|
||||
void JGE::PressKey(const LocalKeySym sym)
|
||||
{
|
||||
const pair<keycodes_it, keycodes_it> rng = keyBinds.equal_range(sym);
|
||||
for (keycodes_it it = rng.first; it != rng.second; ++it)
|
||||
keyBuffer.push(it->second);
|
||||
}
|
||||
void JGE::PressKey(const JButton sym)
|
||||
{
|
||||
keyBuffer.push(sym);
|
||||
}
|
||||
void JGE::HoldKey(const LocalKeySym sym)
|
||||
{
|
||||
const pair<keycodes_it, keycodes_it> rng = keyBinds.equal_range(sym);
|
||||
for (keycodes_it it = rng.first; it != rng.second; ++it)
|
||||
{
|
||||
keyBuffer.push(it->second);
|
||||
if (holds.end() == holds.find(it->second))
|
||||
holds[it->second] = REPEAT_DELAY;
|
||||
}
|
||||
}
|
||||
void JGE::HoldKey_NoRepeat(const LocalKeySym sym)
|
||||
{
|
||||
const pair<keycodes_it, keycodes_it> rng = keyBinds.equal_range(sym);
|
||||
for (keycodes_it it = rng.first; it != rng.second; ++it)
|
||||
{
|
||||
keyBuffer.push(it->second);
|
||||
if (holds.end() == holds.find(it->second))
|
||||
holds[it->second] = NAN;
|
||||
}
|
||||
}
|
||||
void JGE::HoldKey(const JButton sym)
|
||||
{
|
||||
keyBuffer.push(sym);
|
||||
if (holds.end() == holds.find(sym)) holds[sym] = REPEAT_DELAY;
|
||||
}
|
||||
void JGE::HoldKey_NoRepeat(const JButton sym)
|
||||
{
|
||||
keyBuffer.push(sym);
|
||||
if (holds.end() == holds.find(sym)) holds[sym] = NAN;
|
||||
}
|
||||
void JGE::ReleaseKey(const LocalKeySym sym)
|
||||
{
|
||||
const pair<keycodes_it, keycodes_it> rng = keyBinds.equal_range(sym);
|
||||
for (keycodes_it it = rng.first; it != rng.second; ++it)
|
||||
holds.erase(it->second);
|
||||
}
|
||||
void JGE::ReleaseKey(const JButton sym)
|
||||
{
|
||||
holds.erase(sym);
|
||||
}
|
||||
void JGE::Update(float dt)
|
||||
{
|
||||
for (map<JButton, float>::iterator it = holds.begin(); it != holds.end(); ++it)
|
||||
{
|
||||
if (it->second < 0) { keyBuffer.push(it->first); it->second = REPEAT_PERIOD; }
|
||||
it->second -= dt;
|
||||
}
|
||||
if (mApp != NULL) mApp->Update();
|
||||
oldHolds = holds;
|
||||
}
|
||||
|
||||
|
||||
bool JGE::GetButtonState(JButton button)
|
||||
{
|
||||
return (holds.end() != holds.find(button));
|
||||
}
|
||||
|
||||
|
||||
bool JGE::GetButtonClick(JButton button)
|
||||
{
|
||||
cout << "HOLDS : ";
|
||||
for (map<JButton, float>::iterator it = holds.begin(); it != holds.end(); ++it)
|
||||
cout << it->first << " ";
|
||||
cout << endl << "OLDHOLDS : ";
|
||||
for (map<JButton, float>::iterator it = oldHolds.begin(); it != oldHolds.end(); ++it)
|
||||
cout << it->first << " ";
|
||||
cout << endl;
|
||||
return ((holds.end() != holds.find(button)) && (oldHolds.end() == oldHolds.find(button)));
|
||||
}
|
||||
|
||||
|
||||
JButton JGE::ReadButton()
|
||||
{
|
||||
if (keyBuffer.empty()) return JGE_BTN_NONE;
|
||||
JButton val = keyBuffer.front();
|
||||
keyBuffer.pop();
|
||||
return val;
|
||||
}
|
||||
|
||||
u32 JGE::BindKey(LocalKeySym sym, JButton button)
|
||||
{
|
||||
keyBinds.insert(make_pair(sym, button));
|
||||
return keyBinds.size();
|
||||
}
|
||||
|
||||
u32 JGE::UnbindKey(LocalKeySym sym, JButton button)
|
||||
{
|
||||
for (keycodes_it it = keyBinds.begin(); it != keyBinds.end(); )
|
||||
if (sym == it->first && button == it->second)
|
||||
{
|
||||
keycodes_it er = it;
|
||||
++it;
|
||||
keyBinds.erase(er);
|
||||
}
|
||||
else ++it;
|
||||
return keyBinds.size();
|
||||
}
|
||||
|
||||
u32 JGE::UnbindKey(LocalKeySym sym)
|
||||
{
|
||||
pair<keycodes_it, keycodes_it> rng = keyBinds.equal_range(sym);
|
||||
keyBinds.erase(rng.first, rng.second);
|
||||
return keyBinds.size();
|
||||
}
|
||||
|
||||
void JGE::ClearBindings()
|
||||
{
|
||||
keyBinds.clear();
|
||||
}
|
||||
|
||||
void JGE::ResetBindings()
|
||||
{
|
||||
keyBinds.clear();
|
||||
JGECreateDefaultBindings();
|
||||
}
|
||||
|
||||
|
||||
JGE::keybindings_it JGE::KeyBindings_begin() { return keyBinds.begin(); }
|
||||
JGE::keybindings_it JGE::KeyBindings_end() { return keyBinds.end(); }
|
||||
|
||||
void JGE::ResetInput()
|
||||
{
|
||||
while (!keyBuffer.empty()) keyBuffer.pop();
|
||||
holds.clear();
|
||||
}
|
||||
|
||||
|
||||
JGE::JGE()
|
||||
{
|
||||
mApp = NULL;
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
strcpy(mDebuggingMsg, "");
|
||||
mCurrentMusic = NULL;
|
||||
#endif
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
JGE::~JGE()
|
||||
{
|
||||
JRenderer::Destroy();
|
||||
JFileSystem::Destroy();
|
||||
JSoundSystem::Destroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if defined (WIN32) || defined (LINUX) // Non-PSP code
|
||||
|
||||
void JGE::Init()
|
||||
{
|
||||
mDone = false;
|
||||
mPaused = false;
|
||||
mCriticalAssert = false;
|
||||
JRenderer::GetInstance();
|
||||
JFileSystem::GetInstance();
|
||||
JSoundSystem::GetInstance();
|
||||
}
|
||||
|
||||
void JGE::SetDelta(float delta)
|
||||
{
|
||||
mDeltaTime = (float)delta;
|
||||
}
|
||||
|
||||
float JGE::GetDelta()
|
||||
{
|
||||
return mDeltaTime;
|
||||
}
|
||||
|
||||
float JGE::GetFPS()
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#else ///// PSP specific code
|
||||
|
||||
|
||||
void JGE::Init()
|
||||
{
|
||||
#ifdef DEBUG_PRINT
|
||||
mDebug = true;
|
||||
#else
|
||||
mDebug = false;
|
||||
#endif
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
tickFrequency = 120;
|
||||
#else
|
||||
tickFrequency = sceRtcGetTickResolution();
|
||||
#endif
|
||||
|
||||
if (mDebug)
|
||||
pspDebugScreenInit(); // do this so that we can use pspDebugScreenPrintf
|
||||
|
||||
strcpy(mDebuggingMsg, "");
|
||||
|
||||
sceCtrlSetSamplingCycle(0);
|
||||
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
|
||||
|
||||
JRenderer::GetInstance();
|
||||
JFileSystem::GetInstance();
|
||||
JSoundSystem::GetInstance();
|
||||
|
||||
mDone = false;
|
||||
mPaused = false;
|
||||
mCriticalAssert = false;
|
||||
}
|
||||
|
||||
float JGE::GetDelta()
|
||||
{
|
||||
return mDelta;
|
||||
}
|
||||
|
||||
|
||||
float JGE::GetFPS()
|
||||
{
|
||||
return 1.0f / mDelta;
|
||||
}
|
||||
|
||||
u8 JGE::GetAnalogX()
|
||||
{
|
||||
return JGEGetAnalogX();
|
||||
}
|
||||
|
||||
u8 JGE::GetAnalogY()
|
||||
{
|
||||
return JGEGetAnalogY();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
bool JGE::GetButtonState(u32 button)
|
||||
{
|
||||
return (mCtrlPad.Buttons&button)==button;
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool JGE::GetButtonClick(u32 button)
|
||||
{
|
||||
return (mCtrlPad.Buttons&button)==button && (mVeryOldButtons&button)!=button;
|
||||
}
|
||||
|
||||
u32 JGE::ReadButton()
|
||||
{
|
||||
if (gKeyBuffer.empty()) return 0;
|
||||
u32 val = gKeyBuffer.front();
|
||||
gHolds &= ~val;
|
||||
gKeyBuffer.pop();
|
||||
return val;
|
||||
}
|
||||
|
||||
void JGE::ResetInput()
|
||||
{
|
||||
while (!gKeyBuffer.empty()) gKeyBuffer.pop();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
#endif ///// PSP specific code
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JGE* JGE::mInstance = NULL;
|
||||
//static int gCount = 0;
|
||||
|
||||
// returns number of milliseconds since game started
|
||||
int JGE::GetTime()
|
||||
{
|
||||
return JGEGetTime();
|
||||
}
|
||||
|
||||
|
||||
JGE* JGE::GetInstance()
|
||||
{
|
||||
if (mInstance == NULL)
|
||||
{
|
||||
mInstance = new JGE();
|
||||
}
|
||||
|
||||
//gCount++;
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
|
||||
void JGE::Destroy()
|
||||
{
|
||||
//gCount--;
|
||||
if (mInstance)
|
||||
{
|
||||
delete mInstance;
|
||||
mInstance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void JGE::SetApp(JApp *app)
|
||||
{
|
||||
mApp = app;
|
||||
}
|
||||
|
||||
void JGE::Render()
|
||||
{
|
||||
JRenderer* renderer = JRenderer::GetInstance();
|
||||
|
||||
renderer->BeginScene();
|
||||
if (mApp != NULL) mApp->Render();
|
||||
renderer->EndScene();
|
||||
}
|
||||
|
||||
|
||||
void JGE::End()
|
||||
{
|
||||
mDone = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void JGE::printf(const char *format, ...)
|
||||
{
|
||||
va_list list;
|
||||
|
||||
va_start(list, format);
|
||||
vsprintf(mDebuggingMsg, format, list);
|
||||
va_end(list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void JGE::Pause()
|
||||
{
|
||||
if (mPaused) return;
|
||||
|
||||
mPaused = true;
|
||||
if (mApp != NULL)
|
||||
mApp->Pause();
|
||||
}
|
||||
|
||||
|
||||
void JGE::Resume()
|
||||
{
|
||||
if (mPaused)
|
||||
{
|
||||
mPaused = false;
|
||||
if (mApp != NULL)
|
||||
mApp->Resume();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void JGE::Assert(const char *filename, long lineNumber)
|
||||
{
|
||||
mAssertFile = filename;
|
||||
mAssertLine = lineNumber;
|
||||
mCriticalAssert = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
std::queue<JButton> JGE::keyBuffer;
|
||||
std::multimap<LocalKeySym, JButton> JGE::keyBinds;
|
||||
|
||||
@@ -75,7 +75,7 @@ JGuiController::JGuiController(int id, JGuiListener* listener) : mId(id), mListe
|
||||
mCursorY = SCREEN_HEIGHT/2;
|
||||
mShowCursor = false;
|
||||
|
||||
mActionButton = PSP_CTRL_CIRCLE;
|
||||
mActionButton = JGE_BTN_OK;
|
||||
|
||||
mStyle = JGUI_STYLE_WRAPPING;
|
||||
|
||||
@@ -98,7 +98,7 @@ void JGuiController::Render()
|
||||
if (mObjects[i]!=NULL)
|
||||
mObjects[i]->Render();
|
||||
}
|
||||
bool JGuiController::CheckUserInput(u32 key){
|
||||
bool JGuiController::CheckUserInput(JButton key){
|
||||
|
||||
if (key == mActionButton)
|
||||
{
|
||||
@@ -109,7 +109,7 @@ bool JGuiController::CheckUserInput(u32 key){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if ((PSP_CTRL_LEFT == key) || (PSP_CTRL_UP == key)) // || mEngine->GetAnalogY() < 64 || mEngine->GetAnalogX() < 64)
|
||||
else if ((JGE_BTN_LEFT == key) || (JGE_BTN_UP == key)) // || mEngine->GetAnalogY() < 64 || mEngine->GetAnalogX() < 64)
|
||||
{
|
||||
int n = mCurr;
|
||||
n--;
|
||||
@@ -121,14 +121,14 @@ bool JGuiController::CheckUserInput(u32 key){
|
||||
n = 0;
|
||||
}
|
||||
|
||||
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_UP))
|
||||
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(JGE_BTN_UP))
|
||||
{
|
||||
mCurr = n;
|
||||
mObjects[mCurr]->Entering();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if ((PSP_CTRL_RIGHT == key) || (PSP_CTRL_DOWN == key)) // || mEngine->GetAnalogY()>192 || mEngine->GetAnalogX()>192)
|
||||
else if ((JGE_BTN_RIGHT == key) || (JGE_BTN_DOWN == key)) // || mEngine->GetAnalogY()>192 || mEngine->GetAnalogX()>192)
|
||||
{
|
||||
int n = mCurr;
|
||||
n++;
|
||||
@@ -140,7 +140,7 @@ bool JGuiController::CheckUserInput(u32 key){
|
||||
n = mCount-1;
|
||||
}
|
||||
|
||||
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_DOWN))
|
||||
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(JGE_BTN_DOWN))
|
||||
{
|
||||
mCurr = n;
|
||||
mObjects[mCurr]->Entering();
|
||||
@@ -155,7 +155,7 @@ void JGuiController::Update(float dt)
|
||||
if (mObjects[i]!=NULL)
|
||||
mObjects[i]->Update(dt);
|
||||
|
||||
u32 key = mEngine->ReadButton();
|
||||
JButton key = mEngine->ReadButton();
|
||||
CheckUserInput(key);
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ void JGuiController::Remove(JGuiObject* ctrl)
|
||||
}
|
||||
|
||||
|
||||
void JGuiController::SetActionButton(u32 button) { mActionButton = button; }
|
||||
void JGuiController::SetActionButton(JButton button) { mActionButton = button; }
|
||||
void JGuiController::SetStyle(int style) { mStyle = style; }
|
||||
void JGuiController::SetCursor(JSprite* cursor) { mCursor = cursor; }
|
||||
bool JGuiController::IsActive() { return mActive; }
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#include <X11/XKBlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <queue>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#include "../../JGE/include/JGE.h"
|
||||
#include "../../JGE/include/JTypes.h"
|
||||
@@ -29,9 +30,9 @@ struct window_state_t
|
||||
|
||||
enum
|
||||
{
|
||||
_NET_WM_STATE_REMOVE =0,
|
||||
_NET_WM_STATE_ADD = 1,
|
||||
_NET_WM_STATE_TOGGLE =2
|
||||
_NET_WM_STATE_REMOVE =0,
|
||||
_NET_WM_STATE_ADD = 1,
|
||||
_NET_WM_STATE_TOGGLE =2
|
||||
};
|
||||
|
||||
|
||||
@@ -50,39 +51,35 @@ Display* gXDisplay = NULL;
|
||||
Window gXWindow = NULL;
|
||||
GLXWindow glxWin = NULL;
|
||||
|
||||
static queue< pair<KeySym, u32> > gKeyBuffer;
|
||||
static u32 gControllerState = 0;
|
||||
static u32 gPrevControllerState = 0;
|
||||
static u32 gHolds = 0;
|
||||
static std::multiset<JButton> gControllerState;
|
||||
static std::multiset<JButton> gPrevControllerState;
|
||||
|
||||
static const struct { KeySym keysym; u32 pspCode; } gDefaultBindings[] =
|
||||
static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[] =
|
||||
{
|
||||
{ XK_Escape, PSP_CTRL_START },
|
||||
{ XK_Return, PSP_CTRL_START },
|
||||
{ XK_BackSpace, PSP_CTRL_SELECT },
|
||||
{ XK_Up, PSP_CTRL_UP },
|
||||
{ XK_KP_Up, PSP_CTRL_UP },
|
||||
{ XK_Down, PSP_CTRL_DOWN },
|
||||
{ XK_KP_Down, PSP_CTRL_DOWN },
|
||||
{ XK_Left, PSP_CTRL_LEFT },
|
||||
{ XK_KP_Left, PSP_CTRL_LEFT },
|
||||
{ XK_Right, PSP_CTRL_RIGHT },
|
||||
{ XK_KP_Right, PSP_CTRL_RIGHT },
|
||||
{ XK_space, PSP_CTRL_CIRCLE },
|
||||
{ XK_Control_L, PSP_CTRL_CIRCLE },
|
||||
{ XK_Control_R, PSP_CTRL_CIRCLE },
|
||||
{ XK_Tab, PSP_CTRL_TRIANGLE },
|
||||
{ XK_Alt_L, PSP_CTRL_SQUARE },
|
||||
{ XK_Caps_Lock, PSP_CTRL_CROSS },
|
||||
{ XK_Shift_L, PSP_CTRL_LTRIGGER },
|
||||
{ XK_Shift_R, PSP_CTRL_RTRIGGER },
|
||||
{ XK_F1, PSP_CTRL_HOME },
|
||||
{ XK_F2, PSP_CTRL_HOLD },
|
||||
{ XK_F3, PSP_CTRL_NOTE }
|
||||
{ XK_Escape, JGE_BTN_MENU },
|
||||
{ XK_Return, JGE_BTN_MENU },
|
||||
{ XK_BackSpace, JGE_BTN_CTRL },
|
||||
{ XK_Up, JGE_BTN_UP },
|
||||
{ XK_KP_Up, JGE_BTN_UP },
|
||||
{ XK_Down, JGE_BTN_DOWN },
|
||||
{ XK_KP_Down, JGE_BTN_DOWN },
|
||||
{ XK_Left, JGE_BTN_LEFT },
|
||||
{ XK_KP_Left, JGE_BTN_LEFT },
|
||||
{ XK_Right, JGE_BTN_RIGHT },
|
||||
{ XK_KP_Right, JGE_BTN_RIGHT },
|
||||
{ XK_space, JGE_BTN_OK },
|
||||
{ XK_Control_L, JGE_BTN_OK },
|
||||
{ XK_Control_R, JGE_BTN_OK },
|
||||
{ XK_Tab, JGE_BTN_CANCEL },
|
||||
{ XK_Alt_L, JGE_BTN_PRI },
|
||||
{ XK_Caps_Lock, JGE_BTN_SEC },
|
||||
{ XK_Shift_L, JGE_BTN_PREV },
|
||||
{ XK_Shift_R, JGE_BTN_NEXT },
|
||||
{ XK_F1, JGE_BTN_QUIT },
|
||||
{ XK_F2, JGE_BTN_POWER },
|
||||
{ XK_F3, JGE_BTN_SOUND }
|
||||
};
|
||||
|
||||
static vector< pair<KeySym, u32> > gKeyCodes;
|
||||
|
||||
GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize The GL Window
|
||||
{
|
||||
|
||||
@@ -210,9 +207,6 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits __attribute__((
|
||||
return false;
|
||||
}
|
||||
|
||||
for (signed int i = sizeof(gDefaultBindings)/sizeof(gDefaultBindings[0]) - 1; i >= 0; --i)
|
||||
gKeyCodes.push_back(make_pair(gDefaultBindings[i].keysym, gDefaultBindings[i].pspCode));
|
||||
|
||||
// Get a suitable framebuffer config
|
||||
int numReturned;
|
||||
GLXFBConfig *fbConfigs = glXChooseFBConfig(gXDisplay, DefaultScreen(gXDisplay), doubleBufferAttributes, &numReturned);
|
||||
@@ -266,83 +260,37 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits __attribute__((
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void JGEControl()
|
||||
void Update(float dt)
|
||||
{
|
||||
gPrevControllerState = gControllerState;
|
||||
}
|
||||
|
||||
void Update(int dt)
|
||||
{
|
||||
g_engine->SetDelta(dt);
|
||||
g_engine->Update();
|
||||
JGEControl();
|
||||
g_engine->Update(dt);
|
||||
}
|
||||
|
||||
|
||||
int DrawGLScene(void) // Here's Where We Do All The Drawing
|
||||
int DrawGLScene(void)
|
||||
{
|
||||
|
||||
// glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
|
||||
// glLoadIdentity (); // Reset The Modelview Matrix
|
||||
|
||||
//if (g_app)
|
||||
// g_app->Render();
|
||||
g_engine->Render();
|
||||
|
||||
// glFlush ();
|
||||
|
||||
return true; // Everything Went OK
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool JGEGetButtonState(u32 button)
|
||||
template <typename T>
|
||||
static inline bool include(multiset<T> set, T button)
|
||||
{
|
||||
return gControllerState & button;
|
||||
return set.end() != set.find(button);
|
||||
}
|
||||
|
||||
bool JGEGetButtonClick(u32 button)
|
||||
void JGECreateDefaultBindings()
|
||||
{
|
||||
return ((gControllerState & button) && (!(gPrevControllerState & button)));
|
||||
for (signed int i = sizeof(gDefaultBindings)/sizeof(gDefaultBindings[0]) - 1; i >= 0; --i)
|
||||
g_engine->BindKey(gDefaultBindings[i].keysym, gDefaultBindings[i].keycode);
|
||||
}
|
||||
|
||||
bool JGEGetKeyState(int key __attribute__((unused)))
|
||||
int JGEGetTime()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 JGEReadKey()
|
||||
{
|
||||
if (gKeyBuffer.empty()) return 0;
|
||||
u32 val = gKeyBuffer.front().second;
|
||||
gHolds &= ~val;
|
||||
gKeyBuffer.pop();
|
||||
return val;
|
||||
}
|
||||
|
||||
u32 JGEReadLocalKey()
|
||||
{
|
||||
if (gKeyBuffer.empty()) return 0;
|
||||
pair <KeyCode, u32> val = gKeyBuffer.front();
|
||||
gHolds &= ~val.second;
|
||||
gKeyBuffer.pop();
|
||||
return val.first;
|
||||
}
|
||||
|
||||
void JGEBindLocalKey(u32 localKey, u32 pspSymbol)
|
||||
{
|
||||
}
|
||||
|
||||
void JGEResetInput()
|
||||
{
|
||||
while (!gKeyBuffer.empty()) gKeyBuffer.pop();
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||
}
|
||||
|
||||
void reshapeFunc(int width, int height)
|
||||
@@ -420,6 +368,8 @@ int main(int argc, char* argv[])
|
||||
XSelectInput(gXDisplay, gXWindow, KeyPressMask | KeyReleaseMask | StructureNotifyMask);
|
||||
XkbSetDetectableAutoRepeat(gXDisplay, true, NULL);
|
||||
|
||||
JGECreateDefaultBindings();
|
||||
|
||||
static uint64_t tickCount;
|
||||
while (!g_engine->IsDone())
|
||||
{
|
||||
@@ -430,7 +380,7 @@ int main(int argc, char* argv[])
|
||||
tickCount = tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||
dt = (tickCount - lastTickCount);
|
||||
lastTickCount = tickCount;
|
||||
Update(dt); // Update frame
|
||||
Update((float)dt / 1000.0f); // Update frame
|
||||
|
||||
DrawGLScene(); // Draw The Scene
|
||||
glXSwapBuffers(gXDisplay, glxWin);
|
||||
@@ -438,33 +388,15 @@ int main(int argc, char* argv[])
|
||||
switch (event.type)
|
||||
{
|
||||
case KeyPress:
|
||||
{
|
||||
KeySym sym = XKeycodeToKeysym(gXDisplay, event.xkey.keycode, 1);
|
||||
if (XK_F == sym)
|
||||
fullscreen();
|
||||
for (vector< pair<KeySym, u32> >::iterator it = gKeyCodes.begin(); it != gKeyCodes.end(); ++it)
|
||||
if (sym == it->first)
|
||||
{
|
||||
if (!(gHolds & it->second))
|
||||
gKeyBuffer.push(*it);
|
||||
gControllerState |= it->second;
|
||||
gHolds |= it->second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
{
|
||||
const KeySym sym = XKeycodeToKeysym(gXDisplay, event.xkey.keycode, 1);
|
||||
if (sym == XK_F) fullscreen();
|
||||
g_engine->HoldKey_NoRepeat(sym);
|
||||
}
|
||||
break;
|
||||
case KeyRelease:
|
||||
{
|
||||
KeySym sym = XKeycodeToKeysym(gXDisplay, event.xkey.keycode, 1);
|
||||
for (vector< pair<KeySym, u32> >::iterator it = gKeyCodes.begin(); it != gKeyCodes.end(); ++it)
|
||||
if (sym == it->first)
|
||||
{
|
||||
gControllerState &= ~it->second;
|
||||
gHolds &= ~it->second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
g_engine->ReleaseKey(XKeycodeToKeysym(gXDisplay, event.xkey.keycode, 1));
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
ReSizeGLScene(event.xconfigure.width, event.xconfigure.height);
|
||||
break;
|
||||
|
||||
711
JGE/src/main.cpp
711
JGE/src/main.cpp
@@ -1,301 +1,410 @@
|
||||
#include <pspkernel.h>
|
||||
#include <pspdisplay.h>
|
||||
#include <pspdebug.h>
|
||||
#include <psppower.h>
|
||||
#include <pspsdk.h>
|
||||
#include <pspaudiocodec.h>
|
||||
#include <pspaudio.h>
|
||||
#include <pspaudiolib.h>
|
||||
#include <pspmpeg.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <pspctrl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include "../../JGE/include/JGE.h"
|
||||
#include "../../JGE/include/JApp.h"
|
||||
#include "../../JGE/include/JGameLauncher.h"
|
||||
#include "../../JGE/include/JRenderer.h"
|
||||
|
||||
|
||||
#ifndef JGEApp_Title
|
||||
#define JGEApp_Title "JGE++"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef DEVHOOK
|
||||
PSP_MODULE_INFO(JGEApp_Title, 0, 1, 1);
|
||||
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
|
||||
//256 is not enough for the network to correctly start,
|
||||
// let's find an appropriate value the day JGE has working network
|
||||
PSP_HEAP_SIZE_KB(-256);
|
||||
|
||||
#else
|
||||
|
||||
PSP_MODULE_INFO(JGEApp_Title, 0x1000, 1, 1);
|
||||
PSP_MAIN_THREAD_ATTR(0);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
int mikModThreadID = -1;
|
||||
bool done = false;
|
||||
|
||||
JApp *game = NULL;
|
||||
JGE *engine = NULL;
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// Exit callback
|
||||
int exit_callback(int arg1, int arg2, void *common)
|
||||
{
|
||||
if (engine != NULL)
|
||||
engine->End();
|
||||
|
||||
sceKernelExitGame();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// Power Callback
|
||||
int power_callback(int unknown, int pwrflags, void *common)
|
||||
{
|
||||
if ((pwrflags & (PSP_POWER_CB_POWER_SWITCH | PSP_POWER_CB_STANDBY)) > 0)
|
||||
{
|
||||
// suspending
|
||||
if (engine != NULL)
|
||||
engine->Pause();
|
||||
|
||||
}
|
||||
else if ((pwrflags & PSP_POWER_CB_RESUME_COMPLETE) > 0)
|
||||
{
|
||||
sceKernelDelayThread(1500000);
|
||||
// resume complete
|
||||
if (engine != NULL)
|
||||
engine->Resume();
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// Callback thread
|
||||
int CallbackThread(SceSize args, void *argp)
|
||||
{
|
||||
int cbid;
|
||||
|
||||
#ifdef DEVHOOK
|
||||
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
|
||||
sceKernelRegisterExitCallback(cbid);
|
||||
#endif
|
||||
cbid = sceKernelCreateCallback("Power Callback", power_callback, NULL);
|
||||
scePowerRegisterCallback(0, cbid);
|
||||
|
||||
sceKernelSleepThreadCB();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Sets up the callback thread and returns its thread id
|
||||
int SetupCallbacks(void)
|
||||
{
|
||||
int thid = 0;
|
||||
|
||||
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
|
||||
if(thid >= 0)
|
||||
{
|
||||
sceKernelStartThread(thid, 0, 0);
|
||||
}
|
||||
|
||||
return thid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef DEVHOOK
|
||||
//code by sakya, crazyc, samuraiX
|
||||
//http://forums.ps2dev.org/viewtopic.php?t=9591&sid=2056889f6b9531194cab9b2d487df844
|
||||
PspDebugRegBlock exception_regs;
|
||||
|
||||
extern int _ftext;
|
||||
|
||||
static const char *codeTxt[32] =
|
||||
{
|
||||
"Interrupt", "TLB modification", "TLB load/inst fetch", "TLB store",
|
||||
"Address load/inst fetch", "Address store", "Bus error (instr)",
|
||||
"Bus error (data)", "Syscall", "Breakpoint", "Reserved instruction",
|
||||
"Coprocessor unusable", "Arithmetic overflow", "Unknown 14",
|
||||
"Unknown 15", "Unknown 16", "Unknown 17", "Unknown 18", "Unknown 19",
|
||||
"Unknown 20", "Unknown 21", "Unknown 22", "Unknown 23", "Unknown 24",
|
||||
"Unknown 25", "Unknown 26", "Unknown 27", "Unknown 28", "Unknown 29",
|
||||
"Unknown 31"
|
||||
};
|
||||
|
||||
static const unsigned char regName[32][5] =
|
||||
{
|
||||
"zr", "at", "v0", "v1", "a0", "a1", "a2", "a3",
|
||||
"t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
|
||||
"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
|
||||
"t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra"
|
||||
};
|
||||
|
||||
void ExceptionHandler(PspDebugRegBlock * regs)
|
||||
{
|
||||
int i;
|
||||
SceCtrlData pad;
|
||||
|
||||
pspDebugScreenInit();
|
||||
pspDebugScreenSetBackColor(0x00FF0000);
|
||||
pspDebugScreenSetTextColor(0xFFFFFFFF);
|
||||
pspDebugScreenClear();
|
||||
pspDebugScreenPrintf("Your PSP has just crashed!\n");
|
||||
pspDebugScreenPrintf("Exception details:\n\n");
|
||||
|
||||
pspDebugScreenPrintf("Exception - %s\n", codeTxt[(regs->cause >> 2) & 31]);
|
||||
pspDebugScreenPrintf("EPC - %08X / %s.text + %08X\n", (int)regs->epc, module_info.modname, (unsigned int)(regs->epc-(int)&_ftext));
|
||||
pspDebugScreenPrintf("Cause - %08X\n", (int)regs->cause);
|
||||
pspDebugScreenPrintf("Status - %08X\n", (int)regs->status);
|
||||
pspDebugScreenPrintf("BadVAddr - %08X\n", (int)regs->badvaddr);
|
||||
for(i=0; i<32; i+=4) pspDebugScreenPrintf("%s:%08X %s:%08X %s:%08X %s:%08X\n", regName[i], (int)regs->r[i], regName[i+1], (int)regs->r[i+1], regName[i+2], (int)regs->r[i+2], regName[i+3], (int)regs->r[i+3]);
|
||||
|
||||
sceKernelDelayThread(1000000);
|
||||
pspDebugScreenPrintf("\n\nPress X to dump information on file exception.log and quit");
|
||||
pspDebugScreenPrintf("\nPress O to quit");
|
||||
|
||||
for (;;){
|
||||
sceCtrlReadBufferPositive(&pad, 1);
|
||||
if (pad.Buttons & PSP_CTRL_CROSS){
|
||||
FILE *log = fopen("exception.log", "w");
|
||||
if (log != NULL){
|
||||
char testo[512];
|
||||
sprintf(testo, "Exception details:\n\n");
|
||||
fwrite(testo, 1, strlen(testo), log);
|
||||
sprintf(testo, "Exception - %s\n", codeTxt[(regs->cause >> 2) & 31]);
|
||||
fwrite(testo, 1, strlen(testo), log);
|
||||
sprintf(testo, "EPC - %08X / %s.text + %08X\n", (int)regs->epc, module_info.modname, (unsigned int)(regs->epc-(int)&_ftext));
|
||||
fwrite(testo, 1, strlen(testo), log);
|
||||
sprintf(testo, "Cause - %08X\n", (int)regs->cause);
|
||||
fwrite(testo, 1, strlen(testo), log);
|
||||
sprintf(testo, "Status - %08X\n", (int)regs->status);
|
||||
fwrite(testo, 1, strlen(testo), log);
|
||||
sprintf(testo, "BadVAddr - %08X\n", (int)regs->badvaddr);
|
||||
fwrite(testo, 1, strlen(testo), log);
|
||||
for(i=0; i<32; i+=4){
|
||||
sprintf(testo, "%s:%08X %s:%08X %s:%08X %s:%08X\n", regName[i], (int)regs->r[i], regName[i+1], (int)regs->r[i+1], regName[i+2], (int)regs->r[i+2], regName[i+3], (int)regs->r[i+3]);
|
||||
fwrite(testo, 1, strlen(testo), log);
|
||||
}
|
||||
fclose(log);
|
||||
}
|
||||
break;
|
||||
}else if (pad.Buttons & PSP_CTRL_CIRCLE){
|
||||
break;
|
||||
}
|
||||
sceKernelDelayThread(100000);
|
||||
}
|
||||
sceKernelExitGame();
|
||||
}
|
||||
|
||||
void initExceptionHandler()
|
||||
{
|
||||
SceKernelLMOption option;
|
||||
int args[2], fd, modid;
|
||||
|
||||
memset(&option, 0, sizeof(option));
|
||||
option.size = sizeof(option);
|
||||
option.mpidtext = PSP_MEMORY_PARTITION_KERNEL;
|
||||
option.mpiddata = PSP_MEMORY_PARTITION_KERNEL;
|
||||
option.position = 0;
|
||||
option.access = 1;
|
||||
|
||||
if((modid = sceKernelLoadModule("exception.prx", 0, &option)) >= 0)
|
||||
{
|
||||
args[0] = (int)ExceptionHandler;
|
||||
args[1] = (int)&exception_regs;
|
||||
sceKernelStartModule(modid, 8, args, &fd, NULL);
|
||||
}
|
||||
}
|
||||
#else
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// Custom exception handler
|
||||
void MyExceptionHandler(PspDebugRegBlock *regs)
|
||||
{
|
||||
pspDebugScreenInit();
|
||||
|
||||
pspDebugScreenSetBackColor(0x00FF0000);
|
||||
pspDebugScreenSetTextColor(0xFFFFFFFF);
|
||||
pspDebugScreenClear();
|
||||
|
||||
pspDebugScreenPrintf("I regret to inform you your psp has just crashed\n");
|
||||
pspDebugScreenPrintf("Please contact Sony technical support for further information\n\n");
|
||||
pspDebugScreenPrintf("Exception Details:\n");
|
||||
pspDebugDumpException(regs);
|
||||
pspDebugScreenPrintf("\nBlame the 3rd party software, it cannot possibly be our fault!\n");
|
||||
|
||||
sceKernelExitGame();
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// Sort of hack to install exception handler under USER THREAD
|
||||
__attribute__((constructor)) void handlerInit()
|
||||
{
|
||||
pspKernelSetKernelPC();
|
||||
|
||||
pspSdkInstallNoDeviceCheckPatch();
|
||||
pspSdkInstallNoPlainModuleCheckPatch();
|
||||
pspSdkInstallKernelLoadModulePatch();
|
||||
|
||||
pspDebugInstallErrorHandler(MyExceptionHandler);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// The main loop
|
||||
int main()
|
||||
{
|
||||
|
||||
SetupCallbacks();
|
||||
#ifdef DEVHOOK
|
||||
initExceptionHandler();
|
||||
#endif
|
||||
engine = NULL;
|
||||
|
||||
|
||||
JGameLauncher* launcher = new JGameLauncher();
|
||||
|
||||
u32 flags = launcher->GetInitFlags();
|
||||
if ((flags&JINIT_FLAG_ENABLE3D)!=0)
|
||||
JRenderer::Set3DFlag(true);
|
||||
|
||||
engine = JGE::GetInstance();
|
||||
|
||||
game = launcher->GetGameApp();
|
||||
game->Create();
|
||||
|
||||
|
||||
engine->SetApp(game);
|
||||
engine->Run();
|
||||
|
||||
game->Destroy();
|
||||
delete game;
|
||||
game = NULL;
|
||||
|
||||
engine->SetApp(NULL);
|
||||
|
||||
done = true;
|
||||
|
||||
|
||||
delete launcher;
|
||||
|
||||
JGE::Destroy();
|
||||
engine = NULL;
|
||||
|
||||
sceKernelExitGame();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#include <pspkernel.h>
|
||||
#include <pspdisplay.h>
|
||||
#include <pspdebug.h>
|
||||
#include <psppower.h>
|
||||
#include <pspsdk.h>
|
||||
#include <pspaudiocodec.h>
|
||||
#include <pspaudio.h>
|
||||
#include <pspaudiolib.h>
|
||||
#include <pspmpeg.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <pspctrl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <queue>
|
||||
|
||||
|
||||
#include "../../JGE/include/JGE.h"
|
||||
#include "../../JGE/include/JApp.h"
|
||||
#include "../../JGE/include/JGameLauncher.h"
|
||||
#include "../../JGE/include/JRenderer.h"
|
||||
|
||||
|
||||
#ifndef JGEApp_Title
|
||||
#define JGEApp_Title "JGE++"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef DEVHOOK
|
||||
PSP_MODULE_INFO(JGEApp_Title, 0, 1, 1);
|
||||
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
|
||||
//256 is not enough for the network to correctly start,
|
||||
// let's find an appropriate value the day JGE has working network
|
||||
PSP_HEAP_SIZE_KB(-256);
|
||||
|
||||
#else
|
||||
|
||||
PSP_MODULE_INFO(JGEApp_Title, 0x1000, 1, 1);
|
||||
PSP_MAIN_THREAD_ATTR(0);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
int mikModThreadID = -1;
|
||||
bool done = false;
|
||||
|
||||
JApp *game = NULL;
|
||||
JGE *g_engine = NULL;
|
||||
|
||||
u32 gTickFrequency;
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// Exit callback
|
||||
int exit_callback(int arg1, int arg2, void *common)
|
||||
{
|
||||
if (g_engine != NULL)
|
||||
g_engine->End();
|
||||
sceKernelExitGame();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// Power Callback
|
||||
int power_callback(int unknown, int pwrflags, void *common)
|
||||
{
|
||||
if ((pwrflags & (PSP_POWER_CB_POWER_SWITCH | PSP_POWER_CB_STANDBY)) > 0)
|
||||
{
|
||||
// suspending
|
||||
if (g_engine != NULL) g_engine->Pause();
|
||||
}
|
||||
else if ((pwrflags & PSP_POWER_CB_RESUME_COMPLETE) > 0)
|
||||
{
|
||||
sceKernelDelayThread(1500000);
|
||||
// resume complete
|
||||
if (g_engine != NULL)
|
||||
g_engine->Resume();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// Callback thread
|
||||
int CallbackThread(SceSize args, void *argp)
|
||||
{
|
||||
int cbid;
|
||||
|
||||
#ifdef DEVHOOK
|
||||
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
|
||||
sceKernelRegisterExitCallback(cbid);
|
||||
#endif
|
||||
cbid = sceKernelCreateCallback("Power Callback", power_callback, NULL);
|
||||
scePowerRegisterCallback(0, cbid);
|
||||
|
||||
sceKernelSleepThreadCB();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Sets up the callback thread and returns its thread id
|
||||
int SetupCallbacks(void)
|
||||
{
|
||||
int thid = 0;
|
||||
|
||||
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
|
||||
if (thid >= 0) sceKernelStartThread(thid, 0, 0);
|
||||
return thid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef DEVHOOK
|
||||
//code by sakya, crazyc, samuraiX
|
||||
//http://forums.ps2dev.org/viewtopic.php?t=9591&sid=2056889f6b9531194cab9b2d487df844
|
||||
PspDebugRegBlock exception_regs;
|
||||
|
||||
extern int _ftext;
|
||||
|
||||
static const char *codeTxt[32] =
|
||||
{
|
||||
"Interrupt", "TLB modification", "TLB load/inst fetch", "TLB store",
|
||||
"Address load/inst fetch", "Address store", "Bus error (instr)",
|
||||
"Bus error (data)", "Syscall", "Breakpoint", "Reserved instruction",
|
||||
"Coprocessor unusable", "Arithmetic overflow", "Unknown 14",
|
||||
"Unknown 15", "Unknown 16", "Unknown 17", "Unknown 18", "Unknown 19",
|
||||
"Unknown 20", "Unknown 21", "Unknown 22", "Unknown 23", "Unknown 24",
|
||||
"Unknown 25", "Unknown 26", "Unknown 27", "Unknown 28", "Unknown 29",
|
||||
"Unknown 31"
|
||||
};
|
||||
|
||||
static const unsigned char regName[32][5] =
|
||||
{
|
||||
"zr", "at", "v0", "v1", "a0", "a1", "a2", "a3",
|
||||
"t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
|
||||
"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
|
||||
"t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra"
|
||||
};
|
||||
|
||||
void ExceptionHandler(PspDebugRegBlock * regs)
|
||||
{
|
||||
int i;
|
||||
SceCtrlData pad;
|
||||
|
||||
pspDebugScreenInit();
|
||||
pspDebugScreenSetBackColor(0x00FF0000);
|
||||
pspDebugScreenSetTextColor(0xFFFFFFFF);
|
||||
pspDebugScreenClear();
|
||||
pspDebugScreenPrintf("Your PSP has just crashed!\n");
|
||||
pspDebugScreenPrintf("Exception details:\n\n");
|
||||
|
||||
pspDebugScreenPrintf("Exception - %s\n", codeTxt[(regs->cause >> 2) & 31]);
|
||||
pspDebugScreenPrintf("EPC - %08X / %s.text + %08X\n", (int)regs->epc, module_info.modname, (unsigned int)(regs->epc-(int)&_ftext));
|
||||
pspDebugScreenPrintf("Cause - %08X\n", (int)regs->cause);
|
||||
pspDebugScreenPrintf("Status - %08X\n", (int)regs->status);
|
||||
pspDebugScreenPrintf("BadVAddr - %08X\n", (int)regs->badvaddr);
|
||||
for (i = 0; i < 32; i += 4) pspDebugScreenPrintf("%s:%08X %s:%08X %s:%08X %s:%08X\n", regName[i], (int)regs->r[i], regName[i+1], (int)regs->r[i+1], regName[i+2], (int)regs->r[i+2], regName[i+3], (int)regs->r[i+3]);
|
||||
|
||||
sceKernelDelayThread(1000000);
|
||||
pspDebugScreenPrintf("\n\nPress X to dump information on file exception.log and quit");
|
||||
pspDebugScreenPrintf("\nPress O to quit");
|
||||
|
||||
for (;;)
|
||||
{
|
||||
sceCtrlReadBufferPositive(&pad, 1);
|
||||
if (pad.Buttons & PSP_CTRL_CROSS)
|
||||
{
|
||||
FILE *log = fopen("exception.log", "w");
|
||||
if (log != NULL)
|
||||
{
|
||||
char testo[512];
|
||||
sprintf(testo, "Exception details:\n\n");
|
||||
fwrite(testo, 1, strlen(testo), log);
|
||||
sprintf(testo, "Exception - %s\n", codeTxt[(regs->cause >> 2) & 31]);
|
||||
fwrite(testo, 1, strlen(testo), log);
|
||||
sprintf(testo, "EPC - %08X / %s.text + %08X\n", (int)regs->epc, module_info.modname, (unsigned int)(regs->epc-(int)&_ftext));
|
||||
fwrite(testo, 1, strlen(testo), log);
|
||||
sprintf(testo, "Cause - %08X\n", (int)regs->cause);
|
||||
fwrite(testo, 1, strlen(testo), log);
|
||||
sprintf(testo, "Status - %08X\n", (int)regs->status);
|
||||
fwrite(testo, 1, strlen(testo), log);
|
||||
sprintf(testo, "BadVAddr - %08X\n", (int)regs->badvaddr);
|
||||
fwrite(testo, 1, strlen(testo), log);
|
||||
for (i = 0; i < 32; i += 4)
|
||||
{
|
||||
sprintf(testo, "%s:%08X %s:%08X %s:%08X %s:%08X\n", regName[i], (int)regs->r[i], regName[i+1], (int)regs->r[i+1], regName[i+2], (int)regs->r[i+2], regName[i+3], (int)regs->r[i+3]);
|
||||
fwrite(testo, 1, strlen(testo), log);
|
||||
}
|
||||
fclose(log);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (pad.Buttons & PSP_CTRL_CIRCLE)
|
||||
break;
|
||||
sceKernelDelayThread(100000);
|
||||
}
|
||||
sceKernelExitGame();
|
||||
}
|
||||
|
||||
void initExceptionHandler()
|
||||
{
|
||||
SceKernelLMOption option;
|
||||
int args[2], fd, modid;
|
||||
|
||||
memset(&option, 0, sizeof(option));
|
||||
option.size = sizeof(option);
|
||||
option.mpidtext = PSP_MEMORY_PARTITION_KERNEL;
|
||||
option.mpiddata = PSP_MEMORY_PARTITION_KERNEL;
|
||||
option.position = 0;
|
||||
option.access = 1;
|
||||
|
||||
if ((modid = sceKernelLoadModule("exception.prx", 0, &option)) >= 0)
|
||||
{
|
||||
args[0] = (int)ExceptionHandler;
|
||||
args[1] = (int)&exception_regs;
|
||||
sceKernelStartModule(modid, 8, args, &fd, NULL);
|
||||
}
|
||||
}
|
||||
#else
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// Custom exception handler
|
||||
void MyExceptionHandler(PspDebugRegBlock *regs)
|
||||
{
|
||||
pspDebugScreenInit();
|
||||
|
||||
pspDebugScreenSetBackColor(0x00FF0000);
|
||||
pspDebugScreenSetTextColor(0xFFFFFFFF);
|
||||
pspDebugScreenClear();
|
||||
|
||||
pspDebugScreenPrintf("I regret to inform you your psp has just crashed\n");
|
||||
pspDebugScreenPrintf("Please contact Sony technical support for further information\n\n");
|
||||
pspDebugScreenPrintf("Exception Details:\n");
|
||||
pspDebugDumpException(regs);
|
||||
pspDebugScreenPrintf("\nBlame the 3rd party software, it cannot possibly be our fault!\n");
|
||||
|
||||
sceKernelExitGame();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// Sort of hack to install exception handler under USER THREAD
|
||||
__attribute__((constructor)) void handlerInit()
|
||||
{
|
||||
pspKernelSetKernelPC();
|
||||
|
||||
pspSdkInstallNoDeviceCheckPatch();
|
||||
pspSdkInstallNoPlainModuleCheckPatch();
|
||||
pspSdkInstallKernelLoadModulePatch();
|
||||
|
||||
pspDebugInstallErrorHandler(MyExceptionHandler);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[] =
|
||||
{
|
||||
{ PSP_CTRL_HOME, JGE_BTN_QUIT },
|
||||
{ PSP_CTRL_START, JGE_BTN_MENU },
|
||||
{ PSP_CTRL_SELECT, JGE_BTN_CTRL },
|
||||
{ PSP_CTRL_HOLD, JGE_BTN_POWER },
|
||||
{ PSP_CTRL_NOTE, JGE_BTN_SOUND },
|
||||
{ PSP_CTRL_RIGHT, JGE_BTN_RIGHT },
|
||||
{ PSP_CTRL_LEFT, JGE_BTN_LEFT },
|
||||
{ PSP_CTRL_UP, JGE_BTN_UP },
|
||||
{ PSP_CTRL_DOWN, JGE_BTN_DOWN },
|
||||
{ PSP_CTRL_CIRCLE, JGE_BTN_OK },
|
||||
{ PSP_CTRL_TRIANGLE, JGE_BTN_CANCEL },
|
||||
{ PSP_CTRL_SQUARE, JGE_BTN_PRI },
|
||||
{ PSP_CTRL_CROSS, JGE_BTN_SEC },
|
||||
{ PSP_CTRL_LTRIGGER, JGE_BTN_PREV },
|
||||
{ PSP_CTRL_RTRIGGER, JGE_BTN_NEXT }
|
||||
};
|
||||
void JGECreateDefaultBindings()
|
||||
{
|
||||
for (signed int i = sizeof(gDefaultBindings)/sizeof(gDefaultBindings[0]) - 1; i >= 0; --i)
|
||||
g_engine->BindKey(gDefaultBindings[i].keysym, gDefaultBindings[i].keycode);
|
||||
}
|
||||
int JGEGetTime()
|
||||
{
|
||||
u64 curr;
|
||||
sceRtcGetCurrentTick(&curr);
|
||||
return (int)((curr * 1000) / gTickFrequency);
|
||||
}
|
||||
|
||||
static SceCtrlData gCtrlPad;
|
||||
|
||||
u8 JGEGetAnalogX() { return gCtrlPad.Lx; }
|
||||
u8 JGEGetAnalogY() { return gCtrlPad.Ly; }
|
||||
|
||||
void Run()
|
||||
{
|
||||
static const int keyCodeList[] = {
|
||||
PSP_CTRL_SELECT, // Select button.
|
||||
PSP_CTRL_START, // Start button.
|
||||
PSP_CTRL_UP, // Up D-Pad button.
|
||||
PSP_CTRL_RIGHT, // Right D-Pad button.
|
||||
PSP_CTRL_DOWN, // Down D-Pad button.
|
||||
PSP_CTRL_LEFT, // Left D-Pad button.
|
||||
PSP_CTRL_LTRIGGER, // Left trigger.
|
||||
PSP_CTRL_RTRIGGER, // Right trigger.
|
||||
PSP_CTRL_TRIANGLE, // Triangle button.
|
||||
PSP_CTRL_CIRCLE, // Circle button.
|
||||
PSP_CTRL_CROSS, // Cross button.
|
||||
PSP_CTRL_SQUARE, // Square button.
|
||||
PSP_CTRL_HOLD, // Hold button.
|
||||
/* Do not test keys we cannot get anyway, that's just wasted proc time
|
||||
PSP_CTRL_HOME, // Home button.
|
||||
PSP_CTRL_NOTE, // Music Note button.
|
||||
PSP_CTRL_SCREEN, // Screen button.
|
||||
PSP_CTRL_VOLUP, // Volume up button.
|
||||
PSP_CTRL_VOLDOWN, // Volume down button.
|
||||
PSP_CTRL_WLAN, // _UP Wlan switch up.
|
||||
PSP_CTRL_REMOTE, // Remote hold position.
|
||||
PSP_CTRL_DISC, // Disc present.
|
||||
PSP_CTRL_MS // Memory stick present.
|
||||
*/
|
||||
};
|
||||
|
||||
u64 curr;
|
||||
long long int nextInput = 0;
|
||||
u64 lastTime;
|
||||
u32 oldButtons;
|
||||
u32 veryOldButtons;
|
||||
|
||||
sceRtcGetCurrentTick(&lastTime);
|
||||
oldButtons = veryOldButtons = 0;
|
||||
JGECreateDefaultBindings();
|
||||
|
||||
while (!g_engine->mDone)
|
||||
{
|
||||
if (!g_engine->mPaused)
|
||||
{
|
||||
sceRtcGetCurrentTick(&curr);
|
||||
float dt = (curr - lastTime) / (float)gTickFrequency;
|
||||
g_engine->mDelta = dt;
|
||||
|
||||
sceCtrlPeekBufferPositive(&gCtrlPad, 1);
|
||||
for (signed int i = sizeof(keyCodeList)/sizeof(keyCodeList[0]) - 1; i >= 0; --i)
|
||||
{
|
||||
if (keyCodeList[i] & gCtrlPad.Buttons)
|
||||
{
|
||||
if (!(keyCodeList[i] & oldButtons))
|
||||
g_engine->HoldKey(keyCodeList[i]);
|
||||
}
|
||||
else
|
||||
if (keyCodeList[i] & oldButtons)
|
||||
g_engine->ReleaseKey(keyCodeList[i]);
|
||||
}
|
||||
oldButtons = gCtrlPad.Buttons;
|
||||
|
||||
g_engine->Update(dt);
|
||||
g_engine->Render();
|
||||
|
||||
if (g_engine->mDebug)
|
||||
{
|
||||
if (strlen(g_engine->mDebuggingMsg)>0)
|
||||
{
|
||||
pspDebugScreenSetXY(0, 0);
|
||||
pspDebugScreenPrintf(g_engine->mDebuggingMsg);
|
||||
}
|
||||
}
|
||||
veryOldButtons = gCtrlPad.Buttons;
|
||||
}
|
||||
else
|
||||
sceKernelDelayThread(1);
|
||||
lastTime = curr;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// The main loop
|
||||
int main()
|
||||
{
|
||||
SetupCallbacks();
|
||||
#ifdef DEVHOOK
|
||||
initExceptionHandler();
|
||||
#endif
|
||||
g_engine = NULL;
|
||||
|
||||
JGameLauncher* launcher = new JGameLauncher();
|
||||
|
||||
u32 flags = launcher->GetInitFlags();
|
||||
if ((flags&JINIT_FLAG_ENABLE3D) != 0)
|
||||
JRenderer::Set3DFlag(true);
|
||||
|
||||
gTickFrequency = sceRtcGetTickResolution();
|
||||
g_engine = JGE::GetInstance();
|
||||
|
||||
game = launcher->GetGameApp();
|
||||
game->Create();
|
||||
|
||||
g_engine->SetApp(game);
|
||||
Run();
|
||||
|
||||
game->Destroy();
|
||||
delete game;
|
||||
game = NULL;
|
||||
|
||||
g_engine->SetApp(NULL);
|
||||
|
||||
done = true;
|
||||
|
||||
delete launcher;
|
||||
|
||||
JGE::Destroy();
|
||||
g_engine = NULL;
|
||||
|
||||
sceKernelExitGame();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +158,6 @@ JGameLauncher* g_launcher = NULL;
|
||||
|
||||
static u32 gButtons = 0;
|
||||
static u32 gOldButtons = 0;
|
||||
static queue< pair<u32, u32> > gKeyBuffer;
|
||||
|
||||
static const struct { WPARAM keysym; u32 pspCode; } gDefaultBindings[] =
|
||||
{
|
||||
@@ -185,45 +184,23 @@ static const struct { WPARAM keysym; u32 pspCode; } gDefaultBindings[] =
|
||||
{ VK_F3, PSP_CTRL_NOTE }
|
||||
};
|
||||
|
||||
static vector< pair<WPARAM, u32> > gKeyCodes;
|
||||
|
||||
void JGEControl()
|
||||
void JGECreateDefaultBindings()
|
||||
{
|
||||
gOldButtons = gButtons;
|
||||
|
||||
gButtons = 0;
|
||||
for (vector< pair<WPARAM, u32> >::iterator it = gKeyCodes.begin(); it != gKeyCodes.end(); ++it)
|
||||
if (g_keys[it->first])
|
||||
gButtons |= it->second;
|
||||
for (signed int i = sizeof(gDefaultBindings)/sizeof(gDefaultBindings[0]) - 1; i >= 0; --i)
|
||||
g_engine->BindKey(gDefaultBindings[i].keysym, gDefaultBindings[i].keycode);
|
||||
}
|
||||
|
||||
|
||||
BOOL JGEGetKeyState(int key)
|
||||
int JGEGetTime()
|
||||
{
|
||||
return (g_keys[key]);
|
||||
return (int)GetTickCount();
|
||||
}
|
||||
|
||||
|
||||
bool JGEGetButtonState(u32 button)
|
||||
{
|
||||
return (gButtons&button)==button;
|
||||
}
|
||||
|
||||
|
||||
bool JGEGetButtonClick(u32 button)
|
||||
{
|
||||
return (gButtons&button)==button && (gOldButtons&button)!=button;
|
||||
}
|
||||
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc
|
||||
|
||||
GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
|
||||
{
|
||||
if (height==0) // Prevent A Divide By Zero By
|
||||
{
|
||||
height=1; // Making Height Equal One
|
||||
}
|
||||
|
||||
actualWidth = width;
|
||||
actualHeight = height;
|
||||
@@ -327,15 +304,9 @@ int DrawGLScene(void) // Here's Where We Do All The Drawing
|
||||
|
||||
void Update(int dt)
|
||||
{
|
||||
JGEControl();
|
||||
|
||||
gPrevControllerState = gControllerState;
|
||||
g_engine->SetDelta(dt);
|
||||
|
||||
//if (g_app)
|
||||
// g_app->Update();
|
||||
|
||||
g_engine->Update();
|
||||
|
||||
g_engine->Update(dt);
|
||||
}
|
||||
|
||||
void KillGLWindow(void) // Properly Kill The Window
|
||||
@@ -351,14 +322,9 @@ void KillGLWindow(void) // Properly Kill The Window
|
||||
if (hRC) // Do We Have A Rendering Context?
|
||||
{
|
||||
if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts?
|
||||
{
|
||||
MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
||||
}
|
||||
|
||||
MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
||||
if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
|
||||
{
|
||||
MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
||||
}
|
||||
MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
||||
hRC=NULL; // Set RC To NULL
|
||||
}
|
||||
|
||||
@@ -573,29 +539,6 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscree
|
||||
return TRUE; // Success
|
||||
}
|
||||
|
||||
u32 JGEReadKey()
|
||||
{
|
||||
if (gKeyBuffer.empty()) return 0;
|
||||
pair<u32, u32> val = gKeyBuffer.front();
|
||||
g_holds[val.first] = false;
|
||||
gKeyBuffer.pop();
|
||||
return val.second;
|
||||
}
|
||||
|
||||
u32 JGEReadLocalKey()
|
||||
{
|
||||
if (gKeyBuffer.empty()) return 0;
|
||||
u32 val = gKeyBuffer.front().first;
|
||||
g_holds[val] = false;
|
||||
gKeyBuffer.pop();
|
||||
return val;
|
||||
}
|
||||
|
||||
void JGEResetInput()
|
||||
{
|
||||
while (!gKeyBuffer.empty()) gKeyBuffer.pop();
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
|
||||
UINT uMsg, // Message For This Window
|
||||
WPARAM wParam, // Additional Message Information
|
||||
@@ -641,14 +584,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
|
||||
case WM_KEYDOWN: // Update Keyboard Buffers For Keys Pressed
|
||||
if ((wParam >= 0) && (wParam <= 255)) // Is Key (wParam) In A Valid Range?
|
||||
{
|
||||
g_keys[wParam] = true; // Set The Selected Key (wParam) To True
|
||||
if (false == g_holds[wParam])
|
||||
{
|
||||
g_holds[wParam] = true;
|
||||
for (vector< pair<WPARAM, u32> >::iterator it = gKeyCodes.begin(); it != gKeyCodes.end(); ++it)
|
||||
if (it->first == wParam)
|
||||
gKeyBuffer.push(*it);
|
||||
}
|
||||
g_engine->HoldKey_NoRepeat(wParam);
|
||||
return 0;
|
||||
}
|
||||
break; // Break
|
||||
@@ -656,8 +592,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
|
||||
case WM_KEYUP: // Update Keyboard Buffers For Keys Released
|
||||
if ((wParam >= 0) && (wParam <= 255)) // Is Key (wParam) In A Valid Range?
|
||||
{
|
||||
g_keys[wParam] = FALSE; // Set The Selected Key (wParam) To False
|
||||
g_holds[wParam] = FALSE;
|
||||
g_engine->ReleaseKey(wParam);
|
||||
return 0; // Return
|
||||
}
|
||||
break;
|
||||
@@ -721,8 +656,7 @@ int WINAPI WinMain( HINSTANCE hInstance, // Instance
|
||||
|
||||
u32 flags = g_launcher->GetInitFlags();
|
||||
|
||||
for (signed int i = sizeof(gDefaultBindings)/sizeof(gDefaultBindings[0]) - 1; i >= 0; --i)
|
||||
gKeyCodes.push_back(make_pair(gDefaultBindings[i].keysym, gDefaultBindings[i].pspCode));
|
||||
JGECreateDefaultBindings();
|
||||
|
||||
if ((flags&JINIT_FLAG_ENABLE3D)!=0)
|
||||
JRenderer::Set3DFlag(true);
|
||||
@@ -753,9 +687,7 @@ int WINAPI WinMain( HINSTANCE hInstance, // Instance
|
||||
if (active) // Program Active?
|
||||
{
|
||||
if (g_engine->IsDone())
|
||||
{
|
||||
done=TRUE; // ESC Signalled A Quit
|
||||
}
|
||||
done=TRUE; // ESC Signalled A Quit
|
||||
else // Not Time To Quit, Update Screen
|
||||
{
|
||||
tickCount = GetTickCount(); // Get The Tick Count
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
#define _DUELLAYERS_H_
|
||||
|
||||
#include "GuiLayers.h"
|
||||
#include "CardSelector.h"
|
||||
#include "PlayGuiObject.h"
|
||||
|
||||
template <typename T> class ObjectSelector;
|
||||
typedef ObjectSelector<PlayGuiObject> CardSelector;
|
||||
|
||||
class MTGGuiHand;
|
||||
class MTGGuiPlay;
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
ECON_DIFFICULTY,
|
||||
TRANSITIONS,
|
||||
INTERRUPT_SECONDS,
|
||||
KEY_BINDINGS,
|
||||
//My interrupts
|
||||
INTERRUPTMYSPELLS,
|
||||
INTERRUPTMYABILITIES,
|
||||
@@ -80,7 +81,7 @@ public:
|
||||
static string getName(int option);
|
||||
|
||||
private:
|
||||
static const char* optionNames[];
|
||||
static const string optionNames[];
|
||||
};
|
||||
|
||||
class GameOption {
|
||||
@@ -130,6 +131,10 @@ private:
|
||||
bool viewed; //Flag it as "New!" or not.
|
||||
};
|
||||
|
||||
class GameOptionKeyBindings : public GameOption {
|
||||
virtual bool read(string input);
|
||||
};
|
||||
|
||||
class OptionVolume: public EnumDefinition{
|
||||
public:
|
||||
enum { MUTE = 0, MAX = 100 };
|
||||
|
||||
@@ -58,7 +58,7 @@ class OptionSelect:public OptionItem{
|
||||
virtual void Reload(){initSelections();};
|
||||
virtual void Render();
|
||||
virtual bool Selectable();
|
||||
virtual void Entering(u32 key);
|
||||
virtual void Entering(JButton key);
|
||||
virtual bool Changed() {return (value != prior_value);};
|
||||
virtual void setData();
|
||||
virtual void initSelections();
|
||||
@@ -118,7 +118,7 @@ class OptionProfile:public OptionDirectory{
|
||||
virtual void addSelection(string s);
|
||||
virtual bool Selectable() {return canSelect;};
|
||||
virtual bool Changed() {return (initialValue != value);};
|
||||
virtual void Entering(u32 key);
|
||||
virtual void Entering(JButton key);
|
||||
virtual void Reload();
|
||||
virtual void Render();
|
||||
virtual void confirmChange(bool confirmed);
|
||||
|
||||
93
projects/mtg/include/ShopItem.h
Normal file
93
projects/mtg/include/ShopItem.h
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef _SHOP_ITEM_H
|
||||
#define _SHOP_ITEM_H
|
||||
|
||||
#include <JGui.h>
|
||||
#include <JLBFont.h>
|
||||
#include "SimpleMenu.h"
|
||||
#include "MTGDeck.h"
|
||||
#include "../include/PriceList.h"
|
||||
#include "../include/PlayerData.h"
|
||||
#include "../include/CardDisplay.h"
|
||||
#include "../include/DeckDataWrapper.h"
|
||||
|
||||
#include <string>
|
||||
using std::string;
|
||||
|
||||
class hgeDistortionMesh;
|
||||
|
||||
#define SHOP_BOOSTERS 3
|
||||
|
||||
class ShopItem:public JGuiObject{
|
||||
private:
|
||||
friend class ShopItems;
|
||||
bool mHasFocus;
|
||||
bool mRelease;
|
||||
JLBFont *mFont;
|
||||
string mText;
|
||||
float xy[8];
|
||||
JQuad * quad;
|
||||
JQuad * thumb;
|
||||
float mScale;
|
||||
float mTargetScale;
|
||||
hgeDistortionMesh* mesh;
|
||||
|
||||
void updateThumb();
|
||||
|
||||
public:
|
||||
int nameCount;
|
||||
int quantity;
|
||||
MTGCard * card;
|
||||
int price;
|
||||
ShopItem(int id, JLBFont * font, int _cardid, float _xy[], bool hasFocus, MTGAllCards * collection, int _price, DeckDataWrapper * ddw);
|
||||
ShopItem(int id, JLBFont * font, char* text, JQuad * _quad, JQuad * _thumb,float _xy[], bool hasFocus, int _price);
|
||||
~ShopItem();
|
||||
int updateCount(DeckDataWrapper * ddw);
|
||||
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
|
||||
virtual void Entering();
|
||||
virtual bool Leaving(JButton key);
|
||||
virtual bool ButtonPressed();
|
||||
|
||||
const char * getText();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
};
|
||||
|
||||
class ShopItems:public JGuiController,public JGuiListener{
|
||||
private:
|
||||
PlayerData * playerdata;
|
||||
PriceList * pricelist;
|
||||
int mX, mY, mHeight;
|
||||
JLBFont* mFont;
|
||||
JTexture * mBgAATex;
|
||||
JQuad * mBgAA;
|
||||
MTGAllCards * collection;
|
||||
SimpleMenu * dialog;
|
||||
int showPriceDialog;
|
||||
int setIds[SHOP_BOOSTERS];
|
||||
MTGCardInstance * displayCards[100];
|
||||
CardDisplay * display;
|
||||
void safeDeleteDisplay();
|
||||
DeckDataWrapper * myCollection;
|
||||
|
||||
int lightAlpha;
|
||||
int alphaChange;
|
||||
|
||||
public:
|
||||
bool showCardList;
|
||||
ShopItems(int id, JGuiListener* listener, JLBFont* font, int x, int y, MTGAllCards * _collection, int _setIds[]);
|
||||
~ShopItems();
|
||||
void Render();
|
||||
virtual void Update(float dt);
|
||||
void Add(int cardid);
|
||||
void Add(char * text, JQuad * quad, JQuad * thumb,int _price);
|
||||
void pricedialog(int id, int mode=1);
|
||||
virtual void ButtonPressed(int controllerId, int controlId);
|
||||
bool CheckUserInput(JButton key);
|
||||
void savePriceList();
|
||||
void saveAll();
|
||||
static float _x1[],_y1[],_x2[],_y2[],_x3[],_y3[],_x4[],_y4[];
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -46,8 +46,8 @@ public:
|
||||
virtual PIXEL_TYPE getColor(int type);
|
||||
virtual float getMargin(int type) {return 4;};
|
||||
|
||||
virtual void Entering(u32 key)=0;
|
||||
virtual bool Leaving(u32 key)=0;
|
||||
virtual void Entering(JButton key)=0;
|
||||
virtual bool Leaving(JButton key)=0;
|
||||
|
||||
virtual void Update(float dt)=0;
|
||||
virtual void updateValue(){};
|
||||
@@ -82,15 +82,15 @@ public:
|
||||
virtual void renderBack(WGuiBase * it);
|
||||
virtual void subBack(WGuiBase * item) {};
|
||||
|
||||
virtual bool CheckUserInput(u32 key) {return false;};
|
||||
virtual bool CheckUserInput(JButton key) {return false;};
|
||||
};
|
||||
|
||||
//This is our base class for concrete items.
|
||||
class WGuiItem: public WGuiBase{
|
||||
public:
|
||||
virtual void Entering(u32 key);
|
||||
virtual bool Leaving(u32 key);
|
||||
virtual bool CheckUserInput(u32 key);
|
||||
virtual void Entering(JButton key);
|
||||
virtual bool Leaving(JButton key);
|
||||
virtual bool CheckUserInput(JButton key);
|
||||
virtual void Update(float dt) {};
|
||||
virtual void Render();
|
||||
|
||||
@@ -177,8 +177,8 @@ public:
|
||||
virtual bool Changed() {return it->Changed();};
|
||||
virtual void confirmChange(bool confirmed) {it->confirmChange(confirmed);};
|
||||
|
||||
virtual void Entering(u32 key) {it->Entering(key);};
|
||||
virtual bool Leaving(u32 key) {return it->Leaving(key);};
|
||||
virtual void Entering(JButton key) {it->Entering(key);};
|
||||
virtual bool Leaving(JButton key) {return it->Leaving(key);};
|
||||
virtual void Update(float dt) {it->Update(dt);};
|
||||
virtual void updateValue() {it->updateValue();};
|
||||
virtual void Reload() {it->Reload();};
|
||||
@@ -208,7 +208,7 @@ public:
|
||||
virtual void setHeight(float _h) {it->setHeight(_h);};
|
||||
virtual void setHidden(bool bHidden) {it->setHidden(bHidden);};
|
||||
virtual void setVisible(bool bVisisble) {it->setVisible(bVisisble);};
|
||||
virtual bool CheckUserInput(u32 key) {return it->CheckUserInput(key);};
|
||||
virtual bool CheckUserInput(JButton key) {return it->CheckUserInput(key);};
|
||||
protected:
|
||||
WGuiBase * it;
|
||||
};
|
||||
@@ -251,9 +251,9 @@ public:
|
||||
virtual void ButtonPressed(int controllerId, int controlId);
|
||||
virtual void confirmChange(bool confirmed);
|
||||
|
||||
virtual void Entering(u32 key);
|
||||
virtual bool Leaving(u32 key);
|
||||
virtual bool CheckUserInput(u32 key);
|
||||
virtual void Entering(JButton key);
|
||||
virtual bool Leaving(JButton key);
|
||||
virtual bool CheckUserInput(JButton key);
|
||||
|
||||
bool bRight;
|
||||
float percentRight;
|
||||
@@ -269,12 +269,12 @@ public:
|
||||
virtual bool isModal();
|
||||
virtual void setData();
|
||||
virtual void setModal(bool val);
|
||||
virtual void Entering(u32 key);
|
||||
virtual bool Leaving(u32 key);
|
||||
virtual void Entering(JButton key);
|
||||
virtual bool Leaving(JButton key);
|
||||
virtual void Update(float dt);
|
||||
virtual void Overlay();
|
||||
virtual void ButtonPressed(int controllerId, int controlId);
|
||||
virtual bool CheckUserInput(u32 key);
|
||||
virtual bool CheckUserInput(JButton key);
|
||||
|
||||
string confirm;
|
||||
string cancel;
|
||||
@@ -312,7 +312,7 @@ class WGuiButton: public WGuiDeco{
|
||||
public:
|
||||
WGuiButton( WGuiBase* _it, int _controller, int _control, JGuiListener * jgl);
|
||||
virtual void updateValue();
|
||||
virtual bool CheckUserInput(u32 key);
|
||||
virtual bool CheckUserInput(JButton key);
|
||||
virtual bool Selectable() {return Visible();};
|
||||
virtual PIXEL_TYPE getColor(int type);
|
||||
virtual int getControlID() {return control;};
|
||||
@@ -350,7 +350,7 @@ class WGuiMenu: public WGuiItem{
|
||||
public:
|
||||
friend class WGuiFilters;
|
||||
virtual ~WGuiMenu();
|
||||
WGuiMenu(u32 next, u32 prev, bool mDPad = false, WSyncable * syncme=NULL);
|
||||
WGuiMenu(JButton next, JButton prev, bool mDPad = false, WSyncable * syncme=NULL);
|
||||
|
||||
virtual void Render();
|
||||
virtual void Reload();
|
||||
@@ -358,10 +358,10 @@ public:
|
||||
virtual void ButtonPressed(int controllerId, int controlId);
|
||||
virtual void Add(WGuiBase* item); //Remember, does not set X & Y of items automatically.
|
||||
virtual void confirmChange(bool confirmed);
|
||||
virtual bool Leaving(u32 key);
|
||||
virtual void Entering(u32 key);
|
||||
virtual bool Leaving(JButton key);
|
||||
virtual void Entering(JButton key);
|
||||
virtual void subBack(WGuiBase * item);
|
||||
virtual bool CheckUserInput(u32 key);
|
||||
virtual bool CheckUserInput(JButton key);
|
||||
WGuiBase * Current();
|
||||
virtual int getSelected() {return currentItem;};
|
||||
virtual bool nextItem();
|
||||
@@ -373,12 +373,12 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void syncMove();
|
||||
virtual bool isButtonDir(u32 key, int dir); //For the DPad override.
|
||||
u32 buttonNext, buttonPrev;
|
||||
virtual bool isButtonDir(JButton key, int dir); //For the DPad override.
|
||||
JButton buttonNext, buttonPrev;
|
||||
bool mDPad;
|
||||
vector<WGuiBase*> items;
|
||||
int currentItem;
|
||||
u32 held;
|
||||
JButton held;
|
||||
WSyncable * sync;
|
||||
float duration;
|
||||
};
|
||||
@@ -399,7 +399,7 @@ protected:
|
||||
};
|
||||
class WGuiTabMenu: public WGuiMenu {
|
||||
public:
|
||||
WGuiTabMenu() : WGuiMenu(PSP_CTRL_RTRIGGER,PSP_CTRL_LTRIGGER) {};
|
||||
WGuiTabMenu() : WGuiMenu(JGE_BTN_NEXT, JGE_BTN_PREV) {};
|
||||
virtual void Render();
|
||||
virtual void Add(WGuiBase * it);
|
||||
void save();
|
||||
@@ -415,11 +415,11 @@ public:
|
||||
friend class WGuiFilterItem;
|
||||
WGuiFilters(string header, WSrcCards * src);
|
||||
~WGuiFilters();
|
||||
bool CheckUserInput(u32 key);
|
||||
bool CheckUserInput(JButton key);
|
||||
string getCode(); //For use in filter factory.
|
||||
void Update(float dt);
|
||||
void Render();
|
||||
void Entering(u32 key);
|
||||
void Entering(JButton key);
|
||||
void addColumn();
|
||||
bool isAvailable(int type);
|
||||
bool isAvailableCode(string code);
|
||||
@@ -484,4 +484,4 @@ struct WLFiltersSort{
|
||||
bool operator()(const WGuiBase*l, const WGuiBase*r);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -52,7 +52,7 @@ int ActionLayer::reactToTargetClick(ActionElement* ability, Targetable * card){
|
||||
|
||||
bool ActionLayer::CheckUserInput(u32 key){
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
if (g->waitForExtraPayment && key == PSP_CTRL_CROSS){
|
||||
if (g->waitForExtraPayment && key == JGE_BTN_SEC){
|
||||
g->waitForExtraPayment = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ void ActionStack::Update(float dt){
|
||||
for (int i = 0; i < mCount ; i++){
|
||||
Interruptible * current = (Interruptible *)mObjects[i];
|
||||
if (tc->canTarget(current)){
|
||||
if (mObjects[mCurr]) mObjects[mCurr]->Leaving(PSP_CTRL_UP);
|
||||
if (mObjects[mCurr]) mObjects[mCurr]->Leaving(JGE_BTN_UP);
|
||||
current->display = 1;
|
||||
mCurr = i;
|
||||
mObjects[mCurr]->Entering();
|
||||
@@ -621,32 +621,32 @@ void ActionStack::endOfInterruption(){
|
||||
|
||||
|
||||
bool ActionStack::CheckUserInput(u32 key){
|
||||
u32 trigger = (options[Options::REVERSETRIGGERS].number ? PSP_CTRL_RTRIGGER : PSP_CTRL_LTRIGGER);
|
||||
u32 trigger = (options[Options::REVERSETRIGGERS].number ? JGE_BTN_NEXT : JGE_BTN_PREV);
|
||||
if (mode == ACTIONSTACK_STANDARD){
|
||||
if (askIfWishesToInterrupt){
|
||||
if (PSP_CTRL_CROSS == key){
|
||||
if (JGE_BTN_SEC == key){
|
||||
setIsInterrupting(askIfWishesToInterrupt);
|
||||
return true;
|
||||
}else if ((PSP_CTRL_CIRCLE == key) || (trigger == key) ){
|
||||
}else if ((JGE_BTN_OK == key) || (trigger == key) ){
|
||||
cancelInterruptOffer();
|
||||
return true;
|
||||
}else if ((PSP_CTRL_SQUARE == key)){
|
||||
}else if ((JGE_BTN_PRI == key)){
|
||||
cancelInterruptOffer(2);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}else if (game->isInterrupting){
|
||||
if (PSP_CTRL_CROSS == key){
|
||||
if (JGE_BTN_SEC == key){
|
||||
endOfInterruption();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}else if (mode == ACTIONSTACK_TARGET){
|
||||
if (modal){
|
||||
if (PSP_CTRL_UP == key){
|
||||
if (JGE_BTN_UP == key){
|
||||
if( mObjects[mCurr]){
|
||||
int n = getPreviousIndex(((Interruptible *) mObjects[mCurr]), 0, 0, 1);
|
||||
if (n != -1 && n != mCurr && mObjects[mCurr]->Leaving(PSP_CTRL_UP)){
|
||||
if (n != -1 && n != mCurr && mObjects[mCurr]->Leaving(JGE_BTN_UP)){
|
||||
mCurr = n;
|
||||
mObjects[mCurr]->Entering();
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
@@ -657,10 +657,10 @@ bool ActionStack::CheckUserInput(u32 key){
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}else if (PSP_CTRL_DOWN == key){
|
||||
}else if (JGE_BTN_DOWN == key){
|
||||
if( mObjects[mCurr]){
|
||||
int n = getNextIndex(((Interruptible *) mObjects[mCurr]), 0, 0, 1);
|
||||
if (n!= -1 && n != mCurr && mObjects[mCurr]->Leaving(PSP_CTRL_DOWN)){
|
||||
if (n!= -1 && n != mCurr && mObjects[mCurr]->Leaving(JGE_BTN_DOWN)){
|
||||
mCurr = n;
|
||||
mObjects[mCurr]->Entering();
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
@@ -671,7 +671,7 @@ bool ActionStack::CheckUserInput(u32 key){
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}else if (PSP_CTRL_CIRCLE == key){
|
||||
}else if (JGE_BTN_OK == key){
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
char buf[4096];
|
||||
sprintf(buf, "ACTIONSTACK CLIKED mCurr = %i\n", mCurr);
|
||||
@@ -682,7 +682,7 @@ bool ActionStack::CheckUserInput(u32 key){
|
||||
}
|
||||
return true; //Steal the input to other layers if we're visible
|
||||
}
|
||||
if (PSP_CTRL_TRIANGLE == key){
|
||||
if (JGE_BTN_CANCEL == key){
|
||||
if (modal) modal = 0; else modal = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ void CardDisplay::Update(float dt){
|
||||
}
|
||||
|
||||
bool CardDisplay::CheckUserInput(u32 key){
|
||||
if (PSP_CTRL_CROSS == key)
|
||||
if (JGE_BTN_SEC == key)
|
||||
{
|
||||
if (listener){
|
||||
listener->ButtonPressed(mId, 0);
|
||||
@@ -108,7 +108,7 @@ bool CardDisplay::CheckUserInput(u32 key){
|
||||
|
||||
switch(key)
|
||||
{
|
||||
case PSP_CTRL_LEFT :
|
||||
case JGE_BTN_LEFT :
|
||||
{
|
||||
int n = mCurr;
|
||||
n--;
|
||||
@@ -116,13 +116,13 @@ bool CardDisplay::CheckUserInput(u32 key){
|
||||
if (n< 0){n = 0;}
|
||||
else{ rotateLeft();}
|
||||
}
|
||||
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_LEFT)){
|
||||
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(JGE_BTN_LEFT)){
|
||||
mCurr = n;
|
||||
mObjects[mCurr]->Entering();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case PSP_CTRL_RIGHT :
|
||||
case JGE_BTN_RIGHT :
|
||||
{
|
||||
int n = mCurr;
|
||||
n++;
|
||||
@@ -130,7 +130,7 @@ bool CardDisplay::CheckUserInput(u32 key){
|
||||
if (n>= start_item + nb_displayed_items){
|
||||
rotateRight();
|
||||
}
|
||||
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_RIGHT)){
|
||||
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(JGE_BTN_RIGHT)){
|
||||
mCurr = n;
|
||||
mObjects[mCurr]->Entering();
|
||||
}
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
|
||||
using std::cout;
|
||||
|
||||
|
||||
|
||||
#ifdef True
|
||||
#undef True
|
||||
#endif
|
||||
|
||||
struct Left : public Exp { static inline bool test(CardSelector::Target* ref, CardSelector::Target* test)
|
||||
{ return ref->x - test->x > fabs(ref->y - test->y); } };
|
||||
@@ -119,26 +120,26 @@ bool CardSelector::CheckUserInput(u32 key)
|
||||
Target* oldactive = active;
|
||||
switch (key)
|
||||
{
|
||||
case PSP_CTRL_CROSS:
|
||||
case JGE_BTN_SEC:
|
||||
GameObserver::GetInstance()->cancelCurrentAction();
|
||||
return true;
|
||||
case PSP_CTRL_CIRCLE:
|
||||
case JGE_BTN_OK:
|
||||
GameObserver::GetInstance()->ButtonPressed(active);
|
||||
return true;
|
||||
break;
|
||||
case PSP_CTRL_LEFT:
|
||||
case JGE_BTN_LEFT:
|
||||
active = closest<Left>(cards, limitor, active);
|
||||
break;
|
||||
case PSP_CTRL_RIGHT:
|
||||
case JGE_BTN_RIGHT:
|
||||
active = closest<Right>(cards, limitor, active);
|
||||
break;
|
||||
case PSP_CTRL_UP:
|
||||
case JGE_BTN_UP:
|
||||
active = closest<Up>(cards, limitor, active);
|
||||
break;
|
||||
case PSP_CTRL_DOWN:
|
||||
case JGE_BTN_DOWN:
|
||||
active = closest<Down>(cards, limitor, active);
|
||||
break;
|
||||
case PSP_CTRL_TRIANGLE:
|
||||
case JGE_BTN_CANCEL:
|
||||
bigMode = (bigMode+1) % NB_BIG_MODES;
|
||||
if(bigMode == BIG_MODE_TEXT)
|
||||
options[Options::DISABLECARDS].number = 1;
|
||||
@@ -160,10 +161,10 @@ bool CardSelector::CheckUserInput(u32 key)
|
||||
if (PlayGuiObject* old = fetchMemory(lasts[owner]))
|
||||
switch (key)
|
||||
{
|
||||
case PSP_CTRL_LEFT: if (old->x < oldactive->x) active = old; break;
|
||||
case PSP_CTRL_RIGHT: if (old->x > oldactive->x) active = old; break;
|
||||
case PSP_CTRL_UP: if (old->y < oldactive->y) active = old; break;
|
||||
case PSP_CTRL_DOWN: if (old->y > oldactive->y) active = old; break;
|
||||
case JGE_BTN_LEFT: if (old->x < oldactive->x) active = old; break;
|
||||
case JGE_BTN_RIGHT: if (old->x > oldactive->x) active = old; break;
|
||||
case JGE_BTN_UP: if (old->y < oldactive->y) active = old; break;
|
||||
case JGE_BTN_DOWN: if (old->y > oldactive->y) active = old; break;
|
||||
default: if (old) active = old; break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,22 +248,21 @@ void GameApp::Update()
|
||||
{
|
||||
if (systemError.size()) return;
|
||||
JGE* mEngine = JGE::GetInstance();
|
||||
if (mEngine->GetButtonState(PSP_CTRL_START) && mEngine->GetButtonClick(PSP_CTRL_TRIANGLE))
|
||||
if (mEngine->GetButtonState(JGE_BTN_MENU) && mEngine->GetButtonClick(JGE_BTN_CANCEL))
|
||||
{
|
||||
char s[80];
|
||||
sprintf(s, "ms0:/psp/photo/MTG%d.png", mScreenShotCount++);
|
||||
JRenderer::GetInstance()->ScreenShot(s);
|
||||
}
|
||||
//Exit when START and X ARE PRESSED SIMULTANEOUSLY
|
||||
if (mEngine->GetButtonState(PSP_CTRL_START) && mEngine->GetButtonState(PSP_CTRL_CROSS)){
|
||||
if (mEngine->GetButtonState(JGE_BTN_MENU) && mEngine->GetButtonState(JGE_BTN_SEC)){
|
||||
mEngine->End();
|
||||
return;
|
||||
}
|
||||
|
||||
//Restart Rendering engine when START and SQUARE ARE PRESSED SIMULTANEOUSLY
|
||||
if (mEngine->GetButtonState(PSP_CTRL_START) && mEngine->GetButtonState(PSP_CTRL_SQUARE)){
|
||||
if (mEngine->GetButtonState(JGE_BTN_MENU) && mEngine->GetButtonState(JGE_BTN_PRI))
|
||||
JRenderer::Destroy();
|
||||
}
|
||||
|
||||
float dt = mEngine->GetDelta();
|
||||
if (dt > 35.0f) // min 30 FPS ;)
|
||||
@@ -337,10 +336,10 @@ void GameApp::Render()
|
||||
nbUpdates+=1;
|
||||
JLBFont * mFont= resources.GetJLBFont("simon");
|
||||
char buf[512];
|
||||
sprintf(buf, "avg:%f - %f fps",totalFPS/nbUpdates, fps);
|
||||
sprintf(buf, "avg:%.02f - %.02f fps",totalFPS/nbUpdates, fps);
|
||||
if (mFont) {
|
||||
mFont->SetColor(ARGB(255,255,255,255));
|
||||
mFont->DrawString(buf,1,1);
|
||||
mFont->DrawString(buf,1,10);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -5,12 +5,13 @@
|
||||
#include "../include/Translate.h"
|
||||
#include "../include/OptionItem.h"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
#include <JGE.h>
|
||||
|
||||
const char * Options::optionNames[] = {
|
||||
const string Options::optionNames[] = {
|
||||
//Global options
|
||||
"Profile",
|
||||
"Lang",
|
||||
@@ -31,6 +32,13 @@ const char * Options::optionNames[] = {
|
||||
"economic_difficulty",
|
||||
"transitions",
|
||||
"interruptSeconds",
|
||||
#if defined(WIN32)
|
||||
"keybindings_win",
|
||||
#elsif defined(LINUX)
|
||||
"keybindings_x",
|
||||
#else
|
||||
"keybindings_psp",
|
||||
#endif
|
||||
"interruptMySpells",
|
||||
"interruptMyAbilities",
|
||||
//General interrupts
|
||||
@@ -57,8 +65,7 @@ const char * Options::optionNames[] = {
|
||||
|
||||
};
|
||||
int Options::getID(string name){
|
||||
if(!name.size())
|
||||
INVALID_OPTION;
|
||||
if (0 == name.size()) INVALID_OPTION;
|
||||
|
||||
std::transform(name.begin(),name.end(),name.begin(),::tolower);
|
||||
|
||||
@@ -335,9 +342,6 @@ GameOption& GameOptions::operator[](int optionID){
|
||||
}
|
||||
|
||||
GameOption * GameOptions::get(int optionID) {
|
||||
GameOption * go = NULL;
|
||||
GameOptionEnum * goEnum = NULL;
|
||||
|
||||
//Invalid options!
|
||||
if(optionID < 0)
|
||||
return NULL;
|
||||
@@ -347,39 +351,44 @@ GameOption * GameOptions::get(int optionID) {
|
||||
values.reserve(optionID);
|
||||
|
||||
while(x <= optionID){
|
||||
switch(x){
|
||||
//Enum options
|
||||
case Options::HANDDIRECTION:
|
||||
goEnum = NEW GameOptionEnum();
|
||||
goEnum->def = OptionHandDirection::getInstance();
|
||||
go = goEnum;
|
||||
break;
|
||||
case Options::CLOSEDHAND:
|
||||
goEnum = NEW GameOptionEnum();
|
||||
goEnum->def = OptionClosedHand::getInstance();
|
||||
go = goEnum;
|
||||
break;
|
||||
case Options::MANADISPLAY:
|
||||
goEnum = NEW GameOptionEnum();
|
||||
goEnum->def = OptionManaDisplay::getInstance();
|
||||
go = goEnum;
|
||||
break;
|
||||
case Options::MAX_GRADE:
|
||||
goEnum = NEW GameOptionEnum();
|
||||
goEnum->def = OptionMaxGrade::getInstance();
|
||||
go = goEnum;
|
||||
break;
|
||||
case Options::ECON_DIFFICULTY:
|
||||
goEnum = NEW GameOptionEnum();
|
||||
goEnum->def = OptionEconDifficulty::getInstance();
|
||||
go = goEnum;
|
||||
break;
|
||||
default:
|
||||
if(x >= Options::BEGIN_AWARDS)
|
||||
go = NEW GameOptionAward();
|
||||
else
|
||||
go = NEW GameOption();
|
||||
break;
|
||||
GameOption * go = NULL;
|
||||
GameOptionEnum * goEnum = NULL;
|
||||
switch(x){
|
||||
//Enum options
|
||||
case Options::HANDDIRECTION:
|
||||
goEnum = NEW GameOptionEnum();
|
||||
goEnum->def = OptionHandDirection::getInstance();
|
||||
go = goEnum;
|
||||
break;
|
||||
case Options::CLOSEDHAND:
|
||||
goEnum = NEW GameOptionEnum();
|
||||
goEnum->def = OptionClosedHand::getInstance();
|
||||
go = goEnum;
|
||||
break;
|
||||
case Options::MANADISPLAY:
|
||||
goEnum = NEW GameOptionEnum();
|
||||
goEnum->def = OptionManaDisplay::getInstance();
|
||||
go = goEnum;
|
||||
break;
|
||||
case Options::MAX_GRADE:
|
||||
goEnum = NEW GameOptionEnum();
|
||||
goEnum->def = OptionMaxGrade::getInstance();
|
||||
go = goEnum;
|
||||
break;
|
||||
case Options::KEY_BINDINGS:
|
||||
go = NEW GameOptionKeyBindings();
|
||||
break;
|
||||
case Options::ECON_DIFFICULTY:
|
||||
goEnum = NEW GameOptionEnum();
|
||||
goEnum->def = OptionEconDifficulty::getInstance();
|
||||
go = goEnum;
|
||||
break;
|
||||
default:
|
||||
if(x >= Options::BEGIN_AWARDS)
|
||||
go = NEW GameOptionAward();
|
||||
else
|
||||
go = NEW GameOption();
|
||||
break;
|
||||
}
|
||||
values.push_back(go);
|
||||
x++;
|
||||
@@ -684,10 +693,7 @@ bool GameOptionEnum::write(std::ofstream * file, string name){
|
||||
if(!file || !def || number <= 0 || number >= (int) def->values.size())
|
||||
return false;
|
||||
|
||||
char writer[1024];
|
||||
sprintf(writer,"%s=%s\n", name.c_str(), menuStr().c_str());
|
||||
|
||||
(*file)<<writer;
|
||||
(*file) << name << "=" << menuStr() << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -871,3 +877,35 @@ string GameOptionAward::menuStr(){
|
||||
strftime(buf,255,_("%B %d, %I:%M%p %Y").c_str(),lt);
|
||||
return buf;
|
||||
}
|
||||
|
||||
static JButton u32_to_button(u32 b)
|
||||
{
|
||||
if (b < JGE_BTN_MAX) return static_cast<JButton>(b);
|
||||
else return JGE_BTN_NONE;
|
||||
}
|
||||
|
||||
bool GameOptionKeyBindings::read(string input){
|
||||
istringstream iss(input);
|
||||
vector< pair<LocalKeySym, JButton> > assoc;
|
||||
|
||||
while (iss.good())
|
||||
{
|
||||
stringstream s;
|
||||
iss.get(*(s.rdbuf()), ',');
|
||||
iss.get();
|
||||
|
||||
LocalKeySym local; char sep; u32 button;
|
||||
s >> local >> sep >> button;
|
||||
if (':' != sep) return false;
|
||||
assoc.push_back(make_pair(local, u32_to_button(button)));
|
||||
}
|
||||
|
||||
if (assoc.empty()) return false;
|
||||
JGE* j = JGE::GetInstance();
|
||||
|
||||
j->ClearBindings();
|
||||
for (vector< pair<LocalKeySym, JButton> >::const_iterator it = assoc.begin(); it != assoc.end(); ++it)
|
||||
j->BindKey(it->first, it->second);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -110,8 +110,8 @@ void GameStateAwards::Start()
|
||||
wgh->setDisplay(buf);
|
||||
wgh->mFlags = WGuiItem::NO_TRANSLATE;
|
||||
|
||||
listview->Entering(0);
|
||||
detailview = NULL;
|
||||
listview->Entering(JGE_BTN_NONE);
|
||||
detailview = NULL;
|
||||
setSrc = NULL;
|
||||
showMenu = false;
|
||||
resources.Unmiss("awardback.jpg"); //Last resort, same as shop.
|
||||
@@ -151,19 +151,18 @@ void GameStateAwards::Render()
|
||||
|
||||
void GameStateAwards::Update(float dt)
|
||||
{
|
||||
if(mEngine->GetButtonClick(PSP_CTRL_TRIANGLE))
|
||||
if(mEngine->GetButtonClick(JGE_BTN_CANCEL))
|
||||
options[Options::DISABLECARDS].number = !options[Options::DISABLECARDS].number;
|
||||
|
||||
if(showMenu){
|
||||
menu->Update(dt);
|
||||
}
|
||||
else{
|
||||
u32 key;
|
||||
JButton key;
|
||||
while ((key = JGE::GetInstance()->ReadButton())){
|
||||
switch(key){
|
||||
case PSP_CTRL_START:
|
||||
case JGE_BTN_MENU:
|
||||
showMenu = true;
|
||||
|
||||
SAFE_DELETE(menu);
|
||||
menu = NEW SimpleMenu(-102, this,Constants::MENU_FONT, 50,170);
|
||||
if(mState == STATE_DETAILS)
|
||||
@@ -171,10 +170,10 @@ void GameStateAwards::Update(float dt)
|
||||
menu->Add(1, "Back to Main Menu");
|
||||
menu->Add(3, "Cancel");
|
||||
break;
|
||||
case PSP_CTRL_LTRIGGER:
|
||||
case JGE_BTN_PREV:
|
||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
||||
break;
|
||||
case PSP_CTRL_CROSS:
|
||||
case JGE_BTN_SEC:
|
||||
if(mState == STATE_LISTVIEW)
|
||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
||||
else{
|
||||
@@ -194,9 +193,7 @@ void GameStateAwards::Update(float dt)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(setSrc)
|
||||
setSrc->Update(dt);
|
||||
}
|
||||
@@ -217,7 +214,7 @@ bool GameStateAwards::enterSet(int setid){
|
||||
setSrc->bakeFilters();
|
||||
setSrc->Sort(WSrcCards::SORT_COLLECTOR);
|
||||
|
||||
detailview = NEW WGuiMenu(PSP_CTRL_DOWN,PSP_CTRL_UP);
|
||||
detailview = NEW WGuiMenu(JGE_BTN_DOWN, JGE_BTN_UP);
|
||||
|
||||
WGuiList * spoiler = NEW WGuiList("Spoiler",setSrc);
|
||||
spoiler->setX(210);
|
||||
@@ -228,13 +225,13 @@ bool GameStateAwards::enterSet(int setid){
|
||||
spoiler->Add(NEW WGuiItem(c->data->name));
|
||||
}
|
||||
setSrc->setOffset(0);
|
||||
spoiler->Entering(0);
|
||||
spoiler->Entering(JGE_BTN_NONE);
|
||||
WGuiCardImage * wi = NEW WGuiCardImage(setSrc);
|
||||
wi->setX(105);
|
||||
wi->setY(137);
|
||||
detailview->Add(wi);
|
||||
detailview->Add(spoiler);
|
||||
detailview->Entering(0);
|
||||
detailview->Entering(JGE_BTN_NONE);
|
||||
return true;
|
||||
}
|
||||
bool GameStateAwards::enterStats(int option){
|
||||
@@ -248,7 +245,7 @@ bool GameStateAwards::enterStats(int option){
|
||||
detailview = NEW WGuiList("Details");
|
||||
|
||||
detailview->Add(NEW WGuiHeader("Collection Stats"));
|
||||
detailview->Entering(0);
|
||||
detailview->Entering(JGE_BTN_NONE);
|
||||
|
||||
//Discover favorite set and unique cards
|
||||
int unique = 0;
|
||||
|
||||
@@ -280,43 +280,43 @@ void GameStateDeckViewer::Update(float dt)
|
||||
if (mStage == STAGE_WAITING || mStage == STAGE_ONSCREEN_MENU){
|
||||
switch (mEngine->ReadButton())
|
||||
{
|
||||
case PSP_CTRL_LEFT :
|
||||
case JGE_BTN_LEFT :
|
||||
last_user_activity = 0;
|
||||
mStage = STAGE_TRANSITION_LEFT;
|
||||
break;
|
||||
case PSP_CTRL_RIGHT :
|
||||
case JGE_BTN_RIGHT :
|
||||
last_user_activity = 0;
|
||||
mStage = STAGE_TRANSITION_RIGHT;
|
||||
break;
|
||||
case PSP_CTRL_UP :
|
||||
case JGE_BTN_UP :
|
||||
last_user_activity = 0;
|
||||
mStage = STAGE_TRANSITION_UP;
|
||||
useFilter[myD]++;
|
||||
if(useFilter[myD] >= MAX_SAVED_FILTERS)
|
||||
useFilter[myD] = 0;
|
||||
break;
|
||||
case PSP_CTRL_DOWN :
|
||||
case JGE_BTN_DOWN :
|
||||
last_user_activity = 0;
|
||||
mStage = STAGE_TRANSITION_DOWN;
|
||||
useFilter[myD]--;
|
||||
if(useFilter[myD] < 0)
|
||||
useFilter[myD] = MAX_SAVED_FILTERS-1;
|
||||
break;
|
||||
case PSP_CTRL_TRIANGLE:
|
||||
case JGE_BTN_CANCEL:
|
||||
options[Options::DISABLECARDS].number = !options[Options::DISABLECARDS].number;
|
||||
break;
|
||||
case PSP_CTRL_SQUARE :
|
||||
case JGE_BTN_PRI :
|
||||
if (last_user_activity > 0.2)
|
||||
{
|
||||
last_user_activity = 0;
|
||||
switchDisplay();
|
||||
}
|
||||
break;
|
||||
case PSP_CTRL_CIRCLE :
|
||||
case JGE_BTN_OK :
|
||||
last_user_activity = 0;
|
||||
addRemove(cardIndex[2]);
|
||||
break;
|
||||
case PSP_CTRL_CROSS :
|
||||
case JGE_BTN_SEC :
|
||||
last_user_activity = 0;
|
||||
SAFE_DELETE(sellMenu);
|
||||
char buffer[4096];
|
||||
@@ -332,7 +332,7 @@ void GameStateDeckViewer::Update(float dt)
|
||||
}
|
||||
stw.needUpdate = true;
|
||||
break;
|
||||
/*case PSP_CTRL_SQUARE :
|
||||
/*case JGE_BTN_PRI :
|
||||
if (last_user_activity < NO_USER_ACTIVITY_HELP_DELAY){
|
||||
last_user_activity = NO_USER_ACTIVITY_HELP_DELAY + 1;
|
||||
}else{
|
||||
@@ -340,58 +340,52 @@ void GameStateDeckViewer::Update(float dt)
|
||||
mStage = STAGE_WAITING;
|
||||
}
|
||||
break;*/
|
||||
case PSP_CTRL_START :
|
||||
case JGE_BTN_MENU :
|
||||
mStage = STAGE_MENU;
|
||||
break;
|
||||
case PSP_CTRL_SELECT :
|
||||
case JGE_BTN_CTRL :
|
||||
mStage = STAGE_FILTERS;
|
||||
if(displayed_deck == myDeck){
|
||||
if(!filterDeck)
|
||||
if (displayed_deck == myDeck) {
|
||||
if (!filterDeck)
|
||||
filterDeck = NEW WGuiFilters("Filter by...",myDeck);
|
||||
filterDeck->Entering(0);
|
||||
}else if(displayed_deck == myCollection){
|
||||
if(!filterCollection)
|
||||
filterDeck->Entering(JGE_BTN_NONE);
|
||||
} else if(displayed_deck == myCollection) {
|
||||
if (!filterCollection)
|
||||
filterCollection = NEW WGuiFilters("Filter by...",myCollection);
|
||||
filterCollection->Entering(0);
|
||||
filterCollection->Entering(JGE_BTN_NONE);
|
||||
}
|
||||
break;
|
||||
case PSP_CTRL_LTRIGGER :
|
||||
if (last_user_activity < NO_USER_ACTIVITY_HELP_DELAY){
|
||||
case JGE_BTN_PREV :
|
||||
if (last_user_activity < NO_USER_ACTIVITY_HELP_DELAY)
|
||||
last_user_activity = NO_USER_ACTIVITY_HELP_DELAY + 1;
|
||||
}
|
||||
else if ((mStage == STAGE_ONSCREEN_MENU) && (--stw.currentPage < 0)) {
|
||||
else if ((mStage == STAGE_ONSCREEN_MENU) && (--stw.currentPage < 0))
|
||||
stw.currentPage = stw.pageCount;
|
||||
}
|
||||
break;
|
||||
case PSP_CTRL_RTRIGGER :
|
||||
if (last_user_activity < NO_USER_ACTIVITY_HELP_DELAY){
|
||||
case JGE_BTN_NEXT :
|
||||
if (last_user_activity < NO_USER_ACTIVITY_HELP_DELAY)
|
||||
last_user_activity = NO_USER_ACTIVITY_HELP_DELAY + 1;
|
||||
}
|
||||
else if ((mStage == STAGE_ONSCREEN_MENU) && (++stw.currentPage > stw.pageCount)) {
|
||||
else if ((mStage == STAGE_ONSCREEN_MENU) && (++stw.currentPage > stw.pageCount))
|
||||
stw.currentPage = 0;
|
||||
}
|
||||
break;
|
||||
default : // no keypress
|
||||
if (last_user_activity > NO_USER_ACTIVITY_HELP_DELAY){
|
||||
if (mStage != STAGE_ONSCREEN_MENU){
|
||||
mStage = STAGE_ONSCREEN_MENU;
|
||||
onScreenTransition = 1;
|
||||
}else{
|
||||
if (onScreenTransition >0){
|
||||
} else {
|
||||
if (onScreenTransition >0)
|
||||
onScreenTransition-= 0.05f;
|
||||
}else{
|
||||
else
|
||||
onScreenTransition = 0;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
} else
|
||||
last_user_activity+= dt;
|
||||
}
|
||||
}
|
||||
|
||||
} if (mStage == STAGE_TRANSITION_RIGHT || mStage == STAGE_TRANSITION_LEFT) {
|
||||
if (mStage == STAGE_TRANSITION_RIGHT){
|
||||
mRotation -= dt * MED_SPEED;
|
||||
if (mRotation < -1.0f){
|
||||
if (mRotation < -1.0f) {
|
||||
do {
|
||||
rotateCards(mStage);
|
||||
mRotation += 1;
|
||||
@@ -399,7 +393,7 @@ void GameStateDeckViewer::Update(float dt)
|
||||
mStage = STAGE_WAITING;
|
||||
mRotation = 0;
|
||||
}
|
||||
}else if(mStage == STAGE_TRANSITION_LEFT){
|
||||
} else if (mStage == STAGE_TRANSITION_LEFT) {
|
||||
mRotation += dt * MED_SPEED;
|
||||
if (mRotation > 1.0f){
|
||||
do {
|
||||
@@ -410,47 +404,47 @@ void GameStateDeckViewer::Update(float dt)
|
||||
mRotation = 0;
|
||||
}
|
||||
}
|
||||
} if (mStage == STAGE_TRANSITION_DOWN || mStage == STAGE_TRANSITION_UP){
|
||||
if (mStage == STAGE_TRANSITION_DOWN){
|
||||
} if (mStage == STAGE_TRANSITION_DOWN || mStage == STAGE_TRANSITION_UP) {
|
||||
if (mStage == STAGE_TRANSITION_DOWN) {
|
||||
mSlide -= 0.05f;
|
||||
if (mSlide < -1.0f){
|
||||
updateFilters();
|
||||
loadIndexes();
|
||||
mSlide = 1;
|
||||
}else if (mSlide > 0 && mSlide < 0.05){
|
||||
} else if (mSlide > 0 && mSlide < 0.05) {
|
||||
mStage = STAGE_WAITING;
|
||||
mSlide = 0;
|
||||
}
|
||||
} if (mStage == STAGE_TRANSITION_UP){
|
||||
} if (mStage == STAGE_TRANSITION_UP) {
|
||||
mSlide += 0.05f;
|
||||
if (mSlide > 1.0f){
|
||||
updateFilters();
|
||||
loadIndexes();
|
||||
mSlide = -1;
|
||||
}else if (mSlide < 0 && mSlide > -0.05){
|
||||
} else if (mSlide < 0 && mSlide > -0.05) {
|
||||
mStage = STAGE_WAITING;
|
||||
mSlide = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}else if (mStage == STAGE_WELCOME){
|
||||
} else if (mStage == STAGE_WELCOME)
|
||||
welcome_menu->Update(dt);
|
||||
}else if (mStage == STAGE_MENU){
|
||||
else if (mStage == STAGE_MENU)
|
||||
menu->Update(dt);
|
||||
}else if(mStage == STAGE_FILTERS){
|
||||
u32 key = mEngine->ReadButton();
|
||||
else if(mStage == STAGE_FILTERS){
|
||||
JButton key = mEngine->ReadButton();
|
||||
|
||||
if(displayed_deck == myDeck){
|
||||
if(filterDeck){
|
||||
if(key == PSP_CTRL_SELECT){
|
||||
if (displayed_deck == myDeck) {
|
||||
if (filterDeck) {
|
||||
if (key == JGE_BTN_CTRL) {
|
||||
useFilter[(displayed_deck == myDeck)] = 0;
|
||||
filterDeck->Finish();
|
||||
filterDeck->Update(dt);
|
||||
loadIndexes();
|
||||
return;
|
||||
}
|
||||
if(!filterDeck->isFinished()){
|
||||
if (!filterDeck->isFinished()) {
|
||||
filterDeck->CheckUserInput(key);
|
||||
filterDeck->Update(dt);
|
||||
} else {
|
||||
@@ -458,23 +452,23 @@ void GameStateDeckViewer::Update(float dt)
|
||||
loadIndexes();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(filterCollection ){
|
||||
if(key == PSP_CTRL_SELECT){
|
||||
} else {
|
||||
if (filterCollection) {
|
||||
if (key == JGE_BTN_CTRL) {
|
||||
useFilter[(displayed_deck == myDeck)] = 0;
|
||||
filterCollection->Finish();
|
||||
filterCollection->Update(dt);
|
||||
loadIndexes();
|
||||
return;
|
||||
}
|
||||
if(!filterCollection->isFinished()){
|
||||
if (!filterCollection->isFinished()) {
|
||||
filterCollection->CheckUserInput(key);
|
||||
filterCollection->Update(dt);
|
||||
} else {
|
||||
mStage = STAGE_WAITING;
|
||||
loadIndexes();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1550,11 +1544,11 @@ void GameStateDeckViewer::ButtonPressed(int controllerId, int controlId)
|
||||
if(displayed_deck == myDeck){
|
||||
if(!filterDeck)
|
||||
filterDeck = NEW WGuiFilters("Filter by...",myDeck);
|
||||
filterDeck->Entering(0);
|
||||
filterDeck->Entering(JGE_BTN_NONE);
|
||||
}else if(displayed_deck == myCollection){
|
||||
if(!filterCollection)
|
||||
filterCollection = NEW WGuiFilters("Filter by...",myCollection);
|
||||
filterCollection->Entering(0);
|
||||
filterCollection->Entering(JGE_BTN_NONE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1581,21 +1575,18 @@ void GameStateDeckViewer::ButtonPressed(int controllerId, int controlId)
|
||||
}
|
||||
}
|
||||
|
||||
// n cards total, a of them are of desired type (A), x drawn
|
||||
// n cards total, a of them are of desired type (A), x drawn
|
||||
// returns probability of no A's
|
||||
float noLuck(int n, int a, int x) {
|
||||
if ( (a >= n) || (a == 0)) {
|
||||
if ((a >= n) || (a == 0))
|
||||
return 1;
|
||||
}
|
||||
if ((n == 0) || (x == 0) || (x > n) || (n-a < x)) {
|
||||
if ((n == 0) || (x == 0) || (x > n) || (n-a < x))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
a = n - a;
|
||||
float result = 1;
|
||||
|
||||
for (int i=0; i<x; i++) {
|
||||
|
||||
for (int i=0; i<x; i++)
|
||||
result *= (float)(a-i)/(n-i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ void GameStateDuel::Update(float dt)
|
||||
switch (mGamePhase)
|
||||
{
|
||||
case DUEL_STATE_ERROR_NO_DECK:
|
||||
if (PSP_CTRL_CIRCLE == mEngine->ReadButton())
|
||||
if (JGE_BTN_OK == mEngine->ReadButton())
|
||||
mParent->SetNextState(GAME_STATE_DECK_VIEWER);
|
||||
break;
|
||||
case DUEL_STATE_CHOOSE_DECK1:
|
||||
@@ -291,11 +291,11 @@ void GameStateDuel::Update(float dt)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (opponentMenu->closed) mGamePhase = DUEL_STATE_PLAY;
|
||||
else opponentMenu->Update(dt);
|
||||
if (opponentMenu->closed) mGamePhase = DUEL_STATE_PLAY;
|
||||
else opponentMenu->Update(dt);
|
||||
}
|
||||
break;
|
||||
case DUEL_STATE_PLAY:
|
||||
case DUEL_STATE_PLAY:
|
||||
if (!game){
|
||||
GameObserver::Init(mPlayers, 2);
|
||||
game = GameObserver::GetInstance();
|
||||
@@ -344,9 +344,8 @@ void GameStateDuel::Update(float dt)
|
||||
loadTestSuitePlayers();
|
||||
mGamePhase = DUEL_STATE_PLAY;
|
||||
testSuite->initGame();
|
||||
}else{
|
||||
}else
|
||||
mGamePhase = DUEL_STATE_END;
|
||||
}
|
||||
}else
|
||||
#endif
|
||||
if (mParent->players[0] == PLAYER_TYPE_CPU && mParent->players[1] == PLAYER_TYPE_CPU){
|
||||
@@ -354,9 +353,8 @@ void GameStateDuel::Update(float dt)
|
||||
Start();
|
||||
}
|
||||
}
|
||||
if (mEngine->GetButtonClick(PSP_CTRL_START)){
|
||||
mGamePhase = DUEL_STATE_MENU;
|
||||
}
|
||||
if (mEngine->GetButtonClick(JGE_BTN_MENU))
|
||||
mGamePhase = DUEL_STATE_MENU;
|
||||
break;
|
||||
case DUEL_STATE_MENU:
|
||||
menu->Update(dt);
|
||||
@@ -380,9 +378,8 @@ void GameStateDuel::Update(float dt)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (PSP_CTRL_CIRCLE == mEngine->ReadButton()){
|
||||
if (JGE_BTN_OK == mEngine->ReadButton())
|
||||
mParent->SetNextState(GAME_STATE_MENU);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -439,14 +436,13 @@ void GameStateDuel::Render()
|
||||
case DUEL_STATE_CHOOSE_DECK1_TO_2:
|
||||
case DUEL_STATE_CHOOSE_DECK2:
|
||||
case DUEL_STATE_CHOOSE_DECK2_TO_PLAY:
|
||||
if (mParent->gameType != GAME_TYPE_CLASSIC){
|
||||
if (mParent->gameType != GAME_TYPE_CLASSIC)
|
||||
mFont->DrawString(_("LOADING DECKS").c_str(),0,SCREEN_HEIGHT/2);
|
||||
}else{
|
||||
if (opponentMenu){
|
||||
else{
|
||||
if (opponentMenu)
|
||||
opponentMenu->Render();
|
||||
}else if (deckmenu){
|
||||
else if (deckmenu)
|
||||
deckmenu->Render();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DUEL_STATE_ERROR_NO_DECK:
|
||||
|
||||
@@ -431,7 +431,7 @@ void GameStateMenu::Update(float dt)
|
||||
}
|
||||
if (mGuiController)
|
||||
mGuiController->Update(dt);
|
||||
if(mEngine->GetButtonState(PSP_CTRL_RTRIGGER)) //Hook for GameStateAward state
|
||||
if(mEngine->GetButtonState(JGE_BTN_NEXT)) //Hook for GameStateAward state
|
||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_AWARDS); //TODO: A slide transition would be nice.
|
||||
break;
|
||||
case MENU_STATE_MAJOR_SUBMENU :
|
||||
@@ -471,8 +471,8 @@ void GameStateMenu::Update(float dt)
|
||||
case MENU_STATE_MINOR_NONE :
|
||||
;// Nothing to do.
|
||||
}
|
||||
|
||||
if(mEngine->GetButtonState(PSP_CTRL_LTRIGGER)) {
|
||||
|
||||
if(mEngine->GetButtonState(JGE_BTN_PREV)) {
|
||||
//Reset deck of cards
|
||||
angleMultiplier = MIN_ANGLE_MULTIPLIER;
|
||||
yW = 55;
|
||||
@@ -480,12 +480,12 @@ void GameStateMenu::Update(float dt)
|
||||
|
||||
if (yW <= 55)
|
||||
{
|
||||
if (mEngine->GetButtonState(PSP_CTRL_SQUARE)) angleMultiplier += STEP_ANGLE_MULTIPLIER;
|
||||
if (mEngine->GetButtonState(JGE_BTN_PRI)) angleMultiplier += STEP_ANGLE_MULTIPLIER;
|
||||
else angleMultiplier *= 0.9999;
|
||||
if (angleMultiplier > MAX_ANGLE_MULTIPLIER) angleMultiplier = MAX_ANGLE_MULTIPLIER;
|
||||
else if (angleMultiplier < MIN_ANGLE_MULTIPLIER) angleMultiplier = MIN_ANGLE_MULTIPLIER;
|
||||
|
||||
if (mEngine->GetButtonState(PSP_CTRL_TRIANGLE) && (dt != 0))
|
||||
if (mEngine->GetButtonState(JGE_BTN_CANCEL) && (dt != 0))
|
||||
{
|
||||
angleMultiplier = (cos(timeIndex)*angleMultiplier - M_PI/3 - 0.1 - angleW) / dt;
|
||||
yW = yW + 5*dt + (yW - 45) *5* dt;
|
||||
|
||||
@@ -28,9 +28,9 @@ void GameStateOptions::Start()
|
||||
WGuiList * optionsList;
|
||||
|
||||
optionsList = NEW WGuiList("Settings");
|
||||
|
||||
|
||||
optionsList->Add(NEW WGuiHeader("General Options"));
|
||||
if (GameApp::HasMusic)
|
||||
if (GameApp::HasMusic)
|
||||
optionsList->Add(NEW WDecoEnum(NEW OptionInteger(Options::MUSICVOLUME,"Music volume",100,10,100),OptionVolume::getInstance()));
|
||||
optionsList->Add(NEW WDecoEnum(NEW OptionInteger(Options::SFXVOLUME,"SFX volume",100,10,100),OptionVolume::getInstance()));
|
||||
optionsList->Add(NEW OptionInteger(Options::OSD, "Display InGame extra information"));
|
||||
@@ -40,9 +40,9 @@ void GameStateOptions::Start()
|
||||
}
|
||||
optionsList->Add(NEW OptionInteger(Options::INTERRUPT_SECONDS, "Seconds to pause for an Interrupt", 20, 1));
|
||||
optionsList->Add(NEW OptionInteger(Options::INTERRUPTMYSPELLS, "Interrupt my spells"));
|
||||
optionsList->Add(NEW OptionInteger(Options::INTERRUPTMYABILITIES, "Interrupt my abilities"));
|
||||
optionsList->Add(NEW OptionInteger(Options::INTERRUPT_SECONDMAIN, "Interrupt opponent's end of turn"));
|
||||
optionsTabs = NEW WGuiTabMenu();
|
||||
optionsList->Add(NEW OptionInteger(Options::INTERRUPTMYABILITIES, "Interrupt my abilities"));
|
||||
optionsList->Add(NEW OptionInteger(Options::INTERRUPT_SECONDMAIN, "Interrupt opponent's end of turn"));
|
||||
optionsTabs = NEW WGuiTabMenu();
|
||||
optionsTabs->Add(optionsList);
|
||||
|
||||
optionsList = NEW WGuiList("Game");
|
||||
@@ -61,8 +61,8 @@ void GameStateOptions::Start()
|
||||
cPrf->confirm = "Use this Profile";
|
||||
OptionDirectory * od = NEW OptionTheme();
|
||||
WDecoConfirm * cThm = NEW WDecoConfirm(this,od);
|
||||
cThm->confirm = "Use this Theme";
|
||||
|
||||
cThm->confirm = "Use this Theme";
|
||||
|
||||
optionsList->Add(NEW WGuiSplit(cPrf,cThm));
|
||||
optionsList->Add(NEW WGuiButton(NEW WGuiHeader("New Profile"),-102,4,this));
|
||||
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::CHEATMODE, "Enable cheat mode")));
|
||||
@@ -80,6 +80,9 @@ void GameStateOptions::Start()
|
||||
optionsList->Add(oGra);
|
||||
optionsTabs->Add(optionsList);
|
||||
|
||||
optionsList = NEW WGuiList("Key Bindings");
|
||||
optionsTabs->Add(optionsList);
|
||||
|
||||
optionsList = NEW WGuiList("Credits");
|
||||
optionsList->failMsg = "";
|
||||
optionsTabs->Add(optionsList);
|
||||
@@ -89,7 +92,7 @@ void GameStateOptions::Start()
|
||||
optionsMenu->Add(1, "Save & Back to Main Menu");
|
||||
optionsMenu->Add(3, "Cancel");
|
||||
|
||||
optionsTabs->Entering(0);
|
||||
optionsTabs->Entering(JGE_BTN_NONE);
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +105,7 @@ void GameStateOptions::End()
|
||||
|
||||
|
||||
void GameStateOptions::Update(float dt)
|
||||
{
|
||||
{
|
||||
timer += dt * 10;
|
||||
|
||||
if(options.keypadActive()){
|
||||
@@ -121,23 +124,23 @@ void GameStateOptions::Update(float dt)
|
||||
else switch(mState){
|
||||
default:
|
||||
case SHOW_OPTIONS:
|
||||
u32 key;
|
||||
JButton key;
|
||||
|
||||
while ((key = JGE::GetInstance()->ReadButton())){
|
||||
if(!optionsTabs->CheckUserInput(key) && key == PSP_CTRL_START)
|
||||
if(!optionsTabs->CheckUserInput(key) && key == JGE_BTN_MENU)
|
||||
mState = SHOW_OPTIONS_MENU;
|
||||
}
|
||||
optionsTabs->Update(dt);
|
||||
break;
|
||||
case SHOW_OPTIONS_MENU:
|
||||
optionsMenu->Update(dt);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(mReload){
|
||||
options.reloadProfile(true);
|
||||
Translator::EndInstance();
|
||||
Translator::GetInstance()->init();
|
||||
optionsTabs->Reload();
|
||||
optionsTabs->Reload();
|
||||
mReload = false;
|
||||
}
|
||||
}
|
||||
@@ -157,7 +160,7 @@ void GameStateOptions::Render()
|
||||
"Art: Ilya B, Julio, Jeck, J, Lakeesha",
|
||||
"Check themeinfo.txt for the full credits of each theme!",
|
||||
"",
|
||||
"Dev Team: Abrasax, Daddy32, Dr.Solomat, J, Jeck",
|
||||
"Dev Team: Abrasax, Daddy32, Dr.Solomat, J, Jeck",
|
||||
"Leungclj, Superhiro, Psyringe, Wololo, Yeshua",
|
||||
"",
|
||||
"Music by Celestial Aeon Project, http://www.jamendo.com",
|
||||
@@ -189,7 +192,7 @@ void GameStateOptions::Render()
|
||||
float startpos = 272 - timer;
|
||||
float pos = startpos;
|
||||
int size = sizeof(CreditsText) / sizeof(CreditsText[0]);
|
||||
|
||||
|
||||
for (int i = 0; i < size; i++){
|
||||
pos = startpos + 20 * i;
|
||||
if (pos > -20 && pos < SCREEN_HEIGHT + 20){
|
||||
@@ -197,13 +200,13 @@ void GameStateOptions::Render()
|
||||
}
|
||||
}
|
||||
|
||||
if (pos < -20)
|
||||
if (pos < -20)
|
||||
timer = 0;
|
||||
|
||||
|
||||
optionsTabs->Render();
|
||||
|
||||
if(mState == SHOW_OPTIONS_MENU)
|
||||
if(mState == SHOW_OPTIONS_MENU)
|
||||
optionsMenu->Render();
|
||||
|
||||
if(options.keypadActive())
|
||||
|
||||
@@ -71,7 +71,7 @@ void GameStateShop::Start(){
|
||||
srcCards->setElapsed(15);
|
||||
|
||||
bigSync = 0;
|
||||
shopMenu = NEW WGuiMenu(PSP_CTRL_DOWN,PSP_CTRL_UP,true,&bigSync);
|
||||
shopMenu = NEW WGuiMenu(JGE_BTN_DOWN, JGE_BTN_UP, true, &bigSync);
|
||||
MTGAllCards * ac = GameApp::collection;
|
||||
playerdata = NEW PlayerData(ac);;
|
||||
myCollection = NEW DeckDataWrapper(playerdata->collection);
|
||||
@@ -87,7 +87,7 @@ void GameStateShop::Start(){
|
||||
dist->xy = WDistort(_x1[i],_y1[i],_x2[i],_y2[i],_x3[i],_y3[i],_x4[i],_y4[i]);
|
||||
shopMenu->Add(NEW WGuiButton(dist,-102,i,this));
|
||||
}
|
||||
shopMenu->Entering(0);
|
||||
shopMenu->Entering(JGE_BTN_NONE);
|
||||
|
||||
if(!bigDisplay){
|
||||
bigDisplay = NEW WGuiCardImage(srcCards);
|
||||
@@ -337,11 +337,11 @@ void GameStateShop::beginFilters(){
|
||||
filterMenu->setHeight(SCREEN_HEIGHT-2);
|
||||
}
|
||||
mStage = STAGE_ASK_ABOUT;
|
||||
filterMenu->Entering(0);
|
||||
filterMenu->Entering(JGE_BTN_NONE);
|
||||
}
|
||||
void GameStateShop::Update(float dt)
|
||||
{
|
||||
if(menu && menu->closed)
|
||||
{
|
||||
if (menu && menu->closed)
|
||||
SAFE_DELETE(menu);
|
||||
srcCards->Update(dt);
|
||||
alphaChange = (500 - (rand() % 1000)) * dt;
|
||||
@@ -350,10 +350,10 @@ void GameStateShop::Update(float dt)
|
||||
if (lightAlpha > 50) lightAlpha = 50;
|
||||
// mParent->effect->UpdateSmall(dt);
|
||||
// mParent->effect->UpdateBig(dt);
|
||||
if(mStage != STAGE_FADE_IN)
|
||||
if (mStage != STAGE_FADE_IN)
|
||||
mElapsed += dt;
|
||||
|
||||
u32 btn;
|
||||
JButton btn;
|
||||
switch(mStage){
|
||||
case STAGE_SHOP_PURCHASE:
|
||||
if (menu)
|
||||
@@ -362,32 +362,32 @@ void GameStateShop::Update(float dt)
|
||||
mStage = STAGE_SHOP_SHOP;
|
||||
break;
|
||||
case STAGE_SHOP_MENU:
|
||||
if (menu){
|
||||
if (menu)
|
||||
menu->Update(dt);
|
||||
}else{
|
||||
else{
|
||||
menu = NEW SimpleMenu(11,this,Constants::MENU_FONT,SCREEN_WIDTH/2-100,20);
|
||||
menu->Add(22,"Ask about...");
|
||||
menu->Add(14,"Check task board");
|
||||
if(options[Options::CHEATMODE].number)
|
||||
if (options[Options::CHEATMODE].number)
|
||||
menu->Add(-2,"Steal 1,000 credits");
|
||||
menu->Add(12,"Save & Back to Main Menu");
|
||||
menu->Add(13, "Cancel");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case STAGE_SHOP_TASKS:
|
||||
if(menu){
|
||||
case STAGE_SHOP_TASKS:
|
||||
if (menu){
|
||||
menu->Update(dt);
|
||||
return;
|
||||
}
|
||||
if(taskList){
|
||||
if (taskList){
|
||||
btn = mEngine->ReadButton();
|
||||
taskList->Update(dt);
|
||||
if ( taskList->getState() != TaskList::TASKS_INACTIVE){
|
||||
if( btn == PSP_CTRL_CROSS || btn == PSP_CTRL_TRIANGLE ){
|
||||
if ( btn == JGE_BTN_SEC || btn == JGE_BTN_CANCEL ){
|
||||
taskList->End();
|
||||
return;
|
||||
}else if(taskList->getState() == TaskList::TASKS_ACTIVE && btn == PSP_CTRL_START ){
|
||||
if(!menu){
|
||||
} else if (taskList->getState() == TaskList::TASKS_ACTIVE && btn == JGE_BTN_MENU){
|
||||
if (!menu) {
|
||||
menu = NEW SimpleMenu(11,this,Constants::MENU_FONT,SCREEN_WIDTH/2-100,20);
|
||||
menu->Add(15,"Return to shop");
|
||||
menu->Add(12,"Save & Back to Main Menu");
|
||||
@@ -400,7 +400,7 @@ void GameStateShop::Update(float dt)
|
||||
}
|
||||
|
||||
#ifdef TESTSUITE
|
||||
if ((mEngine->GetButtonClick(PSP_CTRL_SQUARE)) && (taskList)) {
|
||||
if ((mEngine->GetButtonClick(JGE_BTN_PRI)) && (taskList)) {
|
||||
taskList->passOneDay();
|
||||
if (taskList->getTaskCount() < 6) {
|
||||
taskList->addRandomTask();
|
||||
@@ -412,19 +412,19 @@ void GameStateShop::Update(float dt)
|
||||
break;
|
||||
case STAGE_ASK_ABOUT:
|
||||
btn = mEngine->ReadButton();
|
||||
if(menu && !menu->closed){
|
||||
if (menu && !menu->closed){
|
||||
menu->CheckUserInput(btn);
|
||||
menu->Update(dt);
|
||||
return;
|
||||
}
|
||||
if(filterMenu){
|
||||
if(btn == PSP_CTRL_SELECT){
|
||||
if (filterMenu){
|
||||
if (btn == JGE_BTN_CTRL) {
|
||||
needLoad = filterMenu->Finish();
|
||||
filterMenu->Update(dt);
|
||||
return;
|
||||
}
|
||||
if(filterMenu->isFinished()){
|
||||
if(needLoad)
|
||||
if (filterMenu->isFinished()){
|
||||
if (needLoad)
|
||||
load();
|
||||
mStage = STAGE_SHOP_SHOP;
|
||||
}else{
|
||||
@@ -436,42 +436,41 @@ void GameStateShop::Update(float dt)
|
||||
break;
|
||||
case STAGE_SHOP_SHOP:
|
||||
btn = mEngine->ReadButton();
|
||||
if(menu && !menu->closed){
|
||||
if (menu && !menu->closed){
|
||||
menu->CheckUserInput(btn);
|
||||
menu->Update(dt);
|
||||
return;
|
||||
}
|
||||
if (btn == PSP_CTRL_START){
|
||||
if(boosterDisplay){
|
||||
if (btn == JGE_BTN_MENU){
|
||||
if (boosterDisplay){
|
||||
deleteDisplay();
|
||||
return;
|
||||
}
|
||||
mStage = STAGE_SHOP_MENU;
|
||||
return;
|
||||
}else if(btn == PSP_CTRL_SELECT){
|
||||
} else if (btn == JGE_BTN_CTRL)
|
||||
beginFilters();
|
||||
}else if(btn == PSP_CTRL_SQUARE){
|
||||
else if (btn == JGE_BTN_PRI) {
|
||||
srcCards->Shuffle();
|
||||
load();
|
||||
}else if(btn == PSP_CTRL_TRIANGLE){
|
||||
load();
|
||||
} else if (btn == JGE_BTN_CANCEL)
|
||||
options[Options::DISABLECARDS].number = !options[Options::DISABLECARDS].number;
|
||||
}else if (boosterDisplay){
|
||||
if(btn == PSP_CTRL_CROSS)
|
||||
else if (boosterDisplay){
|
||||
if (btn == JGE_BTN_SEC)
|
||||
deleteDisplay();
|
||||
else {
|
||||
boosterDisplay->CheckUserInput(btn);
|
||||
boosterDisplay->Update(dt);}
|
||||
boosterDisplay->CheckUserInput(btn);
|
||||
boosterDisplay->Update(dt);}
|
||||
return;
|
||||
}else if(btn == PSP_CTRL_CROSS){
|
||||
bListCards = !bListCards;
|
||||
}else if(shopMenu){
|
||||
if(shopMenu->CheckUserInput(btn))
|
||||
}else if (btn == JGE_BTN_SEC)
|
||||
bListCards = !bListCards;
|
||||
else if (shopMenu){
|
||||
if (shopMenu->CheckUserInput(btn))
|
||||
srcCards->Touch();
|
||||
}
|
||||
|
||||
if(shopMenu)
|
||||
if (shopMenu)
|
||||
shopMenu->Update(dt);
|
||||
|
||||
|
||||
break;
|
||||
case STAGE_FADE_IN:
|
||||
mParent->DoAnimation(TRANSITION_FADE_IN);
|
||||
@@ -486,7 +485,7 @@ void GameStateShop::makeDisplay(MTGDeck * d){
|
||||
void GameStateShop::deleteDisplay(){
|
||||
vector<MTGCardInstance*>::iterator i;
|
||||
for(i=subBooster.begin();i!=subBooster.end();i++){
|
||||
if(!*i) continue;
|
||||
if (!*i) continue;
|
||||
delete *i;
|
||||
}
|
||||
subBooster.clear();
|
||||
@@ -749,4 +748,4 @@ void ShopBooster::addToDeck(MTGDeck * d, WSrcCards * srcCards){
|
||||
carryover = pool->addToDeck(d,carryover+11);
|
||||
SAFE_DELETE(pool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ bool GuiCombat::CheckUserInput(u32 key)
|
||||
DamagerDamaged* oldActive = active;
|
||||
switch (key)
|
||||
{
|
||||
case PSP_CTRL_CIRCLE:
|
||||
case JGE_BTN_OK:
|
||||
if (BLK == cursor_pos)
|
||||
{
|
||||
if (ORDER == step) go->cardClick(active->card); // { activeAtk->card->raiseBlockerRankOrder(active->card); }
|
||||
@@ -173,7 +173,7 @@ bool GuiCombat::CheckUserInput(u32 key)
|
||||
clickOK();
|
||||
}
|
||||
break;
|
||||
case PSP_CTRL_TRIANGLE:
|
||||
case JGE_BTN_CANCEL:
|
||||
if (BLK == cursor_pos)
|
||||
{
|
||||
oldActive->zoom = 2.2;
|
||||
@@ -181,7 +181,7 @@ bool GuiCombat::CheckUserInput(u32 key)
|
||||
cursor_pos = ATK;
|
||||
}
|
||||
return true;
|
||||
case PSP_CTRL_LEFT:
|
||||
case JGE_BTN_LEFT:
|
||||
switch (cursor_pos)
|
||||
{
|
||||
case NONE : break;
|
||||
@@ -206,7 +206,7 @@ bool GuiCombat::CheckUserInput(u32 key)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PSP_CTRL_RIGHT:
|
||||
case JGE_BTN_RIGHT:
|
||||
switch (cursor_pos)
|
||||
{
|
||||
case NONE :
|
||||
@@ -232,22 +232,22 @@ bool GuiCombat::CheckUserInput(u32 key)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PSP_CTRL_DOWN:
|
||||
case JGE_BTN_DOWN:
|
||||
if (ORDER == step || BLK != cursor_pos || active->sumDamages() <= 0) break;
|
||||
removeOne(active, step);
|
||||
break;
|
||||
case PSP_CTRL_UP:
|
||||
case JGE_BTN_UP:
|
||||
if (ORDER == step || BLK != cursor_pos) break;
|
||||
addOne(active, step);
|
||||
break;
|
||||
case PSP_CTRL_SQUARE:
|
||||
case JGE_BTN_PRI:
|
||||
active = activeAtk = NULL; cursor_pos = OK;
|
||||
break;
|
||||
case PSP_CTRL_RTRIGGER:
|
||||
case JGE_BTN_NEXT:
|
||||
if (!options[Options::REVERSETRIGGERS].number) return false;
|
||||
active = activeAtk = NULL; cursor_pos = OK;
|
||||
break;
|
||||
case PSP_CTRL_LTRIGGER:
|
||||
case JGE_BTN_PREV:
|
||||
if (options[Options::REVERSETRIGGERS].number) return false;
|
||||
active = activeAtk = NULL; cursor_pos = OK;
|
||||
break;
|
||||
|
||||
@@ -139,7 +139,7 @@ void GuiHandSelf::Repos()
|
||||
|
||||
bool GuiHandSelf::CheckUserInput(u32 key)
|
||||
{
|
||||
u32 trigger = (options[Options::REVERSETRIGGERS].number ? PSP_CTRL_LTRIGGER : PSP_CTRL_RTRIGGER);
|
||||
u32 trigger = (options[Options::REVERSETRIGGERS].number ? JGE_BTN_PREV : JGE_BTN_NEXT);
|
||||
if (trigger == key)
|
||||
{
|
||||
state = (Open == state ? Closed : Open);
|
||||
|
||||
@@ -7,7 +7,7 @@ GuiLayer::GuiLayer(){
|
||||
hasFocus = false;
|
||||
mCount = 0;
|
||||
mCurr = 0;
|
||||
mActionButton = PSP_CTRL_CIRCLE;
|
||||
mActionButton = JGE_BTN_OK;
|
||||
}
|
||||
|
||||
GuiLayer::~GuiLayer(){
|
||||
@@ -20,16 +20,15 @@ void GuiLayer::Add(JGuiObject *object){
|
||||
}
|
||||
|
||||
int GuiLayer::Remove(JGuiObject *object){
|
||||
for (int i=0;i<mCount;i++){
|
||||
for (int i=0;i<mCount;i++)
|
||||
if (mObjects[i]==object){
|
||||
delete mObjects[i];
|
||||
mObjects.erase(mObjects.begin()+i);
|
||||
mCount--;
|
||||
if (mCurr == mCount)
|
||||
mCurr = 0;
|
||||
mCurr = 0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ void MTGGamePhase::Update(float dt){
|
||||
bool MTGGamePhase::CheckUserInput(u32 key){
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
if (activeState == INACTIVE){
|
||||
u32 trigger = (options[Options::REVERSETRIGGERS].number ? PSP_CTRL_RTRIGGER : PSP_CTRL_LTRIGGER);
|
||||
u32 trigger = (options[Options::REVERSETRIGGERS].number ? JGE_BTN_NEXT : JGE_BTN_PREV);
|
||||
if ((trigger == key) && game->currentActionPlayer == game->currentlyActing())
|
||||
{
|
||||
activeState = ACTIVE;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "../include/WFilter.h"
|
||||
#include "../include/DeckDataWrapper.h"
|
||||
#include "../include/MTGPack.h"
|
||||
#include "../../../JGE/src/TinyXML/tinyxml.h"
|
||||
#include "../../../JGE/src/tinyxml/tinyxml.h"
|
||||
|
||||
int MTGPackEntryRandom::addCard(WSrcCards *pool, MTGDeck *to){
|
||||
int fails = 0;
|
||||
@@ -270,4 +270,4 @@ void MTGPacks::refreshUnlocked(){
|
||||
if(packs[t]->unlockStatus < 0)
|
||||
packs[t]->unlockStatus = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ int MTGAttackRule::reactToClick(MTGCardInstance * card){
|
||||
if(!card->isAttacker()){
|
||||
CardSelector * cs = game->mLayers->cs;
|
||||
cs->Limit(this,CardSelector::playZone);
|
||||
cs->CheckUserInput(PSP_CTRL_RIGHT);
|
||||
cs->CheckUserInput(JGE_BTN_RIGHT);
|
||||
cs->Limit(NULL,CardSelector::playZone);
|
||||
}
|
||||
card->toggleAttacker();
|
||||
|
||||
@@ -61,7 +61,7 @@ void OptionSelect::initSelections(){
|
||||
}
|
||||
}
|
||||
|
||||
void OptionSelect::Entering(u32 key){
|
||||
void OptionSelect::Entering(JButton key){
|
||||
OptionItem::Entering(key);
|
||||
prior_value = value;
|
||||
}
|
||||
@@ -187,7 +187,7 @@ void OptionProfile::Render(){
|
||||
mFont->SetScale(1);
|
||||
|
||||
}
|
||||
void OptionProfile::Entering(u32 key){
|
||||
void OptionProfile::Entering(JButton key){
|
||||
mFocus = true;
|
||||
initialValue = value;
|
||||
}
|
||||
@@ -427,4 +427,4 @@ void OptionTheme::confirmChange(bool confirmed){
|
||||
resources.Refresh(); //Update images
|
||||
prior_value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
553
projects/mtg/src/ShopItem.cpp
Normal file
553
projects/mtg/src/ShopItem.cpp
Normal file
@@ -0,0 +1,553 @@
|
||||
#include "../include/config.h"
|
||||
#include "../include/ShopItem.h"
|
||||
#include "../include/GameStateShop.h"
|
||||
#include "../include/CardGui.h"
|
||||
#include "../include/WResourceManager.h"
|
||||
#include "../include/Translate.h"
|
||||
#include <hge/hgedistort.h>
|
||||
|
||||
|
||||
|
||||
float ShopItems::_x1[] = { 79, 19, 27,103,154,187,102,144,198,133,183};
|
||||
float ShopItems::_y1[] = {150,194,222,167,164,156,195,190,175,220,220};
|
||||
|
||||
float ShopItems::_x2[] = {103, 48, 74,135,183,215,138,181,231,171,225};
|
||||
float ShopItems::_y2[] = {155,179,218,165,166,155,195,186,177,225,216};
|
||||
|
||||
float ShopItems::_x3[] = { 48, 61, 9, 96,139,190, 81,146,187, 97,191};
|
||||
float ShopItems::_y3[] = {164,205,257,184,180,170,219,212,195,251,252};
|
||||
|
||||
float ShopItems::_x4[] = { 76, 90, 65,131,171,221,123,187,225,141,237};
|
||||
float ShopItems::_y4[] = {169,188,250,182,182,168,220,208,198,259,245};
|
||||
|
||||
|
||||
ShopItem::ShopItem(int id, JLBFont *font, char* text, JQuad * _quad,JQuad * _thumb, float _xy[], bool hasFocus, int _price): JGuiObject(id), mFont(font), mText(text), quad(_quad), thumb(_thumb), price(_price)
|
||||
{
|
||||
for (int i = 0; i < 8; ++i){
|
||||
xy[i] = _xy[i];
|
||||
}
|
||||
quantity = 10;
|
||||
card = NULL;
|
||||
mHasFocus = hasFocus;
|
||||
mRelease = false;
|
||||
|
||||
mScale = 1.0f;
|
||||
mTargetScale = 1.0f;
|
||||
|
||||
mesh=NEW hgeDistortionMesh(2,2);
|
||||
mesh->SetTexture(thumb->mTex);
|
||||
float x0,y0,w0,h0;
|
||||
thumb->GetTextureRect(&x0,&y0,&w0,&h0);
|
||||
mesh->SetTextureRect(x0,y0,w0,h0);
|
||||
mesh->Clear(ARGB(0xFF,0xFF,0xFF,0xFF));
|
||||
mesh->SetDisplacement(0, 0, xy[0],xy[1], HGEDISP_NODE);
|
||||
mesh->SetDisplacement(1, 0, xy[2] - w0,xy[3], HGEDISP_NODE);
|
||||
mesh->SetDisplacement(0, 1,xy[4],xy[5]-h0, HGEDISP_NODE);
|
||||
mesh->SetDisplacement(1, 1, xy[6]-w0,xy[7]-h0, HGEDISP_NODE);
|
||||
mesh->SetColor(1,1,ARGB(255,100,100,100));
|
||||
mesh->SetColor(0,1,ARGB(255,100,100,100));
|
||||
mesh->SetColor(1,0,ARGB(255,100,100,100));
|
||||
mesh->SetColor(0,0,ARGB(255,200,200,200));
|
||||
if (hasFocus)
|
||||
Entering();
|
||||
}
|
||||
|
||||
ShopItem::ShopItem(int id, JLBFont *font, int _cardid, float _xy[], bool hasFocus, MTGAllCards * collection, int _price, DeckDataWrapper * ddw): JGuiObject(id), mFont(font), price(_price){
|
||||
for (int i = 0; i < 8; ++i){
|
||||
xy[i] = _xy[i];
|
||||
}
|
||||
mHasFocus = hasFocus;
|
||||
mRelease = false;
|
||||
mScale = 1.0f;
|
||||
mTargetScale = 1.0f;
|
||||
|
||||
if (hasFocus)
|
||||
Entering();
|
||||
|
||||
card = collection->getCardById(_cardid);
|
||||
updateCount(ddw);
|
||||
|
||||
quantity = 1 + (rand() % 4);
|
||||
if (card->getRarity() == Constants::RARITY_L) quantity = 50;
|
||||
quad = NULL;
|
||||
|
||||
mesh = NULL;
|
||||
thumb = NULL;
|
||||
updateThumb();
|
||||
}
|
||||
|
||||
|
||||
int ShopItem::updateCount(DeckDataWrapper * ddw){
|
||||
if (!card) return 0;
|
||||
nameCount = ddw->countByName(card);
|
||||
return nameCount;
|
||||
}
|
||||
|
||||
ShopItem::~ShopItem(){
|
||||
OutputDebugString("delete shopitem\n");
|
||||
if(thumb)
|
||||
resources.Release(thumb->mTex);
|
||||
SAFE_DELETE(mesh);
|
||||
}
|
||||
|
||||
const char * ShopItem::getText(){
|
||||
return mText.c_str();
|
||||
}
|
||||
|
||||
void ShopItem::updateThumb(){
|
||||
if(card == NULL)
|
||||
return;
|
||||
|
||||
if(thumb && mRelease)
|
||||
resources.Release(thumb->mTex);
|
||||
mRelease = false;
|
||||
|
||||
if(mesh)
|
||||
SAFE_DELETE(mesh);
|
||||
else if(thumb)
|
||||
SAFE_DELETE(thumb);
|
||||
|
||||
thumb = resources.RetrieveCard(card,RETRIEVE_LOCK,TEXTURE_SUB_THUMB);
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
//On pcs we render the big image if the thumbnail is not available
|
||||
if (!thumb) thumb = resources.RetrieveCard(card,RETRIEVE_LOCK);
|
||||
#endif
|
||||
if (!thumb)
|
||||
thumb = CardGui::alternateThumbQuad(card);
|
||||
else
|
||||
mRelease = true;
|
||||
|
||||
|
||||
if (thumb){
|
||||
mesh=NEW hgeDistortionMesh(2,2);
|
||||
mesh->SetTexture(thumb->mTex);
|
||||
float x0,y0,w0,h0;
|
||||
thumb->GetTextureRect(&x0,&y0,&w0,&h0);
|
||||
mesh->SetTextureRect(x0,y0,w0,h0);
|
||||
mesh->Clear(ARGB(0xFF,0xFF,0xFF,0xFF));
|
||||
mesh->SetDisplacement(0, 0, xy[0],xy[1], HGEDISP_NODE);
|
||||
mesh->SetDisplacement(1, 0, xy[2] - w0,xy[3], HGEDISP_NODE);
|
||||
mesh->SetDisplacement(0, 1,xy[4],xy[5]-h0, HGEDISP_NODE);
|
||||
mesh->SetDisplacement(1, 1, xy[6]-w0,xy[7]-h0, HGEDISP_NODE);
|
||||
mesh->SetColor(1,1,ARGB(255,100,100,100));
|
||||
mesh->SetColor(0,1,ARGB(255,100,100,100));
|
||||
mesh->SetColor(1,0,ARGB(255,100,100,100));
|
||||
mesh->SetColor(0,0,ARGB(255,200,200,200));
|
||||
}else{
|
||||
mesh = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ShopItem::Render(){
|
||||
if (mHasFocus){
|
||||
mFont->SetColor(ARGB(255,255,255,0));
|
||||
}else{
|
||||
mFont->SetColor(ARGB(255,255,255,255));
|
||||
}
|
||||
if (!quantity){
|
||||
mFont->SetColor(ARGB(255,128,128,128));
|
||||
}
|
||||
|
||||
if (card){
|
||||
if (nameCount){
|
||||
char buffer[512];
|
||||
sprintf(buffer, "%s (%i)", _(card->data->name).c_str(), nameCount );
|
||||
mText = buffer;
|
||||
}else{
|
||||
mText = _(card->data->name).c_str();
|
||||
}
|
||||
}
|
||||
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
|
||||
if (mesh){
|
||||
mesh->Render(0,0);
|
||||
}else{
|
||||
//ERROR Management
|
||||
}
|
||||
if (mHasFocus){
|
||||
if (card) quad = resources.RetrieveCard(card);
|
||||
if (quad){
|
||||
float scale = 0.9 * 285/ quad->mHeight;
|
||||
quad->SetColor(ARGB(255,255,255,255));
|
||||
renderer->RenderQuad(quad,SCREEN_WIDTH - 105,SCREEN_HEIGHT/2 - 5,0, scale,scale);
|
||||
}else{
|
||||
if (card) CardGui::alternateRender(card,Pos(SCREEN_WIDTH - 105,SCREEN_HEIGHT/2 - 5,0.9f* 285/250, 0,255));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShopItem::Update(float dt)
|
||||
{
|
||||
if (mScale < mTargetScale){
|
||||
mScale += 8.0f*dt;
|
||||
if (mScale > mTargetScale)
|
||||
mScale = mTargetScale;
|
||||
}else if (mScale > mTargetScale){
|
||||
mScale -= 8.0f*dt;
|
||||
if (mScale < mTargetScale)
|
||||
mScale = mTargetScale;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ShopItem::Entering()
|
||||
{
|
||||
for (int i = 0; i < 2; ++i){
|
||||
for (int j = 0; j < 2; ++j){
|
||||
mesh->SetColor(i,j,ARGB(255,255,255,255));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mHasFocus = true;
|
||||
mTargetScale = 1.2f;
|
||||
}
|
||||
|
||||
|
||||
bool ShopItem::Leaving(JButton key)
|
||||
{
|
||||
mesh->SetColor(1,1,ARGB(255,100,100,100));
|
||||
mesh->SetColor(0,1,ARGB(255,100,100,100));
|
||||
mesh->SetColor(1,0,ARGB(255,100,100,100));
|
||||
mesh->SetColor(0,0,ARGB(255,200,200,200));
|
||||
|
||||
mHasFocus = false;
|
||||
mTargetScale = 1.0f;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ShopItem::ButtonPressed()
|
||||
{
|
||||
return (quantity >0);
|
||||
}
|
||||
|
||||
|
||||
ShopItems::ShopItems(int id, JGuiListener* listener, JLBFont* font, int x, int y, MTGAllCards * _collection, int _setIds[]): JGuiController(id, listener), mX(x), mY(y), mFont(font), collection(_collection){
|
||||
mHeight = 0;
|
||||
showPriceDialog = -1;
|
||||
dialog = NULL;
|
||||
pricelist = NEW PriceList(RESPATH"/settings/prices.dat",_collection);
|
||||
playerdata = NEW PlayerData(_collection);
|
||||
display = NULL;
|
||||
for (int i=0; i < SHOP_BOOSTERS; i++){
|
||||
setIds[i] = _setIds[i];
|
||||
};
|
||||
myCollection = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), _collection));
|
||||
showCardList = true;
|
||||
|
||||
mBgAA = NULL;
|
||||
mBgAATex = resources.RetrieveTexture("shop_aliasing.png",RETRIEVE_LOCK);
|
||||
if(mBgAATex){
|
||||
mBgAA = resources.RetrieveQuad("shop_aliasing.png");
|
||||
mBgAA->SetTextureRect(0,1,250,119);
|
||||
}
|
||||
|
||||
lightAlpha = 0;
|
||||
alphaChange = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ShopItems::Add(int cardid){
|
||||
int rnd = (rand() % 20);
|
||||
int price = pricelist->getPrice(cardid);
|
||||
price = price + price * (rnd -10)/100;
|
||||
float xy[] = {_x1[mCount],_y1[mCount],_x2[mCount],_y2[mCount],_x3[mCount],_y3[mCount],_x4[mCount],_y4[mCount]};
|
||||
JGuiController::Add(NEW ShopItem(mCount, mFont, cardid, xy, (mCount == 0),collection, price,myCollection));
|
||||
mHeight += 22;
|
||||
}
|
||||
|
||||
void ShopItems::Add(char * text, JQuad * quad,JQuad * thumb, int price){
|
||||
float xy[] = {_x1[mCount],_y1[mCount],_x2[mCount],_y2[mCount],_x3[mCount],_y3[mCount],_x4[mCount],_y4[mCount]};
|
||||
JGuiController::Add(NEW ShopItem(mCount, mFont, text, quad, thumb, xy, (mCount == 0), price));
|
||||
mHeight += 22;
|
||||
}
|
||||
|
||||
void ShopItems::Update(float dt){
|
||||
|
||||
if (display){
|
||||
display->Update(dt);
|
||||
}else{
|
||||
if (showPriceDialog!=-1){
|
||||
ShopItem * item = ((ShopItem *)mObjects[showPriceDialog]);
|
||||
int price = item->price;
|
||||
char buffer[4096];
|
||||
sprintf(buffer,"%s : %i credits",item->getText(),price);
|
||||
if(!dialog){
|
||||
dialog = NEW SimpleMenu(1,this,Constants::MENU_FONT,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buffer);
|
||||
dialog->Add(1,"Yes");
|
||||
dialog->Add(2,"No");
|
||||
if(options[Options::CHEATMODE].number) {
|
||||
dialog->Add(3,"*Steal 1,000 credits*");
|
||||
}
|
||||
}
|
||||
else{
|
||||
dialog->Update(dt);
|
||||
}
|
||||
}else{
|
||||
SAFE_DELETE(dialog);
|
||||
JGuiController::Update(dt);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
alphaChange = (500 - (rand() % 1000)) * dt;
|
||||
lightAlpha+= alphaChange;
|
||||
if (lightAlpha < 0) lightAlpha = 0;
|
||||
if (lightAlpha > 50) lightAlpha = 50;
|
||||
}
|
||||
|
||||
|
||||
void ShopItems::Render(){
|
||||
JGuiController::Render();
|
||||
JRenderer * r = JRenderer::GetInstance();
|
||||
|
||||
|
||||
if (mBgAA)
|
||||
r->RenderQuad(mBgAA,0,SCREEN_HEIGHT-127);
|
||||
|
||||
JQuad * quad = resources.RetrieveTempQuad("shop_light.jpg",TEXTURE_SUB_5551);
|
||||
if (quad){
|
||||
r->EnableTextureFilter(false);
|
||||
r->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE);
|
||||
quad->SetColor(ARGB(lightAlpha,255,255,255));
|
||||
r->RenderQuad(quad,0,0);
|
||||
r->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
|
||||
r->EnableTextureFilter(true);
|
||||
}
|
||||
|
||||
|
||||
if (display) display->Render();
|
||||
|
||||
if (showPriceDialog!=-1){
|
||||
if(dialog){
|
||||
dialog->Render();
|
||||
}
|
||||
}
|
||||
|
||||
mFont->SetColor(ARGB(255,255,255,255));
|
||||
char c[4096];
|
||||
r->FillRect(0,SCREEN_HEIGHT-17,SCREEN_WIDTH,17,ARGB(128,0,0,0));
|
||||
sprintf(c, "%s", _("[]:other cards").c_str());
|
||||
unsigned int len = 4 + mFont->GetStringWidth(c);
|
||||
mFont->DrawString(c,SCREEN_WIDTH-len,SCREEN_HEIGHT-14);
|
||||
|
||||
char credits[512];
|
||||
sprintf(credits,_("credits: %i").c_str(), playerdata->credits);
|
||||
mFont->SetColor(ARGB(200,0,0,0));
|
||||
mFont->DrawString(credits, 5, SCREEN_HEIGHT - 12);
|
||||
mFont->SetColor(ARGB(255,255,255,255));
|
||||
mFont->DrawString(credits, 5, SCREEN_HEIGHT - 14);
|
||||
|
||||
if(mCurr >= 0){
|
||||
mFont->SetColor(ARGB(255,255,255,0));
|
||||
ShopItem * item = ((ShopItem *)mObjects[mCurr]);
|
||||
mFont->DrawString(item->mText.c_str(), SCREEN_WIDTH/2 - 50, SCREEN_HEIGHT - 14,JGETEXT_CENTER);
|
||||
mFont->SetColor(ARGB(255,255,255,255));
|
||||
}
|
||||
|
||||
if (showCardList){
|
||||
r->FillRoundRect(290,5, 160, mCount * 20 + 15,5,ARGB(200,0,0,0));
|
||||
|
||||
for (int i = 0; i< mCount; ++i){
|
||||
if (!mObjects[i]) continue;
|
||||
ShopItem * s = (ShopItem *)(mObjects[i]);
|
||||
if (i == mCurr) mFont->SetColor(ARGB(255,255,255,0));
|
||||
else mFont->SetColor(ARGB(255,255,255,255));
|
||||
char buffer[512];
|
||||
sprintf(buffer, "%s", s->getText());
|
||||
float x = 300;
|
||||
float y = 10 + 20*i;
|
||||
mFont->DrawString(buffer,x,y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShopItems::pricedialog(int id, int mode){
|
||||
if (mode){
|
||||
showPriceDialog = id;
|
||||
}else{
|
||||
showPriceDialog = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void ShopItems::ButtonPressed(int controllerId, int controlId){
|
||||
if (controllerId == 12){
|
||||
safeDeleteDisplay();
|
||||
return;
|
||||
}
|
||||
|
||||
ShopItem * item = ((ShopItem *)mObjects[showPriceDialog]);
|
||||
int price = item->price;
|
||||
switch(controlId){
|
||||
case 1:
|
||||
if (playerdata->credits >= price){
|
||||
playerdata->credits -= price;
|
||||
if (item->card){
|
||||
int rnd = (rand() % 25);
|
||||
price = price + (rnd * price)/100;
|
||||
pricelist->setPrice(item->card->getMTGId(),price);
|
||||
playerdata->collection->add(item->card);
|
||||
item->quantity--;
|
||||
myCollection->Add(item->card);
|
||||
item->nameCount++;
|
||||
item->price = price;
|
||||
}else{
|
||||
safeDeleteDisplay();
|
||||
display = NEW CardDisplay(12,NULL, SCREEN_WIDTH - 200, SCREEN_HEIGHT/2,this,NULL,5);
|
||||
|
||||
MTGDeck * tempDeck = NEW MTGDeck(playerdata->collection->database);
|
||||
int rare_or_mythic = Constants::RARITY_R;
|
||||
int rnd = rand() % 8;
|
||||
if (rnd == 0) rare_or_mythic = Constants::RARITY_M;
|
||||
int sets[] = {setIds[showPriceDialog]};
|
||||
MTGSetInfo* si = setlist.getInfo(setIds[showPriceDialog]);
|
||||
|
||||
tempDeck->addRandomCards(si->booster[MTGSetInfo::RARE], sets,1,rare_or_mythic);
|
||||
tempDeck->addRandomCards(si->booster[MTGSetInfo::UNCOMMON], sets,1,Constants::RARITY_U);
|
||||
tempDeck->addRandomCards(si->booster[MTGSetInfo::COMMON], sets,1,Constants::RARITY_C);
|
||||
tempDeck->addRandomCards(si->booster[MTGSetInfo::LAND], sets,1,Constants::RARITY_L);
|
||||
|
||||
//Check for duplicates. Does not guarentee none, just makes them extremely unlikely.
|
||||
//Code is kind of inefficient, but shouldn't be used often enough to matter.
|
||||
int loops=0;
|
||||
for(map<int,int>::iterator it = tempDeck->cards.begin();it!= tempDeck->cards.end() && loops < 15;it++,loops++){
|
||||
int dupes = it->second - 1;
|
||||
if(dupes <= 0)
|
||||
continue;
|
||||
|
||||
for(int x=0;x<dupes;x++)
|
||||
tempDeck->remove(it->first);
|
||||
|
||||
int rarity = (int) tempDeck->database->getCardById(it->first)->getRarity();
|
||||
tempDeck->addRandomCards(dupes,sets,1,rarity);
|
||||
it = tempDeck->cards.begin();
|
||||
}
|
||||
|
||||
playerdata->collection->add(tempDeck);
|
||||
myCollection->Add(tempDeck);
|
||||
|
||||
for (int j = 0; j < mCount; j++){
|
||||
ShopItem * si = ((ShopItem *)mObjects[j]);
|
||||
si->updateCount(myCollection);
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for(int cycle=0;cycle<4;cycle++)
|
||||
for (map<int,int>::iterator it = tempDeck->cards.begin(); it!=tempDeck->cards.end(); it++){
|
||||
MTGCard * c = tempDeck->getCardById(it->first);
|
||||
char rarity = c->getRarity();
|
||||
if((cycle == 0 && rarity == Constants::RARITY_L)
|
||||
|| (cycle == 1 && rarity == Constants::RARITY_C)
|
||||
|| (cycle == 2 && rarity == Constants::RARITY_U)
|
||||
|| (cycle == 3 && (rarity == Constants::RARITY_R || rarity == Constants::RARITY_M)))
|
||||
for (int j = 0; j < it->second; j++){
|
||||
MTGCardInstance * card = NEW MTGCardInstance(c, NULL);
|
||||
displayCards[i] = card;
|
||||
display->AddCard(card);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
delete tempDeck;
|
||||
}
|
||||
//Check if we just scored an award...
|
||||
if(myCollection && myCollection->totalPrice() > 10000){
|
||||
GameOptionAward * goa = dynamic_cast<GameOptionAward *>(&options[Options::AWARD_COLLECTOR]);
|
||||
if(goa)
|
||||
goa->giveAward();
|
||||
}
|
||||
showPriceDialog = -1;
|
||||
}else{
|
||||
//error not enough money
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (item->card){
|
||||
int rnd = (rand() % 25);
|
||||
price = price - (rnd * price)/100;
|
||||
pricelist->setPrice(item->card->getMTGId(),price);
|
||||
}
|
||||
showPriceDialog = -1;
|
||||
break;
|
||||
case 3: // (PSY) Cheatmode: get free money
|
||||
playerdata->credits += 1000;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ShopItems::safeDeleteDisplay(){
|
||||
if (!display) return;
|
||||
for (int i = 0; i < display->mCount; i++){
|
||||
delete displayCards[i];
|
||||
}
|
||||
SAFE_DELETE(display);
|
||||
}
|
||||
|
||||
void ShopItems::saveAll(){
|
||||
savePriceList();
|
||||
playerdata->save();
|
||||
}
|
||||
|
||||
void ShopItems::savePriceList(){
|
||||
pricelist->save();
|
||||
}
|
||||
|
||||
ShopItems::~ShopItems(){
|
||||
SAFE_DELETE(pricelist);
|
||||
SAFE_DELETE(playerdata);
|
||||
SAFE_DELETE(dialog);
|
||||
safeDeleteDisplay();
|
||||
SAFE_DELETE(myCollection);
|
||||
resources.Release(mBgAATex);
|
||||
}
|
||||
|
||||
ostream& ShopItem::toString(ostream& out) const
|
||||
{
|
||||
return out << "ShopItem ::: mHasFocus : " << mHasFocus
|
||||
<< " ; mFont : " << mFont
|
||||
<< " ; mText : " << mText
|
||||
<< " ; quad : " << quad
|
||||
<< " ; thumb : " << thumb
|
||||
<< " ; mScale : " << mScale
|
||||
<< " ; mTargetScale : " << mTargetScale
|
||||
<< " ; nameCount : " << nameCount
|
||||
<< " ; quantity : " << quantity
|
||||
<< " ; card : " << card
|
||||
<< " ; price : " << price;
|
||||
}
|
||||
|
||||
bool ShopItems::CheckUserInput(JButton key){
|
||||
if (display && display->CheckUserInput(key))
|
||||
return true;
|
||||
if (showPriceDialog == -1) {
|
||||
JButton buttons[] = {JGE_BTN_LEFT, JGE_BTN_DOWN, JGE_BTN_RIGHT, JGE_BTN_UP, JGE_BTN_OK};
|
||||
for (int i = 0; i < 5; ++i)
|
||||
if (key == buttons[i])
|
||||
showCardList = false;
|
||||
|
||||
if (key == JGE_BTN_CANCEL) {
|
||||
options[Options::DISABLECARDS].number = !options[Options::DISABLECARDS].number;
|
||||
vector<JGuiObject*>::iterator it;
|
||||
for(it=mObjects.begin();it!=mObjects.end();it++){
|
||||
ShopItem * si = dynamic_cast<ShopItem*>(*it);
|
||||
if(si)
|
||||
si->updateThumb();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (key == JGE_BTN_SEC){
|
||||
showCardList = !showCardList;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(dialog)
|
||||
return dialog->CheckUserInput(key);
|
||||
|
||||
return JGuiController::CheckUserInput(key);
|
||||
}
|
||||
@@ -168,7 +168,7 @@ void SimpleMenu::Add(int id, const char * text,string desc, bool forceFocus){
|
||||
JGuiController::Add(smi);
|
||||
if (mCount <= maxItems) mHeight += LINE_HEIGHT;
|
||||
if (forceFocus){
|
||||
mObjects[mCurr]->Leaving(PSP_CTRL_DOWN);
|
||||
mObjects[mCurr]->Leaving(JGE_BTN_DOWN);
|
||||
mCurr = mCount-1;
|
||||
smi->Entering();
|
||||
}
|
||||
|
||||
@@ -184,79 +184,69 @@ void SimplePad::MoveSelection(unsigned char moveto)
|
||||
moveto = KPD_INPUT;
|
||||
else if(!bShowCancel && moveto == KPD_CANCEL )
|
||||
moveto = KPD_SPACE;
|
||||
|
||||
if(selected < KPD_MAX && selected >= 0)
|
||||
|
||||
if (selected < KPD_MAX && selected >= 0)
|
||||
priorKey = selected;
|
||||
|
||||
if(moveto < KPD_MAX) {
|
||||
if (moveto < KPD_MAX)
|
||||
selected = moveto;
|
||||
}
|
||||
else if(moveto == KPD_INPUT)
|
||||
else if (moveto == KPD_INPUT)
|
||||
selected = KPD_INPUT;
|
||||
}
|
||||
|
||||
void SimplePad::Update(float dt){
|
||||
JGE * mEngine = JGE::GetInstance();
|
||||
u32 key = mEngine->ReadButton();
|
||||
|
||||
|
||||
//Start button changes capslock setting.
|
||||
if(key & PSP_CTRL_START)
|
||||
if (key == JGE_BTN_MENU)
|
||||
{
|
||||
if(selected != KPD_OK)
|
||||
if (selected != KPD_OK)
|
||||
selected = KPD_OK;
|
||||
else
|
||||
Finish();
|
||||
}
|
||||
else if(key & PSP_CTRL_SELECT){
|
||||
else if (key == JGE_BTN_CTRL)
|
||||
bCapslock = !bCapslock;
|
||||
}
|
||||
|
||||
if(selected == KPD_SPACE){
|
||||
if(bShowCancel && mEngine->GetButtonClick(PSP_CTRL_RIGHT))
|
||||
if (selected == KPD_SPACE){
|
||||
if (bShowCancel && mEngine->GetButtonClick(JGE_BTN_RIGHT))
|
||||
selected = KPD_CANCEL;
|
||||
else if (key & PSP_CTRL_LEFT || key & PSP_CTRL_RIGHT
|
||||
|| key & PSP_CTRL_UP || key & PSP_CTRL_DOWN)
|
||||
else if (key == JGE_BTN_LEFT || key == JGE_BTN_RIGHT
|
||||
|| key == JGE_BTN_UP || key == JGE_BTN_DOWN)
|
||||
selected = priorKey;
|
||||
} //Moving within/from the text field.
|
||||
else if(selected == KPD_INPUT){
|
||||
if (key & PSP_CTRL_DOWN )
|
||||
else if (selected == KPD_INPUT){
|
||||
if (key == JGE_BTN_DOWN )
|
||||
selected = priorKey;
|
||||
if (key & PSP_CTRL_LEFT){
|
||||
if(cursor > 0)
|
||||
cursor--;
|
||||
}
|
||||
else if (key & PSP_CTRL_RIGHT){
|
||||
if(cursor < buffer.size())
|
||||
cursor++;
|
||||
}
|
||||
if (key == JGE_BTN_LEFT && cursor > 0) cursor--;
|
||||
else if (key == JGE_BTN_RIGHT && cursor < buffer.size()) cursor++;
|
||||
}
|
||||
else if(selected >= 0 && keys[selected]){
|
||||
if (key & PSP_CTRL_LEFT)
|
||||
else if (selected >= 0 && keys[selected]){
|
||||
if (key == JGE_BTN_LEFT)
|
||||
MoveSelection(keys[selected]->adjacency[KPD_LEFT]);
|
||||
else if (key & PSP_CTRL_RIGHT)
|
||||
else if (key == JGE_BTN_RIGHT)
|
||||
MoveSelection(keys[selected]->adjacency[KPD_RIGHT]);
|
||||
if (key & PSP_CTRL_DOWN)
|
||||
if (key == JGE_BTN_DOWN)
|
||||
MoveSelection(keys[selected]->adjacency[KPD_DOWN]);
|
||||
else if (key & PSP_CTRL_UP)
|
||||
else if (key == JGE_BTN_UP)
|
||||
MoveSelection(keys[selected]->adjacency[KPD_UP]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//These bits require a valid key...
|
||||
if(selected >= 0 && selected < nbitems && keys[selected]){
|
||||
if (key & PSP_CTRL_CIRCLE)
|
||||
pressKey(keys[selected]->id);
|
||||
if (selected >= 0 && selected < nbitems && keys[selected])
|
||||
if (key == JGE_BTN_OK)
|
||||
pressKey(keys[selected]->id);
|
||||
if (buffer.size() > 0 && key == JGE_BTN_SEC)
|
||||
buffer = buffer.substr(0, buffer.size() - 1);
|
||||
if (buffer.size() && key == JGE_BTN_PREV) {
|
||||
if (cursor > 0) cursor--;
|
||||
}
|
||||
if (buffer.size() > 0 && key & PSP_CTRL_CROSS)
|
||||
buffer = buffer.substr(0,buffer.size() - 1);
|
||||
if (buffer.size() && key & PSP_CTRL_LTRIGGER){
|
||||
if(cursor > 0)
|
||||
cursor--;
|
||||
}
|
||||
else if (key & PSP_CTRL_RTRIGGER){
|
||||
if(cursor < buffer.size())
|
||||
else if (key == JGE_BTN_NEXT) {
|
||||
if (cursor < buffer.size())
|
||||
cursor++;
|
||||
else{
|
||||
else {
|
||||
buffer += ' ';
|
||||
cursor = buffer.size();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ void WGuiBase::renderBack(WGuiBase * it){
|
||||
|
||||
|
||||
//WGuiItem
|
||||
void WGuiItem::Entering(u32 key){
|
||||
void WGuiItem::Entering(JButton key){
|
||||
mFocus = true;
|
||||
}
|
||||
float WGuiItem::minWidth(){
|
||||
@@ -52,7 +52,7 @@ float WGuiItem::minHeight(){
|
||||
return mFont->GetHeight();
|
||||
}
|
||||
|
||||
bool WGuiItem::Leaving(u32 key){
|
||||
bool WGuiItem::Leaving(JButton key){
|
||||
mFocus = false;
|
||||
return true;
|
||||
}
|
||||
@@ -90,12 +90,12 @@ string WGuiItem::_(string input){
|
||||
return input;
|
||||
return ::_(input);
|
||||
}
|
||||
bool WGuiItem::CheckUserInput(u32 key){
|
||||
if(mFocus && key == PSP_CTRL_CIRCLE){
|
||||
bool WGuiItem::CheckUserInput(JButton key){
|
||||
if(mFocus && key == JGE_BTN_OK){
|
||||
updateValue();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
//WDecoStyled
|
||||
@@ -149,7 +149,7 @@ void WGuiHeader::Render(){
|
||||
}
|
||||
|
||||
|
||||
bool WGuiMenu::Leaving(u32 key){
|
||||
bool WGuiMenu::Leaving(JButton key){
|
||||
int nbitems = (int) items.size();
|
||||
if(key == buttonNext && currentItem < nbitems-1)
|
||||
return false;
|
||||
@@ -163,7 +163,7 @@ bool WGuiMenu::Leaving(u32 key){
|
||||
mFocus = false;
|
||||
return true;
|
||||
}
|
||||
void WGuiMenu::Entering(u32 key){
|
||||
void WGuiMenu::Entering(JButton key){
|
||||
mFocus = true;
|
||||
|
||||
//Try to force a selectable option.
|
||||
@@ -198,7 +198,7 @@ void WGuiMenu::subBack(WGuiBase * item){
|
||||
|
||||
}
|
||||
//WGuiList
|
||||
WGuiList::WGuiList(string name, WSyncable * syncme): WGuiMenu(PSP_CTRL_DOWN,PSP_CTRL_UP,false,syncme){
|
||||
WGuiList::WGuiList(string name, WSyncable * syncme): WGuiMenu(JGE_BTN_DOWN, JGE_BTN_UP, false, syncme){
|
||||
failMsg = "NO OPTIONS AVAILABLE";
|
||||
width = SCREEN_WIDTH-10;
|
||||
height = SCREEN_HEIGHT-10;
|
||||
@@ -237,7 +237,7 @@ void WGuiList::Render(){
|
||||
if(items[i]->Selectable()) {
|
||||
currentItem = i;
|
||||
if(hasFocus())
|
||||
items[currentItem]->Entering(0);
|
||||
items[currentItem]->Entering(JGE_BTN_NONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -405,7 +405,7 @@ WDecoConfirm::~WDecoConfirm(){
|
||||
SAFE_DELETE(confirmMenu);
|
||||
}
|
||||
|
||||
void WDecoConfirm::Entering(u32 key){
|
||||
void WDecoConfirm::Entering(JButton key){
|
||||
setFocus(true);
|
||||
|
||||
if(it)
|
||||
@@ -435,7 +435,7 @@ void WDecoConfirm::setData(){
|
||||
it->setData();
|
||||
}
|
||||
|
||||
bool WDecoConfirm::Leaving(u32 key){
|
||||
bool WDecoConfirm::Leaving(JButton key){
|
||||
if(!it)
|
||||
return true;
|
||||
|
||||
@@ -458,9 +458,9 @@ bool WDecoConfirm::Leaving(u32 key){
|
||||
|
||||
return false;
|
||||
}
|
||||
bool WDecoConfirm::CheckUserInput(u32 key){
|
||||
bool WDecoConfirm::CheckUserInput(JButton key){
|
||||
if(hasFocus()){
|
||||
if (mState == OP_CONFIRMED && key == PSP_CTRL_CIRCLE)
|
||||
if (mState == OP_CONFIRMED && key == JGE_BTN_OK)
|
||||
mState = OP_UNCONFIRMED;
|
||||
|
||||
if (mState != OP_CONFIRMING && it){
|
||||
@@ -520,8 +520,8 @@ void WGuiButton::updateValue(){
|
||||
mListener->ButtonPressed(controller, control);
|
||||
}
|
||||
|
||||
bool WGuiButton::CheckUserInput(u32 key){
|
||||
if (hasFocus() && key == PSP_CTRL_CIRCLE){
|
||||
bool WGuiButton::CheckUserInput(JButton key){
|
||||
if (hasFocus() && key == JGE_BTN_OK){
|
||||
updateValue();
|
||||
return true;
|
||||
}
|
||||
@@ -605,15 +605,15 @@ void WGuiSplit::setModal(bool val){
|
||||
return left->setModal(val);
|
||||
}
|
||||
|
||||
bool WGuiSplit::CheckUserInput(u32 key){
|
||||
bool WGuiSplit::CheckUserInput(JButton key){
|
||||
if(hasFocus()){
|
||||
if (!bRight){
|
||||
if(left->CheckUserInput(key))
|
||||
return true;
|
||||
if(key == PSP_CTRL_RIGHT && !isModal()
|
||||
&& right->Selectable() && left->Leaving(PSP_CTRL_RIGHT)){
|
||||
if(key == JGE_BTN_RIGHT && !isModal()
|
||||
&& right->Selectable() && left->Leaving(JGE_BTN_RIGHT)){
|
||||
bRight = !bRight;
|
||||
right->Entering(PSP_CTRL_RIGHT);
|
||||
right->Entering(JGE_BTN_RIGHT);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -621,10 +621,10 @@ bool WGuiSplit::CheckUserInput(u32 key){
|
||||
{
|
||||
if(right->CheckUserInput(key))
|
||||
return true;
|
||||
if (key == PSP_CTRL_LEFT && !isModal()
|
||||
&& left->Selectable() && right->Leaving(PSP_CTRL_LEFT)){
|
||||
if (key == JGE_BTN_LEFT && !isModal()
|
||||
&& left->Selectable() && right->Leaving(JGE_BTN_LEFT)){
|
||||
bRight = !bRight;
|
||||
left->Entering(PSP_CTRL_LEFT);
|
||||
left->Entering(JGE_BTN_LEFT);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -640,14 +640,14 @@ void WGuiSplit::Update(float dt){
|
||||
left->Update(dt);
|
||||
}
|
||||
|
||||
void WGuiSplit::Entering(u32 key){
|
||||
void WGuiSplit::Entering(JButton key){
|
||||
mFocus = true;
|
||||
if(bRight)
|
||||
right->Entering(key);
|
||||
else
|
||||
left->Entering(key);
|
||||
}
|
||||
bool WGuiSplit::Leaving(u32 key){
|
||||
bool WGuiSplit::Leaving(JButton key){
|
||||
|
||||
if(bRight){
|
||||
if(right->Leaving(key)){
|
||||
@@ -693,7 +693,7 @@ void WGuiSplit::confirmChange(bool confirmed){
|
||||
}
|
||||
|
||||
//WGuiMenu
|
||||
WGuiMenu::WGuiMenu(u32 next = PSP_CTRL_RIGHT, u32 prev = PSP_CTRL_LEFT, bool m, WSyncable * syncme): WGuiItem(""){
|
||||
WGuiMenu::WGuiMenu(JButton next = JGE_BTN_RIGHT, JButton prev = JGE_BTN_LEFT, bool m, WSyncable * syncme): WGuiItem(""){
|
||||
buttonNext = next;
|
||||
buttonPrev = prev;
|
||||
currentItem = -1;
|
||||
@@ -738,14 +738,14 @@ void WGuiMenu::Add(WGuiBase * it){
|
||||
if(it)
|
||||
items.push_back(it);
|
||||
}
|
||||
bool WGuiMenu::CheckUserInput(u32 key){
|
||||
bool WGuiMenu::CheckUserInput(JButton key){
|
||||
bool kidModal = false;
|
||||
bool handledInput = false;
|
||||
int nbitems = (int) items.size();
|
||||
JGE * mEngine = JGE::GetInstance();
|
||||
|
||||
if(!mEngine->GetButtonState(held)) //Key isn't held down.
|
||||
held = 0;
|
||||
held = JGE_BTN_NONE;
|
||||
|
||||
if(currentItem >= 0 && currentItem < nbitems)
|
||||
kidModal = items[currentItem]->isModal();
|
||||
@@ -790,32 +790,34 @@ void WGuiMenu::syncMove(){
|
||||
while(i > 0 && sync->next())
|
||||
i = currentItem - sync->getPos();
|
||||
}
|
||||
bool WGuiMenu::isButtonDir(u32 key, int dir){
|
||||
bool WGuiMenu::isButtonDir(JButton key, int dir){
|
||||
if(!mDPad)
|
||||
return ((dir > 0 && key == buttonNext) || (dir <= 0 && key == buttonPrev));
|
||||
|
||||
if(dir <= 0){
|
||||
switch(buttonPrev){
|
||||
case PSP_CTRL_LEFT:
|
||||
if(key == PSP_CTRL_UP)
|
||||
case JGE_BTN_LEFT:
|
||||
if(key == JGE_BTN_UP)
|
||||
return true;
|
||||
break;
|
||||
case PSP_CTRL_UP:
|
||||
if(key == PSP_CTRL_LEFT)
|
||||
case JGE_BTN_UP:
|
||||
if(key == JGE_BTN_LEFT)
|
||||
return true;
|
||||
break;
|
||||
default: ; // Nothing
|
||||
}
|
||||
return (key == buttonPrev);
|
||||
}else {
|
||||
switch(buttonNext){
|
||||
case PSP_CTRL_RIGHT:
|
||||
if(key == PSP_CTRL_DOWN)
|
||||
case JGE_BTN_RIGHT:
|
||||
if(key == JGE_BTN_DOWN)
|
||||
return true;
|
||||
break;
|
||||
case PSP_CTRL_DOWN:
|
||||
if(key == PSP_CTRL_RIGHT)
|
||||
case JGE_BTN_DOWN:
|
||||
if(key == JGE_BTN_RIGHT)
|
||||
return true;
|
||||
break;
|
||||
default: ; // Nothing
|
||||
}
|
||||
return (key == buttonNext);
|
||||
}
|
||||
@@ -1259,7 +1261,7 @@ void WGuiListRow::Render(){
|
||||
if(items[i]->Selectable()) {
|
||||
currentItem = i;
|
||||
if(hasFocus())
|
||||
items[currentItem]->Entering(0);
|
||||
items[currentItem]->Entering(JGE_BTN_NONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1312,8 +1314,8 @@ void WGuiListRow::Render(){
|
||||
setHeight(tallestRow*numRows+10);
|
||||
}
|
||||
WGuiListRow::WGuiListRow(string n, WSyncable * s) : WGuiList(n,s) {
|
||||
buttonNext = PSP_CTRL_RIGHT;
|
||||
buttonPrev = PSP_CTRL_LEFT;
|
||||
buttonNext = JGE_BTN_RIGHT;
|
||||
buttonPrev = JGE_BTN_LEFT;
|
||||
width = SCREEN_WIDTH;
|
||||
height = 20;
|
||||
}
|
||||
@@ -1367,7 +1369,7 @@ void WGuiFilters::buildList(){
|
||||
subMenu = NULL;
|
||||
list->Add(NEW WGuiHeader(displayValue));
|
||||
list->Add(wgs);
|
||||
list->Entering(0);
|
||||
list->Entering(JGE_BTN_NONE);
|
||||
}
|
||||
WGuiFilters::WGuiFilters(string header, WSrcCards * src) : WGuiItem(header) {
|
||||
bFinished = false;
|
||||
@@ -1417,12 +1419,11 @@ void WGuiFilters::Update(float dt){
|
||||
it = wgl->items.erase(it);
|
||||
bDeleted = true;
|
||||
}
|
||||
if(bDeleted){
|
||||
wgl->Entering(0);
|
||||
}
|
||||
if(bDeleted)
|
||||
wgl->Entering(JGE_BTN_NONE);
|
||||
}
|
||||
}
|
||||
void WGuiFilters::Entering(u32 key){
|
||||
void WGuiFilters::Entering(JButton key){
|
||||
bFinished = false;
|
||||
WGuiItem::Entering(key);
|
||||
}
|
||||
@@ -1439,10 +1440,10 @@ void WGuiFilters::Render(){
|
||||
if(subMenu && !subMenu->closed)
|
||||
subMenu->Render();
|
||||
}
|
||||
bool WGuiFilters::CheckUserInput(u32 key){
|
||||
bool WGuiFilters::CheckUserInput(JButton key){
|
||||
if(subMenu && !subMenu->closed && subMenu->CheckUserInput(key))
|
||||
return true;
|
||||
if(key == PSP_CTRL_CROSS){//|| key == PSP_CTRL_START){
|
||||
if(key == JGE_BTN_SEC){//|| key == JGE_BTN_MENU){
|
||||
//TODO Pop up a "Are you sure?" dialog.
|
||||
return true;
|
||||
}
|
||||
@@ -1729,4 +1730,4 @@ string WGuiFilterItem::getCode(){
|
||||
if(mState != STATE_FINISHED || !mCode.size())
|
||||
return "";
|
||||
return mCode;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user