Register    Login    Forum    Search    FAQ

Board index » General Programming




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: ZPGUI Tutorial - Charactor Info - How to?
 Post Posted: Fri Feb 04, 2011 5:51 pm 
Offline
Site Admin

Joined: Sat Feb 19, 2011 1:33 am
Posts: 15
This 's example to create character information in your game.

Step 1 : Create Image layout of your GUI.
Image


Step 2 : Export Image each layer of GUI Control.
Image

Step 3 : Load Texture into your system.
Code:

      //Alpha Background for transparent background.
      pctvTexture->LoadTexture("AlphaBG.png", "AlphaBG",20,20,cTV_COLORKEY_USE_ALPHA_CHANNEL,false);
      //Char Info Mini.
      pctvTexture->LoadTexture("CharInfoMiniBG.png", "CharInfoMiniBG",326,119,cTV_COLORKEY_USE_ALPHA_CHANNEL,false);
      pctvTexture->LoadTexture("CHHPBar.png", "CHHPBar",162,18,cTV_COLORKEY_USE_ALPHA_CHANNEL,false);
      pctvTexture->LoadTexture("CHMPBar.png", "CHMPBar",162,18,cTV_COLORKEY_USE_ALPHA_CHANNEL,false);
      pctvTexture->LoadTexture("CHSPBar.png", "CHSPBar",138,18,cTV_COLORKEY_USE_ALPHA_CHANNEL,false);
      pctvTexture->LoadTexture("CHSPBarBG.png", "CHSPBarBG",138,16,cTV_COLORKEY_USE_ALPHA_CHANNEL,false);
      pctvTexture->LoadTexture("CHHPMPBarBG.png", "CHHPMPBarBG",162,16,cTV_COLORKEY_USE_ALPHA_CHANNEL,false);
      pctvTexture->LoadTexture("CharIMG.png", "CharIMG",80,80,cTV_COLORKEY_USE_ALPHA_CHANNEL,false);


Step 4 : Define structure object of GUI. ** This's example struct.
Code:
//CharInfo Mini
typedef struct ZP_STC_CHARINFOMINI
{
   ZPGuiSystem    clsGUI; // Main GUI System object.
   ZP_STC_SCALEBAREX stcHPBar; // for HP.
   ZP_STC_SCALEBAREX stcMPBar; // for MP.
   ZP_STC_SCALEBAREX stcSPBar; // for SP.
   ZP_STC_TEXTSHOWEX stcHPText; // for HP Text.
   ZP_STC_TEXTSHOWEX stcMPText; // for MP Text.
   ZP_STC_TEXTSHOWEX stcSPText; // for SP Text.
   ZP_STC_TEXTSHOWEX stcLevel; // for Level Text.
   ZP_STC_TEXTSHOWEX stcJob; // for Job Text. - Not use in example
   ZP_STC_TEXTSHOWEX stcName; // for Name Text.
   ZP_STC_IMAGE stcCharImage; // for Main Character Image.
}ZP_STC_CHARINFOMINI;
static struct ZP_STC_CHARINFOMINI pclsCHInfo;


Step 5 : Initial GUI. ** Position of Controls can get from your Image creater,It reference by GUI Object rect not window rect. expect Main Dialog reference window rect.
Code:
   pclsCHInfo.clsGUI.Initial();
   pclsCHInfo.clsGUI.CreateDlg("CharInfoMini",4,4,326,119,GetTex("CharInfoMiniBG"),false,0);
   pclsCHInfo.clsGUI.CreateDrag(-1,92,26,26,GetTex("MessageBoxDrag"));
   pclsCHInfo.clsGUI.SetDlgFade(ZP_FADEIN,300);
   pclsCHInfo.clsGUI.SetDlgFade(ZP_FADEOUT,300);
   pclsCHInfo.clsGUI.EnableDlg(true);  // Important . True or False

   pclsCHInfo.stcHPBar = pclsCHInfo.clsGUI.CreateScaleBarSLOT(133,32,162,16,ZP_SCALEBAR_HORIZONTAL,GetTex("CHHPMPBarBG"),GetTex("CHHPBar"));
   pclsCHInfo.stcMPBar = pclsCHInfo.clsGUI.CreateScaleBarSLOT(133,53,162,16,ZP_SCALEBAR_HORIZONTAL,GetTex("CHHPMPBarBG"),GetTex("CHMPBar"));
   pclsCHInfo.stcSPBar = pclsCHInfo.clsGUI.CreateScaleBarSLOT(133,74,138,16,ZP_SCALEBAR_HORIZONTAL,GetTex("CHSPBarBG"),GetTex("CHSPBar"));
   
   pclsCHInfo.stcLevel = pclsCharInfoMini.clsGUI.CreateTextShowSLOT(122,10,53,16,GetTex("AlphaBG"));
   pclsCHInfo.clsGUI.SetTextAlign(ZP_ALIGNCENTER,pclsCharInfoMini.stcLevel);
   pclsCHInfo.stcName = pclsCharInfoMini.clsGUI.CreateTextShowSLOT(202,10,74,16,GetTex("AlphaBG"));
   pclsCHInfo.clsGUI.SetTextAlign(ZP_ALIGNCENTER,pclsCharInfoMini.stcName);

   pclsCHInfo.stcHPText = pclsCharInfoMini.clsGUI.CreateTextShowSLOT(133,31,140,16,GetTex("AlphaBG"));
   pclsCHInfo.clsGUI.SetTextAlign(ZP_ALIGNCENTER,pclsCharInfoMini.stcHPText);
   pclsCHInfo.stcMPText = pclsCharInfoMini.clsGUI.CreateTextShowSLOT(133,52,140,16,GetTex("AlphaBG"));
   pclsCHInfo.clsGUI.SetTextAlign(ZP_ALIGNCENTER,pclsCharInfoMini.stcMPText);
   pclsCHInfo.stcSPText = pclsCharInfoMini.clsGUI.CreateTextShowSLOT(133,73,140,16,GetTex("AlphaBG"));
   pclsCHInfo.clsGUI.SetTextAlign(ZP_ALIGNCENTER,pclsCharInfoMini.stcSPText);
   pclsCHInfo.clsGUI.SetFont("Consolas","_10",pclsCharInfoMini.stcLevel.stcSR.lSID_F); // Set font each of control.
   pclsCHInfo.clsGUI.SetFont("Consolas","_10",pclsCharInfoMini.stcHPText.stcSR.lSID_F);
   pclsCHInfo.clsGUI.SetFont("Consolas","_10",pclsCharInfoMini.stcMPText.stcSR.lSID_F);
   pclsCHInfo.clsGUI.SetFont("Consolas","_10",pclsCharInfoMini.stcSPText.stcSR.lSID_F);

   pclsCHInfo.stcCharImage = pclsCHInfo.clsGUI.CreateImageSLOT(17,15,80,80,GetTex("CharIMG"));



Step 6 : Add GUI to ZPGuiMultiLayer - Option please see ZPGUI Tutorial - How to Multi GUI Dialog

Step 6 - 1 : Insert 3 Method to do GUI get working or use ZPGuiMultiLayer.

Code:
   pclsCHInfo.clsGUI.DoDlgLoop(MouseAbsObject);

/* ------------------  GUI Event --------------------*/

   pclsCHInfo.clsGUI.UpdateDlg();

   pclsCHInfo.clsGUI.RenderGUI(true);


Sample GUI Event.

- Update HP Bar and Text
Code:
      char strMsgBuff[ZP_MAX_CHARBUFFER];
      //Create text  "xxxx / xxxx "; no stuff in ZPGUI.
      CombineMsg(strMsgBuff,stcTotalStats.stcHP.lReal,stcTotalStats.stcHP.lMax,"/");
      
      //Set Text Meassage.
      pclsCHInfo.clsGUI.SetData(pclsCHInfo.stcHPText,strMsgBuff);
      //Update HP Scalebar.
      pclsCHInfo.clsGUI.DoScaleBar(pclsCHInfo.stcHPBar,(float)stcTotalStats.stcHP.lReal,(float)stcTotalStats.stcHP.lMax,ZP_INCREASE);
      //Option. - if you need Fast GUI Update,You must call UpdateDlg() method after change data event.
      pclsCHInfo.clsGUI.UpdateDlg();


Image


Top 
 Profile  
 
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 1 post ] 

Board index » General Programming


Who is online

Users browsing this forum: No registered users and 1 guest

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron