Some of libtcod's functions are depreciated #99
Replies: 105 comments 112 replies
-
Nothing dangerous will happen from ignoring them, but these functions will not be forward compatible with later versions of libtcod. You can use the porting guide to help with most of these. This guide shows a sample program without deprecated functions. Be sure to ask about anything not mentioned in the documentation, which is likely still full of gaps. |
Beta Was this translation helpful? Give feedback.
-
For the latest docs, I recommend adding snippets of code for every function, because as someone new to this lib, I'm having difficulties understanding it. |
Beta Was this translation helpful? Give feedback.
-
Code examples are something I'm trying to do more of, but it takes time to get around to it. Anything not mentioned in the porting guide should work without warnings for examples from the older documentation. |
Beta Was this translation helpful? Give feedback.
-
Just tried compiling it statically, can say it ended badly
|
Beta Was this translation helpful? Give feedback.
-
Well, how would you recommend me to do if I were to write a game with this lib, package it into one folder? Like basically when you clone the repo you can start playing without having to install SDL or libtcod? |
Beta Was this translation helpful? Give feedback.
-
As you might be able to tell from the link errors. SDL2 and zlib are required to be available at link time. This might be an issue with libtcod's I don't know, but the error is that the SDL2/zlib libs were wanted but weren't provided.
I currently recommend Vcpkg and CMake for packaging an executable or building dependencies automatically. I base any new C/C++ projects off of this template. You can use Vcpkg/CMake without the template and that will get you an older stable version of libtcod instead of the development versions. |
Beta Was this translation helpful? Give feedback.
-
Also, I have another question, since the default font is a bit unclear and it hurts my eyes to look at it, I've decided to use my own .ttf file, but after some digging at your samples, seems like I have to convert it to a .png or something? |
Beta Was this translation helpful? Give feedback.
-
Libtcod has experimental functions of TTF loading but I was never sure if the quality was consistent. They're shown in this header file and are not in a stable part of the API. |
Beta Was this translation helpful? Give feedback.
-
Well then what's the stable way of loading it? |
Beta Was this translation helpful? Give feedback.
-
Converting the font into a tileset is technically the most stable way. Using the experimental functions should be good enough, since they won't be going away until after a real solution exists. |
Beta Was this translation helpful? Give feedback.
-
Is there any documentation about how to convert the font into a tileset? |
Beta Was this translation helpful? Give feedback.
-
You might use a tool like this. It's easier to find existing Code Page 437 tilesets than to make them from a TTF file. You're on your own if you plan on creating your own tilesets. |
Beta Was this translation helpful? Give feedback.
-
Alright then, I have another question, lets say I declared a new window
What is the best way to pass it into a function? |
Beta Was this translation helpful? Give feedback.
-
Always by reference unless you are passing ownership. Pass by pointer if you have to use a C function for some reason. The type is a usual |
Beta Was this translation helpful? Give feedback.
-
I found this terminal-blues bitmap font
Here is how I applied it, but somehow I don't see the font. Did I do anything wrong? |
Beta Was this translation helpful? Give feedback.
-
Alright, after a couple cups of coffee I managed to get from 1200 errors down to 500 errors. I don't understand the difference between manually doing something like this std::string get_string(tcod::ConsolePtr &main_win, tcod::ContextPtr &context, std::string original){
std::string input;
clear_and_draw_dialog(main_win, context, "([ESC] to cancel) Rename item to: ");
int ch;
while(true){
ch=SDL_getch(main_win, context);
if(ch==SDLK_RETURN&&input.length()>0){ // KEY_ENTER
return input;
}
if(ch==SDLK_BACKSPACE){ // KEY_BACKSPACE
if(input.length()>0){
input.pop_back();
}
}
if(ch==SDLK_ESCAPE){ // KEY_ESC
return original;
}
else if(input.length()<30&&(isdigit(ch)||isalpha(ch)||isblank(ch))){
input.push_back(ch);
}
std::stringstream ss;
ss<<"Rename item to: "<<input;
clear_and_draw_dialog(main_win, context, ss.str());
}
} and using this https://wiki.libsdl.org/Tutorials-TextInput |
Beta Was this translation helpful? Give feedback.
-
So to clear an area to the default colors, I should do something like this right? void SDL_wclear_dialog_bar(tcod::ConsolePtr &main_win, tcod::ContextPtr &context){
tcod::draw_rect(*main_win, {0, 0, 80, 1}, ' ', nullptr, nullptr);
context->present(*main_win);
} |
Beta Was this translation helpful? Give feedback.
-
The source code to this project is in this branch -> https://github.com/epixinvites/wayventure/tree/develop-libtcod |
Beta Was this translation helpful? Give feedback.
-
Which function in SDL2 should I use to check if the current window has keyboard focus? Debugging and testing around has made me realise that SDL2 is taking every single mouse and keyboard input, even when I'm not focused on the window. |
Beta Was this translation helpful? Give feedback.
-
Thanks for spending time to guide me :) I've added a special thanks to you in my project's README |
Beta Was this translation helpful? Give feedback.
-
So, how am I supposed to compile this lib to Windows? |
Beta Was this translation helpful? Give feedback.
-
Is it possible to get keyboard input without depending on SDL2? |
Beta Was this translation helpful? Give feedback.
-
I've noticed if I call functions like |
Beta Was this translation helpful? Give feedback.
-
Can you create a definite guide to statically compiling libtcod along with SDL2? I've been stuck at the SegFault for weeks. |
Beta Was this translation helpful? Give feedback.
-
While I was building libtcod from the latest git commit, I ran
|
Beta Was this translation helpful? Give feedback.
-
What's the best way you'd recommend for me to turn my game into a package? What I mean is basically like a .tar.gz and you can just do I've just realised that trying to statically compile it isn't always the best solution. |
Beta Was this translation helpful? Give feedback.
-
wayventure-client.tar.gz |
Beta Was this translation helpful? Give feedback.
-
Well I just downloaded the new 1.19.0 release and tried compiling with it
|
Beta Was this translation helpful? Give feedback.
-
So apparently these functions are depreciated, what are the replacements for these functions? |
Beta Was this translation helpful? Give feedback.
-
Is TTF fonts loading supported yet? I would love to substitute my current tileset for some monospaced font. And by the way, if it's possible to load TTF fonts now, how am I supposed to set the font size? |
Beta Was this translation helpful? Give feedback.
-
I'm using
g++ (GCC) 11.1.0
andsdl2 2.0.16-2
.My host system is Arch Linux.
This is the code,
This is the compile command,
These are the warnings:
Can I safely ignore these warnings? Or are they even supposed to happen?
Beta Was this translation helpful? Give feedback.
All reactions