SFML community forums
Help => General => Topic started by: lezebulon 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 :
(http://development.objectvideo.com/hl2console.png)
Is there a way to do this easily?
-
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
-
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...
-
I wrote one a while back which used std::function / lambdas. I did a blog post (http://trederia.blogspot.co.uk/2014/02/creating-command-console.html) on it, and there's some source on my github page (https://github.com/fallahn/crush/blob/master/include/Console.hpp). It's on my list of things to revisit and tidy up soon :)
-
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.
-
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 :(