Erwan
- Updated options system
This commit is contained in:
@@ -89,7 +89,7 @@ int Spell::resolve(){
|
||||
source->controller()->game->putInPlay(source);
|
||||
|
||||
//Play SFX
|
||||
if (GameOptions::GetInstance()->values[OPTIONS_SFXVOLUME] > 0){
|
||||
if (GameOptions::GetInstance()->values[OPTIONS_SFXVOLUME].getIntValue() > 0){
|
||||
JSample * sample = source->getSample();
|
||||
if (sample){
|
||||
JSoundSystem::GetInstance()->PlaySample(sample);
|
||||
|
||||
@@ -135,7 +135,7 @@ void GameObserver::userRequestNextGamePhase(){
|
||||
if (getCurrentTargetChooser()) return;
|
||||
if (mLayers->combatLayer()->remainingDamageSteps) return;
|
||||
//TODO CHECK POSSIBILITY
|
||||
if (opponent()->isAI() || GameOptions::GetInstance()->values[OPTIONS_INTERRUPTATENDOFPHASE_OFFSET+currentGamePhase]){
|
||||
if (opponent()->isAI() || GameOptions::GetInstance()->values[GameOptions::phaseInterrupts[currentGamePhase]].getIntValue()){
|
||||
mLayers->stackLayer()->AddNextGamePhase();
|
||||
}else{
|
||||
nextGamePhase();
|
||||
|
||||
@@ -4,6 +4,32 @@
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
#include <JGE.h>
|
||||
|
||||
const char* GameOptions::phaseInterrupts[] = {
|
||||
"interrupt ---",
|
||||
"interrupt Untap",
|
||||
"interrupt Upkeep",
|
||||
"interrupt Draw",
|
||||
"interrupt Main phase 1",
|
||||
"interrupt Combat begins",
|
||||
"interrupt Attackers",
|
||||
"interrupt Blockers",
|
||||
"interrupt Combat damage",
|
||||
"interrupt Combat ends",
|
||||
"interrupt Main phase 2",
|
||||
"interrupt End of turn",
|
||||
"interrupt Cleanup",
|
||||
"interrupt ---"
|
||||
};
|
||||
|
||||
GameOption::GameOption(int _value){
|
||||
value = _value;
|
||||
}
|
||||
|
||||
int GameOption::getIntValue(){
|
||||
return value;
|
||||
}
|
||||
|
||||
GameOptions* GameOptions::mInstance = NULL;
|
||||
|
||||
@@ -14,9 +40,6 @@ GameOptions * GameOptions::GetInstance(){
|
||||
}
|
||||
|
||||
GameOptions::GameOptions(){
|
||||
for(int i = 0; i < MAX_OPTIONS; i++){
|
||||
values[i] = 0;
|
||||
}
|
||||
load();
|
||||
}
|
||||
|
||||
@@ -24,12 +47,10 @@ int GameOptions::load(){
|
||||
std::ifstream file(OPTIONS_SAVEFILE);
|
||||
std::string s;
|
||||
if(file){
|
||||
for (int i = 0; i < MAX_OPTIONS; i++){
|
||||
if(std::getline(file,s)){
|
||||
values[i] = atoi(s.c_str());
|
||||
}else{
|
||||
//TODO error management
|
||||
}
|
||||
while(std::getline(file,s)){
|
||||
int found =s.find("=");
|
||||
string name = s.substr(0,found);
|
||||
values[name] = GameOption(atoi(s.substr(found+1).c_str()));
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
@@ -38,10 +59,11 @@ int GameOptions::load(){
|
||||
|
||||
int GameOptions::save(){
|
||||
std::ofstream file(OPTIONS_SAVEFILE);
|
||||
char writer[10];
|
||||
char writer[1024];
|
||||
if (file){
|
||||
for (int i = 0; i < MAX_OPTIONS; i++){
|
||||
sprintf(writer,"%i\n", values[i]);
|
||||
map<string, GameOption>::iterator it;
|
||||
for ( it=values.begin() ; it != values.end(); it++ ){
|
||||
sprintf(writer,"%s=%d\n", it->first.c_str(), it->second.getIntValue());
|
||||
file<<writer;
|
||||
}
|
||||
file.close();
|
||||
|
||||
@@ -133,12 +133,12 @@ void GameStateMenu::Start(){
|
||||
JRenderer::GetInstance()->EnableVSync(true);
|
||||
subMenuController = NULL;
|
||||
|
||||
if (GameApp::HasMusic && !GameApp::music && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME] > 0){
|
||||
if (GameApp::HasMusic && !GameApp::music && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME].getIntValue() > 0){
|
||||
GameApp::music = JSoundSystem::GetInstance()->LoadMusic("sound/Track0.mp3");
|
||||
JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true);
|
||||
}
|
||||
|
||||
if (GameApp::HasMusic && GameApp::music && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME] == 0){
|
||||
if (GameApp::HasMusic && GameApp::music && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME].getIntValue() == 0){
|
||||
JSoundSystem::GetInstance()->StopMusic(GameApp::music);
|
||||
SAFE_DELETE(GameApp::music);
|
||||
}
|
||||
|
||||
@@ -67,9 +67,9 @@ void GameStateOptions::Render()
|
||||
|
||||
const char * const CreditsText[] = {
|
||||
"Wagic, The Homebrew ?! by WilLoW",
|
||||
"This is a work in progress and it contains bugs, deal with it",
|
||||
"This is a work in progress and it contains bugs",
|
||||
"updates on http://www.wololo.net/wagic",
|
||||
"Many thanks to Abrasax and J for their help in this release",
|
||||
"Many thanks to J for his help in this release, and to all card creators",
|
||||
"",
|
||||
"Developped with the JGE++ Library (http://jge.khors.com)",
|
||||
"",
|
||||
|
||||
@@ -90,7 +90,7 @@ void MTGPlayerCards::putInGraveyard(MTGCardInstance * card){
|
||||
void MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone * from, MTGGameZone * to){
|
||||
if (from->removeCard(card)){
|
||||
|
||||
if (GameOptions::GetInstance()->values[OPTIONS_SFXVOLUME] > 0){
|
||||
if (GameOptions::GetInstance()->values[OPTIONS_SFXVOLUME].getIntValue() > 0){
|
||||
if (to == graveyard){
|
||||
if (card->isACreature()){
|
||||
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/graveyard.wav");
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
#include "../include/GameOptions.h"
|
||||
|
||||
|
||||
OptionItem::OptionItem(int _id, string _displayValue, int _maxValue, int _increment):JGuiObject(0){
|
||||
OptionItem::OptionItem(string _id, string _displayValue, int _maxValue, int _increment):JGuiObject(0){
|
||||
id = _id;
|
||||
maxValue = _maxValue;
|
||||
increment = _increment;
|
||||
displayValue = _displayValue;
|
||||
value = GameOptions::GetInstance()->values[id];
|
||||
value = GameOptions::GetInstance()->values[id].getIntValue();
|
||||
hasFocus = 0;
|
||||
x = 0;
|
||||
y = 0;
|
||||
@@ -20,7 +20,10 @@ OptionItem::~OptionItem(){
|
||||
}
|
||||
|
||||
void OptionItem::setData(){
|
||||
GameOptions::GetInstance()->values[id] = value;
|
||||
GameOptions::GetInstance()->values[id] = GameOption(value);
|
||||
char buf[4096];
|
||||
sprintf(buf, "Option: %s => %i\n", id.c_str(), GameOptions::GetInstance()->values[id].getIntValue());
|
||||
OutputDebugString(buf);
|
||||
}
|
||||
|
||||
void OptionItem::Render(){
|
||||
|
||||
Reference in New Issue
Block a user