Skip to content

Commit

Permalink
UI Shop Buttons and Bar Resources
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricGDV committed Apr 16, 2020
1 parent 1624f6c commit 70e90b6
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 16 deletions.
Binary file modified PaintWars/Project II Game/Game/textures/Barracks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified PaintWars/Project II Game/Game/textures/PaintExtractor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified PaintWars/Project II Game/Game/textures/Spawner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified PaintWars/Project II Game/Game/textures/TownHall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified PaintWars/Project II Game/Game/textures/UI/UI_atlas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified PaintWars/Project II Game/Game/textures/WoodProducer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 45 additions & 7 deletions PaintWars/Project II Game/Motor2D/GameScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ bool GameScene::Start()

//HUD - Bar
hudBarImage = App->gui->AddElement(GUItype::GUI_IMAGE, nullptr, { 15 , 5 }, { 0 , 0 }, false, true, { 0, 1353, 1250, 35 }, nullptr, nullptr, false, false, SCROLL_TYPE::SCROLL_NONE, true, TEXTURE::ATLAS);
paintLabel = App->gui->AddElement(GUItype::GUI_LABEL, hudBarImage, { 100 , 10 }, { 2 , 0 }, false, true, { 0, 0, 0, 0 }, "0", nullptr, false, false, SCROLL_TYPE::SCROLL_NONE, true, TEXTURE::ATLAS, FONT::FONT_SMALL);
woodLabel = App->gui->AddElement(GUItype::GUI_LABEL, hudBarImage, { 200 , 5 }, { 2 , 0 }, false, true, { 0, 0, 0, 0 }, "0", nullptr, false, false, SCROLL_TYPE::SCROLL_NONE, true, TEXTURE::ATLAS, FONT::FONT_SMALL);
metalLabel = App->gui->AddElement(GUItype::GUI_LABEL, hudBarImage, { 300 , 5 }, { 2 , 0 }, false, true, { 0, 0, 0, 0 }, "0", nullptr, false, false, SCROLL_TYPE::SCROLL_NONE, true, TEXTURE::ATLAS, FONT::FONT_SMALL);
titaniumLabel = App->gui->AddElement(GUItype::GUI_LABEL, hudBarImage, { 400 , 5 }, { 2 , 0 }, false, true, { 0, 0, 0, 0 }, "0", nullptr, false, false, SCROLL_TYPE::SCROLL_NONE, true, TEXTURE::ATLAS, FONT::FONT_SMALL);
researchLabel = App->gui->AddElement(GUItype::GUI_LABEL, hudBarImage, { 500 , 5 }, { 2 , 0 }, false, true, { 0, 0, 0, 0 }, "0", nullptr, false, false, SCROLL_TYPE::SCROLL_NONE, true, TEXTURE::ATLAS, FONT::FONT_SMALL);
entitiesLabel = App->gui->AddElement(GUItype::GUI_LABEL, hudBarImage, { 670 , 5 }, { 2 , 0 }, false, true, { 0, 0, 0, 0 }, "0", nullptr, false, false, SCROLL_TYPE::SCROLL_NONE, true, TEXTURE::ATLAS, FONT::FONT_SMALL);

//HUD - Quests
questsImage = App->gui->AddElement(GUItype::GUI_IMAGE, nullptr, { 15 , 50 }, { 0 , 0 }, false, true, { 0, 1388, 263, 40 }, nullptr, nullptr, false, false, SCROLL_TYPE::SCROLL_NONE, true, TEXTURE::ATLAS);
Expand Down Expand Up @@ -214,8 +220,17 @@ bool GameScene::Start()
noButton->click_rect = { 1437, 359, 166, 57 };

// Shop
shopImage = App->gui->AddElement(GUItype::GUI_IMAGE, nullptr, { 15 , 450 }, { 0 , 0 }, false, false, { 0, 1388, 263, 265 }, nullptr, nullptr, false, false, SCROLL_TYPE::SCROLL_NONE, true, TEXTURE::ATLAS);
shopImage = App->gui->AddElement(GUItype::GUI_IMAGE, nullptr, { 15 , 450 }, { 0 , 0 }, false, false, { 263, 1551, 263, 265 }, nullptr, nullptr, false, false, SCROLL_TYPE::SCROLL_NONE, true, TEXTURE::ATLAS);
shopLabel = App->gui->AddElement(GUItype::GUI_LABEL, shopImage, { 15 , 452 }, { 2 , 2 }, false, false, { 0, 0, 0, 0 }, "SHOP", nullptr, false, false, SCROLL_TYPE::SCROLL_NONE, true, TEXTURE::ATLAS, FONT::FONT_SMALL_WHITE);
buyWoodProducerButton = App->gui->AddElement(GUItype::GUI_BUTTON, shopImage, { 15, 485 }, { 0,0 }, true, false, { 1985, 1966, 65, 82 }, nullptr, App->scenes, false , false, SCROLL_TYPE::SCROLL_NONE, true, TEXTURE::ATLAS, FONT::FONT_SMALL, 6);
buyWoodProducerButton->hover_rect = { 0, 1966, 65, 82 };
buyWoodProducerButton->click_rect = { 65, 1966, 65, 82 };
buyPaintExtractorButton = App->gui->AddElement(GUItype::GUI_BUTTON, shopImage, { 80, 485 }, { 0,0 }, true, false, { 1985, 1966, 65, 82 }, nullptr, App->scenes, false, false, SCROLL_TYPE::SCROLL_NONE, true, TEXTURE::ATLAS, FONT::FONT_SMALL, 6);
buyPaintExtractorButton->hover_rect = { 0, 1966, 65, 82 };
buyPaintExtractorButton->click_rect = { 65, 1966, 65, 82 };
buyBarrackButton = App->gui->AddElement(GUItype::GUI_BUTTON, shopImage, { 145, 485 }, { 0,0 }, true, false, { 1985, 1966, 65, 82 }, nullptr, App->scenes, false, false, SCROLL_TYPE::SCROLL_NONE, true, TEXTURE::ATLAS, FONT::FONT_SMALL, 6);
buyBarrackButton->hover_rect = { 0, 1966, 65, 82 };
buyBarrackButton->click_rect = { 65, 1966, 65, 82 };

//shopLabel = App->gui->AddElement(GUItype::GUI_LABEL, shopImage, { 985 , 352 }, { 2 , 2 }, false, false, { 0, 0, 0, 0 }, "", nullptr, false, false, SCROLL_TYPE::SCROLL_NONE, true, TEXTURE::ATLAS, FONT::FONT_SMALL_WHITE);

Expand Down Expand Up @@ -462,6 +477,8 @@ bool GameScene::CleanUp()
void GameScene::GUI_Event_Manager(GUI_Event type, j1Element* element)
{

//Minimap

if (element == miniMapMINI && type == GUI_Event::EVENT_ONCLICK) {
miniMapBack->enabled = true;
miniMapFULL->enabled = true;
Expand All @@ -475,6 +492,10 @@ void GameScene::GUI_Event_Manager(GUI_Event type, j1Element* element)
miniMapFULL->enabled = false;
miniMapCamera->enabled = true;
}


//Quests

if (element == questsOpenButton && type == GUI_Event::EVENT_ONCLICK)
{
questsImage->rect.h = 360;
Expand All @@ -489,17 +510,35 @@ void GameScene::GUI_Event_Manager(GUI_Event type, j1Element* element)
questsCloseButton->enabled = false;
}


//HomeButton

if (element == homeButton && type == GUI_Event::EVENT_ONCLICK)
{
App->render->camera.x = 0;
App->render->camera.y = 0;
}


//Shop

if (element == shopButton && type == GUI_Event::EVENT_ONCLICK)
{
shopMenu = !shopMenu;
shopImage->enabled = !shopImage->enabled;
shopLabel->enabled = !shopLabel->enabled;
buyWoodProducerButton->enabled = !buyWoodProducerButton->enabled;
buyPaintExtractorButton->enabled = !buyPaintExtractorButton->enabled;
buyBarrackButton->enabled = !buyBarrackButton->enabled;
}

if (element == buyWoodProducerButton && type == GUI_Event::EVENT_ONCLICK)
{

}


//Pause Menu

if (element == pauseMenuButton && type == GUI_Event::EVENT_ONCLICK)
{
App->PAUSE_ACTIVE = true;
Expand Down Expand Up @@ -606,6 +645,9 @@ void GameScene::GUI_Event_Manager(GUI_Event type, j1Element* element)
backButton->enabled = false;
}


//Disclaimers

if (element == restartButton && type == GUI_Event::EVENT_ONCLICK)
{
restartMenu = true;
Expand Down Expand Up @@ -728,11 +770,7 @@ void GameScene::GUI_Event_Manager(GUI_Event type, j1Element* element)
noButton->enabled = false;
}

if (element == shopButton && type == GUI_Event::EVENT_ONCLICK)
{
shopImage->enabled = !shopImage->enabled;
shopLabel->enabled = !shopLabel->enabled;
}


}

Expand Down
10 changes: 3 additions & 7 deletions PaintWars/Project II Game/Motor2D/GameScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,11 @@ class GameScene : public Scene

//HUD - Bar
j1Element* hudBarImage = nullptr;
j1Element* paintImage = nullptr;
j1Element* paintLabel = nullptr;
j1Element* woodImage = nullptr;
j1Element* woodLabel = nullptr;
j1Element* metalImage = nullptr;
j1Element* metalLabel = nullptr;
j1Element* titaniumImage = nullptr;
j1Element* titaniumLabel = nullptr;
j1Element* foodImage = nullptr;
j1Element* foodLabel = nullptr;
j1Element* researchImage = nullptr;
j1Element* researchLabel = nullptr;
j1Element* entitiesImage = nullptr;
j1Element* entitiesLabel = nullptr;
Expand All @@ -99,7 +93,6 @@ class GameScene : public Scene
j1Element* pauseMenuButton = nullptr;
bool pauseMenu = false;
j1Element* shopButton = nullptr;
bool shopMenu = false;
j1Element* restartButton = nullptr;
bool restartMenu = false;

Expand Down Expand Up @@ -142,6 +135,9 @@ class GameScene : public Scene
// Shop
j1Element* shopImage = nullptr;
j1Element* shopLabel = nullptr;
j1Element* buyPaintExtractorButton = nullptr;
j1Element* buyWoodProducerButton = nullptr;
j1Element* buyBarrackButton = nullptr;
bool debugTile = true;


Expand Down
2 changes: 1 addition & 1 deletion PaintWars/Project II Game/Motor2D/Motor2D.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ProjectGuid>{2AF9969B-F202-497B-AF30-7BEF9CE8005E}</ProjectGuid>
<RootNamespace>programacio_2</RootNamespace>
<ProjectName>PaintWars_by_BrainDeadStudios</ProjectName>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand Down
3 changes: 2 additions & 1 deletion PaintWars/Project II Game/Motor2D/j1GUIElements.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ enum class FONT
FONT_SMALL,
FONT_MEDIUM,
FONT_SMALL_WHITE,
FONT_LOSE_WIN
FONT_LOSE_WIN,
FONT_EXTRA_SMALL
};

enum class SCROLL_TYPE
Expand Down
2 changes: 2 additions & 0 deletions PaintWars/Project II Game/Motor2D/j1Label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ bool j1Label::Start()
font_name = App->fonts->Load("textures/font_small.png", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789= ", 2);
else if (fontType == FONT::FONT_SMALL_WHITE)
font_name = App->fonts->Load("textures/font_small_white.png", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789= ", 2);
else if (fontType == FONT::FONT_EXTRA_SMALL)
font_name = App->fonts->Load("textures/font_extra_small.png", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789= ", 2);
//else if (fontType == FONT::FONT_LOSE_WIN)
// font_name = App->fonts->Load("textures/font.png", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789= ",2);

Expand Down

0 comments on commit 70e90b6

Please sign in to comment.