diff --git a/ChallengeLeaguePointSolver/ChampionsLeaguePointSolver.cpp b/ChallengeLeaguePointSolver/ChampionsLeaguePointSolver.cpp index b066124..8507a1d 100644 --- a/ChallengeLeaguePointSolver/ChampionsLeaguePointSolver.cpp +++ b/ChallengeLeaguePointSolver/ChampionsLeaguePointSolver.cpp @@ -6,6 +6,8 @@ using namespace olc; QuickGUI::TextBox*prevTextBox=nullptr; +QuickGUI::TextBox*activeBox=nullptr; + // Override base class with your custom functionality class ChampionsLeaguePointSolver : public olc::PixelGameEngine { @@ -217,6 +219,7 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine QuickGUI::Label*p2Label; QuickGUI::Label*p3Label; QuickGUI::Button*calculateButton; + std::arrayinputButtons; int totalCalculationSteps=0; bool calculating=false; @@ -283,6 +286,19 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine p3Label=new QuickGUI::Label(gui,"P3",vf2d{4.f,2.f}+vf2d{192+42*2,0},{36,12}); calculateButton=new QuickGUI::Button(gui,"Calculate",{4,2},{100,16}); + for(int i=0;ibVisible=false; + inputButtons[i]->Enable(false); + } + for(int i=0;i<5;i++){ for(int j=0;j<5;j++){ for(int k=0;k<5;k++){ @@ -327,14 +343,36 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine bestComboA={}; bestComboB={}; } + QuickGUI::TextBox*prevActiveBox=activeBox; gui.Update(this); gui.Draw(this); if(highestEX!=0){ DrawString({112,4},std::to_string(highestEX)+" EX",YELLOW); } + if(!calculating){ + if(prevActiveBox!=nullptr){ + for(int i=0;ibVisible=true; + inputButtons[i]->Enable(true); + if(inputButtons[i]->bPressed){ + if(i==10){ + prevActiveBox->sText=prevActiveBox->sText.substr(0,std::max(0,int(prevActiveBox->sText.length())-1)); + }else{ + if(prevActiveBox->sText.length()<4){ + prevActiveBox->sText+=inputButtons[i]->sText; + } + } + activeBox=prevActiveBox; + prevActiveBox->m_bTextEdit=true; + TextEntryEnable(true,prevActiveBox->sText); + } + } + } + } if(calculating){ + activeBox=nullptr; if(calculationStep + + + + + + Emscripten-Generated Code + + + + + + + + + + diff --git a/ChallengeLeaguePointSolver/olcPGEX_QuickGUI.h b/ChallengeLeaguePointSolver/olcPGEX_QuickGUI.h index 8e92c64..94d6d78 100644 --- a/ChallengeLeaguePointSolver/olcPGEX_QuickGUI.h +++ b/ChallengeLeaguePointSolver/olcPGEX_QuickGUI.h @@ -76,7 +76,6 @@ #include "pixelGameEngine.h" - namespace olc::QuickGUI { class Manager; @@ -216,7 +215,7 @@ namespace olc::QuickGUI TextBox*tabNext=nullptr; TextBox*tabPrev=nullptr; - protected: + public: bool m_bTextEdit = false; }; @@ -394,6 +393,8 @@ namespace olc::QuickGUI #ifdef OLC_PGEX_QUICKGUI #undef OLC_PGEX_QUICKGUI + +extern olc::QuickGUI::TextBox*activeBox; namespace olc::QuickGUI { @@ -570,6 +571,7 @@ namespace olc::QuickGUI if (bPressed && pge->IsTextEntryEnabled() && !m_bTextEdit) { pge->TextEntryEnable(false); + activeBox=nullptr; } @@ -577,6 +579,7 @@ namespace olc::QuickGUI { TextBox::bBoxClicked=true; pge->TextEntryEnable(true, sText); + activeBox=this; m_bTextEdit = true; } @@ -596,6 +599,7 @@ namespace olc::QuickGUI if(!TextBox::bBoxClicked){ sText = pge->TextEntryGetString(); pge->TextEntryEnable(false); + activeBox=nullptr; } m_bTextEdit = false; } @@ -608,6 +612,7 @@ namespace olc::QuickGUI if(tabPrev!=nullptr){ m_bTextEdit = false; pge->TextEntryEnable(true, tabPrev->sText); + activeBox=tabPrev; tabPrev->m_bTextEdit=true; TextBox::bBoxClicked=true; } @@ -615,6 +620,7 @@ namespace olc::QuickGUI if(tabNext!=nullptr){ m_bTextEdit = false; pge->TextEntryEnable(true, tabNext->sText); + activeBox=tabNext; tabNext->m_bTextEdit=true; TextBox::bBoxClicked=true; } diff --git a/ChallengeLeaguePointSolver/pixelGameEngine_wasm.o b/ChallengeLeaguePointSolver/pixelGameEngine_wasm.o index 74d0630..564cfc1 100644 Binary files a/ChallengeLeaguePointSolver/pixelGameEngine_wasm.o and b/ChallengeLeaguePointSolver/pixelGameEngine_wasm.o differ