목요일, 10월 19, 2006

Purpose: Creating a New VGUI Menu - Part 1

Creating a New VGUI Menu - Part 1
Date posted: Jun 09 2003
User Rating: 5 out of 5.0
Number of views: 2392
Number of comments: 2
Description: And getting it to show in your mod

먼저 이 분서의 저작권의 모든 권리는 rkzad님께 있습니다.
이 문서의 출처는 http://articles.thewavelength.net 입니다.

원문 Author: rkzad
번역 Author: godmode2k@hotmail.com (MSN IM)
Released date: July. 14. 2004 (KST)

이 문서는 Half-Life1 Modification을 위한 것으로 화면에 VGUI Menu를 보여 주고 control 하는데 필요한 코드를 잘 제시해 주고 있습니다. 하지만, 작성된 환경이 Half-Life SDK 2.x 로 추정됩니다. 따라서 Half-Life SDK 2.3을 사용하시는 분들은 정확한 line을 찾아야 합니다. 그렇지만, SDK가 2.3으로 version up 되면서 이부분이 바뀐것은 아니니 걱정하지마세요... ^___^

제가 이 문서를 번역할 때(정확히 하면 설명을 한국식으로 한다는 거죠...) 제가 사용한 Half-Life SDK가 2.3 이기 때문에 정확한 line을 사용하도록 하겠습니다. 또한 Half-Life SDK 2.3 아래의 버전의 line도 같이 사용하도록 하겠습니다.

* line이 제시되면 그 라인 바로 아래에 코드를 추가 해주시면 되겠습니다.
* 작업경로와 line 번호를 꼭 참고하셔야 합니다.
* 번역시 나름대로 내용을 추가 또는 의역을 하겠습니다.
* 또한, 이곳에서 사용된 코드는 모두 Single-Player Source 기반임을 알려드립니다.

제가 Single-Player Source에서 테스트 해보고 나서 작성하는것이기 때문에 아직 Multiplayer Source에서는 되는지 모르겠습니다.

번역시작:
이제 오늘 할 일을 정확히 알려주겠습니다. 먼저, 간단한 메뉴를 만들것입니다. 오직 'cancel' 버튼만. 후에, 우리는 명령을 전달할 좀더 많은 button을 추가하고 모든 종류의 멋진것들을 할것입니다. 근데, 우리가 몇몇 VGUI와 함께 작업하는데 있어서, 여러분의 코드내에서 이 문서에 나온 코드를 사용해 정확히 시도? -사용하려면- mp/hl.dll 과 client.dll, 이 두 파일과 같은 코드를 만들 수 있는 Compiler가 있어야 합니다. 제가 이 두 파일을 만들 수있다고 확신하고 가장 권장되는 Compiler중 하나가 Microsoft Visual C++ 6 (MSVC) 입니다.

이제 시작하기에 앞서 조그만한 작업을 하나 하겠습니다.
Half-Life1(이하 하프 혹은 HL1) 이나 Counter-Strike 상용판(이하 카스 혹은 CS), STEAM(이하 스팀 혹은 STEAM)에서 여러분의 Modification(이하 모드 혹은 MOD)을 돌리려면 liblist.gam 파일이 필요합니다.
대부분 맞게 했을 수도 있겠습니다만, 혹시나 하는 생각에...

liblist.gam 파일의 속성에서 다음과 같이 되어있는지 확인하시기 바랍니다.

[원문]
Now, let me tell you exactly what we're gonna be doing today. First, we will create a very basic menu. Only a cancel button. Later on, we will add more buttons sending commands and doing all sorts of nifty things. So, because we are working with some VGUI, if you want to be able to actually try this out in your own code, make sure you have a compiler that will be able to code both the mp/hl.dll and the client.dll. One compiler that I am certain can do both, and is most recommended, is Microsoft Visual C++ 6 (MSVC). Next, make sure that you're liblist.gam has the following inside:

파일명: liblist.gam

CODE (liblist.gam)
svonly "0"
cldll "1"


위의것들은 단지 여러분의 MOD가 client.dll 파일을 찾기위해 필요한 것입니다.
덧붙이자면, dll을 "your_mod_folder/cl_dlls/client.dll"에서 찾는 동안 mp/hl.dll을 찾게 됩니다. dll 파일이 어디에 있든 여러분이 "gamedll" 파라미터에서 정의해 놓은 대로 찾을 것입니다.
liblist.gam 에 대해서는 이쯤하면 된것 같군요...(어디에서든지 liblist.gam에 대한 많은 tutorial 들은 찾을 수 있을것입니다.)
그럼 코딩을 해볼까요!

그럼 mp/hl Workspace를 열고, player.h 파일을 열겠습니다.

[참고]
------------------------------------------
client.dll: "cl_dll Workspace" -> "cl_dll files"
mp/hl.dll : "dlls Workspace" -> "hl files"
------------------------------------------------

여기에서는(작업경로) "dlls Workspace"에서 "hl files"->player.h
HL1 SDK 2.3: go to line 95
HL1 SDK 2.x: go to line 74
그리고 아래의 내용을 추가해 주세요.

[원문]
These are just some necessary things to make sure your mod will look for a client.dll also. It will search for this dll in "your_mod_folder/cl_dlls/client.dll", while it will look for your mp/hl.dll wherever you specified it in the "gamedll" parameter. Enough about liblist.gam though (there are some tutorials on this you can find elsewhere). Let's get coding!

Let's open up the mp/hl workspace, and open player.h. Insert this at line 74:

CODE (C++)
class CBasePlayer : public CBaseMonster
{
public:
void ShowVGUIMenu(int iMenuID); // VGUI Tutorial( 이 부분을 추가 )
int random_seed;

이것은 우리의 함수(function) 즉 client.dll 에서 VGUI 메뉴중에 하나를 보여줄 함수의 정의(prototype)입니다.
There we go. This is a prototype for our function that will tell the client dll to show one of the VGUI menus.
이제 구현을 해봅시다. 먼저 player.cpp 파일을 열고 237 라인을 보세요.


작업경로: "dlls Workspace"에서 "hl files"->player.cpp
HL1 SDK 2.3: go to line 242
HL1 SDK 2.x: go to line 237

그리고 아래의 내용을 추가해 주세요.

[원문]
There we go. This is a prototype for our function that will tell the client dll to show one of the VGUI menus.

Now, let's implement it. Open player.cpp and go to line 237:

CODE (C++)
LINK_ENTITY_TO_CLASS( player, CBasePlayer );

// Start - VGUI Tutorial( 이 부분을 추가 )
void CBasePlayer :: ShowVGUIMenu(int iMenuID)
{
MESSAGE_BEGIN(MSG_ONE, gmsgVGUIMenu, NULL, pev);
WRITE_BYTE( iMenuID );
MESSAGE_END();
}
// End - VGUI Tutorial( 여기까지 추가 )

void CBasePlayer :: Pain( void )


여기서 잠깐!,,, 위의 gmsgVGUIMenu 가 어디에서 왔을까요? 그렇습니다! 정의 되지 않았습니다. 먼저 190 라인으로 가보죠.

작업경로: "dlls Workspace"에서 "hl files"->player.cpp (계속 이어서)
HL1 SDK 2.3: go to line 188
HL1 SDK 2.x: go to line 190

그리고 아래의 내용을 추가해 주세요.

[원문]
But, hold on a sec. Where did gmsgVGUIMenu come from? That's right! It's not declared. First let's go to line 190:

CODE (C++)
int gmsgShowMenu = 0;
int gmsgGeigerRange = 0;
int gmsgVGUIMenu = 0; // VGUI Tutorial( 이 부분을 추가 )

void LinkUserMessages( void )


다음으로, void LinkUserMessages(void) 함수의 끝으로 가서 아래의 내용을 추가하겠습니다.

작업경로: "dlls Workspace"에서 "hl files"->player.cpp (계속 이어서)
HL1 SDK 2.3: go to line 238
HL1 SDK 2.x: go to line ???: 바로 위에서 작성한 부분 아래에 보면 void LinkUserMessages(void)가 있습니다. 이 함수의 끝.

그리고 아래의 내용을 추가해 주세요.

[원문]
Next, let's go to the end of that LinkUserMessages and add the following:

CODE (C++)
gmsgFade = REG_USER_MSG("ScreenFade", sizeof(ScreenFade));
gmsgAmmoX = REG_USER_MSG("AmmoX", 2);
gmsgVGUIMenu = REG_USER_MSG("VGUIMenu", 1); // VGUI Tutorial( 이 부분을 추가 )
}

LINK_ENTITY_TO_CLASS( player, CBasePlayer );


위의 내용은 client.dll에게 ShowVGUIMenu에서 message를 전달하기 위해 필요합니다. 이제 player.h, player.cpp 부분은 끝났습니다. 이제 우리의 ShowVGUIMenu를 사용할 것입니다! 그럼 client.cpp 파일을 열고 380 라인으로 가보죠.


작업경로: "dlls Workspace"에서 "hl files"->client.cpp
HL1 SDK 2.3: go to line 439 : 함수의 위치는 void ClientCommand( edict_t *pEntity ) {
HL1 SDK 2.x: go to line 380

그리고 아래의 내용을 추가해 주세요.

[원문]
The above is needed to tell the client dll what message we are sending in ShowVGUIMenu. Now that that's done, it's time to put our ShowVGUIMenu to use! Let's open client.cpp and go to line 380:


CODE (C++)
GetClassPtr((CBasePlayer *)pev)->SelectLastItem();
}
// Start - VGUI Tutorial( 이 부분을 추가 )
else if ( FStrEq(pcmd, "vguimenu" ) )
{
if (CMD_ARGC() >= 1)
GetClassPtr((CBasePlayer *)pev)->ShowVGUIMenu(atoi(CMD_ARGV(1)));
}
// End - VGUI Tutorial( 여기까지 추가 )
else if ( g_pGameRules->ClientCommand( GetClassPtr((CBasePlayer *)pev), pcmd ) )


이제, 우리는 "vguimenu xx" 라는 console command로 어떠한 VGUI Menu 들도 우리가 원하는 대로 접근 할 수 있습니다! mp.dll을 Build 하고 그 파일을 여러분의 MOD 디렉토리내 dlls 디렉토리에 넣어주시면 되겠습니다. HL 또는 CS, Steam 으로 여러분의 MOD를 실행한 다음 console을 열어서 "vguimenu 5" (" 없이)를 넣어보고 아래의 그림과 같은지 확인해 보세요.


[원문]
Now, we can use the command "vguimenu xx" to access any of the VGUI Menus we want! Build your mp.dll and put it in your mod's gamedll folder. Start a game of HL, and in the console type "vguimenu 5" (without the ") and something close to the following should show:



일단 "hl files" 코드들을 hl.dll 파일로 build 해야 합니다.
현재 VC++ 6.0 상태에서 왼쪽 Workspace를 보시게 되면 "cl_dll files" 와 "hl files" 두개의 project가 있을 것입니다.

여기에서는 "hl files" 부분을 build 해야 하기 때문에 "hl files" 부분에 마우스 오른쪽 버튼을 눌러서 "Set as Active Project"를 눌러서 build 시킬 project를 활성화 시켜줍니다.

다음으로 VC++ 6.0 메뉴 -> Build -> Build hl.dll 을 선택해 주세요. 또는 F7을 누르셔도 됩니다.

정확히 입력하셨다면 error 없이 hl.dll 파일이 생성 되었을 것입니다.

이제 게임을 하기 위해서는 여러분이 만든 MOD안에 생성된 hl.dll 파일을 넣어줘야 합니다.
정상적이라면(모드나라 http://mod.zoa.to 동영상 강좌를 보고 VC++ 6.0을 Setting 한 경우), hl.dll 파일의 경로는 SDK/Single-Player Source/dlls/debughl/ 입니다. 즉, Build 작업을 거쳐서 hl.dll 파일이 생성될 디렉토리 위치입니다.

* SDK/... 에서 SDK는 여러분이 설치한 HL1 SDK 2.x의 경로입니다.

이 디렉토리 SDK/Single-Player Source/dlls/debughl/ 에 있는 hl.dll 파일을 여러분의 MOD 디렉토리의 dlls 디렉토리에 복사를 합니다.
e.g., SDK/Single-Player Source/dlls/debughl/hl.dll ---> Steam/SteamApps/스팀_ID/half-life/나의_MOD_NAME/dlls/

그리고 게임을 실행해서 "~" tilde를 눌러서 게임의 console로 들어갑니다.
이때 명령창에 "vguimenu 5" 라고 입력합니다. (" double quote-따옴표-는 빼시고 입력하세요.)
정확히 하셨다면 아래의 화면과 같은 화면을 보실 수 있습니다. 어떻습니까? CS 시작할 때의 윈도우과 같지요? ^___^

Figure #1


음, 그런데 메뉴가 좋아 보이지는 않군... 하지만 이 문서의 목적에 근접했다. 이건 우리의 새로운 vguimenu 명령이 동작하는가를 보기위한 테스트였다. 아니면 말고. 이제, 우리는 드디어 우리만의 새로운 VGUI 메뉴를 만들게 될것이다! cl_dll 프로젝트를 열고나서 vgui_TeamFortressViewport.h를 열고 46 라인을 보자.


작업경로: "cl_dll Workspace"에서 "cl_dll files"->vgui_TeamFortressViewport.h
HL1 SDK 2.3: go to line 52
HL1 SDK 2.x: go to line 46

그리고 아래의 내용을 추가해 주세요.


[원문]
So that menu may not look the best... but that's besides the point. That was a test to see whether or not our new vguimenu command works. Now, we will finally create our own new VGUI menu! Lets open up the cl_dll project now. Open up vgui_TeamFortressViewport.h at line 46:

CODE (C++)
class CClassMenuPanel;
class CTeamMenuPanel;
class CFirstMenu; // VGUI Tutorial( 이 부분을 추가 )

char* GetVGUITGAName(const char *pszName);


이제 우리는 우리의 class를 하나 갖게 되었고, 이 경우 우리의 class를 참조하기 위해 class를 만들어 주어야 한다. 다음을 보자. 라인은 1118 이다.


작업경로: "cl_dll Workspace"에서 "cl_dll files"->vgui_TeamFortressViewport.h (계속 이어서)
HL1 SDK 2.3: go to line 1576
HL1 SDK 2.x: go to line 1118

그리고 아래의 내용을 추가해 주세요.


[원문]
Now we have our class prototyped, just in case we need to reference to it before we wrote the next bit of text (goto line 1118):

CODE (C++)
public:
CTFScrollPanel(int x,int y,int wide,int tall);
};

// Start - VGUI Tutorial( 이 부분을 추가 )
//================================================================
// First VGUI menu!
//============================================================
class CFirstMenu : public CMenuPanel
{
private:
CommandButton *m_pCancelButton;

public:
CFirstMenu(int iTrans, int iRemoveMe, int x, int y, int wide, int tall);
};
// End - VGUI Tutorial( 여기까지 추가 )

//================================================================
// Menu Panels that take key input


비로서 우리는 우리의 첫번째 메뉴 class를 갖게 되었다. 그럼 이제 구현을 해보자. "vgui_FirstMenu.cpp" 라는 파일을 cl_dll 프로젝트의 "Source Files"에 새로 추가하자. 추가를 했다면 그 파일을 열고 아래와 같이 작성하자.


아래의 그림대로 파일을 추가 했다면 Workspace에서 "cl_dll files" project의 Source Files/hl/ 안에 vgui_FirstMenu.cpp 파일이 있을것입니다. 이 파일을 마우스로 drag 해서 Source Files에 drop 하세요. 즉, Source/hl 에 있는 파일을 Source Files/ 에 옮기는 것입니다.

Figure #2


작업경로: "cl_dll Workspace"에서 "cl_dll files"->vgui_FirstMenu.cpp
HL1 SDK 2.3: go to line 0
HL1 SDK 2.x: go to line 0

그리고 아래의 내용 전체를 추가해 주세요.


[원문]
There we go, we have our first menu class. Now let's implement our constructor. Add a new file to the Source Files of the cl_dll project named "vgui_FirstMenu.cpp". Open up that file and write in the following:


CODE (C++)
#include "hud.h"
#include "cl_util.h"
#include "vgui_TeamFortressViewport.h"


CFirstMenu :: CFirstMenu(int iTrans, int iRemoveMe, int x, int y, int wide, int tall) : CMenuPanel(iTrans, iRemoveMe, x,y,wide,tall)
{
m_pCancelButton = new CommandButton( gHUD.m_TextMessage.BufferedLocaliseTextString( "Cancel" ), 5, 5, XRES(75), YRES(30));
m_pCancelButton->setParent( this );
m_pCancelButton->addActionSignal( new CMenuHandler_TextWindow(HIDE_TEXTWINDOW) );
}


이제, 위의 코드는 우리의 "Cancel" 이라는 문자를 넣은 cancel 버튼을 만드는데, 위치는 x(5), y(5) 이고 width(가로)는 75, height(세로)는 30 이다. XRES와 YRES는 우리가 640x480 이나 320x240과 같은 해상도와 관련된 우리의 number들을 만든다. 그 다음 라인은 CFirstMenu가 현재 새로운 자식이 화면에 나타나는지, 숨겨졌는지, 무엇이던간에 이것들은 CFirstMenu의 자식들이다. 마지막 라인은 버튼을 클릭함과 동시에 MenuHandler에게 우리의 메뉴가 숨겨질거라는걸 알려준다.
다음으로, 우리의 ShowVGUIMenu 명령을 통해서 우리의 VGUI 메뉴를 열기위해 필요한 부분을 변경할 것이다. 278 라인으로 가보자.


작업경로: "cl_dll Workspace"에서 "cl_dll files"->vgui_TeamFortressViewport.h (계속 이어서)
HL1 SDK 2.3: go to line 441
HL1 SDK 2.x: go to line 278

그리고 아래의 내용을 추가해 주세요.


[원문]
Now, what this does, is create our cancel button with "Cancel" as the text on it, position it at x(5), y(5), and let it have a width of 75 and a height of 30. XRES and YRES make our numbers relative to either 640x480 or 320x240. The second line tells CFirstMenu that it now has a new child that it has to show, or hide, or do whatever it should to it's children. The last line makes it so that when you click on the button, it'll send a MenuHandler that will hide our menu. Next, we will make the necessary changes so that we may open our VGUI menu through our ShowVGUIMenu command. Goto line 278:

CODE (C++)
void CreateClassMenu( void );
CMenuPanel* ShowClassMenu( void );
// Start - VGUI Tutorial( 이 부분을 추가 )
void CreateFirstMenu( void );
CMenuPanel* ShowFirstMenu( void );
// End - VGUI Tutorial( 여기까지 추가 )
void CreateSpectatorMenu( void );


첫번째 함수(function)는 나중에 우리의 메뉴가 만들어지는 부분이 시작될때 VGUI에서 먼저 호출되어진다. 두번째 함수는 우리가 우리의 FirstMenu가 보여지기를 원하는 언제라도 호출된다. 다음, 399 라인으로 가서 아래의 코드를 추가하자.


작업경로: "cl_dll Workspace"에서 "cl_dll files"->vgui_TeamFortressViewport.h (계속 이어서)
HL1 SDK 2.3: go to line 568
HL1 SDK 2.x: go to line 399

그리고 아래의 내용을 추가해 주세요.


[원문]
The first function, later on, is what gets called early in the VGUI starting stage to create our menu. The second function gets called every time we want our FirstMenu to show up. Next, go to line 399 and add the following:

CODE (C++)
CTeamMenuPanel *m_pTeamMenu;
CClassMenuPanel *m_pClassMenu;
CFirstMenu *m_pFirstMenu; // VGUI Tutorial( 이 부분을 추가 )
ScorePanel *m_pScoreBoard;


이제, 우리의 FirstMenu는 실제로 TeamFortressViewport 클래스의 한 부분이 되었다.

여기까지는 vgui_TeamFortressViewport.h 에 대한 내용이었다! 이제, vgui_TeamFortressViewport.cpp 파일을 열어보자. 468 라인을 한번 보자.


작업경로: "cl_dll Workspace"에서 "cl_dll files"->vgui_TeamFortressViewport.cpp
HL1 SDK 2.3: go to line 523
HL1 SDK 2.x: go to line 468

그리고 아래의 내용을 추가해 주세요.


[원문]
Now, our FirstMenu is part of the actual TeamFortressViewport class.

That's it for vgui_TeamFortressViewport.h! Now, open vgui_TeamFortressViewport.cpp! Let's take a look at line 468:

CODE (C++)
m_pTeamMenu = NULL;
m_pClassMenu = NULL;
m_pFirstMenu = NULL; // VGUI Tutorial( 이 부분을 추가 )
m_pScoreBoard = NULL;


우리는 우리의 메뉴에서 몇몇 이상한 (wacko: 미 속어 -wacky-) 정보을 얻지 못하기 때문에 이러한 작업이 필요하다. 따라서 전부 NULL 로 만든다. 나중에 함수내에서 우리는 우리의 메뉴를 생성할 것이다. 이러한 작업을 532 라인에서 할 수 있다.


작업경로: "cl_dll Workspace"에서 "cl_dll files"->vgui_TeamFortressViewport.cpp (계속 이어서)
HL1 SDK 2.3: go to line 585
HL1 SDK 2.x: go to line 532

그리고 아래의 내용을 추가해 주세요.


[원문]
These are necessary so that we don't get some wacko information in our menu. So we make it all NULL. Later on in this function we will create our menu. You can do that at line 532:

CODE (C++)
// VGUI MENUS
CreateTeamMenu();
CreateClassMenu();
CreateFirstMenu(); // VGUI Tutorial( 이 부분을 추가 )
CreateScoreBoard();


이제, TeamFortressViewport가 만들어질때 우리의 FirstMenu도 생성될 것이다. 553 라인을 계속해서 보자.


작업경로: "cl_dll Workspace"에서 "cl_dll files"->vgui_TeamFortressViewport.cpp (계속 이어서)
HL1 SDK 2.3: go to line 619
HL1 SDK 2.x: go to line 553

그리고 아래의 내용을 추가해 주세요.


[원문]
Now, when the TeamFortressViewport is being constructed, our FirstMenu will be created! Let's continue on to line 553:

CODE (C++)
// Force each menu to Initialize
if (m_pTeamMenu)
{
m_pTeamMenu->Initialize();
}
if (m_pClassMenu)
{
m_pClassMenu->Initialize();
}
// Start - VGUI Tutorial( 이 부분을 추가 )
if (m_pFirstMenu)
{
m_pFirstMenu->setVisible( false );
}
// End - VGUI Tutorial( 여기까지 추가 )
if (m_pScoreBoard)
{
m_pScoreBoard->Initialize();
HideScoreBoard();
}


이것은 새로운 맵(map)이 로드될 때 마다 필요한 것으로, 우리의 메뉴는 다시 숨겨진다. 이제, tf_defs.h(Externel Dependencies에 있는) 파일의 1132 라인에 있는 내용을 간단하게 바꿔보자.


작업경로: "cl_dll Workspace"에서 "cl_dll files"->Externel Dependencies->tf_defs.h
HL1 SDK 2.3: go to line 1128
HL1 SDK 2.x: go to line 1132

그리고 아래의 내용을 추가해 주세요.


[원문]
This is necessary so that whenver a new map gets loaded, our menu will be hidden again. Now, let's make a quick little change in tf_defs.h (External Dependencies) at line 1132:

CODE (C++)
#define MENU_REFRESH_RATE 25

// VGUI Tutorial( 아래 부분을 추가 )
#define MENU_FIRSTMENU 30

//============================
// Timer Types


이제, 우리는 우리의 FirstMenu에 부여될 번호를 정의 했다! 우리는 vguimenu를 사용할 때 이 번호를 사용하게 될것이다 (ex: "vguimenu 30").

그럼, vgui_TeamFortressViewport.cpp로 돌아와서, 1506 라인으로 가보자.


작업경로: "cl_dll Workspace"에서 "cl_dll files"->vgui_TeamFortressViewport.cpp (계속 이어서)
HL1 SDK 2.3: go to line 1751
HL1 SDK 2.x: go to line 1506

그리고 아래의 내용을 추가해 주세요.


[원문]
Now, we have a defined number assigned to our FirstMenu! We may use this number when we use vguimenu (ex: "vguimenu 30").

Now, back to vgui_TeamFortressViewport.cpp, let's go all the way down to line 1506:

CODE (C++)
case MENU_CLASS:
pNewMenu = ShowClassMenu();
break;

// Start - VGUI Tutorial( 이 부분을 추가 )
case MENU_FIRSTMENU:
pNewMenu = ShowFirstMenu();
break;
// End - VGUI Tutorial( 여기까지 추가 )

default:
break;
}


함수의 이름을 이렇게 놓아서 가족처럼 보이지 않나? 음, 모두에게 유의(비위를 맞추려면)하려면 그렇게 해야 한다고 나는 오래전부터 지금까지 말하고 있다. 아니, 이것은 우리가 앞서 했던것과는 같은것이 아니다. 이것은 우리의 메뉴들을 보여주도록 사용하는 실제 VGUI 코드이다. 그것들이 MenuID(우리의 경우 30)을 어떻게 가지는지 본 다음, MENU_FIRSTMENU의 case 문 작성, MenuID 가 30과 같을 때 부터 그것(VGUI 코드)은 우리의 FirstMenu를 보여줄것이다. 멋지지 않나? 응?

다음으로, 우리는 우리의 ShowFirstMenu 와 CreateFirstMenu의 원형을 만들고, 우리는 그 함수들을 코드에서 몇차례나 사용할 것이다. 하지만, 우리는 여전히 그것들을 구현하지 않았다. 1618 라인으로 가서 아래의 코드를 추가하자.


작업경로: "cl_dll Workspace"에서 "cl_dll files"->vgui_TeamFortressViewport.cpp (계속 이어서)
HL1 SDK 2.3: go to line 1877
HL1 SDK 2.x: go to line 1618

그리고 아래의 내용을 추가해 주세요.


[원문]
Does the name of the function we're putting this in look familiar? Well it should if you were paying attention to all I've been saying for a long while now. No, this is not the same thing we had before. This is what the actual VGUI code is using to show our menus. See how it'll take the MenuID (in our case, 30), and then when it gets to case MENU_FIRSTMENU, since MenuID equals 30, it will show our FirstMenu, cool, huh?

Now then. We've made our ShowFirstMenu and CreateFirstMenu prototypes, and we've used the functions on several occasions in the code. But we still haven't implemented them! Let's go down to line 1618 and then add the following:

CODE (C++)
m_pClassMenu->setParent(this);
m_pClassMenu->setVisible( false );
}

// Start - VGUI Tutorial( 이 부분을 추가 )
//======================================================================================
// OUR FIRST MENU
//======================================================================================
// Show the FirstMenu
CMenuPanel* TeamFortressViewport::ShowFirstMenu()
{
// Don't open menus in demo playback
if ( gEngfuncs.pDemoAPI->IsPlayingback() )
return NULL;

m_pFirstMenu->Reset();
return m_pFirstMenu;
}

void TeamFortressViewport::CreateFirstMenu()
{
// Create the panel
m_pFirstMenu = new CFirstMenu(100, false, 0, 0, ScreenWidth, ScreenHeight);
m_pFirstMenu->setParent(this);
m_pFirstMenu->setVisible( false );
}
// End - VGUI Tutorial( 여기까지 추가 )

//======================================================================================
// SPECTATOR MENU



여기까지 왔군! 이제는 그냥 client.dll 을 compile 시키고 나서 여러분의 MOD의 cl_dlls 폴더에 옮기면 된다. HL1 또는 CS, Steam 등에서 여러분의 MOD를 "custom game" 으로 실행 하고나서 게임을 시작하면 된다. console에서 vguimenu 30을 적고 아래와 같은 메뉴가 나오는지 바라보라.


일단 "cl_dll files" 코드들을 client.dll 파일로 build 해야 합니다.
현재 VC++ 6.0 상태에서 왼쪽 Workspace를 보시게 되면 "cl_dll files" 와 "hl files" 두개의 project가 있을것입니다.

여기에서는 "cl_dll files" 부분을 build 해야 하기 때문에 "cl_dll files" 부분에 마우스 오른쪽 버튼을 눌러서 "Set as Active Project"를 눌러서 build 시킬 project를 활성화 시켜줍니다.

다음으로 VC++ 6.0 메뉴 -> Build -> Build client.dll 을 선택해 주세요. 또는 F7을 누르셔도 됩니다.

정확히 입력하셨다면 error 없이 client.dll 파일이 생성 되었을 것입니다.

이제 게임을 하기 위해서는 여러분이 만든 MOD안에 생성된 client.dll 파일을 넣어줘야 합니다.
정상적이라면(모드나라 http://mod.zoa.to 동영상 강좌를 보고 VC++ 6.0을 Setting 한 경우), client.dll 파일의 경로는 SDK/Single-Player Source/cl_dll/Debug/ 가 아닌 Steam/SteamApps/스팀_ID/half-life/나의_MOD_NAME/cl_dlls 입니다. 즉, Build 작업을 거쳐서 client.dll 파일이 생성될 디렉토리 위치입니다.

* SDK/... 에서 SDK는 여러분이 설치한 HL1 SDK 2.x의 경로입니다.

*** 위의 디렉토리로 설정이 되어있지 않다면 위에서 hl.dll 파일을 복사한것 처럼 복사를 해줘야 합니다. ***

이 디렉토리 SDK/Single-Player Source/cl_dll/Debug/ 에 있는 client.dll 파일을
여러분의 MOD 디렉토리의 cl_dlls 디렉토리에 복사를 합니다.
e.g., SDK/Single-Player Source/cl_dll/Debug/client.dll ---> Steam/SteamApps/스팀_ID/half-life/나의_MOD_NAME/cl_dlls/

그리고 게임을 실행해서 "~" tilde를 눌러서 게임의 console로 들어갑니다.
이때 명령창에 "vguimenu 30" 라고 입력합니다. (" double quote-따옴표-는 빼시고 입력하세요.)
정확히 하셨다면 아래의 화면과 같은 화면을 보실 수 있습니다. ^___^


[원문]
There we go! Now just compile your client.dll and move it to your mod's cl_dlls folder. Run Half-Life with your mod as your custom game, and start a game. In the console, type vguimenu 30 and, low and behold, the following pops up:

Figure #3


그래, 이것은 대한단 메뉴가 아니다. 하지만 이번 tutorial에서 메뉴를 어떻게 당신것으로 만드는지 보여주었다. 이것은 단지 기본적인 시작일 뿐이다(시작에 불과 하다.). part 2 에서 좀더 재미있는 우리의 메뉴를 확인하자(만들어 보자.).


[원문]
Yeah, it's not much of a menu. But this tutorial has shown you how you can create your own. This is just the basic start! Check out part 2 for more fun with our menu.

역주:
이제 게임내에서 어떻게 메뉴를 만드는지 아시겠지요? 여러분들도 MOD 게임 시작시에 괜찮은 메뉴를 만들어 보세요.
이 tutorial이 총 3부분으로 나누어져 있습니다. 앞으로 part 2, part 3 를 번역해서 만나 뵙도록하죠...

Ps: 처음엔 제가 존대말로 작성을 했는데요, 영어는 존대말보단 반말이 더 낫더군요. ^^; 미국말은 참 예의가 없지요...
혹시라도 번역상에 문제가 되는게 있다면 아래의 email로 spam을 마구 보내주세요... 보내주시면 정정하도록 하겠습니다.

지금까지 번역에 godmode ( godmode2k@hotmail.com ) 이었습니다.

끝까지 읽어주셔서 감사합니다.
수고하셨습니다.

댓글 없음:

댓글 쓰기