Jeck - Keypad and deck editor fixes.
* Fixed a call to profileFile() in deck editor that was using the wrong form. * Spacebar works, keypad now does smart capitalization (switches to lower case on second letter)
This commit is contained in:
@@ -1,69 +1,69 @@
|
|||||||
#ifndef _SIMPLEPAD_H_
|
#ifndef _SIMPLEPAD_H_
|
||||||
#define _SIMPLEPAD_H_
|
#define _SIMPLEPAD_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <JGui.h>
|
#include <JGui.h>
|
||||||
#include <JLBFont.h>
|
#include <JLBFont.h>
|
||||||
#include "hge/hgeparticle.h"
|
#include "hge/hgeparticle.h"
|
||||||
|
|
||||||
enum SIMPLE_KEYS{
|
enum SIMPLE_KEYS{
|
||||||
KPD_A, KPD_B, KPD_C, KPD_D, KPD_E, KPD_F,
|
KPD_A, KPD_B, KPD_C, KPD_D, KPD_E, KPD_F,
|
||||||
KPD_G, KPD_H, KPD_I, KPD_J, KPD_K, KPD_L,
|
KPD_G, KPD_H, KPD_I, KPD_J, KPD_K, KPD_L,
|
||||||
KPD_M, KPD_N, KPD_O, KPD_P, KPD_Q, KPD_R,
|
KPD_M, KPD_N, KPD_O, KPD_P, KPD_Q, KPD_R,
|
||||||
KPD_S, KPD_T, KPD_U, KPD_V, KPD_W, KPD_X,
|
KPD_S, KPD_T, KPD_U, KPD_V, KPD_W, KPD_X,
|
||||||
KPD_Y, KPD_Z, KPD_SPACE, KPD_OK, KPD_CANCEL,
|
KPD_Y, KPD_Z, KPD_SPACE, KPD_OK, KPD_CANCEL,
|
||||||
KPD_DEL, KPD_CAPS, KPD_0, KPD_1, KPD_2, KPD_3,
|
KPD_DEL, KPD_CAPS, KPD_0, KPD_1, KPD_2, KPD_3,
|
||||||
KPD_4, KPD_5, KPD_6, KPD_7, KPD_8, KPD_9,
|
KPD_4, KPD_5, KPD_6, KPD_7, KPD_8, KPD_9,
|
||||||
KPD_MAX,
|
KPD_MAX,
|
||||||
KPD_NOWHERE = 254,
|
KPD_NOWHERE = 254,
|
||||||
KPD_INPUT = 255,
|
KPD_INPUT = 255,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SimpleKey{
|
struct SimpleKey{
|
||||||
SimpleKey( string _ds, int _id);
|
SimpleKey( string _ds, int _id);
|
||||||
string displayValue;
|
string displayValue;
|
||||||
unsigned char id;
|
unsigned char id;
|
||||||
unsigned char adjacency[4];
|
unsigned char adjacency[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
class SimplePad{
|
class SimplePad{
|
||||||
public:
|
public:
|
||||||
friend class GameSettings;
|
friend class GameSettings;
|
||||||
|
|
||||||
string buffer;
|
string buffer;
|
||||||
string title;
|
string title;
|
||||||
unsigned int cursorPos();
|
unsigned int cursorPos();
|
||||||
bool isActive() {return bActive;};
|
bool isActive() {return bActive;};
|
||||||
void Render();
|
void Render();
|
||||||
void Update(float dt);
|
void Update(float dt);
|
||||||
void pressKey(unsigned char id);
|
void pressKey(unsigned char id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SimplePad();
|
SimplePad();
|
||||||
~SimplePad();
|
~SimplePad();
|
||||||
|
|
||||||
int mX; int mY;
|
int mX; int mY;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void linkKeys(int from, int to, int dir);
|
void linkKeys(int from, int to, int dir);
|
||||||
SimpleKey * Add(string display, unsigned char id);
|
SimpleKey * Add(string display, unsigned char id);
|
||||||
void MoveSelection(unsigned char dir);
|
void MoveSelection(unsigned char dir);
|
||||||
void Start(string value, string * _dest=NULL);
|
void Start(string value, string * _dest=NULL);
|
||||||
string Finish();
|
string Finish();
|
||||||
|
|
||||||
bool bActive;
|
bool bActive;
|
||||||
bool bCapslock;
|
bool bCapslock;
|
||||||
bool bShowCancel, bShowNumpad;
|
bool bShowCancel, bShowNumpad;
|
||||||
bool bCanceled;
|
bool bCanceled;
|
||||||
int nbitems;
|
int nbitems;
|
||||||
unsigned int cursor;
|
unsigned int cursor;
|
||||||
int selected;
|
int selected;
|
||||||
int priorKey; //The prior key from those places.
|
int priorKey; //The prior key from those places.
|
||||||
SimpleKey * keys[KPD_MAX];
|
SimpleKey * keys[KPD_MAX];
|
||||||
string * dest;
|
string * dest;
|
||||||
string original; //For cancelling.
|
string original; //For cancelling.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ void GameStateDeckViewer::Start()
|
|||||||
|
|
||||||
menu = NEW SimpleMenu(11,this,menuFont,SCREEN_WIDTH/2-100,20);
|
menu = NEW SimpleMenu(11,this,menuFont,SCREEN_WIDTH/2-100,20);
|
||||||
menu->Add(11,"Save");
|
menu->Add(11,"Save");
|
||||||
menu->Add(12,"Rename deck");
|
menu->Add(12,"Save & Rename");
|
||||||
menu->Add(13,"Switch decks without saving");
|
menu->Add(13,"Switch decks without saving");
|
||||||
menu->Add(14,"Back to main menu");
|
menu->Add(14,"Back to main menu");
|
||||||
menu->Add(15,"Cancel");
|
menu->Add(15,"Cancel");
|
||||||
@@ -216,8 +216,10 @@ void GameStateDeckViewer::Update(float dt)
|
|||||||
|
|
||||||
if(newDeckname != ""){
|
if(newDeckname != ""){
|
||||||
loadDeck(deckNum);
|
loadDeck(deckNum);
|
||||||
if(myDeck && myDeck->parent)
|
if(myDeck && myDeck->parent){
|
||||||
myDeck->parent->meta_name = newDeckname;
|
myDeck->parent->meta_name = newDeckname;
|
||||||
|
myDeck->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
newDeckname = "";
|
newDeckname = "";
|
||||||
}
|
}
|
||||||
@@ -708,7 +710,7 @@ int GameStateDeckViewer::loadDeck(int deckid){
|
|||||||
char deckname[256];
|
char deckname[256];
|
||||||
sprintf(deckname,"deck%i.txt",deckid);
|
sprintf(deckname,"deck%i.txt",deckid);
|
||||||
SAFE_DELETE(myDeck);
|
SAFE_DELETE(myDeck);
|
||||||
myDeck = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(deckname).c_str(), mParent->collection));
|
myDeck = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(deckname,"",false,false).c_str(), mParent->collection));
|
||||||
MTGCard * current = myDeck->getNext();
|
MTGCard * current = myDeck->getNext();
|
||||||
while (current){
|
while (current){
|
||||||
int howmanyinDeck = myDeck->cards[current];
|
int howmanyinDeck = myDeck->cards[current];
|
||||||
|
|||||||
@@ -145,6 +145,15 @@ void SimplePad::pressKey(unsigned char key){
|
|||||||
cursor++;
|
cursor++;
|
||||||
|
|
||||||
buffer.insert(cursor,input);
|
buffer.insert(cursor,input);
|
||||||
|
|
||||||
|
//Auto swap capitalization
|
||||||
|
if(bCapslock && buffer.size() == 1)
|
||||||
|
bCapslock = !bCapslock;
|
||||||
|
}
|
||||||
|
else if(key == KPD_SPACE){
|
||||||
|
if(cursor < buffer.size())
|
||||||
|
cursor++;
|
||||||
|
buffer.insert(cursor," ");
|
||||||
}
|
}
|
||||||
else if(key == KPD_CAPS)
|
else if(key == KPD_CAPS)
|
||||||
bCapslock = !bCapslock;
|
bCapslock = !bCapslock;
|
||||||
|
|||||||
Reference in New Issue
Block a user