| 173 | } |
| 174 | |
| 175 | bool OnUserUpdate(float fElapsedTime) override |
| 176 | { |
| 177 | // We must update the manager at some point each frame. Values of controls |
| 178 | // are only valid AFTER this call to update() |
| 179 | guiManager.Update(this); |
| 180 | |
| 181 | // Some silly examples... |
| 182 | |
| 183 | // 001) The "theme colour" can be set from slider values |
| 184 | guiManager.colNormal = olc::Pixel( |
| 185 | uint8_t(guiThemeColourR->fValue), |
| 186 | uint8_t(guiThemeColourG->fValue), |
| 187 | uint8_t(guiThemeColourB->fValue)); |
| 188 | |
| 189 | // 002) Display Slider 1 value on Button 2 |
| 190 | guiButton2->sText = "Button " + std::to_string(int32_t(guiSlider1->fValue)); |
| 191 | |
| 192 | // 003) Check if "Reset Theme" button is pressed, if it is, well, err... |
| 193 | if (guiButton3->bPressed) |
| 194 | { |
| 195 | // ...reset the theme! (which also updates the sliders) |
| 196 | guiThemeColourR->fValue = 0.0f; |
| 197 | guiThemeColourG->fValue = 0.0f; |
| 198 | guiThemeColourB->fValue = 128.0f; |
| 199 | } |
| 200 | |
| 201 | // 004) Link Slider 2 and Slider 3 together |
| 202 | if(guiSlider2->bHeld) |
| 203 | guiSlider3->fValue = 100.0f - guiSlider2->fValue; |
| 204 | if (guiSlider3->bHeld) |
| 205 | guiSlider2->fValue = 100.0f - guiSlider3->fValue; |
| 206 | |
| 207 | |
| 208 | // Draw Stuff! |
| 209 | Clear(olc::BLACK); |
| 210 | |
| 211 | // 005) Use checkbox to determine rendering mode |
| 212 | if (guiCheckBox1->bChecked) |
| 213 | guiManager.DrawDecal(this); |
| 214 | else |
| 215 | guiManager.Draw(this); |
| 216 | return true; |
| 217 | } |
| 218 | }; |
| 219 | |
| 220 | int main() |