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