not sure about this one.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Athlon_Jedi
Posts: 156
Joined: Wed Jul 21, 2004 4:29 am
Location: Mishawaka, In

not sure about this one.

Post by Athlon_Jedi »

ok so i have been working on a skill management system for my project(MMO style).

now im trying to get the skills i have defined to display in a listbox.

here is the gui code i have so far:


Code: Select all


   //window
   IGUIWindow* mwin = pGUIEnv->addWindow(rect<s32>(10, 0, 408, 400), 0,L"UniComm");
   
   //listbox
   IGUIListBox* mwin2 = pGUIEnv->addListBox(rect<s32>(15, 100, 375, 325),0,-1,false);

   mwin->addChild(mwin2);
   //gui elements 
    gui::CGUIPanel* panel = new gui::CGUIPanel( pGUIEnv, pGUIEnv->getRootGUIElement(), -1,core::rect<s32>(10,0,408,400)
		,false,
            gui::ESBM_AUTOMATIC,
            gui::ESBM_ALWAYS_INVISIBLE );
	panel->setVisible(true);
    
    //put elements together
	//mwin->addChild(mwin2);
	//panel->addChild(mwin2);
    
	panel->fitChildrenToPanel();

    panel->drop();

    gui::CGUIExtendedText* text = new gui::CGUIExtendedText( pGUIEnv, panel, -1, core::rect<s32>(15,35,350,350) );
	
	//text color
    gui::CColorTextTag* color = new gui::CColorTextTag();
    color->addDefaultColors();
    text->addTextTag( color );
    color->drop();
    
	//gui images
    gui::CImageTextTag* img = new gui::CImageTextTag();
	img->addImage( L"warn", pDrv->getTexture("G:/ada1/ada1/debug/maps/blast1.jpg"), core::dimension2d<s32>(65,65) );
    img->addImage( L"life", pDrv->getTexture("G:/ada1/ada1/debug/maps/arm1.jpg"), core::dimension2d<s32>(65,65) );
    img->addImage( L"Psionic", pDrv->getTexture("G:/ada1/ada1/debug/maps/dbl4.jpg"), core::dimension2d<s32>(65,65) );
 //   img->addImage( L"armorbig", pDrv->getTexture("armor.png"), core::dimension2d<s32>(60,45) );
 //   img->addImage( L"star", pDrv->getTexture("star.png"), core::dimension2d<s32>(10,10) );
    text->addTextTag( img );
    img->drop();
    
  
    
    gui::CTabTextTag* tab = new gui::CTabTextTag( L"tab", 40 );
    text->addTextTag( tab );
    tab->drop();
    
    gui::CHLineTextTag* hline = new gui::CHLineTextTag();
    text->addTextTag( hline );
    hline->drop();
    
    gui::CAlignTextTag* align = new gui::CAlignTextTag();
    text->addTextTag( align );
    align->drop();
    
    text->setText( L"#img:armorbig:left#This will be the main user interface for Adabraxix, It can contain images: #img:warn# as well as #col:red#coloured text#col#."
                //   L"You can also change the #font:thick#font to something else#font# if you #col:yellow#would like to do so.#col#"
                   L"Here is an example of the tabulator:\n\n"
                   L"#tab##img:life# 140/350#tab##img:warn#Warning!\n"
                   L"#tab##img:warn# 170#tab##img:star# 25#hline#There are also horizontal lines.They can be coloured as well, and have variable width:"
                   L"#col:orange##hline:250##col#\n"
                   L"#img:warn:right##align:center#Text can be centered#align:right##img:Psionic#..or right-aligned #img:star##align#"
                   L"The two big images are \"anchored\" - they are anchored to either side and the text wraps around them."
                   L"#align:right#This text is right-aligned#align:center#And this is centered#align#" );
    
    text->setText( L"#img:armorbig:left#The leather armor offers good protection for the upper torso and shoulders. Electrical and fire attacks "
                   L"are especially well fend off by its hard leathers.\n\n"
                   L"#align:center##col:blue#Stats:#col##align##hline#\n"
                   L"#tab##img:armor# 17#tab##img:life# 35/35\n"
                   L"#tab##img:star# 26#tab##img:warn# #col:red#Can't use#col#\n" );

this is an adaptation of the extended gui system posted in the forum.

now , i have my skillmanager initializing the skills i have defined:

skillmanager.cpp

Code: Select all


#include "skillmanager.h"
#include <iostream>


CSkillManager::CSkillManager(void)
{
}

CSkillManager::~CSkillManager(void)
{
}

bool CSkillManager::Init(CGameCore* sManager)
{
	InitSkills();
	
	return true;
}

void CSkillManager::InitSkills()
{
	std::cout<<"Initializing Skills !!\n";
	//skill types ,names, and definitions  TODO: this is where we add skills for the game we wamt in it
	CGameSkill* sk_openlock = new CGameSkill(0, "Lock Picking" , SKILLTYPE_ACTION, 10);
	CGameSkill* sk_hacking = new CGameSkill(1, "Hacking" , SKILLTYPE_ACTION, 10);
	CGameSkill* sk_pistols = new CGameSkill(2, "Pistols" , SKILLTYPE_COMBAT, 10);
	CGameSkill* sk_rifles = new CGameSkill(3, "Riflery" , SKILLTYPE_COMBAT, 10);
    CGameSkill* sk_marksman = new CGameSkill(4, "Marksmanship" , SKILLTYPE_COMBAT, 10);
	CGameSkill* sk_heavyweapons = new CGameSkill(5, "Heavy Weapons" , SKILLTYPE_COMBAT, 10);
	CGameSkill* sk_explosives = new CGameSkill(6, "Explosives" ,SKILLTYPE_COMBAT, 10);
	//TODO : add more skills to basic skillset and others
	std::cout<<"Skills Initialized!!\n";
}

this also is adapted from a forum post.

now since i have CSkillManager::GetSkill();

defined in the skill manager class like so:

skillmanager.h

Code: Select all


//define the skillmanager class and set it up to work as part of the game management system

class CGameCore;

class CSkillManager
{
public:
	CSkillManager(void);
	~CSkillManager(void);

	void InitSkills(); //<----initialization call to initialize the skills defined in skills.h 
	bool Init(CGameCore* sManager);



	void GetSkill();//<-----------get my current skill level
//	bool Init(CGameCore* sManager);

    void Rise_Skill();//<----keeps track of skill training  levels and  what not
//	bool Init(CGameCore* sManager);

    void Use_Skill();//<----can I use the item with my skill lvl?
	//bool Init(CGameCore* sManager);



//TODO : Add more management funtions to improve skill system managment like
// saving and loading current skill levels and what skills the player has/doesnt have

private:
	CGameCore* sManager;
};
#endif
and finaly skills.h

Code: Select all

#ifndef _SKILLS_H_
#define _SKILLS_H_


#include "core.h"
#include <irrlicht.h>

using namespace irr;
using namespace core;
using namespace gui;
using namespace video;
using namespace scene;

class CGameCore;
//skill type definitions initialized at runtime and passed to the game management system
const int SKILLTYPE_PASSIVE = 0;  //passive
const int SKILLTYPE_COMBAT = 1;   //combat
const int SKILLTYPE_ACTION = 2;   //action skills
//TODO : add more skill types

class CGameSkill
{
public:
	CGameSkill(int sid, char* sname, int stype, int value); //initial declaration
	virtual ~CGameSkill();

	void SetSkillName(char* skillname); //set one name per skill
	void SetSkillID(int skillid);       //set skill id
	void SetSkillType(int skilltype);   //set skill type
	void SetSkillValue(int skillvalue); //skill value

	//get skill values
	char* GetSkillName();
	int GetSkillID();
	int GetSkillType();
	int GetSkillValue();

private:
	//skill atributes
	char* Skill_Name;
	int Skill_ID;
	int Skill_Type;
	int Skill_Value;
	CGameSkill* pSkill;
	CGameCore* sManager;
};
#endif

I am unclear how i would create the GetSkill(); Function then use that function to display the skills in question in a list box. everything i have thought of so far would create an endless loop or just plain break my app lol

anyone have any sugestions?
jreuschel1
Posts: 25
Joined: Sun Nov 12, 2006 7:51 pm
Contact:

Post by jreuschel1 »

This might help

Code: Select all

GetSkill(Char* SkillsToRetrieveList[], int count){  //count is the number of items in the list
	for(ctr=0;ctr<count;ctr++){
		populate listbox with data for SkillID from SkillsToRetrieveList[ctr] //where SkillsToRetrieveList[] holds a custom "Skill ID List"
		}
	}

______________________________________________________________________________


or if you already know how many skills total then get skills from an array

define constants like this

Code: Select all

#define sk_openLock 0
#define sk_hacking  1
#define sk_pistols  2
#define sk_rifles   3

#define num_sk      4
and use them for the array index

Code: Select all

CGameSkill *AllSkills[1000]  //very large array for skill storage
Then use the function from the top.

___________________________________________________________________________________
Post Reply