*** tpb has joined #freeorion | 00:00 | |
*** fixIt has joined #freeorion | 00:16 | |
fixIt | when using GG::Connect() is it possible, and if it is possible...what is the correct syntax to have a function callback with a parameter? | 00:17 |
---|---|---|
fixIt | *Actually I meant argument | 00:51 |
CIA-3 | FreeOrion: eleazzaar * r4625 /trunk/FreeOrion/default/ship_hulls.txt: fixed the commenting out of krill sitrep that i did badly. | 00:58 |
*** VargaD has quit IRC | 01:02 | |
*** bjorn2in has quit IRC | 01:25 | |
GeofftheMedio | fixit: give an example? | 02:19 |
fixIt | Okay well I have a button widget that is set up with a GG::Connect to call a method that creates a modal pop up window. So I when the button is pressed and calls the method I want it to pass a string indicating which hot key it is like "HotKey.OpenChatWindow". | 02:21 |
fixIt | So I was hoping there was a way to do GG::Connect(blah, &MapWnd::makewindow("this.hotkey"), this) | 02:22 |
fixIt | something like that so the call back is called with an argument specified | 02:22 |
fixIt | I have tried a ton of variations of syntax in hopes of getting it to work with no luck. From looking at the GG::Connect it makes templates of parameters so I thought it could work but thats only a guess | 02:23 |
GeofftheMedio | make the signal you're connecting take a parameter | 02:24 |
GeofftheMedio | boost::signal<void (const std::string&)> signal; | 02:24 |
GeofftheMedio | GG::Connect(signal, &MapWnd::RunHotkeySelectDialog, this) | 02:25 |
GeofftheMedio | and then when calling the signal, | 02:25 |
GeofftheMedio | signal("HotKey.OpenChatWindow") | 02:25 |
fixIt | Wait so the signal parameter would also be called with the callback function as well? | 02:27 |
fixIt | I am using the button->ClickedSignal btw | 02:27 |
GeofftheMedio | if you don't want a custom signal type, then try using boost::bind to specify one of the parameters to the function you want to call at the time of signal connection | 02:28 |
GeofftheMedio | also, the "this" is actually a parameter.... I'm not sure if you can specify more than one or of arbitrary type | 02:28 |
GeofftheMedio | a quick skim suggests not; use bind | 02:31 |
fixIt | Ahh okay thanks, just looked up bind that does look like exactly what I need | 02:32 |
fixIt | Hey Geoff do you program professionally? | 02:35 |
GeofftheMedio | not really | 02:39 |
GeofftheMedio | ie. I've never had a job as a programmer | 02:39 |
GeofftheMedio | though I have done programming as part of my work / school | 02:39 |
fixIt | Wow I am shocked. Your clearly really talented and knowledgeable. Ah whats your major? | 02:48 |
GeofftheMedio | I'm no lead programmer. | 02:48 |
GeofftheMedio | engineering physics and medical physics | 02:49 |
fixIt | Ah very cool. Well you basically are now right? So tzlaine is more responsible for the overall design then? | 02:54 |
GeofftheMedio | tzlaine knows more about designing software systems and adding new stuff... I more so extend stuff based on his examples | 02:57 |
*** StrangerDanger has quit IRC | 03:08 | |
*** STalKer-Y has joined #freeorion | 04:51 | |
*** STalKer-X has quit IRC | 04:51 | |
fixIt | Hey Geoff is it necessary to have 2 hot keys for zoom? right now + and e for zoom in, - and r for zoom out | 05:28 |
fixIt | Could only 1 be okay? Because zoom in and out are the only ones and it would be much simpler if there was only 1 for them. | 05:29 |
fixIt | actually nevermind I'll just make 2 configurable options for them | 05:34 |
GeofftheMedio | it should be possible to have multiple key commands for every action | 06:03 |
GeofftheMedio | but for the first version, you can do just one | 06:04 |
*** fixIt has quit IRC | 06:27 | |
*** fixIt has joined #freeorion | 06:27 | |
fixIt | In the Options GUI I'm a little bit lost as to how I can display what the current hot key combination is for something..a Key is just an enum/int and then the ModKey is a class and neither have a ToString() that I have seen. Do you know of any better ways to do that or am I just going to have to make a massive if/else if translating each GG::Key into a string equivalent? I just tried boost lexical cast and the string comes out as G | 07:20 |
fixIt | GK_RIGHTBRACKET I dunno if thats acceptable? | 07:20 |
GeofftheMedio | you can pass "GGK_RIGHTBRACKET" to UserString, and add appropriate entries to eng_stringtable.txt | 07:21 |
fixIt | Ah okay but either way I still have to add an entry for every single possible key right? | 07:22 |
GeofftheMedio | possibly | 07:22 |
GeofftheMedio | not all keys need to be acceptable for hotkey use, though | 07:23 |
GeofftheMedio | and it might be possible to convert the enum into a char and use that in some cases | 07:23 |
fixIt | Oh really which ones are not? As of now I have the basic functionality working allowing you to set and change hot keys..allowing anything you press. | 07:25 |
fixIt | for enum to char would that go right to the correct char if its a single character or do I need to do something with ASCII to get the right value? | 07:25 |
GeofftheMedio | I think there's some comment in the GG code about the enum values mapping to ascii | 07:26 |
GeofftheMedio | have a search... | 07:26 |
GeofftheMedio | or see how GG sets up what text to enter in an edit box if the user types something | 07:26 |
fixIt | Okay thanks I'll take a look at that. But are there any keys that should not be allowed to be mapped to something? | 07:28 |
GeofftheMedio | probably; I'm not sure which off the top of my head | 07:28 |
fixIt | alright if you think of any just let me know. You were right just read a comment by GG:Key saying their enum values are cleverly chosen to map to ascii thats perfect | 07:30 |
GeofftheMedio | see how GG code does the conversion for Edit; it's probably also useful for you... | 07:31 |
*** bjorn2in has joined #freeorion | 07:31 | |
fixIt | k | 07:32 |
fixIt | when you say conversion for edit, where exactly is this happening? Are you speaking of like the CUIEdit? | 07:54 |
GeofftheMedio | gg edit | 07:54 |
GeofftheMedio | looks kinda complicated... not sure how it works myself | 07:54 |
fixIt | Ah thanks. Yea indeed it does | 07:57 |
*** fixIt has quit IRC | 08:00 | |
*** VargaD has joined #freeorion | 09:16 | |
*** theTroy has quit IRC | 11:54 | |
*** em3 has joined #freeorion | 12:14 | |
*** theTroy has joined #freeorion | 12:53 | |
*** theTroy has quit IRC | 13:01 | |
*** theTroy has joined #freeorion | 13:01 | |
*** em3 has joined #freeorion | 14:37 | |
*** em3 has joined #freeorion | 14:38 | |
*** bookwar1 has quit IRC | 15:56 | |
*** StrangerDanger has joined #freeorion | 16:38 | |
*** fixIt has joined #freeorion | 17:29 | |
*** Mikoto_ has joined #freeorion | 18:48 | |
*** Mikoto has quit IRC | 18:49 | |
fixIt | So for getting a Key Press from the user I am using the method I saw used in other places of the code for my modal window. ConfigureHotKeyModalWnd::KeyPress (GG::Key key, boost::uint32_t key_code_point, GG::Flags<GG::ModKey> mod_keys). Something I just noticed though is that when lets say I press Tab + y at the same exact time, instead of having one key press event that has y as its key and Tab as a mod key it ends up having 2 diff | 18:54 |
fixIt | erent KeyPress events with each event containing one of the keys I pressed. So if I press 3 keys at the same time I will get 3 separate key press events each containing 1 of the keys pressed. | 18:54 |
fixIt | So I'm not sure how I will be able to allow a hot key with more than 1 key...or I guess I'd have to find a different way to grab key input? | 18:55 |
GeofftheMedio | I don't think tab is a valid modkey | 18:55 |
GeofftheMedio | what happens if you press and hold shift, then press y ? | 18:55 |
fixIt | Same exact thing still. And you can't really hold a key, you sorta have to press them at the same time when setting them. Also kinda weird even if you just press y it will have a key that is y along with some flags set in the modkey | 18:58 |
GeofftheMedio | reject keypress events that are also modkeys then | 18:59 |
GeofftheMedio | so if you press and hold shift, you'll get a keypress with GGK_LSHIFT | 18:59 |
GeofftheMedio | check for that, and reject it | 18:59 |
GeofftheMedio | then when y is pressed, you should get GGK_Y with the LSHIFT and SHIFT modkey flags set | 19:00 |
GeofftheMedio | accept that one | 19:00 |
fixIt | Okay that makes sense. So then doing things like that way it is not allowed to set a mod key as the only hot key for something? | 19:01 |
GeofftheMedio | seems appropriate... otherwise it'll be impossible to specify that as a hotkey command without it grabbing the initial modkey keypress and treating it as the acutal desired keypress | 19:02 |
fixIt | Sounds good. Uhm so now I understand how to allow a modkey + key, should multiple keys be allowed...because I'm not sure how that would work with the way keypress events work. Would I be correct in that only a single key or a modkey + key are allowed to be set as a hotkey? | 19:11 |
fixIt | when I say multiple keys I mean like G and H for instance | 19:12 |
GeofftheMedio | yeah, I don't think CTRL + Q + C is necessary | 19:12 |
fixIt | Okay yea or that. So don't allow more than a mod key + key or just a key then? Should I specify this at the top of the options tab or something? | 19:13 |
GeofftheMedio | multiple modkeys should be possible without much trouble... | 19:13 |
GeofftheMedio | I don't think it's necessary to specify that only one keypress per command is accepted | 19:14 |
GeofftheMedio | it should be apparent from the defaults and the fact that it exits the window after a single non-modkey keypress | 19:14 |
fixIt | by multiple modkeys do you mean multiple modkeys alone like shift and ctrl or do you mean multiple modkeys with a key? With a key I get how to make that work | 19:17 |
fixIt | Okay cool | 19:17 |
GeofftheMedio | with a key | 19:17 |
GeofftheMedio | just modkeys shouldn't do anything | 19:17 |
fixIt | Alright thanks | 19:17 |
GeofftheMedio | another thought: you could use keydown and keyup instead of keypress to capture the hotkey commands | 19:58 |
GeofftheMedio | ie only capture the result when getting a keyup event? not sure if that would be awkward in practice... | 19:58 |
fixIt | Ah okay I'll take a glance and see if that might make things easier or harder. Also when you set a hot key with lets say Left CTRL do you want it to only work with left control or should the right control work as well for it? | 20:03 |
GeofftheMedio | just check for CTRL, not LCTRL or RCTRL independently | 20:03 |
fixIt | k | 20:05 |
*** em3 has quit IRC | 20:05 | |
fixIt | So enter and return should work the same way then? | 20:27 |
GeofftheMedio | as eachother, or as something else? | 20:33 |
fixIt | Like if a hot key is CTRL and Enter, should CTRL and Return work automatically? | 20:36 |
*** theTroy has quit IRC | 20:38 | |
GeofftheMedio | uhm... no opinion? whatever's easiest for you, I guess | 20:40 |
fixIt | Okay i was looking and it would make things problematic and I would have to do things special to do that. So at least for now it won't work that way then. I only asked because before for like the end turn it was set up with CTRL Enter and CTRL Return but I have those set up as 2 different configurable options now | 20:41 |
GeofftheMedio | should be fine | 20:42 |
*** theTroy has joined #freeorion | 20:59 | |
fixIt | k. two other weird things, so there are some keys that aren't even recognized as key press events like ` or even +, however the numpad + is a keypress event. so if anyone tries to set one of those keys as a hot key it will never get logged unless its on the numpad. | 21:02 |
GeofftheMedio | normally + is = when shift is not pressed | 21:02 |
GeofftheMedio | dunno why ` wouldn't be a key | 21:03 |
GeofftheMedio | ` seems to work for me... it shows up as GGK_BACKQUOTE | 21:04 |
fixIt | Ah okay well pressing the +/= key with or without shift does not make an event. Same with the `/~ key. However the numpad + always does. | 21:05 |
fixIt | Yea I see the enums for the but IDK why those 2 keys literally don't generate the event at least for me, all the keys around them do though | 21:05 |
GeofftheMedio | how are you determining this? | 21:07 |
GeofftheMedio | if I put a breakpoint in GUI::HandleGGEvent in the case KEYPRESS section, then attach to FO and press = I get an event | 21:08 |
GeofftheMedio | and pressing = when the focus is in an Edit control does type "=" so it must be sending events | 21:08 |
fixIt | Well for my modal window that has the KeyPress method that gets the event/signal I have a break point in there. If I press either of those the modal window will just stay there forever and the method is never entered, if I try other keys the method will be entered and the modal window will disappear and the hot key will then be set and work. | 21:08 |
GeofftheMedio | try putting the breakpoint in GUI::HandleGGEvent under KEYPRESS and see if it catches it there | 21:09 |
fixIt | k | 21:10 |
fixIt | Nope same exact thing. GUI::HandleGGEvent for KeyPress doesn't get entered for those keys but does for others. IDK if it has to do with me using a Release version maybe? But usually the code is still ran I just can't step through it or see values... | 21:14 |
fixIt | I guess I'll just ignore it for now then once i finish it have your or someone else try it out and see if its just because of release? | 21:14 |
GeofftheMedio | I'm building as release as well | 21:14 |
GeofftheMedio | that shouldn't have anything to do with a particular key being functional or not | 21:15 |
GeofftheMedio | do you have a standard us english keyboard? | 21:15 |
*** theTroy has quit IRC | 21:15 | |
fixIt | Uhm I assume so, its Logitech K200 which I bought in the U.S.. And from what I can tell its the same as all keyboards Ive used in the past. Maybe a bit smaller | 21:16 |
GeofftheMedio | do those keys work normally to type into irc? | 21:17 |
GeofftheMedio | ` = | 21:17 |
fixIt | ` = yep | 21:17 |
GeofftheMedio | weird... I dunno. | 21:17 |
fixIt | Hmm yeah well hopefully they work for other people, I personally never plan on configuring those two keys as hot keys lol. Once I finish someone will have to verify they do | 21:19 |
GeofftheMedio | there should probably be a cancel button on the modal dialog, in case someone doesn't have a functional keyboard... | 21:25 |
*** em3 has joined #freeorion | 21:32 | |
*** theTroy has joined #freeorion | 21:33 | |
*** theTroy has quit IRC | 21:50 | |
*** theTroy has joined #freeorion | 22:04 | |
*** Digit01 has joined #freeorion | 22:33 | |
*** Mikoto_ is now known as Mikoto | 22:37 | |
CIA-3 | FreeOrion: geoffthemedio * r4626 /trunk/FreeOrion/universe/ShipDesign.cpp: Grooming | 23:26 |
*** em3 has quit IRC | 23:46 |
Generated by irclog2html.py 2.5 by Marius Gedminas - find it at mg.pov.lt!