first commit
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
#ifndef _CONTENT_H_
|
||||
#define _CONTENT_H_
|
||||
|
||||
#define CKG_CM_MAX_COLORS_PER_ITEM 4
|
||||
|
||||
/*!
|
||||
\brief Item types define where an item is worn.
|
||||
|
||||
Due to layering support, multiple items per position can be worn.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
// Lower 4 bits are sub locations (0 - 3)
|
||||
CKG_CM_SubItem_BASE = 0,
|
||||
CKG_CM_SubItem_MASK = 0xF,
|
||||
|
||||
CKG_CM_SubItem_Default = CKG_CM_SubItem_BASE,
|
||||
CKG_CM_SubItem_Upper = (1 << (CKG_CM_SubItem_BASE + 0)),
|
||||
CKG_CM_SubItem_Middle = (1 << (CKG_CM_SubItem_BASE + 1)),
|
||||
CKG_CM_SubItem_Lower = (1 << (CKG_CM_SubItem_BASE + 2)),
|
||||
CKG_CM_SubItem_Unused = (1 << (CKG_CM_SubItem_BASE + 3)),
|
||||
|
||||
// Next 8 bits are Patterns (4 - 15)
|
||||
CKG_CM_Pattern_BASE = 4,
|
||||
CKG_CM_Pattern_MASK = 0xFF0,
|
||||
|
||||
CKG_CM_Pattern_Solid = (1 << (CKG_CM_Pattern_BASE + 0)),
|
||||
CKG_CM_Pattern_Stripe_Vertical = (1 << (CKG_CM_Pattern_BASE + 1)),
|
||||
CKG_CM_Pattern_Stripe_Horizontal= (1 << (CKG_CM_Pattern_BASE + 2)),
|
||||
CKG_CM_Pattern_Stripe_Diagonal = (1 << (CKG_CM_Pattern_BASE + 3)),
|
||||
CKG_CM_Pattern_Plaid = (1 << (CKG_CM_Pattern_BASE + 4)),
|
||||
|
||||
// Upper bits are all primary items (16+)
|
||||
CKG_CM_Item_BASE = 16,
|
||||
CKG_CM_Item_MASK = ~(CKG_CM_SubItem_MASK | CKG_CM_Pattern_MASK),
|
||||
|
||||
CKG_CM_Item_Type_Head = (1 << (CKG_CM_Item_BASE + 0)), // Headware
|
||||
CKG_CM_Item_Type_Torso = (1 << (CKG_CM_Item_BASE + 1)), // Torsoware, shirts, bras, etc
|
||||
CKG_CM_Item_Type_Arm = (1 << (CKG_CM_Item_BASE + 2)), // Arm covers etc (goths)
|
||||
CKG_CM_Item_Type_Wrist = (1 << (CKG_CM_Item_BASE + 3)), // Watches, bracelets, etc
|
||||
CKG_CM_Item_Type_Finger = (1 << (CKG_CM_Item_BASE + 4)), // Rings and such
|
||||
CKG_CM_Item_Type_Pelvic = (1 << (CKG_CM_Item_BASE + 5)), // Underwear
|
||||
CKG_CM_Item_Type_Leg = (1 << (CKG_CM_Item_BASE + 6)), // Pants, skirts, etc
|
||||
CKG_CM_Item_Type_Foot = (1 << (CKG_CM_Item_BASE + 7)), // Footwear, etc
|
||||
} CKG_CM_ItemTypeInfo;
|
||||
|
||||
/*!
|
||||
\brief Color structure is used to define color
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned int r;
|
||||
unsigned int g;
|
||||
unsigned int b;
|
||||
} CKG_CM_Color;
|
||||
|
||||
/*!
|
||||
\brief Item itself holds the data for each given item
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
CKG_CM_Color color[CKG_CM_MAX_COLORS_PER_ITEM];
|
||||
CKG_CM_ItemTypeInfo itemTypeInfo;
|
||||
void *picture;
|
||||
char numColors;
|
||||
} CKG_CM_Item;
|
||||
|
||||
extern CKG_CM_Item *CKG_CM_InitItem(CKG_CM_Item *item);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef _CONTENT_MANAGEMENT_H_
|
||||
#define _CONTENT_MANAGEMENT_H_
|
||||
|
||||
#include "Content.h"
|
||||
|
||||
#define CKG_CM_CATEGORY_NAME_LEN 64
|
||||
|
||||
typedef struct CKG_CM_ItemList
|
||||
{
|
||||
struct CKG_CM_ItemList *prev;
|
||||
struct CKG_CM_ItemList *next;
|
||||
CKG_CM_Item item;
|
||||
} CKG_CM_ItemList;
|
||||
|
||||
typedef struct CKG_CM_ContentCategory
|
||||
{
|
||||
char categoryName[CKG_CM_CATEGORY_NAME_LEN];
|
||||
CKG_CM_ItemList *itemList;
|
||||
} CKG_CM_ContentCategory;
|
||||
|
||||
typedef struct CKG_CM_ContentCategoryList
|
||||
{
|
||||
struct CKG_CM_ContentCategoryList *prev;
|
||||
struct CKG_CM_ContentCategoryList *next;
|
||||
char categoryName[CKG_CM_CATEGORY_NAME_LEN];
|
||||
} CKG_CM_ContentCategoryList;
|
||||
|
||||
typedef struct CKG_CM_List
|
||||
{
|
||||
struct CKG_CM_List *prev;
|
||||
struct CKG_CM_List *next;
|
||||
} CKG_CM_List;
|
||||
|
||||
|
||||
extern int CKG_CM_AddItemToList(CKG_CM_List **list, CKG_CM_List *itemToAdd);
|
||||
extern int CKG_CM_RemoveItemFromList(CKG_CM_List **list, CKG_CM_List *itemToRemove);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef CKG_CM_ERROR_H_
|
||||
#define CKG_CM_ERROR_H_
|
||||
|
||||
/* Error List */
|
||||
#define CKG_CM_OK 0 // 0 or greater are sucessful
|
||||
#define CKG_CM_ERROR -1 // negative is failure
|
||||
#define CKG_CM_INVALIDARG -2 // Invalid arg as in NULL or the like
|
||||
|
||||
/* Macros for success/failure */
|
||||
#define CKG_CM_SUCCESS(x) (CKG_CM_OK <= (x))
|
||||
#define CKG_CM_FAILED(x) ((x) < CKG_CM_OK)
|
||||
|
||||
#endif
|
||||
16
closet/trunk/common/ContentManagement/source/Content.c
Normal file
16
closet/trunk/common/ContentManagement/source/Content.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "ContentManagement/Content.h"
|
||||
|
||||
|
||||
/*!
|
||||
\brief Initialize a Content item to defaults
|
||||
*/
|
||||
CKG_CM_Item *CKG_CM_InitItem(CKG_CM_Item *item)
|
||||
{
|
||||
if (item)
|
||||
{
|
||||
memset(item, 0x00, sizeof(*item));
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "ContentManagement/ContentManagement.h"
|
||||
#include "ContentManagement/Error.h"
|
||||
|
||||
int CKG_CM_AddItemToList(CKG_CM_List **list, CKG_CM_List *itemToAdd)
|
||||
{
|
||||
if (list && itemToAdd)
|
||||
{
|
||||
CKG_CM_List *oldHead;
|
||||
|
||||
oldHead = *list;
|
||||
*list = itemToAdd;
|
||||
itemToAdd->next = oldHead;
|
||||
|
||||
return CKG_CM_OK;
|
||||
}
|
||||
|
||||
return CKG_CM_INVALIDARG;
|
||||
}
|
||||
|
||||
int CKG_CM_RemoveItemFromList(CKG_CM_List **list, CKG_CM_List *itemToRemove)
|
||||
{
|
||||
if (list && itemToRemove)
|
||||
{
|
||||
CKG_CM_List *current = *list;
|
||||
|
||||
//whole (current)
|
||||
}
|
||||
|
||||
return CKG_CM_INVALIDARG;
|
||||
}
|
||||
|
||||
6
closet/trunk/common/ContentManagement/test/test.c
Normal file
6
closet/trunk/common/ContentManagement/test/test.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#include "../include/ContentManagement/ContentManagement.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user