📄 charcontrol.h
字号:
#ifndef CHARCONTROL_H
#define CHARCONTROL_H
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
// wx
#include "wx/spinbutt.h"
#include "wx/choicdlg.h"
#include "wx/window.h"#include "wx/dialog.h"#include "wx/checklst.h"
// stl
#include <string>
#include <vector>
// our headers
#include "chardb.h"
#include "itemdb.h"
#include "creaturedb.h"
#include "model.h"
#include "modelcanvas.h"
// forward class declarations
class ChoiceDialog;
class ModelViewer;
bool slotHasModel(int i);
bool correctType(int type, int slot);
enum {
ID_CHARCONTROLFRAME = 3400,
ID_SKIN_COLOR,
ID_FACE_TYPE,
ID_HAIR_COLOR,
ID_HAIR_STYLE,
ID_FACIAL_HAIR,
ID_FACIAL_COLOR,
ID_TABARD_ICON,
ID_TABARD_ICONCOLOR,
ID_TABARD_BORDER,
ID_TABARD_BORDERCOLOR,
ID_TABARD_BACKGROUND,
ID_SHOW_UNDERWEAR,
ID_SHOW_EARS,
ID_SHOW_HAIR,
ID_SHOW_FACIALHAIR,
ID_SHEATHE,
ID_SAVE_EQUIPMENT,
ID_LOAD_EQUIPMENT,
ID_CLEAR_EQUIPMENT,
ID_SAVE_CHAR,
ID_LOAD_CHAR,
ID_LOAD_SET,
ID_LOAD_START,
ID_MOUNT,
ID_EQUIPMENT = 5000
};
enum CharRegions {
CR_BASE = 0,
CR_ARM_UPPER,
CR_ARM_LOWER,
CR_HAND,
CR_FACE_UPPER,
CR_FACE_LOWER,
CR_TORSO_UPPER,
CR_TORSO_LOWER,
CR_PELVIS_UPPER,
CR_PELVIS_LOWER,
CR_FOOT,
NUM_REGIONS,
CR_LEG_UPPER = CR_PELVIS_UPPER,
CR_LEG_LOWER = CR_PELVIS_LOWER
};
enum {
UPDATE_ITEM,
UPDATE_SET,
UPDATE_START,
UPDATE_MOUNT,
UPDATE_CREATURE_ITEM
};
struct CharRegionCoords {
int xpos, ypos, xsize, ysize;
};
const CharRegionCoords regions[NUM_REGIONS] =
{
{0, 0, 256, 256}, // base
{0, 0, 128, 64}, // arm upper
{0, 64, 128, 64}, // arm lower
{0, 128, 128, 32}, // hand
{0, 160, 128, 32}, // face upper
{0, 192, 128, 64}, // face lower
{128, 0, 128, 64}, // torso upper
{128, 64, 128, 32}, // torso lower
{128, 96, 128, 64}, // pelvis upper
{128, 160, 128, 64},// pelvis lower
{128, 224, 128, 32} // foot
};
struct CharTextureComponent
{
string name;
int region;
int layer;
const bool operator<(const CharTextureComponent& c) const
{
return layer < c.layer;
}
};
struct CharTexture
{
std::vector<CharTextureComponent> components;
void addLayer(const char* fn, int region, int layer)
{
if (fn==0 || strlen(fn)==0) return;
CharTextureComponent ct;
ct.name = fn;
ct.region = region;
ct.layer = layer;
components.push_back(ct);
}
void compose(TextureID tex);
};
enum CharSlots {
CS_HEAD,
CS_NECK,
CS_SHOULDER,
CS_BOOTS,
CS_BELT,
CS_SHIRT,
CS_PANTS,
CS_CHEST,
CS_BRACERS,
CS_GLOVES,
CS_HAND_RIGHT,
CS_HAND_LEFT,
CS_CAPE,
CS_TABARD,
NUM_CHAR_SLOTS
};
struct TabardDetails
{
int Icon;
int IconColor;
int Border;
int BorderColor;
int Background;
int maxIcon;
int maxIconColor;
int maxBorder;
int maxBorderColor;
int maxBackground;
bool showCustom;
std::string GetIconTex(int slot);
std::string GetBorderTex(int slot);
std::string GetBackgroundTex(int slot);
};
struct CharDetails
{
int skinColor;
int faceType;
int hairColor;
int hairStyle;
int facialHair;
int facialColor;
int maxFacialColor;
int maxHairStyle, maxHairColor, maxSkinColor, maxFaceType, maxFacialHair;
int race, gender;
unsigned int useNPC;
bool showUnderwear, showEars, showHair, showFacialHair;
int equipment[NUM_CHAR_SLOTS];
int geosets[16];
// save + load equipment
void save(wxString fn, TabardDetails *td);
bool load(wxString fn, TabardDetails *td);
void loadSet(ItemSetDB &sets, ItemDatabase &items, int setid);
void loadStart(StartOutfitDB &start, ItemDatabase &items, int cls);
void reset();
};
class CharControl: public wxWindow
{
DECLARE_CLASS(CharControl)
DECLARE_EVENT_TABLE()
CharHairGeosetsDB hairdb;
CharSectionsDB chardb;
CharClassesDB classdb;
CharFacialHairDB facialhairdb;
wxSpinButton *spins[6];
wxSpinButton *tabardSpins[5];
//wxCheckBox *checkUnderwear, *checkHair, *checkEars;
wxButton *buttons[NUM_CHAR_SLOTS];
wxStaticText *labels[NUM_CHAR_SLOTS];
void AddEquipment(int slot, int itemnum, int layer, CharTexture &tex);
public:
// Item selection stuff
ChoiceDialog *itemDialog;
int choosingSlot;
std::vector<int> numbers, cats;
wxArrayString choices, catnames;
// dbs
ItemDatabase items;
ItemDisplayDB itemdb;
ItemVisualDB visualdb;
ItemVisualEffectDB effectdb;
ItemSubClassDB subclassdb;
ItemSetDB sets;
StartOutfitDB start;
HelmGeosetDB helmetdb;
ModelViewer *modelViewer;
CharControl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
~CharControl();
bool Init();
//void UpdateModel(Model *m);
void UpdateModel(Attachment *a);
void UpdateNPCModel(Attachment *a, unsigned int id);
void RefreshModel();
void RefreshNPCModel();
void RefreshItem(int slot);
void RefreshCreatureItem(int slot);
void RefreshEquipment();
TextureID chartex, hairtex, furtex, capetex, gobtex;
bool randomLooks;
bool bSheathe;
void OnSpin(wxSpinEvent &event);
void OnTabardSpin(wxSpinEvent &event);
void OnCheck(wxCommandEvent &event);
void OnButton(wxCommandEvent &event);
void OnSize(wxSizeEvent &event);
void OnUpdateItem(int type, int id);
CharDetails cd;
TabardDetails td;
Attachment *charAtt;
Model *model;
ModelCanvas *canvas;
CharRacesDB racedb;
NPCDB npcdb;
std::string makeItemTexture(int region, const char *name);
const char *customSkin;
void ClearItemDialog();
void selectItem(int type, int current, const wxChar *caption=_T("Item"));
void selectSet();
void selectStart();
void selectMount();
const std::string selectCharModel();
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -