diff --git a/Adventures in Lestoria Tests/MonsterTests.cpp b/Adventures in Lestoria Tests/MonsterTests.cpp index f9b927c7..fca6ec27 100644 --- a/Adventures in Lestoria Tests/MonsterTests.cpp +++ b/Adventures in Lestoria Tests/MonsterTests.cpp @@ -61,7 +61,7 @@ namespace MonsterTests //Makes MONSTER_DATA["TestName"] available. void SetupTestMonster(){ testGame.reset(new AiL()); - testGame->EnableTestingMode(); + testGame->olc_SetTestingMode(true); ItemAttribute::Initialize(); ItemInfo::InitializeItems(); testGame->InitializePlayer(); diff --git a/Adventures in Lestoria Tests/PlayerTests.cpp b/Adventures in Lestoria Tests/PlayerTests.cpp index 0a1da731..70e6a7f9 100644 --- a/Adventures in Lestoria Tests/PlayerTests.cpp +++ b/Adventures in Lestoria Tests/PlayerTests.cpp @@ -53,12 +53,16 @@ namespace PlayerTests HWButton*testKey; TEST_METHOD_INITIALIZE(PlayerInitialize){ testGame.reset(new AiL()); - testGame->EnableTestingMode(); + testGame->olc_SetTestingMode(true); + ItemAttribute::Initialize(); + ItemInfo::InitializeItems(); + testGame->InitializeGraphics(); testGame->InitializeClasses(); + sig::Animation::InitializeAnimations(); testGame->InitializeDefaultKeybinds(); - Tutorial::Initialize(); - ItemAttribute::Initialize(); testGame->InitializePlayer(); + Menu::InitializeMenus(); + Tutorial::Initialize(); Stats::InitializeDamageReductionTable(); player=testGame->GetPlayer(); //Setup key "0" as a test input @@ -118,5 +122,13 @@ namespace PlayerTests player->GetRightClickAbility().action(player,player->GetPos()); Assert::AreEqual(int(State::BLOCK),int(player->GetState())); } + TEST_METHOD(WizardCastDoesNotConsumeManaImmediately){ + testGame->ChangePlayerClass(WIZARD); + player=testGame->GetPlayer(); //The player pointer has been reassigned... + //Ability 3 is Meteor, which is a cast. Mana should not be consumed for a spell that begins as a cast. + testKey->bHeld=true; //Force the key to be held down for testing purposes. + player->CheckAndPerformAbility(player->GetAbility3(),testKeyboardInput); + Assert::AreEqual(player->GetMaxMana(),player->GetMana()); + } }; } diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index c5e51ae7..7e5d1abd 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -267,10 +267,6 @@ bool AiL::OnUserCreate(){ VisualNovel::Initialize(); - ItemAttribute::Initialize(); - - ItemInfo::InitializeItems(); - InitializeGraphics(); InitializeClasses(); @@ -3584,6 +3580,15 @@ void AiL::RenderMenu(){ } void AiL::InitializeGraphics(){ + circleCooldownPoints.clear(); + squareCircleCooldownPoints.clear(); + GFX.Reset(); + Menu::themes.Reset(); + + //These two create item graphics, so they should be after the GFX structure gets reset! + ItemAttribute::Initialize(); + ItemInfo::InitializeItems(); + circleCooldownPoints.push_back({0,0}); squareCircleCooldownPoints.push_back({0,0}); for(int i=0;i<=360;i+=4){ @@ -4394,12 +4399,4 @@ void AiL::UsingSteamAPI(const bool usingSteam){ void AiL::InitializePlayer(){ player=std::make_unique(); -} - -void AiL::EnableTestingMode(){ - testingMode=true; -} - -const bool AiL::TestingModeEnabled()const{ - return testingMode; } \ No newline at end of file diff --git a/Adventures in Lestoria/AdventuresInLestoria.h b/Adventures in Lestoria/AdventuresInLestoria.h index af07379c..49ee012a 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.h +++ b/Adventures in Lestoria/AdventuresInLestoria.h @@ -217,7 +217,6 @@ private: std::optionalbossIndicatorPos{}; bool steamAPIEnabled{true}; Overlay hudOverlay{"pixel.png",BLANK}; - bool testingMode{false}; public: AiL(); bool OnUserCreate() override; @@ -367,8 +366,6 @@ public: const HurtList HurtMonsterType(vf2d pos,float radius,int damage,bool upperLevel,float z,const std::string_view monsterName)const; void InitializeGameConfigurations(); void InitializePlayer(); - void EnableTestingMode(); - const bool TestingModeEnabled()const; struct TileGroupData{ vi2d tilePos; diff --git a/Adventures in Lestoria/Animation.cpp b/Adventures in Lestoria/Animation.cpp index ad23b540..ace62e6c 100644 --- a/Adventures in Lestoria/Animation.cpp +++ b/Adventures in Lestoria/Animation.cpp @@ -46,6 +46,8 @@ INCLUDE_DATA INCLUDE_GFX void sig::Animation::InitializeAnimations(){ + ANIMATION_DATA.Reset(); + auto CreateStillAnimation=[&](std::string imgName,vf2d size,AnimationData data={}){ Animate2D::FrameSequence anim(data.frameDuration,data.style); anim.AddFrame({&GFX[imgName],{{0,0},size}}); diff --git a/Adventures in Lestoria/Bullet.cpp b/Adventures in Lestoria/Bullet.cpp index 4e052ecf..bc6e08b2 100644 --- a/Adventures in Lestoria/Bullet.cpp +++ b/Adventures in Lestoria/Bullet.cpp @@ -52,7 +52,7 @@ Bullet::Bullet(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool fr Bullet::Bullet(vf2d pos,vf2d vel,float radius,int damage,std::string animation,bool upperLevel,bool hitsMultiple,float lifetime,bool rotatesWithAngle,bool friendly,Pixel col,vf2d scale,float image_angle) :pos(pos),vel(vel),radius(radius),damage(damage),col(col),animated(true),rotates(rotatesWithAngle),lifetime(lifetime),hitsMultiple(hitsMultiple),friendly(friendly),upperLevel(upperLevel),scale(scale),image_angle(image_angle){ - this->animation.AddState(animation,ANIMATION_DATA[animation]); + this->animation.AddState(animation,ANIMATION_DATA.at(animation)); this->animation.ChangeState(internal_animState,animation); }; diff --git a/Adventures in Lestoria/CharacterMenuWindow.cpp b/Adventures in Lestoria/CharacterMenuWindow.cpp index e26707e3..544450ac 100644 --- a/Adventures in Lestoria/CharacterMenuWindow.cpp +++ b/Adventures in Lestoria/CharacterMenuWindow.cpp @@ -146,6 +146,7 @@ void Menu::InitializeCharacterMenuWindow(){ characterMenuWindow->ADD("Character Label",MenuLabel)(geom2d::rect{{0,-4},{float(windowSize.x)-1,24}},"Character",2,ComponentAttr::SHADOW|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND)END; characterMenuWindow->ADD("Equip Slot Outline",MenuComponent)(geom2d::rect{{0,28},{120,windowSize.y-37}},"",DO_NOTHING,ButtonAttr::UNSELECTABLE)END; + //Don't load this graphical element if testing mode is enabled. characterMenuWindow->ADD("Character Rotating Display",CharacterRotatingDisplay)(geom2d::rect{{118,18},{130,windowSize.y-28}},GFX[classutils::GetClassInfo(game->GetPlayer()->GetClassName()).classFullImgName].Decal())END; characterMenuWindow->ADD("Level Class Display",MenuLabel)(geom2d::rect{vf2d{126.f,windowSize.y-28},{118.f,8.f}},std::format("Lv{} {}",game->GetPlayer()->Level(),game->GetPlayer()->GetClassName()),1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END; diff --git a/Adventures in Lestoria/Effect.cpp b/Adventures in Lestoria/Effect.cpp index de7b2f2c..0a6c567d 100644 --- a/Adventures in Lestoria/Effect.cpp +++ b/Adventures in Lestoria/Effect.cpp @@ -45,13 +45,11 @@ INCLUDE_game Effect::Effect(vf2d pos,float lifetime,std::string imgFile,bool upperLevel,float size,float fadeout,vf2d spd,Pixel col,float rotation,float rotationSpd,bool additiveBlending) :Effect::Effect(pos,lifetime,imgFile,upperLevel,vf2d{size,size},fadeout,spd,col,rotation,rotationSpd,additiveBlending){ - if(game->TestingModeEnabled())return; this->animation.AddState(imgFile,ANIMATION_DATA[imgFile]); } Effect::Effect(vf2d pos,float lifetime,std::string imgFile,bool upperLevel,vf2d size,float fadeout,vf2d spd,Pixel col,float rotation,float rotationSpd,bool additiveBlending) :pos(pos),lifetime(lifetime),upperLevel(upperLevel),size(size),fadeout(fadeout),original_fadeoutTime(fadeout),spd(spd),col(col),rotation(rotation),rotationSpd(rotationSpd),additiveBlending(additiveBlending){ - if(game->TestingModeEnabled())return; this->animation.AddState(imgFile,ANIMATION_DATA[imgFile]); } diff --git a/Adventures in Lestoria/MenuIconButton.h b/Adventures in Lestoria/MenuIconButton.h index 62a62566..5e9bacf1 100644 --- a/Adventures in Lestoria/MenuIconButton.h +++ b/Adventures in Lestoria/MenuIconButton.h @@ -52,7 +52,7 @@ enum class IconButtonAttr{ class MenuIconButton:public MenuComponent{ protected: - Decal*icon; + Decal*icon{nullptr}; vf2d iconScale{1,1}; Pixel tint=WHITE; public: diff --git a/Adventures in Lestoria/Monster.cpp b/Adventures in Lestoria/Monster.cpp index df9f7e25..0bfb73ae 100644 --- a/Adventures in Lestoria/Monster.cpp +++ b/Adventures in Lestoria/Monster.cpp @@ -932,7 +932,7 @@ geom2d::circleMonster::BulletCollisionHitbox(){ } void Monster::Knockback(const vf2d&vel){ - if(IsSolid())return; + if(IsSolid()||GetZ()>=1.f)return; //A new angle will be applied, but will be constrained by whichever applied velocity is strongest (either the current velocity, or the new one). This prevents continuous uncapped velocities to knockbacks applied. if(vel==vf2d{})return; float maxVelThreshold; diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp index 7a0df4bd..67655d4f 100644 --- a/Adventures in Lestoria/Player.cpp +++ b/Adventures in Lestoria/Player.cpp @@ -307,7 +307,7 @@ State::State Player::GetState(){ void Player::Knockback(vf2d vel){ //A new angle will be applied, but will be constrained by whichever applied velocity is strongest (either the current velocity, or the new one). This prevents continuous uncapped velocities to knockbacks applied. - if(vel==vf2d{})return; + if(vel==vf2d{}||GetZ()>=1.f)return; float maxVelThreshold; if(GetState()==State::BLOCK)vel*=1-("Warrior.Right Click Ability.Knockback Reduction"_I/100.f); if(this->vel==vf2d{})maxVelThreshold=vel.mag(); @@ -811,7 +811,6 @@ void Player::AddAnimation(std::string state){ } void Player::UpdateAnimation(std::string animState,int specificClass, const float frameMult){ - if(game->TestingModeEnabled())return; if(specificClass==ANY||specificClass&GetClass()){ animation.ChangeState(internal_animState,animState,frameMult); } diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 3d416920..39c84122 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 1 #define VERSION_MINOR 2 #define VERSION_PATCH 3 -#define VERSION_BUILD 9814 +#define VERSION_BUILD 9835 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/olcPixelGameEngine.h b/Adventures in Lestoria/olcPixelGameEngine.h index 7d9df8fd..244bce78 100644 --- a/Adventures in Lestoria/olcPixelGameEngine.h +++ b/Adventures in Lestoria/olcPixelGameEngine.h @@ -1043,6 +1043,7 @@ namespace olc // Gets "screen" size const olc::vi2d& GetScreenSize() const; const bool IsFullscreen()const; + const bool TestingModeEnabled()const; // Gets any files dropped this frame const std::vector& GetDroppedFiles() const; const olc::vi2d& GetDroppedFilesPoint() const; @@ -1359,6 +1360,8 @@ namespace olc bool pMouseOldState[nMouseButtons] = { 0 }; HWButton pMouseState[nMouseButtons] = { 0 }; + bool testingMode{false}; + // The main engine thread void EngineThread(); @@ -1387,6 +1390,8 @@ namespace olc void olc_Reanimate(); bool olc_IsRunning(); + void olc_SetTestingMode(const bool testingMode); + // At the very end of this file, chooses which // components to compile virtual void olc_ConfigureSystem(); @@ -1708,7 +1713,7 @@ namespace olc Decal::Decal(olc::Sprite* spr, bool filter, bool clamp) { id = -1; - if (spr == nullptr) return; + if (renderer->ptrPGE->TestingModeEnabled()||spr == nullptr) return; sprite = spr; id = renderer->CreateTexture(sprite->width, sprite->height, filter, clamp); Update(); @@ -1716,13 +1721,13 @@ namespace olc Decal::Decal(const uint32_t nExistingTextureResource, olc::Sprite* spr) { - if (spr == nullptr) return; + if (renderer->ptrPGE->TestingModeEnabled()||spr == nullptr) return; id = nExistingTextureResource; } void Decal::Update() { - if (sprite == nullptr) return; + if (renderer->ptrPGE->TestingModeEnabled()||sprite == nullptr) return; vUVScale = { 1.0f / float(sprite->width), 1.0f / float(sprite->height) }; renderer->ApplyTexture(id); renderer->UpdateTexture(id, sprite); @@ -1730,7 +1735,7 @@ namespace olc void Decal::UpdateSprite() { - if (sprite == nullptr) return; + if (renderer->ptrPGE->TestingModeEnabled()||sprite == nullptr) return; renderer->ApplyTexture(id); renderer->ReadTexture(id, sprite); } @@ -2034,7 +2039,7 @@ namespace olc else { nTargetLayer = 0; - pDrawTarget = vLayers[0].pDrawTarget.Sprite(); + if(!TestingModeEnabled())pDrawTarget = vLayers[0].pDrawTarget.Sprite(); } } @@ -2202,6 +2207,10 @@ namespace olc const bool PixelGameEngine::IsFullscreen()const{ return bFullScreen; } + + const bool PixelGameEngine::TestingModeEnabled()const{ + return testingMode; + } const olc::vi2d& PixelGameEngine::GetWindowMouse() const { return vMouseWindowPos; } @@ -3950,6 +3959,7 @@ namespace olc olc::vi2d PixelGameEngine::GetTextSizeProp(std::string_view s) { + if(vFontSpacing.size()==0)return{}; //Hack to allow for testing mode to just return a default value. olc::vi2d size = { 0,1 }; olc::vi2d pos = { 0,1 }; for (int skip=0;auto c : s) @@ -4565,6 +4575,10 @@ namespace olc bool PixelGameEngine::olc_IsRunning() { return bAtomActive; } + void PixelGameEngine::olc_SetTestingMode(const bool testingMode){ + this->testingMode=testingMode; + } + void PixelGameEngine::olc_Terminate() { bAtomActive = false; } diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 0f3298eb..305dab80 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ