aboutsummaryrefslogtreecommitdiff
path: root/game/menus/shop
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2025-01-10 14:43:42 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2025-01-10 14:43:42 +0100
commitd1cebcca2018ed4ef47ad125e45aafd018a2ab2e (patch)
tree8f4881cf4abc58774625383620cf82fa55b9d1f0 /game/menus/shop
parent938b6a7bb62459e8308320280d15ccaf1b8af0ac (diff)
make format
Diffstat (limited to 'game/menus/shop')
-rw-r--r--game/menus/shop/ButtonBuySelectBubbleScript.cpp18
-rw-r--r--game/menus/shop/ButtonBuySelectBulletScript.cpp18
-rw-r--r--game/menus/shop/ShopLoadScript.cpp73
-rw-r--r--game/menus/shop/ShopMenuScene.cpp21
-rw-r--r--game/menus/shop/Shopconfig.h2
5 files changed, 63 insertions, 69 deletions
diff --git a/game/menus/shop/ButtonBuySelectBubbleScript.cpp b/game/menus/shop/ButtonBuySelectBubbleScript.cpp
index 21dbe1a..741afde 100644
--- a/game/menus/shop/ButtonBuySelectBubbleScript.cpp
+++ b/game/menus/shop/ButtonBuySelectBubbleScript.cpp
@@ -17,19 +17,17 @@ void ButtonBuySelectBubbleScript::init() {
bool ButtonBuySelectBubbleScript::on_button_press(const ButtonPressEvent & e) {
SaveManager & save = this->get_save_manager();
- ValueBroker<int> buy_bullet = save.get<int>(BUY_BUBBLE_SAVE,0);
- if(!buy_bullet.get()){
- ValueBroker<int> coins = save.get<int>(TOTAL_COINS_GAME,0);
- if(coins.get() >= 1000)
- {
+ ValueBroker<int> buy_bullet = save.get<int>(BUY_BUBBLE_SAVE, 0);
+ if (!buy_bullet.get()) {
+ ValueBroker<int> coins = save.get<int>(TOTAL_COINS_GAME, 0);
+ if (coins.get() >= 1000) {
int coin = coins.get();
coin -= 1000;
- save.set(TOTAL_COINS_GAME,coin);
- save.set(BUY_BUBBLE_SAVE,1);
+ save.set(TOTAL_COINS_GAME, coin);
+ save.set(BUY_BUBBLE_SAVE, 1);
}
- }
- else {
- save.set(JETPACK_PARTICLES,1);
+ } else {
+ save.set(JETPACK_PARTICLES, 1);
}
this->trigger_event<ShopUpdate>();
return false;
diff --git a/game/menus/shop/ButtonBuySelectBulletScript.cpp b/game/menus/shop/ButtonBuySelectBulletScript.cpp
index 71d8b76..d30849c 100644
--- a/game/menus/shop/ButtonBuySelectBulletScript.cpp
+++ b/game/menus/shop/ButtonBuySelectBulletScript.cpp
@@ -17,19 +17,17 @@ void ButtonBuySelectBulletScript::init() {
bool ButtonBuySelectBulletScript::on_button_press(const ButtonPressEvent & e) {
SaveManager & save = this->get_save_manager();
- ValueBroker<int> buy_bullet = save.get<int>(BUY_BULLET_SAVE,0);
- if(!buy_bullet.get()){
- ValueBroker<int> coins = save.get<int>(TOTAL_COINS_GAME,0);
- if(coins.get() >= 0)
- {
+ ValueBroker<int> buy_bullet = save.get<int>(BUY_BULLET_SAVE, 0);
+ if (!buy_bullet.get()) {
+ ValueBroker<int> coins = save.get<int>(TOTAL_COINS_GAME, 0);
+ if (coins.get() >= 0) {
int coin = coins.get();
coin -= 0;
- save.set(TOTAL_COINS_GAME,coin);
- save.set(BUY_BULLET_SAVE,1);
+ save.set(TOTAL_COINS_GAME, coin);
+ save.set(BUY_BULLET_SAVE, 1);
}
- }
- else {
- save.set(JETPACK_PARTICLES,0);
+ } else {
+ save.set(JETPACK_PARTICLES, 0);
}
this->trigger_event<ShopUpdate>();
return false;
diff --git a/game/menus/shop/ShopLoadScript.cpp b/game/menus/shop/ShopLoadScript.cpp
index a9f9bfe..a545fe2 100644
--- a/game/menus/shop/ShopLoadScript.cpp
+++ b/game/menus/shop/ShopLoadScript.cpp
@@ -1,129 +1,124 @@
#include "ShopLoadScript.h"
-#include <crepe/ValueBroker.h>
+#include "Shopconfig.h"
#include "api/Button.h"
#include "api/Sprite.h"
-#include "Shopconfig.h"
#include "api/Text.h"
#include "manager/SaveManager.h"
+#include <crepe/ValueBroker.h>
using namespace crepe;
using namespace std;
void ShopLoadScript::init() {
this->update();
- this->subscribe<ShopUpdate>([this](const ShopUpdate e) {
- return this->update();
- });
+ this->subscribe<ShopUpdate>([this](const ShopUpdate e) { return this->update(); });
}
-bool ShopLoadScript::update(){
+bool ShopLoadScript::update() {
SaveManager & save = this->get_save_manager();
- ValueBroker<int> buy_bullet = save.get<int>(BUY_BULLET_SAVE,0);
- ValueBroker<int> buy_bubble = save.get<int>(BUY_BUBBLE_SAVE,0);
+ ValueBroker<int> buy_bullet = save.get<int>(BUY_BULLET_SAVE, 0);
+ ValueBroker<int> buy_bubble = save.get<int>(BUY_BUBBLE_SAVE, 0);
-
- if(buy_bullet.get()){
+ if (buy_bullet.get()) {
auto sprites = this->get_components_by_tag<Sprite>(BUY_BULLET);
- for(auto sprite : sprites){
+ for (auto sprite : sprites) {
sprite.get().active = false;
}
auto buttons = this->get_components_by_tag<Button>(BUY_BULLET);
- for(auto btn : buttons){
+ for (auto btn : buttons) {
btn.get().active = false;
}
auto texts = this->get_components_by_tag<Text>(BUY_BULLET);
- for(auto txt : texts){
+ for (auto txt : texts) {
txt.get().active = false;
}
auto sprites1 = this->get_components_by_tag<Sprite>(SELECT_BULLET);
- for(auto sprite : sprites1){
+ for (auto sprite : sprites1) {
sprite.get().active = true;
}
auto buttons1 = this->get_components_by_tag<Button>(SELECT_BULLET);
- for(auto btn : buttons1){
+ for (auto btn : buttons1) {
btn.get().active = true;
}
auto texts1 = this->get_components_by_tag<Text>(SELECT_BULLET);
- for(auto txt : texts1){
+ for (auto txt : texts1) {
txt.get().active = true;
}
- }
- else {
+ } else {
auto sprites = this->get_components_by_tag<Sprite>(SELECT_BULLET);
- for(auto sprite : sprites){
+ for (auto sprite : sprites) {
sprite.get().active = false;
}
auto buttons = this->get_components_by_tag<Button>(SELECT_BULLET);
- for(auto btn : buttons){
+ for (auto btn : buttons) {
btn.get().active = false;
}
auto texts = this->get_components_by_tag<Text>(SELECT_BULLET);
- for(auto txt : texts){
+ for (auto txt : texts) {
txt.get().active = false;
}
auto sprites1 = this->get_components_by_tag<Sprite>(BUY_BULLET);
- for(auto sprite : sprites1){
+ for (auto sprite : sprites1) {
sprite.get().active = true;
}
auto buttons1 = this->get_components_by_tag<Button>(BUY_BULLET);
- for(auto btn : buttons1){
+ for (auto btn : buttons1) {
btn.get().active = true;
}
auto texts1 = this->get_components_by_tag<Text>(BUY_BULLET);
- for(auto txt : texts1){
+ for (auto txt : texts1) {
txt.get().active = true;
}
}
- if(buy_bubble.get()){
+ if (buy_bubble.get()) {
auto sprites = this->get_components_by_tag<Sprite>(BUY_BUBBLE);
- for(auto sprite : sprites){
+ for (auto sprite : sprites) {
sprite.get().active = false;
}
auto buttons = this->get_components_by_tag<Button>(BUY_BUBBLE);
- for(auto btn : buttons){
+ for (auto btn : buttons) {
btn.get().active = false;
}
auto texts = this->get_components_by_tag<Text>(BUY_BUBBLE);
- for(auto txt : texts){
+ for (auto txt : texts) {
txt.get().active = false;
}
auto sprites1 = this->get_components_by_tag<Sprite>(SELECT_BUBBLE);
- for(auto sprite : sprites1){
+ for (auto sprite : sprites1) {
sprite.get().active = true;
}
auto buttons1 = this->get_components_by_tag<Button>(SELECT_BUBBLE);
- for(auto btn : buttons1){
+ for (auto btn : buttons1) {
btn.get().active = true;
}
auto texts1 = this->get_components_by_tag<Text>(SELECT_BUBBLE);
- for(auto txt : texts1){
+ for (auto txt : texts1) {
txt.get().active = true;
}
- }
- else {
+ } else {
auto sprites = this->get_components_by_tag<Sprite>(SELECT_BUBBLE);
- for(auto sprite : sprites){
+ for (auto sprite : sprites) {
sprite.get().active = false;
}
auto buttons = this->get_components_by_tag<Button>(SELECT_BUBBLE);
- for(auto btn : buttons){
+ for (auto btn : buttons) {
btn.get().active = false;
}
auto texts = this->get_components_by_tag<Text>(SELECT_BUBBLE);
- for(auto txt : texts){
+ for (auto txt : texts) {
txt.get().active = false;
}
auto sprites1 = this->get_components_by_tag<Sprite>(BUY_BUBBLE);
- for(auto sprite : sprites1){
+ for (auto sprite : sprites1) {
sprite.get().active = true;
}
auto buttons1 = this->get_components_by_tag<Button>(BUY_BUBBLE);
- for(auto btn : buttons1){
+ for (auto btn : buttons1) {
btn.get().active = true;
}
auto texts1 = this->get_components_by_tag<Text>(BUY_BUBBLE);
- for(auto txt : texts1){
+ for (auto txt : texts1) {
txt.get().active = true;
}
}
diff --git a/game/menus/shop/ShopMenuScene.cpp b/game/menus/shop/ShopMenuScene.cpp
index fc7323b..641352c 100644
--- a/game/menus/shop/ShopMenuScene.cpp
+++ b/game/menus/shop/ShopMenuScene.cpp
@@ -9,10 +9,10 @@
#include "menus/shop/ShopLoadScript.h"
#include "types.h"
+#include "Shopconfig.h"
#include <crepe/api/Camera.h>
#include <crepe/api/Sprite.h>
#include <crepe/api/Text.h>
-#include "Shopconfig.h"
using namespace crepe;
using namespace std;
@@ -58,8 +58,6 @@ void ShopMenuScene::load_scene() {
}
);
-
-
const float CHAR_SIZE = 16;
const float CHAR_SIZE_COIN = 16;
crepe::vec2 size;
@@ -75,7 +73,9 @@ void ShopMenuScene::load_scene() {
);
const string BULLETS_STRING = "BULLETS";
- size = {CHAR_SIZE*BULLETS_STRING.size(), (CHAR_SIZE*BULLETS_STRING.size() / BULLETS_STRING.size()) * 2};
+ size
+ = {CHAR_SIZE * BULLETS_STRING.size(),
+ (CHAR_SIZE * BULLETS_STRING.size() / BULLETS_STRING.size()) * 2};
shop_item_bullet.add_component<Text>(
size, FONT,
@@ -95,7 +95,9 @@ void ShopMenuScene::load_scene() {
);
const string BULLETS_GOLD_STRING = "0";
- size = {CHAR_SIZE_COIN*BULLETS_GOLD_STRING.size(), (CHAR_SIZE_COIN*BULLETS_GOLD_STRING.size() / BULLETS_GOLD_STRING.size()) * 2};
+ size
+ = {CHAR_SIZE_COIN * BULLETS_GOLD_STRING.size(),
+ (CHAR_SIZE_COIN * BULLETS_GOLD_STRING.size() / BULLETS_GOLD_STRING.size()) * 2};
shop_item_bullet.add_component<Text>(
size, FONT,
Text::Data {
@@ -116,7 +118,9 @@ void ShopMenuScene::load_scene() {
);
const string BUBBLE_STRING = "BUBBLE";
- size = {CHAR_SIZE*BUBBLE_STRING.size(), (CHAR_SIZE*BUBBLE_STRING.size() / BUBBLE_STRING.size()) * 2};
+ size
+ = {CHAR_SIZE * BUBBLE_STRING.size(),
+ (CHAR_SIZE * BUBBLE_STRING.size() / BUBBLE_STRING.size()) * 2};
shop_item_bubble.add_component<Text>(
size, FONT,
Text::Data {
@@ -135,7 +139,9 @@ void ShopMenuScene::load_scene() {
);
const string BUBBLE_GOLD_STRING = "1000";
- size = {CHAR_SIZE_COIN*BUBBLE_GOLD_STRING.size(), (CHAR_SIZE_COIN*BUBBLE_GOLD_STRING.size() / BUBBLE_GOLD_STRING.size()) * 2};
+ size
+ = {CHAR_SIZE_COIN * BUBBLE_GOLD_STRING.size(),
+ (CHAR_SIZE_COIN * BUBBLE_GOLD_STRING.size() / BUBBLE_GOLD_STRING.size()) * 2};
shop_item_bubble.add_component<Text>(
size, FONT,
Text::Data {
@@ -205,7 +211,6 @@ void ShopMenuScene::load_scene() {
.btn_side_color = ButtonSubScene::ButtonSideColor::PURPLE
}
);
-
}
string ShopMenuScene::get_name() const { return SHOP_SCENE; }
diff --git a/game/menus/shop/Shopconfig.h b/game/menus/shop/Shopconfig.h
index 04c8c5c..a686242 100644
--- a/game/menus/shop/Shopconfig.h
+++ b/game/menus/shop/Shopconfig.h
@@ -7,10 +7,8 @@ static constexpr const char * SELECT_BULLET = "SELECT_BULLET";
static constexpr const char * BUY_BUBBLE = "BUY_BUBBLE";
static constexpr const char * SELECT_BUBBLE = "SELECT_BUBBLE";
-
//save_data
static constexpr const char * BUY_BULLET_SAVE = "BUY_BULLET_SAVE";
static constexpr const char * BUY_BUBBLE_SAVE = "BUY_BUBBLE_SAVE";
-
struct ShopUpdate : public crepe::Event {};