13 Replies - 1101 Views - Last Post: 04 September 2013 - 07:54 AM Rate Topic: -----

#1 frostraver  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 93
  • Joined: 11-September 12

In-game chat textbox and showing messages

Posted 02 September 2013 - 01:34 PM

Hi,

I've got a fairly easy question but maybe not so easy to answer.
I'm currently creating a server/client system where I would be able to activate a chat system (I'm building a component based system where I can add things based on the game I'm making).
Now, I want it to be a part of a HUD and I want to create a custom textbox.

Are these things possible? So, how would I go about creating a custom textbox? And how would I create a custom box to show all the messages?

I want to do a similar thing like the chat in WoW or Guild Wars(2).

Is This A Good Question/Topic? 0
  • +

Replies To: In-game chat textbox and showing messages

#2 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 835
  • View blog
  • Posts: 2,459
  • Joined: 20-March 10

Re: In-game chat textbox and showing messages

Posted 02 September 2013 - 03:14 PM

What GUI library do you plan on using ?

Or do you want to do it in the native api of whatever OS you are using ?

What IDE are you using to build the application ?

We need to know all pertinent information to answer any of your questions.

Regards

Snoopy.
Was This Post Helpful? 1
  • +
  • -

#3 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 615
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: In-game chat textbox and showing messages

Posted 02 September 2013 - 03:15 PM

If you're talking about about overlaying native controls (e.g. Win32 controls on Windows) on a window which you're rendering to with OpenGL or DirectX, I would think that would be extremely problematic and probably more trouble than it's worth. Most games I've seen seem to render their own controls and handle input to those controls. I don't know if that's what you were implying though. I guess that creating your own controls from scratch with a graphics API is a very open ended and subjective subject. At the bare minimum, I would expect that you would need to be able to render text, shapes and take input from the mouse and keyboard.

Edit.
Snoopy hit the nail of the head though, I assumed a lot here.

This post has been edited by Aphex19: 02 September 2013 - 03:17 PM

Was This Post Helpful? 0
  • +
  • -

#4 frostraver  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 93
  • Joined: 11-September 12

Re: In-game chat textbox and showing messages

Posted 02 September 2013 - 04:14 PM

What GUI library do you plan on using ?
I have no idea. That could be part of my question. I'm going to try and get it running with DirectX though

What IDE are you using to build the application ?
I'm using Visual Studio 2012 if that's what you're asking.

I don't want to "reinvent" something. I just need some guidance on how I would create some sort of chat system that could fit in a game.
Was This Post Helpful? 0
  • +
  • -

#5 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 835
  • View blog
  • Posts: 2,459
  • Joined: 20-March 10

Re: In-game chat textbox and showing messages

Posted 02 September 2013 - 07:57 PM

View Postfrostraver, on 02 September 2013 - 11:14 PM, said:

What GUI library do you plan on using ?
I have no idea. That could be part of my question. I'm going to try and get it running with DirectX though

What IDE are you using to build the application ?
I'm using Visual Studio 2012 if that's what you're asking.

I don't want to "reinvent" something. I just need some guidance on how I would create some sort of chat system that could fit in a game.

Ok then,

You probably want to use the native api for windows which is win32.

win32 window with textbox Example on how to change font and color as well.

#include <windows.h>
#define ID_TEXT1 1001

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = "Win32 Window with Textbox";

int WINAPI WinMain (HINSTANCE hThisInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpszArgument,
                     int nCmdShow)
{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default colour as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           szClassName,       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nCmdShow);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   static HWND textBox1;
   static HFONT hFont;

    switch (message)                  /* handle the messages */
    {
    case WM_CREATE:

       textBox1 = CreateWindowEx(NULL,"Edit","",WS_CHILD|WS_VISIBLE|WS_BORDER|ES_MULTILINE|ES_WANTRETURN|ES_LEFT,50,80,225,230,hwnd,(HMENU)ID_TEXT1,NULL,NULL);
       hFont = CreateFont(18,0,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
                CLIP_DEFAULT_PRECIS,CLEARTYPE_QUALITY, VARIABLE_PITCH,TEXT("Impact"));
       SendMessage (textBox1, WM_SETFONT, (WPARAM)hFont, TRUE);

       SetFocus(textBox1);// SET WINDOW FOCUS
       break;

     case WM_CTLCOLOREDIT:

            // Set the text foreground color.to BLUE
            SetTextColor((HDC)wParam, RGB(0, 0, 255) );

      return (LRESULT)CreateSolidBrush(RGB(255,255,255));

        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;

        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}



This is not a unicode build so select
Use Multi-Byte Character Set
However it will be a steep learning curve for you if you want to dive into DirectX.

Good Luck

Snoopy.

This post has been edited by snoopy11: 02 September 2013 - 07:59 PM

Was This Post Helpful? 1
  • +
  • -

#6 frostraver  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 93
  • Joined: 11-September 12

Re: In-game chat textbox and showing messages

Posted 03 September 2013 - 02:59 AM

I know DirectX so that isn't the problem :)
I also know how to make textboxes and everything since it's already implemented in the game engine I'm going to use (but these are only win32 api textboxes and stuff).

I know I can use DXUT to create a ui in DirectX but I don't know if that's a good way.

I think I should use an already existing library though but I don't know which one is the best free, and if possible commercial, gui library. Yes, I did my research but couldn't find one I really wanted to start with. Any experience with one of those?
Was This Post Helpful? 0
  • +
  • -

#7 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 835
  • View blog
  • Posts: 2,459
  • Joined: 20-March 10

Re: In-game chat textbox and showing messages

Posted 03 September 2013 - 08:51 AM

View Postfrostraver, on 03 September 2013 - 09:59 AM, said:

I know DirectX so that isn't the problem :)/>
I also know how to make textboxes and everything since it's already implemented in the game engine I'm going to use (but these are only win32 api textboxes and stuff).

I know I can use DXUT to create a ui in DirectX but I don't know if that's a good way.

I think I should use an already existing library though but I don't know which one is the best free, and if possible commercial, gui library. Yes, I did my research but couldn't find one I really wanted to start with. Any experience with one of those?


Ahh I see your an advanced user,

You never said..

Well straight to crazy eddies for you then...

Crazy Eddies GUI

See the build for Win32 section

http://www.cegui.org...ource_for_Win32

follow the examples and you're done !

Regards

Snoopy
Was This Post Helpful? 0
  • +
  • -

#8 frostraver  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 93
  • Joined: 11-September 12

Re: In-game chat textbox and showing messages

Posted 03 September 2013 - 10:10 AM

Great! Thanks, I'll definitely try it out! (And I'll remember to give some more ifo in the future) :)
Was This Post Helpful? 0
  • +
  • -

#9 frostraver  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 93
  • Joined: 11-September 12

Re: In-game chat textbox and showing messages

Posted 03 September 2013 - 05:25 PM

I've been trying to setup CEGUI all day but couldn't figure out how to do it. I can't seem to build it too (using CMake, is this the right way?). There seems to be very little information on how to setup CEGUI in Visual Studio 2012 with DirectX10.

Do you know any documents or tutorials I could read that explain what I need to do?
Was This Post Helpful? 0
  • +
  • -

#10 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 835
  • View blog
  • Posts: 2,459
  • Joined: 20-March 10

Re: In-game chat textbox and showing messages

Posted 03 September 2013 - 06:05 PM

Right so your an expert in DirectX,

but you cant build a simple library....???

That makes no sense...

from the second link I sent you.

Download: CEGUI-0.7.7.zip and CEGUI-DEPS-0.7.x-r3-vc10.zip
Unpack CEGUI-0.7.7.zip files to c:\CEGUI-0.7.7\ or some other path.
Unpack CEGUI-DEPS-0.7.x-r3-vc10.zip files. Now cut and past the dependencies folder into c:\CEGUI-0.7.7\
Run build_vs2008.bat located in C:\CEGUI-0.7.7\projects\premake\ -You should now have a CEGUI.sln file.
Run the CEGUI.sln using Visual C++ Express 2010. It should now load up the MSVC integrated development environment (IDE). It should also present you with a conversion wizard to convert the MSVC 2008 solution file (.sln) into a MSVC 2010 .sln
Press the Finish button in the conversion wizard, and then press Close. It should convert it to the proper format now.
Change the Solution Configurations drop-down list-box at the top of the MSVC IDE from the default Debug to Release, or leave it set to Debug.
Next, you have 3 options on how you may proceed to actually build the solution. You can click on the menu bar, which will open up a context menu; click on the Build Solution option when you're ready. You can do that, or if you'd like, you can just press F7 instead. Alternately, in the Solution Explorer, usually found to the right side of the IDE, you can right-click on the top most label which reads Solution 'CEGUI' (14 Projects), and then click on Build Solution from that context menu

So NO you dont use CMake.....

you use Run build_vs2008.bat

have you done that ?

Regards
Snoopy.
Was This Post Helpful? 1
  • +
  • -

#11 frostraver  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 93
  • Joined: 11-September 12

Re: In-game chat textbox and showing messages

Posted 04 September 2013 - 01:22 AM

I've done that but when I tried to run the project in Visual Studio 12 it gave me a lot of warnings/errors after converting the projects for my VS version.
(By the way, I didn't say I was an expert in DirectX. I should have said I have some knowledge of it because I'm in a game development school where I had DirectX this year.)

This CeGUI version is an older one though. There is a newer one and in those documents they said I had to use CMake. I'll try it again...
Was This Post Helpful? 0
  • +
  • -

#12 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 835
  • View blog
  • Posts: 2,459
  • Joined: 20-March 10

Re: In-game chat textbox and showing messages

Posted 04 September 2013 - 03:21 AM

Ahh I never noticed you were trying to build in 2012,

Well the gui library does have some compatibility issues
with vs 2012 I suggest starting a new solution and importing the files
directly to build linking with whatever libs are necessary.

Support for 2012 is virtually non existant at present
and has a lot of compatibility issues with older builds
VS 2010 has no such issues can you use that to build ?

Regards

Snoopy.
Was This Post Helpful? 0
  • +
  • -

#13 frostraver  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 93
  • Joined: 11-September 12

Re: In-game chat textbox and showing messages

Posted 04 September 2013 - 05:36 AM

Ok, so the trick was to, like you said, install Visual Studio 2010 and then when you try to build the projects set the process to Release. If you build in Debug it gives some errors and warnings.

I guess I can now just copy the lib files to wherever I want and include them in my projects? (I guess I could find this in the documentation as well...)
Was This Post Helpful? 0
  • +
  • -

#14 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 835
  • View blog
  • Posts: 2,459
  • Joined: 20-March 10

Re: In-game chat textbox and showing messages

Posted 04 September 2013 - 07:54 AM

View Postfrostraver, on 04 September 2013 - 12:36 PM, said:

I guess I can now just copy the lib files to wherever I want and include them in my projects? (I guess I could find this in the documentation as well...)


Yes exactly use the .libs and required header files where you want now.

Glad you got it sorted.

Snoopy.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1