Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML ingame console?  (Read 4286 times)

0 Members and 1 Guest are viewing this topic.

lezebulon

  • Full Member
  • ***
  • Posts: 235
    • View Profile
SFML ingame console?
« on: December 24, 2015, 12:52:49 am »
Hi!
is there a code snippet somewhere or a full source code on how to make a in-game "console" window in sfml?
basically :
- a text area is shown that will display what text is entered
- when enter is pressed, the text that was entered goes into a variable and an event is fired
- show output may or may not be displayed in the console window
Basically this :


Is there a way to do this easily?

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: SFML ingame console?
« Reply #1 on: December 24, 2015, 02:00:49 am »
I've made myself one for Lua: http://en.sfml-dev.org/forums/index.php?topic=15962
I need to update the first post I guess :P, I didn't bother since commits are small, explain stuff well and there is an example and code itself is well commented out too. And there wasn't any visible interest after few initial posts and I was basically talking to myself.

And I mention another one here but I never tried it out personally: http://en.sfml-dev.org/forums/index.php?topic=15962.msg114285#msg114285
« Last Edit: December 24, 2015, 02:08:59 am by FRex »
Back to C++ gamedev with SFML in May 2023

lezebulon

  • Full Member
  • ***
  • Posts: 235
    • View Profile
Re: SFML ingame console?
« Reply #2 on: December 24, 2015, 01:48:29 pm »
Very nice ! I'll have a try with this later after christmas :)

BTW I looked at the source code, but is it really necessary to draw everything glyph by glyph, making a new quad for each character? I honestly don't know how it is possible to do it differently, but I find it strange that it requires to go that much into "low-level" details to do a console...

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: SFML ingame console?
« Reply #3 on: December 24, 2015, 05:15:07 pm »
I wrote one a while back which used std::function / lambdas. I did a blog post on it, and there's some source on my github page. It's on my list of things to revisit and tidy up soon :)

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: SFML ingame console?
« Reply #4 on: December 24, 2015, 06:34:18 pm »
I could have used a few sf::Text instances but I decided to copy its' code and modify it a bit instead so entire console draws in few (now even one because I added background and cursor to that vertex array too) calls. I just liked it better, it's more efficient, it's not a big deal compared to model code, etc.
Back to C++ gamedev with SFML in May 2023

Sanction

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
Re: SFML ingame console?
« Reply #5 on: December 30, 2015, 07:04:08 pm »
This is the console I created after help from the guys in IRC chat.
link: https://github.com/SanctionMan/SFML_Game/blob/master/SFML_Game/Console.cpp

It could use some cleanup but hey.. it did work.. I never did add commands like I wanted to :(
Knowledge comes, but wisdom lingers. It may not be difficult to store up in the mind a vast quantity of facts within a comparatively short time, but the ability to form judgments requires the severe discipline of hard work and the tempering heat of experience and maturity.