Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button added #58

Merged
merged 4 commits into from Jul 20, 2021
Merged

Button added #58

merged 4 commits into from Jul 20, 2021

Conversation

requizm
Copy link
Contributor

@requizm requizm commented Jul 20, 2021

#51

Features

  • Interactive color changes with mouse.
  • Text Alignment options
  • Input Controls (OnMouseDown, OnMouseUp etc.)

Issues

  • For now, we can't draw button with filled rectangle. Because since the rectangle is rendered first, we can't see the text below it. So we will render a empty rectangle until we fix the error.
  • Text Colors seems sus. It doesn't show the same color as I want to draw. When clicking the button in the gif below, the rectangle successfully turns yellow, while the text does not completely change to yellow. Or i'm just confused.

Screenshots
wase-button-test

I am open to discussion.

@requizm
Copy link
Contributor Author

requizm commented Jul 20, 2021

Example usage:

	SDL_Color red, blue, green;
	red.r = 200;
	red.g = 0;
	red.b = 0;
	red.a = 255;
	blue.r = 0;
	blue.g = 0;
	blue.b = 200;
	blue.a = 255;
	green.r = 0;
	green.g = 200;
	green.b = 0;
	green.a = 255;

	SDL_Color redHighlighted, blueHighlighted, greenHighlighted;
	red.r = 255;
	red.g = 0;
	red.b = 0;
	red.a = 255;
	blue.r = 0;
	blue.g = 0;
	blue.b = 255;
	blue.a = 255;
	green.r = 0;
	green.g = 255;
	green.b = 0;
	green.a = 255;

	Entity *entity = entityManager.addEntity("entity");
	Button *button = entity->addComponent<Button>("Text", siz, "opensans", TextAlignment::TOP_LEFT, red, blue);
	entity->getComponent<Transform>()->setPosition(250, 250);
	button->setButtonPressEffect(true);
	button->setButtonHoverColor(blueHighlighted);
	button->setButtonPressColor(greenHighlighted);
	button->setTextHoverColor(redHighlighted);
	button->setTextPressColor(green);

@JaimieVos
Copy link
Member

@requizm thanks a lot for the big contribution, awesome! I did refactor a bit of the code because there was a lot of the BoxCollider2D class that was duplicated. With this code I don't have any problems with the colors like you mentioned. I really like how you made the text alignment.

I see the problem with the fill and the text disapearing under it. I don't think this is a quick fix so for now we could just let it be and I could open a bug issue for it. You should check out my refactored version of the code and let me know what you think and if you want to make any changes feel free to do so, if not let me know and then I will merge it.

Again big thanks for the contribution and if you ever want to pick up another issue or open one yourself if you have a cool idea feel free to do so!

@JaimieVos JaimieVos linked an issue Jul 20, 2021 that may be closed by this pull request
@JaimieVos JaimieVos added the enhancement New feature or request label Jul 20, 2021
@requizm
Copy link
Contributor Author

requizm commented Jul 20, 2021

@JelleVos1
Good job. But i have some things to say:

  • Initially, I used the BoxCollider2D component. However, if we add the BoxCollider2D component to the entity, the user will not be able to add their own BoxCollider2D to that entity. That's why I wrote myself. In addition, BoxCollider2D component has functions such as collision control with other collider components; it would be better to write another Collider system for ui elements in the future.
  • If we are going to use char* instead of std::string, we must also make these changes in the label class. While I was creating the Button class, I had copied everything from the label.

TLDR; You can merge it.

@JaimieVos
Copy link
Member

JaimieVos commented Jul 20, 2021

@JelleVos1
Good job. But i have some things to say:

* Initially, I used the BoxCollider2D component. However, if we add the BoxCollider2D component to the entity, the user will not be able to add their own BoxCollider2D to that entity. That's why I wrote myself. In addition, BoxCollider2D component has functions such as collision control with other collider components; it would be better to write another Collider system for ui elements in the future.

* If we are going to use char* instead of std::string, we must also make these changes in the label class. While I was creating the Button class, I had copied everything from the label.

TLDR; You can merge it.

Oh I didn't know I used in the Label class before too. I will change that too. I think you have a good point about the collision system for in the future because then this will become an issue however now it was many duplicated code. I think your suggestion of building a second collider system for the UI is a very good idea and I will note that. For now I will merge it.

Big thanks for the contribution, you did a great job! Feel free to pick up or create other issues.

@JaimieVos JaimieVos changed the base branch from master to development July 20, 2021 22:31
@JaimieVos JaimieVos merged commit bb1206e into Wase-Engine:development Jul 20, 2021
@JaimieVos JaimieVos self-assigned this Jul 20, 2021
@JaimieVos JaimieVos self-requested a review July 20, 2021 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Buttons
2 participants