00001
00010 #ifndef __PS2_ICON_SYS_HPP_INCLUDE_GUARD__
00011 #define __PS2_ICON_SYS_HPP_INCLUDE_GUARD__
00012
00013 #include <fstream>
00014 #include "../gbLib/include/gbException.hpp"
00015
00018 class IconSys {
00019 public:
00024 class IconSys_Color {
00025 private:
00026 int R;
00027 int G;
00028 int B;
00029 int X;
00030 public:
00031 IconSys_Color(int const *);
00032 IconSys_Color(unsigned int const *);
00033 IconSys_Color(int r, int g, int b, int x);
00034 IconSys_Color(IconSys_Color const&);
00035 ~IconSys_Color();
00036 IconSys_Color& operator =(IconSys_Color const&);
00037 int GetR() const;
00038 int GetG() const;
00039 int GetB() const;
00040 int GetX() const;
00041 int GetR8() const;
00042 int GetG8() const;
00043 int GetB8() const;
00044 int GetX8() const;
00045 bool SetR(int r);
00046 bool SetG(int g);
00047 bool SetB(int b);
00048 bool SetX(int x);
00049 void Get(unsigned int* p) const;
00050 private:
00051 void CheckRanges();
00052 };
00057 class IconSys_LightColor {
00058 private:
00059 float R;
00060 float G;
00061 float B;
00062 float X;
00063 public:
00064 IconSys_LightColor(float const*);
00065 IconSys_LightColor(float r, float g, float b, float x);
00066 IconSys_LightColor(IconSys_LightColor const& rhs);
00067 ~IconSys_LightColor();
00068 IconSys_LightColor& operator=(IconSys_LightColor const& rhs);
00069 float GetR() const;
00070 float GetG() const;
00071 float GetB() const;
00072 float GetX() const;
00073 int GetR8() const;
00074 int GetG8() const;
00075 int GetB8() const;
00076 int GetX8() const;
00077 bool SetR(float r);
00078 bool SetG(float g);
00079 bool SetB(float b);
00080 bool SetX(float x);
00081 void Get(float* p) const;
00082 private:
00083 void CheckRanges();
00084 };
00087 class IconSys_LightVec {
00088 private:
00089 float X;
00090 float Y;
00091 float Z;
00092 float W;
00093 public:
00094 IconSys_LightVec(float const*);
00095 IconSys_LightVec(float fx, float fy, float fz, float fw);
00096 IconSys_LightVec(IconSys_LightVec const &);
00097 ~IconSys_LightVec();
00098 IconSys_LightVec& operator=(IconSys_LightVec const&);
00099 float GetX() const;
00100 float GetY() const;
00101 float GetZ() const;
00102 float GetW() const;
00103 bool SetX(float x);
00104 bool SetY(float y);
00105 bool SetZ(float z);
00106 bool SetW(float w);
00107 void Get(float* p) const;
00108 };
00109 private:
00115 struct File_t {
00116
00117
00118
00119
00120
00121
00122
00123 char ps2d_string[4];
00124 unsigned short reserve1;
00125 unsigned short offset_2nd_line;
00126 unsigned int reserve2;
00127 unsigned int bg_opacity;
00128 unsigned int bg_color_upperleft[4];
00129 unsigned int bg_color_upperright[4];
00130 unsigned int bg_color_lowerleft[4];
00131 unsigned int bg_color_lowerright[4];
00132 float light1_direction[4];
00133 float light2_direction[4];
00134 float light3_direction[4];
00135 float light1_color[4];
00136 float light2_color[4];
00137 float light3_color[4];
00138 float light_ambient_color[4];
00139 unsigned char title[68];
00140 unsigned char icon_file[64];
00141 unsigned char icon_copy_file[64];
00142 unsigned char icon_delete_file[64];
00143 unsigned char reserve3[512];
00144 } File;
00145 char decoded_title[34];
00146 char title_str[35];
00147 char title_str_single_line[35];
00148 public:
00151 IconSys();
00156 IconSys(const char* fname);
00159 ~IconSys();
00162 void SetToDefault();
00166 char const * GetTitle() const;
00171 void SetTitle(char const* str);
00176 void SetLinebreak(int lb);
00180 char const * GetTitleSingleLine() const;
00184 char const * GetIconFilename() const;
00189 void SetIconFilename(char const* fname);
00193 char const * GetIconCopyFilename() const;
00198 void SetIconCopyFilename(char const* fname);
00202 char const * GetIconDeleteFilename() const;
00207 void SetIconDeleteFilename(char const* fname);
00212 int GetBackgroundOpacity() const;
00217 void SetBackgroundOpacity(int i);
00221 IconSys_Color GetBackgroundColor_UL() const;
00224 void SetBackgroundColor_UL(IconSys_Color const& c);
00228 IconSys_Color GetBackgroundColor_UR() const;
00231 void SetBackgroundColor_UR(IconSys_Color const& c);
00235 IconSys_Color GetBackgroundColor_LL() const;
00238 void SetBackgroundColor_LL(IconSys_Color const& c);
00242 IconSys_Color GetBackgroundColor_LR() const;
00245 void SetBackgroundColor_LR(IconSys_Color const& c);
00249 IconSys_LightColor GetLight1Color() const;
00252 void SetLight1Color(IconSys_LightColor const& c);
00256 IconSys_LightColor GetLight2Color() const;
00259 void SetLight2Color(IconSys_LightColor const& c);
00263 IconSys_LightColor GetLight3Color() const;
00266 void SetLight3Color(IconSys_LightColor const& c);
00270 IconSys_LightColor GetLightAmbientColor() const;
00273 void SetLightAmbientColor(IconSys_LightColor const& c);
00277 IconSys_LightVec GetLight1Dir() const;
00280 void SetLight1Dir(IconSys_LightVec const& v);
00284 IconSys_LightVec GetLight2Dir() const;
00287 void SetLight2Dir(IconSys_LightVec const& v);
00291 IconSys_LightVec GetLight3Dir() const;
00294 void SetLight3Dir(IconSys_LightVec const& v);
00299 void WriteFile(char const * fname);
00300 private:
00304 static bool CheckValidity(File_t const&);
00308 static void DecodeTitle(unsigned char const * str_in, char* str_out);
00312 static void EncodeTitle(char const* str_in, unsigned char* str_out);
00315 static void GetTitleString(char const * str_in, unsigned int pos_linebreak, char * str_out);
00316 IconSys(IconSys const&);
00317 IconSys& operator=(IconSys const&);
00318 };
00319 typedef IconSys *LPICONSYS;
00320
00321
00336 #endif