New UITextComponent implemented
This commit is contained in:
@ -18,20 +18,20 @@
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include "../assetmgr/AssetManager.h"
|
||||
#include "../ui/UIText.h"
|
||||
// #include "../ui/UIText.h"
|
||||
#include "../ui/UINineSlice.h"
|
||||
#include "../cjson/cJSON.h"
|
||||
|
||||
Map* map;
|
||||
Manager manager;
|
||||
UIText* text;
|
||||
// UIText* text;
|
||||
UINineSlice* my9Slice;
|
||||
UIText* scoreboardText;
|
||||
// UIText* scoreboardText;
|
||||
UINineSlice* scoreboard9Slice;
|
||||
UINineSlice* debugBox;
|
||||
UIText* debugStaticText;
|
||||
UIText* debugdynamicText;
|
||||
UIText* debugJumpText;
|
||||
// UIText* debugStaticText;
|
||||
// UIText* debugdynamicText;
|
||||
// UIText* debugJumpText;
|
||||
|
||||
GameStateManager* Game::gsm = new GameStateManager();
|
||||
|
||||
@ -141,8 +141,8 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
|
||||
// std::string myText = "Find lost puppies!\nThey need your help!";
|
||||
std::string myText = "Press U to Start";
|
||||
|
||||
text = new UIText(myText, "font", 0, 0, 8, 12, globalScale);
|
||||
text->ParseString(myText, 12, 22, globalScale, "text",Game::groupUI_Layer1);
|
||||
// text = new UIText(myText, "font", 0, 0, 8, 12, globalScale, "start instructions", Game::groupUI_Layer1);
|
||||
// text->ParseString(myText, 12, 22, globalScale, "text",Game::groupUI_Layer1);
|
||||
SDL_Rect myDestRect = SDL_Rect();
|
||||
myDestRect.x = 12;
|
||||
myDestRect.y = 8;
|
||||
@ -151,39 +151,42 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
|
||||
my9Slice = new UINineSlice("textBox");
|
||||
my9Slice->MakeSlices("textBox",32,32,14,16,14,16,myDestRect,globalScale,Game::groupUI_Layer0);
|
||||
|
||||
uiInfo.addComponent<TransformComponent>(160,120,64,32,1);
|
||||
uiInfo.addComponent<UITextComponent>("font", "UI Text works again!", 8, 12, 1);
|
||||
uiInfo.addGroup(groupUI_Layer3);
|
||||
// debug UI text
|
||||
UIText* debugStaticText2;
|
||||
/* UIText* debugStaticText2;
|
||||
UIText* debugStaticText3;
|
||||
UIText* debugStaticText4;
|
||||
UIText* debugStaticText5;
|
||||
UIText* debugStaticText6;
|
||||
UIText* debugStaticText7;
|
||||
UIText* debugStaticText7; */
|
||||
|
||||
|
||||
std::string debugStaticString = "Collision";
|
||||
debugStaticText = new UIText(debugStaticString, "font", 0,0,8,12,1);
|
||||
debugStaticText->ParseString(debugStaticString,camera.w-100*globalScale,14*gScale,1,"debug",Game::groupUI_Layer3);
|
||||
std::string debugStaticString2 = "Hori:";
|
||||
debugStaticText2 = new UIText(debugStaticString2, "font", 0,0,8,12,1);
|
||||
debugStaticText2->ParseString(debugStaticString2,camera.w-100*globalScale,24*gScale,1,"debug",Game::groupUI_Layer3);
|
||||
std::string debugStaticString3 = "Vert:";
|
||||
debugStaticText3 = new UIText(debugStaticString3, "font", 0,0,8,12,1);
|
||||
debugStaticText3->ParseString(debugStaticString3,camera.w-100*globalScale,34*gScale,1,"debug",Game::groupUI_Layer3);
|
||||
std::string debugStaticString4 = "Jump:";
|
||||
debugStaticText4 = new UIText(debugStaticString4, "font", 0,0,8,12,1);
|
||||
debugStaticText4->ParseString(debugStaticString4,camera.w-100*globalScale,44*gScale,1,"debug",Game::groupUI_Layer3);
|
||||
std::string debugStaticString5 = "P.y :";
|
||||
debugStaticText5 = new UIText(debugStaticString5, "font", 0,0,8,12,1);
|
||||
debugStaticText5->ParseString(debugStaticString5,camera.w-100*globalScale,54*gScale,1,"debug",Game::groupUI_Layer3);
|
||||
std::string debugStaticString6 = "P.dy:";
|
||||
debugStaticText6 = new UIText(debugStaticString6, "font", 0,0,8,12,1);
|
||||
debugStaticText6->ParseString(debugStaticString6,camera.w-100*globalScale,64*gScale,1,"debug",Game::groupUI_Layer3);
|
||||
std::string debugStaticString7 = "YVec:";
|
||||
debugStaticText7 = new UIText(debugStaticString7, "font", 0,0,8,12,1);
|
||||
debugStaticText7->ParseString(debugStaticString7,camera.w-100*globalScale,74*gScale,1,"debug",Game::groupUI_Layer3);
|
||||
|
||||
debugJumpText = new UIText(Game::BoolToString(playerIsJumping), "font", 0,0,8,12,1);
|
||||
debugJumpText->ParseString(Game::BoolToString(playerIsJumping),camera.w-50*globalScale,44*gScale,1,"debugJumpText",Game::groupUI_Layer3);
|
||||
// std::string debugStaticString = "Collision";
|
||||
// debugStaticText = new UIText(debugStaticString, "font", 0,0,8,12,1,"debug text",Game::groupUI_Layer3);
|
||||
// debugStaticText->ParseString(debugStaticString,camera.w-100*globalScale,14*gScale,1,"debug",Game::groupUI_Layer3);
|
||||
// std::string debugStaticString2 = "Hori:";
|
||||
// debugStaticText2 = new UIText(debugStaticString2, "font", 0,0,8,12,1,"debug text",Game::groupUI_Layer3);
|
||||
// debugStaticText2->ParseString(debugStaticString2,camera.w-100*globalScale,24*gScale,1,"debug",Game::groupUI_Layer3);
|
||||
// std::string debugStaticString3 = "Vert:";
|
||||
// debugStaticText3 = new UIText(debugStaticString3, "font", 0,0,8,12,1,"debug text",Game::groupUI_Layer3);
|
||||
// debugStaticText3->ParseString(debugStaticString3,camera.w-100*globalScale,34*gScale,1,"debug",Game::groupUI_Layer3);
|
||||
// std::string debugStaticString4 = "Jump:";
|
||||
// debugStaticText4 = new UIText(debugStaticString4, "font", 0,0,8,12,1,"debug text",Game::groupUI_Layer3);
|
||||
// debugStaticText4->ParseString(debugStaticString4,camera.w-100*globalScale,44*gScale,1,"debug",Game::groupUI_Layer3);
|
||||
// std::string debugStaticString5 = "P.y :";
|
||||
// debugStaticText5 = new UIText(debugStaticString5, "font", 0,0,8,12,1,"debug text",Game::groupUI_Layer3);
|
||||
// debugStaticText5->ParseString(debugStaticString5,camera.w-100*globalScale,54*gScale,1,"debug",Game::groupUI_Layer3);
|
||||
// std::string debugStaticString6 = "P.dy:";
|
||||
// debugStaticText6 = new UIText(debugStaticString6, "font", 0,0,8,12,1,"debug text",Game::groupUI_Layer3);
|
||||
// debugStaticText6->ParseString(debugStaticString6,camera.w-100*globalScale,64*gScale,1,"debug",Game::groupUI_Layer3);
|
||||
// std::string debugStaticString7 = "YVec:";
|
||||
// debugStaticText7 = new UIText(debugStaticString7, "font", 0,0,8,12,1,"debug text",Game::groupUI_Layer3);
|
||||
// debugStaticText7->ParseString(debugStaticString7,camera.w-100*globalScale,74*gScale,1,"debug",Game::groupUI_Layer3);
|
||||
//
|
||||
// debugJumpText = new UIText(Game::BoolToString(playerIsJumping), "font", 0,0,8,12,1,"debug text",Game::groupUI_Layer3);
|
||||
// debugJumpText->ParseString(Game::BoolToString(playerIsJumping),camera.w-50*globalScale,44*gScale,1,"debugJumpText",Game::groupUI_Layer3);
|
||||
|
||||
// debug UI box
|
||||
SDL_Rect debugBoxRect = SDL_Rect();
|
||||
@ -194,7 +197,7 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
|
||||
debugBox = new UINineSlice("textBox");
|
||||
debugBox->MakeSlices("textBox",32,32,14,16,14,16,debugBoxRect,1,Game::groupUI_Layer2);
|
||||
|
||||
printf("camera.w: %d \n",camera.w);
|
||||
// printf("camera.w: %d \n",camera.w);
|
||||
|
||||
//ecs implementation
|
||||
|
||||
@ -255,6 +258,8 @@ void Game::update()
|
||||
SDL_Rect playerCol = player.getComponent<ColliderComponent>().collider;
|
||||
Vector2D playerPos = player.getComponent<TransformComponent>().position;
|
||||
|
||||
uiInfo.getComponent<UITextComponent>().updateString("New Text Works!");
|
||||
|
||||
// if (gsm->currentState == GameStateManager::ST_INIT)
|
||||
// {
|
||||
// const char* initText = "Loading...";
|
||||
@ -308,6 +313,7 @@ void Game::update()
|
||||
// Gravity
|
||||
if (gravityOnPlayer){
|
||||
player.getComponent<TransformComponent>().position.y += 3*gScale;
|
||||
// debugJumpText->ParseString(Game::BoolToString(playerIsJumping),camera.w-50*gScale,44*gScale,1,"debugJumpText",Game::groupUI_Layer3);
|
||||
}
|
||||
// for(auto& p: projectiles)
|
||||
// {
|
||||
@ -387,9 +393,9 @@ void Game::render()
|
||||
{
|
||||
guiElement->draw();
|
||||
}
|
||||
for (auto& letter : uiText)
|
||||
for (auto& text : uiText)
|
||||
{
|
||||
letter->draw();
|
||||
text->draw();
|
||||
}
|
||||
}
|
||||
if (debugMenu)
|
||||
@ -398,9 +404,9 @@ void Game::render()
|
||||
{
|
||||
guiElement->draw();
|
||||
}
|
||||
for (auto& letter : debugText)
|
||||
for (auto& text : debugText)
|
||||
{
|
||||
letter->draw();
|
||||
text->draw();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user