Jeck - CommonRes transparently finds themed versions of files. Use JRenderer::LoadTexture for unthemed files, and CommonRes::LoadTexture for themed files. Res/graphics/back.jpg renamed to Res/graphics/backdrop.jpg due to collision with sets/back.jpg.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/Blocker.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/CardSelector.o objs/ConstraintResolver.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DamageResolverLayer.o objs/DeckDataWrapper.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiAvatars.o objs/GuiBackground.o objs/GuiCardsController.o objs/GuiCombat.o objs/GuiFrame.o objs/GuiHand.o objs/GuiLayers.o objs/GuiMana.o objs/GuiPhaseBar.o objs/GuiPlay.o objs/GuiStatic.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGGuiHand.o objs/MTGGuiPlay.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/Pos.o objs/PriceList.o objs/ReplacementEffects.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/TexturesCache.o objs/SimplePad.o objs/Token.o objs/Translate.o objs/utils.o objs/WEvent.o
|
||||
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/Blocker.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/CardSelector.o objs/ConstraintResolver.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DamageResolverLayer.o objs/DeckDataWrapper.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiAvatars.o objs/GuiBackground.o objs/GuiCardsController.o objs/GuiCombat.o objs/GuiFrame.o objs/GuiHand.o objs/GuiLayers.o objs/GuiMana.o objs/GuiPhaseBar.o objs/GuiPlay.o objs/GuiStatic.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGGuiHand.o objs/MTGGuiPlay.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/Pos.o objs/PriceList.o objs/ReplacementEffects.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/TexturesCache.o objs/SimplePad.o objs/Token.o objs/Translate.o objs/utils.o objs/WEvent.o objs/WResourceManager.o
|
||||
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
|
||||
|
||||
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)
|
||||
|
||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
@@ -20,10 +20,7 @@
|
||||
#include <JSprite.h>
|
||||
#include <JLBFont.h>
|
||||
#include <hge/hgeparticle.h>
|
||||
|
||||
|
||||
#include <JResourceManager.h>
|
||||
|
||||
#include "../include/WResourceManager.h"
|
||||
|
||||
#include "../include/GameState.h"
|
||||
#include "../include/GameOptions.h"
|
||||
@@ -86,7 +83,7 @@ class GameApp: public JApp
|
||||
|
||||
void LoadGameStates();
|
||||
void SetNextState(int state);
|
||||
static JResourceManager * CommonRes;
|
||||
static WResourceManager * CommonRes;
|
||||
static hgeParticleSystem * Particles[6];
|
||||
static int HasMusic;
|
||||
static string systemError;
|
||||
|
||||
@@ -30,6 +30,7 @@ struct Options {
|
||||
static const string OSD;
|
||||
static const string ACTIVE_PROFILE;
|
||||
static const string ACTIVE_THEME;
|
||||
static const string ACTIVE_MODE;
|
||||
};
|
||||
|
||||
struct Metrics {
|
||||
@@ -115,7 +116,6 @@ public:
|
||||
//The sanity=false option returns the adjusted path even if the file doesn't exist.
|
||||
string profileFile(string filename="", string fallback="", bool sanity=true,bool relative=false);
|
||||
string modeFile(string filename, string fallback, bool relative);
|
||||
string themeGraphic(string filename);
|
||||
|
||||
void checkProfile();
|
||||
void createUsersFirstDeck(int setId);
|
||||
|
||||
@@ -172,7 +172,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
}
|
||||
|
||||
|
||||
pspIconsTexture = JRenderer::GetInstance()->LoadTexture(options.themeGraphic("iconspsp.png").c_str(), TEX_TYPE_USE_VRAM);
|
||||
pspIconsTexture = GameApp::CommonRes->LoadTexture("iconspsp.png", TEX_TYPE_USE_VRAM);
|
||||
|
||||
for (int i=0; i < 8; i++){
|
||||
pspIcons[i] = NEW JQuad(pspIconsTexture, i*32, 0, 32, 32);
|
||||
@@ -182,7 +182,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
backQuad = GameApp::CommonRes->GetQuad("back");
|
||||
|
||||
//menuFont = NEW JLBFont("graphics/f3",16);
|
||||
menuFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||
menuFont = GameApp::CommonRes->GetJLBFont("f3");
|
||||
welcome_menu = NEW SimpleMenu(10,this,menuFont,20,20);
|
||||
int nbDecks = fillDeckMenu(welcome_menu,options.profileFile());
|
||||
welcome_menu->Add(nbDecks+1, "--NEW--");
|
||||
|
||||
47
projects/mtg/include/WResourceManager.h
Normal file
47
projects/mtg/include/WResourceManager.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef _WRESOURCEMANAGER_H_
|
||||
#define _WRESOURCEMANAGER_H_
|
||||
#include <JResourceManager.h>
|
||||
#include <JTypes.h>
|
||||
|
||||
//This class is a wrapper for JResourceManager
|
||||
class WResourceManager
|
||||
{
|
||||
public:
|
||||
WResourceManager();
|
||||
~WResourceManager();
|
||||
|
||||
//Wrapped from JResourceManager
|
||||
int CreateTexture(const string &textureName);
|
||||
JTexture* GetTexture(const string &textureName);
|
||||
JTexture* GetTexture(int id);
|
||||
|
||||
int CreateQuad(const string &quadName, const string &textureName, float x, float y, float width, float height);
|
||||
JQuad* GetQuad(const string &quadName);
|
||||
JQuad* GetQuad(int id);
|
||||
|
||||
int LoadJLBFont(const string &fontName, int height);
|
||||
JLBFont* GetJLBFont(const string &fontName);
|
||||
JLBFont* GetJLBFont(int id);
|
||||
|
||||
int LoadMusic(const string &musicName);
|
||||
JMusic* GetMusic(const string &musicName);
|
||||
JMusic* GetMusic(int id);
|
||||
|
||||
int LoadSample(const string &sampleName);
|
||||
JSample* GetSample(const string &sampleName);
|
||||
JSample* GetSample(int id);
|
||||
|
||||
//Wrapped from JRenderer, if we need it.
|
||||
JTexture* LoadTexture(const char* filename, int mode = 0, int textureFormat = TEXTURE_FORMAT);
|
||||
|
||||
//Our new redirect system.
|
||||
string graphicsFile(const string filename, const string specific = "");
|
||||
string musicFile(const string filename, const string specific = "");
|
||||
string sfxFile(const string filename, const string specific = "");
|
||||
bool fileOK(string filename, bool relative = false);
|
||||
|
||||
private:
|
||||
static JResourceManager * jrm;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -122,7 +122,7 @@ void CardGui::alternateRender(MTGCard * card, const Pos& pos){
|
||||
renderer->RenderQuad(q, pos.actX, pos.actY, pos.actT, scale, scale);
|
||||
|
||||
// Write the title
|
||||
JLBFont * font = GameApp::CommonRes->GetJLBFont("graphics/magic");
|
||||
JLBFont * font = GameApp::CommonRes->GetJLBFont("magic");
|
||||
float backup_scale = font->GetScale();
|
||||
font->SetColor(ARGB((int)pos.actA, 0, 0, 0));
|
||||
font->SetScale(0.8 * pos.actZ);
|
||||
|
||||
@@ -74,27 +74,27 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app){
|
||||
if (unlocked == -1){
|
||||
unlocked = isDifficultyUnlocked();
|
||||
if (unlocked){
|
||||
unlockedTex = JRenderer::GetInstance()->LoadTexture(options.themeGraphic("unlocked.png").c_str(), TEX_TYPE_USE_VRAM);
|
||||
unlockedTex = GameApp::CommonRes->LoadTexture("unlocked.png", TEX_TYPE_USE_VRAM);
|
||||
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
|
||||
options[Options::DIFFICULTY_MODE_UNLOCKED] = GameOption(1);
|
||||
options.save();
|
||||
} else if ((unlocked = isMomirUnlocked())) {
|
||||
unlockedTex = JRenderer::GetInstance()->LoadTexture(options.themeGraphic("momir_unlocked.png").c_str(), TEX_TYPE_USE_VRAM);
|
||||
unlockedTex = GameApp::CommonRes->LoadTexture("momir_unlocked.png", TEX_TYPE_USE_VRAM);
|
||||
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
|
||||
options[Options::MOMIR_MODE_UNLOCKED] = GameOption(1);
|
||||
options.save();
|
||||
} else if ((unlocked = isEvilTwinUnlocked())) {
|
||||
unlockedTex = JRenderer::GetInstance()->LoadTexture(options.themeGraphic("eviltwin_unlocked.png").c_str(), TEX_TYPE_USE_VRAM);
|
||||
unlockedTex = GameApp::CommonRes->LoadTexture("eviltwin_unlocked.png", TEX_TYPE_USE_VRAM);
|
||||
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
|
||||
options[Options::EVILTWIN_MODE_UNLOCKED] = GameOption(1);
|
||||
options.save();
|
||||
}else if((unlocked = isRandomDeckUnlocked())) {
|
||||
unlockedTex = JRenderer::GetInstance()->LoadTexture(options.themeGraphic("randomdeck_unlocked.png").c_str(), TEX_TYPE_USE_VRAM);
|
||||
unlockedTex = GameApp::CommonRes->LoadTexture("randomdeck_unlocked.png", TEX_TYPE_USE_VRAM);
|
||||
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
|
||||
options[Options::RANDOMDECK_MODE_UNLOCKED] = GameOption(1);
|
||||
options.save();
|
||||
}else if((unlocked = unlockRandomSet())) {
|
||||
unlockedTex = JRenderer::GetInstance()->LoadTexture(options.themeGraphic("set_unlocked.png").c_str(), TEX_TYPE_USE_VRAM);
|
||||
unlockedTex = GameApp::CommonRes->LoadTexture("set_unlocked.png", TEX_TYPE_USE_VRAM);
|
||||
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
|
||||
char buffer[4096];
|
||||
unlockedString = MtgSets::SetsList->values[unlocked -1];
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <pspfpu.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "../include/WResourceManager.h"
|
||||
#include "../include/GameApp.h"
|
||||
#include "../include/Subtypes.h"
|
||||
#include "../include/GameStateDeckViewer.h"
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "../include/Translate.h"
|
||||
|
||||
const char * const GameState::menuTexts[]= {"--NEW--","Deck 1", "Deck 2", "Deck 3", "Deck 4", "Deck 5", "Deck 6"} ;
|
||||
JResourceManager* GameApp::CommonRes = NEW JResourceManager();
|
||||
WResourceManager* GameApp::CommonRes = NEW WResourceManager();
|
||||
hgeParticleSystem* GameApp::Particles[] = {NULL,NULL,NULL,NULL,NULL,NULL};
|
||||
int GameApp::HasMusic = 1;
|
||||
JMusic * GameApp::music = NULL;
|
||||
@@ -77,15 +77,15 @@ void GameApp::Create()
|
||||
else
|
||||
HasMusic = 0;
|
||||
|
||||
CommonRes->CreateTexture("graphics/menuicons.png");
|
||||
CommonRes->CreateTexture("menuicons.png");
|
||||
//Creating thes quad in this specific order allows us to have them in the correct order to call them by integer id
|
||||
CommonRes->CreateQuad("c_artifact", "graphics/menuicons.png", 2 + 6*36, 38, 32, 32);
|
||||
CommonRes->CreateQuad("c_green", "graphics/menuicons.png", 2 + 0*36, 38, 32, 32);
|
||||
CommonRes->CreateQuad("c_blue", "graphics/menuicons.png", 2 + 1*36, 38, 32, 32);
|
||||
CommonRes->CreateQuad("c_red", "graphics/menuicons.png", 2 + 3*36, 38, 32, 32);
|
||||
CommonRes->CreateQuad("c_black", "graphics/menuicons.png", 2 + 2*36, 38, 32, 32);
|
||||
CommonRes->CreateQuad("c_white", "graphics/menuicons.png", 2 + 4*36, 38, 32, 32);
|
||||
CommonRes->CreateQuad("c_land", "graphics/menuicons.png", 2 + 5*36, 38, 32, 32);
|
||||
CommonRes->CreateQuad("c_artifact", "menuicons.png", 2 + 6*36, 38, 32, 32);
|
||||
CommonRes->CreateQuad("c_green", "menuicons.png", 2 + 0*36, 38, 32, 32);
|
||||
CommonRes->CreateQuad("c_blue", "menuicons.png", 2 + 1*36, 38, 32, 32);
|
||||
CommonRes->CreateQuad("c_red", "menuicons.png", 2 + 3*36, 38, 32, 32);
|
||||
CommonRes->CreateQuad("c_black", "menuicons.png", 2 + 2*36, 38, 32, 32);
|
||||
CommonRes->CreateQuad("c_white", "menuicons.png", 2 + 4*36, 38, 32, 32);
|
||||
CommonRes->CreateQuad("c_land", "menuicons.png", 2 + 5*36, 38, 32, 32);
|
||||
manaIcons[Constants::MTG_COLOR_ARTIFACT] = GameApp::CommonRes->GetQuad("c_artifact");
|
||||
manaIcons[Constants::MTG_COLOR_LAND] = GameApp::CommonRes->GetQuad("c_land");
|
||||
manaIcons[Constants::MTG_COLOR_WHITE] = GameApp::CommonRes->GetQuad("c_white");
|
||||
@@ -95,72 +95,71 @@ void GameApp::Create()
|
||||
manaIcons[Constants::MTG_COLOR_GREEN] = GameApp::CommonRes->GetQuad("c_green");
|
||||
for (int i = sizeof(manaIcons)/sizeof(manaIcons[0]) - 1; i >= 0; --i) manaIcons[i]->SetHotSpot(16,16);
|
||||
|
||||
CommonRes->CreateTexture("sets/back.jpg");
|
||||
CommonRes->CreateQuad("back", "sets/back.jpg", 0, 0, 200, 285);
|
||||
CommonRes->CreateTexture("back.jpg");
|
||||
CommonRes->CreateQuad("back", "back.jpg", 0, 0, 200, 285);
|
||||
CommonRes->GetQuad("back")->SetHotSpot(100, 145);
|
||||
|
||||
CommonRes->CreateTexture("sets/back_thumb.jpg");
|
||||
CommonRes->CreateQuad("back_thumb", "sets/back_thumb.jpg", 0, 0, MTG_MINIIMAGE_WIDTH, MTG_MINIIMAGE_HEIGHT);
|
||||
CommonRes->CreateTexture("back_thumb.jpg");
|
||||
CommonRes->CreateQuad("back_thumb", "back_thumb.jpg", 0, 0, MTG_MINIIMAGE_WIDTH, MTG_MINIIMAGE_HEIGHT);
|
||||
|
||||
CommonRes->CreateTexture("graphics/particles.png");
|
||||
CommonRes->CreateQuad("particles", "graphics/particles.png", 0, 0, 32, 32);
|
||||
CommonRes->CreateTexture("particles.png");
|
||||
CommonRes->CreateQuad("particles", "particles.png", 0, 0, 32, 32);
|
||||
CommonRes->GetQuad("particles")->SetHotSpot(16,16);
|
||||
|
||||
CommonRes->CreateQuad("stars", "graphics/particles.png", 64, 0, 32, 32);
|
||||
CommonRes->CreateQuad("stars", "particles.png", 64, 0, 32, 32);
|
||||
CommonRes->GetQuad("stars")->SetHotSpot(16,16);
|
||||
|
||||
CommonRes->LoadJLBFont("graphics/simon",11);
|
||||
CommonRes->GetJLBFont("graphics/simon")->SetTracking(-1);
|
||||
CommonRes->LoadJLBFont("graphics/f3",16);
|
||||
CommonRes->LoadJLBFont("graphics/magic",16);
|
||||
CommonRes->LoadJLBFont("simon",11);
|
||||
CommonRes->GetJLBFont("simon")->SetTracking(-1);
|
||||
CommonRes->LoadJLBFont("f3",16);
|
||||
CommonRes->LoadJLBFont("magic",16);
|
||||
|
||||
|
||||
CommonRes->CreateTexture("graphics/phasebar.png");
|
||||
CommonRes->CreateTexture("graphics/wood.png");
|
||||
CommonRes->CreateTexture("graphics/gold.png");
|
||||
CommonRes->CreateTexture("graphics/goldglow.png");
|
||||
CommonRes->CreateTexture("graphics/back.jpg");
|
||||
CommonRes->CreateTexture("phasebar.png");
|
||||
CommonRes->CreateTexture("wood.png");
|
||||
CommonRes->CreateTexture("gold.png");
|
||||
CommonRes->CreateTexture("goldglow.png");
|
||||
CommonRes->CreateTexture("backdrop.jpg");
|
||||
CommonRes->CreateTexture("handback.png");
|
||||
|
||||
CommonRes->CreateTexture("graphics/handback.png");
|
||||
|
||||
CommonRes->CreateTexture("sets/red.jpg");
|
||||
CommonRes->CreateTexture("sets/white.jpg");
|
||||
CommonRes->CreateTexture("sets/blue.jpg");
|
||||
CommonRes->CreateTexture("sets/black.jpg");
|
||||
CommonRes->CreateTexture("sets/green.jpg");
|
||||
CommonRes->CreateQuad("red", "sets/red.jpg", 0, 0, 200, 285);
|
||||
CommonRes->CreateQuad("white", "sets/white.jpg", 0, 0, 200, 285);
|
||||
CommonRes->CreateQuad("blue", "sets/blue.jpg", 0, 0, 200, 285);
|
||||
CommonRes->CreateQuad("black", "sets/black.jpg", 0, 0, 200, 285);
|
||||
CommonRes->CreateQuad("green", "sets/green.jpg", 0, 0, 200, 285);
|
||||
CommonRes->CreateTexture("red.jpg");
|
||||
CommonRes->CreateTexture("white.jpg");
|
||||
CommonRes->CreateTexture("blue.jpg");
|
||||
CommonRes->CreateTexture("black.jpg");
|
||||
CommonRes->CreateTexture("green.jpg");
|
||||
CommonRes->CreateQuad("red", "red.jpg", 0, 0, 200, 285);
|
||||
CommonRes->CreateQuad("white", "white.jpg", 0, 0, 200, 285);
|
||||
CommonRes->CreateQuad("blue", "blue.jpg", 0, 0, 200, 285);
|
||||
CommonRes->CreateQuad("black", "black.jpg", 0, 0, 200, 285);
|
||||
CommonRes->CreateQuad("green", "green.jpg", 0, 0, 200, 285);
|
||||
CommonRes->GetQuad("red")->SetHotSpot(100, 145);
|
||||
CommonRes->GetQuad("white")->SetHotSpot(100, 145);
|
||||
CommonRes->GetQuad("blue")->SetHotSpot(100, 145);
|
||||
CommonRes->GetQuad("black")->SetHotSpot(100, 145);
|
||||
CommonRes->GetQuad("green")->SetHotSpot(100, 145);
|
||||
|
||||
CommonRes->CreateTexture("sets/red_thumb.jpg");
|
||||
CommonRes->CreateTexture("sets/white_thumb.jpg");
|
||||
CommonRes->CreateTexture("sets/blue_thumb.jpg");
|
||||
CommonRes->CreateTexture("sets/black_thumb.jpg");
|
||||
CommonRes->CreateTexture("sets/green_thumb.jpg");
|
||||
CommonRes->CreateQuad("red_thumb", "sets/red_thumb.jpg", 0, 0, 28, 40);
|
||||
CommonRes->CreateQuad("white_thumb", "sets/white_thumb.jpg", 0, 0, 28, 40);
|
||||
CommonRes->CreateQuad("blue_thumb", "sets/blue_thumb.jpg", 0, 0, 28, 40);
|
||||
CommonRes->CreateQuad("black_thumb", "sets/black_thumb.jpg", 0, 0, 28, 40);
|
||||
CommonRes->CreateQuad("green_thumb", "sets/green_thumb.jpg", 0, 0, 28, 40);
|
||||
CommonRes->CreateTexture("red_thumb.jpg");
|
||||
CommonRes->CreateTexture("white_thumb.jpg");
|
||||
CommonRes->CreateTexture("blue_thumb.jpg");
|
||||
CommonRes->CreateTexture("black_thumb.jpg");
|
||||
CommonRes->CreateTexture("green_thumb.jpg");
|
||||
CommonRes->CreateQuad("red_thumb", "red_thumb.jpg", 0, 0, 28, 40);
|
||||
CommonRes->CreateQuad("white_thumb", "white_thumb.jpg", 0, 0, 28, 40);
|
||||
CommonRes->CreateQuad("blue_thumb", "blue_thumb.jpg", 0, 0, 28, 40);
|
||||
CommonRes->CreateQuad("black_thumb", "black_thumb.jpg", 0, 0, 28, 40);
|
||||
CommonRes->CreateQuad("green_thumb", "green_thumb.jpg", 0, 0, 28, 40);
|
||||
CommonRes->GetQuad("red_thumb")->SetHotSpot(14, 20);
|
||||
CommonRes->GetQuad("white_thumb")->SetHotSpot(14, 20);
|
||||
CommonRes->GetQuad("blue_thumb")->SetHotSpot(14, 20);
|
||||
CommonRes->GetQuad("black_thumb")->SetHotSpot(14, 20);
|
||||
CommonRes->GetQuad("green_thumb")->SetHotSpot(14, 20);
|
||||
|
||||
CommonRes->CreateTexture("graphics/BattleIcon.png");
|
||||
CommonRes->CreateTexture("graphics/DefenderIcon.png");
|
||||
CommonRes->CreateTexture("graphics/shadow.png");
|
||||
CommonRes->CreateQuad("BattleIcon", "graphics/BattleIcon.png", 0, 0, 25, 25);
|
||||
CommonRes->CreateQuad("DefenderIcon", "graphics/DefenderIcon.png", 0, 0, 24, 23);
|
||||
CommonRes->CreateQuad("shadow", "graphics/shadow.png", 0, 0, 1, 1);
|
||||
CommonRes->CreateTexture("BattleIcon.png");
|
||||
CommonRes->CreateTexture("DefenderIcon.png");
|
||||
CommonRes->CreateTexture("shadow.png");
|
||||
CommonRes->CreateQuad("BattleIcon", "BattleIcon.png", 0, 0, 25, 25);
|
||||
CommonRes->CreateQuad("DefenderIcon", "DefenderIcon.png", 0, 0, 24, 23);
|
||||
CommonRes->CreateQuad("shadow", "shadow.png", 0, 0, 1, 1);
|
||||
CommonRes->GetQuad("BattleIcon")->SetHotSpot(12, 12);
|
||||
CommonRes->GetQuad("DefenderIcon")->SetHotSpot(12, 12);
|
||||
CommonRes->GetQuad("shadow")->SetHotSpot(0.5, 0.5);
|
||||
@@ -309,7 +308,7 @@ void GameApp::Render()
|
||||
{
|
||||
if (systemError.size()){
|
||||
fprintf(stderr, systemError.c_str());
|
||||
JLBFont * mFont= CommonRes->GetJLBFont("graphics/simon");
|
||||
JLBFont * mFont= CommonRes->GetJLBFont("simon");
|
||||
if (mFont) mFont->DrawString(systemError.c_str(),1,1);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ const string Options::INTERRUPTMYSPELLS = "interruptMySpells";
|
||||
const string Options::INTERRUPTMYABILITIES = "interruptMyAbilities";
|
||||
const string Options::OSD = "displayOSD";
|
||||
const string Options::ACTIVE_THEME = "Theme";
|
||||
const string Options::ACTIVE_MODE = "Mode";
|
||||
//Global options
|
||||
const string Options::ACTIVE_PROFILE = "_gProfile";
|
||||
const string Options::DIFFICULTY_MODE_UNLOCKED = "_gprx_handler"; //huhu
|
||||
@@ -278,26 +279,6 @@ string GameSettings::profileFile(string filename, string fallback,bool sanity, b
|
||||
return buf;
|
||||
}
|
||||
|
||||
string GameSettings::themeGraphic(string filename)
|
||||
{
|
||||
char buf[4096];
|
||||
string theme = (*this)[Options::ACTIVE_THEME].str;
|
||||
|
||||
if(theme == "" || theme == "default"){
|
||||
sprintf(buf,"graphics/%s",filename.c_str());
|
||||
return buf;
|
||||
}
|
||||
|
||||
sprintf(buf,RESPATH"/themes/%s/%s",theme.c_str(),filename.c_str());
|
||||
|
||||
if(fileExists(buf)){
|
||||
sprintf(buf,"themes/%s/%s",theme.c_str(),filename.c_str());
|
||||
return buf;
|
||||
}
|
||||
|
||||
sprintf(buf,"graphics/%s",filename.c_str());
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
void GameSettings::checkProfile(){
|
||||
|
||||
@@ -83,13 +83,13 @@ void GameStateMenu::Create()
|
||||
mReadConf = 0;
|
||||
mCurrentSetName[0] = 0;
|
||||
|
||||
mIconsTexture = JRenderer::GetInstance()->LoadTexture(options.themeGraphic("menuicons.png").c_str(), TEX_TYPE_USE_VRAM);
|
||||
bgTexture = JRenderer::GetInstance()->LoadTexture(options.themeGraphic("menutitle.png").c_str(), TEX_TYPE_USE_VRAM);
|
||||
movingWTexture = JRenderer::GetInstance()->LoadTexture(options.themeGraphic("movingW.png").c_str(), TEX_TYPE_USE_VRAM);
|
||||
mIconsTexture = GameApp::CommonRes->LoadTexture("menuicons.png", TEX_TYPE_USE_VRAM);
|
||||
bgTexture = GameApp::CommonRes->LoadTexture("menutitle.png", TEX_TYPE_USE_VRAM);
|
||||
movingWTexture = GameApp::CommonRes->LoadTexture("movingW.png", TEX_TYPE_USE_VRAM);
|
||||
mBg = NEW JQuad(bgTexture, 0, 0, 256, 166); // Create background quad for rendering.
|
||||
mMovingW = NEW JQuad(movingWTexture, 2, 2, 84, 62);
|
||||
if (fileExists(options.themeGraphic("splash.jpg").c_str())){
|
||||
splashTex = JRenderer::GetInstance()->LoadTexture(options.themeGraphic("splash.jpg").c_str(), TEX_TYPE_USE_VRAM);
|
||||
if (fileExists(GameApp::CommonRes->graphicsFile("splash.jpg").c_str())){
|
||||
splashTex = GameApp::CommonRes->LoadTexture("splash.jpg", TEX_TYPE_USE_VRAM);
|
||||
splashQuad = NEW JQuad(splashTex, 0, 0, 480, 272);
|
||||
}
|
||||
mBg->SetHotSpot(105,50);
|
||||
|
||||
@@ -53,7 +53,7 @@ void GameStateOptions::Start()
|
||||
optionsList->failMsg = "";
|
||||
optionsTabs->Add(optionsList);
|
||||
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
|
||||
optionsMenu = NEW SimpleMenu(102, this,mFont, 50,170);
|
||||
optionsMenu->Add(1, "Save & Back to Main Menu");
|
||||
optionsMenu->Add(2, "Back to Main Menu");
|
||||
@@ -136,7 +136,7 @@ void GameStateOptions::Render()
|
||||
"Please support this project with donations at http://wololo.net/wagic",
|
||||
};
|
||||
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/magic");
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("magic");
|
||||
mFont->SetColor(ARGB(255,200,200,200));
|
||||
mFont->SetScale(1.0);
|
||||
float startpos = 272 - timer * 10;
|
||||
|
||||
@@ -36,7 +36,7 @@ void GameStateShop::Start()
|
||||
|
||||
mStage = STAGE_SHOP_SHOP;
|
||||
|
||||
bgTexture = JRenderer::GetInstance()->LoadTexture(options.themeGraphic("shop.jpg").c_str(), TEX_TYPE_USE_VRAM);
|
||||
bgTexture = GameApp::CommonRes->LoadTexture("shop.jpg", TEX_TYPE_USE_VRAM);
|
||||
mBg = NEW JQuad(bgTexture, 0, 0, 480, 272); // Create background quad for rendering.
|
||||
mBack = GameApp::CommonRes->GetQuad("back");
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
GuiBackground::GuiBackground()
|
||||
{
|
||||
JTexture* texture = GameApp::CommonRes->GetTexture("graphics/back.jpg");
|
||||
JTexture* texture = GameApp::CommonRes->GetTexture("backdrop.jpg");
|
||||
if (texture)
|
||||
quad = NEW JQuad(texture, 0, 0, 480, 255);
|
||||
else
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
GuiFrame::GuiFrame()
|
||||
{
|
||||
if (JTexture* woodTex = GameApp::CommonRes->GetTexture("graphics/wood.png"))
|
||||
if (JTexture* woodTex = GameApp::CommonRes->GetTexture("wood.png"))
|
||||
wood = NEW JQuad(woodTex, 0, 0, SCREEN_WIDTH, 16);
|
||||
else
|
||||
{
|
||||
@@ -12,7 +12,7 @@ GuiFrame::GuiFrame()
|
||||
GameApp::systemError += "Can't load wood texture : " __FILE__ "\n";
|
||||
}
|
||||
|
||||
if (JTexture* goldTex = GameApp::CommonRes->GetTexture("graphics/gold.png"))
|
||||
if (JTexture* goldTex = GameApp::CommonRes->GetTexture("gold.png"))
|
||||
{
|
||||
gold1 = NEW JQuad(goldTex, 0, 0, SCREEN_WIDTH, 6);
|
||||
gold2 = NEW JQuad(goldTex, 0, 6, SCREEN_WIDTH, 6);
|
||||
@@ -22,7 +22,7 @@ GuiFrame::GuiFrame()
|
||||
gold1 = gold2 = NULL;
|
||||
GameApp::systemError += "Can't load gold texture : " __FILE__ "\n";
|
||||
}
|
||||
if (JTexture* goldGlowTex = GameApp::CommonRes->GetTexture("graphics/goldglow.png"))
|
||||
if (JTexture* goldGlowTex = GameApp::CommonRes->GetTexture("goldglow.png"))
|
||||
goldGlow = NEW JQuad(goldGlowTex, 0, 1, SCREEN_WIDTH, 18);
|
||||
else
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ HandLimitor::HandLimitor(GuiHand* hand) : hand(hand) {}
|
||||
|
||||
GuiHand::GuiHand(CardSelector* cs, MTGHand* hand) : GuiLayer(), hand(hand), cs(cs)
|
||||
{
|
||||
JTexture* texture = GameApp::CommonRes->GetTexture("graphics/handback.png");
|
||||
JTexture* texture = GameApp::CommonRes->GetTexture("handback.png");
|
||||
if (texture)
|
||||
{
|
||||
back = NEW JQuad(texture, 0, 0, 101, 250);
|
||||
|
||||
@@ -20,7 +20,7 @@ static int colors[] =
|
||||
|
||||
GuiPhaseBar::GuiPhaseBar() : phase(GameObserver::GetInstance()->phaseRing->getCurrentPhase()), angle(0.0f)
|
||||
{
|
||||
JTexture* texture = GameApp::CommonRes->GetTexture("graphics/phasebar.png");
|
||||
JTexture* texture = GameApp::CommonRes->GetTexture("phasebar.png");
|
||||
if (texture)
|
||||
quad = NEW JQuad(texture, 0, 0, Width, Height);
|
||||
else
|
||||
|
||||
@@ -1,62 +1,62 @@
|
||||
#include "../include/config.h"
|
||||
#include "../include/MTGGamePhase.h"
|
||||
|
||||
|
||||
MTGGamePhase::MTGGamePhase(int id):ActionElement(id){
|
||||
animation = 0;
|
||||
currentState = -1;
|
||||
mFont= GameApp::CommonRes->GetJLBFont("graphics/simon");
|
||||
mFont->SetBase(0); // using 2nd font
|
||||
}
|
||||
|
||||
|
||||
void MTGGamePhase::Update(float dt){
|
||||
|
||||
int newState = GameObserver::GetInstance()->getCurrentGamePhase();
|
||||
if (newState != currentState){
|
||||
activeState = ACTIVE;
|
||||
animation = 4;
|
||||
currentState = newState;
|
||||
|
||||
switch (currentState){
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (animation > 0){
|
||||
// fprintf(stderr, "animation = %f", animation);
|
||||
animation -- ;
|
||||
}else{
|
||||
activeState = INACTIVE;
|
||||
animation = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool MTGGamePhase::CheckUserInput(u32 key){
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
if (activeState == INACTIVE){
|
||||
if ((PSP_CTRL_RTRIGGER == key) && game->currentActionPlayer == game->currentlyActing())
|
||||
{
|
||||
activeState = ACTIVE;
|
||||
game->userRequestNextGamePhase();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#include "../include/config.h"
|
||||
#include "../include/MTGGamePhase.h"
|
||||
|
||||
|
||||
MTGGamePhase::MTGGamePhase(int id):ActionElement(id){
|
||||
animation = 0;
|
||||
currentState = -1;
|
||||
mFont= GameApp::CommonRes->GetJLBFont("simon");
|
||||
mFont->SetBase(0); // using 2nd font
|
||||
}
|
||||
|
||||
|
||||
void MTGGamePhase::Update(float dt){
|
||||
|
||||
int newState = GameObserver::GetInstance()->getCurrentGamePhase();
|
||||
if (newState != currentState){
|
||||
activeState = ACTIVE;
|
||||
animation = 4;
|
||||
currentState = newState;
|
||||
|
||||
switch (currentState){
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (animation > 0){
|
||||
// fprintf(stderr, "animation = %f", animation);
|
||||
animation -- ;
|
||||
}else{
|
||||
activeState = INACTIVE;
|
||||
animation = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool MTGGamePhase::CheckUserInput(u32 key){
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
if (activeState == INACTIVE){
|
||||
if ((PSP_CTRL_RTRIGGER == key) && game->currentActionPlayer == game->currentlyActing())
|
||||
{
|
||||
activeState = ACTIVE;
|
||||
game->userRequestNextGamePhase();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
MTGGamePhase * MTGGamePhase::clone() const{
|
||||
MTGGamePhase * a = NEW MTGGamePhase(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
ostream& MTGGamePhase::toString(ostream& out) const
|
||||
{
|
||||
return out << "MTGGamePhase ::: animation " << animation << " ; currentState : " << currentState;
|
||||
}
|
||||
}
|
||||
|
||||
ostream& MTGGamePhase::toString(ostream& out) const
|
||||
{
|
||||
return out << "MTGGamePhase ::: animation " << animation << " ; currentState : " << currentState;
|
||||
}
|
||||
|
||||
@@ -1,111 +1,111 @@
|
||||
#include "../include/config.h"
|
||||
#include "../include/MTGGuiHand.h"
|
||||
#include "../include/CardGui.h"
|
||||
|
||||
MTGGuiHand::MTGGuiHand(GameObserver* game) : game(game) {
|
||||
mShowHand = HAND_HIDE;
|
||||
mAnimState = 0;
|
||||
currentPlayer = NULL;
|
||||
mFont = GameApp::CommonRes->GetJLBFont("graphics/simon");
|
||||
for (int i = 0; i < 2; i++){
|
||||
currentId[i] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MTGGuiHand::updateCards(){
|
||||
Player * player = GameObserver::GetInstance()->currentlyActing();
|
||||
if (player->isAI()) player = GameObserver::GetInstance()->players[0];
|
||||
int nb_cards = player->game->hand->nb_cards;
|
||||
if (mCount != nb_cards || player != currentPlayer ){ //if the number of cards has changed, then an update occured (is this test engouh ?)
|
||||
resetObjects();
|
||||
if (currentId[player->getId()] >= nb_cards) currentId[player->getId()] = nb_cards - 1;
|
||||
for (int i = 0;i<nb_cards; i++){
|
||||
CardView* object = NEW CardView(player->game->hand->cards[i], (float)450 - (nb_cards-i) *35, SCREEN_HEIGHT_F - mAnimState*60);
|
||||
Add(object);
|
||||
if ( i == currentId[player->getId()]) mCurr = i;
|
||||
}
|
||||
currentPlayer = player;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MTGGuiHand::Update(float dt){
|
||||
updateCards();
|
||||
for (int i=0;i<mCount;i++){
|
||||
if (mObjects[i]!=NULL){
|
||||
((CardGui *)mObjects[i])->y = SCREEN_HEIGHT - mAnimState*60;
|
||||
}
|
||||
}
|
||||
|
||||
if (mShowHand == HAND_SHOW_ANIMATION){
|
||||
mAnimState +=7 *dt;
|
||||
if (mAnimState > 1){
|
||||
mAnimState = 1;
|
||||
mShowHand = HAND_SHOW;
|
||||
}
|
||||
}else if(mShowHand == HAND_HIDE_ANIMATION){
|
||||
mAnimState -=7 *dt;
|
||||
if (mAnimState < 0){
|
||||
mAnimState = 0;
|
||||
mShowHand = HAND_HIDE;
|
||||
modal = false;
|
||||
}
|
||||
}
|
||||
|
||||
GuiCardsController::Update(dt);
|
||||
currentId[game->currentlyActing()->getId()] = mCurr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool MTGGuiHand::CheckUserInput(u32 key){
|
||||
if (PSP_CTRL_LTRIGGER == key) {
|
||||
if (mShowHand == HAND_HIDE){
|
||||
mShowHand = HAND_SHOW_ANIMATION;
|
||||
modal = true;
|
||||
}
|
||||
if (mShowHand == HAND_SHOW){
|
||||
mShowHand = HAND_HIDE_ANIMATION;
|
||||
}
|
||||
return true;
|
||||
}else if (PSP_CTRL_LEFT == key){
|
||||
//mGamePhase = NO_USER_INPUT;
|
||||
}
|
||||
|
||||
if (mShowHand == HAND_HIDE || currentPlayer->isAI()){
|
||||
return false;
|
||||
}else{
|
||||
// GuiCardsController::CheckUserInput(key);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void MTGGuiHand::Render(){
|
||||
if (mShowHand != HAND_HIDE){
|
||||
// if (currentPlayer && !currentPlayer->isAI()){
|
||||
RenderMessageBackground(440-mCount * 35 , SCREEN_HEIGHT - mAnimState*60 - 10, mCount * 35 + 20, 70);
|
||||
for (int i=0;i<mCount;i++){
|
||||
if (mObjects[i]!=NULL && i!=mCurr){
|
||||
mObjects[i]->Render();
|
||||
}
|
||||
}
|
||||
if (mCount && mObjects[mCurr] != NULL){
|
||||
mObjects[mCurr]->Render();
|
||||
// if (showBigCards) ((CardGui *)mObjects[mCurr])->RenderBig(10,-1,showBigCards-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "../include/config.h"
|
||||
#include "../include/MTGGuiHand.h"
|
||||
#include "../include/CardGui.h"
|
||||
|
||||
MTGGuiHand::MTGGuiHand(GameObserver* game) : game(game) {
|
||||
mShowHand = HAND_HIDE;
|
||||
mAnimState = 0;
|
||||
currentPlayer = NULL;
|
||||
mFont = GameApp::CommonRes->GetJLBFont("simon");
|
||||
for (int i = 0; i < 2; i++){
|
||||
currentId[i] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MTGGuiHand::updateCards(){
|
||||
Player * player = GameObserver::GetInstance()->currentlyActing();
|
||||
if (player->isAI()) player = GameObserver::GetInstance()->players[0];
|
||||
int nb_cards = player->game->hand->nb_cards;
|
||||
if (mCount != nb_cards || player != currentPlayer ){ //if the number of cards has changed, then an update occured (is this test engouh ?)
|
||||
resetObjects();
|
||||
if (currentId[player->getId()] >= nb_cards) currentId[player->getId()] = nb_cards - 1;
|
||||
for (int i = 0;i<nb_cards; i++){
|
||||
CardView* object = NEW CardView(player->game->hand->cards[i], (float)450 - (nb_cards-i) *35, SCREEN_HEIGHT_F - mAnimState*60);
|
||||
Add(object);
|
||||
if ( i == currentId[player->getId()]) mCurr = i;
|
||||
}
|
||||
currentPlayer = player;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MTGGuiHand::Update(float dt){
|
||||
updateCards();
|
||||
for (int i=0;i<mCount;i++){
|
||||
if (mObjects[i]!=NULL){
|
||||
((CardGui *)mObjects[i])->y = SCREEN_HEIGHT - mAnimState*60;
|
||||
}
|
||||
}
|
||||
|
||||
if (mShowHand == HAND_SHOW_ANIMATION){
|
||||
mAnimState +=7 *dt;
|
||||
if (mAnimState > 1){
|
||||
mAnimState = 1;
|
||||
mShowHand = HAND_SHOW;
|
||||
}
|
||||
}else if(mShowHand == HAND_HIDE_ANIMATION){
|
||||
mAnimState -=7 *dt;
|
||||
if (mAnimState < 0){
|
||||
mAnimState = 0;
|
||||
mShowHand = HAND_HIDE;
|
||||
modal = false;
|
||||
}
|
||||
}
|
||||
|
||||
GuiCardsController::Update(dt);
|
||||
currentId[game->currentlyActing()->getId()] = mCurr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool MTGGuiHand::CheckUserInput(u32 key){
|
||||
if (PSP_CTRL_LTRIGGER == key) {
|
||||
if (mShowHand == HAND_HIDE){
|
||||
mShowHand = HAND_SHOW_ANIMATION;
|
||||
modal = true;
|
||||
}
|
||||
if (mShowHand == HAND_SHOW){
|
||||
mShowHand = HAND_HIDE_ANIMATION;
|
||||
}
|
||||
return true;
|
||||
}else if (PSP_CTRL_LEFT == key){
|
||||
//mGamePhase = NO_USER_INPUT;
|
||||
}
|
||||
|
||||
if (mShowHand == HAND_HIDE || currentPlayer->isAI()){
|
||||
return false;
|
||||
}else{
|
||||
// GuiCardsController::CheckUserInput(key);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void MTGGuiHand::Render(){
|
||||
if (mShowHand != HAND_HIDE){
|
||||
// if (currentPlayer && !currentPlayer->isAI()){
|
||||
RenderMessageBackground(440-mCount * 35 , SCREEN_HEIGHT - mAnimState*60 - 10, mCount * 35 + 20, 70);
|
||||
for (int i=0;i<mCount;i++){
|
||||
if (mObjects[i]!=NULL && i!=mCurr){
|
||||
mObjects[i]->Render();
|
||||
}
|
||||
}
|
||||
if (mCount && mObjects[mCurr] != NULL){
|
||||
mObjects[mCurr]->Render();
|
||||
// if (showBigCards) ((CardGui *)mObjects[mCurr])->RenderBig(10,-1,showBigCards-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WALDORF - added method
|
||||
void MTGGuiHand::showHand (bool show)
|
||||
{
|
||||
if (show) mShowHand = HAND_SHOW;
|
||||
else mShowHand = HAND_HIDE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ MTGGuiPlay::MTGGuiPlay(GameObserver* game) : game(game){
|
||||
offset = 0;
|
||||
|
||||
|
||||
mPhaseBarTexture = GameApp::CommonRes->GetTexture("graphics/phasebar.png");
|
||||
mPhaseBarTexture = GameApp::CommonRes->GetTexture("phasebar.png");
|
||||
for (int i=0; i < 12; i++){
|
||||
phaseIcons[2*i] = NEW JQuad(mPhaseBarTexture, i*28, 0, 28, 28);
|
||||
phaseIcons[2*i + 1] = NEW JQuad(mPhaseBarTexture, i*28, 28, 28, 28);
|
||||
@@ -36,7 +36,7 @@ MTGGuiPlay::MTGGuiPlay(GameObserver* game) : game(game){
|
||||
mGlitter = NEW JQuad(mPhaseBarTexture, 392, 0, 5, 5);
|
||||
mGlitter->SetHotSpot(2.5,2.5);
|
||||
mGlitterAlpha = -1;
|
||||
mFont= GameApp::CommonRes->GetJLBFont("graphics/simon");
|
||||
mFont= GameApp::CommonRes->GetJLBFont("simon");
|
||||
|
||||
//load all the icon images
|
||||
mIcons[Constants::MTG_COLOR_ARTIFACT] = GameApp::CommonRes->GetQuad("c_artifact");
|
||||
@@ -50,14 +50,14 @@ MTGGuiPlay::MTGGuiPlay(GameObserver* game) : game(game){
|
||||
mIcons[i]->SetHotSpot(16,16);
|
||||
}
|
||||
|
||||
mBgTex = GameApp::CommonRes->GetTexture("graphics/background.png");
|
||||
mBgTex = GameApp::CommonRes->GetTexture("background.png");
|
||||
if (mBgTex) mBg = NEW JQuad(mBgTex, 0, 0, 480, 272);
|
||||
else {
|
||||
mBg = NULL;
|
||||
GameApp::systemError = "error Loading Texture mBgTex in MTGGuiPlay intialization";
|
||||
}
|
||||
|
||||
mBgTex2 = GameApp::CommonRes->GetTexture("graphics/back.jpg");
|
||||
mBgTex2 = GameApp::CommonRes->GetTexture("backdrop.jpg");
|
||||
if (mBgTex2){
|
||||
mBg2 = NEW JQuad(mBgTex2, 0, 0, 480, 255);
|
||||
for (int i= 0; i < 4; i++){
|
||||
|
||||
@@ -46,7 +46,7 @@ OptionItem::OptionItem( string _id, string _displayValue) {
|
||||
//Option Integer
|
||||
|
||||
void OptionInteger::Render(){
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
|
||||
if (hasFocus){
|
||||
mFont->SetColor(options[Metrics::OPTION_ITEM_TCH].asColor(ARGB(255,255,255,0)));
|
||||
}else{
|
||||
@@ -106,7 +106,7 @@ void OptionSelect::initSelections(){
|
||||
}
|
||||
|
||||
void OptionSelect::Render(){
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
|
||||
if (hasFocus){
|
||||
mFont->SetColor(options[Metrics::OPTION_ITEM_TCH].asColor(ARGB(255,255,255,0)));
|
||||
}else{
|
||||
@@ -148,7 +148,7 @@ ostream& OptionSelect::toString(ostream& out) const
|
||||
//OptionHeader
|
||||
|
||||
void OptionHeader::Render(){
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
|
||||
mFont->SetColor(options[Metrics::OPTION_HEADER_TC].asColor());
|
||||
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
@@ -157,7 +157,7 @@ void OptionHeader::Render(){
|
||||
}
|
||||
|
||||
void OptionText::Render(){
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
|
||||
mFont->SetScale(.8);
|
||||
mFont->SetColor(options[Metrics::OPTION_TEXT_TC].asColor());
|
||||
|
||||
@@ -248,7 +248,7 @@ void OptionProfile::populate(){
|
||||
|
||||
void OptionProfile::Render(){
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
|
||||
mFont->SetScale(1);
|
||||
int spacing = 2+(int)mFont->GetHeight();
|
||||
|
||||
@@ -432,7 +432,7 @@ void OptionsList::Render(){
|
||||
|
||||
//List is empty.
|
||||
if (!nbitems && failMsg != ""){
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
|
||||
mFont->SetColor(options[Metrics::MSG_FAIL_TC].asColor(ARGB(255,155,155,155)));
|
||||
mFont->DrawString(failMsg.c_str(),SCREEN_WIDTH/2, 40, JGETEXT_RIGHT);
|
||||
return;
|
||||
@@ -568,7 +568,7 @@ void OptionsMenu::Add(OptionsList * tab){
|
||||
}
|
||||
|
||||
void OptionsMenu::Render(){
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
|
||||
|
||||
if (!nbitems){
|
||||
mFont->DrawString("NO OPTIONS AVAILABLE",SCREEN_WIDTH/2, 5, JGETEXT_RIGHT);
|
||||
@@ -710,7 +710,7 @@ void OptionsList::cancelSubmode()
|
||||
|
||||
void OptionString::Render(){
|
||||
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
|
||||
if (hasFocus){
|
||||
mFont->SetColor(options[Metrics::OPTION_ITEM_TCH].asColor(ARGB(255,255,255,0)));
|
||||
}else{
|
||||
|
||||
@@ -43,10 +43,10 @@ SimpleMenu::SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int
|
||||
|
||||
JRenderer* renderer = JRenderer::GetInstance();
|
||||
|
||||
if (!spadeLTex) spadeLTex= renderer->LoadTexture(options.themeGraphic("spade_ul.png").c_str(), TEX_TYPE_USE_VRAM);
|
||||
if (!spadeRTex) spadeRTex = renderer->LoadTexture(options.themeGraphic("spade_ur.png").c_str(), TEX_TYPE_USE_VRAM);
|
||||
if (!spadeLTex) spadeLTex= GameApp::CommonRes->LoadTexture("spade_ul.png", TEX_TYPE_USE_VRAM);
|
||||
if (!spadeRTex) spadeRTex = GameApp::CommonRes->LoadTexture("spade_ur.png", TEX_TYPE_USE_VRAM);
|
||||
if (!jewelTex) jewelTex= renderer->CreateTexture(5, 5, TEX_TYPE_USE_VRAM);
|
||||
if (!sideTex) sideTex = renderer->LoadTexture(options.themeGraphic("menuside.png").c_str(), TEX_TYPE_USE_VRAM);
|
||||
if (!sideTex) sideTex = GameApp::CommonRes->LoadTexture("menuside.png", TEX_TYPE_USE_VRAM);
|
||||
if (NULL == spadeL) spadeL = NEW JQuad(spadeLTex, 2, 1, 16, 13);
|
||||
if (NULL == spadeR) spadeR = NEW JQuad(spadeRTex, 2, 1, 16, 13);
|
||||
if (NULL == jewel) jewel = NEW JQuad(jewelTex, 1, 1, 3, 3);
|
||||
@@ -54,8 +54,8 @@ if (NULL == spadeL) spadeL = NEW JQuad(spadeLTex, 2, 1, 16, 13);
|
||||
|
||||
if (NULL == titleFont)
|
||||
{
|
||||
GameApp::CommonRes->LoadJLBFont(options.themeGraphic("smallface"), 7);
|
||||
titleFont = GameApp::CommonRes->GetJLBFont(options.themeGraphic("smallface"));
|
||||
GameApp::CommonRes->LoadJLBFont("smallface", 7);
|
||||
titleFont = GameApp::CommonRes->GetJLBFont("smallface");
|
||||
}
|
||||
if (NULL == stars) stars = NEW hgeParticleSystem("graphics/stars.psi", GameApp::CommonRes->GetQuad("stars"));
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ string SimplePad::Finish() {
|
||||
|
||||
void SimplePad::Render(){
|
||||
//This could use some cleaning up to make margins more explicit
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
|
||||
|
||||
int offX = 0, offY = 0;
|
||||
int kH = mFont->GetHeight();
|
||||
|
||||
209
projects/mtg/src/WResourceManager.cpp
Normal file
209
projects/mtg/src/WResourceManager.cpp
Normal file
@@ -0,0 +1,209 @@
|
||||
#include "../include/config.h"
|
||||
#include "../include/utils.h"
|
||||
#include "../include/GameOptions.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
#include <JGE.h>
|
||||
#include "../include/WResourceManager.h"
|
||||
|
||||
JResourceManager *WResourceManager::jrm = NEW JResourceManager();
|
||||
|
||||
WResourceManager::WResourceManager(){
|
||||
}
|
||||
WResourceManager::~WResourceManager(){
|
||||
}
|
||||
|
||||
string WResourceManager::graphicsFile(const string filename, const string specific)
|
||||
{
|
||||
char buf[512];
|
||||
|
||||
//Check the specific location, if any.
|
||||
if(specific != ""){
|
||||
sprintf(buf,"%s/%s",specific.c_str(),filename.c_str());
|
||||
if(fileOK(buf,true))
|
||||
return buf;
|
||||
}
|
||||
|
||||
//Check the theme folder.
|
||||
string theme = options[Options::ACTIVE_THEME].str;
|
||||
std::transform(theme.begin(), theme.end(), theme.begin(), ::tolower);
|
||||
|
||||
if(theme != "" || theme != "default"){
|
||||
sprintf(buf,"themes/%s/%s",theme.c_str(),filename.c_str());
|
||||
if(fileOK(buf,true))
|
||||
return buf;
|
||||
}
|
||||
|
||||
//Failure. Check mode graphics
|
||||
string mode = options[Options::ACTIVE_MODE].str;
|
||||
std::transform(mode.begin(), mode.end(), mode.begin(), ::tolower);
|
||||
|
||||
if(mode != "" && mode != "defualt"){
|
||||
sprintf(buf,"modes/graphics/%s",mode,filename.c_str());
|
||||
if(fileOK(buf,true))
|
||||
return buf;
|
||||
}
|
||||
|
||||
//Failure. Check graphics
|
||||
char graphdir[512];
|
||||
sprintf(graphdir,"graphics/%s",filename.c_str());
|
||||
if(fileOK(graphdir,true))
|
||||
return graphdir;
|
||||
|
||||
//Failure. Check sets.
|
||||
sprintf(buf,"sets/%s",filename.c_str());
|
||||
if(fileOK(buf,true))
|
||||
return buf;
|
||||
|
||||
//Complete abject failure. Probably a crash...
|
||||
return graphdir;
|
||||
}
|
||||
|
||||
string WResourceManager::musicFile(const string filename, const string specific)
|
||||
{
|
||||
char buf[512];
|
||||
|
||||
//Check the specific location, if any.
|
||||
if(specific != ""){
|
||||
sprintf(buf,"%s/%s",specific.c_str(),filename.c_str());
|
||||
if(fileOK(buf,true))
|
||||
return buf;
|
||||
}
|
||||
|
||||
//Check the theme folder.
|
||||
string theme = options[Options::ACTIVE_THEME].str;
|
||||
std::transform(theme.begin(), theme.end(), theme.begin(), ::tolower);
|
||||
|
||||
if(theme != "" || theme != "default"){
|
||||
sprintf(buf,"themes/%s/sound/%s",theme.c_str(),filename.c_str());
|
||||
if(fileOK(buf,true))
|
||||
return buf;
|
||||
}
|
||||
|
||||
//Failure. Check mode
|
||||
string mode = options[Options::ACTIVE_MODE].str;
|
||||
std::transform(mode.begin(), mode.end(), mode.begin(), ::tolower);
|
||||
|
||||
if(mode != "" && mode != "defualt"){
|
||||
sprintf(buf,"modes/sound/%s",mode,filename.c_str());
|
||||
if(fileOK(buf,true))
|
||||
return buf;
|
||||
}
|
||||
|
||||
//Failure. Check sound
|
||||
char defdir[512];
|
||||
sprintf(defdir,"sound/%s",filename.c_str());
|
||||
if(fileOK(defdir,true))
|
||||
return defdir;
|
||||
|
||||
//Complete abject failure. Probably a crash...
|
||||
return defdir;
|
||||
}
|
||||
|
||||
string WResourceManager::sfxFile(const string filename, const string specific)
|
||||
{
|
||||
char buf[512];
|
||||
|
||||
//Check the specific location, if any.
|
||||
if(specific != ""){
|
||||
sprintf(buf,"%s/%s",specific.c_str(),filename.c_str());
|
||||
if(fileOK(buf,true))
|
||||
return buf;
|
||||
}
|
||||
|
||||
//Check the theme folder.
|
||||
string theme = options[Options::ACTIVE_THEME].str;
|
||||
std::transform(theme.begin(), theme.end(), theme.begin(), ::tolower);
|
||||
|
||||
if(theme != "" || theme != "default"){
|
||||
sprintf(buf,"themes/%s/sound/sfx/%s",theme.c_str(),filename.c_str());
|
||||
if(fileOK(buf,true))
|
||||
return buf;
|
||||
}
|
||||
|
||||
//Failure. Check mode
|
||||
string mode = options[Options::ACTIVE_MODE].str;
|
||||
std::transform(mode.begin(), mode.end(), mode.begin(), ::tolower);
|
||||
if(mode != "" && mode != "defualt"){
|
||||
sprintf(buf,"modes/sound/sfx/%s",mode,filename.c_str());
|
||||
if(fileOK(buf,true))
|
||||
return buf;
|
||||
}
|
||||
|
||||
//Failure. Check sound
|
||||
char defdir[512];
|
||||
sprintf(defdir,"sound/sfx/%s",filename.c_str());
|
||||
if(fileOK(defdir,true))
|
||||
return defdir;
|
||||
|
||||
//Complete abject failure. Probably a crash...
|
||||
return defdir;
|
||||
}
|
||||
|
||||
bool WResourceManager::fileOK(string filename, bool relative){
|
||||
|
||||
if(relative){
|
||||
char buf[512];
|
||||
sprintf(buf,RESPATH"/%s",filename.c_str());
|
||||
return fileExists(buf);
|
||||
}
|
||||
|
||||
return fileExists(filename.c_str());
|
||||
}
|
||||
|
||||
int WResourceManager::CreateTexture(const string &textureName) {
|
||||
return jrm->CreateTexture(graphicsFile(textureName));
|
||||
}
|
||||
JTexture* WResourceManager::GetTexture(const string &textureName) {
|
||||
return jrm->GetTexture(graphicsFile(textureName));
|
||||
}
|
||||
JTexture* WResourceManager::GetTexture(int id) {
|
||||
return jrm->GetTexture(id);
|
||||
}
|
||||
|
||||
int WResourceManager::CreateQuad(const string &quadName, const string &textureName, float x, float y, float width, float height){
|
||||
return jrm->CreateQuad(quadName, graphicsFile(textureName), x, y, width, height);
|
||||
}
|
||||
JQuad* WResourceManager::GetQuad(const string &quadName){
|
||||
return jrm->GetQuad(quadName);
|
||||
}
|
||||
JQuad* WResourceManager::GetQuad(int id){
|
||||
return jrm->GetQuad(id);
|
||||
}
|
||||
|
||||
int WResourceManager::LoadJLBFont(const string &fontName, int height){
|
||||
return jrm->LoadJLBFont(graphicsFile(fontName), height);
|
||||
}
|
||||
JLBFont* WResourceManager::GetJLBFont(const string &fontName){
|
||||
return jrm->GetJLBFont(graphicsFile(fontName));
|
||||
}
|
||||
|
||||
JLBFont* WResourceManager::GetJLBFont(int id){
|
||||
return jrm->GetJLBFont(id);
|
||||
}
|
||||
|
||||
int WResourceManager::LoadMusic(const string &musicName){
|
||||
return jrm->LoadMusic(musicFile(musicName));
|
||||
}
|
||||
JMusic* WResourceManager::GetMusic(const string &musicName){
|
||||
return jrm->GetMusic(musicFile(musicName));
|
||||
}
|
||||
JMusic* WResourceManager::GetMusic(int id){
|
||||
return jrm->GetMusic(id);
|
||||
}
|
||||
|
||||
int WResourceManager::LoadSample(const string &sampleName){
|
||||
return jrm->LoadSample(sfxFile(sampleName));
|
||||
}
|
||||
JSample* WResourceManager::GetSample(const string &sampleName){
|
||||
return jrm->GetSample(sfxFile(sampleName));
|
||||
}
|
||||
JSample* WResourceManager::GetSample(int id){
|
||||
return jrm->GetSample(id);
|
||||
}
|
||||
|
||||
JTexture* WResourceManager::LoadTexture(const char* filename, int mode, int textureFormat){
|
||||
return JRenderer::GetInstance()->LoadTexture(graphicsFile(filename).c_str(),mode,textureFormat);
|
||||
}
|
||||
@@ -564,6 +564,10 @@
|
||||
RelativePath=".\src\WEvent.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\WResourceManager.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Misc"
|
||||
@@ -921,6 +925,10 @@
|
||||
RelativePath=".\include\WEvent.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\WResourceManager.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
|
||||
Reference in New Issue
Block a user