« first day (879 days earlier)      last day (4068 days later) » 

user142019
5:00 PM
Passing it every time is good.
 
user142019
Less state = good.
 
@MooingDuck trying to understand when you need to use ::template to call a template function
 
@Zoidberg I had been thinking, function calls with that many parameters are bad design - you need to look at the documentation to figure out what it is.
 
user142019
Use decent types.
 
@TonyTheLion when the compiler tells you :( I dunno, I never got that one.
 
5:01 PM
@Zoidberg lolwut? does it use globals or singletons?
 
user142019
@Abyx wat no.
 
@Zoidberg define decent types
 
user142019
@Pawnguy7 for example, a point type instead of two doubles.
 
user142019
Or a font type instead of a string and a double.
 
user142019
struct point {
    double x, y;
};

class font {
public:
    font(std::string const& name, double size);
};
 
5:03 PM
@Zoidberg it's a free function, right? and it doesn't take any parameters like DrawingContext/Surface/whatnot.
 
user142019
@Abyx oh that can be another parameter.
 
user142019
Or make draw_text a member function of drawing_target.
 
@Zoidberg ah really? or maybe ten parameters?
your function sucks.
 
user142019
@Abyx if you need ten parameters you need ten parameters.
 
user142019
It's that simple.
 
user142019
5:05 PM
But for a draw_text function you don't.
 
@Zoidberg so it shouldn't be a free function?
 
user142019
WHATEVER
 
user142019
Just don't make a TextDrawer class or some other stupid thing like that.
 
@Zoidberg I get what you are saying. But there is style, color, font, size, position, text, and yes, there is a surface. Color is already containing r, g, b, and can include a. position, yes, could be a point. But how do you get lower? Combining style and font? Anything else seems rather odd.
 
user142019
Size is part of font.
 
user142019
5:06 PM
Two fonts with different sizes are two different fonts.
 
user142019
As per the definition of "font".
 
@Zoidberg In this library, they are separate. You propose to make a new font class with, for example, sizze and style together?
 
@Pawnguy7 style, color, font, and size should probably all be members of a thing.
 
user142019
class drawing_target {
public:
    void draw_text(font f, color c, point coords, std::string text);
    void draw_rectangle(color c, point p1, point p2, bool fill = true);
    void draw_rectangle(color c, point p1, size s, bool fill = true);
    // etc
};
 
@Pawnguy7 you're probably thinking of a font family. A font has a size.
 
5:07 PM
@MooingDuck I think you are correct. It is just, the way the library handles its text, you set the size and font separately.
 
@Pawnguy7 you set the size and the font family seperately.
@Pawnguy7 what is a "style"?
 
@MooingDuck Yes. I guess I have been corroded by the synominous use of them in the digital age.
@MooingDuck style as in underlined, italic, strikethrough
 
user142019
Italic is part of the font.
 
user142019
std::optional<T&>
 
user142019
5:14 PM
Null is bad.
 
@Zoidberg Is part of font style, along with bold, underline and strikeout
 
user142019
Italic and bold are part of the font.
 
user142019
I'm not sure about strikeout and underline.
 
@MartinJames Think printing press. A "font" is a set of stamps. If you need to change to say bold, you need a different font/set of stamps.
 
user142019
There is a difference between font family and font.
 
5:18 PM
I'm also unsure about strikes and underlines
 
user142019
Arial is a font family, Arial 12pt bold is a font.
 
Ah, the official name for "font family" is "typeface"
I can find no indication that underline/strikethrough are officially part of a font, though in any technical endeavor I would definitely put them in my font class.
 
sbi
@casperOne Because that "Zoidberg" did not refer to who I think you thought it did. And if you knew who it referred to, you would most likely not want to be here.
@BartekBanachewicz "No" what?
 
it irks me that in C++, with the allocator concept, it is immensely easier to do things the wrong way than the right way :/ When I design a new language, I'll have to (A) find a way to make allocator concepts easier or (B) simpily make the wrong way harder.
 
user1182183
 
user1182183
5:26 PM
anyone knows how to get this color for permanent only for boxes?
 
user1182183
not the whole screen
 
user1182183
and buttons
 
user1182183
googled change windows 7 system colors but nothing showed up
 
sorry, my internet connection went out.
I had tried to say:
 
user1182183
@Pawnguy7 We really noticed..
 
5:27 PM
@MooingDuck So your propose making my own font struct for use with this method, which would be composed of the libraries font (family), size, and style?
 
user142019
@Pawnguy7 Don't worry, we didn't miss you.
 
@Zoidberg I feel so much better now :D
 
@Pawnguy7 I'd probably also stick color in there. But yes. And not just "for this method".
 
Uh
Hm.
 
user1182183
@Pawnguy7 just get used to the dicks in this room, they will burn your house, take your life, and play justin bieber music without the possibility to stop it.
 
5:31 PM
@MooingDuck I feel like I will be making lots of font instances, but what I could do is, perhaps, make the fonts static const members of something. For example, the library has things like Color::Red. Similarely, Font::normalFont, Font::specialFont, and what have you.
@GamErix will do
 
user1182183
@Pawnguy7 ;p
 
@Pawnguy7 Why? Look at this page. There's one font for the chat, one for admin names, one for room owner names, one for the title, one for the catchline... but realistically, there's only like 20 or so fonts, and they pretty much never change. Why would you be making "lots of font instances?"
 
user142019
@Pawnguy7 Boost.Flyweight if you benchmarked and it turned out you had too many identical instances.
 
@Pawnguy7 oh, you changed your name. No wonder people keep talking to "Pawnguy".
 
@MooingDuck I was thinking if I were to construct a font as part of the function call every time.
 
user142019
5:33 PM
Also, you don't really need identical instances. You can reuse them.
 
On my screen you were still user0123456789
@Pawnguy7 Well obviously don't do that :P
 
user142019
font f{"Arial", 12_pt};
target.draw_text("Hello, world!", f);
target.draw_text("foobar!", f); // used the same instance! \o/
 
@MooingDuck Would it be good to have these static fonts as part of the font class/struct?
Also, on my screen since refresh, all of your @ have Pawnguy7. Go figure.
 
@Pawnguy7 I don't think so, I think it's best if the Application has a set of fonts it uses, but I don't think a standard Font::normalFont is a good idea. What happens on a system where the user doesn't have the font family for that "normal font"?
 
@MooingDuck I load the fonts. I meant to say, "normalFont" would identify, in this case, the font most used in the game.
 
5:36 PM
@Pawnguy7 I think that would encourage people to just use the "normalFont" for everything, which would be bad.
 
Xeo
Hmmm. Fail. I put the wrong customer ID on my bank transfor for the monthly power bill. :(
 
I assume you guys saw today's XKCD?
 
user142019
Yes, we did.
 
user142019
As well as the spelling fail.
 
Alright.
 
Ell
5:36 PM
I didn't
 
user142019
Now you're doing.
 
@Zoidberg I've seen that halfhearted mergesort in so many SO questions :( "I can't figure out this step! Give me teh codez!"
Also the quicksort anytime we try to discuss a detail of quicksorts.
 
@MooingDuck No, normalFont in the code. As in, only I would see it. I was just using the name as an example, it would probably be more specific, along the lines of "articleHeaderFont", etc.
 
Ell
Someone Linky por favor?
 
@Pawnguy7 I think it should be a static member of the "main program class", or something, not of your "font".
@Ell to xkcd? really? www.xkcd.com?
 
Xeo
5:39 PM
@MooingDuck That's not a link. It's not orange.
 
@MooingDuck what would you say the "main program class" is?
 
@Ell if you type x into your searchbar, as a geek, it ought to be the first hit on your computer. Or we're revoking your geekhood.
 
user142019
@Pawnguy7 There is none. You have a main function.
 
@R.MartinhoFernandes Why did you ping me there? D: I don't see what's going on.
 
@Pawnguy7 I usually have one to hold "globals".
 
5:41 PM
@MooingDuck I have done that. This for constants.
 
@Xeo if I made it a full link, it would hide some of the text and my mockery would be less obvious
 
Ell
Im on my tablet, I'm being lazy :P
 
@MooingDuck this leads to me next question. I have a Resource class. It statically loads and offers static const access to all resources (texturex, sounds, and in this case, could add fonts). Good idea?
 
@Pawnguy7 a font shouldn't be a constant I think, a user might want to change the font family or something. I dunno.
 
Xeo
@Pawnguy7 Talk to @ThePhD and @BartekBanachewicz
 
5:42 PM
I don't know what you're talking about.
It's all @BartekBanachewicz .
 
@Pawnguy7 textures and sounds sure, but not fonts. Fonts should not be hardcoded.
 
@MooingDuck I am making a game. Pong. Do such games normally aloow changes of the font, or do we have a misunderstanding?
 
@Pawnguy7 pft, I didn't know you were making pong :D
 
Xeo
Do such games normally need a resource cache?
Wait, it's not even a cache?
 
Either way, I'd just ask the OS for a font family at startup, otherwise you risk not having your hardcoded typeface available.
 
Xeo
5:43 PM
Just a bunch of globals?
@MooingDuck Can always distribute it with the game
Not unheard of
 
true
 
@MooingDuck I planned to distribute the font with the game, the library does not allow making font queries to the OS at this time
 
@Pawnguy7 then hardcoding/resource makes sense in that case.
 
@Xeo more or less, yes. It seems good organization to me: I don't need to call a load method, and I can easily access any resources from other parts of the game. For example, I could do sprite.setTexture(Resource::paddleTexture)
@MooingDuck This includes the font, which would be part of said Resource class?
 
@Pawnguy7 yeah
 
5:46 PM
Fonts are always stored in the same location, right?
And any application is always gauranteed write access to those locations, right?
 
@MooingDuck A font instance should be held by any class capable of rendering text.
 
@ThePhD I don't think so. Fonts are registered with the OS somehow I think. Though they're usually mostly in one folder.
 
Well yeah, you install them and the OS keeps a font cache for fast rendering and usage and lookup. But I'm talking about just getting to the .ttf/.otf files themselves.
 
As some background here, the graphical text class that can be rendered holds a pointer to the font, and since the fonts are const, any class which renders text could use it fine, I think.
 
@ThePhD My Windows has 389 fonts in the control panel\Fonts, and 389 in C:\Windows\Fonts. Inconclusive, but....
 
5:49 PM
275 items here.
 
Xeo
@Pawnguy7 Yay singletons!!!! NOT
 
Usually, when a font is installed, it's placed in C:/Windows/Fonts . So if you have the capability to load the font file, try to see if you can access C:/Windows/Fonts
 
@MooingDuck Yeah - there's sure to be a 'fonts' registry folder, but whether there are full file paths there or not, I don't know.
 
The next step would be to generate a font bitmap using GDI+ or FreeType.
If you can't do all of that, just make a Bitmap Font and say "Fuck unicode"
 
Also, assuming in this case the resource class, is it better/preferable for it to be static, or a globle singleton?
 
Xeo
5:52 PM
Neither
 
What do your propose instead?
 
@ThePhD "pong"
 
@Pawnguy7 not a good idea.
 
HKLM\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Fonts
 
hello, I have a console app. I use two files my.cpp and my.h, I implement all the functions in my.cpp and I run them in main func in my.cpp

then a friend uses my functions in his application. does he need to include my.h or my.cpp?

for example: I use function which has last two parameters with default values (p1,p2,p3,p4="",p5="\n")
when my friend tries to run it with only three parameters, it says it does not match
 
5:53 PM
@Pawnguy7 not using the word singleton. Use a "main program class", which contains a resource cache.
 
oh, I always lose track of how old was the plink
@Qwerty .h
 
Xeo
@MooingDuck Are you on the sane or the crazy side?!
 
@Pawnguy7 Don't use static.
 
@Qwerty he needs to include the header, and link against a compiled version of your Cpp (probably after(or as part of) compiling it himself)
 
@BartekBanachewicz but why does not it matches my func call with two default parameteres? It says I need to input more. Do I define default parameters in .h or in .cpp when implementing function?
 
5:54 PM
@Qwerty .h
 
@Xeo there's not really any other way to do things besides globals.
 
@BartekBanachewicz can you explain what is inherently bad about static?
 
@Pawnguy7 uniqueness
 
Xeo
@MooingDuck Oh, sure there is - don't make it global. :) Just pass stuff where it needs to be.
 
@Xeo "main program class" should definitely not be a singleton. User should be theoretically able to create many instances of it.
@Xeo I can't pass all 187+ parameters to all my functions. I'll stick a few of the more global-type ones that few need in a class. I'll call it: "main program class".
 
5:55 PM
Dependency injection works much better in that case
@MooingDuck what.
 
Xeo
Globals are a sure-fire way to fuck over any tries to sensibly create unittests.
 
You are totally not getting it.
Construct an object with a dependency injection. That was what @Xeo was talking about.
 
Xeo
@MooingDuck Why are they taking 187+ parameters in the first place?
 
@Xeo exactly why I suggested an alternative besides globals.
 
5:56 PM
@Xeo I have unit tests for my globals!
 
"main program class" sounds like something totally fucked up
 
Do I bother to tell the guy he really wants a keyboard hook instead of GetAsyncKeyState? Or do I just think "Keylogger -- better to not help?"
 
Xeo
@R.MartinhoFernandes Haha
 
how is that really different from globals
 
@Xeo because they call subfunctions which might need to know the state of the program.
 
5:57 PM
1 min ago, by Bartek Banachewicz
Construct an object with a dependency injection. That was what @Xeo was talking about.
 
@BartekBanachewicz I have no idea what that is/means.
 
Xeo
@MooingDuck Gimme a concrete example, please. It's easier to work with that.
 
do I write default parameters in .cpp file when implementing function or in .h file?
The problem is that when I call a function from file where it wasn't implemented, it says that my parameters don't match.

void pyPrintToFile(string filename, char *mode, string Text, string delimBefore = "", string delimAfter = "\n")
 
@Qwerty Then you don't.
 
If you are designing something new, simply don't design your program so that your functions need that much state.
If there's legacy, that's another story.
 
5:58 PM
@MooingDuck My first reaction would be that a function with 187 parameters sounds suspiciously like it's trying to do more than one thing.
 
@EtiennedeMartel I don't what?
 
I feel like I am getting mixed messages here...
 
@MooingDuck class Cache {}; class User { Cache& c; User(Cache& _c) : c(_c) { }};
 
@Xeo character.moveforward would have to be passed all the networking stuff as parameters to send the move message to all other players. Also the audio so it can start playing the walking sound.
 
@Qwerty Oh.
You put them in the .h
 
5:59 PM
@Pawnguy7 you are, we're debating
 
Yes, it's trying to do too much.
 
5 mins ago, by Bartek Banachewicz
@Qwerty .h
 

« first day (879 days earlier)      last day (4068 days later) »