UPDATE YOUR rules FOLDER!!!
- This is some Work in progress to make Wagic less "game" dependent. This change especially is an attempt at moving away from some dangerous patents owned by some company. It introduces "modrules.xml", a global configuration file describing dynamic settings for any given Wagic mod. It is very basic for now, but allows to customize a bit. In particular, it allows to remove the concept of shop and deck editor from the game, dynamically generate the main menu, and represent card activation with a mask rather than a rotation. I have a sample in progress which I hope to submit in the days to come, a proof of concept (nothing fancy yet) for another type of game using these ideas, as well as a few other things I introduced recently. In the future, I am hoping to extend modrules.xml so that it entirely describes the rules of a given card game. the other files in rules.txt will describe "extensions" to the core rules, just like they do right now, so this new file does not make them obsolete. - Also fixed minor bugs I stumbled upon while developing
This commit is contained in:
@@ -43,6 +43,8 @@ public:
|
||||
static const float BigWidth;
|
||||
static const float BigHeight;
|
||||
|
||||
PIXEL_TYPE mMask;
|
||||
|
||||
MTGCardInstance* card;
|
||||
CardGui(MTGCardInstance* card, float x, float y);
|
||||
CardGui(MTGCardInstance* card, const Pos& ref);
|
||||
@@ -95,4 +97,33 @@ public:
|
||||
TransientCardView(MTGCardInstance* card, const Pos& ref);
|
||||
};
|
||||
|
||||
|
||||
class SimpleCardEffect
|
||||
{
|
||||
public:
|
||||
virtual void doEffect(Pos * card) = 0;
|
||||
virtual void undoEffect(Pos * card) = 0;
|
||||
};
|
||||
|
||||
class SimpleCardEffectRotate:public SimpleCardEffect
|
||||
{
|
||||
protected:
|
||||
float mRotation;
|
||||
public:
|
||||
SimpleCardEffectRotate(float rotation);
|
||||
void doEffect(Pos * card);
|
||||
void undoEffect(Pos * card);
|
||||
};
|
||||
|
||||
class SimpleCardEffectMask:public SimpleCardEffect
|
||||
{
|
||||
protected:
|
||||
PIXEL_TYPE mMask;
|
||||
public:
|
||||
SimpleCardEffectMask(PIXEL_TYPE mask);
|
||||
void doEffect(Pos * card);
|
||||
void undoEffect(Pos * card);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,6 @@ private:
|
||||
JTexture * splashTex;
|
||||
float mCreditsYPos;
|
||||
int currentState;
|
||||
//JMusic * bgMusic;
|
||||
int mVolume;
|
||||
char nbcardsStr[400];
|
||||
vector<string> langs;
|
||||
@@ -48,7 +47,10 @@ private:
|
||||
void genNbCardsStr(); //computes the contents of nbCardsStr
|
||||
void ensureMGuiController(); //creates the MGuiController if it doesn't exist
|
||||
string loadRandomWallpaper(); //loads a list of string of textures that can be randolmy shown on the loading screen
|
||||
|
||||
void RenderTopMenu();
|
||||
public:
|
||||
|
||||
GameStateMenu(GameApp* parent);
|
||||
virtual ~GameStateMenu();
|
||||
virtual void Create();
|
||||
|
||||
110
projects/mtg/include/ModRules.h
Normal file
110
projects/mtg/include/ModRules.h
Normal file
@@ -0,0 +1,110 @@
|
||||
#ifndef _MODRULES_H_
|
||||
#define _MODRULES_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
#include "CardGui.h"
|
||||
|
||||
class TiXmlElement;
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
SUBMENUITEM_CANCEL = kCancelMenuID,
|
||||
MENUITEM_PLAY,
|
||||
MENUITEM_DECKEDITOR,
|
||||
MENUITEM_SHOP,
|
||||
MENUITEM_OPTIONS,
|
||||
MENUITEM_EXIT,
|
||||
MENUITEM_TROPHIES,
|
||||
SUBMENUITEM_1PLAYER,
|
||||
#ifdef NETWORK_SUPPORT
|
||||
SUBMENUITEM_2PLAYERS,
|
||||
SUBMENUITEM_HOST_GAME,
|
||||
SUBMENUITEM_JOIN_GAME,
|
||||
#endif //NETWORK_SUPPORT
|
||||
SUBMENUITEM_DEMO,
|
||||
SUBMENUITEM_TESTSUITE,
|
||||
SUBMENUITEM_END_OFFSET
|
||||
};
|
||||
|
||||
class ModRulesMenuItem
|
||||
{
|
||||
protected:
|
||||
static int strToAction(string str);
|
||||
public:
|
||||
int mActionId;
|
||||
string mDisplayName;
|
||||
ModRulesMenuItem(string actionIdStr, string displayName);
|
||||
//most actionIds are associated to a game state. e.g. MENUITEM_DECKEDITOR <--> GAME_STATE_DECK_VIEWER
|
||||
//This function returns the game state that matches the actionId, if any
|
||||
int getMatchingGameState();
|
||||
static int getMatchingGameState(int actionId);
|
||||
};
|
||||
|
||||
class ModRulesMainMenuItem: public ModRulesMenuItem
|
||||
{
|
||||
public:
|
||||
int mIconId;
|
||||
string mParticleFile;
|
||||
ModRulesMainMenuItem(string actionIdStr, string displayName, int iconId, string particleFile);
|
||||
};
|
||||
|
||||
class ModRulesOtherMenuItem: public ModRulesMenuItem
|
||||
{
|
||||
public:
|
||||
JButton mKey;
|
||||
ModRulesOtherMenuItem(string actionIdStr, string displayName, string keyStr);
|
||||
static JButton strToJButton(string keyStr);
|
||||
};
|
||||
|
||||
class ModRulesMenu
|
||||
{
|
||||
public:
|
||||
vector<ModRulesMainMenuItem *> main;
|
||||
vector<ModRulesOtherMenuItem *> other;
|
||||
|
||||
void parse(TiXmlElement* element);
|
||||
~ModRulesMenu();
|
||||
};
|
||||
|
||||
class ModRulesGeneral
|
||||
{
|
||||
protected:
|
||||
bool mHasDeckEditor;
|
||||
bool mHasShop;
|
||||
public:
|
||||
bool hasDeckEditor() {return mHasDeckEditor;};
|
||||
bool hasShop() {return mHasShop;};
|
||||
ModRulesGeneral();
|
||||
void parse(TiXmlElement* element);
|
||||
};
|
||||
|
||||
class ModRulesCards
|
||||
{
|
||||
public:
|
||||
SimpleCardEffect * activateEffect;
|
||||
static SimpleCardEffect * parseEffect(string str);
|
||||
ModRulesCards();
|
||||
~ModRulesCards();
|
||||
void parse(TiXmlElement* element);
|
||||
};
|
||||
|
||||
class ModRules
|
||||
{
|
||||
public:
|
||||
ModRulesGeneral general;
|
||||
ModRulesCards cards;
|
||||
ModRulesMenu menu;
|
||||
|
||||
bool load(string filename);
|
||||
static int getValueAsInt(TiXmlElement* element, string childName);
|
||||
|
||||
};
|
||||
|
||||
extern ModRules gModRules;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -7,6 +7,7 @@ struct Pos
|
||||
{
|
||||
float actX, actY, actZ, actT, actA;
|
||||
float x, y, zoom, t, alpha;
|
||||
PIXEL_TYPE mask;
|
||||
Pos(float, float, float, float, float);
|
||||
virtual void Update(float dt);
|
||||
void UpdateNow();
|
||||
|
||||
Reference in New Issue
Block a user