|
From: <sir...@us...> - 2006-05-26 18:38:22
|
Revision: 77 Author: sirisian Date: 2006-05-26 11:38:09 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/perceptioncrash/?rev=77&view=rev Log Message: ----------- Added Paths: ----------- trunk/perceptioncrash/src/item_system2/ trunk/perceptioncrash/src/item_system2/ItemManager.hpp trunk/perceptioncrash/src/item_system2/cDATA_itemSystem.hpp trunk/perceptioncrash/src/item_system2/cDATA_weaponItem.hpp trunk/perceptioncrash/src/item_system2/c_containerContents.hpp trunk/perceptioncrash/src/item_system2/c_itemSystem.hpp trunk/perceptioncrash/src/item_system2/c_unitWindow.hpp trunk/perceptioncrash/src/item_system2/c_weaponItem.hpp trunk/perceptioncrash/src/item_system2/class_text.h Added: trunk/perceptioncrash/src/item_system2/ItemManager.hpp =================================================================== --- trunk/perceptioncrash/src/item_system2/ItemManager.hpp (rev 0) +++ trunk/perceptioncrash/src/item_system2/ItemManager.hpp 2006-05-26 18:38:09 UTC (rev 77) @@ -0,0 +1,126 @@ +enum enumSupplyType{ +metal +}; + +enum enumUsuableType{ +buff +}; + +enum enumAmmoType{ +solid, +energy +}; + +enum enumEquipableType{ +ArmorHelmet, +ArmorBody, +ArmorGauntlets, +ArmorLegs +}; + +//class c_itemInventory; +struct s_dataRange +{ + int min, max;//The minimum and maximum of the range. +}; +#include "cDATA_itemSystem.hpp" +#include "c_itemSystem.hpp" +#include "c_unitWindow.hpp" + + +class c_itemManager +{ +private: + +public: + cDATA_itemData itemData; + std::vector<c_itemInventory*> itemContainerArray; + c_unitWindow unitWindow; + + c_itemManager::c_itemManager(){ + + } + + void InitializeItemData(std::string name){ + + + TiXmlDocument configFile; + TiXmlElement* configNode; + /// @todo This should load the file using the Ogre resource manager + //configFile.Parse(&(Ogre::ResourceGroupManager::getSingleton().openResource("config.xml")->getAsString()[0])); + configFile.LoadFile("data/config.xml"); + configNode = dynamic_cast<TiXmlElement*>(configFile.RootElement()->FirstChild("Item")); + assert(configNode != 0); + + + throw std::runtime_error("Controller '" + name + "' already exists"); + + + TiXmlElement* node; + InputManager* inputManager = InputManager::getSingletonPtr(); + inputManager->getEventProcessor()->addKeyListener(this); + inputManager->getEventProcessor()->addMouseMotionListener(this); + + // Make sure we were given the right kind of node + if (static_cast<std::string>(node->Value()) != "item") + { + throw std::runtime_error("Invalid XML node. Must be element called item."); + } + static_cast<std::string>(node->Attribute("type")) + for (TiXmlNode* child = node->FirstChild(); child; child = child->NextSibling()) + { + TiXmlElement* nodeItemData = dynamic_cast<TiXmlElement*>(child); + + if (nodeItemData == 0) + continue; + //nodeItemData->Attribute("classification", &classification); + std::string classification = 0; + + itemData.addItem( + static_cast<std::string>(node->Attribute("classification")), + static_cast<std::string>(node->Attribute("name")), + static_cast<std::string>(node->Attribute("size")) + static_cast<std::string>(node->Attribute("rariety")) + static_cast<std::string>(node->Attribute("questNumber")) + ); + if(nodeItemData->Attribute("classification")=="supply"){ + + }else if(nodeItemData->Attribute("classification")=="usuable"){ + + } + + Button to; + + + to = nodeItemData->Attribute("to"); + + createKeyboardInputButton(to, from); + } + } + /* + itemData.addItem("supply", "iron ore", 10, 0, 0); + dynamic_cast<cDATA_supplyItem&>(itemData.editLastCreated()).supplyType = metal; + itemData.addItem("supply", "copper ore", 10, 0, 0); + itemData.addItem("supply", "coal ore", 10, 0, 0); + itemData.addItem("supply", "steel bar", 10, 1, 0); + itemData.addItem("supply", "bronze bar", 10, 1, 0); + itemData.addItem("supply", "electronic chip", 10, 1, 0); + itemData.addItem("supply", "copper bar", 10, 1, 0); + itemData.addItem("supply", "alloy", 10, 2, 0); + itemData.addItem("supply", "steel plate", 10, 2, 0); + itemData.addItem("usuable", "medkit", 10, 1, 0); + itemData.addItem("usuable", "drugs", 10, 2, 0); + itemData.addItem("weapon", "m16", 10, 2, 0); + //dynamic_cast<cDATA_usuableItem&>(itemData.editLastCreated()).attributeBuffs.addBuff("health rejuvenation", 10, 100); + //dynamic_cast<cDATA_usuableItem&>(itemData.editLastCreated()).attributeBuffs.addBuff("speed", -10, 50); + //itemData.editLastCreated().supplyType = metal; + */ + } + + void addItemContainer(){ + itemInventoryData.push_back(c_itemInventory); + } + + + +}; Added: trunk/perceptioncrash/src/item_system2/cDATA_itemSystem.hpp =================================================================== --- trunk/perceptioncrash/src/item_system2/cDATA_itemSystem.hpp (rev 0) +++ trunk/perceptioncrash/src/item_system2/cDATA_itemSystem.hpp 2006-05-26 18:38:09 UTC (rev 77) @@ -0,0 +1,138 @@ +#ifndef ITEM_DATA_HPP +#define ITEM_DATA_HPP + +class cDATA_buff +{ + struct s_statBuff + { + std::string buffType; + std::string attributeName; + int value; + int duration; + }; +public: + std::vector<s_statBuff> buffArray; + void addBuff(std::string buffType, std::string attributeName,int value, int duration){ // you'd add a buff like itemData.editLastCreated().addBuff("health rejuvenation", 10,100); meaning a buff of 10 to health rujevenation over 100 time + buffArray.push_back(s_statBuff()); + buffArray[buffArray.size()-1].type = type; + buffArray[buffArray.size()-1].attributeName = attributeName; + buffArray[buffArray.size()-1].value = value; + buffArray[buffArray.size()-1].duration = duration; + } + std::vector<cDATA_buff::s_statBuff> & getBuffs(){ + return buffArray; + } +}; + +class cDATA_item +{ +public: + virtual cDATA_item::~cDATA_item(){} + + std::string name; + std::string classification; + int size; + int rarity; + int questNumber; +}; + +class cDATA_supplyItem: public cDATA_item +{ +public: + enumSupplyType supplyType; +}; + +class cDATA_usuableItem: public cDATA_item +{ +public: + enumUsuableType usuableType; + int numberOfUses; + int cooldownPerUse; + cDATA_buff attributeBuffs; +}; + +class cDATA_ammoItem: public cDATA_item +{ +public: + enumAmmoType ammoType; + + cDATA_ammoItem::cDATA_ammoItem(){ + + } +}; + +class cDATA_equipableItem: public cDATA_item +{ +public: + enumEquipableType equipableType; + cDATA_buff attributeBuffs; + + cDATA_equipableItem::cDATA_equipableItem(){ + + } + cDATA_equipableItem::~cDATA_equipableItem(){ + + } +}; +#include "cDATA_weaponItem.hpp" + +class cDATA_itemDataFactory +{ +public: + cDATA_item *Create(std::string classification) + { + if(classification=="supply") + return new cDATA_supplyItem; + else if(classification=="usuable") + return new cDATA_usuableItem; + else if(classification=="ammo") + return new cDATA_ammoItem; + else if(classification=="equipable") + return new cDATA_equipableItem; + else if(classification=="weapon") + return new cDATA_weaponItem; + } +}; +class cDATA_itemData +{ +private: +cDATA_itemDataFactory itemDataFactory; + +public: + std::vector<cDATA_item*> itemData; + int lastIndex; + + cDATA_itemData::cDATA_itemData(){ + listIndex = 0; + listSize = 10; + } + + cDATA_itemData::~cDATA_itemData(){ + while(!itemData.empty()){ + delete itemData[itemData.size()-1]; + itemData.pop_back(); + } + } + + void addItem(std::string classification, std::string name, int size, int rarity, int questNumber) + { + itemData.push_back(itemDataFactory.Create(classification)); + + itemData[itemData.size()-1]->name = name; + itemData[itemData.size()-1]->classification = classification; + itemData[itemData.size()-1]->size = size; + itemData[itemData.size()-1]->rarity = rarity; + itemData[itemData.size()-1]->questNumber = questNumber; + lastIndex=itemData.size()-1; + } + + cDATA_item & editLastCreated(){ + return * itemData[lastIndex]; + } + + cDATA_item & editItemData(int index){ + return *itemData[index]; + } + +}; +#endif /* ITEM_DATA_HPP */ Added: trunk/perceptioncrash/src/item_system2/cDATA_weaponItem.hpp =================================================================== --- trunk/perceptioncrash/src/item_system2/cDATA_weaponItem.hpp (rev 0) +++ trunk/perceptioncrash/src/item_system2/cDATA_weaponItem.hpp 2006-05-26 18:38:09 UTC (rev 77) @@ -0,0 +1,117 @@ +struct s_color +{ + int r, g, b, a;//red,green,blue,alpha +}; +class cDATA_weaponItem : public cDATA_equipableItem +{ + struct s_modeAccuracy + { + int value;//Accuracy of the Gun -(value) to value modifier + int add;//Amount to add to accuracy when firing + int delay;//How many bullets have to be fired before the COF goes up + int delayTime;//The amount of time for the delay to reset + int cooldownTime;//The time it takes for the accuracy modifier to go down + int cooldownAmount;//The amount the accuracy will go down after the counter equals the time + //add crouch values later + }; + struct s_modeFireRate + { + int value;//Rate at which bullets are fired + int fireModeIndex; + int reFireRate; + int reFireModeIndex; + }; + struct s_modeChargeRate + { + int chargeType;//Charge for Each Bullet, Only Burst Fire, Only ShotGun + int value;//The amount the gun has to charge before firing + bool lockTheGun;//When performing the structures action is the gun locked from doing other things? + }; + struct s_modeStatMod + { + s_dataRange speed; + s_dataRange range; + //ect to have all the mods possible + int fireModeIndex; + }; + struct s_modeReload + { + int value;//The time it takes to reload + bool lockTheGun;//When performing the structures action is the gun locked from doing other things? + int fireModeIndex;//redirects to another firing mode if not its own + }; + struct s_modeBurstShot + { + int value;//How many times the Gun burst shots. + bool lockTheGun;//When performing the structures action is the gun locked from doing other things? + int fireModeIndex;//redirects to another firing mode if not its own + }; + struct s_modeSpreadShot//The number of projectiles fired at one time + { + int value; + bool lockTheGun;//When performing the structures action is the gun locked from doing other things? + int fireModeIndex;//redirects to another firing mode if not its own + }; + struct s_modeAmmoAndClip + { + int ammoType;//Solid, Energy, Grenade, Rocket + int caliber;//The size of the Rounds + int clipType;//Normal Magazine, Banana Clip, Shell Clip, Top-Load Magazine, Canister + s_dataRange speed;//Ammo has different speed classifications, 0-100, and the gun can only use ammo between two values + s_dataRange damageClass;//Ammo has different damage classifications, 0-100, and the gun can only use ammo between two values + s_dataRange range;//Ammo has different range classifications, 0-100, and the gun can only use ammo between two values + s_dataRange ammoCapacity;//Ammo has different ammo capacity classifications, 0-100, and the gun can only use ammo between two values + int fireModeIndex;//redirects to another firing mode if not its own + }; + struct s_modeParticles //When gun is fired, the particles that are created + { + s_color color; + int image; + int interval; + int amount; + int range; + int speed; + s_dataRange angle; + int fireModeIndex;//redirects to another firing mode if not its own + }; + struct s_modeMelee + { + bool value;//Whether the gun can melee + int range;//The range of the melee attack + int baseDamage;//The normal damage of the melee + int modDamage;//Any extra damage the gun may do + int interval;//The time it takes to melee with the weapon + }; + struct s_firingMode + { + s_modeAccuracy accuracy; + s_modeFireRate fireRate; + s_modeChargeRate chargeRate; + s_modeStatMod statMod; + s_modeReload reload; + s_modeBurstShot burstShot; + s_modeSpreadShot spreadShot; + s_modeAmmoAndClip ammoAndClip; + s_modeParticles fireParticles; + }; + +private: + s_modeMelee melee; + std::vector<s_firingMode> firingModes; + +public: + cDATA_weaponItem::cDATA_weaponItem(){ + + } + void Initialize(int numberOfFiringModes){ + for(int expandFiringModes = 0; expandFiringModes < numberOfFiringModes; ++expandFiringModes){ + firingModes.push_back(s_firingMode()); + } + } + s_firingMode & cDATA_weaponItem::editFiringMode(int firingMode){ + return firingModes[firingMode]; + } + s_modeMelee & cDATA_weaponItem::editMelee(int firingMode){ + return melee; + } +}; Added: trunk/perceptioncrash/src/item_system2/c_containerContents.hpp =================================================================== --- trunk/perceptioncrash/src/item_system2/c_containerContents.hpp (rev 0) +++ trunk/perceptioncrash/src/item_system2/c_containerContents.hpp 2006-05-26 18:38:09 UTC (rev 77) @@ -0,0 +1,34 @@ +class c_specificItemGroup +{ + struct s_specificItem + { + int itemDataIndex; + int quantity; + }; + struct s_randomItem + { + s_dataRange rarity; + }; + struct s_randomTypeItem + { + std::string type; + s_dataRange rarity; + }; + struct s_containerContents + { + std::vector<s_specificItem> specificItemArray; + std::vector<s_randomItem> randomItemArray; + std::vector<s_randomTypeItem> randomTypeItemArray; + }; +private: + std::vector<s_containerContents> mContainerContents; +public: + std::map< std::string, int> SpecificContainerMap; + c_specificContents::c_specificContents(){} + +void addItemGroup(std::string){ +mContainerContents.push_back(new +SpecificContainerMap[std::string] = +} + +}; Added: trunk/perceptioncrash/src/item_system2/c_itemSystem.hpp =================================================================== --- trunk/perceptioncrash/src/item_system2/c_itemSystem.hpp (rev 0) +++ trunk/perceptioncrash/src/item_system2/c_itemSystem.hpp 2006-05-26 18:38:09 UTC (rev 77) @@ -0,0 +1,113 @@ +class c_item +{ +public: + virtual c_item::~c_item(){} + int itemDataIndex; + int quantity; + bool slotUsed; +}; + +class c_supplyItem: public c_item +{ +public: + +}; + +class c_usuableItem: public c_item +{ +public: + enumUsuableType usuableType; + int amountLeft; + int cooldownCounter; + c_usuableItem::c_usuableItem(){ + amountLeft = 0; + cooldownCounter = 0; + } +}; + +class c_ammoItem: public c_item +{ +public: + enumAmmoType ammoType; + + c_ammoItem::c_ammoItem(){ + + } +}; + +class c_equipableItem: public c_item +{ +public: + c_equipableItem::c_equipableItem(){ + + } + c_equipableItem::~c_equipableItem(){} +}; +#include "c_weaponItem.hpp" +class c_itemDataFactory +{ +public: + c_item *Create(std::string classification) + { + if(classification=="supply") + return new c_supplyItem; + else if(classification=="usuable") + return new c_usuableItem; + else if(classification=="ammo") + return new c_ammoItem; + else if(classification=="equipable") + return new c_equipableItem; + else if(classification=="weapon") + return new c_weaponItem; + } +}; + +class c_itemInventory +{ +private: + c_itemDataFactory itemDataFactory; +public: + bool slotUsed; + std::vector<c_item*> itemInventoryData; + + c_itemInventory::c_itemInventory(){ + + } + + c_itemInventory::~c_itemInventory(){ + while(!itemInventoryData.empty()){ + delete itemInventoryData[itemInventoryData.size()-1]; + itemInventoryData.pop_back(); + } + } + + void addItem(cDATA_itemData & itemData, int itemDataIndex, int quantity) + { + + for(int cycleItems = 0; cycleItems < itemInventoryData.size(); ++cycleItems){ + if(itemInventoryData[cycleItems]->slotUsed == false){ + delete itemInventoryData[cycleItems]; + itemInventoryData[cycleItems] = itemDataFactory.Create(itemData.itemData[itemDataIndex]->classification); + itemInventoryData[cycleItems]->slotUsed = true; + itemInventoryData[cycleItems]->itemDataIndex = itemDataIndex; + itemInventoryData[cycleItems]->quantity = quantity; + return; + } + } + + itemInventoryData.push_back(itemDataFactory.Create(itemData.itemData[itemDataIndex]->classification)); + itemInventoryData[itemInventoryData.size()-1]->slotUsed = true; + itemInventoryData[itemInventoryData.size()-1]->itemDataIndex = itemDataIndex; + itemInventoryData[itemInventoryData.size()-1]->quantity = quantity; + } + + c_item & editItemData(int index){ + return *itemInventoryData[index]; + } + + void removeItem(int index){ + itemInventoryData[index]->slotUsed = false; + itemInventoryData.erase( itemInventoryData.begin()+index ); + } + +}; Added: trunk/perceptioncrash/src/item_system2/c_unitWindow.hpp =================================================================== --- trunk/perceptioncrash/src/item_system2/c_unitWindow.hpp (rev 0) +++ trunk/perceptioncrash/src/item_system2/c_unitWindow.hpp 2006-05-26 18:38:09 UTC (rev 77) @@ -0,0 +1,218 @@ +class c_unitWindow +{ + struct s_equipmentTile + { + int X, Y, alpha; + }; +private: + std::vector<s_equipmentTile> equipmentTileArray; + + int itemDatalistIndex; + int itemDatalistSize; + int itemDatalistCounter; + +public: + c_unitWindow::c_unitWindow(){ + for(int expandArray = 0; expandArray < 21; ++expandArray){ + equipmentTileArray.push_back(s_equipmentTile()); + equipmentTileArray[equipmentTileArray.size()-1].alpha = 255; + } + equipmentTileArray[0].X = 70; + equipmentTileArray[0].Y = 0; + equipmentTileArray[1].X = 140; + equipmentTileArray[1].Y = 0; + equipmentTileArray[2].X = 70; + equipmentTileArray[2].Y = 70; + equipmentTileArray[3].X = 70; + equipmentTileArray[3].Y = 130; + equipmentTileArray[4].X = 0; + equipmentTileArray[4].Y = 70; + equipmentTileArray[5].X = 0; + equipmentTileArray[5].Y = 130; + equipmentTileArray[6].X = 30; + equipmentTileArray[6].Y = 200; + equipmentTileArray[7].X = 30; + equipmentTileArray[7].Y = 260; + equipmentTileArray[8].X = 30; + equipmentTileArray[8].Y = 330; + + equipmentTileArray[9].X = 230; + equipmentTileArray[9].Y = 10; + equipmentTileArray[10].X = 230; + equipmentTileArray[10].Y = 70; + equipmentTileArray[11].X = 230; + equipmentTileArray[11].Y = 130; + equipmentTileArray[12].X = 230; + equipmentTileArray[12].Y = 190; + equipmentTileArray[13].X = 230; + equipmentTileArray[13].Y = 260; + equipmentTileArray[14].X = 230; + equipmentTileArray[14].Y = 320; + equipmentTileArray[15].X = 230; + equipmentTileArray[15].Y = 390; + //Transparent Counterparts + equipmentTileArray[16].X = 140; + equipmentTileArray[16].Y = 70; + equipmentTileArray[16].alpha = 175; + equipmentTileArray[17].X = 140; + equipmentTileArray[17].Y = 130; + equipmentTileArray[17].alpha = 175; + equipmentTileArray[18].X = 110; + equipmentTileArray[18].Y = 200; + equipmentTileArray[18].alpha = 175; + equipmentTileArray[19].X = 110; + equipmentTileArray[19].Y = 260; + equipmentTileArray[19].alpha = 175; + equipmentTileArray[20].X = 110; + equipmentTileArray[20].Y = 330; + equipmentTileArray[20].alpha = 175; + } + /* + void show(int offsetX, int offsetY){ + for(int cycleEquipmentTiles = 0; cycleEquipmentTiles < equipmentTileArray.size(); ++cycleEquipmentTiles){ + glColor4ub(255, 255, 255, equipmentTileArray[cycleEquipmentTiles].alpha); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glEnable (GL_BLEND); + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, IMGequipmentTile); + glBegin(GL_QUADS); + setVertexAndTexCoords(equipmentTileArray[cycleEquipmentTiles].X+offsetX, equipmentTileArray[cycleEquipmentTiles].Y+offsetY,60,60,64,64,0.0f,0.0f); + glEnd(); + glDisable(GL_TEXTURE_2D); + glDisable (GL_BLEND); + } + } + */ + //ItemData Stuff + /* + void checkClick(int mouseX, int mouseY, bool mouseDown, int offsetX, int offsetY){ + if(listCounter<10) + listCounter++; + if(mouseDown==true && listCounter == 10){ + listCounter = 0; + if(mouseX>offsetX && mouseX<offsetX+200 && mouseY>offsetY && mouseY<offsetY+20) + if(listIndex > 0) listIndex--; + + if(mouseX>offsetX && mouseX<offsetX+200 && mouseY>offsetY+(listSize+1)*20 && mouseY<offsetY+20+(listSize+1)*20) + if(listIndex+listSize < itemData.size()) listIndex++; + } + } + + void show(int offsetX, int offsetY){ + glBegin(GL_QUADS); + glColor4ub(200, 200, 200, 255); + glVertex2f(offsetX, offsetY); + glVertex2f(200+offsetX, offsetY); + glVertex2f(200+offsetX, 20+offsetY); + glVertex2f(offsetX, 20+offsetY); + glEnd(); + for(int cycleDataItems = listIndex, drawY = 0; cycleDataItems<(listIndex + listSize > itemData.size() ? itemData.size() : listIndex + listSize); ++cycleDataItems, ++drawY){ + glBegin(GL_QUADS); + glColor4ub(150, 150, 150, 255); + glVertex2f(offsetX, drawY*20+20+offsetY); + glVertex2f(200+offsetX, drawY*20+20+offsetY); + glVertex2f(200+offsetX, drawY*20+40+offsetY); + glVertex2f(offsetX, drawY*20+40+offsetY); + glEnd(); + switch(itemData[cycleDataItems]->rareness){ + case 0: + drawglyphs(itemData[cycleDataItems]->name, 60, 100+offsetX, 5+drawY*20+20+offsetY, 0, 3, 0, 204, 0, 255); + break; + case 1: + drawglyphs(itemData[cycleDataItems]->name, 60, 100+offsetX, 5+drawY*20+20+offsetY, 0, 3, 255, 255, 0, 255); + break; + case 2: + drawglyphs(itemData[cycleDataItems]->name, 60, 100+offsetX, 5+drawY*20+20+offsetY, 0, 3, 204, 0, 255, 255); + break; + } + } + glBegin(GL_QUADS); + glColor4ub(200, 200, 200, 255); + glVertex2f(offsetX, (listSize+1)*20+offsetY); + glVertex2f(200+offsetX, (listSize+1)*20+offsetY); + glVertex2f(200+offsetX, (listSize+1)*20+20+offsetY); + glVertex2f(offsetX, (listSize+1)*20+20+offsetY); + glEnd(); + + drawglyphs("up", 60, 100+offsetX, 5+offsetY, 0, 3, 0, 204, 0, 255); + drawglyphs("down", 60, 100+offsetX, 5+(listSize+1)*20+offsetY, 0, 3, 0, 204, 0, 255); + } + */ + //Item List Stuff + /* + void checkClick(int mouseX, int mouseY, bool mouseDown, int offsetX, int offsetY){ + if(listCounter<10) + listCounter++; + if(mouseDown==true && listCounter == 10){ + listCounter = 0; + if(mouseX>offsetX && mouseX<offsetX+200 && mouseY>offsetY && mouseY<offsetY+20) + if(listIndex > 0) listIndex--; + + if(mouseX>offsetX && mouseX<offsetX+200 && mouseY>offsetY+(listSize+1)*20 && mouseY<offsetY+20+(listSize+1)*20) + if(listIndex+listSize < itemInventoryData.size()) listIndex++; + + for(int cycleItems = listIndex, checkY = 0; cycleItems < (listIndex+listSize<itemInventoryData.size() ? listIndex+listSize : itemInventoryData.size()); ++cycleItems, ++checkY){ + if(itemInventoryData[cycleItems]->slotUsed == true){ + if(mouseX>offsetX && mouseX<offsetX+200 && mouseY>offsetY+20+checkY*20 && mouseY<offsetY+40+checkY*20){ + this->removeItem(cycleItems); + break; + } + } + } + } + } + */ + + /* + void show(int offsetX, int offsetY, cDATA_itemData & itemData){ + glBegin(GL_QUADS); + glColor4ub(200, 200, 200, 255); + glVertex2f(offsetX, offsetY); + glVertex2f(200+offsetX, offsetY); + glVertex2f(200+offsetX, 20+offsetY); + glVertex2f(offsetX, 20+offsetY); + glEnd(); + for(int cycleDataItems = listIndex, drawY = 0; cycleDataItems<(listIndex + listSize > itemInventoryData.size() ? itemInventoryData.size() : listIndex + listSize); ++cycleDataItems, ++drawY){ + if(itemInventoryData[cycleDataItems]->slotUsed == true){ + glBegin(GL_QUADS); + glColor4ub(150, 150, 150, 255); + glVertex2f(offsetX, drawY*20+20+offsetY); + glVertex2f(200+offsetX, drawY*20+20+offsetY); + glVertex2f(200+offsetX, drawY*20+40+offsetY); + glVertex2f(offsetX, drawY*20+40+offsetY); + glEnd(); + + switch(itemData.itemData[itemInventoryData[cycleDataItems]->itemDataIndex]->rareness){ + case 0: + drawglyphs(itemData.itemData[itemInventoryData[cycleDataItems]->itemDataIndex]->name, 60, 100+offsetX, 5+drawY*20+20+offsetY, 0, 3, 0, 204, 0, 255); + break; + case 1: + drawglyphs(itemData.itemData[itemInventoryData[cycleDataItems]->itemDataIndex]->name, 60, 100+offsetX, 5+drawY*20+20+offsetY, 0, 3, 255, 255, 0, 255); + break; + case 2: + drawglyphs(itemData.itemData[itemInventoryData[cycleDataItems]->itemDataIndex]->name, 60, 100+offsetX, 5+drawY*20+20+offsetY, 0, 3, 204, 0, 255, 255); + break; + } + }else{ + glBegin(GL_QUADS); + glColor4ub(255, 0, 255, 255); + glVertex2f(offsetX, drawY*20+20+offsetY); + glVertex2f(200+offsetX, drawY*20+20+offsetY); + glVertex2f(200+offsetX, drawY*20+40+offsetY); + glVertex2f(offsetX, drawY*20+40+offsetY); + glEnd(); + } + } + glBegin(GL_QUADS); + glColor4ub(200, 200, 200, 255); + glVertex2f(offsetX, (listSize+1)*20+offsetY); + glVertex2f(200+offsetX, (listSize+1)*20+offsetY); + glVertex2f(200+offsetX, (listSize+1)*20+20+offsetY); + glVertex2f(offsetX, (listSize+1)*20+20+offsetY); + glEnd(); + + drawglyphs("up", 60, 100+offsetX, 5+offsetY, 0, 3, 0, 204, 0, 255); + drawglyphs("down", 60, 100+offsetX, 5+(listSize+1)*20+offsetY, 0, 3, 0, 204, 0, 255); + } + */ +}; Added: trunk/perceptioncrash/src/item_system2/c_weaponItem.hpp =================================================================== --- trunk/perceptioncrash/src/item_system2/c_weaponItem.hpp (rev 0) +++ trunk/perceptioncrash/src/item_system2/c_weaponItem.hpp 2006-05-26 18:38:09 UTC (rev 77) @@ -0,0 +1,78 @@ +class c_weaponItem : public c_equipableItem +{ + struct s_modeAccuracy + { + int delayCounter; + int cooldownCounter; + //add crouch values later + }; + struct s_modeFireRate + { + int rateCounter; + int reFireRateCounter; + }; + struct s_modeChargeRate + { + int chargeCounter; + }; + struct s_modeStatMod + { + int speedMod; + int rangeMod; + //ect to have all the mods possible + }; + struct s_modeReload + { + int counter; + }; + struct s_modeBurstShot + { + int counter; + }; + struct s_modeSpreadShot//The number of projectiles fired at one time + { + int counter; + }; + struct s_modeAmmoAndClip + { + int itemNumber; + }; + struct s_modeParticles //When gun is fired, the particles that are created + { + int intervalCounter; + }; + struct s_modeMelee + { + int modDamage;//Any extra damage the gun may do + int intervalCounter;//a counter to keep track of when the gun can melee again + }; + struct s_firingMode + { + s_modeAccuracy accuracy; + s_modeFireRate fireRate; + s_modeChargeRate chargeRate; + s_modeStatMod statMod; + s_modeReload reload; + s_modeBurstShot burstShot; + s_modeSpreadShot spreadShot; + s_modeAmmoAndClip ammoAndClip; + }; +private: + s_modeMelee melee; + std::vector<s_firingMode> firingModes; +public: + c_weaponItem::c_weaponItem(){ + + } + void Initialize(int numberOfFiringModes){ + for(int expandFiringModes = 0; expandFiringModes < numberOfFiringModes; ++expandFiringModes){ + firingModes.push_back(s_firingMode()); + } + } + c_weaponItem::s_firingMode & editFiringMode(int firingMode){ + return firingModes[firingMode]; + } + c_weaponItem::s_modeMelee & editMeleeMode(int firingMode){ + return melee; + } +}; Added: trunk/perceptioncrash/src/item_system2/class_text.h =================================================================== --- trunk/perceptioncrash/src/item_system2/class_text.h (rev 0) +++ trunk/perceptioncrash/src/item_system2/class_text.h 2006-05-26 18:38:09 UTC (rev 77) @@ -0,0 +1,331 @@ +#ifndef textFunction +#define textFunction +struct s_textColor +{ +int red, green, blue, alpha; +}; +struct s_text +{ +bool slotUsed; +int fontSize; +int x,y,width; +int alignment; +s_textColor textColor; +std::string preText; +//double * variable; +//std::string postText; +}; + +void drawglyphs(std::string tempstring, int fontsize, int x, int y, int w, int alignment, int r, int g, int b, int a){ +int wc=0; +float size = float(fontsize)/100; +std::string::size_type length; +length=tempstring.size(); +switch(alignment){ +case 0: + break; +case 1: + w=length; + break; +case 2: + x-=int(size*20.0)*w/2; + break; +case 3: + w=length; + x-=int(size*20.0)*w/2; + break; +case 4: + x-=int(size*20.0)*w; + break; +case 5: + w=length; + x-=int(size*20.0)*w; + break; +default: + break; +} +float gridx,gridy,gridwidth,gridheight; + gridwidth = 16; + gridheight = 16; + for(int drawglyph=0;drawglyph<length;drawglyph++){ + switch(tempstring[drawglyph]){ + case ' ': + gridx = -16; + gridy = -16; + break; + case 'a': + gridx = 0; + gridy = 0; + break; + case 'b': + gridx = 16; + gridy = 0; + break; + case 'c': + gridx = 32; + gridy = 0; + break; + case 'd': + gridx = 48; + gridy = 0; + break; + case 'e': + gridx = 64; + gridy = 0; + break; + case 'f': + gridx = 80; + gridy = 0; + break; + case 'g': + gridx = 96; + gridy = 0; + break; + case 'h': + gridx = 112; + gridy = 0; + break; + case 'i': + gridx = 128; + gridy = 0; + break; + case 'j': + gridx = 144; + gridy = 0; + break; + case 'k': + gridx = 0; + gridy = 16; + break; + case 'l': + gridx = 16; + gridy = 16; + break; + case 'm': + gridx = 32; + gridy = 16; + break; + case 'n': + gridx = 48; + gridy = 16; + break; + case 'o': + gridx = 64; + gridy = 16; + break; + case 'p': + gridx = 80; + gridy = 16; + break; + case 'q': + gridx = 96; + gridy = 16; + break; + case 'r': + gridx = 112; + gridy = 16; + break; + case 's': + gridx = 128; + gridy = 16; + break; + case 't': + gridx = 144; + gridy = 16; + break; + case 'u': + gridx = 0; + gridy = 32; + break; + case 'v': + gridx = 16; + gridy = 32; + break; + case 'w': + gridx = 32; + gridy = 32; + break; + case 'x': + gridx = 48; + gridy = 32; + break; + case 'y': + gridx = 64; + gridy = 32; + break; + case 'z': + gridx = 80; + gridy = 32; + break; + case '0': + gridx = 96; + gridy = 32; + break; + case '1': + gridx = 112; + gridy = 32; + break; + case '2': + gridx = 128; + gridy = 32; + break; + case '3': + gridx = 144; + gridy = 32; + break; + case '4': + gridx = 0; + gridy = 48; + break; + case '5': + gridx = 16; + gridy = 48; + break; + case '6': + gridx = 32; + gridy = 48; + break; + case '7': + gridx = 48; + gridy = 48; + break; + case '8': + gridx = 64; + gridy = 48; + break; + case '9': + gridx = 80; + gridy = 48; + break; + case ',': + gridx = 96; + gridy = 48; + break; + case '/': + gridx = 112; + gridy = 48; + break; + case '-': + gridx = 128; + gridy = 48; + break; + } + wc++; + if(gridx!=-16||gridy!=-16){ + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glColor4ub(r, g, b, a); + + glEnable (GL_BLEND); + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, fontMap); + glBegin(GL_QUADS); + glTexCoord2f(gridx/256, gridy/64); + glVertex2f(x,y); + glTexCoord2f((gridx+16)/256, gridy/64); + glVertex2f(x+int(size*16),y); + glTexCoord2f((gridx+16)/256, (gridy+16)/64); + glVertex2f(x+int(size*16),y+int(size*16)); + glTexCoord2f(gridx/256, (gridy+16)/64); + glVertex2f(x,y+int(size*16)); + glEnd(); + glDisable(GL_TEXTURE_2D); + glDisable (GL_BLEND); + } + x+=int(size*20); + if(wc==w){ + wc=0; + x-=w*int(size*20); + y+=int(size*20); + } + } +} + +class class_text +{ +private: +int lastIndexAdded; +std::vector<s_text> textArray; + +public: + class_text::class_text(){ + + } + void class_text::addText(std::string preText, int x, int y, int width, int fontSize,std::string alignment, s_textColor textColor){//, double &variable, std::string postText + bool textOpen = false; //Used to see if any command buttons that were made arn't being used. + for(short expandTextArray = 0; expandTextArray<textArray.size(); ++expandTextArray){ + if(textArray[expandTextArray].slotUsed == false){ + textOpen = true; + break; + } + } + if(textOpen==false){ + textArray.push_back(s_text()); + textArray[textArray.size()-1].slotUsed = false; + } + for(short cycleText = 0; cycleText < textArray.size(); ++cycleText){ + if(textArray[cycleText].slotUsed == false){ + textArray[cycleText].slotUsed = true; + textArray[cycleText].preText = preText; + //textArray[cycleText].variable = &variable; + //textArray[cycleText].postText = postText; + textArray[cycleText].x = x; + textArray[cycleText].y = y; + textArray[cycleText].width = width; + textArray[cycleText].textColor = textColor; + textArray[cycleText].fontSize = fontSize; + + if(alignment == "none") + textArray[cycleText].alignment = 0; + else + if(alignment == "left") + textArray[cycleText].alignment = 1; + else + if(alignment == "leftFullLine") + textArray[cycleText].alignment = 2; + else + if(alignment == "center") + textArray[cycleText].alignment = 3; + else + if(alignment == "centerFullLine") + textArray[cycleText].alignment = 4; + else + if(alignment == "right") + textArray[cycleText].alignment = 5; + else + if(alignment == "rightFullLine") + textArray[cycleText].alignment = 6; + + lastIndexAdded = cycleText; + break; + } + } + } + void class_text::show(float offsetX, float offsetY){ + for(short cycleText = 0; cycleText < textArray.size(); ++cycleText){ + std::ostringstream text; + text << textArray[cycleText].preText;// << *textArray[cycleText].variable << textArray[cycleText].postText; + if(textArray[cycleText].slotUsed == true){ + drawglyphs( + text.str(), + textArray[cycleText].fontSize, + textArray[cycleText].x+int(offsetX), + textArray[cycleText].y+int(offsetY), + textArray[cycleText].width, + textArray[cycleText].alignment, + textArray[cycleText].textColor.red, + textArray[cycleText].textColor.green, + textArray[cycleText].textColor.blue, + textArray[cycleText].textColor.alpha); + } + } + } + void class_text::edit(int textNumber, std::string text){ + textArray[textNumber].preText = text; + } + void class_text::reset(){ + while(textArray.size()){ + textArray.pop_back(); + } + } +}; +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |