diff --git a/Aquaria/AnimationEditor.cpp b/Aquaria/AnimationEditor.cpp index de82ab2..1c987a2 100644 --- a/Aquaria/AnimationEditor.cpp +++ b/Aquaria/AnimationEditor.cpp @@ -232,11 +232,11 @@ void AnimationEditor::applyState() editSprite->position = Vector(400,300); - addAction(MakeFunctionEvent(AnimationEditor, lmbu), ActionMapper::MOUSE_BUTTON_LEFT, 0); - addAction(MakeFunctionEvent(AnimationEditor, lmbd), ActionMapper::MOUSE_BUTTON_LEFT, 1); - addAction(MakeFunctionEvent(AnimationEditor, rmbu), ActionMapper::MOUSE_BUTTON_RIGHT, 0); - addAction(MakeFunctionEvent(AnimationEditor, rmbd), ActionMapper::MOUSE_BUTTON_RIGHT, 1); - addAction(MakeFunctionEvent(AnimationEditor, mmbd), ActionMapper::MOUSE_BUTTON_MIDDLE, 1); + addAction(MakeFunctionEvent(AnimationEditor, lmbu), MOUSE_BUTTON_LEFT, 0); + addAction(MakeFunctionEvent(AnimationEditor, lmbd), MOUSE_BUTTON_LEFT, 1); + addAction(MakeFunctionEvent(AnimationEditor, rmbu), MOUSE_BUTTON_RIGHT, 0); + addAction(MakeFunctionEvent(AnimationEditor, rmbd), MOUSE_BUTTON_RIGHT, 1); + addAction(MakeFunctionEvent(AnimationEditor, mmbd), MOUSE_BUTTON_MIDDLE, 1); addAction(MakeFunctionEvent(AnimationEditor, cloneBoneAhead), KEY_SPACE, 0); @@ -531,9 +531,8 @@ void AnimationEditor::redo() } } -void AnimationEditor::action(int id, int state) +void AnimationEditor::action(int id, int state, int source) { - StateObject::action(id, state); if (editingBone && state) { if (dsq->isNested()) return; diff --git a/Aquaria/AquariaMenuItem.cpp b/Aquaria/AquariaMenuItem.cpp index 0f454fc..cdadcef 100644 --- a/Aquaria/AquariaMenuItem.cpp +++ b/Aquaria/AquariaMenuItem.cpp @@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "AquariaMenuItem.h" #include "DSQ.h" #include "Game.h" +#include "ActionInput.h" float AquariaGuiElement::guiMoveTimer = 0; AquariaGuiElement::GuiElements AquariaGuiElement::guiElements; @@ -671,7 +672,7 @@ void AquariaKeyConfig::onUpdate(float dt) } else { - for (int i = ActionMapper::JOY1_BUTTON_0; i <= MAX_JOYSTICK_BTN; i++) + for (int i = JOY_BUTTON_0; i <= MAX_JOYSTICK_BTN; i++) { if (dsq->game->getKeyState(i)) { @@ -778,8 +779,8 @@ AquariaMenuItem::AquariaMenuItem() : Quad(), ActionMapper(), AquariaGuiElement() cull = false; followCamera = 1; - addAction(MakeFunctionEvent(AquariaMenuItem, onClick), ActionMapper::MOUSE_BUTTON_LEFT, 0); - addAction(MakeFunctionEvent(AquariaMenuItem, onClick), ActionMapper::MOUSE_BUTTON_RIGHT, 0); + addAction(MakeFunctionEvent(AquariaMenuItem, onClick), MOUSE_BUTTON_LEFT, 0); + addAction(MakeFunctionEvent(AquariaMenuItem, onClick), MOUSE_BUTTON_RIGHT, 0); renderQuad = false; } diff --git a/Aquaria/AquariaMenuItem.h b/Aquaria/AquariaMenuItem.h index fc8beb4..d62ecc9 100644 --- a/Aquaria/AquariaMenuItem.h +++ b/Aquaria/AquariaMenuItem.h @@ -84,6 +84,7 @@ public: bool useQuad(const std::string &tex); void useGlow(const std::string &tex, int w, int h); void useSound(const std::string &tex); + virtual void action(int actionID, int state, int source) {} virtual bool isCursorInMenuItem(); Vector getGuiPosition(); diff --git a/Aquaria/Avatar.cpp b/Aquaria/Avatar.cpp index debb5bc..0dacce2 100644 --- a/Aquaria/Avatar.cpp +++ b/Aquaria/Avatar.cpp @@ -4291,7 +4291,7 @@ Vector Avatar::getVectorToCursor(bool trueMouse) //return core->mouse.position - Vector(400,300); } -void Avatar::action(int id, int state) +void Avatar::action(int id, int state, int source) { if(dsq->game->isIgnoreAction((AquariaActions)id)) return; @@ -7015,54 +7015,11 @@ bool Avatar::checkWarpAreas() //dsq->fade(0, t); return true; } - } } } } } - - } - for (i = 0; i < dsq->game->warpAreas.size(); i++) - { - WarpArea *a = &dsq->game->warpAreas[i]; - if (a->radius) - { - Vector diff = a->position - this->position; - if (diff.getSquaredLength2D() < sqr(a->radius)) - { - if (canWarp) - { - dsq->game->warpToArea(a); - return false; - } - else - { - position = lastPosition; - vel = -diff; - return true; - } - } - } - else - { - if (position.x > a->position.x - a->w && position.x < a->position.x + a->w) - { - if (position.y > a->position.y - a->h && position.y < a->position.y + a->h) - { - if (canWarp) - { - dsq->game->warpToArea(a); - return false; - } - else - { - position = lastPosition; - vel = -vel*1.1f; - } - } - } - } } return false; } diff --git a/Aquaria/Avatar.h b/Aquaria/Avatar.h index cd5960c..42b8fc1 100644 --- a/Aquaria/Avatar.h +++ b/Aquaria/Avatar.h @@ -140,7 +140,7 @@ public: Avatar(); virtual ~Avatar(); void destroy(); - void action(int actionID, int state); + void action(int actionID, int state, int source); AvatarState state; float burst, burstTimer; float burstDelay; diff --git a/Aquaria/Continuity.cpp b/Aquaria/Continuity.cpp index 0cebb8b..8af2b4a 100644 --- a/Aquaria/Continuity.cpp +++ b/Aquaria/Continuity.cpp @@ -1521,10 +1521,6 @@ void Continuity::castSong(int num) dsq->game->avatar->changeForm(FORM_ENERGY); break; #ifndef AQUARIA_DEMO - case SONG_MAP: - if (dsq->game->autoMap) - dsq->game->autoMap->toggle(true); - break; case SONG_HEAL: // do heal effects @@ -1635,6 +1631,7 @@ void Continuity::castSong(int num) dsq->game->avatar->changeForm(FORM_FISH); break; case SONG_SONGDOOR1: + case SONG_MAP: break; #endif } @@ -2083,8 +2080,6 @@ void Continuity::applyWorldEffects(WorldType type, bool transition, bool affectM dsq->game->avatar->canWarp = false; - - dsq->game->backupSceneColor = dsq->game->sceneColor; dsq->game->sceneColor.interpolateTo(Vector(0.4, 0.8, 0.9), time); dsq->game->avatar->applyWorldEffects(type); } @@ -3479,16 +3474,8 @@ void Continuity::reset() dualFormMode = DUALFORM_LI; dualFormCharge = 0; - lastMenuPage = MENUPAGE_NONE; - lastOptionsMenuPage = MENUPAGE_NONE; - if (dsq->game) - { - dsq->game->currentMenuPage = MENUPAGE_NONE; - dsq->game->currentFoodPage = 0; - dsq->game->currentTreasurePage = 0; - dsq->game->recipeMenu.currentPage = 0; - } + dsq->game->onContinuityReset(); diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index 6f77f45..721aedf 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -651,10 +651,6 @@ void DSQ::debugMenu() { dsq->demo.clearRecordedFrames(); } - else if (c == 'M') - { - dsq->game->autoMap->toggle(!dsq->game->autoMap->isOn()); - } else if (c == 'H') { std::ostringstream os; @@ -831,7 +827,6 @@ This build is not yet final, and as such there are a couple things lacking. They fpsText = 0; cmDebug = 0; - routeShoulder = true; debugLog("DSQ init"); useFrameBuffer = false; @@ -3802,9 +3797,9 @@ void DSQ::watch(float t, int canQuit) } } -void DSQ::action(int id, int state) +void DSQ::action(int id, int state, int source) { - Core::action(id, state); + Core::action(id, state, source); if (id == ACTION_ESC && !state) { diff --git a/Aquaria/DSQ.h b/Aquaria/DSQ.h index 9cde5c5..613114a 100644 --- a/Aquaria/DSQ.h +++ b/Aquaria/DSQ.h @@ -174,15 +174,6 @@ typedef std::vector EntityContainer; #define FOR_ENTITIES(i) for (size_t i##_i = 0; dsq->entities[i##_i] != 0; ++i##_i) if (Entity **i = &dsq->entities[i##_i]) -enum MenuPage -{ - MENUPAGE_NONE = -1, - MENUPAGE_SONGS = 0, - MENUPAGE_FOOD = 1, - MENUPAGE_TREASURES = 2, - MENUPAGE_PETS = 3 -}; - enum WorldMapRevealMethod { REVEAL_UNSPECIFIED = -1, @@ -1115,8 +1106,6 @@ public: float poisonBitTime, poisonBitTimeAvatar; - MenuPage lastMenuPage, lastOptionsMenuPage; - enum { DUALFORM_NAIJA = 0, DUALFORM_LI = 1 }; int dualFormMode, dualFormCharge; @@ -1249,7 +1238,7 @@ public: void nag(NagType type); - void action(int id, int state); + void action(int id, int state, int source); void title(bool fadeMusic=true); @@ -1489,8 +1478,6 @@ public: void centerText(const std::string &text); void centerMessage(const std::string &text, float y=300, int type=0); - bool routeShoulder; - void toggleVersionLabel(bool on); void onConfirmYes(); diff --git a/Aquaria/Entity.h b/Aquaria/Entity.h index 114210e..b13499a 100644 --- a/Aquaria/Entity.h +++ b/Aquaria/Entity.h @@ -284,8 +284,6 @@ public: void freeze(float time); - virtual void onSceneFlipped() {} - bool isNearObstruction(int sz, int type=0, TileVector *hitTile=0); enum diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index a052815..d1a282d 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -37,30 +37,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Shot.h" #include "Web.h" #include "StatsAndAchievements.h" +#include "InGameMenu.h" -#include "ToolTip.h" - -std::vector allowedMaps; - -Vector worldLeftCenter(217,250), worldRightCenter(575, 250); -Vector opt_save_original = Vector(350, 350), opt_cancel_original = Vector(450, 350); +static const float MENUPAGETRANSTIME = 0.2; const float bgSfxVol = 1.0; -const float MENUPAGETRANSTIME = 0.2; // 0.2 - -const int foodPageSize = 16; -const int treasurePageSize = 16; - -int FoodSlot::foodSlotIndex = -1; - -int selectedTreasureFlag = -1; - -std::vector foodHolders; -std::vector petSlots; +unsigned char Game::grid[MAX_GRID][MAX_GRID]; -std::string getSceneFilename(const std::string &scene) +static std::string getSceneFilename(const std::string &scene) { if (dsq->mod.isActive()) return std::string(dsq->mod.getPath() + "maps/" + scene + ".xml"); @@ -69,860 +55,6 @@ std::string getSceneFilename(const std::string &scene) return ""; } -PetSlot::PetSlot(int pet) : AquariaGuiQuad() -{ - PetData *p = dsq->continuity.getPetData(pet); - if (p) - { - std::string fn = "collectibles/egg-" + p->namePart; - setTexture(fn); - } - scale = Vector(0.9, 0.9); - petidx = pet; - mouseDown = false; - petFlag = FLAG_PET_NAMESTART + petidx; - wasSlot = false; -} - -void PetSlot::onUpdate(float dt) -{ - AquariaGuiQuad::onUpdate(dt); - - if (!dsq->continuity.getFlag(petFlag)) - { - if (!wasSlot) - { - setTexture("gui/wok"); - setWidthHeight(80); - wasSlot = true; - } - //alphaMod = 0; - return; - } - else - { - alphaMod = 1; - - if (wasSlot) - { - PetData *p = dsq->continuity.getPetData(petidx); - if (p) - { - std::string fn = "collectibles/egg-" + p->namePart; - setTexture(fn); - } - wasSlot = false; - } - } - - if (dsq->continuity.getFlag(FLAG_PET_ACTIVE) == petFlag) - { - color = Vector(1,1,1); - } - else - color = Vector(0.5, 0.5, 0.5); - - if (alpha.x < 1) return; - - if ((core->mouse.position - getWorldPosition()).isLength2DIn(32)) - { - scale.interpolateTo(Vector(1.2, 1.2), 0.1); - - if (core->mouse.buttons.left && !mouseDown) - { - mouseDown = true; - } - else if (!core->mouse.buttons.left && mouseDown) - { - dsq->sound->playSfx("click"); - - if (dsq->continuity.getFlag(FLAG_PET_ACTIVE) == petFlag) - { - dsq->game->setActivePet(0); - dsq->sound->playSfx("pet-on"); - } - else - { - dsq->game->setActivePet(FLAG_PET_NAMESTART + petidx); - dsq->sound->playSfx("pet-off"); - } - mouseDown = false; - } - } - else - { - mouseDown = false; - scale.interpolateTo(Vector(0.9, 0.9), 0.1); - } -} - -FoodHolder::FoodHolder(int slot, bool trash) : Quad(), slot(slot), trash(trash) -{ - foodHolderIngredient = 0; - buttonDown = false; - - //setTexture("Gui/wok"); - renderQuad = false; - - wok = new Quad; - if (trash) - wok->setTexture("gui/wok-drop"); - else - wok->setTexture("gui/wok"); - addChild(wok, PM_POINTER, RBP_ON); - - ing = new Quad; - ing->renderQuad = false; - addChild(ing, PM_POINTER); - - lid = new Quad("gui/wok-lid", Vector(0,0)); - lid->alpha = 0; - lid->alphaMod = 0.5; - addChild(lid, PM_POINTER); -} - -void FoodHolder::animateLid(bool down, bool longAnim) -{ - float t = 0.2; - - if (!longAnim) - { - t = 0.1; - } - - if (down) - { - dsq->sound->playSfx("bubble-lid"); - lid->alpha.interpolateTo(1, t); - dsq->main(t); - } - else - { - lid->alpha.interpolateTo(0, t); - } -} - -bool FoodHolder::isTrash() -{ - return trash; -} - -bool FoodHolder::isEmpty() -{ - return (foodHolderIngredient == 0); -} - -IngredientData *FoodHolder::getIngredient() -{ - return foodHolderIngredient; -} - -void FoodHolder::setIngredient(IngredientData *i, bool effects) -{ - IngredientData *oldi = foodHolderIngredient; - foodHolderIngredient = i; - - if (oldi) { - if (oldi->held > 0) - oldi->held --; - oldi->amount ++; - } - - if (!i) - { - //ing->scale.interpolateTo(Vector(0,0), 0.1); - ing->renderQuad = false; - //setTexture("Gui/wok"); - if (oldi && effects) - { - core->sound->playSfx("Drop"); - } - - game->enqueuePreviewRecipe(); - } - else - { - i->held ++; - if (i->amount > 0) - i->amount --; - - ing->setTexture("Ingredients/" + i->gfx); - ing->renderQuad = true; - if (effects) - { - core->sound->playSfx("Wok"); - - ing->scale.ensureData(); - ing->scale.data->path.clear(); - ing->scale.data->path.addPathNode(Vector(1,1),0); - ing->scale.data->path.addPathNode(Vector(1.25,1.25), 0.2); - ing->scale.data->path.addPathNode(Vector(1,1),1); - ing->scale.startPath(0.5); - } - - game->enqueuePreviewRecipe(); - } -} - -void Game::enqueuePreviewRecipe() -{ - enqueuedPreviewRecipe = 1; -} - -void Game::updatePreviewRecipe() -{ - const float t = 0.2; - - updateCookList(); - - if (cookList.size() < 2 || recipeMenu.on){ - previewRecipe->alpha.interpolateTo(0, t); - } - else{ - Recipe *r = findRecipe(cookList); - - IngredientData *data=0; - - if (r && r->isKnown()) - { - data = dsq->continuity.getIngredientDataByName(r->result); - previewRecipe->setTexture("ingredients/"+data->gfx); - } - else - { - previewRecipe->setTexture("gui/question-mark"); - } - - previewRecipe->alpha.interpolateTo(1, t); - - } -} - -void FoodHolder::dropFood() -{ - if (foodHolderIngredient) - { - setIngredient(0); - dsq->game->refreshFoodSlots(true); - } -} - -void FoodHolder::onUpdate(float dt) -{ - Quad::onUpdate(dt); - - if (!dsq->game->recipeMenu.on && foodHolderIngredient) - { - if ((core->mouse.position - getWorldPosition()).isLength2DIn(20)) - { - if (!buttonDown && core->mouse.buttons.left) - { - dropFood(); - buttonDown = true; - } - } - - if (!buttonDown && core->mouse.buttons.left) - buttonDown = true; - if (buttonDown && !core->mouse.buttons.left) - buttonDown = false; - } -} - -FoodSlot::FoodSlot(int slot) : AquariaGuiQuad(), slot(slot) -{ - doubleClickDelay = 0; - - right = false; - - renderQuad = false; - - label = new DebugFont(8, ""); - label->position = Vector(-2, 9); - addChild(label, PM_POINTER); - - inCookSlot = false; - - ingredient = 0; - - lastIngredient = 0; - lastAmount = 0; - - grabTime = 0; - - foodSlotIndex = -1; - scaleFactor = 1; - - shareAlphaWithChildren = 1; - - rmb = 0; - -} - -void FoodSlot::setOriginalPosition(const Vector &op) -{ - originalPosition = op; -} - -void FoodSlot::toggle(bool f) -{ - if (f) - { - alpha = 1; - alphaMod = 1; - label->alpha = 1; - } - else - { - alpha = 0; - alphaMod = 0; - label->alpha = 0; - } -} - -void FoodSlot::refresh(bool effects) -{ - int offset = game->currentFoodPage*foodPageSize; - IngredientData *i = dsq->continuity.getIngredientHeldByIndex(offset+slot); - if (i) - { - ingredient = i; - - if (i->amount > 0) - { - std::ostringstream os; - if (i->amount > 1) - os << i->amount << "/" << i->maxAmount; - label->setText(os.str()); - setTexture("Ingredients/" + i->gfx); - renderQuad = true; - } - else - { - label->setText(""); - renderQuad = true; - - setTexture("gui/wok"); - setWidthHeight(64); - } - } - else - { - ingredient = 0; - - label->setText(""); - renderQuad = true; - setTexture("gui/wok"); - setWidthHeight(64); - } - - scale.interpolateTo(Vector(1,1)*scaleFactor,0.001); - - if (ingredient != 0 && (i != lastIngredient || (i && i->amount != lastAmount))) - { - if (effects) - { - scale.ensureData(); - scale.data->path.clear(); - scale.data->path.addPathNode(Vector(1,1)*scaleFactor,0); - scale.data->path.addPathNode(Vector(1.5,1.5)*scaleFactor, 0.2); - scale.data->path.addPathNode(Vector(1,1)*scaleFactor,1); - scale.startPath(0.5); - } - } - - lastIngredient = i; - if (i) - lastAmount = i->amount; - else - lastAmount = 0; -} - -void FoodSlot::eatMe() -{ - if (ingredient && !dsq->isNested()) - { - for (int i = 0; i < foodHolders.size(); i++) - { - if (!foodHolders[i]->isTrash() && !foodHolders[i]->isEmpty()) - { - dsq->sound->playSfx("denied"); - foodHolders[i]->dropFood(); - return; - } - } - - if (!ingredient->effects.empty()) - { - bool eaten = dsq->continuity.applyIngredientEffects(ingredient); - if(eaten) - { - ingredient->amount--; - dsq->continuity.removeEmptyIngredients(); - dsq->game->refreshFoodSlots(true); - } - } - else - { - dsq->sound->playSfx("denied"); - /// don't - } - } -} - -void FoodSlot::moveRight() -{ - if (!ingredient) return; - if (ingredient->amount <= 0) return; - - for (int i = foodHolders.size()-1; i >= 0; i--) - { - if (foodHolders[i]->alpha.x > 0 && foodHolders[i]->alphaMod > 0 && foodHolders[i]->isEmpty() && !foodHolders[i]->isTrash()) - { - foodHolders[i]->setIngredient(ingredient); - inCookSlot = true; - refresh(true); - break; - } - } -} - -void FoodSlot::discard() -{ - if (!ingredient) return; - if (ingredient->amount <= 0) return; - - ingredient->amount--; - dsq->game->dropIngrNames.push_back(ingredient->name); - dsq->continuity.removeEmptyIngredients(); - dsq->game->refreshFoodSlots(true); -} - -bool FoodSlot::isCursorIn() -{ - return (core->mouse.position - getWorldPosition()).isLength2DIn(32); -} - -void FoodSlot::onUpdate(float dt) -{ - AquariaGuiQuad::onUpdate(dt); - - if (doubleClickDelay > 0) - { - doubleClickDelay -= dt; - if (doubleClickDelay < 0) doubleClickDelay = 0; - } - - if (alphaMod==1 && ingredient && ingredient->amount > 0) - { - if (foodSlotIndex == slot) - { - //grabTime += dt; - if (!core->mouse.buttons.left) - { - foodSlotIndex = -1; - - //if (ingredient->type < IT_FOOD) - - //if (grabTime > 0.5f) - if (!dsq->game->recipeMenu.on) - { - /* - dsq->game->removeRenderObject(this); - dsq->game->addRenderObject(this, LR_MENU); - */ - - - Vector wp = getWorldPosition(); - if ((dsq->game->lips->getWorldPosition() - wp).isLength2DIn(32)) - { - dsq->menuSelectDelay = 0.5; - - eatMe(); - } - else if (wp.x < 40 || wp.y < 40 || wp.x > 760 || wp.y > 560) - { - discard(); - } - else - { - bool droppedIn = false; - for (int i = 0; i < foodHolders.size(); i++) - { - bool in = (foodHolders[i]->getWorldPosition() - wp).isLength2DIn(32); - if (in) - { - droppedIn = true; - - if (foodHolders[i]->isTrash()) - { - discard(); - - dsq->game->foodLabel->alpha.interpolateTo(0, 2); - dsq->game->foodDescription->alpha.interpolateTo(0, 2); - - break; - //return; - } - else if (foodHolders[i]->isEmpty()) - { - foodHolders[i]->setIngredient(ingredient); - inCookSlot = true; - refresh(true); - break; - } - } - } - - if (!droppedIn) - { - if (doubleClickDelay > 0) - { - dsq->menuSelectDelay = 0.5; - doubleClickDelay = 0; - eatMe(); - - //if (!originalPosition.isZero()) - position = originalPosition; - - label->alpha = 1; - grabTime = 0; - - return; - } - else - { - doubleClickDelay = DOUBLE_CLICK_DELAY; - } - } - } - } - /* - else - { - if (ingredient) - debugLog(splitCamelCase(ingredient->name)); - } - */ - - //if (!originalPosition.isZero()) - position = originalPosition; - - label->alpha = 1; - - grabTime = 0; - } - else - { - if (!dsq->game->recipeMenu.on) - { - if (dsq->inputMode == INPUT_MOUSE) - { - Vector diff = core->mouse.position - getWorldPosition(); - position += diff; - dsq->game->moveFoodSlotToFront = this; - } - } - //position = parent->getWorldCollidePosition(core->mouse.position); - //position = core->mouse.position; - } - } - - if ((core->mouse.position - getWorldPosition()).isLength2DIn(16)) - //if (isCursorIn()) - { - dsq->game->foodLabel->setText(ingredient->displayName); - dsq->game->foodLabel->alpha.interpolateTo(1, 0.2); - - dsq->game->foodDescription->setText(dsq->continuity.getIngredientAffectsString(ingredient)); - dsq->game->foodDescription->alpha.interpolateTo(1, 0.2); - - if (core->mouse.buttons.left && foodSlotIndex == -1) - { - grabTime = 0; - foodSlotIndex = slot; - label->alpha = 0; - - /* - dsq->game->removeRenderObject(this); - dsq->game->addRenderObject(this, LR_HUD); - */ - - if (!inCookSlot) - { - originalPosition = position; - } - } - - if (core->mouse.buttons.right && !rmb) - { - rmb = 1; - } - else if (!core->mouse.buttons.right && rmb) - { - rmb = 0; - if (!game->recipeMenu.on) - moveRight(); - return; - } - - /* - if (core->mouse.buttons.right && !right) - { - right = true; - } - else if (!core->mouse.buttons.right && right) - { - right = false; - - bool dropped = false; - for (int i = foodHolders.size()-1; i >= 0; i--) - { - if (foodHolders[i]->alpha.x > 0 && foodHolders[i]->alphaMod > 0 && foodHolders[i]->isEmpty() && !foodHolders[i]->isTrash()) - { - foodHolders[i]->setIngredient(ingredient); - inCookSlot = true; - refresh(); - dropped = true; - break; - } - } - - if (dropped) - { - } - else - { - core->sound->playSfx("denied"); - } - } - */ - } - else - { - if (!dsq->game->foodLabel->alpha.isInterpolating()) - dsq->game->foodLabel->alpha.interpolateTo(0, 2); - if (!dsq->game->foodDescription->alpha.isInterpolating()) - dsq->game->foodDescription->alpha.interpolateTo(0, 2); - rmb = 0; - } - } - else - { - rmb = 0; - } -} - -SongSlot::SongSlot(int songSlot) : AquariaGuiQuad(), songSlot(songSlot) -{ - songType = dsq->continuity.getSongTypeBySlot(songSlot); - std::ostringstream os; - os << "Song/SongSlot-" << songSlot; - setTexture(os.str()); - - glow = new Quad("particles/glow", Vector(0,0)); - glow->setWidthHeight(128, 128); - glow->setBlendType(RenderObject::BLEND_ADD); - glow->alpha = 0; - addChild(glow, PM_POINTER); - - mbDown = false; - - if (dsq->continuity.isSongTypeForm((SongType)dsq->continuity.getSongTypeBySlot(songSlot))) - scale = Vector(0.9, 0.9); - else - scale = Vector(0.6, 0.6); -} - -void SongSlot::onUpdate(float dt) -{ - AquariaGuiQuad::onUpdate(dt); - - if (alpha.x == 1 && alphaMod == 1 && (!parent || parent->alpha.x == 1)) - { - if ((core->mouse.position - getWorldPosition()).isLength2DIn(24)) - { - dsq->game->playSongInMenu(songType); - dsq->game->songLabel->setText(dsq->continuity.getSongNameBySlot(songSlot)); - dsq->game->songLabel->alpha.interpolateTo(1, 0.2); - const bool anyButton = core->mouse.buttons.left || core->mouse.buttons.right; - if (!mbDown && anyButton) - { - mbDown = true; - } - else if (mbDown && !anyButton) - { - mbDown = false; - - dsq->game->playSongInMenu(songType, 1); - if (!dsq->sound->isPlayingVoice()) - dsq->voice(dsq->continuity.getVoxForSongSlot(songSlot)); - //dsq->game->songDescription->setText(dsq->continuity.getDescriptionForSongSlot(songSlot)); - - } - glow->alpha.interpolateTo(0.2, 0.15); - } - else - { - mbDown = false; - glow->alpha.interpolateTo(0, 0.2); - if (!dsq->game->songLabel->alpha.isInterpolating()) - { - dsq->game->songLabel->alpha.interpolateTo(0, 2); - /* - dsq->game->songLabel->alpha.path.addPathNode(dsq->game->songLabel->alpha, 0); - dsq->game->songLabel->alpha.path.addPathNode(dsq->game->songLabel->alpha, 0.5); - dsq->game->songLabel->alpha.path.addPathNode(0, 1); - dsq->game->songLabel->alpha.startPath(3); - */ - } - } - } -} - -const int treasureFlagStart = 500; - -TreasureSlot::TreasureSlot(int index) : AquariaGuiQuad() -{ - this->index = index; - mbd = false; - flag = 0; - doubleClickTimer = 0; -} - -void TreasureSlot::onUpdate(float dt) -{ - AquariaGuiQuad::onUpdate(dt); - - doubleClickTimer -= dt; - if (doubleClickTimer < 0) - doubleClickTimer = 0; - - if (alphaMod == 1 && alpha.x == 1 && flag != 0) - { - if ((core->mouse.position - getWorldPosition()).isLength2DIn(18)) - { - scale.interpolateTo(Vector(1.2, 1.2), 0.1); - if (core->mouse.buttons.left && !mbd) - { - mbd = true; - } - else if (!core->mouse.buttons.left && mbd) - { - mbd = false; - - if (doubleClickTimer > 0) - { - doubleClickTimer = 0; - - dsq->game->onUseTreasure(flag); - } - else - { - dsq->sound->playSfx("treasure-select", 0.5); - dsq->spawnParticleEffect("menu-switch", worldRightCenter, 0, 0, LR_HUD3, 1); - - - - dsq->game->treasureLabel->setText(treasureName); - dsq->game->treasureLabel->alpha = 1; - dsq->game->treasureCloseUp->setTexture(dsq->continuity.treasureData[flag].gfx); - //dsq->game->treasureCloseUp->scale = Vector(dsq->continuity.treasureData[flag].sz, dsq->continuity.treasureData[flag].sz); - - dsq->game->treasureCloseUp->alpha = 1; - - dsq->game->treasureDescription->setText(treasureDesc, Vector(400,450), 400); - dsq->game->treasureDescription->alpha = 1; - - dsq->game->use->alpha = dsq->continuity.treasureData[flag].use; - - /* - dsq->game->treasureCloseUp->scale = Vector(0.5,0.5); - dsq->game->treasureCloseUp->scale.interpolateTo(Vector(1,1), 0.2); - dsq->game->treasureCloseUp->alpha = 0.1; - dsq->game->treasureCloseUp->alpha.interpolateTo(1, 0.2); - */ - - selectedTreasureFlag = flag; - - doubleClickTimer = 0.2; - - - std::ostringstream os; - os << "treasure flag: " << flag << " desc: " << treasureDesc; - debugLog(os.str()); - } - } - } - else - { - mbd = false; - scale.interpolateTo(Vector(1, 1), 0.1); - } - } - else - { - mbd = false; - scale.interpolateTo(Vector(1, 1), 0.001); - } -} - -void TreasureSlot::refresh() -{ - flag = (game->currentTreasurePage*treasurePageSize) + index + treasureFlagStart; - if (flag >= FLAG_COLLECTIBLE_START && flag < FLAG_COLLECTIBLE_END && dsq->continuity.getFlag(flag)>0) - { - // get treasure image somehow - setTexture(dsq->continuity.treasureData[flag].gfx); - float scl = dsq->continuity.treasureData[flag].sz; - - float w = width; - float h = height; - float sz = 50; - if (w > h) - { - w = sz; - h = (height*sz)/width; - } - else - { - h = sz; - w = (width*sz)/height; - } - - setWidthHeight(w*scl, h*scl); - - std::string parse = dsq->continuity.stringBank.get(flag); - - int p1 = parse.find_first_of('['); - if (p1 != std::string::npos) - { - p1++; - int p2 = parse.find_first_of(']'); - treasureName = parse.substr(p1,p2-p1); - - p1 = parse.find_last_of('['); - if (p1 != std::string::npos) - { - p1++; - p2 = parse.find_last_of(']'); - treasureDesc = parse.substr(p1,p2-p1); - } - } - - alphaMod = 1; - } - else - { - flag = 0; - alphaMod = 1; - - setTexture("gui/wok"); - setWidthHeight(48); - //alphaMod = 0; - } -} - Ingredient *Game::getNearestIngredient(const Vector &pos, int radius) { int closest = -1; @@ -975,53 +107,6 @@ Entity *Game::getNearestEntity(const Vector &pos, int radius, Entity *ignore, En return closest; } -/* -class Avatar : public Entity -{ -public: - Vector position, myZoom; - void clampPosition(); - Entity *convoEntity; - std::string convoToRun; - Entity *attachedTo; - Quad *burstBar; - int health; - bool isCharging(); - bool isEntityDead(); - int maxHealth, mana, maxMana; - bool zoomOverriden; - -}; -*/ - -/* -#include "JetStream.h" -#include "Rock.h" -#include "SchoolFish.h" -*/ -/* -#include "Game.h" -#include "AfterEffect.h" -#include "Button.h" -#include "TextBox.h" -#include "LightShaft.h" -#include "Item.h" - -#include "Elements.h" -#include "WavyWeed.h" -#include "BitmapFont.h" - -#include "ParticleEffects.h" - - - -// SPECIAL -*/ - -Vector menuBgScale; - -const int ITEMS_PER_PAGE = 12; - ObsRow::ObsRow(int tx, int ty, int len) : tx(tx), ty(ty), len(len) { } @@ -1038,82 +123,6 @@ int Game::getNumberOfEntitiesNamed(const std::string &name) return c; } -void Game::playSongInMenu(int songType, bool override) -{ - if (playingSongInMenu == -1 || override) - { - playingSongInMenu = songType; - currentSongMenuNote = 0; - songMenuPlayDelay = 0.5; - } -} - -void Game::flipRenderObjectVertical(RenderObject *r, int flipY) -{ - if (r->position.y < flipY) - r->position.y = flipY + (flipY-r->position.y); - else - r->position.y = flipY - (r->position.y-flipY); -} - -bool Game::isSceneFlipped() -{ - return sceneFlipped; -} - -void Game::flipSceneVertical(int flipY) -{ - sceneFlipped = !sceneFlipped; - dsq->screenTransition->capture(); - dsq->render(); - dsq->screenTransition->go(1); - - FOR_ENTITIES(itr) - { - Entity *e = *itr; - flipRenderObjectVertical(e, flipY); - } - int i = 0; - int flipTY = (flipY/TILE_SIZE)-1; - for (i = 0; i < obsRows.size(); i++) - { - if (obsRows[i].ty < flipTY) - obsRows[i].ty = flipTY + (flipTY - obsRows[i].ty); - else - obsRows[i].ty = flipTY - (obsRows[i].ty - flipTY); - } - for (i = 0; i < dsq->getNumElements(); i++) - { - Element *e = dsq->getElement(i); - e->rotation.z = 180-e->rotation.z; - flipRenderObjectVertical(e, flipY); - } - /* - // DUMBASS: avatar is an entity.. it has already been flipped! - if (dsq->game->avatar) - { - flipRenderObjectVertical(dsq->game->avatar, flipY); - dsq->game->avatar->clampPosition(); - dsq->game->avatar->update(0.03); - } - */ - reconstructGrid(); - FOR_ENTITIES(i) - { - Entity *e = *i; - e->onSceneFlipped(); - } - reconstructGrid(); - if (cameraFollow) - warpCameraTo(*cameraFollow); - dsq->resetTimer(); -} - -void Game::setMenuDescriptionText(const std::string &text) -{ - menuDescription->setText(text); -} - Game *game = 0; Ingredient *Game::spawnIngredient(const std::string &ing, const Vector &pos, int times, int out) @@ -1167,29 +176,9 @@ void Game::spawnIngredientFromEntity(Entity *ent, IngredientData *data) Game::Game() : StateObject() { + themenu = new InGameMenu; + applyingState = false; - blurEffectsCheck = 0; - ripplesCheck = 0; - - cookDelay = 0; - -#if defined(AQUARIA_DEMO) - allowedMaps.push_back("naijacave"); - allowedMaps.push_back("trainingcave"); - allowedMaps.push_back("mainarea"); - allowedMaps.push_back("vedhacave"); - allowedMaps.push_back("openwater02"); - allowedMaps.push_back("energytemple01"); - allowedMaps.push_back("energytemple02"); - allowedMaps.push_back("energytemple03"); - allowedMaps.push_back("energytemple04"); - allowedMaps.push_back("energytemple05"); - allowedMaps.push_back("energytemple06"); - allowedMaps.push_back("songcave"); - allowedMaps.push_back("songcave02"); - allowedMaps.push_back("title"); - allowedMaps.push_back("energytemplevision"); -#endif hasPlayedLow = false; @@ -1201,8 +190,6 @@ Game::Game() : StateObject() registerState(this, "Game"); - optionsOnly = false; - toFlip = -1; shuttingDownGameState = false; dsq->loops.bg = BBGE_AUDIO_NOCHANNEL; @@ -1215,11 +202,9 @@ Game::Game() : StateObject() avatar = 0; fromVel = Vector(0,-1); - currentInventoryPage = 0; deathTimer = 0; game = this; - elementWithMenu = 0; cameraFollow = 0; worldMapRender = 0; @@ -1233,296 +218,14 @@ Game::Game() : StateObject() worldPaused = false; cookingScript = 0; - } Game::~Game() { + delete themenu; tileCache.clean(); game = 0; } -/* -void Game::doChoiceMenu(Vector position, std::vector choices) -{ - dsq->gui.openChoiceMenu(position); - for (int i = 0; i < choices.size(); i++) - { - dsq->gui.choiceMenu.addEntry(choices[i]); - } - selectedChoice = ""; - while (selectedChoice.empty()) - { - dsq->delay(10); - } - dsq->gui.closeChoiceMenu(); -} -*/ - -/* -void Game::onAssignMenuScreenItemToSlot0() -{ - if (!dsq->continuity.hudVisible) return; - if (!selectedMenuScreenItem) return; - dsq->continuity.setItemSlot(0, selectedMenuScreenItem->getItemIndex()); -} - -void Game::onAssignMenuScreenItemToSlot1() -{ - if (!dsq->continuity.hudVisible) return; - if (!selectedMenuScreenItem) return; - dsq->continuity.setItemSlot(1, selectedMenuScreenItem->getItemIndex()); -} - -void Game::onAssignMenuScreenItemToSlot2() -{ - if (!dsq->continuity.hudVisible) return; - if (!selectedMenuScreenItem) return; - dsq->continuity.setItemSlot(2, selectedMenuScreenItem->getItemIndex()); -} - -void Game::onAssignMenuScreenItemToSlot3() -{ - if (!dsq->continuity.hudVisible) return; - if (!selectedMenuScreenItem) return; - dsq->continuity.setItemSlot(3, selectedMenuScreenItem->getItemIndex()); -} -*/ - -Quad *menu_blackout = 0; - -void Game::showInGameMenu(bool ignoreInput, bool optionsOnly, MenuPage menuPage) -{ - if (avatar && core->getNestedMains()==1 && !avatar->isSinging() && (ignoreInput || avatar->isInputEnabled())) - { - //dsq->toggleInputGrabPlat(false); - - dsq->game->clearControlHint(); - - selectedTreasureFlag = -1; - this->optionsOnly = optionsOnly; - - core->sound->playSfx("Menu-Open"); - dropIngrNames.clear(); - - if (avatar->isEntityDead()) return; - - if (dsq->game->autoMap && dsq->game->autoMap->isOn()) - dsq->game->autoMap->toggle(false); - - toggleOptionsMenu(false); - dsq->overlay->alpha.interpolateTo(0, 0.1); - float t = 0.3; - - - if (!optionsOnly) - { - togglePause(true); - } - - if (optionsOnly) - { - menu_blackout = new Quad; - menu_blackout->color = 0; - menu_blackout->autoWidth = AUTO_VIRTUALWIDTH; - menu_blackout->autoHeight = AUTO_VIRTUALHEIGHT; - menu_blackout->followCamera = 1; - menu_blackout->position = Vector(400,300); - menu_blackout->alphaMod = 0.75; - menu_blackout->alpha = 0; - menu_blackout->alpha.interpolateTo(1, 0.5); - addRenderObject(menu_blackout, LR_AFTER_EFFECTS); - - menuBg2->alpha = 0; - } - else - { - menuBg2->alpha = 0; - menuBg2->alpha.interpolateTo(1, t*0.5f); - } - - if (dsq->continuity.hasFormUpgrade(FORMUPGRADE_ENERGY2)) - energyIdol->alphaMod = 1; - else - energyIdol->alphaMod = 0; - - if (dsq->continuity.getFlag(FLAG_LI) >= 100) - liCrystal->alphaMod = 1; - else - liCrystal->alphaMod = 0; - - int i = 0; - - - for (i = 0; i < songSlots.size(); i++) - { - if (dsq->continuity.hasSong(dsq->continuity.getSongTypeBySlot(i))) - songSlots[i]->alpha.interpolateTo(1, t); - else - songSlots[i]->alpha = 0; - } - - - - /* - std::ostringstream os; - os << "Exp: " << dsq->continuity.exp; - menuEXP->setText(os.str()); - menuEXP->alpha.interpolateTo(1, 0.5); - - std::ostringstream os2; - os2 << "Money: " << dsq->continuity.money; - menuMoney->setText(os2.str()); - menuMoney->alpha.interpolateTo(1, 0.5); - */ - - menuDescription->setText(""); - - menuDescription->alpha.interpolateTo(1, t); - - menuBg->scale = menuBgScale*0.5f; - menuBg->scale.interpolateTo(menuBgScale, t); - menuBg->alpha.interpolateTo(1, t*0.5f); - menuBg->setHidden(false); - - // FIXME: This gets a little verbose because of all the - // individual non-child objects. Is there a reason they - // can't all be children of menuBg? --achurch - opt_save->setHidden(false); - opt_cancel->setHidden(false); - options->setHidden(false); - keyConfigButton->setHidden(false); - cook->setHidden(false); - foodSort->setHidden(false); - recipes->setHidden(false); - use->setHidden(false); - prevFood->setHidden(false); - nextFood->setHidden(false); - prevTreasure->setHidden(false); - nextTreasure->setHidden(false); - circlePageNum->setHidden(false); - previewRecipe->setHidden(false); - showRecipe->setHidden(false); - recipeMenu.scroll->setHidden(false); - recipeMenu.scrollEnd->setHidden(false); - recipeMenu.header->setHidden(false); - recipeMenu.page->setHidden(false); - recipeMenu.prevPage->setHidden(false); - recipeMenu.nextPage->setHidden(false); - menuDescription->setHidden(false); - eAre->setHidden(false); - eYes->setHidden(false); - eNo->setHidden(false); - menuIconGlow->setHidden(false); - for (int i = 0; i < menu.size(); i++) - menu[i]->setHidden(false); - for (int i = 0; i < treasureSlots.size(); i++) - treasureSlots[i]->setHidden(false); - treasureDescription->setHidden(false); - for (int i = 0; i < foodSlots.size(); i++) - foodSlots[i]->setHidden(false); - - - if (dsq->game->miniMapRender) - { - dsq->game->miniMapRender->slide(1); - } - - toggleMainMenu(false); - - dsq->main(t); - - dsq->screenTransition->capture(); - - //toggleMiniMapRender(0); - - MenuPage useMenuPage = MENUPAGE_NONE; - - if (!optionsOnly) - { - if (menuPage != MENUPAGE_NONE) - { - useMenuPage = menuPage; - } - else if (dsq->continuity.lastMenuPage != MENUPAGE_NONE) - { - //errorLog("setting last menu page"); - useMenuPage = dsq->continuity.lastMenuPage; - } - } - - - switch(useMenuPage) - { - case MENUPAGE_FOOD: - toggleFoodMenu(true); - ((AquariaMenuItem*)menu[6])->setFocus(true); - break; - case MENUPAGE_TREASURES: - toggleTreasureMenu(true); - break; - case MENUPAGE_PETS: - togglePetMenu(true); - break; - case MENUPAGE_SONGS: - default: - { - if (optionsOnly) - { - toggleOptionsMenu(true); - } - else - { - float t = 0.1; - - toggleMainMenu(true); - - songBubbles->alpha.interpolateTo(1, t); - if (menuSongs) - { - menuSongs->alpha.interpolateTo(1, t); - } - for (i = 0; i < menu.size(); i++) - { - menu[i]->scale = Vector(0,0); - menu[i]->alpha = 0; - } - ((AquariaMenuItem*)menu[5])->setFocus(true); - } - } - } - - - if (!optionsOnly) - { - for (i = 0; i < menu.size(); i++) - { - menu[i]->scale.interpolateTo(Vector(1, 1), 0.15); - - menu[i]->alpha.interpolateTo(1, 0.15); - } - - menuIconGlow->alpha.interpolateTo(1, 0.5); - } - - menuOpenTimer = 0; - - inGameMenu = true; - - - - dsq->routeShoulder = false; - - - dsq->screenTransition->transition(MENUPAGETRANSTIME); - - - - if (optionsOnly) - { - dsq->main(-1); - } - } -} void Game::pickupIngredientEffects(IngredientData *data) { @@ -1541,273 +244,11 @@ void Game::pickupIngredientEffects(IngredientData *data) ingOffYTimer = 2; } -void Game::hideInGameMenu(bool effects, bool cancel) -{ - if (isCooking) return; - if (FoodSlot::foodSlotIndex != -1) return; - if (effects && !this->isInGameMenu()) return; - - if (avatar) - { - if (resBox) - resBox->close(); - - //dsq->toggleInputGrabPlat(true); - - if (effects) - core->sound->playSfx("Menu-Close"); - - hideInGameMenuExitCheck(false); - playingSongInMenu = -1; - - - float t = 0.3; - - if (!effects) - t = 0; - //if (avatar->isEntityDead()) return; - - int i = 0; - - for (i = 0; i < foodHolders.size(); i++) - { - foodHolders[i]->dropFood(); - } - - dsq->continuity.lastMenuPage = currentMenuPage; - if(cancel && (optionsMenu || keyConfigMenu)) - onOptionsCancel(); - else - toggleOptionsMenu(false); - - if (!optionsOnly) - { - toggleFoodMenu(false); - toggleTreasureMenu(false); - togglePetMenu(false); - toggleMainMenu(false); - toggleKeyConfigMenu(false); - } - - menuIconGlow->alpha = 0; - - for (i = 0; i < menu.size(); i++) - { - menu[i]->alpha = 0; - //menu[i]->alpha.interpolateTo(0, t*0.5f); - //menu[i]->scale.interpolateTo(Vector(0, 0), t); - } - for (i = 0; i < spellIcons.size(); i++) - spellIcons[i]->alpha.interpolateTo(0, t); - for (i = 0; i < songSlots.size(); i++) - songSlots[i]->alpha.interpolateTo(0, t); - songBubbles->alpha.interpolateTo(0, t); - - /* - menuEXP->alpha.interpolateTo(0, t); - menuMoney->alpha.interpolateTo(0, t); - */ - if (dsq->game->miniMapRender) - dsq->game->miniMapRender->slide(0); - - menuDescription->alpha.interpolateTo(0, t); - menuBg->alpha.interpolateTo(0, t); - menuBg->scale.interpolateTo(menuBg->scale*0.5f, t); - menuBg2->alpha.interpolateTo(0, t); - - - - if (menuSongs) - menuSongs->alpha.interpolateTo(0, t); - - if (menu_blackout) - { - menu_blackout->alpha.interpolateTo(0, t); - } - - if (showRecipe) - { - showRecipe->alpha.interpolateTo(0, t); - } - - if (effects) - core->main(t); - - if (menu_blackout) - { - menu_blackout->safeKill(); - menu_blackout = 0; - } - if (effects) - togglePause(false); - inGameMenu = false; - //toggleMiniMapRender(1); - - for (int i = 0; i < songTips.size(); i++) - songTips[i]->alpha = 0; - - - - for (int i = 0; i < dropIngrNames.size(); i++) - { - dsq->game->spawnIngredient(dropIngrNames[i], avatar->position + Vector(0,-96), 1, 1); - } - dropIngrNames.clear(); - - if (effects) - dsq->quitNestedMain(); - - dsq->routeShoulder = true; - } - - menuBg->setHidden(true); - opt_save->setHidden(true); - opt_cancel->setHidden(true); - options->setHidden(true); - keyConfigButton->setHidden(true); - cook->setHidden(true); - foodSort->setHidden(true); - recipes->setHidden(true); - use->setHidden(true); - prevFood->setHidden(true); - nextFood->setHidden(true); - prevTreasure->setHidden(true); - nextTreasure->setHidden(true); - circlePageNum->setHidden(true); - previewRecipe->setHidden(true); - showRecipe->setHidden(true); - recipeMenu.scroll->setHidden(true); - recipeMenu.scrollEnd->setHidden(true); - recipeMenu.header->setHidden(true); - recipeMenu.page->setHidden(true); - recipeMenu.prevPage->setHidden(true); - recipeMenu.nextPage->setHidden(true); - menuDescription->setHidden(true); - eAre->setHidden(true); - eYes->setHidden(true); - eNo->setHidden(true); - menuIconGlow->setHidden(true); - for (int i = 0; i < menu.size(); i++) - menu[i]->setHidden(true); - for (int i = 0; i < treasureSlots.size(); i++) - treasureSlots[i]->setHidden(true); - treasureDescription->setHidden(true); - for (int i = 0; i < foodSlots.size(); i++) - foodSlots[i]->setHidden(true); -} - -void Game::onLeftMouseButton() -{ - // hud button - /* - if (avatar && !avatar->isCharging()) - { - - if ((core->mouse.position - Vector(20, 20)).getSquaredLength2D() < sqr(40)) - { - if (paused) - hideInGameMenu(); - else - showInGameMenu(); - } - } - */ -} - -/* -void Game::onActivate() -{ - if (!dsq->gui.isInteractionSelectorOpen() && avatar->isInputEnabled()) - { - Element * e = dsq->getElementAtVector(dsq->cursor->position); - if (e) - { - // open a pop-up menu - // how? - // gui system - // embed menu control in all elements? - // if in all elements -> stupid, because you can only have on menu at once - elementWithMenu = e; - dsq->gui.openInteractionSelectorForElement(e); - } - } - - if (dsq->gui.isInteractionSelectorOpen()) - { - if (dsq->gui.menu.getSelectedEntry() > -1) - { - Interaction::Type type = elementWithMenu->interactions[dsq->gui.menu.getSelectedEntry()].getType(); - dsq->gui.closeInteractionSelector(); - // will crash sometime - elementWithMenu->interact(type, avatar); - elementWithMenu = 0; - - - avatar->enableInput(); - //dsq->gui.menu.clearEntries(); - } - } - else if (dsq->gui.isChoiceMenuOpen()) - { - if (dsq->gui.choiceMenu.getSelectedEntry() > -1) - { - selectedChoice = dsq->gui.choiceMenu.getSelectedEntryName(); - dsq->gui.closeChoiceMenu(); - if (core->getNestedMains() > 1) - { - core->quitNestedMain(); - } - } - } - else if(core->getNestedMains()) - { - core->quitNestedMain(); - } -} -*/ - void Game::spawnManaBall(Vector pos, float a) { ManaBall *m = new ManaBall(pos, a); addRenderObject(m, LR_PARTICLES); } - -void Game::refreshItemSlotIcons() -{ - /* - for (int i = 0; i < itemSlotIcons.size(); i++) - { - if (dsq->continuity.itemSlots[i] != -1) - { - itemSlotIcons[i]->setTexture(dsq->getItemTexture(dsq->continuity.itemSlots[i])); - int n = dsq->continuity.getNumberOf(dsq->continuity.itemSlots[i]); - if (n > 0) - itemSlotIcons[i]->alpha = 1; - else - itemSlotIcons[i]->alpha = 0; - } - else - itemSlotIcons[i]->alpha = 0; - itemSlotIcons[i]->setWidthHeight(32, 32); - - - } - */ - /* - if (n > 0) - itemSlotIcons[i]->alpha.interpolateTo(1,0.2); - else - itemSlotIcons[i]->alpha.interpolateTo(0,0.2); - */ -} - -void Game::clearPointers() -{ - bg = 0; - bg2 = 0; - avatar = 0; -} - void Game::warpPrep() { avatar->onWarp(); @@ -2234,46 +675,6 @@ void Game::dilateGrid(unsigned int radius, ObsType test, ObsType set, ObsType al } } -float Game::getCoverage(Vector pos, int sampleArea) -{ - TileVector t(pos); - int total = 0, covered = 0; - for (int x = t.x-sampleArea; x <= t.x+sampleArea; x++) - { - for (int y = t.y-sampleArea; y <= t.y+sampleArea; y++) - { - if (x == t.x && y == t.y) continue; - TileVector ct(x,y); - Vector vt = ct.worldVector(); - if (isObstructed(ct)) - { - covered++; - } - total++; - } - } - return float(covered)/float(total); -} - -float Game::getPercObsInArea(Vector pos, int sampleArea, int obs) -{ - int sz = sampleArea * sampleArea; - int c = 0; - TileVector t(pos); - - for (int x = t.x-sampleArea; x <= t.x+sampleArea; x++) - { - for (int y = t.y-sampleArea; y <= t.y+sampleArea; y++) - { - if (isObstructed(TileVector(x, y), obs)) - { - c++; - } - } - } - return float(c)/float(sz); -} - Vector Game::getWallNormal(Vector pos, int sampleArea, float *dist, int obs) { TileVector t(pos); @@ -2293,29 +694,8 @@ Vector Game::getWallNormal(Vector pos, int sampleArea, float *dist, int obs) Vector vt = ct.worldVector(); if (isObstructed(ct, obs)) { - /* - int xDiff = abs(t.x - x); - int yDiff = abs(t.y - y); - float xv = float(sampleArea-xDiff)/float(sampleArea); - if (x < t.x) - xv = -xv; - float yv = float(sampleArea-yDiff)/float(sampleArea); - if (y < t.y) - yv = -yv; - Vector v(-xv, -yv); - */ - /* - int xDiff = t.x-x; - int yDiff = t.y-y; - */ - int xDiff = pos.x-vt.x; int yDiff = pos.y-vt.y; - /* - float xEffect = (sampleArea*TILE_SIZE - abs(xDiff))*1.0f; - float yEffect = (sampleArea*TILE_SIZE - abs(yDiff))*1.0f; - */ - //Vector v(xDiff*xEffect, yDiff*yEffect); Vector v(xDiff, yDiff); vs.push_back (v); @@ -2327,14 +707,6 @@ Vector Game::getWallNormal(Vector pos, int sampleArea, float *dist, int obs) *dist = d; } } - /* - float len = v.getLength2D(); - if (len > maxLen || maxLen == -1) - maxLen = len; - */ - //Vector v(xDiff, yDiff); - //avg += v; - //c++; } } } @@ -2362,11 +734,6 @@ Vector Game::getWallNormal(Vector pos, int sampleArea, float *dist, int obs) { avg.x = avg.y = 0; } - - /* - avg.x = -avg.x; - avg.y = -avg.y; - */ return avg; } @@ -2452,34 +819,6 @@ void Game::bindIngredients() } } -/* -void Game::getEntityTypeName(int entityType) -{ - switch(entityType) - { - case ET_NAUTILUS: return "Nautilus"; - case ET_CENTIPEDE: return "Centipede"; - case ET_WATERBUG: return "WaterBug"; - case ET_CRAWLER: return "Crawler"; - case ET_HELLBEASTHEAD: return "HellBeastHead"; - case ET_SPINNER: return "Spinner"; - case ET_SQUID: return "Squid"; - case ET_JELLYFISH: return "JellyFish"; - case ET_ROCKHEAD: return "RockHead"; - case ET_SPIKE: return "Spike"; - case ET_MEGASHRIMP: return "MegaShrimp"; - case ET_ZUNNA: return "Zunna"; - case ET_PICKUPITEM: return "PickupItem"; - case ET_HERETICSKULL: return "HereticSkull"; - case ET_RATTLEOYSTER: return "RattleOyster"; - case ET_LEACH: return "Leach"; - case ET_QUEENHYDRA: return "QueenHydra"; - case ET_HYDRALARVA: return "Lumite"; - case ET_BARRIER: return "Barrier"; - } -} -*/ - void Game::loadEntityTypeList() // and group list! { @@ -2497,12 +836,6 @@ void Game::loadEntityTypeList() float scale; std::istringstream is(line); is >> idx >> name >> prevGfx >> scale; - //errorLog(line); - /* - std::ostringstream os; - os << "adding entity [" << name << "] idx[" << idx << "] prevGfx [" << prevGfx << "] scale [" << scale << "]"; - debugLog(os.str()); - */ entityTypeList.push_back(EntityClass(name, 1, idx, prevGfx, scale)); } in.close(); @@ -2531,7 +864,7 @@ void Game::loadEntityTypeList() // entityGroups.push_back(newGroup); curGroup = entityGroups.size()-1; - } + } else if (!line.empty()) { EntityGroupEntity ent; @@ -2554,11 +887,6 @@ EntityClass *Game::getEntityClassForEntityType(const std::string &type) { for (int i = 0; i < entityTypeList.size(); i++) { - /* - std::ostringstream os; - os << "Comparing entityTypeList [" << entityTypeList[i].name << "] with type [" << type << "]"; - debugLog(os.str()); - */ if (nocasecmp(entityTypeList[i].name, type)==0) return &entityTypeList[i]; } @@ -2567,8 +895,6 @@ EntityClass *Game::getEntityClassForEntityType(const std::string &type) int Game::getIdxForEntityType(std::string type) { - //if (!type.empty() && type[0] == '@') return -1; - for (int i = 0; i < entityTypeList.size(); i++) { if (nocasecmp(entityTypeList[i].name, type)==0) @@ -2724,16 +1050,6 @@ EntitySaveData *Game::getEntitySaveDataForEntity(Entity *e, Vector pos) { return &entitySaveData[i]; } - /* - if (entitySaveData[i].x == int(e->startPos.x) && entitySaveData[i].y == int(e->startPos.y)) - { - if (entitySaveData[i].idx == e->entityTypeIdx) - { - debugLog("found entity"); - return &entitySaveData[i]; - } - } - */ } return 0; } @@ -2832,37 +1148,6 @@ void Game::generateCollisionMask(Quad *q, float overrideCollideRadius /* = 0 */) q->collisionMaskRadius = 512; free(data); - - - /* - for (int i = 0; i < q->collisionMask.size(); i++) - { - float xsz = q->collisionMask[i].x; - float ysz = q->collisionMask[i].y; - if (xsz < 0) xsz = -xsz; - if (ysz < 0) ysz = -ysz; - if (xsz > q->collisionMaskRadius) - q->collisionMaskRadius = xsz; - if (ysz > q->collisionMaskRadius) - q->collisionMaskRadius = ysz; - } - q->collisionMaskRadius += TILE_SIZE/2; - */ - /* - if (w2 > h2) - q->collisionMaskRadius = w2*2; - else - q->collisionMaskRadius = h2*2; - */ - //q->collisionMaskRadius = sqrtf(sqr(w2)+sqr(h2)); - - /* - int rot = rotation.z; - while (rot > 360) - rot -= 360; - while (rot < 0) - rot += 360; - */ } } @@ -2908,28 +1193,10 @@ int Game::getIndexOfPath(Path *p) Path *Game::getPathAtCursor() { return getNearestPath(dsq->getGameCursorPosition(), ""); - /* - int range = 128; - int sz = paths.size(); - for (int i = 0; i < sz; i++) - { - Path *p = &(paths[i]); - if (!p->nodes.empty()) - { - int dist = (p->nodes[0].position - dsq->getGameCursorPosition()).getSquaredLength2D(); - if (dist < sqr(range)) - { - return p; - } - } - } - return 0; - */ } Path *Game::getScriptedPathAtCursor(bool withAct) { - //int range = 64; int sz = paths.size(); for (int i = 0; i < sz; i++) { @@ -2943,13 +1210,6 @@ Path *Game::getScriptedPathAtCursor(bool withAct) return p; } } - /* - int dist = (p->nodes[0].position - dsq->getGameCursorPosition()).getSquaredLength2D(); - if (dist < sqr(range)) - { - return p; - } - */ } } return 0; @@ -3016,1116 +1276,6 @@ Path *Game::getPathByName(std::string name) return 0; } - -void Game::addKeyConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int y, int l1, int l2, int l3) -{ - //DebugFont *lb = new DebugFont(6, label); - TTFText *lb = new TTFText(&dsq->fontArialSmallest); - lb->setText(label); - lb->position = Vector(140,y); - group->addChild(lb, PM_POINTER); - - AquariaKeyConfig *k1 = new AquariaKeyConfig(actionInputName, INPUTSET_KEY, 0); - k1->position = Vector(350,y); - k1->setLock(l1); - group->addChild(k1, PM_POINTER); - - AquariaKeyConfig *k2 = new AquariaKeyConfig(actionInputName, INPUTSET_KEY, 1); - k2->position = Vector(475,y); - k2->setLock(l2); - group->addChild(k2, PM_POINTER); - - AquariaKeyConfig *j1 = new AquariaKeyConfig(actionInputName, INPUTSET_JOY, 0); - j1->position = Vector(600,y); - j1->setLock(l3); - group->addChild(j1, PM_POINTER); - - k1->setDirMove(DIR_RIGHT, k2); - k2->setDirMove(DIR_RIGHT, j1); - - j1->setDirMove(DIR_LEFT, k2); - k2->setDirMove(DIR_LEFT, k1); -} - -AquariaKeyConfig *Game::addAxesConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int y, int offx) -{ - /// DebugFont *lb = new DebugFont(6, label); - TTFText *lb = new TTFText(&dsq->fontArialSmallest); - lb->setText(label); - lb->position = Vector(140+offx, y); - group->addChild(lb, PM_POINTER); - - AquariaKeyConfig *i1 = new AquariaKeyConfig(actionInputName, INPUTSET_OTHER, 0); - i1->position = Vector(140+80+offx,y); - //i1->setLock(l1); - group->addChild(i1, PM_POINTER); - - i1->setDirMove(DIR_RIGHT, 0); - i1->setDirMove(DIR_LEFT, 0); - - return i1; -} - -bool Game::doFlagCheck(const std::string &flagCheck, FlagCheckType type, bool lastTruth) -{ - if (!flagCheck.empty()) - { - std::string flagName, comparison, next; - int value=0; - std::istringstream is(flagCheck); - is >> flagName >> comparison >> value >> next; - - bool truth=false; - if (comparison == "==") - { - if (dsq->continuity.getFlag(flagName) == value) truth = true; - } - else if (comparison == "<") - { - if (dsq->continuity.getFlag(flagName) < value) truth = true; - } - else if (comparison == ">") - { - if (dsq->continuity.getFlag(flagName) > value) truth = true; - } - else if (comparison == "<=") - { - if (dsq->continuity.getFlag(flagName) <= value) truth = true; - } - else if (comparison == ">=") - { - if (dsq->continuity.getFlag(flagName) >= value) truth = true; - } - - if (type == AND) - { - truth = (lastTruth && truth); - } - else if (type == OR) - { - truth = (lastTruth || truth); - } - - if (next == "AND") - { - std::string restOfIt; - std::getline(is, restOfIt); - return doFlagCheck(restOfIt, AND, truth); - } - else if (next == "OR") - { - std::string restOfIt; - std::getline(is, restOfIt); - return doFlagCheck(restOfIt, OR, truth); - } - - return truth; - } - return true; -} - -void Game::switchToSongMenu() -{ - dsq->screenTransition->capture(); - - toggleOptionsMenu(false); - toggleFoodMenu(false); - togglePetMenu(false); - toggleTreasureMenu(false); - - toggleMainMenu(true); - - dsq->screenTransition->transition(MENUPAGETRANSTIME); -} - -void Game::switchToFoodMenu() -{ - dsq->screenTransition->capture(); - - toggleOptionsMenu(false); - togglePetMenu(false); - toggleMainMenu(false); - toggleTreasureMenu(false); - - toggleFoodMenu(true); - dsq->screenTransition->transition(MENUPAGETRANSTIME); -} - -void Game::switchToPetMenu() -{ - dsq->screenTransition->capture(); - - toggleOptionsMenu(false); - toggleFoodMenu(false); - toggleMainMenu(false); - toggleTreasureMenu(false); - - togglePetMenu(true); - dsq->screenTransition->transition(MENUPAGETRANSTIME); -} - -void Game::switchToTreasureMenu() -{ - dsq->screenTransition->capture(); - - toggleOptionsMenu(false); - toggleFoodMenu(false); - toggleMainMenu(false); - togglePetMenu(false); - - toggleTreasureMenu(true); - dsq->screenTransition->transition(MENUPAGETRANSTIME); -} - -/* -IET_INVINCIBLE -IET_HP -IET_MAXHP -IET_DEFENSE -IET_SPEED -IET_REGEN -IET_ENERGY -IET_BLIND -IET_LIGHT -IET_PETPOWER -IET_WEB -IET_LI -IET_FISHPOISON -IET_BITE -IET_EAT -IET_YUM -IET_TRIP -IET_RANDOM -IET_POISON -IET_ALLSTATUS -*/ - -typedef std::vector IngVec; - -void Game::sortFood() -{ - /* - if (dsq->continuity.foodSortType == FOODSORT_UNSORTED) - { - if (dsq->continuity.sortByUnsort.empty()) - for (int i = 0; i < dsq->continuity.ingredients.size(); i++) - dsq->continuity.sortByUnsort.push_back(FoodSortOrder(IT_NONE, IET_NONE, dsq->continuity.ingredients[i].name)); - } - */ - - std::vector foodHolderNames; - foodHolderNames.resize(foodHolders.size()); - - for (int i = 0; i < foodHolders.size(); i++) { - IngredientData *ing = foodHolders[i]->getIngredient(); - if (ing) { - foodHolderNames[i] = ing->name; - //errorLog(foodHolderNames[i]); - //foodHolders[i]->setIngredient(0); - } - } - - dsq->continuity.foodSortType++; - if (dsq->continuity.foodSortType >= MAX_FOODSORT) - dsq->continuity.foodSortType = 0; - - dsq->continuity.sortFood(); - - // rebuild the page - - refreshFoodSlots(false); - - /* - toggleFoodMenu(false); - toggleFoodMenu(true); - */ - - dsq->sound->playSfx("shuffle"); - dsq->sound->playSfx("menu-switch", 0.5); - dsq->spawnParticleEffect("menu-switch", worldLeftCenter, 0, 0, LR_HUD3, 1); - - for (int i = 0; i < foodHolders.size(); i++) { - if (!foodHolderNames[i].empty()) { - IngredientData *ing = dsq->continuity.getIngredientHeldByName(foodHolderNames[i]); - foodHolders[i]->setIngredient(ing, false); - - //foodHolders[i]->setIngredient(dsq->continuity.getIngredientByName(foodHolderNames[i])); - /* - if (!foodHolders[i]->foodHolderIngredient) { - errorLog("not found"); - } - else { - std::ostringstream os; - os << "get: " << foodHolders[i]->foodHolderIngredient->name; - errorLog(os.str()); - } - */ - } - } -} - -void Game::createInGameMenu() -{ - float menuz = 4; - int i = 0; - - - menuBg = new Quad; - menuBg->setTexture("menu"); - //menuBg->setWidthHeight(800); - //menuBg->scale = Vector(800.0f/1024.0f, 800.0f/1024.0f); - menuBgScale = Vector(800.0f/1024.0f, 800.0f/1024.0f); - menuBg->position = Vector(400,300,menuz); - menuBg->followCamera = 1; - //menuBg->shareAlphaWithChildren=true; - addRenderObject(menuBg, LR_MENU); - - - menuBg2 = new Quad; - menuBg2->setTexture("menu2"); - menuBg2->position = Vector(0, 240); - menuBg->addChild(menuBg2, PM_POINTER); - - float scale = menuBg->scale.x; - /* - songDescription = new BitmapText(&dsq->font); - songDescription->position = Vector(0,100); - songDescription->parentManagedPointer = 1; - menuBg->addChild(songDescription); - */ - - options = new Quad; - - options->renderQuad = false; - - int sliderx = 250, slidery = 160, sliderd = 26; - int checkx=660, checky = 160, checkd = 26; - - Quad *audio = new Quad("gui/audiovisual", Vector(200, 125)); - options->addChild(audio, PM_POINTER); - - Quad *controls = new Quad("gui/controls", Vector(600, 125)); - options->addChild(controls, PM_POINTER); - - /* - Quad *visual = new Quad("gui/visual", Vector(170, 300)); - visual->parentManagedPointer = 1; - options->addChild(visual); - */ - - /* - Quad *blurEffectsLabel = new Quad("gui/blurEffectsLabel.png", visual->position + Vector(-20,40)); - blurEffectsLabel->parentManagedPointer = 1; - options->addChild(blurEffectsLabel); - */ - - /* - blurEffectsCheck = new AquariaCheckBox(); - blurEffectsCheck->position = visual->position + Vector(60, 40); - blurEffectsCheck->parentManagedPointer = 1; - options->addChild(blurEffectsCheck); - */ - - Quad *controllabels = new Quad("gui/controllabels", Vector(0,0,0)); - int w = controllabels->getWidth(); - int h = controllabels->getHeight(); - controllabels->position = Vector(checkx-16-w/2.0f, checky + h/2.0f - 14); - options->addChild(controllabels, PM_POINTER); - - - - int scheckx=270; - int schecky=315; - int sw,sh; - int voptoffy = 26; - - Quad *subtitleslabel = new Quad("gui/subtitles", Vector(0,0,0)); - sw = subtitleslabel->getWidth(); - sh = subtitleslabel->getHeight(); - subtitleslabel->position = Vector(scheckx-16-sw*0.5f, schecky + sh/2.0f - 14); - options->addChild(subtitleslabel, PM_POINTER); - - subtitlesCheck = new AquariaCheckBox(); - subtitlesCheck->setValue(dsq->user.audio.subtitles); - subtitlesCheck->position = Vector(scheckx,schecky); - options->addChild(subtitlesCheck, PM_POINTER); - - Quad *fullscreenLabel = new Quad("gui/fullscreen", Vector(0,0,0)); - fullscreenLabel->position = Vector(scheckx-16-sw*0.5f, schecky + voptoffy + sh/2.0f - 14); - options->addChild(fullscreenLabel, PM_POINTER); - - fullscreenCheck = new AquariaCheckBox(); - fullscreenCheck->setValue(dsq->isFullscreen()); - fullscreenCheck->position = Vector(scheckx,schecky + voptoffy); - options->addChild(fullscreenCheck, PM_POINTER); - - Quad *resolutionLabel = new Quad("gui/resolution", Vector(0,0,0)); - resolutionLabel->position = Vector(160, 260); - options->addChild(resolutionLabel, PM_POINTER); - - resBox = new AquariaComboBox(Vector(0.7f, 1.0f)); - resBox->position = Vector(196, 285); - for (i = 0; i < core->screenModes.size(); i++) - { - std::ostringstream os; - os << core->screenModes[i].x << "x" << core->screenModes[i].y; - if(core->screenModes[i].hz) - os << " (" << core->screenModes[i].hz << "hz)"; - resBox->addItem(os.str()); - if (core->screenModes[i].x == dsq->user.video.resx && core->screenModes[i].y == dsq->user.video.resy) - { - resBox->enqueueSelectItem(i); - } - } - options->addChild(resBox, PM_POINTER); - - Quad *audiolabels = new Quad("gui/audiolabels", Vector(0,0,0)); - w = audiolabels->getWidth(); - h = audiolabels->getHeight(); - audiolabels->position = Vector(sliderx-64-w/2.0f, slidery + h/2.0f - 14); - options->addChild(audiolabels, PM_POINTER); - - musslider = new AquariaSlider(); - musslider->setValue(dsq->user.audio.musvol); - musslider->position = Vector(sliderx,slidery+1*sliderd); - options->addChild(musslider, PM_POINTER); - - sfxslider = new AquariaSlider(); - sfxslider->setValue(dsq->user.audio.sfxvol); - sfxslider->position = Vector(sliderx,slidery); - options->addChild(sfxslider, PM_POINTER); - - voxslider = new AquariaSlider(); - voxslider->setValue(dsq->user.audio.voxvol); - voxslider->position = Vector(sliderx,slidery+2*sliderd); - options->addChild(voxslider, PM_POINTER); - - - flipInputButtonsCheck = new AquariaCheckBox(); - flipInputButtonsCheck->setValue(dsq->user.control.flipInputButtons); - flipInputButtonsCheck->position = Vector(checkx,checky); - options->addChild(flipInputButtonsCheck, PM_POINTER); - - micInputCheck = 0; - - toolTipsCheck = new AquariaCheckBox(); - toolTipsCheck->setValue(dsq->user.control.toolTipsOn); - toolTipsCheck->position = Vector(checkx,checky+1*checkd); - options->addChild(toolTipsCheck, PM_POINTER); - - autoAimCheck = new AquariaCheckBox(); - autoAimCheck->setValue(dsq->user.control.autoAim); - autoAimCheck->position = Vector(checkx,checky+2*checkd); - options->addChild(autoAimCheck, PM_POINTER); - - targetingCheck = new AquariaCheckBox(); - targetingCheck->setValue(dsq->user.control.targeting); - targetingCheck->position = Vector(checkx,checky+3*checkd); - options->addChild(targetingCheck, PM_POINTER); - - - - opt_save = new AquariaMenuItem; - opt_save->useQuad("gui/Apply"); - opt_save->useGlow("particles/glow", 100, 50); - opt_save->event.set(MakeFunctionEvent(Game, onOptionsSave)); - opt_save->position = opt_save_original; - opt_save->alpha = 0; - addRenderObject(opt_save, LR_MENU); - - opt_cancel = new AquariaMenuItem; - opt_cancel->useQuad("gui/Cancel"); - opt_cancel->useGlow("particles/glow", 100, 50); - opt_cancel->event.set(MakeFunctionEvent(Game, onOptionsCancel)); - opt_cancel->position = opt_cancel_original; - opt_cancel->alpha = 0; - addRenderObject(opt_cancel, LR_MENU); - - options->shareAlphaWithChildren = 1; - options->alpha = 0; - options->followCamera = 1; - addRenderObject(options, LR_MENU); - - scale = 1; - songSlots.clear(); - //songSlots.resize(3); - songSlots.resize(10); - // rewrite this: so you can hide / ignore certain songs, etc - //songSlots.resize(dsq->continuity.getSongBankSize()); - //Vector center(-235, -50); - Vector center(-230, -50), rightCenter(230, -50); - - energyIdol = new Quad("formupgrades/energyidol-charged", Vector(40,0)); - menuBg->addChild(energyIdol, PM_POINTER); - - liCrystal = new Quad("gui/li-crystal", Vector(0,0)); - menuBg->addChild(liCrystal, PM_POINTER); - - songBubbles = new Quad("gui/SongBubbles", Vector(-center.x, center.y)); - menuBg->addChild(songBubbles, PM_POINTER); - - - // Vector(575,250); - - - songLabel = new BitmapText(&dsq->smallFont); - { - songLabel->alpha = 0; - songLabel->setAlign(ALIGN_CENTER); - songLabel->followCamera = 1; - songLabel->setFontSize(20); - songLabel->position = Vector(-center.x, center.y) + Vector(0, -15); //+ Vector(10, -10); - songLabel->scale = Vector(1.2, 1.2); - } - menuBg->addChild(songLabel, PM_POINTER); - - - - ToolTip *tip = 0; - - foodTips.clear(); - songTips.clear(); - petTips.clear(); - treasureTips.clear(); - - tip = new ToolTip; - tip->alpha = 0; - tip->setCircularAreaFromCenter(worldLeftCenter, 240); - tip->setText(dsq->continuity.stringBank.get(0), Vector(200,450), 350); - addRenderObject(tip, LR_HUD); - foodTips.push_back(tip); - - - tip = new ToolTip; - tip->alpha = 0; - tip->setCircularAreaFromCenter(worldRightCenter, 240); - tip->setText(dsq->continuity.stringBank.get(1), Vector(600,450), 350); - addRenderObject(tip, LR_HUD); - foodTips.push_back(tip); - - - - tip = new ToolTip; - tip->alpha = 0; - tip->setCircularAreaFromCenter(worldLeftCenter, 240); - tip->setText(dsq->continuity.stringBank.get(14), Vector(200,450), 350); - addRenderObject(tip, LR_HUD); - songTips.push_back(tip); - - - /* - tip = new ToolTip; - tip->alpha = 0; - tip->setAreaFromCenter(Vector(400,300), 800, 600); - tip->setText(dsq->continuity.stringBank.get(16), Vector(400,300), 400); - addRenderObject(tip, LR_HUD); - petTips.push_back(tip); - */ - - tip = new ToolTip; - tip->alpha = 0; - tip->setCircularAreaFromCenter(worldLeftCenter, 240); - tip->setText(dsq->continuity.stringBank.get(17), Vector(200,450), 350); - addRenderObject(tip, LR_HUD); - petTips.push_back(tip); - - tip = new ToolTip; - tip->alpha = 0; - tip->setAreaFromCenter(Vector(400,350), 150, 50); - tip->setText(dsq->continuity.stringBank.get(15), Vector(400,450), 450); - addRenderObject(tip, LR_HUD); - songTips.push_back(tip); - foodTips.push_back(tip); - petTips.push_back(tip); - treasureTips.push_back(tip); - - int radius = 118; - int food = 0; - - keyConfigButton = new AquariaMenuItem; - keyConfigButton->useQuad("gui/keyconfig-button"); - keyConfigButton->useGlow("particles/glow", 128, 40); - keyConfigButton->position = worldRightCenter + Vector(0, 80); - keyConfigButton->alpha = 0; - keyConfigButton->scale = Vector(0.8, 0.8); - keyConfigButton->event.set(MakeFunctionEvent(Game, onKeyConfig)); - //keyConfigButton->setCanDirMove(false); - addRenderObject(keyConfigButton, LR_MENU); - - - - group_keyConfig = new RenderObject; - - /* - Quad *kbg = new Quad("gui/keyconfig-menu", Vector(400,300)); - kbg->setWidthHeight(800, 800); - group_keyConfig->addChild(kbg); - */ - - //Quad *kcb = new Quad; - RoundedRect *kcb = new RoundedRect(); - //kcb->color = 0; - //kcb->alphaMod = 0.75; - kcb->position = Vector(400,276 - 10); - kcb->setWidthHeight(580, 455, 10); - group_keyConfig->addChild(kcb, PM_POINTER); - - int offy = -20; - -#define SB(x) dsq->continuity.stringBank.get(x) - - TTFText *header_action = new TTFText(&dsq->fontArialSmall); - header_action->setText(SB(2101)); - header_action->position = Vector(140, 80+offy); - group_keyConfig->addChild(header_action, PM_POINTER); - - TTFText *header_key1 = new TTFText(&dsq->fontArialSmall); - header_key1->setText(SB(2102)); - header_key1->position = Vector(350, 80+offy); - header_key1->setAlign(ALIGN_CENTER); - group_keyConfig->addChild(header_key1, PM_POINTER); - - TTFText *header_key2 = new TTFText(&dsq->fontArialSmall); - header_key2->setText(SB(2103)); - header_key2->position = Vector(475, 80+offy); - header_key2->setAlign(ALIGN_CENTER); - group_keyConfig->addChild(header_key2, PM_POINTER); - - TTFText *header_joy = new TTFText(&dsq->fontArialSmall); - header_joy->setText(SB(2104)); - header_joy->position = Vector(600, 80+offy); - header_joy->setAlign(ALIGN_CENTER); - group_keyConfig->addChild(header_joy, PM_POINTER); - - addKeyConfigLine(group_keyConfig, SB(2105), "lmb", 100+offy, 0, 0, 0); - addKeyConfigLine(group_keyConfig, SB(2106), "rmb", 120+offy, 0, 0, 0); - addKeyConfigLine(group_keyConfig, SB(2107), "PrimaryAction", 140+offy); - addKeyConfigLine(group_keyConfig, SB(2108), "SecondaryAction", 160+offy); - addKeyConfigLine(group_keyConfig, SB(2109), "SwimUp", 180+offy); - addKeyConfigLine(group_keyConfig, SB(2110), "SwimDown", 200+offy); - addKeyConfigLine(group_keyConfig, SB(2111), "SwimLeft", 220+offy); - addKeyConfigLine(group_keyConfig, SB(2112), "SwimRight", 240+offy); - addKeyConfigLine(group_keyConfig, SB(2113), "Roll", 260+offy); - addKeyConfigLine(group_keyConfig, SB(2114), "Revert", 280+offy); - addKeyConfigLine(group_keyConfig, SB(2115), "WorldMap", 300+offy); - addKeyConfigLine(group_keyConfig, SB(2116), "Escape", 320+offy, 1, 0, 0); - - AquariaKeyConfig* s1x = addAxesConfigLine(group_keyConfig, SB(2117), "s1ax", 340+offy, 0); - AquariaKeyConfig* s1y = addAxesConfigLine(group_keyConfig, SB(2118), "s1ay", 340+offy, 130); - AquariaKeyConfig* s2x = addAxesConfigLine(group_keyConfig, SB(2119), "s2ax", 340+offy, 260); - AquariaKeyConfig* s2y = addAxesConfigLine(group_keyConfig, SB(2120), "s2ay", 340+offy, 380); - - s1x->setDirMove(DIR_LEFT, s1x); - s1x->setDirMove(DIR_RIGHT, s1y); - - s1y->setDirMove(DIR_LEFT, s1x); - s1y->setDirMove(DIR_RIGHT, s2x); - - s2x->setDirMove(DIR_LEFT, s1y); - s2x->setDirMove(DIR_RIGHT, s2y); - - s2y->setDirMove(DIR_LEFT, s2x); - s2y->setDirMove(DIR_RIGHT, s2y); - - offy += 20; - - addKeyConfigLine(group_keyConfig, SB(2121), "PrevPage", 340+offy); - addKeyConfigLine(group_keyConfig, SB(2122), "NextPage", 360+offy); - addKeyConfigLine(group_keyConfig, SB(2123), "CookFood", 380+offy); - addKeyConfigLine(group_keyConfig, SB(2124), "FoodLeft", 400+offy); - addKeyConfigLine(group_keyConfig, SB(2125), "FoodRight", 420+offy); - addKeyConfigLine(group_keyConfig, SB(2126), "FoodDrop", 440+offy); - - addKeyConfigLine(group_keyConfig, SB(2127), "Look", 460+offy); - - addKeyConfigLine(group_keyConfig, SB(2128), "ToggleHelp", 480+offy); - -#undef SB - - group_keyConfig->shareAlphaWithChildren = 1; - group_keyConfig->followCamera = 1; - group_keyConfig->alpha = 0; - group_keyConfig->setHidden(true); - - group_keyConfig->position = Vector(0, -40); - - addRenderObject(group_keyConfig, LR_OVERLAY); - - - cook = new AquariaMenuItem; - cook->useQuad("Gui/cook-button"); - cook->useGlow("particles/glow", 128, 40); - cook->position = worldRightCenter + Vector(0, -120); - cook->alpha = 0; - cook->scale = Vector(0.8, 0.8); - cook->event.set(MakeFunctionEvent(Game, onCook)); - cook->setCanDirMove(false); - addRenderObject(cook, LR_MENU); - - foodSort = new AquariaMenuItem; - foodSort->useQuad("gui/sort"); - foodSort->useSound("click"); - foodSort->useGlow("particles/glow", 32,32); - foodSort->position = worldLeftCenter + Vector(-100, -100); - foodSort->event.set(MakeFunctionEvent(Game, sortFood)); - foodSort->alpha = 0; - addRenderObject(foodSort, LR_MENU); - - recipes = new AquariaMenuItem; - recipes->useQuad("Gui/recipes-button"); - recipes->useGlow("particles/glow", 128, 32); - recipes->position = worldLeftCenter + Vector(-40, 140); - recipes->alpha = 0; - recipes->scale = Vector(0.8, 0.8); - recipes->event.set(MakeFunctionEvent(Game, onRecipes)); - addRenderObject(recipes, LR_MENU); - - use = new AquariaMenuItem; - use->useQuad("Gui/use-button"); - use->useGlow("particles/glow", 128, 64); - use->position = worldRightCenter + Vector(0, -120); - use->alpha = 0; - use->scale = Vector(0.8, 0.8); - use->event.set(MakeFunctionEvent(Game, onUseTreasure)); - addRenderObject(use, LR_MENU); - - prevFood = new AquariaMenuItem; - prevFood->useQuad("Gui/arrow-left"); - prevFood->useSound("click"); - prevFood->useGlow("particles/glow", 64, 32); - prevFood->position = worldLeftCenter + Vector(-50, -130); - prevFood->alpha = 0; - prevFood->event.set(MakeFunctionEvent(Game, onPrevFoodPage)); - prevFood->scale = Vector(0.6, 0.6); - prevFood->setCanDirMove(false); - addRenderObject(prevFood, LR_MENU); - - nextFood = new AquariaMenuItem; - nextFood->useQuad("Gui/arrow-right"); - nextFood->useSound("click"); - nextFood->useGlow("particles/glow", 64, 32); - nextFood->position = worldLeftCenter + Vector(50, -130); - nextFood->alpha = 0; - nextFood->setCanDirMove(false); - nextFood->event.set(MakeFunctionEvent(Game, onNextFoodPage)); - nextFood->scale = Vector(0.6, 0.6); - addRenderObject(nextFood, LR_MENU); - - prevTreasure = new AquariaMenuItem; - prevTreasure->useQuad("Gui/arrow-left"); - prevTreasure->useSound("click"); - prevTreasure->useGlow("particles/glow", 64, 32); - prevTreasure->position = worldLeftCenter + Vector(-50, -130); - prevTreasure->alpha = 0; - prevTreasure->setCanDirMove(false); - prevTreasure->scale = Vector(0.6, 0.6); - prevTreasure->event.set(MakeFunctionEvent(Game, onPrevTreasurePage)); - prevTreasure->setCanDirMove(false); - addRenderObject(prevTreasure, LR_MENU); - - nextTreasure = new AquariaMenuItem; - nextTreasure->useQuad("Gui/arrow-right"); - nextTreasure->useSound("click"); - nextTreasure->useGlow("particles/glow", 64, 32); - nextTreasure->position = worldLeftCenter + Vector(50, -130); - nextTreasure->alpha = 0; - nextTreasure->scale = Vector(0.6, 0.6); - nextTreasure->event.set(MakeFunctionEvent(Game, onNextTreasurePage)); - nextTreasure->setCanDirMove(false); - addRenderObject(nextTreasure, LR_MENU); - - circlePageNum = new BitmapText(&dsq->smallFont); - circlePageNum->color = Vector(0,0,0); - circlePageNum->position = worldLeftCenter + Vector(0, -142); - circlePageNum->alpha = 0; - circlePageNum->followCamera = 1; - addRenderObject(circlePageNum, LR_MENU); - - foodHolders.resize(3); - int holders=0; - for (i = 0; i < foodHolders.size(); i++) - { - foodHolders[i] = new FoodHolder(i); - foodHolders[i]->alpha = 0; - - float angle = (float(holders)/float(foodHolders.size()))*PI*2; - foodHolders[i]->position = rightCenter + Vector(sinf(angle), cosf(angle))*radius; - holders ++; - - menuBg->addChild(foodHolders[i], PM_POINTER); - } - - previewRecipe = new Quad; - previewRecipe->alphaMod = 0.75; - previewRecipe->followCamera = 1; - previewRecipe->alpha = 0; - previewRecipe->scale = Vector(0.7, 0.7); - previewRecipe->scale.interpolateTo(Vector(0.9, 0.9), 0.5, -1, 1, 1); - previewRecipe->position = worldRightCenter; - addRenderObject(previewRecipe, LR_MENU); - - showRecipe = new Quad(); - showRecipe->followCamera = 1; - showRecipe->position = Vector(575,250); - addRenderObject(showRecipe, LR_MENU); - - float scrollx = 555; - recipeMenu.scroll = new Quad("gui/recipe-scroll", Vector(scrollx, 200)); - recipeMenu.scroll->followCamera = 1; - recipeMenu.scroll->alpha = 0; - addRenderObject(recipeMenu.scroll, LR_RECIPES); // LR_HUD3 - - recipeMenu.scrollEnd = new Quad("gui/recipe-scroll-end", Vector(scrollx, 400)); - recipeMenu.scrollEnd->followCamera = 1; - recipeMenu.scrollEnd->alpha = 0; - addRenderObject(recipeMenu.scrollEnd, LR_RECIPES); - - recipeMenu.header = new BitmapText(&dsq->font); - recipeMenu.header->color = 0; - recipeMenu.header->followCamera = 1; - recipeMenu.header->setText(dsq->continuity.stringBank.get(2007)); - recipeMenu.header->alpha = 0; - recipeMenu.header->position = Vector(scrollx, 5); //10 - addRenderObject(recipeMenu.header, LR_RECIPES); - - recipeMenu.page = new BitmapText(&dsq->smallFont); - recipeMenu.page->color = 0; - recipeMenu.page->followCamera = 1; - recipeMenu.page->position = Vector(scrollx, 400); - recipeMenu.page->setText(dsq->continuity.stringBank.get(2006)); - recipeMenu.page->alpha = 0; - addRenderObject(recipeMenu.page, LR_RECIPES); - - recipeMenu.prevPage = new AquariaMenuItem; - recipeMenu.prevPage->useQuad("Gui/arrow-left"); - recipeMenu.prevPage->useSound("click"); - recipeMenu.prevPage->useGlow("particles/glow", 64, 32); - recipeMenu.prevPage->position = Vector(scrollx - 150, 410); - recipeMenu.prevPage->alpha = 0; - recipeMenu.prevPage->event.set(MakeFunctionEvent(Game, onPrevRecipePage)); - recipeMenu.prevPage->scale = Vector(0.8, 0.8); - addRenderObject(recipeMenu.prevPage, LR_RECIPES); - - recipeMenu.nextPage = new AquariaMenuItem; - recipeMenu.nextPage->useQuad("Gui/arrow-right"); - recipeMenu.nextPage->useSound("click"); - recipeMenu.nextPage->useGlow("particles/glow", 64, 32); - recipeMenu.nextPage->position = Vector(scrollx + 150, 410); - recipeMenu.nextPage->alpha = 0; - recipeMenu.nextPage->event.set(MakeFunctionEvent(Game, onNextRecipePage)); - recipeMenu.nextPage->scale = Vector(0.8, 0.8); - addRenderObject(recipeMenu.nextPage, LR_RECIPES); - - - petSlots.resize(dsq->continuity.petData.size()); - for (i = 0; i < petSlots.size(); i++) - { - PetData *p = dsq->continuity.getPetData(i); - if (p) - { - petSlots[i] = new PetSlot(i); - petSlots[i]->alpha = 0; - float angle = (float(i)/float(petSlots.size()))*PI*2; - petSlots[i]->position = center + Vector(sinf(angle), cosf(angle))*(radius*0.9f); - menuBg->addChild(petSlots[i], PM_POINTER); - } - } - - foodHolders.resize(4); - foodHolders[3] = new FoodHolder(-1, true); - foodHolders[3]->alpha = 0; - foodHolders[3]->position = rightCenter + Vector(96, 150); - menuBg->addChild(foodHolders[3], PM_POINTER); - - - - int outer = 0; - int inner = 0; - for (i = 0; i < songSlots.size(); i++) - { - songSlots[i] = new SongSlot(i); - float angle = 0; - SongType s = (SongType)dsq->continuity.getSongTypeBySlot(i); - if (dsq->continuity.isSongTypeForm(s)) - { - angle = (float(outer)/float(numForms))*PI*2; - songSlots[i]->position = center + Vector(sinf(angle), cosf(angle))*radius; - outer ++; - } - else - { - angle = (float(inner)/float(songSlots.size()-numForms))*PI*2 + PI; - songSlots[i]->position = center + Vector(sinf(angle), cosf(angle))*radius*0.4f; - inner ++; - } - menuBg->addChild(songSlots[i], PM_POINTER); - } - menuSongs = 0; - - menuMoney = menuEXP = 0; - - menuDescription = new BitmapText(&dsq->smallFont); - menuDescription->setFontSize(14); - menuDescription->position = Vector(400, 450); - menuDescription->setAlign(ALIGN_CENTER); - menuDescription->setWidth(400); - menuDescription->followCamera = 1; - menuDescription->alpha = 0; - addRenderObject(menuDescription, LR_MENU); - - currentInventoryPage = 0; - - int areYouShim = -25; - eAre = new Quad; - eAre->position = Vector(400,448+areYouShim); - eAre->setTexture("AreYouSure"); - eAre->alpha = 0; - eAre->followCamera = 1; - addRenderObject(eAre, LR_MENU); - - eYes = new AquariaMenuItem; - eYes->position = Vector(400-100,516+areYouShim); - eYes->useQuad("Yes"); - eYes->useGlow("particles/glow", 100, 32); - eYes->event.set(MakeFunctionEvent(Game, onExitCheckYes)); - eYes->alpha = 0; - eYes->shareAlpha = 1; - addRenderObject(eYes, LR_MENU); - - eNo = new AquariaMenuItem; - eNo->position = Vector(400+100,516+areYouShim); - eNo->useQuad("No"); - eNo->useGlow("particles/glow", 100, 32); - eNo->event.set(MakeFunctionEvent(Game, onExitCheckNo)); - eNo->alpha = 0; - eNo->shareAlpha = 1; - addRenderObject(eNo, LR_MENU); - - eNo->setDirMove(DIR_LEFT, eYes); - eYes->setDirMove(DIR_RIGHT, eNo); - - - - menu.resize(10); - for (i = 0; i < menu.size(); i++) - menu[i] = new AquariaMenuItem; - - int ty = 530; - //menu[0]->setLabel("Continue"); - menu[0]->event.set(MakeFunctionEvent(Game, onInGameMenuContinue)); - menu[0]->useGlow("particles/glow", 200, 100); - //menu[0]->position = Vector(150, 550); - menu[0]->position = Vector(150-30, ty-10); - - //menu[1]->setLabel("Exit"); - menu[1]->useGlow("particles/glow", 200, 100); - menu[1]->event.set(MakeFunctionEvent(Game, onInGameMenuExit)); - //menu[1]->position = Vector(800-150, 550); - //menu[1]->position = Vector(800-150+30, ty); - menu[1]->position = Vector(800-150+20, ty-10); - - menu[2]->setLabel("DebugSave"); - menu[2]->event.set(MakeFunctionEvent(Game, onDebugSave)); - menu[2]->position = Vector(400,ty+60); - if (!dsq->isDeveloperKeys()) - menu[2]->position = Vector(400, 12000); - menu[2]->setCanDirMove(false); - - menu[3]->event.set(MakeFunctionEvent(Game, onLips)); - menu[3]->useGlow("particles/glow", 64, 64); - //menu[0]->position = Vector(150, 550); - menu[3]->position = Vector(400, 195); - menu[3]->setCanDirMove(false); - - lips = menu[3]; - - // options - menu[4]->event.set(MakeFunctionEvent(Game, onOptionsMenu)); - menu[4]->useGlow("particles/glow", 200, 32); - menu[4]->position = Vector(400,ty+10); - - int gs = 40; - - menu[5]->event.set(MakeFunctionEvent(Game, switchToSongMenu)); - menu[5]->useQuad("gui/icon-songs"); - menu[5]->useGlow("particles/glow", gs, gs); - menu[5]->useSound("Click"); - menu[5]->position = Vector(400-60, 350); - - menuIconGlow = new Quad("particles/glow", menu[5]->position); - menuIconGlow->alphaMod = 0.4; - menuIconGlow->alpha = 0; - menuIconGlow->setWidthHeight(80, 80); - menuIconGlow->setBlendType(RenderObject::BLEND_ADD); - menuIconGlow->followCamera = 1; - addRenderObject(menuIconGlow, LR_MENU); - - menu[6]->event.set(MakeFunctionEvent(Game, switchToFoodMenu)); - menu[6]->useQuad("gui/icon-food"); - menu[6]->useGlow("particles/glow", gs, gs); - menu[6]->useSound("Click"); - menu[6]->position = Vector(400-20, 350); - - menu[7]->event.set(MakeFunctionEvent(Game, switchToPetMenu)); - menu[7]->useQuad("gui/icon-pets"); - menu[7]->useGlow("particles/glow", gs, gs); - menu[7]->useSound("Click"); - menu[7]->position = Vector(400+20, 350); - - menu[8]->event.set(MakeFunctionEvent(Game, switchToTreasureMenu)); - menu[8]->useQuad("gui/icon-treasures"); - menu[8]->useGlow("particles/glow", gs, gs); - menu[8]->useSound("Click"); - menu[8]->position = Vector(400+60, 350); - - menu[9]->event.set(MakeFunctionEvent(Game, toggleHelpScreen)); - menu[9]->useQuad("gui/icon-help"); - menu[9]->useGlow("particles/glow", gs, gs); - menu[9]->useSound("Click"); - menu[9]->position = Vector(400+60*3, 410); - - /* - menu[9]->event.set(MakeFunctionEvent(Game, sortFood)); - menu[9]->setLabel("sort food"); - menu[9]->position = Vector(100,100); - */ - - for (i = 0; i < menu.size(); i++) - { - addRenderObject(menu[i], LR_MENU); - menu[i]->alpha = 0; - } - - ((AquariaMenuItem*)menu[5])->setDirMove(DIR_DOWN, ((AquariaMenuItem*)menu[0])); - ((AquariaMenuItem*)menu[6])->setDirMove(DIR_DOWN, ((AquariaMenuItem*)menu[4])); - ((AquariaMenuItem*)menu[7])->setDirMove(DIR_DOWN, ((AquariaMenuItem*)menu[4])); - ((AquariaMenuItem*)menu[8])->setDirMove(DIR_DOWN, ((AquariaMenuItem*)menu[1])); - - ((AquariaMenuItem*)menu[0])->setDirMove(DIR_UP, ((AquariaMenuItem*)menu[5])); - ((AquariaMenuItem*)menu[1])->setDirMove(DIR_UP, ((AquariaMenuItem*)menu[8])); - - ((AquariaMenuItem*)menu[4])->setDirMove(DIR_UP, ((AquariaMenuItem*)menu[6])); - - - -// ---------- FOOD MENU - - foodSlots.resize(foodPageSize); - - Vector worldCenter(222, 252); - - int foodSlotRadius = 96; - for (i = 0; i < foodSlots.size(); i++) - { - foodSlots[i] = new FoodSlot(i); - - float angle = (float(food)/float(foodSlots.size()))*PI*2; - foodSlots[i]->position = worldCenter + Vector(sinf(angle), cosf(angle))*foodSlotRadius; - - foodSlots[i]->setOriginalPosition(foodSlots[i]->position); - - food ++; - - foodSlots[i]->alphaMod = 0; - - foodSlots[i]->followCamera = 1; - - foodSlots[i]->scaleFactor = 0.75; - - //foodSlots[i]->parentManagedPointer = 1; - //menuBg->addChild(foodSlots[i]); - //foodSlots[i]->position = menuBg->getWorldCollidePosition(foodSlots[i]->position); - addRenderObject(foodSlots[i], LR_HUD2); - } - - - foodLabel = new BitmapText(&dsq->smallFont); - { - foodLabel->alpha = 0; - foodLabel->setAlign(ALIGN_CENTER); - foodLabel->followCamera = 1; - foodLabel->setFontSize(20); - foodLabel->position = center - Vector(0, 16) + Vector(0,-32); - foodLabel->scale = Vector(1, 1); - } - menuBg->addChild(foodLabel, PM_POINTER); - - foodDescription = new BitmapText(&dsq->smallFont); - { - foodDescription->alpha = 0; - foodDescription->setAlign(ALIGN_CENTER); - foodDescription->followCamera = 1; - foodDescription->position = center + Vector(0, 8) + Vector(0,-32); - foodDescription->scale = Vector(0.8, 0.8); - - foodDescription->setWidth(240); - } - menuBg->addChild(foodDescription, PM_POINTER); - - -// ---------- TREASURES - - - int treasureSlotRadius = 96; - - treasureSlots.resize(treasurePageSize); - - for (i = 0; i < treasureSlots.size(); i++) - { - treasureSlots[i] = new TreasureSlot(i); - - - float angle = (float(i)/float(treasureSlots.size()))*PI*2; - treasureSlots[i]->position = worldCenter + Vector(sinf(angle), cosf(angle))*treasureSlotRadius; - - treasureSlots[i]->alphaMod = 0; - - treasureSlots[i]->followCamera = 1; - - //treasureSlots[i]->scaleFactor = 0.75; - - addRenderObject(treasureSlots[i], LR_MENU); - } - - treasureLabel = new BitmapText(&dsq->smallFont); - { - treasureLabel->alpha = 0; - treasureLabel->setAlign(ALIGN_CENTER); - treasureLabel->followCamera = 1; - treasureLabel->setFontSize(20); - treasureLabel->position = center - Vector(0, 16); - treasureLabel->scale = Vector(1, 1); - } - menuBg->addChild(treasureLabel, PM_POINTER); - - treasureDescription = new ToolTip(); - treasureDescription->alpha = 0; - treasureDescription->setAreaFromCenter(Vector(400,200), 800, 400); - treasureDescription->required = true; - addRenderObject(treasureDescription, LR_HUD); - - foodTips.push_back(tip); - - treasureCloseUp = new Quad(); - treasureCloseUp->position = rightCenter; - treasureCloseUp->alpha = 0; - menuBg->addChild(treasureCloseUp, PM_POINTER); - - - - menuBg->alpha = 0; -} - -void Game::onNextRecipePage() -{ - game->recipeMenu.goNextPage(); -} - -void Game::onPrevRecipePage() -{ - game->recipeMenu.goPrevPage(); -} - void Game::toggleOverrideZoom(bool on) { if (avatar) @@ -4144,25 +1294,6 @@ void Game::toggleOverrideZoom(bool on) } } -void Game::addProgress() -{ - if (progressBar) - { - progressBar->progress(); - } -} - -void Game::endProgress() -{ - if (progressBar) - { - progressBar->setLife(1); - progressBar->setDecayRate(1.0f/0.5f); - progressBar->fadeAlphaWithLife = 1; - progressBar = 0; - } -} - bool Game::loadSceneXML(std::string scene) { bgSfxLoop = ""; @@ -4193,50 +1324,8 @@ bool Game::loadSceneXML(std::string scene) { saveFile = new XMLDocument(); } - - addProgress(); - clearObsRows(); - warpAreas.clear(); - XMLElement *lensFlare = doc.FirstChildElement("LensFlare"); - while (lensFlare) - { - LensFlare *l = new LensFlare; - SimpleIStringStream is(lensFlare->Attribute("tex")); - int w = -1, h=-1; - w = atoi(lensFlare->Attribute("w")); - h = atoi(lensFlare->Attribute("h")); - std::string tex; - while (is >> tex) - { - if (!tex.empty()) - l->addFlare(tex, Vector(1,1,1), w, h); - } - SimpleIStringStream is2(lensFlare->Attribute("inc")); - is2 >> l->inc; - l->maxLen = atoi(lensFlare->Attribute("maxLen")); - /* - l->addFlare("flares/flare0", Vector(1,1,0.5)); - l->addFlare("flares/flare1", Vector(1,1,1)); - l->addFlare("flares/flare2", Vector(0.5,1,1)); - l->addFlare("flares/flare2", Vector(1,1,1)); - */ - l->position = Vector(atoi(lensFlare->Attribute("x")),atoi(lensFlare->Attribute("y"))); - addRenderObject(l, LR_LIGHTING); - - XMLElement *lSF = saveFile->NewElement("LensFlare"); - lSF->SetAttribute("inc", lensFlare->Attribute("inc")); - lSF->SetAttribute("x", lensFlare->Attribute("x")); - lSF->SetAttribute("y", lensFlare->Attribute("y")); - lSF->SetAttribute("tex", lensFlare->Attribute("tex")); - lSF->SetAttribute("w", lensFlare->Attribute("w")); - lSF->SetAttribute("h", lensFlare->Attribute("h")); - lSF->SetAttribute("maxLen", lensFlare->Attribute("maxLen")); - saveFile->InsertEndChild(lSF); - - lensFlare = lensFlare->NextSiblingElement("LensFlare"); - } XMLElement *level = doc.FirstChildElement("Level"); if (level) { @@ -4289,14 +1378,6 @@ bool Game::loadSceneXML(std::string scene) bNatural = false; } - /* - if (level->Attribute("darkLayer")) - { - int v = (atoi(level->Attribute("darkLayer"))); - - levelSF->SetAttribute("darkLayer", v); - } - */ dsq->darkLayer.toggle(true); if (level->Attribute("bgRepeat")) @@ -4321,23 +1402,11 @@ bool Game::loadSceneXML(std::string scene) os << maxZoom; levelSF->SetAttribute("maxZoom", os.str().c_str()); } - if (level->Attribute("natureForm")) - { - sceneNatureForm = level->Attribute("natureForm"); - levelSF->SetAttribute("natureForm", sceneNatureForm.c_str()); - } if (level->Attribute("bg")) { std::string tex = std::string(level->Attribute("bg")); if (!tex.empty()) { - /* - if (tex.find('.') == std::string::npos) - bg->setTexture(tex+""); - else - bg->setTexture(tex); - */ - bg->setTexture(tex); bg->setWidthHeight(900,600); levelSF->SetAttribute("bg", tex.c_str()); @@ -4350,7 +1419,6 @@ bool Game::loadSceneXML(std::string scene) else { bg->alpha = 0; - //grad->alpha =0; } gradTop = gradBtm = Vector(0,0,0); if (level->Attribute("gradient")) @@ -4425,12 +1493,6 @@ bool Game::loadSceneXML(std::string scene) std::string tex = std::string(level->Attribute("bg2")); if (!tex.empty()) { - /* - if (tex.find('.') == std::string::npos) - bg2->setTexture(tex+""); - else - bg2->setTexture(tex); - */ bg2->setTexture(tex); bg2->setWidthHeight(900,600); levelSF->SetAttribute("bg2", tex.c_str()); @@ -4438,7 +1500,6 @@ bool Game::loadSceneXML(std::string scene) } else bg2->alpha = 0; - //createGradient(); bg2->alpha = 0; bg->alpha = 0; @@ -4446,7 +1507,6 @@ bool Game::loadSceneXML(std::string scene) else { bg2->alpha = 0; - //grad->alpha =0; } if (level->Attribute("backdrop")) @@ -4473,7 +1533,6 @@ bool Game::loadSceneXML(std::string scene) levelSF->SetAttribute("bd-h", h); } backdropQuad->toggleCull(false); - //backdropQuad->followCamera = 1; addRenderObject(backdropQuad, LR_SCENEBACKGROUNDIMAGE); // upper left justify @@ -4482,7 +1541,6 @@ bool Game::loadSceneXML(std::string scene) (backdropQuad->getHeight()*backdropQuad->scale.y)/2.0f); // save levelSF->SetAttribute("backdrop", backdrop.c_str()); - //backdrop="cavebg" bd-w="2400" bd-h="2400" } musicToPlay = ""; if (level->Attribute("music")) @@ -4490,13 +1548,6 @@ bool Game::loadSceneXML(std::string scene) setMusicToPlay(level->Attribute("music")); saveMusic = level->Attribute("music"); levelSF->SetAttribute("music", level->Attribute("music")); - /* - // if using SDL_Mixer - if (!core->sound->isPlayingMusic(musicToPlay)) - { - core->sound->fadeMusic(SFT_OUT, 1); - } - */ } if (level->Attribute("sceneColor")) { @@ -4520,7 +1571,6 @@ bool Game::loadSceneXML(std::string scene) is >> ty >> len; addObsRow(tx, ty, len); } - addProgress(); } XMLElement *pathXml = doc.FirstChildElement("Path"); @@ -4529,12 +1579,6 @@ bool Game::loadSceneXML(std::string scene) Path *path = new Path; path->name = pathXml->Attribute("name"); stringToLower(path->name); - /* - if (pathXml->Attribute("active")) - { - path.active = atoi(pathXml->Attribute("active")); - } - */ XMLElement *nodeXml = pathXml->FirstChildElement("Node"); while (nodeXml) { @@ -4566,7 +1610,6 @@ bool Game::loadSceneXML(std::string scene) } path->refreshScript(); addPath(path); - addProgress(); pathXml = pathXml->NextSiblingElement("Path"); } @@ -4582,7 +1625,6 @@ bool Game::loadSceneXML(std::string scene) std::string tex; qSF->SetAttribute("x", x = atoi(quad->Attribute("x"))); qSF->SetAttribute("y", y = atoi(quad->Attribute("y"))); - //qSF->SetAttribute("z", z = atoi(quad->Attribute("z"))); qSF->SetAttribute("w", w = atoi(quad->Attribute("w"))); qSF->SetAttribute("h", h = atoi(quad->Attribute("h"))); qSF->SetAttribute("tex", (tex = (quad->Attribute("tex"))).c_str()); @@ -4594,15 +1636,7 @@ bool Game::loadSceneXML(std::string scene) Quad *q = new Quad; q->position = Vector(x,y,z); - /* - if (solid) - Texture::pngLoadHaloFix = false; - */ q->setTexture(tex); - /* - if (solid) - Texture::pngLoadHaloFix = true; - */ q->toggleCull(cull); q->setWidthHeight(w, h); @@ -4617,125 +1651,6 @@ bool Game::loadSceneXML(std::string scene) quad = quad->NextSiblingElement("Quad"); } - XMLElement *floater = doc.FirstChildElement("Floater"); - while(floater) - { - XMLElement *nSF = doc.NewElement("Floater"); - if (!floater->Attribute("boxW") || !floater->Attribute("boxH")) - { - errorLog ("no boxW/boxH"); - break; - } - int boxW, boxH, x, y, fx, fy; - nSF->SetAttribute("boxW", boxW = atoi(floater->Attribute("boxW"))); - nSF->SetAttribute("boxH", boxH = atoi(floater->Attribute("boxH"))); - nSF->SetAttribute("tex", floater->Attribute("tex")); - nSF->SetAttribute("x", x = atoi(floater->Attribute("x"))); - nSF->SetAttribute("y", y = atoi(floater->Attribute("y"))); - nSF->SetAttribute("fx", fx = atoi(floater->Attribute("fx"))); - nSF->SetAttribute("fy", fy = atoi(floater->Attribute("fy"))); - - /* - Floater *f = new Floater(Vector(x,y), Vector(fx, fy), boxW, boxH, tex); - { - } - addRenderObject(f, LR_BACKGROUND); - saveFile->InsertEndChild(nSF); - */ - floater = floater->NextSiblingElement("Floater"); - - } - - /* - XMLElement *breakable = doc.FirstChildElement("Breakable"); - while(breakable) - { - XMLElement *nSF = doc.NewElement("Breakable"); - if (!breakable->Attribute("boxW") || !breakable->Attribute("boxH")) - { - errorLog ("Breakable error.. no boxW/boxH"); - break; - } - int boxW, boxH; - std::string tex; - nSF->SetAttribute("boxW", boxW = atoi(breakable->Attribute("boxW"))); - nSF->SetAttribute("boxH", boxH = atoi(breakable->Attribute("boxH"))); - tex = breakable->Attribute("tex"); - nSF->SetAttribute("tex", tex); - Breakable *n = new Breakable(boxW, boxH, tex); - { - nSF->SetAttribute("x", n->position.x = atoi(breakable->Attribute("x"))); - nSF->SetAttribute("y", n->position.y = atoi(breakable->Attribute("y"))); - int w=0, h=0; - if (breakable->Attribute("w")) - nSF->SetAttribute("w", w = atoi(breakable->Attribute("w"))); - if (breakable->Attribute("h")) - nSF->SetAttribute("h", h= atoi(breakable->Attribute("h"))); - if (w != 0 && h != 0) - { - n->setWidthHeight(w, h); - } - } - addRenderObject(n, LR_BACKGROUND); - saveFile->InsertEndChild(nSF); - breakable = breakable->NextSiblingElement("Breakable"); - } - */ - - XMLElement *warpArea = doc.FirstChildElement("WarpArea"); - while(warpArea) - { - XMLElement *waSF = doc.NewElement("WarpArea"); - WarpArea a; - waSF->SetAttribute("x", a.position.x = atoi(warpArea->Attribute("x"))); - waSF->SetAttribute("y", a.position.y = atoi(warpArea->Attribute("y"))); - if (warpArea->Attribute("radius")) - waSF->SetAttribute("radius", a.radius = atoi(warpArea->Attribute("radius"))); - bool isRect = false; - if (warpArea->Attribute("w")) - { - isRect = true; - waSF->SetAttribute("w", a.w = atoi(warpArea->Attribute("w"))); - waSF->SetAttribute("h", a.h = atoi(warpArea->Attribute("h"))); - } - if (warpArea->Attribute("g")) - { - waSF->SetAttribute("g", a.generated = atoi(warpArea->Attribute("g"))); - } - std::string sceneString = warpArea->Attribute("scene"); - waSF->SetAttribute("scene", sceneString.c_str()); - /* - waSF->SetAttribute("ax", a.avatarPosition.x = atoi(warpArea->Attribute("ax"))); - waSF->SetAttribute("ay", a.avatarPosition.y = atoi(warpArea->Attribute("ay"))); - */ - - SimpleIStringStream is(sceneString); - std::string sceneName, warpAreaType, side; - is >> sceneName >> warpAreaType >> a.spawnOffset.x >> a.spawnOffset.y; - a.spawnOffset.normalize2D(); - a.sceneName = sceneName; - a.warpAreaType = warpAreaType; - //a.side = side; - // saveFile->InsertEndChild(waSF); - - bool add = true; - std::string flagCheck; - if (warpArea->Attribute("flagCheck")) - { - flagCheck = warpArea->Attribute("flagCheck"); - add = doFlagCheck(flagCheck); - } - if (add) - warpAreas.push_back(a); - - if (a.generated) - { - setWarpAreaSceneName(a); - } - - warpArea = warpArea->NextSiblingElement("WarpArea"); - } - XMLElement *schoolFish = doc.FirstChildElement("SchoolFish"); while(schoolFish) { @@ -4750,11 +1665,6 @@ bool Game::loadSceneXML(std::string scene) { gfx = schoolFish->Attribute("gfx"); texture = gfx; - /* - std::ostringstream os; - os << "flock-" << gfx << ""; - texture = os.str(); - */ } int layer = 0; if (schoolFish->Attribute("layer")) @@ -4804,31 +1714,9 @@ bool Game::loadSceneXML(std::string scene) else addRenderObject(s, LR_ENTITIES); } - - /*if (layer == 1) - { - addRenderObject(s, LR_ENTITIES); - } - else - { - // school fish layer hack - // because we want all fish on top dammit - //addRenderObject(s, LR_ENTITIES2); - - // or... not? - //hrm.. why not? - if (chance(50)) - addRenderObject(s, LR_ENTITIES2); - else - addRenderObject(s, LR_ENTITIES); - //s->setOverrideRenderPass(4); - } - */ s->applyLayer(layer); s->scale *= size; - //s->update(0.033); - } schoolFish = schoolFish->NextSiblingElement("SchoolFish"); @@ -4852,18 +1740,7 @@ bool Game::loadSceneXML(std::string scene) saveFile->InsertEndChild(newSF); } - /* - XMLElement *boxElement = doc.FirstChildElement("BoxElement"); - while (boxElement) - { - BoxElement *b = new BoxElement(atoi(boxElement->Attribute("w")), atoi(boxElement->Attribute("h"))); - b->position = Vector(atoi(boxElement->Attribute("x")), atoi(boxElement->Attribute("y"))); - addRenderObject(b, LR_BLACKGROUND); - b->position.z = boxElementZ; - dsq->addElement(b); - boxElement = boxElement->NextSiblingElement("BoxElement"); - } - */ + std::vector loadedElements; loadedElements.reserve(200); XMLElement *simpleElements = doc.FirstChildElement("SE"); @@ -5005,7 +1882,6 @@ bool Game::loadSceneXML(std::string scene) { SimpleIStringStream is2(simpleElements->Attribute("k")); int l = atoi(simpleElements->Attribute("l")); - int c = 0; while(is2 >> idx) { int fh, fv; @@ -5030,13 +1906,6 @@ bool Game::loadSceneXML(std::string scene) if (repeat) e->repeatTextureToFill(true); - c++; - if (c> 100) - { - c=0; - addProgress(); - } - loadedElements.push_back(e); } } @@ -5106,27 +1975,6 @@ bool Game::loadSceneXML(std::string scene) this->reconstructGrid(true); - /* - XMLElement *enemyNode = doc.FirstChildElement("Enemy"); - while(enemyNode) - { - Vector pos; - pos.x = atoi(enemyNode->Attribute("x")); - pos.y = atoi(enemyNode->Attribute("y")); - - std::string type = enemyNode->Attribute("type"); - - std::string flagCheck; - if (enemyNode->Attribute("flagCheck")) - { - flagCheck = enemyNode->Attribute("flagCheck"); - } - if (doFlagCheck(flagCheck)) - Entity *e = createEnemy(type, pos, true, enemyNode, flagCheck, -1); - - enemyNode = enemyNode->NextSiblingElement("Enemy"); - } - */ XMLElement *entitiesNode = doc.FirstChildElement("Entities"); while(entitiesNode) { @@ -5150,13 +1998,7 @@ bool Game::loadSceneXML(std::string scene) } entitiesNode = entitiesNode->NextSiblingElement("Entities"); } - //assignEntitiesUniqueIDs(); - //initEntities(); - FOR_ENTITIES(i) - { - Entity *e = *i; - e->onSceneFlipped(); - } + this->reconstructGrid(true); rebuildElementUpdateList(); setElementLayerFlags(); @@ -5168,8 +2010,6 @@ bool Game::loadSceneXML(std::string scene) findMaxCameraValues(); - endProgress(); - return true; } @@ -5200,16 +2040,6 @@ void Game::findMaxCameraValues() cameraMax.y = v.y; } } - /* - for (i = 0; i < dsq->getNumElements(); i++) - { - Element *e = dsq->getElement(i); - if (e->position.x > cameraMax.x) - cameraMax.x = e->position.x; - if (e->position.y > cameraMax.y) - cameraMax.y = e->position.y; - } - */ if (backdropQuad) { if (backdropQuad->getWidth() > cameraMax.x) @@ -5223,45 +2053,6 @@ void Game::findMaxCameraValues() } } -void Game::setWarpAreaSceneName(WarpArea &warpArea) -{ - InStream in("data/warpAreas.txt"); - std::string color, area1, dir1, area2, dir2; - std::string line; - while (std::getline(in, line)) - { - - std::istringstream is(line); - is >> color >> area1 >> dir1 >> area2 >> dir2; - /* - errorLog (color + " : " + area1 + " : " + dir1 + " : " + area2 + " : " + dir2); - */ - if (area2 == dsq->game->sceneName && warpArea.warpAreaType == color) - { - area2 = area1; - dir2 = dir1; - area1 = dsq->game->sceneName; - } - if (area1 == dsq->game->sceneName && warpArea.warpAreaType == color) - { - if (dir2=="Left") - warpArea.spawnOffset = Vector(-1,0); - else if (dir2=="Right") - warpArea.spawnOffset = Vector(1,0); - else if (dir2=="Up") - warpArea.spawnOffset = Vector(0,-1); - else if (dir2=="Down") - warpArea.spawnOffset = Vector(0,1); - warpArea.sceneName = area2; - break; - } - } - if (warpArea.sceneName.empty()) - { - errorLog(warpArea.warpAreaType + " WarpArea for " + dsq->game->sceneName + " not found"); - } -} - bool Game::loadScene(std::string scene) { stringToLower(scene); @@ -5272,40 +2063,11 @@ bool Game::loadScene(std::string scene) return false; } -#ifdef AQUARIA_DEMO - int i = 0; - for (; i < allowedMaps.size(); i++) - { - if (allowedMaps[i] == scene) - break; - } - if (i == allowedMaps.size()) - { - exit_error("Demo version refuses to load this map, sorry."); - } -#endif - - loadingScene = true; bool ret = loadSceneXML(scene); loadingScene = false; return ret; - - /* - std::string fn = ("data/maps/"+scene+".xml"); - if (!exists(fn)) - { - loadSceneDAT(scene); - return; - } - loadSceneXML(scene); - */ - - - /* - - */ } bool Game::saveScene(std::string scene) @@ -5362,21 +2124,6 @@ bool Game::saveScene(std::string scene) } } - /* - XMLElement *level = doc.NewElement("Level"); - level->SetAttribute("elementTemplatePack", elementTemplatePack); - if (bg) - { - int pos = bg->texture->name.find_last_of('/')+1; - int pos2 = bg->texture->name.find_last_of('.'); - level->SetAttribute("bg", bg->texture->name.substr(pos, pos2-pos)); - std::ostringstream os; - os << sceneColor.x << " " << sceneColor.y << " " << sceneColor.z; - level->SetAttribute("sceneColor", os.str()); - } - saveFile->InsertEndChild(level); - */ - std::ostringstream obs; int i = 0; for (i = 0; i < obsRows.size(); i++) @@ -5393,7 +2140,6 @@ bool Game::saveScene(std::string scene) XMLElement *pathXml = saveFile.NewElement("Path"); Path *p = dsq->game->getPath(i); pathXml->SetAttribute("name", p->name.c_str()); - //pathXml->SetAttribute("active", p->active); for (int n = 0; n < p->nodes.size(); n++) { XMLElement *nodeXml = saveFile.NewElement("Node"); @@ -5413,30 +2159,6 @@ bool Game::saveScene(std::string scene) saveFile.InsertEndChild(pathXml); } - for (i = 0; i < dsq->game->warpAreas.size(); i++) - { - WarpArea a = dsq->game->warpAreas[i]; - XMLElement *waSF = saveFile.NewElement("WarpArea"); - waSF->SetAttribute("x", a.position.x); - waSF->SetAttribute("y", a.position.y); - if (a.radius > 0) - waSF->SetAttribute("radius", a.radius); - else if (a.w > 0 && a.h > 0) - { - waSF->SetAttribute("w", a.w); - waSF->SetAttribute("h", a.h); - } - if (a.generated) - { - waSF->SetAttribute("g", 1); - } - std::ostringstream os; - os << a.sceneName << " " << a.warpAreaType << " " << a.spawnOffset.x << " " << a.spawnOffset.y; - waSF->SetAttribute("scene", os.str().c_str()); - - saveFile.InsertEndChild(waSF); - } - std::ostringstream simpleElements[LR_MAX]; std::ostringstream simpleElements_repeatScale[LR_MAX]; @@ -5504,33 +2226,6 @@ bool Game::saveScene(std::string scene) } } - // HACK: fix this later (won't save light shafts) - /* - for (Core::RenderObjects::iterator i = core->renderObjects.begin(); i != core->renderObjects.end(); i++) - { - LightShaft *l = dynamic_cast(*i); - if (l) - { - XMLElement *lightShaft = saveFile.NewElement("LightShaft"); - lightShaft->SetAttribute("x", l->position.x); - lightShaft->SetAttribute("y", l->position.y); - std::ostringstream os; - os << l->getDir().x; - lightShaft->SetAttribute("dirx", os.str()); - std::ostringstream os2; - os2 << l->getDir().y; - lightShaft->SetAttribute("diry", os2.str()); - std::ostringstream os3; - os3 << l->shaftWidth; - lightShaft->SetAttribute("w", os3.str()); - - //lightShaft->SetAttribute("dirx", int(l->getDir().x*1000)); - //lightShaft->SetAttribute("diry", int(l->getDir().y*1000)); - saveFile.InsertEndChild(lightShaft); - } - } - */ - bool result = saveFile.SaveFile(fn.c_str()) == XML_SUCCESS; if (result) debugLog("Successfully saved map: " + fn); @@ -5540,19 +2235,6 @@ bool Game::saveScene(std::string scene) return result; } -void Game::warpToArea(WarpArea *area) -{ - if (this->miniMapHint.scene == area->sceneName && this->miniMapHint.warpAreaType == area->warpAreaType) - { - miniMapHint.clear(); - } - //positionToAvatar = area->avatarPosition; - dsq->game->warpAreaType = area->warpAreaType; - dsq->game->spawnOffset = area->spawnOffset; - //dsq->game->warpAreaSide = area->; - dsq->game->transitionToScene(area->sceneName); -} - void Game::createGradient() { if (grad) @@ -5585,38 +2267,14 @@ void Game::createGradient() bool Game::isInGameMenu() { - return inGameMenu; + return themenu->isInGameMenu(); } bool Game::isValidTarget(Entity *e, Entity *me) { - //(e->layer == LR_ENTITIES0 || e->layer == LR_ENTITIES || e->layer == LR_ENTITIES2) - //&& true return (e != me && e->isNormalLayer() && e->isPresent() && e->getEntityType() == ET_ENEMY && e->isAvatarAttackTarget()); } -void Game::updateMiniMapHintPosition() -{ - miniMapHintPosition = Vector(0,0,0); - for (int i = 0; i < warpAreas.size(); i++) - { - if (this->sceneName == miniMapHint.scene) - { - if (warpAreas[i].warpAreaType == miniMapHint.warpAreaType) - { - miniMapHintPosition = warpAreas[i].position; - } - } - else - { - if (warpAreas[i].sceneName == miniMapHint.scene) - { - miniMapHintPosition = warpAreas[i].position; - } - } - } -} - void Game::createPets() { setActivePet(dsq->continuity.getFlag(FLAG_PET_ACTIVE)); @@ -5670,38 +2328,6 @@ void Game::createLi() } } -void Game::colorTest() -{ - // test element coloring - // possibly useful for darker maps - /* - std::vector quadLights; - quadLights.push_back(QuadLight(Vector(400, 300), Vector(1, 0, 0), 2000)); - for (int i = 0; i < dsq->getNumElements(); i++) - { - Element *e = dsq->getElement(i); - //e->color = Vector(rand()%100, rand()%100, rand()%100); - for (int i = 0; i < quadLights.size(); i++) - { - QuadLight *q = &quadLights[i]; - Vector dist = e->position - q->position; - if (dist.isLength2DIn(q->dist)) - { - float fract = float(dist.getLength2D())/float(quadLights[i].dist); - float amb = fract; - fract = 1.0f - fract; - e->color = Vector(1,1,1)*amb + q->color*fract; - } - else - { - e->color = Vector(1,1,0); - } - } - //e->color.normalize2D(); - } - */ -} - void Game::showImage(const std::string &gfx) { if (!image) @@ -5849,37 +2475,6 @@ int game_collideParticle(Vector pos) return dsq->game->isObstructed(t); } -void game_wibbleParticle(Particle *p) -{ - /* - if (dsq->game->avatar->getNotesOpen() > 0 && (p->position - dsq->game->avatar->position).isLength2DIn(256)) - { - if (!p->offset.isInterpolating()) - { - p->offset.interpolateTo(Vector(10,0), (8-dsq->game->avatar->getLastNote())/10.0f, -1, 1); - - //if (dsq->game->avatar->isSinging()) - //{ - // p->influenceVariable = 1; - // p->color.interpolateTo(dsq->getNoteColor(dsq->game->avatar->getLastNote()), 1.0); - //} - - } - else - { - } - } - else - { - p->offset.stop(); - - //if (p->influenceVariable) - // p->color.interpolateTo(Vector(1,1,1), 1); - - } - */ -} - void Game::rebuildElementUpdateList() { for (int i = LR_ELEMENTS1; i <= LR_ELEMENTS8; i++) @@ -5917,26 +2512,18 @@ float Game::getTimer(float mod) return timer*mod; } -float Game::getHalf2WayTimer(float mod) -{ - float t=timer; - if (t > 0.5f) - t = 1 - t; - return timer*2*mod; -} - float Game::getHalfTimer(float mod) { return halfTimer*mod; } -void Game::action(int id, int state) +void Game::action(int id, int state, int source) { for (int i = 0; i < paths.size(); i++) { if (paths[i]->catchActions) { - if (!paths[i]->action(id, state)) + if (!paths[i]->action(id, state, source)) break; } } @@ -5947,25 +2534,13 @@ void Game::action(int id, int state) if (id == ACTION_TOGGLEHELPSCREEN && !state) { onToggleHelpScreen(); - //toggleHelpScreen(!inHelpScreen); - } - if (id == ACTION_ESC && !state) onPressEscape(); - if (id == ACTION_PRIMARY && !state) onLeftMouseButton(); - if (id == ACTION_TOGGLEMENU) - { - if(state) - showInGameMenu(); - else - hideInGameMenu(); } + if (id == ACTION_ESC && !state) + onPressEscape(); + if (id == ACTION_TOGGLEWORLDMAP && !state) { - if (foodMenu) - { - recipes->setFocus(true); - recipeMenu.toggle(!recipeMenu.on, true); - } - else if (!core->isStateJumpPending()) + if (!core->isStateJumpPending() && !themenu->isFoodMenuOpen()) { toggleWorldMap(); } @@ -5979,133 +2554,6 @@ void Game::action(int id, int state) { if (id == ACTION_TOGGLEGRID && !state) toggleGridRender(); } - - if (isInGameMenu()) - { - if (treasureMenu) - { - if (!state && !dsq->isNested()) - { - if (dsq->menuSelectDelay == 0) - { - if (id == ACTION_PREVPAGE) - { - dsq->menuSelectDelay = MENUSELECTDELAY; - onPrevTreasurePage(); - //menu[5]->setFocus(true); - } - if (id == ACTION_NEXTPAGE) - { - dsq->menuSelectDelay = MENUSELECTDELAY; - onNextTreasurePage(); - //menu[5]->setFocus(true); - } - } - } - } - else if (foodMenu) - { - if (!state && !dsq->isNested()) - { - if (dsq->menuSelectDelay == 0) - { - if (id == ACTION_PREVPAGE) - { - dsq->menuSelectDelay = MENUSELECTDELAY; - if (recipeMenu.on) - recipeMenu.goPrevPage(); - else - onPrevFoodPage(); - } - if (id == ACTION_NEXTPAGE) - { - dsq->menuSelectDelay = MENUSELECTDELAY; - if (recipeMenu.on) - recipeMenu.goNextPage(); - else - onNextFoodPage(); - } - } - - if (id == ACTION_COOKFOOD) - { - if (!recipeMenu.on) - onCook(); - } - - if (id == ACTION_FOODLEFT) - { - if (recipeMenu.on) - { - } - else - { - for (int i = 0; i < foodHolders.size(); i++) - { - if (!foodHolders[i]->isTrash() && !foodHolders[i]->isEmpty()) - { - foodHolders[i]->dropFood(); - break; - } - } - } - } - - if (id == ACTION_FOODRIGHT) - { - if (recipeMenu.on) - { - } - else - { - for (int i = 0; i < foodSlots.size(); i++) - { - if (foodSlots[i]->isCursorIn() && foodSlots[i]->getIngredient()) - { - foodSlots[i]->moveRight(); - break; - } - } - } - } - - if (id == ACTION_FOODDROP) - { - if (recipeMenu.on) - { - } - else - { - int trashIndex = -1; - for (int i = 0; i < foodHolders.size(); i++) - { - if (foodHolders[i]->alpha.x > 0 && foodHolders[i]->alphaMod > 0 && foodHolders[i]->isTrash()) - { - trashIndex = i; - break; - } - } - if (trashIndex >= 0) - { - int ingrIndex = -1; - for (int i = 0; i < foodSlots.size(); i++) - { - if (foodSlots[i]->isCursorIn() && foodSlots[i]->getIngredient()) - { - ingrIndex = i; - break; - } - } - if (ingrIndex >= 0) - { - foodSlots[ingrIndex]->discard(); - } - } - } - } - } - } - } } void Game::toggleWorldMap() @@ -6143,16 +2591,10 @@ void Game::applyState() dsq->collectScriptGarbage(); - isCooking = false; - enqueuedPreviewRecipe = 0; - dsq->toggleBlackBars(false); dsq->setTexturePointers(); - - moveFoodSlotToFront = 0; - cameraOffBounds = false; @@ -6161,8 +2603,6 @@ void Game::applyState() AquariaGuiElement::canDirMoveGlobal = true; - cookDelay = 0; - dsq->toggleVersionLabel(false); activation = true; @@ -6181,10 +2621,6 @@ void Game::applyState() particleManager->setNumSuckPositions(10); - dropIngrNames.clear(); - - foodMenu = optionsMenu = petMenu = treasureMenu = false; - currentPet = 0; bgSfxLoopPlaying2 = ""; @@ -6204,17 +2640,14 @@ void Game::applyState() image = 0; core->particleManager->collideFunction = game_collideParticle; - core->particleManager->specialFunction = game_wibbleParticle; controlHint_ignoreClear = false; - inGameMenuExitState = 0; - int i = 0; debugLog("Entering Game::applyState"); dsq->overlay->alpha = 1; dsq->overlay->color = 0; - for (i = LR_ELEMENTS1; i <= LR_ELEMENTS12; i++) // LR_ELEMENTS13 is darkness, stop before that + for (int i = LR_ELEMENTS1; i <= LR_ELEMENTS12; i++) // LR_ELEMENTS13 is darkness, stop before that { dsq->game->setElementLayerVisible(i-LR_ELEMENTS1, true); } @@ -6225,7 +2658,7 @@ void Game::applyState() cameraConstrained = true; // reset parallax RenderObjectLayer *l = 0; - for (i = LR_ELEMENTS10; i <= LR_ELEMENTS16; i++) + for (int i = LR_ELEMENTS10; i <= LR_ELEMENTS16; i++) { l = &dsq->renderObjectLayers[i]; l->followCamera = 0; @@ -6237,29 +2670,21 @@ void Game::applyState() ignoredActions.clear(); cameraLerpDelay = 0; - playingSongInMenu = -1; sceneColor2 = Vector(1,1,1); sceneColor3 = Vector(1,1,1); if (core->afterEffectManager) { core->afterEffectManager->clear(); - //core->afterEffectManager->addEffect(new RippleEffect()); } Shot::shots.clear(); // the shots were deleted elsewhere, drop any remaining pointers Shot::deleteShots.clear(); backdropQuad = 0; clearObsRows(); - inGameMenu = false; - sceneFlipped = false; useWaterLevel = false; waterLevel = saveWaterLevel = 0; - //miniMapHintPosition = Vector(8900, 14520); - currentInventoryPage = 0; dsq->getRenderObjectLayer(LR_BLACKGROUND)->update = false; - //dsq->getRenderObjectLayer(LR_ELEMENTS5)->update = false; - backgroundImageRepeat = 1; grad = 0; maxZoom = -1; @@ -6273,28 +2698,14 @@ void Game::applyState() sceneName = ""; elementTemplatePack =""; clearGrid(); - clearPointers(); + bg = 0; + bg2 = 0; + avatar = 0; SkeletalSprite::clearCache(); - - StateObject::applyState(); - //core->enable2D(800); dsq->clearEntities(); dsq->clearElements(); - elementWithMenu = 0; - //dsq->gui.menu.clearEntries(); - - - progressBar = 0; - - /* - progressBar = new AquariaProgressBar(); - { - progressBar->position = Vector(400,300); - } - addRenderObject(progressBar, LR_PROGRESS); - */ damageSprite = new Quad; { @@ -6430,98 +2841,41 @@ void Game::applyState() } #endif -/* - if (liFlag == 100) - */ - if (verbose) debugLog("Creating Avatar"); avatar = new Avatar(); if (verbose) debugLog("Done new Avatar"); - if (warpAreaType.empty()) - { - if (positionToAvatar.x == 0 && positionToAvatar.y == 0) - avatar->position = Vector(dsq->avStart.x,dsq->avStart.y); - else - avatar->position = positionToAvatar; - positionToAvatar = Vector(0,0); - } + if (positionToAvatar.x == 0 && positionToAvatar.y == 0) + avatar->position = Vector(dsq->avStart.x,dsq->avStart.y); + else + avatar->position = positionToAvatar; + positionToAvatar = Vector(0,0); + if (verbose) debugLog("Done warp"); if (verbose) debugLog("Create Li"); createLi(); if (verbose) debugLog("Done"); - - if (toFlip == 1) { dsq->game->avatar->flipHorizontal(); toFlip = -1; } - - - // li - //if (true) - - - if (verbose) debugLog("WarpKeys"); - - - - if (verbose) debugLog("Done WarpKeys"); - bindInput(); - shapeDebug = 0; - - /* - shapeDebug = new Quad; - shapeDebug->setWidthHeight(80, 80); - shapeDebug->color = Vector(1,1,0); - addRenderObject(shapeDebug, LR_ENTITIES); - */ - - - if (verbose) debugLog("Loading Scene"); if (!loadScene(sceneToLoad)) { loadElementTemplates(elementTemplatePack); } if (verbose) debugLog("...Done"); - backupSceneColor = sceneColor; dsq->continuity.worldMap.revealMap(sceneName); - colorTest(); - - if (!warpAreaType.empty()) - { - for (int i = 0; i < warpAreas.size(); i++) - { - WarpArea *a = &warpAreas[i]; - if (a->warpAreaType == warpAreaType) - { - int extra=96; - if (a->radius) - avatar->position = a->position + (spawnOffset*(a->radius+extra)); - else - { - Vector s(spawnOffset.x*(a->w+extra), spawnOffset.y*(a->h+extra)); - avatar->position = a->position + s; - } - break; - } - } - warpAreaType = ""; - } - - if (verbose) debugLog("Adding Avatar"); addRenderObject(avatar, LR_ENTITIES); - //cameraFollow = &avatar->position; setCameraFollowEntity(avatar); if (verbose) debugLog("...Done"); @@ -6580,41 +2934,9 @@ void Game::applyState() blackRender->blendEnabled = false; addRenderObject(blackRender, LR_ELEMENTS4); - - hudUnderlay = new Quad; - hudUnderlay->color = 0; - hudUnderlay->position = Vector(400,300); - //hudUnderlay->scale = Vector(800, 600); - hudUnderlay->autoWidth = AUTO_VIRTUALWIDTH; - hudUnderlay->autoHeight = AUTO_VIRTUALHEIGHT; - hudUnderlay->alpha = 0; - hudUnderlay->followCamera = 1; - addRenderObject(hudUnderlay, LR_HUDUNDERLAY); - - autoMap = 0; - /* - autoMap = new AutoMap; - addRenderObject(autoMap, LR_MESSAGEBOX); - */ - - miniMapRender = 0; - - //miniMapRender->position = Vector(400,300); - miniMapRender = new MiniMapRender; - - //miniMapRender->position = Vector(740,540); - // position = (vw,vh) - (scale*100) - // set in minimaprender::onupdate + // position is set in minimaprender::onupdate miniMapRender->scale = Vector(0.55, 0.55); - - - /* - miniMapRender->position = Vector(750,550); - miniMapRender->scale = Vector(0.5, 0.5); - */ - - //miniMapRender->scale = Vector(8,8); addRenderObject(miniMapRender, LR_MINIMAP); timerText = new BitmapText(&dsq->smallFont); @@ -6632,8 +2954,6 @@ void Game::applyState() worldMapRender = new WorldMapRender; addRenderObject(worldMapRender, LR_WORLDMAP); - // to hide minimap - //miniMapRender->position += Vector(800,0); sceneToLoad=""; @@ -6704,15 +3024,6 @@ void Game::applyState() avatar->position = closest->getEnterPosition(50); if (doFlip) avatar->flipHorizontal(); - /* - avatar->position = closest->nodes[0].position; - avatar->position += closestPushOut * 80; - */ - - /* - fromVel = Vector(0,1); - avatar->rotateToVec(fromVel, 0.001); - */ } else { @@ -6729,13 +3040,6 @@ void Game::applyState() } toNode = ""; } - /* - if (!fromVel.isZero()) - { - //avatar->vel = fromVel; - avatar->rotateToVec(fromVel, 0.001); - } - */ avatar->setWasUnderWater(); if (!avatar->isUnderWater()) @@ -6767,8 +3071,7 @@ void Game::applyState() toNode = ""; - createInGameMenu(); - hideInGameMenu(false); + themenu->reset(); core->cacheRender(); @@ -6803,49 +3106,13 @@ void Game::applyState() else cookingScript = dsq->scriptInterface.openScript("scripts/global/cooking.lua", true); - //INFO: this used to be here to start fading out the music - // before the level had begun - /* - if (dsq->sound->isPlayingMusic()) - { - if (dsq->sound->currentMusic.find(musicToPlay) != std::string::npos) - { - } - else - { - dsq->sound->fadeMusic(SFT_CROSS, 1); - } - } - */ - - /* - // HACK: to get the player on the map if there's an error with the warp coords - while(dsq->game->collideCircleWithGrid(avatar->position, 32)) - { - if (avatar->position.y < 200) - avatar->position.y += 200; - avatar->position += Vector(40,0); - avatar->clampPosition(); - } - */ - - updateMiniMapHintPosition(); - createPets(); postInitEntities(); - - /* - core->sound->musicVolume(1.0, 0.5); - core->sound->sfxVolume(1.0, 0.5); - */ - bool musicchanged = updateMusic(); - - dsq->loops.bg = BBGE_AUDIO_NOCHANNEL; if (!bgSfxLoop.empty()) @@ -6873,11 +3140,10 @@ void Game::applyState() core->resetTimer(); if (verbose) debugLog("paths init"); + int pathSz = getNumPaths(); - for (i = 0; i < pathSz; i++) - { + for (int i = 0; i < pathSz; i++) getPath(i)->init(); - } debugLog("Updating bgSfxLoop"); updateBgSfxLoop(); @@ -6951,7 +3217,6 @@ void Game::bindInput() } #endif - dsq->user.control.actionSet.importAction(this, "PrimaryAction", ACTION_PRIMARY); dsq->user.control.actionSet.importAction(this, "SecondaryAction", ACTION_SECONDARY); @@ -7003,521 +3268,11 @@ void Game::bindInput() if (worldMapRender) worldMapRender->bindInput(); + + if(themenu) + themenu->bindInput(); } -bool ingType(const std::vector &list, IngredientType type, int amount=1) -{ - int c = 0; - for (int i = 0; i < list.size(); i++) - { - IngredientData *data = list[i]; - if ((data->marked < data->held) && (data->type == type || type == IT_ANYTHING)) - { - if (type != IT_ANYTHING) - data->marked++; - c++; - if (c == amount) - return true; - } - } - return false; -} - -bool ingName(const std::vector &list, const std::string &name, int amount=1) -{ - int c = 0; - for (int i = 0; i < list.size(); i++) - { - IngredientData *data = list[i]; - if ((data->marked < data->held) && (nocasecmp(data->name, name)==0))//data->name == name) - { - data->marked++; - c++; - if (c == amount) - return true; - } - } - return false; -} - -const int numTreasures = 16*2; - -void Game::onPrevTreasurePage() -{ - if (currentTreasurePage > 0) - { - dsq->sound->playSfx("menu-switch", 0.5); - dsq->spawnParticleEffect("menu-switch", worldLeftCenter, 0, 0, LR_HUD3, 1); - - currentTreasurePage--; - refreshTreasureSlots(); - } - else - { - if (numTreasures > 0) - { - dsq->sound->playSfx("menu-switch", 0.5); - dsq->spawnParticleEffect("menu-switch", worldLeftCenter, 0, 0, LR_HUD3, 1); - - currentTreasurePage = ((numTreasures-1)/treasurePageSize); - refreshTreasureSlots(); - } - } -} - -void Game::onNextTreasurePage() -{ - if ((currentTreasurePage+1)*treasurePageSize < numTreasures) - { - dsq->sound->playSfx("menu-switch", 0.5); - dsq->spawnParticleEffect("menu-switch", worldLeftCenter, 0, 0, LR_HUD3, 1); - - currentTreasurePage++; - refreshTreasureSlots(); - } - else - { - if (currentTreasurePage != 0) - { - dsq->sound->playSfx("menu-switch", 0.5); - dsq->spawnParticleEffect("menu-switch", worldLeftCenter, 0, 0, LR_HUD3, 1); - - currentTreasurePage = 0; - refreshTreasureSlots(); - } - } -} - -void Game::onPrevFoodPage() -{ - int lastFoodPage = currentFoodPage; - if (currentFoodPage > 0) - { - currentFoodPage--; - refreshFoodSlots(false); - } - else - { - if (dsq->continuity.hasIngredients()) - { - currentFoodPage = ((dsq->continuity.ingredientCount()-1)/foodPageSize); - refreshFoodSlots(false); - } - } - - std::ostringstream os; - os << "food page: " << currentFoodPage; - debugLog(os.str()); - - if (currentFoodPage != lastFoodPage) - { - dsq->sound->playSfx("menu-switch", 0.5); - dsq->spawnParticleEffect("menu-switch", worldLeftCenter, 0, 0, LR_HUD3, 1); - } -} - -void Game::onNextFoodPage() -{ - int lastFoodPage = currentFoodPage; - if ((currentFoodPage+1)*foodPageSize < dsq->continuity.ingredientCount()) - { - currentFoodPage++; - refreshFoodSlots(false); - } - else - { - if (currentFoodPage != 0) - { - currentFoodPage = 0; - refreshFoodSlots(false); - } - } - - if (currentFoodPage != lastFoodPage) - { - dsq->sound->playSfx("menu-switch", 0.5); - dsq->spawnParticleEffect("menu-switch", worldLeftCenter, 0, 0, LR_HUD3, 1); - } -} - -void Game::onUseTreasure() -{ - debugLog("Use Treasure!"); - - if (selectedTreasureFlag != -1) - { - onUseTreasure(selectedTreasureFlag); - } -} - -void Game::onUseTreasure(int flag) -{ - if(dsq->mod.isActive()) - dsq->runScriptNum(dsq->mod.getPath() + "scripts/menu-treasures.lua", "useTreasure", flag); - else - dsq->runScriptNum("scripts/global/menu-treasures.lua", "useTreasure", flag); -} - -Recipe *Game::findRecipe(const std::vector &list) -{ - if (list.size() < 2) return 0; - - // there will be a number of types and a number of names - // the types and names DO NOT overlap - int rc = 0; - Recipe *r = 0; - Recipe *tr = 0; - int q = 0, q2 = 0; - for ( rc = 0; rc < dsq->continuity.recipes.size(); rc++) - { - for (int i = 0; i < list.size(); i++) list[i]->marked = 0; - - tr = 0; - r = &dsq->continuity.recipes[rc]; - tr = r; - q = 0; - - // get the amount of ingredients provided by the player - int listAmount = list.size(); - - // get the amount of ingredients required - int recipeAmount = 0; - - for (int i = 0; i < r->types.size(); i++) - recipeAmount += r->types[i].amount; - - for (int i = 0; i < r->names.size(); i++) - recipeAmount += r->names[i].amount; - - if (listAmount != recipeAmount) - continue; - - for (int c = 0; c < r->types.size(); c++) - { - RecipeType *t = &r->types[c]; - if (ingType(list, t->type, t->amount)) - q++; - else - break; - } - - /* - // if all the types are checked - // AND there are no names to check - // then you found it! - if (q == r->types.size() && q > 0 && r->names.empty()) - { - return tr; - } - */ - - // this check is _kinda_ unnecessary... but we'll see - if (q == r->types.size()) - { - q2 = 0; - for (int c = 0; c < r->names.size(); c++) - { - RecipeName *n = &r->names[c]; - if (ingName(list, n->name, n->amount)) - q2++; - else - break; - } - if (q2 == r->names.size()) - { - return r; - } - /* - // if there were actually types to check - // and they were checked successfully - // (being in this section of code implies that there were no types OR there was a successful full check) - else if (q>0 && tr) - { - // return the ingredient we found in types - - // but this is kind of silly. - // would make more sense to return earlier - return tr; - } - */ - } - } - - for (int i = 0; i < list.size(); i++) list[i]->marked = 0; - - if (rc == dsq->continuity.recipes.size()) - { - /* - data = dsq->continuity.getIngredientByName("SeaLoaf"); - if (data) - { - dsq->continuity.pickupIngredient(data); - } - */ - } - - return 0; -} - -void Game::updateCookList() -{ - cookList.clear(); - for (int i = 0; i < foodHolders.size(); i++) - { - IngredientData *ing = foodHolders[i]->getIngredient(); - if (!foodHolders[i]->isTrash() && ing) - { - std::ostringstream os; - os << "cooklist: " << ing->name; - debugLog(os.str()); - cookList.push_back(ing); - } - } -} - -void Game::onRecipes() -{ - if (foodMenu) - { - toggleRecipeList(!recipeMenu.on); - } -} - -void Game::onKeyConfig() -{ - dsq->screenTransition->capture(); - toggleKeyConfigMenu(true); - dsq->screenTransition->transition(MENUPAGETRANSTIME); -} - -#define DEBUG_COOK - -void Game::onCook() -{ - if (recipeMenu.on) return; - if (cookDelay > 0) return; - - debugLog("Cook!"); - - //std::vector list; - updateCookList(); - - if (cookList.size() < 2 || recipeMenu.on) return; - - AquariaGuiElement::canDirMoveGlobal = false; - - cookDelay = 0.4; - - bool cooked = false; - - isCooking = true; - - IngredientData *data=0; - Recipe *r = findRecipe(cookList); - - if (r) - data = dsq->continuity.getIngredientDataByName(r->result); - else if(cookingScript) - { - const char *p1 = cookList[0]->name.c_str(); - const char *p2 = cookList[1]->name.c_str(); - const char *p3 = cookList.size() >= 3 ? cookList[2]->name.c_str() : ""; - std::string ingname; - if(cookingScript->call("cookFailure", p1, p2, p3, &ingname)) - { - if(ingname.length()) - data = dsq->continuity.getIngredientDataByName(ingname); - if(!data) - goto endcook; - } - } - - if(!data) - { - dsq->sound->playSfx("Denied"); - data = dsq->continuity.getIngredientDataByName("SeaLoaf"); - - bool tooMany = data && dsq->continuity.isIngredientFull(data); - - if (!tooMany) - { - int f = dsq->continuity.getFlag(FLAG_SEALOAFANNOYANCE); - f++; - if (f >= 3) - { - dsq->voiceInterupt("naija_sealoaf"); - f = 0; - } - dsq->continuity.setFlag(FLAG_SEALOAFANNOYANCE, f); - } - } - - if (data) - { - cooked = !dsq->continuity.isIngredientFull(data); - } - - if (cooked) - { - debugLog("Cooked something!"); - - // do animationy stuff. - - core->mouse.buttonsEnabled = false; - - bool longAnim = true; - int cooks = dsq->continuity.getFlag(FLAG_COOKS); - - if (cooks >= 4) - longAnim = false; - - for (int i = foodHolders.size()-1; i >= 0; i--) - if (foodHolders[i]->alpha.x > 0 && !foodHolders[i]->isEmpty() && !foodHolders[i]->isTrash()) - foodHolders[i]->animateLid(true, longAnim); - - //dsq->main(0.2); - - - if (longAnim) - { - float ft = 0.8; - float nt = 0.1; - float nt2 = 0.2; - void *handle = NULL; - - /* - if (!longAnim) - { - float factor = 0.3; - ft *= factor; - nt *= factor; - nt2 *= factor; - } - */ - - PlaySfx note1; - note1.name = getNoteName(0); - PlaySfx note2; - note2.name = getNoteName(4); - PlaySfx note3; - note3.name = getNoteName(3); - - handle = dsq->sound->playSfx(note1); - dsq->main(nt2); - dsq->sound->fadeSfx(handle, SFT_OUT, ft); - dsq->main(nt); - - handle = dsq->sound->playSfx(note2); - dsq->main(nt2); - dsq->sound->fadeSfx(handle, SFT_OUT, ft); - dsq->main(nt); - - handle = dsq->sound->playSfx(note3); - dsq->main(nt2); - dsq->sound->fadeSfx(handle, SFT_OUT, ft); - dsq->main(nt); - } - - dsq->sound->playSfx("boil"); - - for (int i = 0; i < foodHolders.size(); i++) - { - if (!foodHolders[i]->isEmpty()) - dsq->spawnParticleEffect("cook-ingredient", foodHolders[i]->getWorldPosition(), 0, 0, LR_HUD3, 1); - } - - if (longAnim) - dsq->main(0.5); - else - dsq->main(0.2); - - bool haveLeftovers = true; - for (int i = 0; i < foodHolders.size(); i++) - { - if (!foodHolders[i]->isEmpty()) { - IngredientData *ing = foodHolders[i]->getIngredient(); - if (!ing || ing->amount < ing->held) - { - haveLeftovers = false; - break; - } - } - } - for (int i = 0; i < foodHolders.size(); i++) - { - IngredientData *ing = foodHolders[i]->getIngredient(); - if (ing) - { - ing->amount--; - } - - if (!haveLeftovers) - { - foodHolders[i]->setIngredient(0, false); - } - } - - dsq->sound->playSfx("Cook"); - - for (int i = 0; i < foodHolders.size(); i++) - if (foodHolders[i]->alpha.x > 0 && !foodHolders[i]->isTrash()) - foodHolders[i]->animateLid(false); - - dsq->spawnParticleEffect("cook-food", Vector(575,250), 0, 0, LR_HUD3, 1); - - if (longAnim) - dsq->main(0.5); - else - dsq->main(0.2); - - if (data) - { - float t = 3; - std::string n = "Ingredients/" + data->gfx; - //Quad *e = new Quad(); - - showRecipe->setTexture(n); - showRecipe->scale = Vector(0.5, 0.5); - showRecipe->scale.interpolateTo(Vector(1.2, 1.2), t); - showRecipe->alpha.ensureData(); - showRecipe->alpha.data->path.clear(); - showRecipe->alpha.data->path.addPathNode(0, 0); - showRecipe->alpha.data->path.addPathNode(1, 0.1); - showRecipe->alpha.data->path.addPathNode(1, 0.6); - showRecipe->alpha.data->path.addPathNode(0, 1); - showRecipe->alpha.startPath(t); - } - - dsq->continuity.pickupIngredient(data, 1); - - dsq->continuity.removeEmptyIngredients(); - - dsq->main(0.5); - - dsq->continuity.setFlag(FLAG_COOKS, dsq->continuity.getFlag(FLAG_COOKS)+1); - - if (r) - { - dsq->continuity.learnRecipe(r); - if (haveLeftovers) - updatePreviewRecipe(); - } - - core->mouse.buttonsEnabled = true; - } - else - { - dsq->sound->playSfx("Denied"); - dsq->centerMessage(dsq->continuity.stringBank.get(27)); - } - refreshFoodSlots(true); - -endcook: - - AquariaGuiElement::canDirMoveGlobal = true; - - isCooking = false; -} void Game::overrideZoom(float sz, float t) { @@ -7534,28 +3289,6 @@ void Game::overrideZoom(float sz, float t) } } -FoodSlot* getFoodSlotFromIndex() -{ - for (int i = 0; i < dsq->game->foodSlots.size(); i++) - { - if (dsq->game->foodSlots[i]->slot == FoodSlot::foodSlotIndex) - { - return dsq->game->foodSlots[i]; - } - } - return 0; -} - -void Game::onLips() -{ - if (!foodMenu) - { - if (dsq->lastVoiceFile.find("NAIJA_SONG_") != std::string::npos) - { - dsq->stopVoice(); - } - } -} const float hintTransTime = 0.5; @@ -7743,11 +3476,6 @@ void Game::setControlHint(const std::string &h, bool left, bool right, bool midd controlHint_shine->alpha.startPath(0.4); } -void Game::onFlipTest() -{ - flipSceneVertical(14960); -} - void appendFileToString(std::string &string, const std::string &file) { InStream inf(file.c_str()); @@ -7761,7 +3489,7 @@ void appendFileToString(std::string &string, const std::string &file) #if BBGE_BUILD_UNIX read = stripEndlineForUnix(read); #endif - read = dsq->user.control.actionSet.insertInputIntoString(read); + //read = dsq->user.control.actionSet.insertInputIntoString(read); string += read + "\n"; } } @@ -7777,6 +3505,7 @@ void Game::onToggleHelpScreen() return; else { + const MenuPage currentMenuPage = themenu->getCurrentMenuPage(); if (worldMapRender->isOn()) { toggleHelpScreen(true, "[World Map]"); @@ -8004,6 +3733,7 @@ void Game::toggleHelpScreen(bool on, const std::string &label) inHelpScreen = on; } + bool Game::updateMusic() { std::string musicToPlay = this->musicToPlay; @@ -8017,35 +3747,7 @@ bool Game::updateMusic() if (musicToPlay == "none") core->sound->fadeMusic(SFT_OUT, 1); else - { - bool play = true; - /* - std::string originalFile = musicToPlay; - std::string file = originalFile; - - if (!exists(file, false) && file.find('.') == std::string::npos) - { - file = originalFile + ".ogg"; - if (!exists(file, false)) - { - file = originalFile + ".mp3"; - if (!exists(file, false)) - { - errorLog ("music file not found [" + originalFile + "]"); - play = false; - } - } - } - */ - if (play) - { - /* - if (core->sound->isStreamingMusic()) - core->sound->crossfadeOutMusic(1); - */ - return core->sound->playMusic(musicToPlay, SLT_LOOP, SFT_CROSS, 1, SCT_ISNOTPLAYING); - } - } + return core->sound->playMusic(musicToPlay, SLT_LOOP, SFT_CROSS, 1, SCT_ISNOTPLAYING); } else { @@ -8072,36 +3774,12 @@ void Game::onPressEscape() dsq->game->worldMapRender->toggle(false); return; } - if (dsq->game->isInGameMenu()) - { - if (!AquariaKeyConfig::waitingForInput) - { - if (dsq->game->menuOpenTimer > 0.5f) - { - if (optionsMenu || keyConfigMenu) - onOptionsCancel(); - else - action(ACTION_TOGGLEMENU, 0); // hide menu - } - } - return; - } if (!paused) { if (core->getNestedMains() == 1 && !core->isStateJumpPending()) - action(ACTION_TOGGLEMENU, 1); // show menu + action(ACTION_TOGGLEMENU, 1, -1); // show menu } - else - { - - if (autoMap) - { - if (paused && autoMap->isOn()) - autoMap->toggle(false); - } - } - if ((dsq->saveSlotMode != SSM_NONE || dsq->inModSelector) && core->isNested()) { @@ -8111,84 +3789,6 @@ void Game::onPressEscape() } } -void Game::onDebugSave() -{ - hideInGameMenu(); - clearControlHint(); - core->main(0.5); - dsq->game->togglePause(true); - dsq->doSaveSlotMenu(SSM_SAVE); - dsq->game->togglePause(false); - //dsq->continuity.saveFile(0); -} - -void Game::onInGameMenuInventory() -{ -} - -void Game::onInGameMenuSpellBook() -{ -} - -void Game::onInGameMenuContinue() -{ - hideInGameMenu(); -} - -void Game::onInGameMenuOptions() -{ -} - -void Game::onInGameMenuSave() -{ -} - -void Game::onExitCheckYes() -{ - dsq->sound->stopAllVoice(); - dsq->toggleCursor(0, 0.25); - dsq->title(); -} - -void Game::onExitCheckNo() -{ - hideInGameMenuExitCheck(true); -} - -void Game::showInGameMenuExitCheck() -{ - recipeMenu.toggle(false); - inGameMenuExitState = 1; - eYes->alpha.interpolateTo(1, 0.2); - eNo->alpha.interpolateTo(1, 0.2); - eAre->alpha.interpolateTo(1, 0.2); - - eNo->setFocus(true); -} - -void Game::hideInGameMenuExitCheck(bool refocus) -{ - inGameMenuExitState = 0; - eYes->alpha.interpolateTo(0, 0.2); - eNo->alpha.interpolateTo(0, 0.2); - eAre->alpha.interpolateTo(0, 0.2); - - if (refocus) - ((AquariaMenuItem*)menu[1])->setFocus(true); -} - -void Game::onInGameMenuExit() -{ - if (!dsq->user.demo.warpKeys || (core->getCtrlState() && core->getAltState())) - { - if (inGameMenuExitState == 0) - { - // show yes/no - showInGameMenuExitCheck(); - } - } -} - void Game::toggleDamageSprite(bool on) { if (on) @@ -8275,16 +3875,10 @@ Bone *Game::collideSkeletalVsCircle(Entity *skeletal, RenderObject *circle) Bone *Game::collideSkeletalVsLine(Entity *skeletal, Vector start, Vector end, float radius) { - //float smallestDist = HUGE_VALF; Bone *closest = 0; for (int i = 0; i < skeletal->skeletalSprite.bones.size(); i++) { Bone *b = skeletal->skeletalSprite.bones[i]; - /* - int checkRadius = sqr(radius+b->collisionMaskRadius); - Vector bonePos = b->getWorldCollidePosition(); - float dist = (bonePos - pos).getSquaredLength2D(); - */ // MULTIPLE CIRCLES METHOD if (!b->collisionMask.empty() && b->alpha.x == 1 && b->renderQuad) @@ -8294,7 +3888,6 @@ Bone *Game::collideSkeletalVsLine(Entity *skeletal, Vector start, Vector end, fl if (isTouchingLine(start, end, b->transformedCollisionMask[i], radius+b->collideRadius)) { closest = b; - //smallestDist = dist; break; } } @@ -8303,20 +3896,6 @@ Bone *Game::collideSkeletalVsLine(Entity *skeletal, Vector start, Vector end, fl { break; } - /* - // ONE CIRCLE PER BONE METHOD - else if (b->collideRadius && b->alpha.x == 1) - { - if (dist < checkRadius) - { - if (dist < smallestDist) - { - closest = b; - smallestDist = dist; - } - } - } - */ } return closest; } @@ -8343,10 +3922,6 @@ bool Game::collideCircleVsLineAngle(RenderObject *r, float angle, float startLen { collision = true; } - if (shapeDebug) - { - shapeDebug->position = end; - } return collision; } @@ -8643,1035 +4218,6 @@ void Game::setCameraFollowEntity(Entity *e) cameraFollowEntity = e; } -void Game::updateCurrentVisuals(float dt) -{ - /* - static float delay = 0; - delay += dt; - if (delay > 0.2f) - { - for (Path *p = dsq->game->getFirstPathOfType(PATH_CURRENT); p; p = p->nextOfType) - { - if (p->active) - { - for (int n = 1; n < p->nodes.size(); n++) - { - PathNode *node2 = &p->nodes[n]; - PathNode *node1 = &p->nodes[n-1]; - Vector dir = node2->position - node1->position; - - dir.setLength2D(p->currentMod); - dsq->spawnBubble(node1->position, dir); - } - } - - } - delay = 0; - } - */ - - /* - if (dsq->game->getPath(i)->name == "CURRENT" && dsq->game->getPath(i)->nodes.size() >= 2) - { - Vector dir = dsq->game->getPath(i)->nodes[1].position - dsq->game->getPath(i)->nodes[0].position; - dir.setLength2D(800); - dsq->spawnBubble(dsq->game->getPath(i)->nodes[0].position, dir); - } - */ -} - -void Game::onOptionsMenu() -{ - dsq->screenTransition->capture(); - toggleOptionsMenu(true); - dsq->screenTransition->transition(MENUPAGETRANSTIME); -} - -void Game::onOptionsSave() -{ - dsq->user.apply(); - - if (dsq->user.video.resx != dsq->user_backup.video.resx - || dsq->user.video.resy != dsq->user_backup.video.resy - || dsq->user.video.bits != dsq->user_backup.video.bits - || dsq->user.video.full != dsq->user_backup.video.full - || dsq->user.video.vsync != dsq->user_backup.video.vsync) - { - dsq->resetGraphics(dsq->user.video.resx, dsq->user.video.resy, dsq->user.video.full); - if (dsq->confirm("", "graphics", false, 10)) { - } else { - dsq->user.video.resx = dsq->user_backup.video.resx; - dsq->user.video.resy = dsq->user_backup.video.resy; - dsq->user.video.bits = dsq->user_backup.video.bits; - dsq->user.video.full = dsq->user_backup.video.full; - dsq->user.video.vsync = dsq->user_backup.video.vsync; - - dsq->user.apply(); - - dsq->resetGraphics(dsq->user.video.resx, dsq->user.video.resy, dsq->user.video.full); - } - } - - /* - if (dsq->user.video.ripples != dsq->user_backup.video.ripples) - { - if (dsq->user.video.ripples) - { - if (core->frameBuffer.isInited()) - { - if (!core->afterEffectManager) - { - core->afterEffectManager = new AfterEffectManager(vars->afterEffectsXDivs, vars->afterEffectsYDivs); - core->afterEffectManager->update(0.0); - core->afterEffectManager->capture(); - } - - dsq->useFrameBuffer = 1; - } - else - { - dsq->useFrameBuffer = 0; - } - } - else - { - if (core->afterEffectManager) - { - delete core->afterEffectManager; - core->afterEffectManager = 0; - } - } - } - */ - - if (!keyConfigMenu) - dsq->user.save(); - - if (keyConfigMenu) - { - AquariaKeyConfig::waitingForInput = 0; - dsq->screenTransition->capture(); - toggleKeyConfigMenu(false); - toggleOptionsMenu(true, false, true); - dsq->screenTransition->transition(MENUPAGETRANSTIME); - } - else - { - if (optionsOnly) - { - hideInGameMenu(); - } - else - { - dsq->screenTransition->capture(); - toggleOptionsMenu(false); - dsq->screenTransition->transition(MENUPAGETRANSTIME); - } - } -} - -void Game::onOptionsCancel() -{ - if (!keyConfigMenu) - { - dsq->user = dsq->user_backup; - } - else - { - dsq->user.control.actionSet = dsq->user_bcontrol.control.actionSet; - } - - dsq->user.apply(); - - if (keyConfigMenu) - { - AquariaKeyConfig::waitingForInput = 0; - dsq->screenTransition->capture(); - toggleKeyConfigMenu(false); - toggleOptionsMenu(true, true, true); - dsq->screenTransition->transition(MENUPAGETRANSTIME); - } - else - { - if (optionsOnly) - { - hideInGameMenu(); - } - else - { - dsq->screenTransition->capture(); - toggleOptionsMenu(false); - dsq->screenTransition->transition(MENUPAGETRANSTIME); - } - } -} - -void Game::refreshFoodSlots(bool effects) -{ - for (int i = 0; i < foodSlots.size(); i++) - { - foodSlots[i]->refresh(effects); - } -} - -void Game::refreshTreasureSlots() -{ - for (int i = 0; i < treasureSlots.size(); i++) - { - treasureSlots[i]->refresh(); - } -} - -void Game::togglePetMenu(bool f) -{ - if (optionsMenu) - { - toggleOptionsMenu(false); - } - - if (foodMenu) - toggleFoodMenu(false); - if (treasureMenu) - toggleTreasureMenu(false); - - if (f && !petMenu) - { - currentMenuPage = MENUPAGE_PETS; - - toggleMainMenu(false); - - bool hasPet = false; - for (int i = 0; i < petSlots.size(); i++) - { - petSlots[i]->alpha = 1; - bool has = dsq->continuity.getFlag(petSlots[i]->petFlag); - if (has) - { - hasPet = true; - /* - for (int j = 0; j < petSlots.size(); j++) - { - if (j != i) - { - bool has = dsq->continuity.getFlag(petSlots[j]->petFlag); - if (has) - { - if (i == 0 && j == 1) - { - - } - } - } - } - */ - } - } - // act as if they're all active for now... - if (petSlots.size() == 4) - { - petSlots[0]->setDirMove(DIR_RIGHT, petSlots[1]); - petSlots[0]->setDirMove(DIR_UP, petSlots[2]); - petSlots[0]->setDirMove(DIR_LEFT, petSlots[3]); - petSlots[0]->setDirMove(DIR_DOWN, menu[0]); - - menu[0]->setDirMove(DIR_UP, petSlots[0]); - - petSlots[1]->setDirMove(DIR_LEFT, petSlots[3]); - petSlots[1]->setDirMove(DIR_UP, petSlots[2]); - petSlots[1]->setDirMove(DIR_DOWN, petSlots[0]); - - petSlots[1]->setDirMove(DIR_RIGHT, menu[5]); - menu[5]->setDirMove(DIR_LEFT, petSlots[1]); - menu[5]->setDirMove(DIR_UP, petSlots[1]); - - petSlots[2]->setDirMove(DIR_RIGHT, petSlots[1]); - petSlots[2]->setDirMove(DIR_DOWN, petSlots[0]); - petSlots[2]->setDirMove(DIR_LEFT, petSlots[3]); - - petSlots[3]->setDirMove(DIR_UP, petSlots[2]); - petSlots[3]->setDirMove(DIR_RIGHT, petSlots[1]); - petSlots[3]->setDirMove(DIR_DOWN, petSlots[0]); - } - - - for (int i = 0; i < petTips.size(); i++) - { - /* - if (hasPet && i == 0) - { - petTips[i]->alpha = 0; - } - else if (!hasPet && i == 1) - petTips[i]->alpha = 0; - else - petTips[i]->alpha = 1; - */ - petTips[i]->alpha = 1; - } - - liCrystal->alpha = 1; - - - menu[7]->setFocus(true); - - - doMenuSectionHighlight(2); - - } - else if (!f && petMenu) - { - for (int i = 0; i < petSlots.size(); i++) - { - petSlots[i]->alpha = 0; - } - - for (int i = 0; i < petTips.size(); i++) - { - petTips[i]->alpha = 0; - } - - liCrystal->alpha = 0; - - - menu[5]->setDirMove(DIR_LEFT, 0); - menu[5]->setDirMove(DIR_UP, 0); - menu[0]->setDirMove(DIR_UP, 0); - } - - petMenu = f; -} - -void Game::toggleTreasureMenu(bool f) -{ - //debugLog("toggle treasure menu!"); - - if (optionsMenu) - toggleOptionsMenu(false); - - if (foodMenu) - toggleFoodMenu(false); - if (petMenu) - togglePetMenu(false); - - if (f && !treasureMenu) - { - currentMenuPage = MENUPAGE_TREASURES; - - treasureMenu = true; - toggleMainMenu(false); - - refreshTreasureSlots(); - - for (int i = 0; i < treasureTips.size(); i++) - treasureTips[i]->alpha = 1; - - if (treasureSlots.size() > 8) - { - treasureSlots[0]->setDirMove(DIR_DOWN, menu[0]); - menu[0]->setDirMove(DIR_UP, treasureSlots[0]); - - treasureSlots[2]->setDirMove(DIR_RIGHT, menu[5]); - menu[5]->setDirMove(DIR_LEFT, treasureSlots[2]); - - treasureSlots[3]->setDirMove(DIR_RIGHT, menu[5]); - } - - menu[8]->setFocus(true); - - doMenuSectionHighlight(3); - - liCrystal->alpha = 1; - - circlePageNum->alpha = 1; - } - else if (!f && treasureMenu) - { - treasureMenu = false; - - for (int i = 0; i < treasureTips.size(); i++) - treasureTips[i]->alpha = 0; - - menu[0]->setDirMove(DIR_UP, 0); - menu[5]->setDirMove(DIR_LEFT, 0); - - liCrystal->alpha = 0; - - circlePageNum->alpha = 0; - } - - for (int i = 0; i < treasureSlots.size(); i++) - { - if (f) - treasureSlots[i]->alpha = 1; - else - treasureSlots[i]->alpha = 0; - } - - if (f) - { - nextTreasure->alpha = 1; - prevTreasure->alpha = 1; - use->alpha = 0; - - treasureLabel->alpha = 0; - treasureDescription->alpha = 0; - treasureCloseUp->alpha = 0; - } - else - { - nextTreasure->alpha = 0; - prevTreasure->alpha = 0; - use->alpha = 0; - - treasureLabel->alpha = 0; - treasureDescription->alpha = 0; - treasureCloseUp->alpha = 0; - } -} - -void Game::toggleRecipeList(bool on) -{ - recipeMenu.toggle(on, true); -} - -void Game::toggleFoodMenu(bool f) -{ - if (optionsMenu) - toggleOptionsMenu(false); - if (petMenu) - togglePetMenu(false); - if (treasureMenu) - toggleTreasureMenu(false); - - - for (int i = 0; i < foodHolders.size(); i++) - { - if (f) - foodHolders[i]->alpha = 1; - else - foodHolders[i]->alpha = 0; - } - - if (f) - { - if (dsq->game->avatar) - { - Path *p=0; - if (dsq->continuity.getFlag(FLAG_UPGRADE_WOK) > 0 - || ((p=dsq->game->getNearestPath(dsq->game->avatar->position, PATH_COOK)) - && p->isCoordinateInside(dsq->game->avatar->position))) - { - //cook->alpha = 1; - foodHolders[0]->alpha = 1; - } - else - { - foodHolders[0]->alpha = 0; - } - } - } - - if (f && !foodMenu) - { - currentMenuPage = MENUPAGE_FOOD; - - foodMenu = true; - - toggleMainMenu(false); - - refreshFoodSlots(false); - - cook->alpha = 1; - recipes->alpha = 1; - - prevFood->alpha = 1; - nextFood->alpha = 1; - foodLabel->alphaMod = 1; - foodDescription->alphaMod = 1; - - foodSort->alpha = 1; - - for (int i = 0; i < foodTips.size(); i++) - foodTips[i]->alpha = 1; - - if (foodSlots.size() >= 16) - { - foodSlots[2]->setDirMove(DIR_RIGHT, menu[5]); - foodSlots[3]->setDirMove(DIR_RIGHT, menu[5]); - menu[5]->setDirMove(DIR_LEFT, foodSlots[2]); - - treasureSlots[3]->setDirMove(DIR_RIGHT, menu[5]); - - recipes->setDirMove(DIR_UP, foodSlots[15]); - foodSlots[15]->setDirMove(DIR_DOWN, recipes); - foodSlots[14]->setDirMove(DIR_DOWN, recipes); - foodSlots[0]->setDirMove(DIR_DOWN, recipes); - - foodSlots[0]->setDirMove(DIR_LEFT, foodSlots[15]); - foodSlots[15]->setDirMove(DIR_RIGHT, foodSlots[0]); - - foodSlots[15]->setDirMove(DIR_LEFT, foodSlots[14]); - - recipes->setDirMove(DIR_RIGHT, menu[5]); - } - - menu[6]->setFocus(true); - - doMenuSectionHighlight(1); - - liCrystal->alpha = 1; - - circlePageNum->alpha = 1; - - previewRecipe->alpha = 0; - updatePreviewRecipe(); - } - else if (!f && foodMenu) - { - recipeMenu.toggle(false); - foodMenu = false; - - cook->alpha = 0; - recipes->alpha = 0; - prevFood->alpha = 0; - nextFood->alpha = 0; - foodLabel->alphaMod = 0; - foodLabel->alpha = 0; - foodDescription->alpha = 0; - foodSort->alpha = 0; - showRecipe->alpha = 0; - - liCrystal->alpha = 0; - - for (int i = 0; i < foodTips.size(); i++) - foodTips[i]->alpha = 0; - - menu[5]->setDirMove(DIR_LEFT, 0); - - circlePageNum->alpha = 0; - - previewRecipe->alpha = 0; - } - - for (int i = 0; i < foodSlots.size(); i++) - { - foodSlots[i]->toggle(f); - } -} - -void Game::doMenuSectionHighlight(int section) -{ - for (int i = 0; i < 4; i++) - ((AquariaMenuItem*)menu[(5+i)])->quad->alphaMod = 0.8; - //menu[(5+i)]->offset = Vector(0,-2); - ((AquariaMenuItem*)menu[(5+section)])->quad->alphaMod = 1.0; - menuIconGlow->position = menu[5+section]->position; - /* - for (int i = 0; i < 4; i++) - menu[5+i]->color = Vector(0.5, 0.5, 0.5); - - menu[5+section]->color = Vector(1,1,1); - */ -} - -void Game::toggleMainMenu(bool f) -{ - const float t = 0; - if (f) - { - currentMenuPage = MENUPAGE_SONGS; - for (int i = 0; i < songSlots.size(); i++) - { - //songSlots[i]->alpha.interpolateTo(1, t); - songSlots[i]->alphaMod = 1; - } - songBubbles->alpha.interpolateTo(1,t); - energyIdol->alpha.interpolateTo(1,t); - liCrystal->alpha.interpolateTo(1, t); - for (int i = 0; i < songTips.size(); i++) - songTips[i]->alpha = 1; - menuBg2->alpha.interpolateTo(1, t); - - - int sm=-900; - SongSlot *ss=0; - for (int i = 0; i < songSlots.size(); i++) - { - if (dsq->continuity.hasSong(dsq->continuity.getSongTypeBySlot(i))) - { - //if (songSlots[i]->alpha == 1 && songSlots[i]->renderQuad && songSlots[i]->alphaMod == 1) - { - Vector p = songSlots[i]->getWorldPosition(); - if (p.x > sm) - { - sm = p.x; - ss = songSlots[i]; - } - } - } - } - - if (ss) - { - ss->setDirMove(DIR_RIGHT, (AquariaMenuItem*)menu[5]); - } - ((AquariaMenuItem*)menu[5])->setDirMove(DIR_LEFT, ss); - - doMenuSectionHighlight(0); - } - else - { - ((AquariaMenuItem*)menu[5])->setDirMove(DIR_LEFT, 0); - - for (int i = 0; i < songSlots.size(); i++) - { - songSlots[i]->alphaMod = 0; - } - - for (int i = 0; i < songTips.size(); i++) - songTips[i]->alpha = 0; - - songBubbles->alpha.interpolateTo(0, t); - energyIdol->alpha.interpolateTo(0,t); - liCrystal->alpha.interpolateTo(0, t); - } -} - -void Game::toggleKeyConfigMenu(bool f) -{ - const float t = 0; - playingSongInMenu = -1; - - - if (f && !keyConfigMenu) - { - //dsq->screenTransition->capture(); - - toggleOptionsMenu(false, false, true); - - // Prevent int i from "leaking out" due to Microsoft extension to for-scope - { - for (int i = 0; i <= 1; i++) - menu[i]->alpha.interpolateTo(0, t); - for (int i = 4; i <= 8; i++) - menu[i]->alpha.interpolateTo(0, t); - } - - toggleMainMenu(false); - - menuBg2->alpha.interpolateTo(0, t); - - keyConfigMenu = true; - - group_keyConfig->setHidden(false); - group_keyConfig->alpha = 1; - - dsq->user_bcontrol = dsq->user; - - //group_keyConfig->children[group_keyConfig->children.size()-3] - - RenderObject::Children::reverse_iterator i = group_keyConfig->children.rbegin(); - AquariaKeyConfig *upright0 = (AquariaKeyConfig*)(*i); - i++; - AquariaKeyConfig *upright = (AquariaKeyConfig*)(*i); - i++; //i++; - AquariaKeyConfig *upleft = (AquariaKeyConfig*)(*i); - - opt_cancel->setDirMove(DIR_UP, upright); - upright->setDirMove(DIR_DOWN, opt_cancel); - upright0->setDirMove(DIR_DOWN, opt_cancel); - - opt_save->setDirMove(DIR_UP, upleft); - upleft->setDirMove(DIR_DOWN, opt_save); - - - opt_cancel->alpha = 1; - opt_save->alpha = 1; - - - opt_save->position = opt_save_original + Vector(0, 120); - opt_cancel->position = opt_cancel_original + Vector(0, 120); - - opt_cancel->setFocus(true); - - menuIconGlow->alpha = 0; - - //dsq->screenTransition->transition(MENUPAGETRANSTIME); - } - else if (!f) - { - keyConfigMenu = false; - - group_keyConfig->alpha = 0; - group_keyConfig->setHidden(true); - - opt_cancel->alpha = 0; - opt_save->alpha = 0; - - opt_save->position = opt_save_original; - opt_cancel->position = opt_cancel_original; - - menuIconGlow->alpha = 1; - } -} - -void Game::toggleOptionsMenu(bool f, bool skipBackup, bool isKeyConfig) -{ - const float t = 0; - playingSongInMenu = -1; - - if (f && !optionsMenu) - { - //menuBg->setTexture("gui/options-menu"); - //menuBg->setWidthHeight(1024, 1024); - - if (!isKeyConfig && !optionsOnly) - { - dsq->continuity.lastOptionsMenuPage = currentMenuPage; - } - - toggleFoodMenu(false); - optionsMenu = true; - voxslider->setValue(dsq->user.audio.voxvol); - musslider->setValue(dsq->user.audio.musvol); - sfxslider->setValue(dsq->user.audio.sfxvol); - - if (blurEffectsCheck) - blurEffectsCheck->setValue(dsq->user.video.blur); - - flipInputButtonsCheck->setValue(dsq->user.control.flipInputButtons); - toolTipsCheck->setValue(dsq->user.control.toolTipsOn); - autoAimCheck->setValue(dsq->user.control.autoAim); - targetingCheck->setValue(dsq->user.control.targeting); - - subtitlesCheck->setValue(dsq->user.audio.subtitles); - fullscreenCheck->setValue(dsq->isFullscreen()); - - if (ripplesCheck) - ripplesCheck->setValue(core->afterEffectManager!=0); - - if (micInputCheck) - micInputCheck->setValue(dsq->user.audio.micOn); - - if (resBox) - { - std::ostringstream os; - os << core->width << "x" << core->height; - if (!resBox->setSelectedItem(os.str())) - { - resBox->addItem(os.str()); - resBox->setSelectedItem(os.str()); - } - } - - opt_cancel->setDirMove(DIR_UP, targetingCheck); - targetingCheck->setDirMove(DIR_DOWN, opt_cancel); - - - opt_save->setDirMove(DIR_UP, voxslider); - voxslider->setDirMove(DIR_DOWN, opt_save); - - keyConfigButton->setDirMove(DIR_UP, targetingCheck); - - if (!skipBackup) - dsq->user_backup = dsq->user; - - - options->alpha.interpolateTo(1, t); - - for (int i = 0; i <= 1; i++) - menu[i]->alpha.interpolateTo(0, t); - for (int i = 4; i <= 9; i++) - menu[i]->alpha.interpolateTo(0, t); - - toggleMainMenu(false); - - keyConfigButton->alpha = 1; - - menuBg2->alpha.interpolateTo(0, t); - - opt_cancel->alpha = 1; - opt_save->alpha = 1; - opt_cancel->setFocus(true); - - lips->alpha = 0; - - liCrystal->alpha = 1; - - optionsMenu = true; - - menuIconGlow->alpha = 0; - - /* - for (int i = 0; i < menu.size(); i++) - menu[i]->alpha.interpolateTo(0, 0.2); - */ - } - else if (!f && optionsMenu) - { - lips->alpha = 0; - - keyConfigButton->alpha = 0; - - options->alpha.interpolateTo(0, t); - - opt_cancel->alpha = 0; - opt_save->alpha = 0; - - liCrystal->alpha = 0; - - /* - // what does this do? - if (optionsMenu) - ((AquariaMenuItem*)menu[4])->setFocus(true); - */ - //((AquariaMenuItem*)menu[5])->setFocus(true); - - optionsMenu = false; - - - - if (!optionsOnly) - { - for (int i = 0; i <= 1; i++) - menu[i]->alpha.interpolateTo(1, t); - for (int i = 4; i <= 9; i++) - { - menu[i]->alpha.interpolateTo(1, t); - } - - //menu[9]->alpha = 1; - - if (!isKeyConfig) - { - switch(dsq->continuity.lastOptionsMenuPage) - { - case MENUPAGE_FOOD: - toggleFoodMenu(true); - ((AquariaMenuItem*)menu[6])->setFocus(true); - break; - case MENUPAGE_TREASURES: - toggleTreasureMenu(true); - ((AquariaMenuItem*)menu[8])->setFocus(true); - break; - case MENUPAGE_PETS: - togglePetMenu(true); - ((AquariaMenuItem*)menu[7])->setFocus(true); - break; - case MENUPAGE_SONGS: - default: - toggleMainMenu(true); - ((AquariaMenuItem*)menu[5])->setFocus(true); - break; - } - } - - //((AquariaMenuItem*)menu[4])->setFocus(true); - - - menuBg2->alpha.interpolateTo(1, t); - } - - menuIconGlow->alpha = 1; - - } -} - -float optsfxdly = 0; -void Game::updateOptionsMenu(float dt) -{ - if (optionsMenu) - { - dsq->user.audio.voxvol = voxslider->getValue(); - dsq->user.audio.sfxvol = sfxslider->getValue(); - dsq->user.audio.musvol = musslider->getValue(); - - if (micInputCheck) - dsq->user.audio.micOn = micInputCheck->getValue(); - - dsq->user.control.flipInputButtons = flipInputButtonsCheck->getValue(); - dsq->user.control.toolTipsOn = toolTipsCheck->getValue(); - dsq->user.control.autoAim = autoAimCheck->getValue(); - dsq->user.control.targeting = targetingCheck->getValue(); - - dsq->user.audio.subtitles = subtitlesCheck->getValue(); - dsq->user.video.full = fullscreenCheck->getValue(); - - if (ripplesCheck) - dsq->user.video.fbuffer = ripplesCheck->getValue(); - - if (blurEffectsCheck) - dsq->user.video.blur = blurEffectsCheck->getValue(); - - if (resBox) - { - std::string s = resBox->getSelectedItemString(); - if (!s.empty()) - { - int pos = s.find('x'); - std::istringstream is1(s.substr(0, pos)); - is1 >> dsq->user.video.resx; - std::istringstream is2(s.substr(pos+1, s.size()-(pos+1))); - is2 >> dsq->user.video.resy; - } - - } - - /* - dsq->user.audio.sfxvol = sfxslider->getValue(); - dsq->user.audio.musvol = musslider->getValue(); - */ - - optsfxdly += dt; - if (sfxslider->hadInput()) - { - dsq->sound->playSfx("denied"); - } - else if (voxslider->hadInput()) - { - if (!dsq->sound->isPlayingVoice()) - dsq->voice("naija_somethingfamiliar"); - } - else if (optsfxdly > 0.6f) - { - optsfxdly = 0; - if (sfxslider->isGrabbed()) - { - dsq->sound->playSfx("denied"); - dsq->loops.updateVolume(); - } - if (voxslider->isGrabbed()) - { - if (!dsq->sound->isPlayingVoice()) - { - dsq->voice("naija_somethingfamiliar"); - } - } - } - - /* - std::ostringstream os; - os << "musvol: " << dsq->user.audio.musvol; - debugLog(os.str()); - */ - - dsq->user.apply(); - } -} - -void Game::updateInGameMenu(float dt) -{ - if (isInGameMenu()) - { - menuOpenTimer += dt; - if (dt > 10) - dt = 10; - - if (foodMenu) - { - if (dsq->inputMode == INPUT_JOYSTICK) - { - //debugLog("food menu, joystick"); - - - /* - */ - } - - if (dsq->continuity.hasIngredients()) - { - int pageNum = (currentFoodPage+1); - int numPages = ((dsq->continuity.ingredientCount()-1)/foodPageSize)+1; - - std::ostringstream os; - os << pageNum << "/" << numPages; - circlePageNum->setText(os.str()); - - if (pageNum > numPages && pageNum > 1) - { - onPrevFoodPage(); - } - } - else - { - circlePageNum->setText("1/1"); - } - } - if (treasureMenu) - { - std::ostringstream os; - os << (currentTreasurePage+1) << "/" << (numTreasures/treasurePageSize); - circlePageNum->setText(os.str()); - } - // HACK: move this later - updateOptionsMenu(dt); - if (playingSongInMenu != -1) - { - songMenuPlayDelay += dt; - - Song s = dsq->continuity.songBank[playingSongInMenu]; - - if (currentSongMenuNote < s.notes.size()) - { - if (songMenuPlayDelay >= 0.5f) - { - songMenuPlayDelay = 0; - - - if (currentSongMenuNote >= 0 && currentSongMenuNote < s.notes.size()) - { - /* - std::ostringstream os; - os << "MenuNote" << s[currentSongMenuNote]; - */ - sound->playSfx(dsq->game->getNoteName(s.notes[currentSongMenuNote], "Menu")); - - float a = (s.notes[currentSongMenuNote]*2*PI)/8.0f; - int sz = 110*menuBg->scale.x; - Vector notePos(sinf(a)*sz,cosf(a)*sz); - - float t = 0.5; - Quad *q = new Quad("particles/glow", Vector(400+237*menuBg->scale.x,300-52*menuBg->scale.x)+notePos); - q->setBlendType(RenderObject::BLEND_ADD); - q->scale = Vector(5,5); - q->alpha.ensureData(); - q->alpha.data->path.addPathNode(0, 0); - q->alpha.data->path.addPathNode(0.75, 0.5); - q->alpha.data->path.addPathNode(0.75, 0.5); - q->alpha.data->path.addPathNode(0, 1); - q->alpha.startPath(t); - q->followCamera = 1; - q->setLife(t); - q->setDecayRate(1); - - game->addRenderObject(q, LR_HUD); - - currentSongMenuNote++; - } - else - { - - /* - if (playedDudNote) - playingSongInMenu = -1; - else - playedDudNote = true; - */ - } - } - } - else - { - if (songMenuPlayDelay >= 1.0f) - { - playingSongInMenu = -1; - } - } - } - } -} - - void Game::updateCursor(float dt) { bool rotate = false; @@ -9828,43 +4374,6 @@ void Game::constrainCamera() } } -bool areEntitiesUnique() -{ - bool unique = true; - int c = 0; - - FOR_ENTITIES(i) - { - Entity *e = *i; - FOR_ENTITIES(j) - { - Entity *e2 = *j; - if (e != e2) - { - if (e->getID() == e2->getID()) - { - std::ostringstream os; - os << "found non-unique entity: " << e->getID() << " names, " << e->name << " and " << e2->name; - debugLog(os.str()); - unique = false; - c++; - } - } - } - } - if (unique) - { - debugLog("Entity IDs are unique"); - } - else - { - std::ostringstream os; - os << c << " Entity IDs are NOT unique"; - debugLog(os.str()); - } - return unique; -} - bool Game::isControlHint() { return controlHint_bg->alpha.x != 0; @@ -10010,17 +4519,6 @@ void Game::update(float dt) } } } - if (enqueuedPreviewRecipe) - { - updatePreviewRecipe(); - enqueuedPreviewRecipe = 0; - } - - if (moveFoodSlotToFront) - { - moveFoodSlotToFront->moveToFront(); - moveFoodSlotToFront = 0; - } if (ingOffYTimer > 0) { @@ -10032,26 +4530,8 @@ void Game::update(float dt) } } - if (cookDelay > 0) - { - cookDelay -= dt; - if (cookDelay < 0) - cookDelay = 0; - } - if (avatar) { - /*tintColor.update(dt); - if (core->afterEffectManager) - { - if (tintColor.isInterpolating()) - core->afterEffectManager->setActiveShader(AS_GLOW); - else - core->afterEffectManager->setActiveShader(AS_NONE); - - core->afterEffectManager->glowShader.setValue(tintColor.x, tintColor.y, tintColor.z, 1); - }*/ - if (avatar->isRolling()) particleManager->addInfluence(ParticleInfluence(avatar->position, 300, 800, true)); else if (avatar->isCharging()) @@ -10064,27 +4544,8 @@ void Game::update(float dt) particleManager->setSuckPosition(0, avatar->position); particleManager->setSuckPosition(1, avatar->position + avatar->vel + avatar->vel2); - - //avatar->vel.getLength2D() - /* - for (Shot::Shots::iterator i = Shot::shots.begin(); i != Shot::shots.end(); i++) - { - Emitter::addInfluence(ParticleInfluence((*i)->position, 400, 128, true)); - } - */ - /* - FOR_ENTITIES (i) - { - Entity *e = *i; - if (e->getEntityType() != ET_AVATAR && e->collideRadius > 0) - { - Emitter::addInfluence(ParticleInfluence(e->position, 200, e->collideRadius, false)); - } - } - */ } updateParticlePause(); - //areEntitiesUnique(); if (controlHintTimer > 0) { controlHintTimer -= dt; @@ -10118,44 +4579,9 @@ void Game::update(float dt) FlockEntity::updateFlockData(); - updateCurrentVisuals(dt); updateCursor(dt); updateBgSfxLoop(); - /* - for (int i = 0; i < 2; i++) - dsq->spawnBubble(Vector(rand()%800 + core->cameraPos.x, rand()%600 + core->cameraPos.y, -0.05f), Vector(0, 0,0)); - */ - - // spawn bubbles - /* - const float spawnTime = 0.008; - static float bubbleTimer = 0; - bubbleTimer += dt; - int sx1, sx2, sy1, sy2; - int extra = 300; - sx1 = core->screenCullX1 - extra; - sx2 = core->screenCullX2 + extra; - sy1 = core->screenCullY1 - extra; - sy2 = core->screenCullY2 + extra; - - while (bubbleTimer >= spawnTime) - { - Vector p(sx1 + rand()%(sx2-sx1),sy1 + rand()%(sy2-sy1)); - Quad *q = new Quad; - q->scale = Vector(0.25,0.25); - q->position = p; - q->setTexture("bubble"); - q->setLife(2); - q->setDecayRate(1); - q->alpha = 0; - q->alpha.interpolateTo(0.4, 1, 1, 1, 1); - addRenderObject(q, LR_ELEMENTS3); - q->velocity = Vector(((rand()%200)-100)/100.0f, ((rand()%200)-100)/100.0f); - q->velocity *= 32; - bubbleTimer -= spawnTime; - } - */ sceneColor.update(dt); sceneColor2.update(dt); @@ -10169,50 +4595,7 @@ void Game::update(float dt) { setParallaxTextureCoordinates(bg2, 0.1); } - updateInGameMenu(dt); - if (avatar && grad && bg && bg2) - { - //float d = avatar->position.y / float(40000.0); - - /* - Vector top1(0.6, 0.8, 0.65); - Vector top2(0.1, 0.2, 0.4); - Vector btm1(0.1, 0.2, 0.4); - Vector btm2(0, 0, 0.1); - */ - /* - Vector top1(0.5, 0.65, 7); - Vector top2(0.2, 0.25, 0.3); - Vector btm1(0.2, 0.25, 0.3); - Vector btm2(0, 0, 0.1); - */ - - /* - // dynamic gradient - Vector top1(99/256.0f, 166/256.0f, 170/256.0f); - Vector top2(86/256.0f, 150/256.0f, 154/256.0f); - Vector btm1(86/256.0f, 150/256.0f, 154/256.0f); - Vector btm2(66/256.0f, 109/256.0f, 122/256.0f); - btm2 *= 0.75; - - - Vector newtop1(105/256.0f, 190/256.0f, 200/256.0f); - - grad->makeVertical(newtop1, btm2); - */ - - - - //grad->makeVertical(top1*(1.0-d) + top2*(d), btm1*(1.0-d) + btm2*(d)); - /* - float range = 0.5f; - float left = 1.0f - range; - float v = ((range-(d*range)) + left); - bg->color = Vector(v,v,v); - bg2->color = Vector(v,v,v); - */ - - } + themenu->update(dt); #ifdef AQUARIA_BUILD_SCENEEDITOR { @@ -10237,21 +4620,11 @@ void Game::update(float dt) if (avatar && (avatar->isEntityDead() || avatar->health <= 0) && core->getNestedMains()==1 && !isPaused()) { dsq->stopVoice(); - /* - if (runGameOverScript && dsq->runScript("scripts/maps/" + sceneName + ".lua", "gameOver")) - { - // no game over for you! - } - else - */ if (deathTimer > 0) { deathTimer -= dt; if (deathTimer <= 0) { - // run game over script - - //errorLog("here"); core->enqueueJumpState("GameOver"); } } @@ -10263,7 +4636,6 @@ void Game::update(float dt) } if (avatar && core->getNestedMains() == 1 && !isPaused() && !avatar->isSinging() && activation) - // && dsq->continuity.form == FORM_NORMAL { dsq->continuity.refreshAvatarData(avatar); @@ -10301,8 +4673,6 @@ void Game::update(float dt) } avatar->pathToActivate = 0; - //if (!avatar->entityToActivate && !avatar->state.lockedToWall) - // make sure you also disable entityToActivate if (dsq->game && dsq->game->avatar->canActivateStuff()) @@ -10328,14 +4698,6 @@ void Game::update(float dt) } } } - - /* - if (!hadThingToActivate && (avatar->entityToActivate || avatar->pathToActivate)) - { - debugLog("Spawning cursor particles"); - dsq->spawnParticleEffect("CursorBurst", dsq->getGameCursorPosition()); - } - */ } if (!activation) @@ -10400,19 +4762,6 @@ bool Game::isElementLayerVisible(int bgLayer) return core->getRenderObjectLayer(LR_ELEMENTS1+bgLayer)->visible; } -/* -void Game::cameraPanToNode(Path *p, int speed) -{ - - cameraFollow = &p->nodes[0].position; -} - -void Game::cameraRestore() -{ - setCameraFollow(avatar); -} -*/ - Shot *Game::fireShot(const std::string &bankShot, Entity *firer, Entity *target, const Vector &pos, const Vector &aim, bool playSfx) { Shot *s = 0; @@ -10453,65 +4802,6 @@ Shot *Game::fireShot(const std::string &bankShot, Entity *firer, Entity *target, return s; } -Shot* Game::fireShot(Entity *firer, const std::string &particleEffect, Vector position, bool big, Vector dir, Entity *target, int homing, int velLenOverride, int targetPt) -{ - //sound->playSfx("BasicShot", 255, 0, rand()%100 + 1000); - /* - DamageType dt; - if (firer->getEntityType() == ET_ENEMY) - dt = DT_ENEMY_ENERGYBLAST; - else if (firer->getEntityType() == ET_AVATAR) - dt = DT_AVATAR_ENERGYBLAST; - else - debugLog("UNDEFINED DAMAGE TYPE!"); - int velLen = 900; - if (big) - velLen += 200; - if (velLenOverride != 0) - velLen = velLenOverride; - Shot *shot; - if (big && target) - shot = new Shot(dt, firer, position, target, "energyBlast", homing, velLen, 8, 0.1, 4, 2); - else - { - if (homing > 0) - shot = new Shot(dt, firer, position, target, "energyBlast", homing, velLen, 5, 0.1, 4, 1); - else - shot = new Shot(dt, firer, position, 0, "energyBlast", 0, velLen, 5, 0.1, 4, 1); - } - shot->setParticleEffect(particleEffect); - if (big) - shot->scale = Vector(1.5, 1.5); - //shot->velocity = dsq->getGameCursorPosition() - position; - if (dir.x == 0 && dir.y == 0 && target) - { - shot->velocity = target->position - firer->position; - } - else - { - shot->velocity = dir; - } - if (velLen != 0 && !shot->velocity.isZero()) - shot->velocity.setLength2D(velLen); - - if (firer->getEntityType() == ET_AVATAR && homing && target) - { - //std::ostringstream os; - //os << "targetvel(" << target->vel.x << ", " << target->vel.y << ")"; - //debugLog(os.str()); - if (!target->vel.isZero() && !target->vel.isNan()) - shot->velocity += target->vel; - } - shot->targetPt = targetPt; - //shot->velocity += firer->vel; - - core->getTopStateData()->addRenderObject(shot, LR_PROJECTILES); - return shot; - */ - debugLog("Old version of Game::fireShot is obsolete"); - return 0; -} - void Game::warpCameraTo(RenderObject *r) { warpCameraTo(r->position); @@ -10563,15 +4853,6 @@ void Game::loadElementTemplates(std::string pack) { stringToLower(pack); - /* - std::string fn = ("data/"+pack+".xml"); - if (!exists(fn)) - { - loadElementTemplatesDAT(pack); - return; - } - loadElementTemplatesXML(pack); - */ elementTemplates.clear(); @@ -10657,11 +4938,6 @@ void Game::setGrid(ElementTemplate *et, Vector position, float rot360) for (int i = 0; i < et->grid.size(); i++) { TileVector t(position); - /* - std::ostringstream os; - os << "opos(" << position.x << ", " << position.y << ") centre(" << t.x << ", " << t.y << ")"; - debugLog(os.str()); - */ int x = et->grid[i].x; int y = et->grid[i].y; if (rot360 >= 0 && rot360 < 90) @@ -10687,7 +4963,6 @@ void Game::setGrid(ElementTemplate *et, Vector position, float rot360) y = -y; } TileVector s(t.x+x, t.y+y); - //Vector v = Vector(position.x+et->grid[i].x*TILE_SIZE, position.y+et->grid[i].y*TILE_SIZE); setGrid(s, OT_INVISIBLE); } } @@ -10700,8 +4975,6 @@ void Game::removeState() dsq->subtitlePlayer.hide(fadeTime); - dropIngrNames.clear(); - debugLog("Entering Game::removeState"); shuttingDownGameState = true; debugLog("avatar->endOfGameState()"); @@ -10736,19 +5009,9 @@ void Game::removeState() clearControlHint(); dsq->overlay->color = 0; - //dsq->overlay->alpha = 0; dsq->overlay->alpha.interpolateTo(1, fadeTime); dsq->main(fadeTime); - /* - // to block on voice overs - while (dsq->isStreamingVoice()) - { - dsq->main(FRAME_TIME); - } - */ - // AFTER TRANSITION: - dsq->rumble(0,0,0); dsq->sound->clearFadingSfx(); @@ -10769,18 +5032,11 @@ void Game::removeState() dsq->getRenderObjectLayer(LR_BLACKGROUND)->update = true; - //core->sound->fadeOut(1); if (saveFile) { delete saveFile; saveFile = 0; } - /* - if (core->getEnqueuedJumpState() != "Game") - { - this->overrideMusic = ""; - } - */ dsq->continuity.zoom = core->globalScale; dsq->game->toggleOverrideZoom(false); @@ -10803,7 +5059,6 @@ void Game::removeState() dsq->clearElements(); dsq->clearEntities(); avatar = 0; - //items.clear(); #ifdef AQUARIA_BUILD_SCENEEDITOR sceneEditor.shutdown(); #endif @@ -10824,20 +5079,6 @@ void Game::removeState() gridRenderUser1 = 0; gridRenderUser2 = 0; worldMapRender = 0; - //core->sound->stopStreamingOgg(); - - // optimize:: clear layers - /* - int c = 0; - for (DSQ::RenderObjectLayers::iterator i = core->renderObjectLayers.begin(); i != core->renderObjectLayers.end(); i++) - { - DSQ::RenderObjects *r = &(*i); - //if (c <= LR_HUD) - if (c<=LR_PARTICLES) - r->clear(); - c++; - } - */ clearObsRows(); @@ -10857,13 +5098,7 @@ void Game::removeState() active = false; - - dsq->routeShoulder = true; - - - debugLog("Game::removeState Done"); - //core->sound->stopAllSounds(); } bool Game::isActive() @@ -11007,10 +5242,6 @@ void Game::learnedRecipe(Recipe *r, bool effects) dsq->game->setControlHint(os.str(), 0, 0, 0, 3, std::string("gfx/ingredients/") + data->gfx); } } - - /* - errorLog(os.str()); - */ } } @@ -11026,3 +5257,8 @@ bool Game::isIgnoreAction(AquariaActions ac) const { return ignoredActions.find(ac) != ignoredActions.end(); } + +void Game::onContinuityReset() +{ + themenu->onContinuityReset(); +} diff --git a/Aquaria/Game.h b/Aquaria/Game.h index 687a120..198ee60 100644 --- a/Aquaria/Game.h +++ b/Aquaria/Game.h @@ -35,47 +35,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. using namespace tinyxml2; -class RecipeMenuEntry : public RenderObject -{ -public: - RecipeMenuEntry(Recipe *recipe); -protected: - void onUpdate(float dt); - Quad *result, *ing[3]; - Quad *glow; - BitmapText *description; - IngredientData *data; - - Recipe *recipe; - - int selected; -}; - -struct RecipeMenu -{ - RecipeMenu(); - Quad *scroll; - Quad *scrollEnd; - BitmapText *header, *page, *description; - AquariaMenuItem *nextPage, *prevPage; - - - void toggle(bool on, bool watch=false); - void createPage(int p); - void slide(RenderObject *r, bool in, float t); - void destroyPage(); - void goNextPage(); - void goPrevPage(); - int getNumPages(); - int getNumKnown(); - - int currentPage; - - bool on; - - std::vector recipeMenuEntries; -}; - class Avatar; class Gradient; class CurrentRender; @@ -84,8 +43,9 @@ class SongLineRender; class AutoMap; class DebugButton; class WorldMapRender; +class InGameMenu; -const float boxElementZ = -0.1f; +// FIXME: this should be made dynamic, or at least a power of 2 const int MAX_GRID = 2222; const char CHAR_DOWN = 'd'; @@ -184,122 +144,6 @@ protected: typedef std::list Ingredients; -class WarpArea -{ -public: - WarpArea() - { - w = h = radius = 0; - generated = false; - } - Vector position; - Vector avatarPosition; - int radius; - bool generated; - int w, h; - Vector spawnOffset; - std::string sceneName, warpAreaType; -}; - -class SongSlot : public AquariaGuiQuad -{ -public: - SongSlot(int songSlot); - - int songSlot, songType; - bool mbDown; -protected: - Quad *glow; - void onUpdate(float dt); -}; - -class FoodSlot : public AquariaGuiQuad -{ -public: - FoodSlot(int slot); - - void refresh(bool effects); - int slot; - void toggle(bool f); - static int foodSlotIndex; - - IngredientData *getIngredient() { return ingredient; } - - float scaleFactor; - - void eatMe(); - void moveRight(); - void discard(); - - bool isCursorIn(); - - void setOriginalPosition(const Vector &op); - -protected: - int rmb; - bool right; - float doubleClickDelay; - float grabTime; - int lastAmount; - IngredientData *lastIngredient; - Vector originalPosition; - void onUpdate(float dt); - DebugFont *label; - bool inCookSlot; - IngredientData *ingredient; - Quad *lid; -}; - -class PetSlot : public AquariaGuiQuad -{ -public: - PetSlot(int pet); - int petFlag; -protected: - bool wasSlot; - int petidx; - bool mouseDown; - void onUpdate(float dt); -}; - -class TreasureSlot : public AquariaGuiQuad -{ -public: - TreasureSlot(int treasureFlag); - void refresh(); -protected: - float doubleClickTimer; - bool mbd; - int flag; - std::string treasureName, treasureDesc; - int index; - void onUpdate(float dt); -}; - -class FoodHolder : public Quad -{ -public: - FoodHolder(int slot, bool trash=false); - - bool isEmpty(); - bool isTrash(); - void setIngredient(IngredientData *i, bool effects=true); - void dropFood(); - IngredientData *getIngredient(); - void animateLid(bool down, bool longAnim=true); -protected: - bool trash; - Quad *wok, *ing; - bool buttonDown; - void onUpdate(float dt); - - Quad *lid; - - int slot; -private: - IngredientData *foodHolderIngredient; -}; - class ElementTemplate { public: @@ -314,25 +158,6 @@ public: int idx; }; -class MiniMapHint -{ -public: - std::string scene; - std::string warpAreaType; - void clear() - { - debugLog("miniMapHint: CLEAR"); - scene = warpAreaType = ""; - } -}; - -class WarpAreaRender : public RenderObject -{ -public: -protected: - void onRender(); -}; - class ObsRow { public: @@ -415,7 +240,7 @@ public: void flipElementVert(); void deleteSelectedElement(); void deleteElement(int selectedIdx); - void action(int id, int state); + virtual void action(int id, int state, int source); void scaleElementUp(); void scaleElementDown(); void scaleElement1(); @@ -436,10 +261,6 @@ public: void regenLevel(); - - void startDrawingWarpArea(char c); - void endDrawingWarpArea(char c); - void updateSaveFileEnemyPosition(Entity *ent); void startMoveEntity(); void endMoveEntity(); @@ -467,7 +288,6 @@ public: Entity *editingEntity; Path *editingPath; - void toggleWarpAreaRender(); int selectedIdx; int selectedNode; Path *getSelectedPath(); @@ -536,8 +356,6 @@ protected: Vector oldPosition, oldRotation, oldScale, cursorOffset, oldRepeatScale; Entity *movingEntity; - void updateDrawingWarpArea(char c, int k); - char drawingWarpArea; void nextEntityType(); void prevEntityType(); @@ -546,13 +364,8 @@ protected: void selectEntityFromGroups(); - - WarpAreaRender *warpAreaRender; Vector zoom; - Vector boxPos; - Quad *boxPromo; - bool drawingBox; void rotateElement(); void rotateElement2(); void updateText(); @@ -632,20 +445,11 @@ public: void applyState(); void removeState(); void update(float dt); - void onLeftMouseButton(); Avatar *avatar; Entity *li; - Element *elementWithMenu; - - FoodSlot *moveFoodSlotToFront; - - - - std::string getSelectedChoice() { return selectedChoice; } - ObsType getGrid(const TileVector &tile) const; ObsType getGridRaw(const TileVector &tile) const; unsigned char *getGridColumn(int tileX); @@ -656,11 +460,6 @@ public: void trimGrid(); void dilateGrid(unsigned int radius, ObsType test, ObsType set, ObsType allowOverwrite); - void clearPointers(); - - void sortFood(); - void updatePreviewRecipe(); - void transitionToScene(std::string scene); bool loadScene(std::string scene); @@ -669,9 +468,9 @@ public: void toggleWorldMap(); - void action(int id, int state); + void action(int id, int state, int source); - void adjustFoodSlotCursor(); + InGameMenu *getInGameMenu() { return themenu; } void loadElementTemplates(std::string pack); Element* createElement(int etidx, Vector position, int bgLayer=0, RenderObject *copy=0, ElementTemplate *et=0); @@ -704,16 +503,11 @@ public: ElementTemplate *getElementTemplateByIdx(int idx); bool saveScene(std::string scene); - typedef std::vector WarpAreas; - WarpAreas warpAreas; void postInitEntities(); EntityClass *getEntityClassForEntityType(const std::string &type); - void warpToArea(WarpArea *area); - InterpolatedVector sceneColor, sceneColor2, sceneColor3; - Vector backupSceneColor; Vector getCameraPositionFor(const Vector &vec); @@ -743,16 +537,9 @@ public: XMLDocument *saveFile; Vector positionToAvatar; - float getCoverage(Vector pos, int sampleArea = 5); - float getPercObsInArea(Vector position, int range, int obs=-1); Vector getWallNormal(Vector pos, int sampleArea = 5, float *dist=0, int obs = -1); - // HACK:: clean up these vars - std::string warpAreaType, warpAreaSide; - Vector spawnOffset; - Vector miniMapHintPosition; - MiniMapHint miniMapHint; void updateMiniMapHintPosition(); EntitySaveData *getEntitySaveDataForEntity(Entity *e, Vector pos); Entity *createEntity(int idx, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType = ET_ENEMY, bool doPostInit=false); @@ -760,23 +547,17 @@ public: Entity *establishEntity(Entity *e, int id=0, Vector position=Vector(0,0), int rot=0, bool createSaveData=false, std::string name="", EntityType = ET_ENEMY,bool doPostInit=false); void setCameraFollow(RenderObject *r); void setCameraFollowEntity(Entity *e); - void setMenuDescriptionText(const std::string &text); bool removeEntityAtCursor(); void toggleOverrideZoom(bool on); - bool doFlagCheck(const std::string &flagCheck, FlagCheckType type=NO_TYPE, bool lastTruth=false); bool useWaterLevel; InterpolatedVector waterLevel; int saveWaterLevel; - void flipSceneVertical(int flipY); void warpCameraTo(RenderObject *r); - bool isSceneFlipped(); - void refreshItemSlotIcons(); void addObsRow(int tx, int ty, int len); void clearObsRows(); - void setWarpAreaSceneName(WarpArea &warpArea); Entity *getEntityAtCursor(); Vector cameraMin, cameraMax; bool removeEntity(Entity *e); @@ -815,19 +596,10 @@ public: void loadEntityTypeList(); std::vector entitySaveData; int getIdxForEntityType(std::string type); - void hideInGameMenu(bool effects=true, bool cancel=false); - void showInGameMenu(bool force=false, bool optionsOnly=false, MenuPage menuPage = MENUPAGE_NONE); - bool optionsOnly; - - MenuPage currentMenuPage; - int currentFoodPage, currentTreasurePage; Precacher tileCache; - - void setCameraFollow(Vector *position); - Shot *fireShot(Entity *firer, const std::string &particleEffect, Vector position, bool big, Vector direction, Entity *target, int homing=0, int velLenOverride=0, int targetPt=-1); Shot *fireShot(const std::string &bankShot, Entity *firer, Entity *target=0, const Vector &pos=Vector(0,0,0), const Vector &aim=Vector(0,0,0), bool playSfx=true); void playBurstSound(bool wallJump=false); void toggleMiniMapRender(); @@ -839,7 +611,6 @@ public: void setTimerText(float time); void generateCollisionMask(Quad *q, float overrideCollideRadius=0); - std::string sceneNatureForm; std::string fromScene, toNode; int toFlip; char fromWarpType; @@ -861,18 +632,8 @@ public: void setControlHint(const std::string &hint, bool left, bool right, bool middle, float time, std::string image="", bool ignoreClear=false, int songType=0, float scale=1); void clearControlHint(); - void colorTest(); - - void playSongInMenu(int songType, bool override=false); - bool trace(Vector start, Vector target); - Quad *menuSongs; - std::vector songSlots; - std::vector foodSlots; - std::vector treasureSlots; - BitmapText* songDescription; - BitmapText *timerText; float cameraLerpDelay; @@ -884,23 +645,17 @@ public: void setElementLayerVisible(int bgLayer, bool v); bool isElementLayerVisible(int bgLayer); - void showInGameMenuExitCheck(); - void hideInGameMenuExitCheck(bool refocus); bool isControlHint(); int getNumberOfEntitiesNamed(const std::string &name); MiniMapRender *miniMapRender; WorldMapRender *worldMapRender; - AutoMap *autoMap; - - Quad *hudUnderlay; int worldMapIndex; bool loadingScene; WaterSurfaceRender *waterSurfaceRender; - Quad *shapeDebug; #ifdef AQUARIA_BUILD_SCENEEDITOR EntityGroups entityGroups; @@ -924,14 +679,8 @@ public: void hideImage(); bool bNatural; - void onLips(); std::string sceneToLoad; void snapCam(); - - void updateOptionsMenu(float dt); - BitmapText *songLabel, *foodLabel, *foodDescription, *treasureLabel; - ToolTip *treasureDescription; - Quad *treasureCloseUp; void updateBgSfxLoop(); void preLocalWarp(LocalWarpType localWarpType); void postLocalWarp(); @@ -940,30 +689,6 @@ public: bool isShuttingDownGameState() { return shuttingDownGameState; } void warpToSceneNode(std::string scene, std::string node); - AquariaProgressBar *progressBar; - void addProgress(); - void endProgress(); - - void refreshFoodSlots(bool effects); - void refreshTreasureSlots(); - - Recipe *findRecipe(const std::vector &list); - void onCook(); - void onRecipes(); - void updateCookList(); - void onUseTreasure(); - void onUseTreasure(int flag); - - void onPrevFoodPage(); - void onNextFoodPage(); - - void onPrevTreasurePage(); - void onNextTreasurePage(); - - std::vector dropIngrNames; - - AquariaMenuItem *lips; - int lastCollideMaskIndex; void ensureLimit(Entity *e, int num, int state=0); @@ -973,7 +698,6 @@ public: float getTimer(float mod=1); float getHalfTimer(float mod=1); - float getHalf2WayTimer(float mod=1); std::string bgSfxLoopPlaying2; @@ -1008,16 +732,10 @@ public: void pickupIngredientEffects(IngredientData *data); void bindInput(); - RecipeMenu recipeMenu; - - AquariaMenuItem *eYes, *eNo, *cook, *recipes, *nextFood, *prevFood, *nextTreasure, *prevTreasure, *use, *keyConfigButton; - AquariaMenuItem *opt_cancel, *opt_save, *foodSort; bool cameraOffBounds; - void enqueuePreviewRecipe(); - - void toggleHelpScreen() { action(ACTION_TOGGLEHELPSCREEN, 0); } + void toggleHelpScreen() { action(ACTION_TOGGLEHELPSCREEN, 0, -1); } void setWorldPaused(bool b) { worldPaused = b; } bool isWorldPaused() const { return worldPaused; } @@ -1025,6 +743,8 @@ public: void setIgnoreAction(AquariaActions ac, bool ignore); bool isIgnoreAction(AquariaActions ac) const; + void onContinuityReset(); + protected: void toggleHelpScreen(bool on, const std::string &label=""); @@ -1038,30 +758,11 @@ protected: TTFText *helpText; bool inHelpScreen; - int enqueuedPreviewRecipe; - - Quad *previewRecipe; - Quad *menuIconGlow; - Quad *showRecipe; - - bool isCooking; - - void doMenuSectionHighlight(int sect); - - float cookDelay; - float ingOffY; float ingOffYTimer; std::vector controlHintNotes; - void onPrevRecipePage(); - void onNextRecipePage(); - - - - typedef std::vector CookList; - CookList cookList; bool active; bool applyingState; @@ -1071,70 +772,19 @@ protected: void warpPrep(); bool shuttingDownGameState; - void onOptionsMenu(); - bool optionsMenu, foodMenu, petMenu, treasureMenu, keyConfigMenu; - void toggleOptionsMenu(bool f, bool skipBackup=false, bool isKeyConfig=false); - void toggleFoodMenu(bool f); - void toggleMainMenu(bool f); - void togglePetMenu(bool f); - void toggleTreasureMenu(bool f); - void toggleRecipeList(bool on); - void toggleKeyConfigMenu(bool f); - - void switchToSongMenu(); - void switchToFoodMenu(); - void switchToPetMenu(); - void switchToTreasureMenu(); - - void onKeyConfig(); - - void addKeyConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int y, int l1=0, int l2=0, int l3=0); - - AquariaKeyConfig *addAxesConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int y, int offx); - - void onOptionsSave(); - void onOptionsCancel(); - AquariaSlider *sfxslider, *musslider, *voxslider; - AquariaCheckBox *autoAimCheck, *targetingCheck, *toolTipsCheck, *flipInputButtonsCheck, *micInputCheck, *blurEffectsCheck; - AquariaCheckBox *subtitlesCheck, *fullscreenCheck, *ripplesCheck; - AquariaComboBox *resBox; - Quad *songBubbles, *energyIdol, *liCrystal; - - RenderObject *group_keyConfig; - - Quad *options; - Quad *image; void initEntities(); - - void onExitCheckNo(); - void onExitCheckYes(); - - BitmapText *circlePageNum; - - std::vector foodTips, songTips, petTips, treasureTips; - - - - Quad *eAre; - int inGameMenuExitState; float controlHintTimer; bool cameraConstrained; void updateCursor(float dt); - void updateInGameMenu(float dt); - float songMenuPlayDelay; - int currentSongMenuNote; - int playingSongInMenu; + Quad *controlHint_mouseLeft, *controlHint_mouseRight, *controlHint_mouseBody, *controlHint_mouseMiddle, *controlHint_bg, *controlHint_image; Quad *controlHint_shine; bool controlHint_ignoreClear; BitmapText *controlHint_text; - - - void updateCurrentVisuals(float dt); std::string lastTileset; @@ -1144,19 +794,6 @@ protected: void findMaxCameraValues(); std::vector obsRows; - bool sceneFlipped; - - - void flipRenderObjectVertical(RenderObject *r, int flipY); - void onFlipTest(); - - void onDebugSave(); - - BitmapText *menuDescription; - BitmapText *menuEXP, *menuMoney; - - std::vector spellIcons; - int currentInventoryPage; float backgroundImageRepeat; std::string musicToPlay; @@ -1164,20 +801,8 @@ protected: float deathTimer; - - void onInGameMenuInventory(); - void onInGameMenuSpellBook(); - void onInGameMenuContinue(); - void onInGameMenuOptions(); - void onInGameMenuSave(); - void onInGameMenuExit(); - void onPressEscape(); - - - std::vector menu; - Quad *menuBg, *menuBg2; bool paused; bool worldPaused; @@ -1196,25 +821,16 @@ protected: void toggleSceneEditor(); #endif - unsigned char grid[MAX_GRID][MAX_GRID]; - - Quad *bg, *bg2; - bool inGameMenu; - float menuOpenTimer; - - std::vector itemSlotIcons, itemSlotEmptyIcons; - - - std::string selectedChoice; - void warpCameraTo(Vector position); std::set ignoredActions; private: Ingredients ingredients; + InGameMenu *themenu; + static unsigned char grid[MAX_GRID][MAX_GRID]; }; extern Game *game; diff --git a/Aquaria/GridRender.h b/Aquaria/GridRender.h index e3913e2..5a48d8b 100644 --- a/Aquaria/GridRender.h +++ b/Aquaria/GridRender.h @@ -86,7 +86,7 @@ public: Vector getAvatarWorldMapPosition(); Vector getWorldToTile(WorldMapTile *tile, Vector position, bool fromCenter, bool tilePos); void setProperTileColor(WorldMapTile *tile); - void action(int id, int state); + void action(int id, int state, int source); GemMover* addGem(GemData *gemData); void bindInput(); void createGemHint(const std::string &gfx); diff --git a/Aquaria/InGameMenu.cpp b/Aquaria/InGameMenu.cpp new file mode 100644 index 0000000..641320e --- /dev/null +++ b/Aquaria/InGameMenu.cpp @@ -0,0 +1,3986 @@ +#include "InGameMenu.h" + +#include "DSQ.h" +#include "Game.h" +#include "AquariaMenuItem.h" +#include "Quad.h" +#include "ToolTip.h" +#include "DSQ.h" +#include "Avatar.h" +#include "GridRender.h" + +static InGameMenu *themenu = 0; + +std::vector foodHolders; +std::vector petSlots; + + +// ---------------- Constants ---------------------------- + +static const float MENUPAGETRANSTIME = 0.2; +const Vector menuBgScale(800.0f/1024.0f, 800.0f/1024.0f); +const int foodPageSize = 16; +const int treasurePageSize = 16; +const int ITEMS_PER_PAGE = 12; +const int numTreasures = 16*2; + +const Vector worldLeftCenter(217,250), worldRightCenter(575, 250); +const Vector opt_save_original = Vector(350, 350), opt_cancel_original = Vector(450, 350); + + +// --------- Private class defs, not used outside --------------- + +class FoodSlot : public AquariaGuiQuad +{ +public: + FoodSlot(int slot); + + void refresh(bool effects); + int slot; + void toggle(bool f); + static int foodSlotIndex; + + IngredientData *getIngredient() { return ingredient; } + + float scaleFactor; + + void eatMe(); + void moveRight(); + void discard(); + + bool isCursorIn(); + + void setOriginalPosition(const Vector &op); + +protected: + int rmb; + bool right; + float doubleClickDelay; + float grabTime; + int lastAmount; + IngredientData *lastIngredient; + Vector originalPosition; + void onUpdate(float dt); + DebugFont *label; + bool inCookSlot; + IngredientData *ingredient; + Quad *lid; +}; + +int FoodSlot::foodSlotIndex = -1; + + +class PetSlot : public AquariaGuiQuad +{ +public: + PetSlot(int pet); + int petFlag; +protected: + bool wasSlot; + int petidx; + bool mouseDown; + void onUpdate(float dt); +}; + +class TreasureSlot : public AquariaGuiQuad +{ +public: + TreasureSlot(int treasureFlag); + void refresh(); +protected: + float doubleClickTimer; + bool mbd; + int flag; + std::string treasureName, treasureDesc; + int index; + void onUpdate(float dt); +}; + +class FoodHolder : public Quad +{ +public: + FoodHolder(int slot, bool trash=false); + + bool isEmpty(); + bool isTrash(); + void setIngredient(IngredientData *i, bool effects=true); + void dropFood(); + IngredientData *getIngredient(); + void animateLid(bool down, bool longAnim=true); +protected: + bool trash; + Quad *wok, *ing; + bool buttonDown; + void onUpdate(float dt); + + Quad *lid; + + int slot; +private: + IngredientData *foodHolderIngredient; +}; + +class SongSlot : public AquariaGuiQuad +{ +public: + SongSlot(int songSlot); + + int songSlot, songType; + bool mbDown; +protected: + Quad *glow; + void onUpdate(float dt); +}; + +// ------------- Private class impls ------------------- + + +PetSlot::PetSlot(int pet) : AquariaGuiQuad() +{ + PetData *p = dsq->continuity.getPetData(pet); + if (p) + { + std::string fn = "collectibles/egg-" + p->namePart; + setTexture(fn); + } + scale = Vector(0.9, 0.9); + petidx = pet; + mouseDown = false; + petFlag = FLAG_PET_NAMESTART + petidx; + wasSlot = false; +} + +void PetSlot::onUpdate(float dt) +{ + AquariaGuiQuad::onUpdate(dt); + + if (!dsq->continuity.getFlag(petFlag)) + { + if (!wasSlot) + { + setTexture("gui/wok"); + setWidthHeight(80); + wasSlot = true; + } + //alphaMod = 0; + return; + } + else + { + alphaMod = 1; + + if (wasSlot) + { + PetData *p = dsq->continuity.getPetData(petidx); + if (p) + { + std::string fn = "collectibles/egg-" + p->namePart; + setTexture(fn); + } + wasSlot = false; + } + } + + if (dsq->continuity.getFlag(FLAG_PET_ACTIVE) == petFlag) + { + color = Vector(1,1,1); + } + else + color = Vector(0.5, 0.5, 0.5); + + if (alpha.x < 1) return; + + if ((core->mouse.position - getWorldPosition()).isLength2DIn(32)) + { + scale.interpolateTo(Vector(1.2, 1.2), 0.1); + + if (core->mouse.buttons.left && !mouseDown) + { + mouseDown = true; + } + else if (!core->mouse.buttons.left && mouseDown) + { + dsq->sound->playSfx("click"); + + if (dsq->continuity.getFlag(FLAG_PET_ACTIVE) == petFlag) + { + game->setActivePet(0); + dsq->sound->playSfx("pet-on"); + } + else + { + game->setActivePet(FLAG_PET_NAMESTART + petidx); + dsq->sound->playSfx("pet-off"); + } + mouseDown = false; + } + } + else + { + mouseDown = false; + scale.interpolateTo(Vector(0.9, 0.9), 0.1); + } +} + +FoodHolder::FoodHolder(int slot, bool trash) : Quad(), slot(slot), trash(trash) +{ + foodHolderIngredient = 0; + buttonDown = false; + + //setTexture("Gui/wok"); + renderQuad = false; + + wok = new Quad; + if (trash) + wok->setTexture("gui/wok-drop"); + else + wok->setTexture("gui/wok"); + addChild(wok, PM_POINTER, RBP_ON); + + ing = new Quad; + ing->renderQuad = false; + addChild(ing, PM_POINTER); + + lid = new Quad("gui/wok-lid", Vector(0,0)); + lid->alpha = 0; + lid->alphaMod = 0.5; + addChild(lid, PM_POINTER); +} + +void FoodHolder::animateLid(bool down, bool longAnim) +{ + float t = 0.2; + + if (!longAnim) + { + t = 0.1; + } + + if (down) + { + dsq->sound->playSfx("bubble-lid"); + lid->alpha.interpolateTo(1, t); + dsq->main(t); + } + else + { + lid->alpha.interpolateTo(0, t); + } +} + +bool FoodHolder::isTrash() +{ + return trash; +} + +bool FoodHolder::isEmpty() +{ + return (foodHolderIngredient == 0); +} + +IngredientData *FoodHolder::getIngredient() +{ + return foodHolderIngredient; +} + +void FoodHolder::setIngredient(IngredientData *i, bool effects) +{ + IngredientData *oldi = foodHolderIngredient; + foodHolderIngredient = i; + + if (oldi) { + if (oldi->held > 0) + oldi->held --; + oldi->amount ++; + } + + if (!i) + { + //ing->scale.interpolateTo(Vector(0,0), 0.1); + ing->renderQuad = false; + //setTexture("Gui/wok"); + if (oldi && effects) + { + core->sound->playSfx("Drop"); + } + + themenu->enqueuePreviewRecipe(); + } + else + { + i->held ++; + if (i->amount > 0) + i->amount --; + + ing->setTexture("Ingredients/" + i->gfx); + ing->renderQuad = true; + if (effects) + { + core->sound->playSfx("Wok"); + + ing->scale.ensureData(); + ing->scale.data->path.clear(); + ing->scale.data->path.addPathNode(Vector(1,1),0); + ing->scale.data->path.addPathNode(Vector(1.25,1.25), 0.2); + ing->scale.data->path.addPathNode(Vector(1,1),1); + ing->scale.startPath(0.5); + } + + themenu->enqueuePreviewRecipe(); + } +} + + +void FoodHolder::dropFood() +{ + if (foodHolderIngredient) + { + setIngredient(0); + themenu->refreshFoodSlots(true); + } +} + +void FoodHolder::onUpdate(float dt) +{ + Quad::onUpdate(dt); + + if (!themenu->recipeMenu.on && foodHolderIngredient) + { + if ((core->mouse.position - getWorldPosition()).isLength2DIn(20)) + { + if (!buttonDown && core->mouse.buttons.left) + { + dropFood(); + buttonDown = true; + } + } + + if (!buttonDown && core->mouse.buttons.left) + buttonDown = true; + if (buttonDown && !core->mouse.buttons.left) + buttonDown = false; + } +} + +FoodSlot::FoodSlot(int slot) : AquariaGuiQuad(), slot(slot) +{ + doubleClickDelay = 0; + + right = false; + + renderQuad = false; + + label = new DebugFont(8, ""); + label->position = Vector(-2, 9); + addChild(label, PM_POINTER); + + inCookSlot = false; + + ingredient = 0; + + lastIngredient = 0; + lastAmount = 0; + + grabTime = 0; + + foodSlotIndex = -1; + scaleFactor = 1; + + shareAlphaWithChildren = 1; + + rmb = 0; + +} + +void FoodSlot::setOriginalPosition(const Vector &op) +{ + originalPosition = op; +} + +void FoodSlot::toggle(bool f) +{ + if (f) + { + alpha = 1; + alphaMod = 1; + label->alpha = 1; + } + else + { + alpha = 0; + alphaMod = 0; + label->alpha = 0; + } +} + +void FoodSlot::refresh(bool effects) +{ + int offset = themenu->currentFoodPage*foodPageSize; + IngredientData *i = dsq->continuity.getIngredientHeldByIndex(offset+slot); + if (i) + { + ingredient = i; + + if (i->amount > 0) + { + std::ostringstream os; + if (i->amount > 1) + os << i->amount << "/" << i->maxAmount; + label->setText(os.str()); + setTexture("Ingredients/" + i->gfx); + renderQuad = true; + } + else + { + label->setText(""); + renderQuad = true; + + setTexture("gui/wok"); + setWidthHeight(64); + } + } + else + { + ingredient = 0; + + label->setText(""); + renderQuad = true; + setTexture("gui/wok"); + setWidthHeight(64); + } + + scale.interpolateTo(Vector(1,1)*scaleFactor,0.001); + + if (ingredient != 0 && (i != lastIngredient || (i && i->amount != lastAmount))) + { + if (effects) + { + scale.ensureData(); + scale.data->path.clear(); + scale.data->path.addPathNode(Vector(1,1)*scaleFactor,0); + scale.data->path.addPathNode(Vector(1.5,1.5)*scaleFactor, 0.2); + scale.data->path.addPathNode(Vector(1,1)*scaleFactor,1); + scale.startPath(0.5); + } + } + + lastIngredient = i; + if (i) + lastAmount = i->amount; + else + lastAmount = 0; +} + +void FoodSlot::eatMe() +{ + if (ingredient && !dsq->isNested()) + { + for (int i = 0; i < foodHolders.size(); i++) + { + if (!foodHolders[i]->isTrash() && !foodHolders[i]->isEmpty()) + { + dsq->sound->playSfx("denied"); + foodHolders[i]->dropFood(); + return; + } + } + + if (!ingredient->effects.empty()) + { + bool eaten = dsq->continuity.applyIngredientEffects(ingredient); + if(eaten) + { + ingredient->amount--; + dsq->continuity.removeEmptyIngredients(); + themenu->refreshFoodSlots(true); + } + } + else + { + dsq->sound->playSfx("denied"); + /// don't + } + } +} + +void FoodSlot::moveRight() +{ + if (!ingredient) return; + if (ingredient->amount <= 0) return; + + for (int i = foodHolders.size()-1; i >= 0; i--) + { + if (foodHolders[i]->alpha.x > 0 && foodHolders[i]->alphaMod > 0 && foodHolders[i]->isEmpty() && !foodHolders[i]->isTrash()) + { + foodHolders[i]->setIngredient(ingredient); + inCookSlot = true; + refresh(true); + break; + } + } +} + +void FoodSlot::discard() +{ + if (!ingredient) return; + if (ingredient->amount <= 0) return; + + ingredient->amount--; + themenu->dropIngrNames.push_back(ingredient->name); + dsq->continuity.removeEmptyIngredients(); + themenu->refreshFoodSlots(true); +} + +bool FoodSlot::isCursorIn() +{ + return (core->mouse.position - getWorldPosition()).isLength2DIn(32); +} + +void FoodSlot::onUpdate(float dt) +{ + AquariaGuiQuad::onUpdate(dt); + + if (doubleClickDelay > 0) + { + doubleClickDelay -= dt; + if (doubleClickDelay < 0) doubleClickDelay = 0; + } + + if (alphaMod==1 && ingredient && ingredient->amount > 0) + { + if (foodSlotIndex == slot) + { + if (!core->mouse.buttons.left) + { + foodSlotIndex = -1; + if (!themenu->recipeMenu.on) + { + Vector wp = getWorldPosition(); + if ((themenu->lips->getWorldPosition() - wp).isLength2DIn(32)) + { + dsq->menuSelectDelay = 0.5; + + eatMe(); + } + else if (wp.x < 40 || wp.y < 40 || wp.x > 760 || wp.y > 560) + { + discard(); + } + else + { + bool droppedIn = false; + for (int i = 0; i < foodHolders.size(); i++) + { + bool in = (foodHolders[i]->getWorldPosition() - wp).isLength2DIn(32); + if (in) + { + droppedIn = true; + + if (foodHolders[i]->isTrash()) + { + discard(); + + themenu->foodLabel->alpha.interpolateTo(0, 2); + themenu->foodDescription->alpha.interpolateTo(0, 2); + + break; + } + else if (foodHolders[i]->isEmpty()) + { + foodHolders[i]->setIngredient(ingredient); + inCookSlot = true; + refresh(true); + break; + } + } + } + + if (!droppedIn) + { + if (doubleClickDelay > 0) + { + dsq->menuSelectDelay = 0.5; + doubleClickDelay = 0; + eatMe(); + + position = originalPosition; + + label->alpha = 1; + grabTime = 0; + + return; + } + else + { + doubleClickDelay = DOUBLE_CLICK_DELAY; + } + } + } + } + position = originalPosition; + + label->alpha = 1; + + grabTime = 0; + } + else + { + if (!themenu->recipeMenu.on) + { + if (dsq->inputMode == INPUT_MOUSE) + { + Vector diff = core->mouse.position - getWorldPosition(); + position += diff; + themenu->moveFoodSlotToFront = this; + } + } + } + } + + if ((core->mouse.position - getWorldPosition()).isLength2DIn(16)) + { + themenu->foodLabel->setText(ingredient->displayName); + themenu->foodLabel->alpha.interpolateTo(1, 0.2); + + themenu->foodDescription->setText(dsq->continuity.getIngredientAffectsString(ingredient)); + themenu->foodDescription->alpha.interpolateTo(1, 0.2); + + if (core->mouse.buttons.left && foodSlotIndex == -1) + { + grabTime = 0; + foodSlotIndex = slot; + label->alpha = 0; + + if (!inCookSlot) + { + originalPosition = position; + } + } + + if (core->mouse.buttons.right && !rmb) + { + rmb = 1; + } + else if (!core->mouse.buttons.right && rmb) + { + rmb = 0; + if (!themenu->recipeMenu.on) + moveRight(); + return; + } + } + else + { + if (!themenu->foodLabel->alpha.isInterpolating()) + themenu->foodLabel->alpha.interpolateTo(0, 2); + if (!themenu->foodDescription->alpha.isInterpolating()) + themenu->foodDescription->alpha.interpolateTo(0, 2); + rmb = 0; + } + } + else + { + rmb = 0; + } +} + +SongSlot::SongSlot(int songSlot) : AquariaGuiQuad(), songSlot(songSlot) +{ + songType = dsq->continuity.getSongTypeBySlot(songSlot); + std::ostringstream os; + os << "Song/SongSlot-" << songSlot; + setTexture(os.str()); + + glow = new Quad("particles/glow", Vector(0,0)); + glow->setWidthHeight(128, 128); + glow->setBlendType(RenderObject::BLEND_ADD); + glow->alpha = 0; + addChild(glow, PM_POINTER); + + mbDown = false; + + if (dsq->continuity.isSongTypeForm((SongType)dsq->continuity.getSongTypeBySlot(songSlot))) + scale = Vector(0.9, 0.9); + else + scale = Vector(0.6, 0.6); +} + +void SongSlot::onUpdate(float dt) +{ + AquariaGuiQuad::onUpdate(dt); + + if (alpha.x == 1 && alphaMod == 1 && (!parent || parent->alpha.x == 1)) + { + if ((core->mouse.position - getWorldPosition()).isLength2DIn(24)) + { + themenu->playSongInMenu(songType); + themenu->songLabel->setText(dsq->continuity.getSongNameBySlot(songSlot)); + themenu->songLabel->alpha.interpolateTo(1, 0.2); + const bool anyButton = core->mouse.buttons.left || core->mouse.buttons.right; + if (!mbDown && anyButton) + { + mbDown = true; + } + else if (mbDown && !anyButton) + { + mbDown = false; + + themenu->playSongInMenu(songType, 1); + if (!dsq->sound->isPlayingVoice()) + dsq->voice(dsq->continuity.getVoxForSongSlot(songSlot)); + } + glow->alpha.interpolateTo(0.2, 0.15); + } + else + { + mbDown = false; + glow->alpha.interpolateTo(0, 0.2); + if (!themenu->songLabel->alpha.isInterpolating()) + { + themenu->songLabel->alpha.interpolateTo(0, 2); + } + } + } +} + + +const int treasureFlagStart = 500; + +TreasureSlot::TreasureSlot(int index) : AquariaGuiQuad() +{ + this->index = index; + mbd = false; + flag = 0; + doubleClickTimer = 0; +} + +void TreasureSlot::onUpdate(float dt) +{ + AquariaGuiQuad::onUpdate(dt); + + doubleClickTimer -= dt; + if (doubleClickTimer < 0) + doubleClickTimer = 0; + + if (alphaMod == 1 && alpha.x == 1 && flag != 0) + { + if ((core->mouse.position - getWorldPosition()).isLength2DIn(18)) + { + scale.interpolateTo(Vector(1.2, 1.2), 0.1); + if (core->mouse.buttons.left && !mbd) + { + mbd = true; + } + else if (!core->mouse.buttons.left && mbd) + { + mbd = false; + + if (doubleClickTimer > 0) + { + doubleClickTimer = 0; + + themenu->onUseTreasure(flag); + } + else + { + dsq->sound->playSfx("treasure-select", 0.5); + dsq->spawnParticleEffect("menu-switch", worldRightCenter, 0, 0, LR_HUD3, 1); + + + + themenu->treasureLabel->setText(treasureName); + themenu->treasureLabel->alpha = 1; + themenu->treasureCloseUp->setTexture(dsq->continuity.treasureData[flag].gfx); + + themenu->treasureCloseUp->alpha = 1; + + themenu->treasureDescription->setText(treasureDesc, Vector(400,450), 400); + themenu->treasureDescription->alpha = 1; + + themenu->use->alpha = dsq->continuity.treasureData[flag].use; + + themenu->selectedTreasureFlag = flag; + + doubleClickTimer = 0.2; + + + std::ostringstream os; + os << "treasure flag: " << flag << " desc: " << treasureDesc; + debugLog(os.str()); + } + } + } + else + { + mbd = false; + scale.interpolateTo(Vector(1, 1), 0.1); + } + } + else + { + mbd = false; + scale.interpolateTo(Vector(1, 1), 0.001); + } +} + +void TreasureSlot::refresh() +{ + flag = (themenu->currentTreasurePage*treasurePageSize) + index + treasureFlagStart; + if (flag >= FLAG_COLLECTIBLE_START && flag < FLAG_COLLECTIBLE_END && dsq->continuity.getFlag(flag)>0) + { + // get treasure image somehow + setTexture(dsq->continuity.treasureData[flag].gfx); + float scl = dsq->continuity.treasureData[flag].sz; + + float w = width; + float h = height; + float sz = 50; + if (w > h) + { + w = sz; + h = (height*sz)/width; + } + else + { + h = sz; + w = (width*sz)/height; + } + + setWidthHeight(w*scl, h*scl); + + std::string parse = dsq->continuity.stringBank.get(flag); + + int p1 = parse.find_first_of('['); + if (p1 != std::string::npos) + { + p1++; + int p2 = parse.find_first_of(']'); + treasureName = parse.substr(p1,p2-p1); + + p1 = parse.find_last_of('['); + if (p1 != std::string::npos) + { + p1++; + p2 = parse.find_last_of(']'); + treasureDesc = parse.substr(p1,p2-p1); + } + } + + alphaMod = 1; + } + else + { + flag = 0; + alphaMod = 1; + + setTexture("gui/wok"); + setWidthHeight(48); + } +} + + + + +// ------------------ Menu code ------------------------- + +InGameMenu::InGameMenu() +{ + themenu = this; + inGameMenu = false; + optionsOnly = false; + cookDelay = 0; + lastMenuPage = MENUPAGE_NONE; + lastOptionsMenuPage = MENUPAGE_NONE; + optsfxdly = 0; + blurEffectsCheck = 0; + ripplesCheck = 0; + menu_blackout = 0; +} + +InGameMenu::~InGameMenu() +{ + themenu = 0; +} + +void InGameMenu::bindInput() +{ + dsq->user.control.actionSet.importAction(this, "Escape", ACTION_ESC); + + dsq->user.control.actionSet.importAction(this, "WorldMap", ACTION_TOGGLEWORLDMAP); + + dsq->user.control.actionSet.importAction(this, "PrevPage", ACTION_PREVPAGE); + dsq->user.control.actionSet.importAction(this, "NextPage", ACTION_NEXTPAGE); + dsq->user.control.actionSet.importAction(this, "CookFood", ACTION_COOKFOOD); + dsq->user.control.actionSet.importAction(this, "FoodLeft", ACTION_FOODLEFT); + dsq->user.control.actionSet.importAction(this, "FoodRight", ACTION_FOODRIGHT); + dsq->user.control.actionSet.importAction(this, "FoodDrop", ACTION_FOODDROP); +} + +void InGameMenu::reset() +{ + isCooking = false; + enqueuedPreviewRecipe = 0; + moveFoodSlotToFront = 0; + cookDelay = 0; + foodMenu = optionsMenu = petMenu = treasureMenu = false; + inGameMenuExitState = 0; + optsfxdly = 0; + playingSongInMenu = -1; + + dropIngrNames.clear(); + + create(); + hide(false); +} + +void InGameMenu::onContinuityReset() +{ + currentMenuPage = MENUPAGE_NONE; + currentFoodPage = 0; + currentTreasurePage = 0; + recipeMenu.currentPage = 0; + lastMenuPage = MENUPAGE_NONE; + lastOptionsMenuPage = MENUPAGE_NONE; +} + +void InGameMenu::action(int id, int state, int source) +{ + if(game->isIgnoreAction((AquariaActions)id)) + return; + + if (id == ACTION_TOGGLEMENU) + { + if(state) + show(); + else + hide(); + } + + if (id == ACTION_TOGGLEWORLDMAP && !state) + { + if (foodMenu) + { + recipes->setFocus(true); + recipeMenu.toggle(!recipeMenu.on, true); + } + } + + if(id == ACTION_ESC) + { + if (isInGameMenu()) + { + if (!AquariaKeyConfig::waitingForInput) + { + if (menuOpenTimer > 0.5f) + { + if (optionsMenu || keyConfigMenu) + onOptionsCancel(); + else + action(ACTION_TOGGLEMENU, 0, -1); // hide menu + } + } + } + } + + if (isInGameMenu()) + { + if (treasureMenu) + { + if (!state && !dsq->isNested()) + { + if (dsq->menuSelectDelay == 0) + { + if (id == ACTION_PREVPAGE) + { + dsq->menuSelectDelay = MENUSELECTDELAY; + onPrevTreasurePage(); + //menu[5]->setFocus(true); + } + if (id == ACTION_NEXTPAGE) + { + dsq->menuSelectDelay = MENUSELECTDELAY; + onNextTreasurePage(); + //menu[5]->setFocus(true); + } + } + } + } + else if (foodMenu) + { + if (!state && !dsq->isNested()) + { + if (dsq->menuSelectDelay == 0) + { + if (id == ACTION_PREVPAGE) + { + dsq->menuSelectDelay = MENUSELECTDELAY; + if (recipeMenu.on) + recipeMenu.goPrevPage(); + else + onPrevFoodPage(); + } + if (id == ACTION_NEXTPAGE) + { + dsq->menuSelectDelay = MENUSELECTDELAY; + if (recipeMenu.on) + recipeMenu.goNextPage(); + else + onNextFoodPage(); + } + } + + if (id == ACTION_COOKFOOD) + { + if (!recipeMenu.on) + onCook(); + } + + if (id == ACTION_FOODLEFT) + { + if (recipeMenu.on) + { + } + else + { + for (int i = 0; i < foodHolders.size(); i++) + { + if (!foodHolders[i]->isTrash() && !foodHolders[i]->isEmpty()) + { + foodHolders[i]->dropFood(); + break; + } + } + } + } + + if (id == ACTION_FOODRIGHT) + { + if (recipeMenu.on) + { + } + else + { + for (int i = 0; i < foodSlots.size(); i++) + { + if (foodSlots[i]->isCursorIn() && foodSlots[i]->getIngredient()) + { + foodSlots[i]->moveRight(); + break; + } + } + } + } + + if (id == ACTION_FOODDROP) + { + if (recipeMenu.on) + { + } + else + { + int trashIndex = -1; + for (int i = 0; i < foodHolders.size(); i++) + { + if (foodHolders[i]->alpha.x > 0 && foodHolders[i]->alphaMod > 0 && foodHolders[i]->isTrash()) + { + trashIndex = i; + break; + } + } + if (trashIndex >= 0) + { + int ingrIndex = -1; + for (int i = 0; i < foodSlots.size(); i++) + { + if (foodSlots[i]->isCursorIn() && foodSlots[i]->getIngredient()) + { + ingrIndex = i; + break; + } + } + if (ingrIndex >= 0) + { + foodSlots[ingrIndex]->discard(); + } + } + } + } + } + } + } +} + +void InGameMenu::enqueuePreviewRecipe() +{ + enqueuedPreviewRecipe = 1; +} + +void InGameMenu::setMenuDescriptionText(const std::string &text) +{ + menuDescription->setText(text); +} + +void InGameMenu::playSongInMenu(int songType, bool override) +{ + if (playingSongInMenu == -1 || override) + { + playingSongInMenu = songType; + currentSongMenuNote = 0; + songMenuPlayDelay = 0.5; + } +} + +void InGameMenu::updatePreviewRecipe() +{ + const float t = 0.2; + + updateCookList(); + + if (cookList.size() < 2 || recipeMenu.on){ + previewRecipe->alpha.interpolateTo(0, t); + } + else{ + Recipe *r = findRecipe(cookList); + + IngredientData *data=0; + + if (r && r->isKnown()) + { + data = dsq->continuity.getIngredientDataByName(r->result); + previewRecipe->setTexture("ingredients/"+data->gfx); + } + else + { + previewRecipe->setTexture("gui/question-mark"); + } + + previewRecipe->alpha.interpolateTo(1, t); + + } +} + + +void InGameMenu::show(bool ignoreInput, bool optionsOnly, MenuPage menuPage) +{ + if (game->avatar && core->getNestedMains()==1 && !game->avatar->isSinging() && (ignoreInput || game->avatar->isInputEnabled())) + { + game->clearControlHint(); + + selectedTreasureFlag = -1; + optionsOnly = optionsOnly; + + core->sound->playSfx("Menu-Open"); + dropIngrNames.clear(); + + if (game->avatar->isEntityDead()) return; + + toggleOptionsMenu(false); + dsq->overlay->alpha.interpolateTo(0, 0.1); + float t = 0.3; + + + if (!optionsOnly) + { + game->togglePause(true); + } + + if (optionsOnly) + { + menu_blackout = new Quad; + menu_blackout->color = 0; + menu_blackout->autoWidth = AUTO_VIRTUALWIDTH; + menu_blackout->autoHeight = AUTO_VIRTUALHEIGHT; + menu_blackout->followCamera = 1; + menu_blackout->position = Vector(400,300); + menu_blackout->alphaMod = 0.75; + menu_blackout->alpha = 0; + menu_blackout->alpha.interpolateTo(1, 0.5); + game->addRenderObject(menu_blackout, LR_AFTER_EFFECTS); + + menuBg2->alpha = 0; + } + else + { + menuBg2->alpha = 0; + menuBg2->alpha.interpolateTo(1, t*0.5f); + } + + if (dsq->continuity.hasFormUpgrade(FORMUPGRADE_ENERGY2)) + energyIdol->alphaMod = 1; + else + energyIdol->alphaMod = 0; + + if (dsq->continuity.getFlag(FLAG_LI) >= 100) + liCrystal->alphaMod = 1; + else + liCrystal->alphaMod = 0; + + int i = 0; + + + for (i = 0; i < songSlots.size(); i++) + { + if (dsq->continuity.hasSong(dsq->continuity.getSongTypeBySlot(i))) + songSlots[i]->alpha.interpolateTo(1, t); + else + songSlots[i]->alpha = 0; + } + + menuDescription->setText(""); + + menuDescription->alpha.interpolateTo(1, t); + + menuBg->scale = menuBgScale*0.5f; + menuBg->scale.interpolateTo(menuBgScale, t); + menuBg->alpha.interpolateTo(1, t*0.5f); + menuBg->setHidden(false); + + // FIXME: This gets a little verbose because of all the + // individual non-child objects. Is there a reason they + // can't all be children of menuBg? --achurch + opt_save->setHidden(false); + opt_cancel->setHidden(false); + options->setHidden(false); + keyConfigButton->setHidden(false); + cook->setHidden(false); + foodSort->setHidden(false); + recipes->setHidden(false); + use->setHidden(false); + prevFood->setHidden(false); + nextFood->setHidden(false); + prevTreasure->setHidden(false); + nextTreasure->setHidden(false); + circlePageNum->setHidden(false); + previewRecipe->setHidden(false); + showRecipe->setHidden(false); + recipeMenu.scroll->setHidden(false); + recipeMenu.scrollEnd->setHidden(false); + recipeMenu.header->setHidden(false); + recipeMenu.page->setHidden(false); + recipeMenu.prevPage->setHidden(false); + recipeMenu.nextPage->setHidden(false); + menuDescription->setHidden(false); + eAre->setHidden(false); + eYes->setHidden(false); + eNo->setHidden(false); + menuIconGlow->setHidden(false); + for (int i = 0; i < menu.size(); i++) + menu[i]->setHidden(false); + for (int i = 0; i < treasureSlots.size(); i++) + treasureSlots[i]->setHidden(false); + treasureDescription->setHidden(false); + for (int i = 0; i < foodSlots.size(); i++) + foodSlots[i]->setHidden(false); + + + if (game->miniMapRender) + { + game->miniMapRender->slide(1); + } + + toggleMainMenu(false); + + dsq->main(t); + + dsq->screenTransition->capture(); + + MenuPage useMenuPage = MENUPAGE_NONE; + + if (!optionsOnly) + { + if (menuPage != MENUPAGE_NONE) + { + useMenuPage = menuPage; + } + else if (lastMenuPage != MENUPAGE_NONE) + { + useMenuPage = lastMenuPage; + } + } + + switch(useMenuPage) + { + case MENUPAGE_FOOD: + toggleFoodMenu(true); + ((AquariaMenuItem*)menu[6])->setFocus(true); + break; + case MENUPAGE_TREASURES: + toggleTreasureMenu(true); + break; + case MENUPAGE_PETS: + togglePetMenu(true); + break; + case MENUPAGE_SONGS: + default: + { + if (optionsOnly) + { + toggleOptionsMenu(true); + } + else + { + float t = 0.1; + + toggleMainMenu(true); + + songBubbles->alpha.interpolateTo(1, t); + for (i = 0; i < menu.size(); i++) + { + menu[i]->scale = Vector(0,0); + menu[i]->alpha = 0; + } + ((AquariaMenuItem*)menu[5])->setFocus(true); + } + } + } + + + if (!optionsOnly) + { + for (i = 0; i < menu.size(); i++) + { + menu[i]->scale.interpolateTo(Vector(1, 1), 0.15); + + menu[i]->alpha.interpolateTo(1, 0.15); + } + + menuIconGlow->alpha.interpolateTo(1, 0.5); + } + + menuOpenTimer = 0; + + inGameMenu = true; + dsq->screenTransition->transition(MENUPAGETRANSTIME); + + if (optionsOnly) + dsq->main(-1); + } +} + + +void InGameMenu::hide(bool effects, bool cancel) +{ + if (isCooking) return; + if (FoodSlot::foodSlotIndex != -1) return; + if (effects && !isInGameMenu()) return; + + if (game->avatar) + { + if (resBox) + resBox->close(); + + if (effects) + core->sound->playSfx("Menu-Close"); + + hideInGameMenuExitCheck(false); + playingSongInMenu = -1; + + + float t = 0.3; + + if (!effects) + t = 0; + + for (int i = 0; i < foodHolders.size(); i++) + { + foodHolders[i]->dropFood(); + } + + lastMenuPage = currentMenuPage; + if(cancel && (optionsMenu || keyConfigMenu)) + onOptionsCancel(); + else + toggleOptionsMenu(false); + + if (!optionsOnly) + { + toggleFoodMenu(false); + toggleTreasureMenu(false); + togglePetMenu(false); + toggleMainMenu(false); + toggleKeyConfigMenu(false); + } + + menuIconGlow->alpha = 0; + + for (int i = 0; i < menu.size(); i++) + { + menu[i]->alpha = 0; + } + for (int i = 0; i < songSlots.size(); i++) + songSlots[i]->alpha.interpolateTo(0, t); + songBubbles->alpha.interpolateTo(0, t); + + if (game->miniMapRender) + game->miniMapRender->slide(0); + + menuDescription->alpha.interpolateTo(0, t); + menuBg->alpha.interpolateTo(0, t); + menuBg->scale.interpolateTo(menuBg->scale*0.5f, t); + menuBg2->alpha.interpolateTo(0, t); + + if (menu_blackout) + { + menu_blackout->alpha.interpolateTo(0, t); + } + + if (showRecipe) + { + showRecipe->alpha.interpolateTo(0, t); + } + + if (effects) + core->main(t); + + if (menu_blackout) + { + menu_blackout->safeKill(); + menu_blackout = 0; + } + if (effects) + game->togglePause(false); + + inGameMenu = false; + + for (int i = 0; i < songTips.size(); i++) + songTips[i]->alpha = 0; + + for (int i = 0; i < dropIngrNames.size(); i++) + { + game->spawnIngredient(dropIngrNames[i], game->avatar->position + Vector(0,-96), 1, 1); + } + dropIngrNames.clear(); + + if (effects) + dsq->quitNestedMain(); + } + + menuBg->setHidden(true); + opt_save->setHidden(true); + opt_cancel->setHidden(true); + options->setHidden(true); + keyConfigButton->setHidden(true); + cook->setHidden(true); + foodSort->setHidden(true); + recipes->setHidden(true); + use->setHidden(true); + prevFood->setHidden(true); + nextFood->setHidden(true); + prevTreasure->setHidden(true); + nextTreasure->setHidden(true); + circlePageNum->setHidden(true); + previewRecipe->setHidden(true); + showRecipe->setHidden(true); + recipeMenu.scroll->setHidden(true); + recipeMenu.scrollEnd->setHidden(true); + recipeMenu.header->setHidden(true); + recipeMenu.page->setHidden(true); + recipeMenu.prevPage->setHidden(true); + recipeMenu.nextPage->setHidden(true); + menuDescription->setHidden(true); + eAre->setHidden(true); + eYes->setHidden(true); + eNo->setHidden(true); + menuIconGlow->setHidden(true); + for (int i = 0; i < menu.size(); i++) + menu[i]->setHidden(true); + for (int i = 0; i < treasureSlots.size(); i++) + treasureSlots[i]->setHidden(true); + treasureDescription->setHidden(true); + for (int i = 0; i < foodSlots.size(); i++) + foodSlots[i]->setHidden(true); +} + + +void InGameMenu::addKeyConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int y, int l1, int l2, int l3) +{ + TTFText *lb = new TTFText(&dsq->fontArialSmallest); + lb->setText(label); + lb->position = Vector(140,y); + group->addChild(lb, PM_POINTER); + + AquariaKeyConfig *k1 = new AquariaKeyConfig(actionInputName, INPUTSET_KEY, 0); + k1->position = Vector(350,y); + k1->setLock(l1); + group->addChild(k1, PM_POINTER); + + AquariaKeyConfig *k2 = new AquariaKeyConfig(actionInputName, INPUTSET_KEY, 1); + k2->position = Vector(475,y); + k2->setLock(l2); + group->addChild(k2, PM_POINTER); + + AquariaKeyConfig *j1 = new AquariaKeyConfig(actionInputName, INPUTSET_JOY, 0); + j1->position = Vector(600,y); + j1->setLock(l3); + group->addChild(j1, PM_POINTER); + + k1->setDirMove(DIR_RIGHT, k2); + k2->setDirMove(DIR_RIGHT, j1); + + j1->setDirMove(DIR_LEFT, k2); + k2->setDirMove(DIR_LEFT, k1); +} + +AquariaKeyConfig *InGameMenu::addAxesConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int y, int offx) +{ + TTFText *lb = new TTFText(&dsq->fontArialSmallest); + lb->setText(label); + lb->position = Vector(140+offx, y); + group->addChild(lb, PM_POINTER); + + AquariaKeyConfig *i1 = new AquariaKeyConfig(actionInputName, INPUTSET_OTHER, 0); + i1->position = Vector(140+80+offx,y); + //i1->setLock(l1); + group->addChild(i1, PM_POINTER); + + i1->setDirMove(DIR_RIGHT, 0); + i1->setDirMove(DIR_LEFT, 0); + + return i1; +} + + +void InGameMenu::switchToSongMenu() +{ + dsq->screenTransition->capture(); + + toggleOptionsMenu(false); + toggleFoodMenu(false); + togglePetMenu(false); + toggleTreasureMenu(false); + + toggleMainMenu(true); + + dsq->screenTransition->transition(MENUPAGETRANSTIME); +} + +void InGameMenu::switchToFoodMenu() +{ + dsq->screenTransition->capture(); + + toggleOptionsMenu(false); + togglePetMenu(false); + toggleMainMenu(false); + toggleTreasureMenu(false); + + toggleFoodMenu(true); + dsq->screenTransition->transition(MENUPAGETRANSTIME); +} + +void InGameMenu::switchToPetMenu() +{ + dsq->screenTransition->capture(); + + toggleOptionsMenu(false); + toggleFoodMenu(false); + toggleMainMenu(false); + toggleTreasureMenu(false); + + togglePetMenu(true); + dsq->screenTransition->transition(MENUPAGETRANSTIME); +} + +void InGameMenu::switchToTreasureMenu() +{ + dsq->screenTransition->capture(); + + toggleOptionsMenu(false); + toggleFoodMenu(false); + toggleMainMenu(false); + togglePetMenu(false); + + toggleTreasureMenu(true); + dsq->screenTransition->transition(MENUPAGETRANSTIME); +} + + +void InGameMenu::sortFood() +{ + std::vector foodHolderNames; + foodHolderNames.resize(foodHolders.size()); + + for (int i = 0; i < foodHolders.size(); i++) { + IngredientData *ing = foodHolders[i]->getIngredient(); + if (ing) + foodHolderNames[i] = ing->name; + } + + dsq->continuity.foodSortType++; + if (dsq->continuity.foodSortType >= MAX_FOODSORT) + dsq->continuity.foodSortType = 0; + + dsq->continuity.sortFood(); + + // rebuild the page + + refreshFoodSlots(false); + + dsq->sound->playSfx("shuffle"); + dsq->sound->playSfx("menu-switch", 0.5); + dsq->spawnParticleEffect("menu-switch", worldLeftCenter, 0, 0, LR_HUD3, 1); + + for (int i = 0; i < foodHolders.size(); i++) { + if (!foodHolderNames[i].empty()) { + IngredientData *ing = dsq->continuity.getIngredientHeldByName(foodHolderNames[i]); + foodHolders[i]->setIngredient(ing, false); + } + } +} + +void InGameMenu::create() +{ + float menuz = 4; + int i = 0; + + + menuBg = new Quad; + menuBg->setTexture("menu"); + //menuBg->setWidthHeight(800); + //menuBg->scale = Vector(800.0f/1024.0f, 800.0f/1024.0f); + menuBg->position = Vector(400,300,menuz); + menuBg->followCamera = 1; + //menuBg->shareAlphaWithChildren=true; + game->addRenderObject(menuBg, LR_MENU); + + + menuBg2 = new Quad; + menuBg2->setTexture("menu2"); + menuBg2->position = Vector(0, 240); + menuBg->addChild(menuBg2, PM_POINTER); + + float scale = menuBg->scale.x; + /* + songDescription = new BitmapText(&dsq->font); + songDescription->position = Vector(0,100); + songDescription->parentManagedPointer = 1; + menuBg->addChild(songDescription); + */ + + options = new Quad; + + options->renderQuad = false; + + int sliderx = 250, slidery = 160, sliderd = 26; + int checkx=660, checky = 160, checkd = 26; + + Quad *audio = new Quad("gui/audiovisual", Vector(200, 125)); + options->addChild(audio, PM_POINTER); + + Quad *controls = new Quad("gui/controls", Vector(600, 125)); + options->addChild(controls, PM_POINTER); + + /* + Quad *visual = new Quad("gui/visual", Vector(170, 300)); + visual->parentManagedPointer = 1; + options->addChild(visual); + */ + + /* + Quad *blurEffectsLabel = new Quad("gui/blurEffectsLabel.png", visual->position + Vector(-20,40)); + blurEffectsLabel->parentManagedPointer = 1; + options->addChild(blurEffectsLabel); + */ + + /* + blurEffectsCheck = new AquariaCheckBox(); + blurEffectsCheck->position = visual->position + Vector(60, 40); + blurEffectsCheck->parentManagedPointer = 1; + options->addChild(blurEffectsCheck); + */ + + Quad *controllabels = new Quad("gui/controllabels", Vector(0,0,0)); + int w = controllabels->getWidth(); + int h = controllabels->getHeight(); + controllabels->position = Vector(checkx-16-w/2.0f, checky + h/2.0f - 14); + options->addChild(controllabels, PM_POINTER); + + + + int scheckx=270; + int schecky=315; + int sw,sh; + int voptoffy = 26; + + Quad *subtitleslabel = new Quad("gui/subtitles", Vector(0,0,0)); + sw = subtitleslabel->getWidth(); + sh = subtitleslabel->getHeight(); + subtitleslabel->position = Vector(scheckx-16-sw*0.5f, schecky + sh/2.0f - 14); + options->addChild(subtitleslabel, PM_POINTER); + + subtitlesCheck = new AquariaCheckBox(); + subtitlesCheck->setValue(dsq->user.audio.subtitles); + subtitlesCheck->position = Vector(scheckx,schecky); + options->addChild(subtitlesCheck, PM_POINTER); + + Quad *fullscreenLabel = new Quad("gui/fullscreen", Vector(0,0,0)); + fullscreenLabel->position = Vector(scheckx-16-sw*0.5f, schecky + voptoffy + sh/2.0f - 14); + options->addChild(fullscreenLabel, PM_POINTER); + + fullscreenCheck = new AquariaCheckBox(); + fullscreenCheck->setValue(dsq->isFullscreen()); + fullscreenCheck->position = Vector(scheckx,schecky + voptoffy); + options->addChild(fullscreenCheck, PM_POINTER); + + Quad *resolutionLabel = new Quad("gui/resolution", Vector(0,0,0)); + resolutionLabel->position = Vector(160, 260); + options->addChild(resolutionLabel, PM_POINTER); + + resBox = new AquariaComboBox(Vector(0.7f, 1.0f)); + resBox->position = Vector(196, 285); + for (i = 0; i < core->screenModes.size(); i++) + { + std::ostringstream os; + os << core->screenModes[i].x << "x" << core->screenModes[i].y; + if(core->screenModes[i].hz) + os << " (" << core->screenModes[i].hz << "hz)"; + resBox->addItem(os.str()); + if (core->screenModes[i].x == dsq->user.video.resx && core->screenModes[i].y == dsq->user.video.resy) + { + resBox->enqueueSelectItem(i); + } + } + options->addChild(resBox, PM_POINTER); + + Quad *audiolabels = new Quad("gui/audiolabels", Vector(0,0,0)); + w = audiolabels->getWidth(); + h = audiolabels->getHeight(); + audiolabels->position = Vector(sliderx-64-w/2.0f, slidery + h/2.0f - 14); + options->addChild(audiolabels, PM_POINTER); + + musslider = new AquariaSlider(); + musslider->setValue(dsq->user.audio.musvol); + musslider->position = Vector(sliderx,slidery+1*sliderd); + options->addChild(musslider, PM_POINTER); + + sfxslider = new AquariaSlider(); + sfxslider->setValue(dsq->user.audio.sfxvol); + sfxslider->position = Vector(sliderx,slidery); + options->addChild(sfxslider, PM_POINTER); + + voxslider = new AquariaSlider(); + voxslider->setValue(dsq->user.audio.voxvol); + voxslider->position = Vector(sliderx,slidery+2*sliderd); + options->addChild(voxslider, PM_POINTER); + + + flipInputButtonsCheck = new AquariaCheckBox(); + flipInputButtonsCheck->setValue(dsq->user.control.flipInputButtons); + flipInputButtonsCheck->position = Vector(checkx,checky); + options->addChild(flipInputButtonsCheck, PM_POINTER); + + micInputCheck = 0; + + toolTipsCheck = new AquariaCheckBox(); + toolTipsCheck->setValue(dsq->user.control.toolTipsOn); + toolTipsCheck->position = Vector(checkx,checky+1*checkd); + options->addChild(toolTipsCheck, PM_POINTER); + + autoAimCheck = new AquariaCheckBox(); + autoAimCheck->setValue(dsq->user.control.autoAim); + autoAimCheck->position = Vector(checkx,checky+2*checkd); + options->addChild(autoAimCheck, PM_POINTER); + + targetingCheck = new AquariaCheckBox(); + targetingCheck->setValue(dsq->user.control.targeting); + targetingCheck->position = Vector(checkx,checky+3*checkd); + options->addChild(targetingCheck, PM_POINTER); + + + + opt_save = new AquariaMenuItem; + opt_save->useQuad("gui/Apply"); + opt_save->useGlow("particles/glow", 100, 50); + opt_save->event.set(MakeFunctionEvent(InGameMenu, onOptionsSave)); + opt_save->position = opt_save_original; + opt_save->alpha = 0; + game->addRenderObject(opt_save, LR_MENU); + + opt_cancel = new AquariaMenuItem; + opt_cancel->useQuad("gui/Cancel"); + opt_cancel->useGlow("particles/glow", 100, 50); + opt_cancel->event.set(MakeFunctionEvent(InGameMenu, onOptionsCancel)); + opt_cancel->position = opt_cancel_original; + opt_cancel->alpha = 0; + game->addRenderObject(opt_cancel, LR_MENU); + + options->shareAlphaWithChildren = 1; + options->alpha = 0; + options->followCamera = 1; + game->addRenderObject(options, LR_MENU); + + scale = 1; + songSlots.clear(); + //songSlots.resize(3); + songSlots.resize(10); + // rewrite this: so you can hide / ignore certain songs, etc + //songSlots.resize(dsq->continuity.getSongBankSize()); + //Vector center(-235, -50); + Vector center(-230, -50), rightCenter(230, -50); + + energyIdol = new Quad("formupgrades/energyidol-charged", Vector(40,0)); + menuBg->addChild(energyIdol, PM_POINTER); + + liCrystal = new Quad("gui/li-crystal", Vector(0,0)); + menuBg->addChild(liCrystal, PM_POINTER); + + songBubbles = new Quad("gui/SongBubbles", Vector(-center.x, center.y)); + menuBg->addChild(songBubbles, PM_POINTER); + + + // Vector(575,250); + + + songLabel = new BitmapText(&dsq->smallFont); + { + songLabel->alpha = 0; + songLabel->setAlign(ALIGN_CENTER); + songLabel->followCamera = 1; + songLabel->setFontSize(20); + songLabel->position = Vector(-center.x, center.y) + Vector(0, -15); //+ Vector(10, -10); + songLabel->scale = Vector(1.2, 1.2); + } + menuBg->addChild(songLabel, PM_POINTER); + + + + ToolTip *tip = 0; + + foodTips.clear(); + songTips.clear(); + petTips.clear(); + treasureTips.clear(); + + tip = new ToolTip; + tip->alpha = 0; + tip->setCircularAreaFromCenter(worldLeftCenter, 240); + tip->setText(dsq->continuity.stringBank.get(0), Vector(200,450), 350); + game->addRenderObject(tip, LR_HUD); + foodTips.push_back(tip); + + + tip = new ToolTip; + tip->alpha = 0; + tip->setCircularAreaFromCenter(worldRightCenter, 240); + tip->setText(dsq->continuity.stringBank.get(1), Vector(600,450), 350); + game->addRenderObject(tip, LR_HUD); + foodTips.push_back(tip); + + + + tip = new ToolTip; + tip->alpha = 0; + tip->setCircularAreaFromCenter(worldLeftCenter, 240); + tip->setText(dsq->continuity.stringBank.get(14), Vector(200,450), 350); + game->addRenderObject(tip, LR_HUD); + songTips.push_back(tip); + + + /* + tip = new ToolTip; + tip->alpha = 0; + tip->setAreaFromCenter(Vector(400,300), 800, 600); + tip->setText(dsq->continuity.stringBank.get(16), Vector(400,300), 400); + game->addRenderObject(tip, LR_HUD); + petTips.push_back(tip); + */ + + tip = new ToolTip; + tip->alpha = 0; + tip->setCircularAreaFromCenter(worldLeftCenter, 240); + tip->setText(dsq->continuity.stringBank.get(17), Vector(200,450), 350); + game->addRenderObject(tip, LR_HUD); + petTips.push_back(tip); + + tip = new ToolTip; + tip->alpha = 0; + tip->setAreaFromCenter(Vector(400,350), 150, 50); + tip->setText(dsq->continuity.stringBank.get(15), Vector(400,450), 450); + game->addRenderObject(tip, LR_HUD); + songTips.push_back(tip); + foodTips.push_back(tip); + petTips.push_back(tip); + treasureTips.push_back(tip); + + int radius = 118; + int food = 0; + + keyConfigButton = new AquariaMenuItem; + keyConfigButton->useQuad("gui/keyconfig-button"); + keyConfigButton->useGlow("particles/glow", 128, 40); + keyConfigButton->position = worldRightCenter + Vector(0, 80); + keyConfigButton->alpha = 0; + keyConfigButton->scale = Vector(0.8, 0.8); + keyConfigButton->event.set(MakeFunctionEvent(InGameMenu, onKeyConfig)); + //keyConfigButton->setCanDirMove(false); + game->addRenderObject(keyConfigButton, LR_MENU); + + + + group_keyConfig = new RenderObject; + + /* + Quad *kbg = new Quad("gui/keyconfig-menu", Vector(400,300)); + kbg->setWidthHeight(800, 800); + group_keyConfig->addChild(kbg); + */ + + //Quad *kcb = new Quad; + RoundedRect *kcb = new RoundedRect(); + //kcb->color = 0; + //kcb->alphaMod = 0.75; + kcb->position = Vector(400,276 - 10); + kcb->setWidthHeight(580, 455, 10); + group_keyConfig->addChild(kcb, PM_POINTER); + + int offy = -20; + +#define SB(x) dsq->continuity.stringBank.get(x) + + TTFText *header_action = new TTFText(&dsq->fontArialSmall); + header_action->setText(SB(2101)); + header_action->position = Vector(140, 80+offy); + group_keyConfig->addChild(header_action, PM_POINTER); + + TTFText *header_key1 = new TTFText(&dsq->fontArialSmall); + header_key1->setText(SB(2102)); + header_key1->position = Vector(350, 80+offy); + header_key1->setAlign(ALIGN_CENTER); + group_keyConfig->addChild(header_key1, PM_POINTER); + + TTFText *header_key2 = new TTFText(&dsq->fontArialSmall); + header_key2->setText(SB(2103)); + header_key2->position = Vector(475, 80+offy); + header_key2->setAlign(ALIGN_CENTER); + group_keyConfig->addChild(header_key2, PM_POINTER); + + TTFText *header_joy = new TTFText(&dsq->fontArialSmall); + header_joy->setText(SB(2104)); + header_joy->position = Vector(600, 80+offy); + header_joy->setAlign(ALIGN_CENTER); + group_keyConfig->addChild(header_joy, PM_POINTER); + + addKeyConfigLine(group_keyConfig, SB(2105), "lmb", 100+offy, 0, 0, 0); + addKeyConfigLine(group_keyConfig, SB(2106), "rmb", 120+offy, 0, 0, 0); + addKeyConfigLine(group_keyConfig, SB(2107), "PrimaryAction", 140+offy); + addKeyConfigLine(group_keyConfig, SB(2108), "SecondaryAction", 160+offy); + addKeyConfigLine(group_keyConfig, SB(2109), "SwimUp", 180+offy); + addKeyConfigLine(group_keyConfig, SB(2110), "SwimDown", 200+offy); + addKeyConfigLine(group_keyConfig, SB(2111), "SwimLeft", 220+offy); + addKeyConfigLine(group_keyConfig, SB(2112), "SwimRight", 240+offy); + addKeyConfigLine(group_keyConfig, SB(2113), "Roll", 260+offy); + addKeyConfigLine(group_keyConfig, SB(2114), "Revert", 280+offy); + addKeyConfigLine(group_keyConfig, SB(2115), "WorldMap", 300+offy); + addKeyConfigLine(group_keyConfig, SB(2116), "Escape", 320+offy, 1, 0, 0); + + AquariaKeyConfig* s1x = addAxesConfigLine(group_keyConfig, SB(2117), "s1ax", 340+offy, 0); + AquariaKeyConfig* s1y = addAxesConfigLine(group_keyConfig, SB(2118), "s1ay", 340+offy, 130); + AquariaKeyConfig* s2x = addAxesConfigLine(group_keyConfig, SB(2119), "s2ax", 340+offy, 260); + AquariaKeyConfig* s2y = addAxesConfigLine(group_keyConfig, SB(2120), "s2ay", 340+offy, 380); + + s1x->setDirMove(DIR_LEFT, s1x); + s1x->setDirMove(DIR_RIGHT, s1y); + + s1y->setDirMove(DIR_LEFT, s1x); + s1y->setDirMove(DIR_RIGHT, s2x); + + s2x->setDirMove(DIR_LEFT, s1y); + s2x->setDirMove(DIR_RIGHT, s2y); + + s2y->setDirMove(DIR_LEFT, s2x); + s2y->setDirMove(DIR_RIGHT, s2y); + + offy += 20; + + addKeyConfigLine(group_keyConfig, SB(2121), "PrevPage", 340+offy); + addKeyConfigLine(group_keyConfig, SB(2122), "NextPage", 360+offy); + addKeyConfigLine(group_keyConfig, SB(2123), "CookFood", 380+offy); + addKeyConfigLine(group_keyConfig, SB(2124), "FoodLeft", 400+offy); + addKeyConfigLine(group_keyConfig, SB(2125), "FoodRight", 420+offy); + addKeyConfigLine(group_keyConfig, SB(2126), "FoodDrop", 440+offy); + + addKeyConfigLine(group_keyConfig, SB(2127), "Look", 460+offy); + + addKeyConfigLine(group_keyConfig, SB(2128), "ToggleHelp", 480+offy); + +#undef SB + + group_keyConfig->shareAlphaWithChildren = 1; + group_keyConfig->followCamera = 1; + group_keyConfig->alpha = 0; + group_keyConfig->setHidden(true); + + group_keyConfig->position = Vector(0, -40); + + game->addRenderObject(group_keyConfig, LR_OVERLAY); + + + cook = new AquariaMenuItem; + cook->useQuad("Gui/cook-button"); + cook->useGlow("particles/glow", 128, 40); + cook->position = worldRightCenter + Vector(0, -120); + cook->alpha = 0; + cook->scale = Vector(0.8, 0.8); + cook->event.set(MakeFunctionEvent(InGameMenu, onCook)); + cook->setCanDirMove(false); + game->addRenderObject(cook, LR_MENU); + + foodSort = new AquariaMenuItem; + foodSort->useQuad("gui/sort"); + foodSort->useSound("click"); + foodSort->useGlow("particles/glow", 32,32); + foodSort->position = worldLeftCenter + Vector(-100, -100); + foodSort->event.set(MakeFunctionEvent(InGameMenu, sortFood)); + foodSort->alpha = 0; + game->addRenderObject(foodSort, LR_MENU); + + recipes = new AquariaMenuItem; + recipes->useQuad("Gui/recipes-button"); + recipes->useGlow("particles/glow", 128, 32); + recipes->position = worldLeftCenter + Vector(-40, 140); + recipes->alpha = 0; + recipes->scale = Vector(0.8, 0.8); + recipes->event.set(MakeFunctionEvent(InGameMenu, onRecipes)); + game->addRenderObject(recipes, LR_MENU); + + use = new AquariaMenuItem; + use->useQuad("Gui/use-button"); + use->useGlow("particles/glow", 128, 64); + use->position = worldRightCenter + Vector(0, -120); + use->alpha = 0; + use->scale = Vector(0.8, 0.8); + use->event.set(MakeFunctionEvent(InGameMenu, onUseTreasure)); + game->addRenderObject(use, LR_MENU); + + prevFood = new AquariaMenuItem; + prevFood->useQuad("Gui/arrow-left"); + prevFood->useSound("click"); + prevFood->useGlow("particles/glow", 64, 32); + prevFood->position = worldLeftCenter + Vector(-50, -130); + prevFood->alpha = 0; + prevFood->event.set(MakeFunctionEvent(InGameMenu, onPrevFoodPage)); + prevFood->scale = Vector(0.6, 0.6); + prevFood->setCanDirMove(false); + game->addRenderObject(prevFood, LR_MENU); + + nextFood = new AquariaMenuItem; + nextFood->useQuad("Gui/arrow-right"); + nextFood->useSound("click"); + nextFood->useGlow("particles/glow", 64, 32); + nextFood->position = worldLeftCenter + Vector(50, -130); + nextFood->alpha = 0; + nextFood->setCanDirMove(false); + nextFood->event.set(MakeFunctionEvent(InGameMenu, onNextFoodPage)); + nextFood->scale = Vector(0.6, 0.6); + game->addRenderObject(nextFood, LR_MENU); + + prevTreasure = new AquariaMenuItem; + prevTreasure->useQuad("Gui/arrow-left"); + prevTreasure->useSound("click"); + prevTreasure->useGlow("particles/glow", 64, 32); + prevTreasure->position = worldLeftCenter + Vector(-50, -130); + prevTreasure->alpha = 0; + prevTreasure->setCanDirMove(false); + prevTreasure->scale = Vector(0.6, 0.6); + prevTreasure->event.set(MakeFunctionEvent(InGameMenu, onPrevTreasurePage)); + prevTreasure->setCanDirMove(false); + game->addRenderObject(prevTreasure, LR_MENU); + + nextTreasure = new AquariaMenuItem; + nextTreasure->useQuad("Gui/arrow-right"); + nextTreasure->useSound("click"); + nextTreasure->useGlow("particles/glow", 64, 32); + nextTreasure->position = worldLeftCenter + Vector(50, -130); + nextTreasure->alpha = 0; + nextTreasure->scale = Vector(0.6, 0.6); + nextTreasure->event.set(MakeFunctionEvent(InGameMenu, onNextTreasurePage)); + nextTreasure->setCanDirMove(false); + game->addRenderObject(nextTreasure, LR_MENU); + + circlePageNum = new BitmapText(&dsq->smallFont); + circlePageNum->color = Vector(0,0,0); + circlePageNum->position = worldLeftCenter + Vector(0, -142); + circlePageNum->alpha = 0; + circlePageNum->followCamera = 1; + game->addRenderObject(circlePageNum, LR_MENU); + + foodHolders.resize(3); + int holders=0; + for (i = 0; i < foodHolders.size(); i++) + { + foodHolders[i] = new FoodHolder(i); + foodHolders[i]->alpha = 0; + + float angle = (float(holders)/float(foodHolders.size()))*PI*2; + foodHolders[i]->position = rightCenter + Vector(sinf(angle), cosf(angle))*radius; + holders ++; + + menuBg->addChild(foodHolders[i], PM_POINTER); + } + + previewRecipe = new Quad; + previewRecipe->alphaMod = 0.75; + previewRecipe->followCamera = 1; + previewRecipe->alpha = 0; + previewRecipe->scale = Vector(0.7, 0.7); + previewRecipe->scale.interpolateTo(Vector(0.9, 0.9), 0.5, -1, 1, 1); + previewRecipe->position = worldRightCenter; + game->addRenderObject(previewRecipe, LR_MENU); + + showRecipe = new Quad(); + showRecipe->followCamera = 1; + showRecipe->position = Vector(575,250); + game->addRenderObject(showRecipe, LR_MENU); + + float scrollx = 555; + recipeMenu.scroll = new Quad("gui/recipe-scroll", Vector(scrollx, 200)); + recipeMenu.scroll->followCamera = 1; + recipeMenu.scroll->alpha = 0; + game->addRenderObject(recipeMenu.scroll, LR_RECIPES); // LR_HUD3 + + recipeMenu.scrollEnd = new Quad("gui/recipe-scroll-end", Vector(scrollx, 400)); + recipeMenu.scrollEnd->followCamera = 1; + recipeMenu.scrollEnd->alpha = 0; + game->addRenderObject(recipeMenu.scrollEnd, LR_RECIPES); + + recipeMenu.header = new BitmapText(&dsq->font); + recipeMenu.header->color = 0; + recipeMenu.header->followCamera = 1; + recipeMenu.header->setText(dsq->continuity.stringBank.get(2007)); + recipeMenu.header->alpha = 0; + recipeMenu.header->position = Vector(scrollx, 5); //10 + game->addRenderObject(recipeMenu.header, LR_RECIPES); + + recipeMenu.page = new BitmapText(&dsq->smallFont); + recipeMenu.page->color = 0; + recipeMenu.page->followCamera = 1; + recipeMenu.page->position = Vector(scrollx, 400); + recipeMenu.page->setText(dsq->continuity.stringBank.get(2006)); + recipeMenu.page->alpha = 0; + game->addRenderObject(recipeMenu.page, LR_RECIPES); + + recipeMenu.prevPage = new AquariaMenuItem; + recipeMenu.prevPage->useQuad("Gui/arrow-left"); + recipeMenu.prevPage->useSound("click"); + recipeMenu.prevPage->useGlow("particles/glow", 64, 32); + recipeMenu.prevPage->position = Vector(scrollx - 150, 410); + recipeMenu.prevPage->alpha = 0; + recipeMenu.prevPage->event.set(MakeFunctionEvent(InGameMenu, onPrevRecipePage)); + recipeMenu.prevPage->scale = Vector(0.8, 0.8); + game->addRenderObject(recipeMenu.prevPage, LR_RECIPES); + + recipeMenu.nextPage = new AquariaMenuItem; + recipeMenu.nextPage->useQuad("Gui/arrow-right"); + recipeMenu.nextPage->useSound("click"); + recipeMenu.nextPage->useGlow("particles/glow", 64, 32); + recipeMenu.nextPage->position = Vector(scrollx + 150, 410); + recipeMenu.nextPage->alpha = 0; + recipeMenu.nextPage->event.set(MakeFunctionEvent(InGameMenu, onNextRecipePage)); + recipeMenu.nextPage->scale = Vector(0.8, 0.8); + game->addRenderObject(recipeMenu.nextPage, LR_RECIPES); + + + petSlots.resize(dsq->continuity.petData.size()); + for (i = 0; i < petSlots.size(); i++) + { + PetData *p = dsq->continuity.getPetData(i); + if (p) + { + petSlots[i] = new PetSlot(i); + petSlots[i]->alpha = 0; + float angle = (float(i)/float(petSlots.size()))*PI*2; + petSlots[i]->position = center + Vector(sinf(angle), cosf(angle))*(radius*0.9f); + menuBg->addChild(petSlots[i], PM_POINTER); + } + } + + foodHolders.resize(4); + foodHolders[3] = new FoodHolder(-1, true); + foodHolders[3]->alpha = 0; + foodHolders[3]->position = rightCenter + Vector(96, 150); + menuBg->addChild(foodHolders[3], PM_POINTER); + + + + int outer = 0; + int inner = 0; + for (i = 0; i < songSlots.size(); i++) + { + songSlots[i] = new SongSlot(i); + float angle = 0; + SongType s = (SongType)dsq->continuity.getSongTypeBySlot(i); + if (dsq->continuity.isSongTypeForm(s)) + { + angle = (float(outer)/float(numForms))*PI*2; + songSlots[i]->position = center + Vector(sinf(angle), cosf(angle))*radius; + outer ++; + } + else + { + angle = (float(inner)/float(songSlots.size()-numForms))*PI*2 + PI; + songSlots[i]->position = center + Vector(sinf(angle), cosf(angle))*radius*0.4f; + inner ++; + } + menuBg->addChild(songSlots[i], PM_POINTER); + } + + menuDescription = new BitmapText(&dsq->smallFont); + menuDescription->setFontSize(14); + menuDescription->position = Vector(400, 450); + menuDescription->setAlign(ALIGN_CENTER); + menuDescription->setWidth(400); + menuDescription->followCamera = 1; + menuDescription->alpha = 0; + game->addRenderObject(menuDescription, LR_MENU); + + int areYouShim = -25; + eAre = new Quad; + eAre->position = Vector(400,448+areYouShim); + eAre->setTexture("AreYouSure"); + eAre->alpha = 0; + eAre->followCamera = 1; + game->addRenderObject(eAre, LR_MENU); + + eYes = new AquariaMenuItem; + eYes->position = Vector(400-100,516+areYouShim); + eYes->useQuad("Yes"); + eYes->useGlow("particles/glow", 100, 32); + eYes->event.set(MakeFunctionEvent(InGameMenu, onExitCheckYes)); + eYes->alpha = 0; + eYes->shareAlpha = 1; + game->addRenderObject(eYes, LR_MENU); + + eNo = new AquariaMenuItem; + eNo->position = Vector(400+100,516+areYouShim); + eNo->useQuad("No"); + eNo->useGlow("particles/glow", 100, 32); + eNo->event.set(MakeFunctionEvent(InGameMenu, onExitCheckNo)); + eNo->alpha = 0; + eNo->shareAlpha = 1; + game->addRenderObject(eNo, LR_MENU); + + eNo->setDirMove(DIR_LEFT, eYes); + eYes->setDirMove(DIR_RIGHT, eNo); + + + + menu.resize(10); + for (i = 0; i < menu.size(); i++) + menu[i] = new AquariaMenuItem; + + int ty = 530; + //menu[0]->setLabel("Continue"); + menu[0]->event.set(MakeFunctionEvent(InGameMenu, onInGameMenuContinue)); + menu[0]->useGlow("particles/glow", 200, 100); + //menu[0]->position = Vector(150, 550); + menu[0]->position = Vector(150-30, ty-10); + + //menu[1]->setLabel("Exit"); + menu[1]->useGlow("particles/glow", 200, 100); + menu[1]->event.set(MakeFunctionEvent(InGameMenu, onInGameMenuExit)); + //menu[1]->position = Vector(800-150, 550); + //menu[1]->position = Vector(800-150+30, ty); + menu[1]->position = Vector(800-150+20, ty-10); + + menu[2]->setLabel("DebugSave"); + menu[2]->event.set(MakeFunctionEvent(InGameMenu, onDebugSave)); + menu[2]->position = Vector(400,ty+60); + if (!dsq->isDeveloperKeys()) + menu[2]->position = Vector(400, 12000); + menu[2]->setCanDirMove(false); + + menu[3]->event.set(MakeFunctionEvent(InGameMenu, onLips)); + menu[3]->useGlow("particles/glow", 64, 64); + //menu[0]->position = Vector(150, 550); + menu[3]->position = Vector(400, 195); + menu[3]->setCanDirMove(false); + + lips = menu[3]; + + // options + menu[4]->event.set(MakeFunctionEvent(InGameMenu, onOptionsMenu)); + menu[4]->useGlow("particles/glow", 200, 32); + menu[4]->position = Vector(400,ty+10); + + int gs = 40; + + menu[5]->event.set(MakeFunctionEvent(InGameMenu, switchToSongMenu)); + menu[5]->useQuad("gui/icon-songs"); + menu[5]->useGlow("particles/glow", gs, gs); + menu[5]->useSound("Click"); + menu[5]->position = Vector(400-60, 350); + + menuIconGlow = new Quad("particles/glow", menu[5]->position); + menuIconGlow->alphaMod = 0.4; + menuIconGlow->alpha = 0; + menuIconGlow->setWidthHeight(80, 80); + menuIconGlow->setBlendType(RenderObject::BLEND_ADD); + menuIconGlow->followCamera = 1; + game->addRenderObject(menuIconGlow, LR_MENU); + + menu[6]->event.set(MakeFunctionEvent(InGameMenu, switchToFoodMenu)); + menu[6]->useQuad("gui/icon-food"); + menu[6]->useGlow("particles/glow", gs, gs); + menu[6]->useSound("Click"); + menu[6]->position = Vector(400-20, 350); + + menu[7]->event.set(MakeFunctionEvent(InGameMenu, switchToPetMenu)); + menu[7]->useQuad("gui/icon-pets"); + menu[7]->useGlow("particles/glow", gs, gs); + menu[7]->useSound("Click"); + menu[7]->position = Vector(400+20, 350); + + menu[8]->event.set(MakeFunctionEvent(InGameMenu, switchToTreasureMenu)); + menu[8]->useQuad("gui/icon-treasures"); + menu[8]->useGlow("particles/glow", gs, gs); + menu[8]->useSound("Click"); + menu[8]->position = Vector(400+60, 350); + + menu[9]->event.set(MakeFunctionEventPointer( Game, toggleHelpScreen, game)); + menu[9]->useQuad("gui/icon-help"); + menu[9]->useGlow("particles/glow", gs, gs); + menu[9]->useSound("Click"); + menu[9]->position = Vector(400+60*3, 410); + + /* + menu[9]->event.set(MakeFunctionEvent(Game, sortFood)); + menu[9]->setLabel("sort food"); + menu[9]->position = Vector(100,100); + */ + + for (i = 0; i < menu.size(); i++) + { + game->addRenderObject(menu[i], LR_MENU); + menu[i]->alpha = 0; + } + + ((AquariaMenuItem*)menu[5])->setDirMove(DIR_DOWN, ((AquariaMenuItem*)menu[0])); + ((AquariaMenuItem*)menu[6])->setDirMove(DIR_DOWN, ((AquariaMenuItem*)menu[4])); + ((AquariaMenuItem*)menu[7])->setDirMove(DIR_DOWN, ((AquariaMenuItem*)menu[4])); + ((AquariaMenuItem*)menu[8])->setDirMove(DIR_DOWN, ((AquariaMenuItem*)menu[1])); + + ((AquariaMenuItem*)menu[0])->setDirMove(DIR_UP, ((AquariaMenuItem*)menu[5])); + ((AquariaMenuItem*)menu[1])->setDirMove(DIR_UP, ((AquariaMenuItem*)menu[8])); + + ((AquariaMenuItem*)menu[4])->setDirMove(DIR_UP, ((AquariaMenuItem*)menu[6])); + + + + // ---------- FOOD MENU + + foodSlots.resize(foodPageSize); + + Vector worldCenter(222, 252); + + int foodSlotRadius = 96; + for (i = 0; i < foodSlots.size(); i++) + { + foodSlots[i] = new FoodSlot(i); + + float angle = (float(food)/float(foodSlots.size()))*PI*2; + foodSlots[i]->position = worldCenter + Vector(sinf(angle), cosf(angle))*foodSlotRadius; + + foodSlots[i]->setOriginalPosition(foodSlots[i]->position); + + food ++; + + foodSlots[i]->alphaMod = 0; + + foodSlots[i]->followCamera = 1; + + foodSlots[i]->scaleFactor = 0.75; + + //foodSlots[i]->parentManagedPointer = 1; + //menuBg->addChild(foodSlots[i]); + //foodSlots[i]->position = menuBg->getWorldCollidePosition(foodSlots[i]->position); + game->addRenderObject(foodSlots[i], LR_HUD2); + } + + + foodLabel = new BitmapText(&dsq->smallFont); + { + foodLabel->alpha = 0; + foodLabel->setAlign(ALIGN_CENTER); + foodLabel->followCamera = 1; + foodLabel->setFontSize(20); + foodLabel->position = center - Vector(0, 16) + Vector(0,-32); + foodLabel->scale = Vector(1, 1); + } + menuBg->addChild(foodLabel, PM_POINTER); + + foodDescription = new BitmapText(&dsq->smallFont); + { + foodDescription->alpha = 0; + foodDescription->setAlign(ALIGN_CENTER); + foodDescription->followCamera = 1; + foodDescription->position = center + Vector(0, 8) + Vector(0,-32); + foodDescription->scale = Vector(0.8, 0.8); + + foodDescription->setWidth(240); + } + menuBg->addChild(foodDescription, PM_POINTER); + + + // ---------- TREASURES + + + int treasureSlotRadius = 96; + + treasureSlots.resize(treasurePageSize); + + for (i = 0; i < treasureSlots.size(); i++) + { + treasureSlots[i] = new TreasureSlot(i); + + + float angle = (float(i)/float(treasureSlots.size()))*PI*2; + treasureSlots[i]->position = worldCenter + Vector(sinf(angle), cosf(angle))*treasureSlotRadius; + + treasureSlots[i]->alphaMod = 0; + + treasureSlots[i]->followCamera = 1; + + //treasureSlots[i]->scaleFactor = 0.75; + + game->addRenderObject(treasureSlots[i], LR_MENU); + } + + treasureLabel = new BitmapText(&dsq->smallFont); + { + treasureLabel->alpha = 0; + treasureLabel->setAlign(ALIGN_CENTER); + treasureLabel->followCamera = 1; + treasureLabel->setFontSize(20); + treasureLabel->position = center - Vector(0, 16); + treasureLabel->scale = Vector(1, 1); + } + menuBg->addChild(treasureLabel, PM_POINTER); + + treasureDescription = new ToolTip(); + treasureDescription->alpha = 0; + treasureDescription->setAreaFromCenter(Vector(400,200), 800, 400); + treasureDescription->required = true; + game->addRenderObject(treasureDescription, LR_HUD); + + foodTips.push_back(tip); + + treasureCloseUp = new Quad(); + treasureCloseUp->position = rightCenter; + treasureCloseUp->alpha = 0; + menuBg->addChild(treasureCloseUp, PM_POINTER); + + + + menuBg->alpha = 0; +} + +void InGameMenu::onNextRecipePage() +{ + recipeMenu.goNextPage(); +} + +void InGameMenu::onPrevRecipePage() +{ + recipeMenu.goPrevPage(); +} + + +void InGameMenu::onPrevTreasurePage() +{ + if (currentTreasurePage > 0) + { + dsq->sound->playSfx("menu-switch", 0.5); + dsq->spawnParticleEffect("menu-switch", worldLeftCenter, 0, 0, LR_HUD3, 1); + + currentTreasurePage--; + refreshTreasureSlots(); + } + else + { + if (numTreasures > 0) + { + dsq->sound->playSfx("menu-switch", 0.5); + dsq->spawnParticleEffect("menu-switch", worldLeftCenter, 0, 0, LR_HUD3, 1); + + currentTreasurePage = ((numTreasures-1)/treasurePageSize); + refreshTreasureSlots(); + } + } +} + +void InGameMenu::onNextTreasurePage() +{ + if ((currentTreasurePage+1)*treasurePageSize < numTreasures) + { + dsq->sound->playSfx("menu-switch", 0.5); + dsq->spawnParticleEffect("menu-switch", worldLeftCenter, 0, 0, LR_HUD3, 1); + + currentTreasurePage++; + refreshTreasureSlots(); + } + else + { + if (currentTreasurePage != 0) + { + dsq->sound->playSfx("menu-switch", 0.5); + dsq->spawnParticleEffect("menu-switch", worldLeftCenter, 0, 0, LR_HUD3, 1); + + currentTreasurePage = 0; + refreshTreasureSlots(); + } + } +} + +void InGameMenu::onPrevFoodPage() +{ + int lastFoodPage = currentFoodPage; + if (currentFoodPage > 0) + { + currentFoodPage--; + refreshFoodSlots(false); + } + else + { + if (dsq->continuity.hasIngredients()) + { + currentFoodPage = ((dsq->continuity.ingredientCount()-1)/foodPageSize); + refreshFoodSlots(false); + } + } + + std::ostringstream os; + os << "food page: " << currentFoodPage; + debugLog(os.str()); + + if (currentFoodPage != lastFoodPage) + { + dsq->sound->playSfx("menu-switch", 0.5); + dsq->spawnParticleEffect("menu-switch", worldLeftCenter, 0, 0, LR_HUD3, 1); + } +} + +void InGameMenu::onNextFoodPage() +{ + int lastFoodPage = currentFoodPage; + if ((currentFoodPage+1)*foodPageSize < dsq->continuity.ingredientCount()) + { + currentFoodPage++; + refreshFoodSlots(false); + } + else + { + if (currentFoodPage != 0) + { + currentFoodPage = 0; + refreshFoodSlots(false); + } + } + + if (currentFoodPage != lastFoodPage) + { + dsq->sound->playSfx("menu-switch", 0.5); + dsq->spawnParticleEffect("menu-switch", worldLeftCenter, 0, 0, LR_HUD3, 1); + } +} + +void InGameMenu::onUseTreasure() +{ + debugLog("Use Treasure!"); + + if (selectedTreasureFlag != -1) + { + onUseTreasure(selectedTreasureFlag); + } +} + +void InGameMenu::onUseTreasure(int flag) +{ + if(dsq->mod.isActive()) + dsq->runScriptNum(dsq->mod.getPath() + "scripts/menu-treasures.lua", "useTreasure", flag); + else + dsq->runScriptNum("scripts/global/menu-treasures.lua", "useTreasure", flag); +} + + +bool ingType(const std::vector &list, IngredientType type, int amount=1) +{ + int c = 0; + for (int i = 0; i < list.size(); i++) + { + IngredientData *data = list[i]; + if ((data->marked < data->held) && (data->type == type || type == IT_ANYTHING)) + { + if (type != IT_ANYTHING) + data->marked++; + c++; + if (c == amount) + return true; + } + } + return false; +} + +bool ingName(const std::vector &list, const std::string &name, int amount=1) +{ + int c = 0; + for (int i = 0; i < list.size(); i++) + { + IngredientData *data = list[i]; + if ((data->marked < data->held) && (nocasecmp(data->name, name)==0))//data->name == name) + { + data->marked++; + c++; + if (c == amount) + return true; + } + } + return false; +} + + +Recipe *InGameMenu::findRecipe(const std::vector &list) +{ + if (list.size() < 2) return 0; + + // there will be a number of types and a number of names + // the types and names DO NOT overlap + int rc = 0; + Recipe *r = 0; + Recipe *tr = 0; + int q = 0, q2 = 0; + for ( rc = 0; rc < dsq->continuity.recipes.size(); rc++) + { + for (int i = 0; i < list.size(); i++) list[i]->marked = 0; + + tr = 0; + r = &dsq->continuity.recipes[rc]; + tr = r; + q = 0; + + // get the amount of ingredients provided by the player + int listAmount = list.size(); + + // get the amount of ingredients required + int recipeAmount = 0; + + for (int i = 0; i < r->types.size(); i++) + recipeAmount += r->types[i].amount; + + for (int i = 0; i < r->names.size(); i++) + recipeAmount += r->names[i].amount; + + if (listAmount != recipeAmount) + continue; + + for (int c = 0; c < r->types.size(); c++) + { + RecipeType *t = &r->types[c]; + if (ingType(list, t->type, t->amount)) + q++; + else + break; + } + + /* + // if all the types are checked + // AND there are no names to check + // then you found it! + if (q == r->types.size() && q > 0 && r->names.empty()) + { + return tr; + } + */ + + // this check is _kinda_ unnecessary... but we'll see + if (q == r->types.size()) + { + q2 = 0; + for (int c = 0; c < r->names.size(); c++) + { + RecipeName *n = &r->names[c]; + if (ingName(list, n->name, n->amount)) + q2++; + else + break; + } + if (q2 == r->names.size()) + { + return r; + } + /* + // if there were actually types to check + // and they were checked successfully + // (being in this section of code implies that there were no types OR there was a successful full check) + else if (q>0 && tr) + { + // return the ingredient we found in types + + // but this is kind of silly. + // would make more sense to return earlier + return tr; + } + */ + } + } + + for (int i = 0; i < list.size(); i++) list[i]->marked = 0; + + if (rc == dsq->continuity.recipes.size()) + { + /* + data = dsq->continuity.getIngredientByName("SeaLoaf"); + if (data) + { + dsq->continuity.pickupIngredient(data); + } + */ + } + + return 0; +} + +void InGameMenu::updateCookList() +{ + cookList.clear(); + for (int i = 0; i < foodHolders.size(); i++) + { + IngredientData *ing = foodHolders[i]->getIngredient(); + if (!foodHolders[i]->isTrash() && ing) + { + std::ostringstream os; + os << "cooklist: " << ing->name; + debugLog(os.str()); + cookList.push_back(ing); + } + } +} + +void InGameMenu::onRecipes() +{ + if (foodMenu) + { + toggleRecipeList(!recipeMenu.on); + } +} + +void InGameMenu::onKeyConfig() +{ + dsq->screenTransition->capture(); + toggleKeyConfigMenu(true); + dsq->screenTransition->transition(MENUPAGETRANSTIME); +} + +#define DEBUG_COOK + +void InGameMenu::onCook() +{ + if (recipeMenu.on) return; + if (cookDelay > 0) return; + + debugLog("Cook!"); + + //std::vector list; + updateCookList(); + + if (cookList.size() < 2 || recipeMenu.on) return; + + AquariaGuiElement::canDirMoveGlobal = false; + + cookDelay = 0.4; + + bool cooked = false; + + isCooking = true; + + IngredientData *data=0; + Recipe *r = findRecipe(cookList); + + if (r) + data = dsq->continuity.getIngredientDataByName(r->result); + else if(game->cookingScript) + { + const char *p1 = cookList[0]->name.c_str(); + const char *p2 = cookList[1]->name.c_str(); + const char *p3 = cookList.size() >= 3 ? cookList[2]->name.c_str() : ""; + std::string ingname; + if(game->cookingScript->call("cookFailure", p1, p2, p3, &ingname)) + { + if(ingname.length()) + data = dsq->continuity.getIngredientDataByName(ingname); + if(!data) + goto endcook; + } + } + + if(!data) + { + dsq->sound->playSfx("Denied"); + data = dsq->continuity.getIngredientDataByName("SeaLoaf"); + + bool tooMany = data && dsq->continuity.isIngredientFull(data); + + if (!tooMany) + { + int f = dsq->continuity.getFlag(FLAG_SEALOAFANNOYANCE); + f++; + if (f >= 3) + { + dsq->voiceInterupt("naija_sealoaf"); + f = 0; + } + dsq->continuity.setFlag(FLAG_SEALOAFANNOYANCE, f); + } + } + + if (data) + { + cooked = !dsq->continuity.isIngredientFull(data); + } + + if (cooked) + { + debugLog("Cooked something!"); + + // do animationy stuff. + + core->mouse.buttonsEnabled = false; + + bool longAnim = true; + int cooks = dsq->continuity.getFlag(FLAG_COOKS); + + if (cooks >= 4) + longAnim = false; + + for (int i = foodHolders.size()-1; i >= 0; i--) + if (foodHolders[i]->alpha.x > 0 && !foodHolders[i]->isEmpty() && !foodHolders[i]->isTrash()) + foodHolders[i]->animateLid(true, longAnim); + + //dsq->main(0.2); + + + if (longAnim) + { + float ft = 0.8; + float nt = 0.1; + float nt2 = 0.2; + void *handle = NULL; + + /* + if (!longAnim) + { + float factor = 0.3; + ft *= factor; + nt *= factor; + nt2 *= factor; + } + */ + + PlaySfx note1; + note1.name = game->getNoteName(0); + PlaySfx note2; + note2.name = game->getNoteName(4); + PlaySfx note3; + note3.name = game->getNoteName(3); + + handle = dsq->sound->playSfx(note1); + dsq->main(nt2); + dsq->sound->fadeSfx(handle, SFT_OUT, ft); + dsq->main(nt); + + handle = dsq->sound->playSfx(note2); + dsq->main(nt2); + dsq->sound->fadeSfx(handle, SFT_OUT, ft); + dsq->main(nt); + + handle = dsq->sound->playSfx(note3); + dsq->main(nt2); + dsq->sound->fadeSfx(handle, SFT_OUT, ft); + dsq->main(nt); + } + + dsq->sound->playSfx("boil"); + + for (int i = 0; i < foodHolders.size(); i++) + { + if (!foodHolders[i]->isEmpty()) + dsq->spawnParticleEffect("cook-ingredient", foodHolders[i]->getWorldPosition(), 0, 0, LR_HUD3, 1); + } + + if (longAnim) + dsq->main(0.5); + else + dsq->main(0.2); + + bool haveLeftovers = true; + for (int i = 0; i < foodHolders.size(); i++) + { + if (!foodHolders[i]->isEmpty()) { + IngredientData *ing = foodHolders[i]->getIngredient(); + if (!ing || ing->amount < ing->held) + { + haveLeftovers = false; + break; + } + } + } + for (int i = 0; i < foodHolders.size(); i++) + { + IngredientData *ing = foodHolders[i]->getIngredient(); + if (ing) + { + ing->amount--; + } + + if (!haveLeftovers) + { + foodHolders[i]->setIngredient(0, false); + } + } + + dsq->sound->playSfx("Cook"); + + for (int i = 0; i < foodHolders.size(); i++) + if (foodHolders[i]->alpha.x > 0 && !foodHolders[i]->isTrash()) + foodHolders[i]->animateLid(false); + + dsq->spawnParticleEffect("cook-food", Vector(575,250), 0, 0, LR_HUD3, 1); + + if (longAnim) + dsq->main(0.5); + else + dsq->main(0.2); + + if (data) + { + float t = 3; + std::string n = "Ingredients/" + data->gfx; + //Quad *e = new Quad(); + + showRecipe->setTexture(n); + showRecipe->scale = Vector(0.5, 0.5); + showRecipe->scale.interpolateTo(Vector(1.2, 1.2), t); + showRecipe->alpha.ensureData(); + showRecipe->alpha.data->path.clear(); + showRecipe->alpha.data->path.addPathNode(0, 0); + showRecipe->alpha.data->path.addPathNode(1, 0.1); + showRecipe->alpha.data->path.addPathNode(1, 0.6); + showRecipe->alpha.data->path.addPathNode(0, 1); + showRecipe->alpha.startPath(t); + } + + dsq->continuity.pickupIngredient(data, 1); + + dsq->continuity.removeEmptyIngredients(); + + dsq->main(0.5); + + dsq->continuity.setFlag(FLAG_COOKS, dsq->continuity.getFlag(FLAG_COOKS)+1); + + if (r) + { + dsq->continuity.learnRecipe(r); + if (haveLeftovers) + updatePreviewRecipe(); + } + + core->mouse.buttonsEnabled = true; + } + else + { + dsq->sound->playSfx("Denied"); + dsq->centerMessage(dsq->continuity.stringBank.get(27)); + } + refreshFoodSlots(true); + +endcook: + + AquariaGuiElement::canDirMoveGlobal = true; + + isCooking = false; +} + + +FoodSlot* InGameMenu::getFoodSlotFromIndex() +{ + for (int i = 0; i < foodSlots.size(); i++) + { + if (foodSlots[i]->slot == FoodSlot::foodSlotIndex) + { + return foodSlots[i]; + } + } + return 0; +} + +void InGameMenu::onLips() +{ + if (!foodMenu) + { + if (dsq->lastVoiceFile.find("NAIJA_SONG_") != std::string::npos) + { + dsq->stopVoice(); + } + } +} + + +void InGameMenu::onExitCheckYes() +{ + dsq->sound->stopAllVoice(); + dsq->toggleCursor(0, 0.25); + dsq->title(); +} + +void InGameMenu::onExitCheckNo() +{ + hideInGameMenuExitCheck(true); +} + +void InGameMenu::showInGameMenuExitCheck() +{ + recipeMenu.toggle(false); + inGameMenuExitState = 1; + eYes->alpha.interpolateTo(1, 0.2); + eNo->alpha.interpolateTo(1, 0.2); + eAre->alpha.interpolateTo(1, 0.2); + + eNo->setFocus(true); +} + +void InGameMenu::hideInGameMenuExitCheck(bool refocus) +{ + inGameMenuExitState = 0; + eYes->alpha.interpolateTo(0, 0.2); + eNo->alpha.interpolateTo(0, 0.2); + eAre->alpha.interpolateTo(0, 0.2); + + if (refocus) + ((AquariaMenuItem*)menu[1])->setFocus(true); +} + +void InGameMenu::onInGameMenuExit() +{ + if (!dsq->user.demo.warpKeys || (core->getCtrlState() && core->getAltState())) + { + if (inGameMenuExitState == 0) + { + // show yes/no + showInGameMenuExitCheck(); + } + } +} + +void InGameMenu::onInGameMenuContinue() +{ + hide(); +} + + +void InGameMenu::onOptionsMenu() +{ + dsq->screenTransition->capture(); + toggleOptionsMenu(true); + dsq->screenTransition->transition(MENUPAGETRANSTIME); +} + +void InGameMenu::onOptionsSave() +{ + dsq->user.apply(); + + if (dsq->user.video.resx != dsq->user_backup.video.resx + || dsq->user.video.resy != dsq->user_backup.video.resy + || dsq->user.video.bits != dsq->user_backup.video.bits + || dsq->user.video.full != dsq->user_backup.video.full + || dsq->user.video.vsync != dsq->user_backup.video.vsync) + { + dsq->resetGraphics(dsq->user.video.resx, dsq->user.video.resy, dsq->user.video.full); + if (dsq->confirm("", "graphics", false, 10)) { + } else { + dsq->user.video.resx = dsq->user_backup.video.resx; + dsq->user.video.resy = dsq->user_backup.video.resy; + dsq->user.video.bits = dsq->user_backup.video.bits; + dsq->user.video.full = dsq->user_backup.video.full; + dsq->user.video.vsync = dsq->user_backup.video.vsync; + + dsq->user.apply(); + + dsq->resetGraphics(dsq->user.video.resx, dsq->user.video.resy, dsq->user.video.full); + } + } + + if (!keyConfigMenu) + dsq->user.save(); + + if (keyConfigMenu) + { + AquariaKeyConfig::waitingForInput = 0; + dsq->screenTransition->capture(); + toggleKeyConfigMenu(false); + toggleOptionsMenu(true, false, true); + dsq->screenTransition->transition(MENUPAGETRANSTIME); + } + else + { + if (optionsOnly) + { + hide(); + } + else + { + dsq->screenTransition->capture(); + toggleOptionsMenu(false); + dsq->screenTransition->transition(MENUPAGETRANSTIME); + } + } +} + +void InGameMenu::onOptionsCancel() +{ + if (!keyConfigMenu) + { + dsq->user = dsq->user_backup; + } + else + { + dsq->user.control.actionSet = dsq->user_bcontrol.control.actionSet; + } + + dsq->user.apply(); + + if (keyConfigMenu) + { + AquariaKeyConfig::waitingForInput = 0; + dsq->screenTransition->capture(); + toggleKeyConfigMenu(false); + toggleOptionsMenu(true, true, true); + dsq->screenTransition->transition(MENUPAGETRANSTIME); + } + else + { + if (optionsOnly) + { + hide(); + } + else + { + dsq->screenTransition->capture(); + toggleOptionsMenu(false); + dsq->screenTransition->transition(MENUPAGETRANSTIME); + } + } +} + +void InGameMenu::refreshFoodSlots(bool effects) +{ + for (int i = 0; i < foodSlots.size(); i++) + { + foodSlots[i]->refresh(effects); + } +} + +void InGameMenu::refreshTreasureSlots() +{ + for (int i = 0; i < treasureSlots.size(); i++) + { + treasureSlots[i]->refresh(); + } +} + +void InGameMenu::togglePetMenu(bool f) +{ + if (optionsMenu) + { + toggleOptionsMenu(false); + } + + if (foodMenu) + toggleFoodMenu(false); + if (treasureMenu) + toggleTreasureMenu(false); + + if (f && !petMenu) + { + currentMenuPage = MENUPAGE_PETS; + + toggleMainMenu(false); + + bool hasPet = false; + for (int i = 0; i < petSlots.size(); i++) + { + petSlots[i]->alpha = 1; + bool has = dsq->continuity.getFlag(petSlots[i]->petFlag); + if (has) + { + hasPet = true; + /* + for (int j = 0; j < petSlots.size(); j++) + { + if (j != i) + { + bool has = dsq->continuity.getFlag(petSlots[j]->petFlag); + if (has) + { + if (i == 0 && j == 1) + { + + } + } + } + } + */ + } + } + // act as if they're all active for now... + if (petSlots.size() == 4) + { + petSlots[0]->setDirMove(DIR_RIGHT, petSlots[1]); + petSlots[0]->setDirMove(DIR_UP, petSlots[2]); + petSlots[0]->setDirMove(DIR_LEFT, petSlots[3]); + petSlots[0]->setDirMove(DIR_DOWN, menu[0]); + + menu[0]->setDirMove(DIR_UP, petSlots[0]); + + petSlots[1]->setDirMove(DIR_LEFT, petSlots[3]); + petSlots[1]->setDirMove(DIR_UP, petSlots[2]); + petSlots[1]->setDirMove(DIR_DOWN, petSlots[0]); + + petSlots[1]->setDirMove(DIR_RIGHT, menu[5]); + menu[5]->setDirMove(DIR_LEFT, petSlots[1]); + menu[5]->setDirMove(DIR_UP, petSlots[1]); + + petSlots[2]->setDirMove(DIR_RIGHT, petSlots[1]); + petSlots[2]->setDirMove(DIR_DOWN, petSlots[0]); + petSlots[2]->setDirMove(DIR_LEFT, petSlots[3]); + + petSlots[3]->setDirMove(DIR_UP, petSlots[2]); + petSlots[3]->setDirMove(DIR_RIGHT, petSlots[1]); + petSlots[3]->setDirMove(DIR_DOWN, petSlots[0]); + } + + + for (int i = 0; i < petTips.size(); i++) + { + /* + if (hasPet && i == 0) + { + petTips[i]->alpha = 0; + } + else if (!hasPet && i == 1) + petTips[i]->alpha = 0; + else + petTips[i]->alpha = 1; + */ + petTips[i]->alpha = 1; + } + + liCrystal->alpha = 1; + + + menu[7]->setFocus(true); + + + doMenuSectionHighlight(2); + + } + else if (!f && petMenu) + { + for (int i = 0; i < petSlots.size(); i++) + { + petSlots[i]->alpha = 0; + } + + for (int i = 0; i < petTips.size(); i++) + { + petTips[i]->alpha = 0; + } + + liCrystal->alpha = 0; + + + menu[5]->setDirMove(DIR_LEFT, 0); + menu[5]->setDirMove(DIR_UP, 0); + menu[0]->setDirMove(DIR_UP, 0); + } + + petMenu = f; +} + +void InGameMenu::toggleTreasureMenu(bool f) +{ + //debugLog("toggle treasure menu!"); + + if (optionsMenu) + toggleOptionsMenu(false); + + if (foodMenu) + toggleFoodMenu(false); + if (petMenu) + togglePetMenu(false); + + if (f && !treasureMenu) + { + currentMenuPage = MENUPAGE_TREASURES; + + treasureMenu = true; + toggleMainMenu(false); + + refreshTreasureSlots(); + + for (int i = 0; i < treasureTips.size(); i++) + treasureTips[i]->alpha = 1; + + if (treasureSlots.size() > 8) + { + treasureSlots[0]->setDirMove(DIR_DOWN, menu[0]); + menu[0]->setDirMove(DIR_UP, treasureSlots[0]); + + treasureSlots[2]->setDirMove(DIR_RIGHT, menu[5]); + menu[5]->setDirMove(DIR_LEFT, treasureSlots[2]); + + treasureSlots[3]->setDirMove(DIR_RIGHT, menu[5]); + } + + menu[8]->setFocus(true); + + doMenuSectionHighlight(3); + + liCrystal->alpha = 1; + + circlePageNum->alpha = 1; + } + else if (!f && treasureMenu) + { + treasureMenu = false; + + for (int i = 0; i < treasureTips.size(); i++) + treasureTips[i]->alpha = 0; + + menu[0]->setDirMove(DIR_UP, 0); + menu[5]->setDirMove(DIR_LEFT, 0); + + liCrystal->alpha = 0; + + circlePageNum->alpha = 0; + } + + for (int i = 0; i < treasureSlots.size(); i++) + { + if (f) + treasureSlots[i]->alpha = 1; + else + treasureSlots[i]->alpha = 0; + } + + if (f) + { + nextTreasure->alpha = 1; + prevTreasure->alpha = 1; + use->alpha = 0; + + treasureLabel->alpha = 0; + treasureDescription->alpha = 0; + treasureCloseUp->alpha = 0; + } + else + { + nextTreasure->alpha = 0; + prevTreasure->alpha = 0; + use->alpha = 0; + + treasureLabel->alpha = 0; + treasureDescription->alpha = 0; + treasureCloseUp->alpha = 0; + } +} + +void InGameMenu::toggleRecipeList(bool on) +{ + recipeMenu.toggle(on, true); +} + +void InGameMenu::toggleFoodMenu(bool f) +{ + if (optionsMenu) + toggleOptionsMenu(false); + if (petMenu) + togglePetMenu(false); + if (treasureMenu) + toggleTreasureMenu(false); + + + for (int i = 0; i < foodHolders.size(); i++) + { + if (f) + foodHolders[i]->alpha = 1; + else + foodHolders[i]->alpha = 0; + } + + if (f) + { + if (game->avatar) + { + Path *p=0; + if (dsq->continuity.getFlag(FLAG_UPGRADE_WOK) > 0 + || ((p=game->getNearestPath(game->avatar->position, PATH_COOK)) + && p->isCoordinateInside(game->avatar->position))) + { + foodHolders[0]->alpha = 1; + } + else + { + foodHolders[0]->alpha = 0; + } + } + } + + if (f && !foodMenu) + { + currentMenuPage = MENUPAGE_FOOD; + + foodMenu = true; + + toggleMainMenu(false); + + refreshFoodSlots(false); + + cook->alpha = 1; + recipes->alpha = 1; + + prevFood->alpha = 1; + nextFood->alpha = 1; + foodLabel->alphaMod = 1; + foodDescription->alphaMod = 1; + + foodSort->alpha = 1; + + for (int i = 0; i < foodTips.size(); i++) + foodTips[i]->alpha = 1; + + if (foodSlots.size() >= 16) + { + foodSlots[2]->setDirMove(DIR_RIGHT, menu[5]); + foodSlots[3]->setDirMove(DIR_RIGHT, menu[5]); + menu[5]->setDirMove(DIR_LEFT, foodSlots[2]); + + treasureSlots[3]->setDirMove(DIR_RIGHT, menu[5]); + + recipes->setDirMove(DIR_UP, foodSlots[15]); + foodSlots[15]->setDirMove(DIR_DOWN, recipes); + foodSlots[14]->setDirMove(DIR_DOWN, recipes); + foodSlots[0]->setDirMove(DIR_DOWN, recipes); + + foodSlots[0]->setDirMove(DIR_LEFT, foodSlots[15]); + foodSlots[15]->setDirMove(DIR_RIGHT, foodSlots[0]); + + foodSlots[15]->setDirMove(DIR_LEFT, foodSlots[14]); + + recipes->setDirMove(DIR_RIGHT, menu[5]); + } + + menu[6]->setFocus(true); + + doMenuSectionHighlight(1); + + liCrystal->alpha = 1; + + circlePageNum->alpha = 1; + + previewRecipe->alpha = 0; + updatePreviewRecipe(); + } + else if (!f && foodMenu) + { + recipeMenu.toggle(false); + foodMenu = false; + + cook->alpha = 0; + recipes->alpha = 0; + prevFood->alpha = 0; + nextFood->alpha = 0; + foodLabel->alphaMod = 0; + foodLabel->alpha = 0; + foodDescription->alpha = 0; + foodSort->alpha = 0; + showRecipe->alpha = 0; + + liCrystal->alpha = 0; + + for (int i = 0; i < foodTips.size(); i++) + foodTips[i]->alpha = 0; + + menu[5]->setDirMove(DIR_LEFT, 0); + + circlePageNum->alpha = 0; + + previewRecipe->alpha = 0; + } + + for (int i = 0; i < foodSlots.size(); i++) + { + foodSlots[i]->toggle(f); + } +} + +void InGameMenu::doMenuSectionHighlight(int section) +{ + for (int i = 0; i < 4; i++) + ((AquariaMenuItem*)menu[(5+i)])->quad->alphaMod = 0.8; + ((AquariaMenuItem*)menu[(5+section)])->quad->alphaMod = 1.0; + menuIconGlow->position = menu[5+section]->position; +} + +void InGameMenu::toggleMainMenu(bool f) +{ + const float t = 0; + if (f) + { + currentMenuPage = MENUPAGE_SONGS; + for (int i = 0; i < songSlots.size(); i++) + { + songSlots[i]->alphaMod = 1; + } + songBubbles->alpha.interpolateTo(1,t); + energyIdol->alpha.interpolateTo(1,t); + liCrystal->alpha.interpolateTo(1, t); + for (int i = 0; i < songTips.size(); i++) + songTips[i]->alpha = 1; + menuBg2->alpha.interpolateTo(1, t); + + + int sm=-900; + SongSlot *ss=0; + for (int i = 0; i < songSlots.size(); i++) + { + if (dsq->continuity.hasSong(dsq->continuity.getSongTypeBySlot(i))) + { + Vector p = songSlots[i]->getWorldPosition(); + if (p.x > sm) + { + sm = p.x; + ss = songSlots[i]; + } + } + } + + if (ss) + { + ss->setDirMove(DIR_RIGHT, (AquariaMenuItem*)menu[5]); + } + ((AquariaMenuItem*)menu[5])->setDirMove(DIR_LEFT, ss); + + doMenuSectionHighlight(0); + } + else + { + ((AquariaMenuItem*)menu[5])->setDirMove(DIR_LEFT, 0); + + for (int i = 0; i < songSlots.size(); i++) + { + songSlots[i]->alphaMod = 0; + } + + for (int i = 0; i < songTips.size(); i++) + songTips[i]->alpha = 0; + + songBubbles->alpha.interpolateTo(0, t); + energyIdol->alpha.interpolateTo(0,t); + liCrystal->alpha.interpolateTo(0, t); + } +} + +void InGameMenu::toggleKeyConfigMenu(bool f) +{ + const float t = 0; + playingSongInMenu = -1; + + + if (f && !keyConfigMenu) + { + toggleOptionsMenu(false, false, true); + + for (int i = 0; i <= 1; i++) + menu[i]->alpha.interpolateTo(0, t); + for (int i = 4; i <= 8; i++) + menu[i]->alpha.interpolateTo(0, t); + + toggleMainMenu(false); + + menuBg2->alpha.interpolateTo(0, t); + + keyConfigMenu = true; + + group_keyConfig->setHidden(false); + group_keyConfig->alpha = 1; + + dsq->user_bcontrol = dsq->user; + + //group_keyConfig->children[group_keyConfig->children.size()-3] + + RenderObject::Children::reverse_iterator i = group_keyConfig->children.rbegin(); + AquariaKeyConfig *upright0 = (AquariaKeyConfig*)(*i); + i++; + AquariaKeyConfig *upright = (AquariaKeyConfig*)(*i); + i++; + AquariaKeyConfig *upleft = (AquariaKeyConfig*)(*i); + + opt_cancel->setDirMove(DIR_UP, upright); + upright->setDirMove(DIR_DOWN, opt_cancel); + upright0->setDirMove(DIR_DOWN, opt_cancel); + + opt_save->setDirMove(DIR_UP, upleft); + upleft->setDirMove(DIR_DOWN, opt_save); + + + opt_cancel->alpha = 1; + opt_save->alpha = 1; + + + opt_save->position = opt_save_original + Vector(0, 120); + opt_cancel->position = opt_cancel_original + Vector(0, 120); + + opt_cancel->setFocus(true); + + menuIconGlow->alpha = 0; + } + else if (!f) + { + keyConfigMenu = false; + + group_keyConfig->alpha = 0; + group_keyConfig->setHidden(true); + + opt_cancel->alpha = 0; + opt_save->alpha = 0; + + opt_save->position = opt_save_original; + opt_cancel->position = opt_cancel_original; + + menuIconGlow->alpha = 1; + } +} + +void InGameMenu::toggleOptionsMenu(bool f, bool skipBackup, bool isKeyConfig) +{ + const float t = 0; + playingSongInMenu = -1; + + if (f && !optionsMenu) + { + if (!isKeyConfig && !optionsOnly) + { + lastOptionsMenuPage = currentMenuPage; + } + + toggleFoodMenu(false); + optionsMenu = true; + voxslider->setValue(dsq->user.audio.voxvol); + musslider->setValue(dsq->user.audio.musvol); + sfxslider->setValue(dsq->user.audio.sfxvol); + + if (blurEffectsCheck) + blurEffectsCheck->setValue(dsq->user.video.blur); + + flipInputButtonsCheck->setValue(dsq->user.control.flipInputButtons); + toolTipsCheck->setValue(dsq->user.control.toolTipsOn); + autoAimCheck->setValue(dsq->user.control.autoAim); + targetingCheck->setValue(dsq->user.control.targeting); + + subtitlesCheck->setValue(dsq->user.audio.subtitles); + fullscreenCheck->setValue(dsq->isFullscreen()); + + if (ripplesCheck) + ripplesCheck->setValue(core->afterEffectManager!=0); + + if (micInputCheck) + micInputCheck->setValue(dsq->user.audio.micOn); + + if (resBox) + { + std::ostringstream os; + os << core->width << "x" << core->height; + if (!resBox->setSelectedItem(os.str())) + { + resBox->addItem(os.str()); + resBox->setSelectedItem(os.str()); + } + } + + opt_cancel->setDirMove(DIR_UP, targetingCheck); + targetingCheck->setDirMove(DIR_DOWN, opt_cancel); + + + opt_save->setDirMove(DIR_UP, voxslider); + voxslider->setDirMove(DIR_DOWN, opt_save); + + keyConfigButton->setDirMove(DIR_UP, targetingCheck); + + if (!skipBackup) + dsq->user_backup = dsq->user; + + + options->alpha.interpolateTo(1, t); + + for (int i = 0; i <= 1; i++) + menu[i]->alpha.interpolateTo(0, t); + for (int i = 4; i <= 9; i++) + menu[i]->alpha.interpolateTo(0, t); + + toggleMainMenu(false); + + keyConfigButton->alpha = 1; + + menuBg2->alpha.interpolateTo(0, t); + + opt_cancel->alpha = 1; + opt_save->alpha = 1; + opt_cancel->setFocus(true); + + lips->alpha = 0; + + liCrystal->alpha = 1; + + optionsMenu = true; + + menuIconGlow->alpha = 0; + } + else if (!f && optionsMenu) + { + lips->alpha = 0; + + keyConfigButton->alpha = 0; + + options->alpha.interpolateTo(0, t); + + opt_cancel->alpha = 0; + opt_save->alpha = 0; + + liCrystal->alpha = 0; + + optionsMenu = false; + + if (!optionsOnly) + { + for (int i = 0; i <= 1; i++) + menu[i]->alpha.interpolateTo(1, t); + for (int i = 4; i <= 9; i++) + { + menu[i]->alpha.interpolateTo(1, t); + } + + if (!isKeyConfig) + { + switch(lastOptionsMenuPage) + { + case MENUPAGE_FOOD: + toggleFoodMenu(true); + ((AquariaMenuItem*)menu[6])->setFocus(true); + break; + case MENUPAGE_TREASURES: + toggleTreasureMenu(true); + ((AquariaMenuItem*)menu[8])->setFocus(true); + break; + case MENUPAGE_PETS: + togglePetMenu(true); + ((AquariaMenuItem*)menu[7])->setFocus(true); + break; + case MENUPAGE_SONGS: + default: + toggleMainMenu(true); + ((AquariaMenuItem*)menu[5])->setFocus(true); + break; + } + } + + menuBg2->alpha.interpolateTo(1, t); + } + + menuIconGlow->alpha = 1; + } +} + +void InGameMenu::updateOptionsMenu(float dt) +{ + if (!optionsMenu) + return; + + dsq->user.audio.voxvol = voxslider->getValue(); + dsq->user.audio.sfxvol = sfxslider->getValue(); + dsq->user.audio.musvol = musslider->getValue(); + + if (micInputCheck) + dsq->user.audio.micOn = micInputCheck->getValue(); + + dsq->user.control.flipInputButtons = flipInputButtonsCheck->getValue(); + dsq->user.control.toolTipsOn = toolTipsCheck->getValue(); + dsq->user.control.autoAim = autoAimCheck->getValue(); + dsq->user.control.targeting = targetingCheck->getValue(); + + dsq->user.audio.subtitles = subtitlesCheck->getValue(); + dsq->user.video.full = fullscreenCheck->getValue(); + + if (ripplesCheck) + dsq->user.video.fbuffer = ripplesCheck->getValue(); + + if (blurEffectsCheck) + dsq->user.video.blur = blurEffectsCheck->getValue(); + + if (resBox) + { + std::string s = resBox->getSelectedItemString(); + if (!s.empty()) + { + int pos = s.find('x'); + std::istringstream is1(s.substr(0, pos)); + is1 >> dsq->user.video.resx; + std::istringstream is2(s.substr(pos+1, s.size()-(pos+1))); + is2 >> dsq->user.video.resy; + } + } + + optsfxdly += dt; + if (sfxslider->hadInput()) + { + dsq->sound->playSfx("denied"); + } + else if (voxslider->hadInput()) + { + if (!dsq->sound->isPlayingVoice()) + dsq->voice("naija_somethingfamiliar"); + } + else if (optsfxdly > 0.6f) + { + optsfxdly = 0; + if (sfxslider->isGrabbed()) + { + dsq->sound->playSfx("denied"); + dsq->loops.updateVolume(); + } + if (voxslider->isGrabbed()) + { + if (!dsq->sound->isPlayingVoice()) + { + dsq->voice("naija_somethingfamiliar"); + } + } + } + + dsq->user.apply(); +} + +void InGameMenu::update(float dt) +{ + if (enqueuedPreviewRecipe) + { + updatePreviewRecipe(); + enqueuedPreviewRecipe = 0; + } + + if (moveFoodSlotToFront) + { + moveFoodSlotToFront->moveToFront(); + moveFoodSlotToFront = 0; + } + + if (cookDelay > 0) + { + cookDelay -= dt; + if (cookDelay < 0) + cookDelay = 0; + } + + if (isInGameMenu()) + { + menuOpenTimer += dt; + if (dt > 10) + dt = 10; + + if (foodMenu) + { + if (dsq->continuity.hasIngredients()) + { + int pageNum = (currentFoodPage+1); + int numPages = ((dsq->continuity.ingredientCount()-1)/foodPageSize)+1; + + std::ostringstream os; + os << pageNum << "/" << numPages; + circlePageNum->setText(os.str()); + + if (pageNum > numPages && pageNum > 1) + { + onPrevFoodPage(); + } + } + else + { + circlePageNum->setText("1/1"); + } + } + if (treasureMenu) + { + std::ostringstream os; + os << (currentTreasurePage+1) << "/" << (numTreasures/treasurePageSize); + circlePageNum->setText(os.str()); + } + // HACK: move this later + updateOptionsMenu(dt); + if (playingSongInMenu != -1) + { + songMenuPlayDelay += dt; + + Song s = dsq->continuity.songBank[playingSongInMenu]; + + if (currentSongMenuNote < s.notes.size()) + { + if (songMenuPlayDelay >= 0.5f) + { + songMenuPlayDelay = 0; + + + if (currentSongMenuNote >= 0 && currentSongMenuNote < s.notes.size()) + { + sound->playSfx(game->getNoteName(s.notes[currentSongMenuNote], "Menu")); + + float a = (s.notes[currentSongMenuNote]*2*PI)/8.0f; + int sz = 110*menuBg->scale.x; + Vector notePos(sinf(a)*sz,cosf(a)*sz); + + float t = 0.5; + Quad *q = new Quad("particles/glow", Vector(400+237*menuBg->scale.x,300-52*menuBg->scale.x)+notePos); + q->setBlendType(RenderObject::BLEND_ADD); + q->scale = Vector(5,5); + q->alpha.ensureData(); + q->alpha.data->path.addPathNode(0, 0); + q->alpha.data->path.addPathNode(0.75, 0.5); + q->alpha.data->path.addPathNode(0.75, 0.5); + q->alpha.data->path.addPathNode(0, 1); + q->alpha.startPath(t); + q->followCamera = 1; + q->setLife(t); + q->setDecayRate(1); + + game->addRenderObject(q, LR_HUD); + + currentSongMenuNote++; + } + } + } + else + { + if (songMenuPlayDelay >= 1.0f) + { + playingSongInMenu = -1; + } + } + } + } +} + +void InGameMenu::onDebugSave() +{ + themenu->hide(); + game->clearControlHint(); + core->main(0.5); + dsq->game->togglePause(true); + dsq->doSaveSlotMenu(SSM_SAVE); + dsq->game->togglePause(false); +} diff --git a/Aquaria/InGameMenu.h b/Aquaria/InGameMenu.h new file mode 100644 index 0000000..b0116b1 --- /dev/null +++ b/Aquaria/InGameMenu.h @@ -0,0 +1,232 @@ +#ifndef IN_GAME_MENU_H +#define IN_GAME_MENU_H + +#include +#include + +#include "ActionMapper.h" + +class BitmapText; +class ToolTip; +class Quad; +class AquariaMenuItem; +class RenderObject; +class SongSlot; +class FoodSlot; +class TreasureSlot; +class IngredientData; +class AquariaKeyConfig; +class AquariaCheckBox; +class AquariaSlider; +class AquariaComboBox; +class RecipeMenuEntry; +class Recipe; + + +enum MenuPage +{ + MENUPAGE_NONE = -1, + MENUPAGE_SONGS = 0, + MENUPAGE_FOOD = 1, + MENUPAGE_TREASURES = 2, + MENUPAGE_PETS = 3 +}; + +struct RecipeMenu +{ + RecipeMenu(); + Quad *scroll; + Quad *scrollEnd; + BitmapText *header, *page, *description; + AquariaMenuItem *nextPage, *prevPage; + + + void toggle(bool on, bool watch=false); + void createPage(int p); + void slide(RenderObject *r, bool in, float t); + void destroyPage(); + void goNextPage(); + void goPrevPage(); + int getNumPages(); + int getNumKnown(); + + int currentPage; + + bool on; + + std::vector recipeMenuEntries; +}; + + +class InGameMenu : public ActionMapper +{ + // These are defined in the cpp file and are exclusively used in menu code + friend class FoodSlot; + friend class PetSlot; + friend class TreasureSlot; + friend class SongSlot; + friend class FoodHolder; + +public: + InGameMenu(); + ~InGameMenu(); + + void create(); + void update(float dt); + void updateOptions(float dt); + void hide(bool effects=true, bool cancel=false); + void show(bool force=false, bool optionsOnly=false, MenuPage menuPage = MENUPAGE_NONE); + bool isInGameMenu() const { return inGameMenu; } + bool isFoodMenuOpen() const { return foodMenu; } + MenuPage getCurrentMenuPage() const { return currentMenuPage; } + void reset(); + void onContinuityReset(); + + void bindInput(); + virtual void action(int actionID, int state, int source); + + void refreshFoodSlots(bool effects); + + RecipeMenu recipeMenu; + +private: + void updateOptionsMenu(float dt); + + void sortFood(); + void updatePreviewRecipe(); + void adjustFoodSlotCursor(); + void playSongInMenu(int songType, bool override=false); + + void refreshTreasureSlots(); + + Recipe *findRecipe(const std::vector &list); + void onCook(); + void onRecipes(); + void updateCookList(); + void onUseTreasure(); + void onUseTreasure(int flag); + + void onPrevFoodPage(); + void onNextFoodPage(); + + void onPrevTreasurePage(); + void onNextTreasurePage(); + void onLips(); + + void showInGameMenuExitCheck(); + void hideInGameMenuExitCheck(bool refocus); + + void setMenuDescriptionText(const std::string &text); + FoodSlot* getFoodSlotFromIndex(); + + BitmapText *songLabel, *foodLabel, *foodDescription, *treasureLabel; + ToolTip *treasureDescription; + Quad *treasureCloseUp; + + Quad *menuBg, *menuBg2; + + AquariaMenuItem *eYes, *eNo, *cook, *recipes, *nextFood, *prevFood, *nextTreasure, *prevTreasure, *use, *keyConfigButton; + AquariaMenuItem *opt_cancel, *opt_save, *foodSort; + + Quad *menu_blackout; + + std::vector songSlots; + std::vector foodSlots; + std::vector treasureSlots; + BitmapText* songDescription; + + int selectedTreasureFlag; + + bool optionsOnly; + + float cookDelay; + + MenuPage currentMenuPage; + int currentFoodPage, currentTreasurePage; + + int enqueuedPreviewRecipe; + + Quad *previewRecipe; + Quad *menuIconGlow; + Quad *showRecipe; + + bool isCooking; + float optsfxdly; + + void doMenuSectionHighlight(int sect); + + void onPrevRecipePage(); + void onNextRecipePage(); + void onDebugSave(); + + typedef std::vector CookList; + CookList cookList; + std::vector dropIngrNames; + + float songMenuPlayDelay; + int currentSongMenuNote; + int playingSongInMenu; + + void onOptionsMenu(); + bool optionsMenu, foodMenu, petMenu, treasureMenu, keyConfigMenu; + void toggleOptionsMenu(bool f, bool skipBackup=false, bool isKeyConfig=false); + void toggleFoodMenu(bool f); + void toggleMainMenu(bool f); + void togglePetMenu(bool f); + void toggleTreasureMenu(bool f); + void toggleRecipeList(bool on); + void toggleKeyConfigMenu(bool f); + + void enqueuePreviewRecipe(); + + void switchToSongMenu(); + void switchToFoodMenu(); + void switchToPetMenu(); + void switchToTreasureMenu(); + + void onKeyConfig(); + + void addKeyConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int y, int l1=0, int l2=0, int l3=0); + + AquariaKeyConfig *addAxesConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int y, int offx); + + void onOptionsSave(); + void onOptionsCancel(); + AquariaSlider *sfxslider, *musslider, *voxslider; + AquariaCheckBox *autoAimCheck, *targetingCheck, *toolTipsCheck, *flipInputButtonsCheck, *micInputCheck, *blurEffectsCheck; + AquariaCheckBox *subtitlesCheck, *fullscreenCheck, *ripplesCheck; + AquariaComboBox *resBox; + Quad *songBubbles, *energyIdol, *liCrystal; + + RenderObject *group_keyConfig; + + Quad *options; + + void onExitCheckNo(); + void onExitCheckYes(); + void onInGameMenuContinue(); + void onInGameMenuOptions(); + void onInGameMenuExit(); + + BitmapText *circlePageNum; + + std::vector foodTips, songTips, petTips, treasureTips; + + Quad *eAre; + int inGameMenuExitState; + + BitmapText *menuDescription; + + std::vector menu; + + bool inGameMenu; + float menuOpenTimer; + + FoodSlot *moveFoodSlotToFront; + AquariaMenuItem *lips; + + MenuPage lastMenuPage, lastOptionsMenuPage; +}; + + +#endif diff --git a/Aquaria/MiniMapRender.cpp b/Aquaria/MiniMapRender.cpp index 824ac86..ef4e3b3 100644 --- a/Aquaria/MiniMapRender.cpp +++ b/Aquaria/MiniMapRender.cpp @@ -412,7 +412,7 @@ void MiniMapRender::onUpdate(float dt) { doubleClickDelay = 0; if (!core->isStateJumpPending()) - dsq->game->action(ACTION_TOGGLEMENU, 1); + dsq->game->action(ACTION_TOGGLEMENU, 1, -1); btn = true; } break; diff --git a/Aquaria/ModSelector.h b/Aquaria/ModSelector.h index 3849cf7..abb5a97 100644 --- a/Aquaria/ModSelector.h +++ b/Aquaria/ModSelector.h @@ -164,6 +164,8 @@ public: AquariaMenuItem arrowUp, arrowDown; void setSubText(const std::string& s); + + virtual void action(int actionID, int state, int source) {} protected: virtual void onUpdate(float dt); diff --git a/Aquaria/Path.cpp b/Aquaria/Path.cpp index f6aa65f..6a2b895 100644 --- a/Aquaria/Path.cpp +++ b/Aquaria/Path.cpp @@ -640,12 +640,12 @@ void Path::update(float dt) } } -bool Path::action(int id, int state) +bool Path::action(int id, int state, int source) { if (hasScript()) { bool dontRemove = true; - if (!script->call("action", this, id, state, &dontRemove)) + if (!script->call("action", this, id, state, source, &dontRemove)) luaDebugMsg("action", script->getLastError()); return dontRemove; } diff --git a/Aquaria/Path.h b/Aquaria/Path.h index ed04ae3..0d9ff81 100644 --- a/Aquaria/Path.h +++ b/Aquaria/Path.h @@ -90,7 +90,7 @@ public: void addNode(int idx); void update(float dt); void setActive(bool v); - bool action(int id, int state); + bool action(int id, int state, int source); void setEmitter(const std::string& name); PathNode *getPathNode(int idx); diff --git a/Aquaria/RecipeMenuEntry.cpp b/Aquaria/RecipeMenuEntry.cpp index 85c3b0d..3ebf60f 100644 --- a/Aquaria/RecipeMenuEntry.cpp +++ b/Aquaria/RecipeMenuEntry.cpp @@ -18,7 +18,11 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "RecipeMenuEntry.h" #include "Game.h" +#include "InGameMenu.h" + namespace RecipeMenuNamespace { @@ -165,7 +169,9 @@ void RecipeMenuEntry::onUpdate(float dt) { RenderObject::onUpdate(dt); - if (!game->recipeMenu.description) + RecipeMenu& recipeMenu = game->getInGameMenu()->recipeMenu; + + if (!recipeMenu.description) return; if (alpha.x == 1) @@ -196,8 +202,8 @@ void RecipeMenuEntry::onUpdate(float dt) } } - game->recipeMenu.description->setText(ds.str()); - game->recipeMenu.description->offset = Vector(0, -10 * (game->recipeMenu.description->getNumLines()-1)); + recipeMenu.description->setText(ds.str()); + recipeMenu.description->offset = Vector(0, -10 * (recipeMenu.description->getNumLines()-1)); selected = 1; } @@ -208,15 +214,15 @@ void RecipeMenuEntry::onUpdate(float dt) int n=0; - for (int i = 0; i < game->recipeMenu.recipeMenuEntries.size(); i++) + for (int i = 0; i < recipeMenu.recipeMenuEntries.size(); i++) { - if (!game->recipeMenu.recipeMenuEntries[i]->selected) + if (!recipeMenu.recipeMenuEntries[i]->selected) n++; } - if (n == game->recipeMenu.recipeMenuEntries.size()) + if (n == recipeMenu.recipeMenuEntries.size()) { - game->recipeMenu.description->setText(""); + recipeMenu.description->setText(""); } } } diff --git a/Aquaria/RecipeMenuEntry.h b/Aquaria/RecipeMenuEntry.h new file mode 100644 index 0000000..0c5cc4f --- /dev/null +++ b/Aquaria/RecipeMenuEntry.h @@ -0,0 +1,28 @@ +#ifndef RECIPEMENUENTRY_H +#define RECIPEMENUENTRY_H + +#include "RenderObject.h" + +class Recipe; +class Quad; +class BitmapText; +class IngredientData; + +class RecipeMenuEntry : public RenderObject +{ +public: + RecipeMenuEntry(Recipe *recipe); +protected: + void onUpdate(float dt); + Quad *result, *ing[3]; + Quad *glow; + BitmapText *description; + IngredientData *data; + + Recipe *recipe; + + int selected; +}; + + +#endif diff --git a/Aquaria/SceneEditor.cpp b/Aquaria/SceneEditor.cpp index 7f31025..ef8c310 100644 --- a/Aquaria/SceneEditor.cpp +++ b/Aquaria/SceneEditor.cpp @@ -91,57 +91,6 @@ std::string getMapTemplateFilename() return ""; } -void WarpAreaRender::onRender() -{ - for (int i = 0; i < dsq->game->warpAreas.size(); i++) - { - WarpArea *a = &dsq->game->warpAreas[i]; - glTranslatef(a->position.x, a->position.y,0); - - if (a->warpAreaType == "Brown") - glColor4f(0.5, 0.25, 0, alpha.getValue()); - else - { - switch (a->warpAreaType[0]) - { - case 'B': - glColor4f(0,0,1,alpha.getValue()); - break; - case 'R': - glColor4f(1,0,0,alpha.getValue()); - break; - case 'G': - glColor4f(0, 1, 0,alpha.getValue()); - break; - case 'Y': - glColor4f(1,1,0,alpha.getValue()); - break; - case 'P': - glColor4f(1,0,1,alpha.getValue()); - break; - case 'O': - glColor4f(1,0.5,0,alpha.getValue()); - break; - } - } - - if (a->radius) - drawCircle(a->radius); - else - { - glBegin(GL_QUADS); - { - glVertex2f(-a->w,-a->h); - glVertex2f(-a->w,a->h); - glVertex2f(a->w,a->h); - glVertex2f(a->w,-a->h); - } - glEnd(); - } - glTranslatef(-a->position.x, -a->position.y,0); - } -} - SceneEditor::SceneEditor() : ActionMapper(), on(false) { autoSaveFile = 0; @@ -169,8 +118,6 @@ void SceneEditor::changeDepth() { if (editingElement) { - - editingElement->followCamera = 0.9; editingElement->cull = false; } @@ -527,7 +474,6 @@ void SceneEditor::init() editType = ET_ELEMENTS; state = ES_SELECTING; - drawingWarpArea = 'N'; btnMenu = new DebugButton(200, &menuReceiver, 700); btnMenu->position = Vector(20, 20); @@ -539,7 +485,6 @@ void SceneEditor::init() selectedEntityType = 0; zoom = Vector(0.2,0.2); - drawingBox = false; bgLayer = 5; text = new DebugFont(); text->setFontSize(6); @@ -550,26 +495,14 @@ void SceneEditor::init() dsq->game->addRenderObject(text, LR_HUD); text->alpha = 0; selectedVariation = -1; - - boxPromo = new Quad; - boxPromo->color = 0; - boxPromo->alpha =0; - boxPromo->cull = false; - dsq->game->addRenderObject(boxPromo, LR_HUD); on = false; - - addAction(MakeFunctionEvent(SceneEditor, loadScene), KEY_F1, 0); addAction(MakeFunctionEvent(SceneEditor, saveScene), KEY_F2, 0); - - addAction(MakeFunctionEvent(SceneEditor, moveToBack), KEY_Z, 0); addAction(MakeFunctionEvent(SceneEditor, moveToFront), KEY_X, 0); - addAction(MakeFunctionEvent(SceneEditor, toggleWarpAreaRender), KEY_F4, 0); - addAction(MakeFunctionEvent(SceneEditor, editModeElements), KEY_F5, 0); addAction(MakeFunctionEvent(SceneEditor, editModeEntities), KEY_F6, 0); addAction(MakeFunctionEvent(SceneEditor, editModePaths), KEY_F7, 0); @@ -689,11 +622,6 @@ void SceneEditor::init() placer->setTexture("missingimage"); } - warpAreaRender = new WarpAreaRender; - warpAreaRender->alpha = 0; - warpAreaRender->toggleCull(false); - dsq->game->addRenderObject(warpAreaRender, LR_HUD); - updateText(); doPrevElement(); @@ -856,16 +784,6 @@ void SceneEditor::reversePath() } } -void SceneEditor::toggleWarpAreaRender() -{ - if (warpAreaRender->alpha.x == 0) - warpAreaRender->alpha.x = 0.5; - else if (warpAreaRender->alpha.x >= 0.5f) - warpAreaRender->alpha.x = 0; - -} - - void SceneEditor::setGridPattern(int gi) { if (selectedElements.size()) @@ -1903,46 +1821,6 @@ void SceneEditor::generateLevel() dsq->game->reconstructGrid(true); - // create warp areas - dsq->game->warpAreas.clear(); - for (i = 0; i < MAX; i++) - { - if (firstColorX[i] != -1) - { - WarpArea warpArea; - int w = lastColorX[i] - firstColorX[i]; - int h = lastColorY[i] - firstColorY[i]; - - warpArea.w = w*TILE_SIZE; - warpArea.h = h*TILE_SIZE; - warpArea.position = Vector(firstColorX[i]*TILE_SIZE + warpArea.w/2, firstColorY[i]*TILE_SIZE + warpArea.h/2); - warpArea.w += TILE_SIZE*4; - warpArea.h += TILE_SIZE*4; - - switch (i) - { - case RED: warpArea.warpAreaType = "Red"; break; - case BLUE: warpArea.warpAreaType = "Blue"; break; - case GREEN: warpArea.warpAreaType = "Green"; break; - case YELLOW: warpArea.warpAreaType = "Yellow"; break; - case PURPLE: warpArea.warpAreaType = "Purple"; break; - case ORANGE: warpArea.warpAreaType = "Orange"; break; - case BROWN: warpArea.warpAreaType = "Brown"; break; - } - - dsq->game->setWarpAreaSceneName(warpArea); - - warpArea.generated = true; - - std::ostringstream os; - os << "WarpArea (" << warpArea.w << ", " << warpArea.h << ") - pos(" << warpArea.position.x << ", " << - warpArea.position.y << ")"; - debugLog(os.str()); - - dsq->game->warpAreas.push_back(warpArea); - } - } - maxX--; maxY--; this->skinMinX = 4; @@ -1969,7 +1847,7 @@ void SceneEditor::removeEntity() void SceneEditor::placeAvatar() { dsq->game->avatar->position = dsq->getGameCursorPosition(); - dsq->game->action(ACTION_PLACE_AVATAR, 0); + dsq->game->action(ACTION_PLACE_AVATAR, 0, -1); } void SceneEditor::scaleElementUp() @@ -2076,7 +1954,7 @@ void SceneEditor::updateMultiSelect() } } -void SceneEditor::action(int id, int state) +void SceneEditor::action(int id, int state, int source) { if (core->getCtrlState() && editingElement) { @@ -2625,7 +2503,7 @@ void SceneEditor::placeElement() { if (editType == ET_ELEMENTS) { - if (!core->getShiftState() && !core->getKeyState(KEY_LALT) && !drawingBox) + if (!core->getShiftState() && !core->getKeyState(KEY_LALT)) { dsq->game->createElement(dsq->game->elementTemplates[curElement].idx, placer->position, bgLayer, placer); updateText(); @@ -2745,7 +2623,6 @@ void SceneEditor::toggle(bool on) btnMenu->alpha = 1; dsq->getRenderObjectLayer(LR_BLACKGROUND)->update = true; - warpAreaRender->alpha = 0.5; dsq->game->togglePause(on); if (dsq->game->avatar) dsq->game->avatar->disableInput(); @@ -2786,7 +2663,6 @@ void SceneEditor::toggle(bool on) dsq->getRenderObjectLayer(LR_BLACKGROUND)->update = false; - warpAreaRender->alpha = 0; dsq->game->togglePause(on); if (dsq->game->avatar) dsq->game->avatar->enableInput(); @@ -2867,70 +2743,6 @@ void SceneEditor::updateText() text->setText(os.str()); } -void SceneEditor::startDrawingWarpArea(char c) -{ - if (drawingWarpArea == 'N') - { - boxPos = dsq->getGameCursorPosition(); - boxPromo->alpha = 1; - switch(c) - { - case 'Y': boxPromo->color = Vector(1,1,0); break; - case 'U': boxPromo->color = Vector(1,0,0); break; - case 'I': boxPromo->color = Vector(0,1,0); break; - case 'O': boxPromo->color = Vector(0,0,1); break; - case 'P': boxPromo->color = Vector(1,0,1); break; - } - drawingWarpArea = c; - } - if (drawingWarpArea == c) - { - Vector diff = dsq->getGameCursorPosition() - boxPos; - boxPromo->setWidthHeight(diff.x, diff.y); - boxPromo->position = boxPos + diff/2; - } -} - -void SceneEditor::updateDrawingWarpArea(char c, int k) -{ - if (core->getKeyState(k)) - { - startDrawingWarpArea(c); - } - else - { - endDrawingWarpArea(c); - } -} - -void SceneEditor::endDrawingWarpArea(char c) -{ - if (drawingWarpArea == c) - { - drawingWarpArea = 'N'; - boxPromo->alpha = 0; - if (boxPromo->getWidth() > TILE_SIZE && boxPromo->getHeight() > TILE_SIZE) - { - WarpArea a; - a.position = boxPromo->position; - a.w = boxPromo->getWidth()/2; - a.h = boxPromo->getHeight()/2; - switch (c) - { - case 'Y': a.warpAreaType = "Yellow"; break; - case 'U': a.warpAreaType = "Red"; break; - case 'I': a.warpAreaType = "Green"; break; - case 'O': a.warpAreaType = "Blue"; break; - case 'P': a.warpAreaType = "Purple"; break; - } - - a.sceneName = dsq->getUserInputString("Enter map to warp to"); - a.spawnOffset = dsq->getUserInputDirection("Enter warp direction"); - dsq->game->warpAreas.push_back(a); - } - } -} - Vector SceneEditor::getSelectedElementsCenter() { Vector c; diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index bec62c5..9305abb 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -39,6 +39,7 @@ extern "C" #include "PathFinding.h" #include #include "Gradient.h" +#include "InGameMenu.h" #include "../BBGE/MathFunctions.h" @@ -2019,12 +2020,13 @@ luaFunc(sendAction) AquariaActions ac = (AquariaActions)lua_tointeger(L, 1); int state = lua_tointeger(L, 2); int mask = lua_tointeger(L, 3); + int source = lua_tointeger(L, 4); if(!mask) mask = -1; if(mask & 1) - dsq->game->action(ac, state); + dsq->game->action(ac, state, source); if((mask & 2) && dsq->game->avatar) - dsq->game->avatar->action(ac, state); + dsq->game->avatar->action(ac, state, source); luaReturnNil(); } @@ -3713,7 +3715,7 @@ luaFunc(unlearnSong) luaFunc(showInGameMenu) { - dsq->game->showInGameMenu(getBool(L, 1), getBool(L, 2), (MenuPage)lua_tointeger(L, 3)); + dsq->game->getInGameMenu()->show(getBool(L, 1), getBool(L, 2), (MenuPage)lua_tointeger(L, 3)); luaReturnNil(); } @@ -3721,7 +3723,7 @@ luaFunc(hideInGameMenu) { bool skipEffect = getBool(L, 1); bool cancel = getBool(L, 2); - dsq->game->hideInGameMenu(!skipEffect, cancel); + dsq->game->getInGameMenu()->hide(!skipEffect, cancel); luaReturnNil(); } @@ -6430,15 +6432,6 @@ luaFunc(entity_setCurrentTarget) luaReturnNil(); } -luaFunc(setMiniMapHint) -{ - std::istringstream is(getString(L, 1)); - is >> dsq->game->miniMapHint.scene >> dsq->game->miniMapHint.warpAreaType; - dsq->game->updateMiniMapHintPosition(); - - luaReturnNil(); -} - luaFunc(entityFollowEntity) { Entity *e = dsq->getEntityByName(getString(L, 1)); @@ -9059,10 +9052,9 @@ luaFunc(inv_remove) if(data && data->amount > 0) { data->amount--; - dsq->game->dropIngrNames.push_back(data->name); dsq->continuity.removeEmptyIngredients(); if(dsq->game->isInGameMenu()) - dsq->game->refreshFoodSlots(true); + dsq->game->getInGameMenu()->refreshFoodSlots(true); } luaReturnNil(); } @@ -9999,7 +9991,6 @@ static const struct { luaRegister(entityFollowEntity), - luaRegister(setMiniMapHint), luaRegister(bedEffects), luaRegister(warpNaijaToEntity), @@ -11822,6 +11813,20 @@ bool Script::call(const char *name, void *param1, float param2, float param3, bo return true; } +bool Script::call(const char *name, void *param1, int param2, int param3, int param4, bool *ret1) +{ + lookupFunc(name); + luaPushPointer(L, param1); + lua_pushinteger(L, param2); + lua_pushinteger(L, param3); + lua_pushinteger(L, param4); + if (!doCall(4, 1)) + return false; + *ret1 = lua_toboolean(L, -1); + lua_pop(L, 1); + return true; +} + bool Script::call(const char *name, void *param1, const char *param2, float param3) { lookupFunc(name); diff --git a/Aquaria/ScriptInterface.h b/Aquaria/ScriptInterface.h index 65de7a1..4230ea9 100644 --- a/Aquaria/ScriptInterface.h +++ b/Aquaria/ScriptInterface.h @@ -49,6 +49,8 @@ public: bool call(const char *name, void *param1, float param2, float param3); // boolean = function(pointer, number, number) bool call(const char *name, void *param1, float param2, float param3, bool *ret1); + // boolean = function(pointer, int, int, int) + bool call(const char *name, void *param1, int param2, int param3, int param4, bool *ret1); // function(pointer, string, number) bool call(const char *name, void *param1, const char *param2, float param3); // function(pointer, string, pointer) diff --git a/Aquaria/States.h b/Aquaria/States.h index 144c7b9..d16d8f6 100644 --- a/Aquaria/States.h +++ b/Aquaria/States.h @@ -225,7 +225,7 @@ public: std::vector keyframeWidgets; - void action(int id, int state); + void action(int id, int state, int source); void rebuildKeyframeWidgets(); diff --git a/Aquaria/ToolTip.cpp b/Aquaria/ToolTip.cpp index fe90bac..2ebb0fc 100644 --- a/Aquaria/ToolTip.cpp +++ b/Aquaria/ToolTip.cpp @@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "ToolTip.h" #include "DSQ.h" #include "Game.h" +#include "InGameMenu.h" bool ToolTip::toolTipsOn = true; @@ -130,7 +131,7 @@ void ToolTip::onUpdate(float dt) void ToolTip::render() { - if (!dsq->game->recipeMenu.on && toolTipsOn) + if (!game->getInGameMenu()->recipeMenu.on && toolTipsOn) { RenderObject::render(); } diff --git a/Aquaria/UserSettings.cpp b/Aquaria/UserSettings.cpp index 8f56ba8..dbb53ea 100644 --- a/Aquaria/UserSettings.cpp +++ b/Aquaria/UserSettings.cpp @@ -182,12 +182,6 @@ void UserSettings::save() } xml_control->InsertEndChild(xml_targeting); - XMLElement *xml_joyCursorSpeed = doc.NewElement("JoyCursorSpeed"); - { - xml_joyCursorSpeed->SetAttribute("v", double(control.joyCursorSpeed)); - } - xml_control->InsertEndChild(xml_joyCursorSpeed); - XMLElement *xml_joyAxes = doc.NewElement("JoyAxes"); { xml_joyAxes->SetAttribute("s1ax", control.s1ax); @@ -455,10 +449,6 @@ void UserSettings::load(bool doApply, const std::string &overrideFile) readInt(xml_control, "Targeting", "on", &control.targeting); - XMLElement *xml_joyCursorSpeed = xml_control->FirstChildElement("JoyCursorSpeed"); - if (xml_joyCursorSpeed) - xml_joyCursorSpeed->QueryFloatAttribute("v", &control.joyCursorSpeed); - XMLElement *xml_joyAxes = xml_control->FirstChildElement("JoyAxes"); if (xml_joyAxes) { diff --git a/Aquaria/UserSettings.h b/Aquaria/UserSettings.h index cdd19f4..0750bd4 100644 --- a/Aquaria/UserSettings.h +++ b/Aquaria/UserSettings.h @@ -133,7 +133,6 @@ public: toolTipsOn = 1; autoAim = 1; targeting = 1; - joyCursorSpeed = 4.0; flipInputButtons = 0; s1ax = 0; s1ay = 0; @@ -146,7 +145,6 @@ public: int joystickEnabled; int autoAim; int targeting; - float joyCursorSpeed; int flipInputButtons; ActionSet actionSet; int s1ax, s1ay, s2ax, s2ay; diff --git a/Aquaria/WorldMapRender.cpp b/Aquaria/WorldMapRender.cpp index 2c1a9f1..052860a 100644 --- a/Aquaria/WorldMapRender.cpp +++ b/Aquaria/WorldMapRender.cpp @@ -1481,7 +1481,7 @@ void WorldMapRender::updateEditor() areaLabel->setText(os.str()); } -void WorldMapRender::action (int id, int state) +void WorldMapRender::action (int id, int state, int source) { if (isOn()) { diff --git a/BBGE/ActionInput.cpp b/BBGE/ActionInput.cpp index 85c3ced..ae68bad 100644 --- a/BBGE/ActionInput.cpp +++ b/BBGE/ActionInput.cpp @@ -18,9 +18,65 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + #include "ActionInput.h" -// crap -#include "Core.h" +#include "ActionMapper.h" + +#ifndef BBGE_BUILD_SDL2 +#error Needs fixes for SDL 1.2, doesnt support scancodes +#endif + + +std::string getInputCodeToString(int k) +{ + if(k < SDL_NUM_SCANCODES) + { + const char *name = SDL_GetScancodeName((SDL_Scancode)k); + if(name) + return name; + + std::stringstream os; + os << "K:" << k; + return os.str(); + } + + if(k >= JOY_BUTTON_0 && k < JOY_BUTTON_END) + { + std::stringstream os; + os << "JB:" << (k - JOY_BUTTON_0); + return os.str(); + } + + switch(k) + { + case MOUSE_BUTTON_LEFT: + return "LMB"; + case MOUSE_BUTTON_RIGHT: + return "RMB"; + case MOUSE_BUTTON_MIDDLE: + return "MMB"; + } + + return std::string(); +} + +int getStringToInputCode(const std::string& s) +{ + if(s == "LMB") + return MOUSE_BUTTON_LEFT; + if(s == "RMB") + return MOUSE_BUTTON_RIGHT; + if(s == "MMB") + return MOUSE_BUTTON_MIDDLE; + if(!strncmp(s.c_str(), "K:", 2)) + return SDL_GetScancodeFromName(s.c_str() + 2); + if(!strncmp(s.c_str(), "JB:", 3)) + return JOY_BUTTON_0 + atoi(s.c_str() + 3); + + return -1; // FIXME: is this correct? +} + + ActionInput::ActionInput() { diff --git a/BBGE/ActionInput.h b/BBGE/ActionInput.h index a679204..034d57d 100644 --- a/BBGE/ActionInput.h +++ b/BBGE/ActionInput.h @@ -22,13 +22,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define ACTIONINPUT_H #include -#include -#include + #define INP_MSESIZE 1 #define INP_KEYSIZE 2 #define INP_JOYSIZE 1 +std::string getInputCodeToString(int k); +int getStringToInputCode(const std::string& s); + class ActionInput { public: @@ -44,8 +46,6 @@ public: void fromString(const std::string &read); }; -typedef std::vector ActionInputSet; - enum InputSetType { INPUTSET_NONE = 0, diff --git a/BBGE/ActionMapper.cpp b/BBGE/ActionMapper.cpp index 33a9680..8ad6188 100644 --- a/BBGE/ActionMapper.cpp +++ b/BBGE/ActionMapper.cpp @@ -60,11 +60,7 @@ void ActionMapper::addAction (int actionID, int k) { ActionData *ad = getActionDataByID(actionID); - if (ad) - { - - } - else + if (!ad) { ActionData data; data.id = actionID; @@ -211,12 +207,13 @@ bool ActionMapper::getKeyState(int k) { keyState = (core->mouse.buttons.middle == DOWN); } - else if (k >= JOY1_BUTTON_0 && k < JOY1_BUTTON_END) + else if (k >= JOY_BUTTON_0 && k < JOY_BUTTON_END) { - int v = k - JOY1_BUTTON_0; + int v = k - JOY_BUTTON_0; - if (core->joystickEnabled) - keyState = core->joystick.getButton(v); + for(size_t i = 0; i < core->joysticks.size(); ++i) + if( ((keyState = core->joysticks[i]->getButton(v))) ) + break; } return keyState; @@ -257,7 +254,7 @@ void ActionMapper::onUpdate (float dt) } else { - action(ad->id, keyState); + action(ad->id, keyState, -1); // FG: FIXME } if (core->loopDone) goto out; } diff --git a/BBGE/ActionMapper.h b/BBGE/ActionMapper.h index 2619366..9ea2cf7 100644 --- a/BBGE/ActionMapper.h +++ b/BBGE/ActionMapper.h @@ -40,7 +40,19 @@ struct ActionData ButtonList buttonList; }; -#define ACTION_EVENT = -1 +enum ActionButtonType +{ + // must start at > 512 (SDL scancodes end there) + MOUSE_BUTTON_LEFT = 999, + MOUSE_BUTTON_RIGHT = 1000, + MOUSE_BUTTON_MIDDLE = 1001, + + JOY_BUTTON_0 = 2000, + JOY_BUTTON_END = JOY_BUTTON_0 + MAX_JOYSTICK_BTN, // one past end + + JOY_AXIS_0 = 3000, + JOY_AXIS_END = JOY_AXIS_0 + MAX_JOYSTICK_AXIS, +}; class ActionMapper { @@ -57,7 +69,7 @@ public: void removeAllActions(); bool isActing(int actionID); - virtual void action(int actionID, int state){} + virtual void action(int actionID, int state, int source) = 0; void clearActions(); @@ -74,17 +86,6 @@ public: bool cleared; - - - enum { - MOUSE_BUTTON_LEFT = 999, - MOUSE_BUTTON_RIGHT = 1000, - MOUSE_BUTTON_MIDDLE = 1001, - - JOY1_BUTTON_0 = 2000, - JOY1_BUTTON_END = JOY1_BUTTON_0 + MAX_JOYSTICK_BTN, // one past end - }; - virtual void enableInput(); virtual void disableInput(); diff --git a/BBGE/ActionSet.cpp b/BBGE/ActionSet.cpp index 53a0593..8a70e58 100644 --- a/BBGE/ActionSet.cpp +++ b/BBGE/ActionSet.cpp @@ -104,6 +104,7 @@ ActionInput *ActionSet::addActionInput(const std::string &name) return a; } +/* std::string ActionSet::insertInputIntoString(const std::string &string) { std::string str = string; @@ -152,4 +153,5 @@ std::string ActionSet::insertInputIntoString(const std::string &string) std::string part2 = getInputCodeToUserString(inputCode); return part1 + part2 + part3; } +*/ diff --git a/BBGE/ActionSet.h b/BBGE/ActionSet.h index 6f6b98f..b64989c 100644 --- a/BBGE/ActionSet.h +++ b/BBGE/ActionSet.h @@ -27,6 +27,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "ActionInput.h" +typedef std::vector ActionInputSet; + class ActionMapper; class Event; @@ -45,7 +47,7 @@ public: ActionInputSet inputSet; - std::string insertInputIntoString(const std::string &string); + //std::string insertInputIntoString(const std::string &string); }; #endif diff --git a/BBGE/Core.cpp b/BBGE/Core.cpp index 32ffd0f..7137b5f 100644 --- a/BBGE/Core.cpp +++ b/BBGE/Core.cpp @@ -664,11 +664,7 @@ void Core::init() loopDone = false; - initInputCodeMap(); - initLocalization(); - - } void Core::initRenderObjectLayers(int num) @@ -3324,9 +3320,28 @@ void Core::initLocalization() void Core::onJoystickAdded(int deviceID) { - + debugLog("Add new joystick"); + Joystick *j = new Joystick; + j->init(deviceID); + for(size_t i = 0; i < joysticks.size(); ++i) + if(!joysticks[i]) + { + joysticks[i] = j; + goto done; + } + joysticks.push_back(j); +done: + ; // TODO: fixup ActionMapper? } void Core::onJoystickRemoved(int instanceID) { + for(size_t i = 0; i < joysticks.size(); ++i) + if(joysticks[i]->getInstanceID() == instanceID) + { + joysticks[i]->shutdown(); + delete joysticks[i]; + joysticks[i] = NULL; + } + // TODO: fixup ActionMapper? } diff --git a/BBGE/Core.h b/BBGE/Core.h index 11bb182..c2f798b 100644 --- a/BBGE/Core.h +++ b/BBGE/Core.h @@ -49,12 +49,6 @@ class ParticleEffect; class ParticleManager; -void initInputCodeMap(); -void clearInputCodeMap(); -std::string getInputCodeToString(int key); -std::string getInputCodeToUserString(int key); -int getStringToInputCode(const std::string &string); - struct ScreenMode { ScreenMode() { idx = x = y = hz = 0; } @@ -72,12 +66,6 @@ struct CoreSettings bool prebufferSounds; }; -enum CoreFlags -{ - CF_CLEARBUFFERS = 0x00000001, - CF_SORTENABLED = 0x00000010 -}; - enum CoreLayers { LR_NONE = -1 @@ -413,7 +401,7 @@ public: void setReentryInputGrab(int on); - void action(int id, int state){} + virtual void action(int id, int state, int source){} bool exists(const std::string &file); @@ -554,8 +542,6 @@ public: bool debugLogTextures; - - Joystick joystick; void setClearColor(const Vector &c); Vector getClearColor(); int flipMouseButtons; @@ -694,14 +680,17 @@ protected: CountedPtr texError; - - int tgaSaveSeries(char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData); virtual void onUpdate(float dt); virtual void onRender(){} void setupFileAccess(); std::string _extraDataDir; + +public: + std::vector joysticks; + + Joystick joystick; // TEMP: TO GET IT TO COMPILE }; extern Core *core; diff --git a/BBGE/Event.cpp b/BBGE/Event.cpp index 556e37a..05ae570 100644 --- a/BBGE/Event.cpp +++ b/BBGE/Event.cpp @@ -64,7 +64,7 @@ void EventPtr::call() } if (actionMapperCallback) { - actionMapperCallback->action(actionValue, stateToCall); + actionMapperCallback->action(actionValue, stateToCall, -1); } } diff --git a/BBGE/Joystick.cpp b/BBGE/Joystick.cpp index 876e943..c131e88 100644 --- a/BBGE/Joystick.cpp +++ b/BBGE/Joystick.cpp @@ -19,6 +19,11 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifndef BBGE_BUILD_SDL2 +#error test this +#endif + +#include "Joystick.h" #include "Core.h" @@ -30,7 +35,6 @@ Joystick::Joystick() sdl_haptic = NULL; # endif sdl_joy = NULL; - inited = false; buttonBitmask = 0; deadZone1 = 0.3; deadZone2 = 0.3; @@ -82,13 +86,16 @@ void Joystick::init(int stick) if (sdl_joy) { - inited = true; #ifdef BBGE_BUILD_SDL2 - debugLog(std::string("Initialized Joystick [") + std::string(SDL_JoystickName(sdl_joy)) + std::string("]")); - if (sdl_controller) debugLog(std::string("Joystick is a Game Controller")); - if (sdl_haptic) debugLog(std::string("Joystick has force feedback support")); + debugLog(std::string("Initialized Joystick [") + SDL_JoystickName(sdl_joy) + "]"); + if (sdl_controller) + debugLog("Joystick is a Game Controller"); + if (sdl_haptic) + debugLog("Joystick has force feedback support"); + instanceID = SDL_JoystickInstanceID(sdl_joy); #else - debugLog(std::string("Initialized Joystick [") + std::string(SDL_JoystickName(stick)) + std::string("]")); + debugLog(std::string("Initialized Joystick [") + SDL_JoystickName(stick)) + std::string("]")); + instanceID = SDL_JoystickIndex(sdl_joy); #endif } else @@ -128,7 +135,7 @@ void Joystick::shutdown() void Joystick::rumble(float leftMotor, float rightMotor, float time) { - if (core->joystickEnabled && inited) + if (core->joystickEnabled) { #ifdef BBGE_BUILD_SDL2 if (sdl_haptic) @@ -149,7 +156,7 @@ void Joystick::rumble(float leftMotor, float rightMotor, float time) } } -void Joystick::callibrate(Vector &calvec, float deadZone) +void Joystick::calibrate(Vector &calvec, float deadZone) { if (calvec.isLength2DIn(deadZone)) @@ -181,25 +188,13 @@ void Joystick::callibrate(Vector &calvec, float deadZone) void Joystick::update(float dt) { - if (core->joystickEnabled && inited && sdl_joy && stickIndex != -1) + if (core->joystickEnabled && sdl_joy && stickIndex != -1) { #ifdef BBGE_BUILD_SDL2 if (!SDL_JoystickGetAttached(sdl_joy)) { debugLog("Lost Joystick"); - if (sdl_haptic) - { - SDL_HapticClose(sdl_haptic); - sdl_haptic = NULL; - } - if (!sdl_controller) - SDL_JoystickClose(sdl_joy); - else - { - SDL_GameControllerClose(sdl_controller); - sdl_controller = NULL; - } - sdl_joy = NULL; + shutdown(); return; } @@ -248,9 +243,9 @@ void Joystick::update(float dt) - callibrate(position, deadZone1); + calibrate(position, deadZone1); - callibrate(rightStick, deadZone2); + calibrate(rightStick, deadZone2); buttonBitmask = 0; @@ -279,7 +274,7 @@ void Joystick::update(float dt) } } -bool Joystick::anyButton() +bool Joystick::anyButton() const { return !!buttonBitmask;; } diff --git a/BBGE/Joystick.h b/BBGE/Joystick.h index c9ed867..0efb6f5 100644 --- a/BBGE/Joystick.h +++ b/BBGE/Joystick.h @@ -3,9 +3,15 @@ #include +#ifdef BBGE_BUILD_SDL2 +#include +#include +#endif + #include "Vector.h" #define MAX_JOYSTICK_BTN 32 +#define MAX_JOYSTICK_AXIS 32 class Joystick { @@ -13,25 +19,27 @@ public: Joystick(); void init(int stick=0); void shutdown(); - //Ranges from 0 to 65535 (full speed). + //Ranges from 0 to 1 (full speed). void rumble(float leftMotor, float rightMotor, float time); void update(float dt); - Vector position, lastPosition; + Vector position; float deadZone1, deadZone2; float clearRumbleTime; - void callibrate(Vector &vec, float dead); - bool anyButton(); - bool getButton(unsigned id) const { return buttonBitmask & (1u << id); } + void calibrate(Vector &vec, float dead); + bool anyButton() const; + bool getButton(unsigned id) const { return !!(buttonBitmask & (1u << id)); } + int getIndex() const { return stickIndex; } + int getInstanceID() const { return instanceID; } Vector rightStick; - int stickIndex; int s1ax, s1ay, s2ax, s2ay; private: - bool inited; + int stickIndex; + int instanceID; unsigned buttonBitmask; // FIXME: this should go SDL_Joystick *sdl_joy; diff --git a/BBGE/StateManager.cpp b/BBGE/StateManager.cpp index 987b3c1..9188e0b 100644 --- a/BBGE/StateManager.cpp +++ b/BBGE/StateManager.cpp @@ -54,10 +54,6 @@ void StateObject::removeRenderObject(RenderObject *renderObject) stateManager->getState(name)->removeRenderObject(renderObject); } -void StateObject::action(int id, int state) -{ -} - void StateObject::update(float dt) { ActionMapper::onUpdate(dt); diff --git a/BBGE/StateManager.h b/BBGE/StateManager.h index d92df2e..c2a3514 100644 --- a/BBGE/StateManager.h +++ b/BBGE/StateManager.h @@ -54,7 +54,6 @@ class StateObject : public ActionMapper public: StateObject(); virtual ~StateObject(); - void action(int id, int state); virtual void applyState(){} virtual void removeState(); @@ -64,6 +63,8 @@ public: void removeRenderObject(RenderObject *renderObject); std::string name; + virtual void action(int actionID, int state, int source) {} + protected: void registerState(StateObject *sb, const std::string &name); }; diff --git a/BBGE/Strings.cpp b/BBGE/Strings.cpp deleted file mode 100644 index 5bbeb26..0000000 --- a/BBGE/Strings.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* -Copyright (C) 2007, 2010 - Bit-Blot - -This file is part of Aquaria. - -Aquaria is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ -#include "Core.h" - -typedef std::map InputCodeMap; - -InputCodeMap inputCodeMap; - -void initInputCodeMap() -{ - inputCodeMap["0"] = 0; - - inputCodeMap["KEY_A"] = KEY_A; - inputCodeMap["KEY_B"] = KEY_B; - inputCodeMap["KEY_C"] = KEY_C; - inputCodeMap["KEY_D"] = KEY_D; - inputCodeMap["KEY_E"] = KEY_E; - inputCodeMap["KEY_F"] = KEY_F; - inputCodeMap["KEY_G"] = KEY_G; - inputCodeMap["KEY_H"] = KEY_H; - inputCodeMap["KEY_I"] = KEY_I; - inputCodeMap["KEY_J"] = KEY_J; - inputCodeMap["KEY_K"] = KEY_K; - inputCodeMap["KEY_L"] = KEY_L; - inputCodeMap["KEY_M"] = KEY_M; - inputCodeMap["KEY_N"] = KEY_N; - inputCodeMap["KEY_O"] = KEY_O; - inputCodeMap["KEY_P"] = KEY_P; - inputCodeMap["KEY_Q"] = KEY_Q; - inputCodeMap["KEY_R"] = KEY_R; - inputCodeMap["KEY_S"] = KEY_S; - inputCodeMap["KEY_T"] = KEY_T; - inputCodeMap["KEY_U"] = KEY_U; - inputCodeMap["KEY_V"] = KEY_V; - inputCodeMap["KEY_W"] = KEY_W; - inputCodeMap["KEY_X"] = KEY_X; - inputCodeMap["KEY_Y"] = KEY_Y; - inputCodeMap["KEY_Z"] = KEY_Z; - - inputCodeMap["KEY_1"] = KEY_1; - inputCodeMap["KEY_2"] = KEY_2; - inputCodeMap["KEY_3"] = KEY_3; - inputCodeMap["KEY_4"] = KEY_4; - inputCodeMap["KEY_5"] = KEY_5; - inputCodeMap["KEY_6"] = KEY_6; - inputCodeMap["KEY_7"] = KEY_7; - inputCodeMap["KEY_8"] = KEY_8; - inputCodeMap["KEY_9"] = KEY_9; - inputCodeMap["KEY_0"] = KEY_0; - - inputCodeMap["KEY_NUMPAD1"] = KEY_NUMPAD1; - inputCodeMap["KEY_NUMPAD2"] = KEY_NUMPAD2; - inputCodeMap["KEY_NUMPAD3"] = KEY_NUMPAD3; - inputCodeMap["KEY_NUMPAD4"] = KEY_NUMPAD4; - inputCodeMap["KEY_NUMPAD5"] = KEY_NUMPAD5; - inputCodeMap["KEY_NUMPAD6"] = KEY_NUMPAD6; - inputCodeMap["KEY_NUMPAD7"] = KEY_NUMPAD7; - inputCodeMap["KEY_NUMPAD8"] = KEY_NUMPAD8; - inputCodeMap["KEY_NUMPAD9"] = KEY_NUMPAD9; - inputCodeMap["KEY_NUMPAD0"] = KEY_NUMPAD0; - - inputCodeMap["KEY_F1"] = KEY_F1; - inputCodeMap["KEY_F2"] = KEY_F2; - inputCodeMap["KEY_F3"] = KEY_F3; - inputCodeMap["KEY_F4"] = KEY_F4; - inputCodeMap["KEY_F5"] = KEY_F5; - inputCodeMap["KEY_F6"] = KEY_F6; - inputCodeMap["KEY_F7"] = KEY_F7; - inputCodeMap["KEY_F8"] = KEY_F8; - inputCodeMap["KEY_F9"] = KEY_F9; - inputCodeMap["KEY_F10"] = KEY_F10; - inputCodeMap["KEY_F11"] = KEY_F11; - inputCodeMap["KEY_F12"] = KEY_F12; - - inputCodeMap["KEY_LEFT"] = KEY_LEFT; - inputCodeMap["KEY_RIGHT"] = KEY_RIGHT; - inputCodeMap["KEY_UP"] = KEY_UP; - inputCodeMap["KEY_DOWN"] = KEY_DOWN; - - inputCodeMap["KEY_SPACE"] = KEY_SPACE; - inputCodeMap["KEY_LCONTROL"] = KEY_LCONTROL; - inputCodeMap["KEY_RCONTROL"] = KEY_RCONTROL; - inputCodeMap["KEY_LSHIFT"] = KEY_LSHIFT; - inputCodeMap["KEY_RSHIFT"] = KEY_RSHIFT; - inputCodeMap["KEY_LMETA"] = KEY_LMETA; - inputCodeMap["KEY_RMETA"] = KEY_RMETA; - inputCodeMap["KEY_LALT"] = KEY_LALT; - inputCodeMap["KEY_RALT"] = KEY_RALT; - inputCodeMap["KEY_RETURN"] = KEY_RETURN; - inputCodeMap["KEY_TAB"] = KEY_TAB; - - inputCodeMap["KEY_ESCAPE"] = KEY_ESCAPE; - - inputCodeMap["MOUSE_BUTTON_LEFT"] = ActionMapper::MOUSE_BUTTON_LEFT; - inputCodeMap["MOUSE_BUTTON_RIGHT"] = ActionMapper::MOUSE_BUTTON_RIGHT; - inputCodeMap["MOUSE_BUTTON_MIDDLE"] = ActionMapper::MOUSE_BUTTON_MIDDLE; - - for (int i = 0; i < 17; i++) - { - std::ostringstream os; - os << "JOY_BUTTON_" << i; - inputCodeMap[os.str()] = ActionMapper::JOY1_BUTTON_0+i; - } -} - -void clearInputCodeMap() -{ - inputCodeMap.clear(); -} - -std::string getInputCodeToString(int key) -{ - for (InputCodeMap::iterator i = inputCodeMap.begin(); i != inputCodeMap.end(); i++) - { - if ((*i).second == key) - { - return (*i).first; - } - } - return ""; -} - -// FIXME: Move stringbank to BBGE and move these strings into it. -- fg - -std::string getInputCodeToUserString(int key) -{ - for (InputCodeMap::iterator i = inputCodeMap.begin(); i != inputCodeMap.end(); i++) - { - if ((*i).second == key) - { - std::string use = (*i).first; - int idx = 0; - idx = use.find("KEY_"); - if (idx != std::string::npos) - { - use = use.substr(4, use.size()); - } - if (use == "MOUSE_BUTTON_LEFT") - use = "Left Mouse Button"; - if (use == "MOUSE_BUTTON_RIGHT") - use = "Right Mouse Button"; - if (use == "MOUSE_BUTTON_MIDDLE") - use = "Middle Mouse Button"; - - return use; - - } - } - return ""; -} - -int getStringToInputCode(const std::string &string) -{ - return inputCodeMap[string]; -} diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fb278f..9436f58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -413,6 +413,7 @@ SET(AQUARIA_SRCS ${SRCDIR}/GridRender.cpp ${SRCDIR}/Hair.cpp ${SRCDIR}/Ingredient.cpp + ${SRCDIR}/InGameMenu.cpp ${SRCDIR}/Intro.cpp ${SRCDIR}/Logo.cpp ${SRCDIR}/Main.cpp @@ -505,7 +506,6 @@ SET(BBGE_SRCS ${BBGEDIR}/SpawnParticleData.cpp ${BBGEDIR}/StateMachine.cpp ${BBGEDIR}/StateManager.cpp - ${BBGEDIR}/Strings.cpp ${BBGEDIR}/Texture.cpp ${BBGEDIR}/TTFFont.cpp ${BBGEDIR}/Vector.cpp diff --git a/win/vc90/Aquaria.vcproj b/win/vc90/Aquaria.vcproj index 906b22c..df67215 100644 --- a/win/vc90/Aquaria.vcproj +++ b/win/vc90/Aquaria.vcproj @@ -42,7 +42,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\gl";"$(SolutionDir)\..\ExternalLibs\glpng\zlib";"$(SolutionDir)\..\ExternalLibs\glpng\png";"$(SolutionDir)\..\ExternalLibs\libogg-1.3.0\include";"$(SolutionDir)\..\ExternalLibs\libvorbis-1.3.3\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\AL\include";"$(SolutionDir)\..\BBGE";"$(SolutionDir)\..\ExternalLibs\lua-5.1.4\src";"$(SolutionDir)\..\ExternalLibs\lvpa\include";"$(SolutionDir)\..\ExternalLibs\lvpa";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs"" - PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;BBGE_BUILD_VFS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;BBGE_BUILD_VFS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1;BBGE_BUILD_SDL2" MinimalRebuild="true" BasicRuntimeChecks="0" RuntimeLibrary="3" @@ -124,7 +124,7 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\gl";"$(SolutionDir)\..\ExternalLibs\glpng\zlib";"$(SolutionDir)\..\ExternalLibs\glpng\png";"$(SolutionDir)\..\ExternalLibs\libogg-1.3.0\include";"$(SolutionDir)\..\ExternalLibs\libvorbis-1.3.3\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\AL\include";"$(SolutionDir)\..\BBGE";"$(SolutionDir)\..\ExternalLibs\lua-5.1.4\src";"$(SolutionDir)\..\ExternalLibs\lvpa\include";"$(SolutionDir)\..\ExternalLibs\lvpa";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs"" - PreprocessorDefinitions="WIN32;NDEBUG;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;_HAS_EXCEPTIONS=0;BBGE_BUILD_VFS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1" + PreprocessorDefinitions="WIN32;NDEBUG;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;_HAS_EXCEPTIONS=0;BBGE_BUILD_VFS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1;BBGE_BUILD_SDL2" StringPooling="true" ExceptionHandling="0" RuntimeLibrary="0" @@ -218,14 +218,6 @@ RelativePath="..\..\Aquaria\AStar.h" > - - - - @@ -334,6 +326,14 @@ RelativePath="..\..\Aquaria\Hair.h" > + + + + @@ -406,6 +406,10 @@ RelativePath="..\..\Aquaria\RecipeMenuEntry.cpp" > + + diff --git a/win/vc90/BBGE.vcproj b/win/vc90/BBGE.vcproj index 8dbd098..b3ca351 100644 --- a/win/vc90/BBGE.vcproj +++ b/win/vc90/BBGE.vcproj @@ -43,7 +43,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\gl";"$(SolutionDir)\..\ExternalLibs\glpng\zlib";"$(SolutionDir)\..\ExternalLibs\glpng\png";"$(SolutionDir)\..\ExternalLibs\libogg-1.3.0\include";"$(SolutionDir)\..\ExternalLibs\libvorbis-1.3.3\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\AL\include";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs\lvpa";"$(SolutionDir)\..\ExternalLibs\lvpa\include";"$(SolutionDir)\..\ExternalLibs"" - PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;FTGL_LIBRARY_STATIC;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;FTGL_LIBRARY_STATIC;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1;BBGE_BUILD_SDL2" MinimalRebuild="true" BasicRuntimeChecks="0" RuntimeLibrary="3" @@ -116,7 +116,7 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\gl";"$(SolutionDir)\..\ExternalLibs\glpng\zlib";"$(SolutionDir)\..\ExternalLibs\glpng\png";"$(SolutionDir)\..\ExternalLibs\libogg-1.3.0\include";"$(SolutionDir)\..\ExternalLibs\libvorbis-1.3.3\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\AL\include";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs\lvpa";"$(SolutionDir)\..\ExternalLibs\lvpa\include";"$(SolutionDir)\..\ExternalLibs"" - PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;FTGL_LIBRARY_STATIC;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;_HAS_EXCEPTIONS=0;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;FTGL_LIBRARY_STATIC;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;_HAS_EXCEPTIONS=0;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1;BBGE_BUILD_SDL2" StringPooling="true" ExceptionHandling="0" RuntimeLibrary="0" @@ -488,10 +488,6 @@ RelativePath="..\..\BBGE\StateManager.h" > - -