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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Danetta

Pages: [1]
1
Window / Re: Minimizing Window
« on: January 22, 2017, 07:40:56 pm »
Well, I come to the conclusion that I need to use WinAPI because SFML provide sf::Style in a weird way. It's apparently not "sfml unrelated" question.

I don't really "want" or "need" to use WinAPI, I just don't know any other workaround for that thing with SFML which I mentioned.

2
Window / Re: Minimizing Window
« on: January 22, 2017, 03:05:04 pm »
Otherwise, you might be better off on StackOverflow or some other forum, if you only have issues with the WinAPI.
Not only with WinAPI, because sf::Style::None not only removes style, but removes the functional of minimizing window via taskbar.

3
Window / Minimizing Window
« on: January 22, 2017, 12:16:57 pm »
Hello.

At first, I used default settings in sf::Style in sf::RenderWindows Create function.
Then I decide to create my one minimize and exit buttons, so I just used sf::Style::None.

I have issues with both of these approaches.

If I use standard windows settings, then I see an empty Window (after launching a program) with plain white color inside it for a half-second before all other objects are rendered.

If I use sf::Style::None instead, then, even if I do implement minimize and exit buttons by myself, then window somehow becomes unresponsible in terms of minimizing/restoring (but everything rendered just after starting, without empty white windows).
First, minimizing stops working when I click on taskbar. It works with standard settings, but doesn't with sf::Style::None, while the only thing I want to do is hiding default buttons and default window upper bar.
Also, if I minimize all active windows with "Win+D", then my application restoring automatically even when I restored another application, not mine.

What is the solution?

UPD:
Tried something with Winapi.
Creating sfml window with sf::Style::Default and then erased some flags like that:
sf::WindowHandle window_handle = window_render.getSystemHandle();
LONG lStyle = GetWindowLong(window_handle, GWL_STYLE);
lStyle &= ~(WS_CAPTION | WS_BORDER | WS_THICKFRAME | WS_SYSMENU);
SetWindowLongPtr(window_handle, GWL_STYLE, lStyle);
Also tried some other combinations, but with this one I managed to create a simple window with working minimize (unlike  sf::Style::None), but again with white empty space at launch (like sf::Style::Default).

Any advice would be appreciated.

UPD2: Well, after reading through WinApi documentation, I tried the following.
Created sfml window with sf::Style::None. Then added a minimize box to it via this code:
LONG lStyle = GetWindowLong(window_handle, GWL_STYLE);
lStyle |= (WS_MINIMIZEBOX);
SetWindowLongPtr(window_handle, GWL_STYLE, lStyle);
SetWindowPos(window_handle, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);

After that I still have no minimize box (because I have no caption and borders obviously), but minimizing via taskbar now works. I don't know if it is good solution and want some insight, but sfml probably need a way to handle this thing without requiring a user to write winapi code.

4
Network / Packet << Vector
« on: December 28, 2016, 08:33:53 am »
Hello.

Probably not really SFML related question, but Goggle did not helped me yet.

I need to send std::vector<sf::String> using sf::Packet.

Here is my code:

sf::Packet& operator<<(sf::Packet& packet, std::vector<sf::String>& vector)
{
        packet << vector.size();
        for (auto &i : vector) {
                packet << i;
        }
        return packet;
}

Then sf::Packet << &std::Vector<sf::String> gives me this warning:
warning C4800: 'std::vector<sf::String,std::allocator<_Ty>> *':
forcing value to bool 'true' or 'false' (performance warning) with
[
_Ty=sf::String
]

I know what does it mean in some regular cases, however, I have no idea how to apply it to Vector.


UPD: I am dumb. I updated the function declaration with "vector&", so I need to use sf::Packet << std::Vector<sf::String> and not sf::Packet << &std::Vector<sf::String>.

However, I still would like to see an explantation about which internal errors were caused by my mistake.

5
System / Re: UTF-8 and stuff
« on: December 16, 2016, 03:20:59 am »
std::string String::toAnsiString(const std::locale& locale) const
{
    // Prepare the output string
    std::string output;
    output.reserve(m_string.length() + 1);

    // Convert
    Utf32::toAnsi(m_string.begin(), m_string.end(), std::back_inserter(output), 0, locale);

    return output;
}

Why would you use string::reserve in this case? Is not it unneeded when you use std::back_inserter?

6
System / Re: UTF-8 and stuff
« on: December 15, 2016, 08:39:59 pm »
I find sf::String::toUtf8 too hard to use because output is std::basic_string while sf::Utf<8> allows me to ger result almost within in a single string. I tried it and got what I need, but with some problems like having to resize declared strings manually so converted ones would fit into them.

Answering your question about what I am trying to do:
Client terminal displaying strings in cp_1251, client gui (label and editboxes) using widestring (seems like?), server processing requests to Database using UTF-8 strings as arguments.

So, when I receive widestring (or UTF-32? I am still not sure, but widestring works well when I use it as parameter; I don't want to, however, but TGUI documentation only said it's "sf::String"; also, UTF-8 doesn't display well with TGUI unless I convert to widestring.. ugh..) from gui, I need to handle all the encodings and decodings from client to server and then back.


Edited.

7
System / Re: UTF-8 and stuff
« on: December 15, 2016, 08:20:16 pm »
Maybe describe your problem in detail, because I don't really understand the issue. Or maybe you just misunderstood the API?

If you have a sf::String that is UTF and want to convert to an ANSI string, all you have to do is call toAnsiString() (and toWideString() for wstring).

If you want to do it manually, you could also take a look how SFML does it internally for toAnsi.
What if my sf::String is widestring and I want to convert it to UTF-8?


string iterator + offset out of range
if I do not set the size of output string manually like that
You want std::back_inserter
Seems like true, will try to figure out.

8
System / Re: UTF-8 and stuff
« on: December 15, 2016, 04:01:51 pm »
Almost all of them require iterators to begin of original string | end of original string | begin of output string.
Output string is empty by default and most conversion function from there would give me
string iterator + offset out of range
if I do not set the size of output string manually like that:

std::string ANSI_to_UTF8(const sf::String& original)
{
        std::string ansi;                                                              
        ansi.resize(original.getSize() * 4);

        std::string::iterator last = sf::Utf<8>::fromAnsi(original.begin(), original.end(), ansi.begin(), std::locale("Russian"));
        ansi.resize(last - ansi.begin());
        return ansi;
}

9
System / UTF-8 and stuff
« on: December 15, 2016, 03:52:07 am »
Hello.

EDIT: It seems like I resolved almost all the issues.

EDIT2: How much bytes I possibly need to convert from sf::String to std::string or std::wstring?
In case when I need to resize empty strings so the converted one would fit. Probably an easy question, but can't google it.

10
Network / Re: Interface selection
« on: December 04, 2016, 06:46:56 pm »
Just having the same questiong, but about TCP_Socket. Decide to not create another topic and just use this one again.
UDP Socket has bind function which can be used, but what about TCP?
When I use "connect" I can only specify the address and port of server I need connect to. How can I select an interface which client should use in case I have multiple of them?

11
Network / Interface selection
« on: September 02, 2016, 05:26:45 pm »
Hello.

How is it possible to select which network interface to use?
I have multiple VPNs installed, Hamachi for example (25.0.0.0)
It is the first one in priority list in my "network adapters" window on Win7.
However, when I use sockets in SFML, it still uses my "local interface", which is 192.168.etc.etc.

Some games I saw are always using local interface, some of them are using the first one in priority list, some of them allow player/user to choose which one to use.

How is it handled in SFML?
I looked through docemntation, but haven't found anything about it.
Google did not help too, probably because I don't know how to phrase my question properly.

Thank you.

Pages: [1]