| 1 |
#include "stdafx.h" |
| 2 |
#include "CCursor.h" |
| 3 |
#include "CSkinPlugin.h" |
| 4 |
#include "CSkinSelectMode.h" |
| 5 |
#include "CConfigMode.h" |
| 6 |
|
| 7 |
// 内部定数 |
| 8 |
const int INTERFACE_SOUND_VOLUME = -1500; // 操作音量 |
| 9 |
|
| 10 |
// 内部グローバル |
| 11 |
CObject g_ArrowObject; // 矢印オブジェクト |
| 12 |
CObject g_LinkObject; // 矢印オブジェクト |
| 13 |
CObject g_SegmentObject; // セグメントオブジェクト |
| 14 |
CObject g_CompassObject[2]; // コンパスオブジェクト |
| 15 |
CObject g_WindDirObject; // 風方向オブジェクト |
| 16 |
CSkinPlugin *g_Skin = NULL; // カレントスキン |
| 17 |
|
| 18 |
/* |
| 19 |
* コンストラクタ |
| 20 |
*/ |
| 21 |
CSkinPlugin::CSkinPlugin( |
| 22 |
char *id // ID |
| 23 |
): |
| 24 |
CPlugin(id) // 基本クラス |
| 25 |
{ |
| 26 |
m_NormalCursorData.m_Cursor2DAnimFrame = NULL; |
| 27 |
m_InterfaceData.m_hFont = NULL; |
| 28 |
int i; |
| 29 |
for(i = 0; i<4; i++) m_ResizeCursorData[i].m_Cursor2DAnimFrame = NULL; |
| 30 |
} |
| 31 |
|
| 32 |
/* |
| 33 |
* デストラクタ |
| 34 |
*/ |
| 35 |
CSkinPlugin::~CSkinPlugin(){ |
| 36 |
DELETE_A(m_NormalCursorData.m_Cursor2DAnimFrame); |
| 37 |
int i; |
| 38 |
for(i = 0; i<4; i++) DELETE_A(m_ResizeCursorData[i].m_Cursor2DAnimFrame); |
| 39 |
DeleteObject(m_InterfaceData.m_hFont); |
| 40 |
} |
| 41 |
|
| 42 |
/* |
| 43 |
* 読込 |
| 44 |
*/ |
| 45 |
bool CSkinPlugin::Load(){ |
| 46 |
char *str = m_Script, *eee; |
| 47 |
int i; |
| 48 |
if(!ChDir()) return false; |
| 49 |
if(m_State==3) goto LOADED; |
| 50 |
if(!m_Script) return false; |
| 51 |
try{ |
| 52 |
if(!(str = m_NormalCursorData.Read(eee = str, "NormalCursor"))) throw CSynErr(eee); |
| 53 |
for(i = 0; i<4; i++) if(!(str = m_ResizeCursorData[i].Read( |
| 54 |
eee = str, FlashIn("ResizeCursor%d", i+1)))) throw CSynErr(eee); |
| 55 |
|
| 56 |
if(!(str = BeginBlock(eee = str, "Interface"))) throw CSynErr(eee); |
| 57 |
if(!(str = AsgnString(eee = str, "TexFileName", |
| 58 |
&m_InterfaceData.m_TexFileName))) throw CSynErr(eee); |
| 59 |
if(!(str = AsgnString(eee = str, "FontName", |
| 60 |
&m_InterfaceData.m_FontName))) throw CSynErr(eee); |
| 61 |
if(!(str = AsgnColor(eee = str, "TitleBarFontColor", |
| 62 |
&m_InterfaceData.m_TitleBarFontColor))) throw CSynErr(eee); |
| 63 |
if(!(str = AsgnColor(eee = str, "ButtonFontColor", |
| 64 |
&m_InterfaceData.m_ButtonFontColor))) throw CSynErr(eee); |
| 65 |
if(!(str = AsgnColor(eee = str, "StaticFontColor", |
| 66 |
&m_InterfaceData.m_StaticFontColor))) throw CSynErr(eee); |
| 67 |
if(!(str = AsgnColor(eee = str, "FocusFrameColor", |
| 68 |
&m_InterfaceData.m_FocusFrameColor))) throw CSynErr(eee); |
| 69 |
if(!(str = EndBlock(eee = str))) throw CSynErr(eee, ERR_ENDBLOCK); |
| 70 |
|
| 71 |
if(!(str = BeginBlock(eee = str, "Background"))) throw CSynErr(eee); |
| 72 |
bool wptmp; |
| 73 |
if(!(str = AsgnYesNo(eee = str, "UseWallpaper", &wptmp))) throw CSynErr(eee); |
| 74 |
if(wptmp){ |
| 75 |
if(!(str = AsgnString(eee = str, "TexFileName", |
| 76 |
&m_BackgroundData.m_TexFileName))) throw CSynErr(eee); |
| 77 |
m_BackgroundData.m_BackgroundColor = 0; |
| 78 |
if(!(str = AsgnInteger(eee = str, "ImageSize", |
| 79 |
m_BackgroundData.m_ImageSize, 2, false))) throw CSynErr(eee); |
| 80 |
}else{ |
| 81 |
if(!(str = AsgnColor(eee = str, "BackgroundColor", |
| 82 |
&m_BackgroundData.m_BackgroundColor))) throw CSynErr(eee); |
| 83 |
m_BackgroundData.m_ImageSize[0] = 0; |
| 84 |
m_BackgroundData.m_ImageSize[1] = 0; |
| 85 |
} |
| 86 |
if(!(str = EndBlock(eee = str))) throw CSynErr(eee, ERR_ENDBLOCK); |
| 87 |
|
| 88 |
if(!(str = BeginBlock(eee = str, "Frame"))) throw CSynErr(eee); |
| 89 |
if(!(str = AsgnString(eee = str, "FrameTexFileName", |
| 90 |
&m_FrameData.m_FrameTexFileName))) throw CSynErr(eee); |
| 91 |
if(!(str = AsgnString(eee = str, "IconTexFileName", |
| 92 |
m_FrameData.m_IconTexFileName, MODE_NUM, false))) throw CSynErr(eee); |
| 93 |
if(!(str = AsgnColor(eee = str, "LabelFontColor", |
| 94 |
&m_FrameData.m_LabelFontColor))) throw CSynErr(eee); |
| 95 |
if(!(str = AsgnColor(eee = str, "InfoFontColor", |
| 96 |
&m_FrameData.m_InfoFontColor))) throw CSynErr(eee); |
| 97 |
if(!(str = AsgnColor(eee = str, "FloatFontColor", |
| 98 |
&m_FrameData.m_FloatFontColor))) throw CSynErr(eee); |
| 99 |
if(!(str = EndBlock(eee = str))) throw CSynErr(eee, ERR_ENDBLOCK); |
| 100 |
|
| 101 |
if(!(str = BeginBlock(eee = str, "EditCtrl"))) throw CSynErr(eee); |
| 102 |
if(!(str = AsgnColor(eee = str, "DefaultFontColor", |
| 103 |
&m_EditCtrlData.m_DefaultFontColor))) throw CSynErr(eee); |
| 104 |
if(!(str = AsgnColor(eee = str, "EditBaseColor", |
| 105 |
m_EditCtrlData.m_EditBaseColor, 4, true))) throw CSynErr(eee); |
| 106 |
if(!(str = AsgnColor(eee = str, "EditFontColor", |
| 107 |
&m_EditCtrlData.m_EditFontColor))) throw CSynErr(eee); |
| 108 |
if(!(str = AsgnColor(eee = str, "ConvertFontColor", |
| 109 |
&m_EditCtrlData.m_ConvertFontColor))) throw CSynErr(eee); |
| 110 |
if(!(str = AsgnColor(eee = str, "ConvertClauseColor", |
| 111 |
m_EditCtrlData.m_ConvertClauseColor, 2, false))) throw CSynErr(eee); |
| 112 |
if(!(str = AsgnColor(eee = str, "SelectedBaseColor", |
| 113 |
m_EditCtrlData.m_SelectedBaseColor, 4, true))) throw CSynErr(eee); |
| 114 |
if(!(str = EndBlock(eee = str))) throw CSynErr(eee, ERR_ENDBLOCK); |
| 115 |
|
| 116 |
if(!(str = BeginBlock(eee = str, "ListView"))) throw CSynErr(eee); |
| 117 |
if(!(str = AsgnColor(eee = str, "DefaultBaseColorOdd", |
| 118 |
m_ListViewData.m_DefaultBaseColorOdd, 4, true))) throw CSynErr(eee); |
| 119 |
if(!(str = AsgnColor(eee = str, "DefaultBaseColorEven", |
| 120 |
m_ListViewData.m_DefaultBaseColorEven, 4, true))) throw CSynErr(eee); |
| 121 |
if(!(str = AsgnColor(eee = str, "DefaultFontColor", |
| 122 |
&m_ListViewData.m_DefaultFontColor))) throw CSynErr(eee); |
| 123 |
if(!(str = AsgnColor(eee = str, "SelectedBaseColor", |
| 124 |
m_ListViewData.m_SelectedBaseColor, 4, true))) throw CSynErr(eee); |
| 125 |
if(!(str = AsgnColor(eee = str, "SelectedFontColor", |
| 126 |
&m_ListViewData.m_SelectedFontColor))) throw CSynErr(eee); |
| 127 |
if(!(str = AsgnColor(eee = str, "FocusFrameColor", |
| 128 |
&m_ListViewData.m_FocusFrameColor))) throw CSynErr(eee); |
| 129 |
if(!(str = EndBlock(eee = str))) throw CSynErr(eee, ERR_ENDBLOCK); |
| 130 |
|
| 131 |
if(!(str = BeginBlock(eee = str, "PluginTree"))) throw CSynErr(eee); |
| 132 |
if(!(str = AsgnColor(eee = str, "DefaultBaseColor", |
| 133 |
m_PluginTreeData.m_DefaultBaseColor, 4, true))) throw CSynErr(eee); |
| 134 |
if(!(str = AsgnColor(eee = str, "DefaultFontColor", |
| 135 |
&m_PluginTreeData.m_DefaultFontColor))) throw CSynErr(eee); |
| 136 |
if(!(str = AsgnColor(eee = str, "SelectedBaseColor", |
| 137 |
m_PluginTreeData.m_SelectedBaseColor, 4, true))) throw CSynErr(eee); |
| 138 |
if(!(str = AsgnColor(eee = str, "SelectedFontColor", |
| 139 |
&m_PluginTreeData.m_SelectedFontColor))) throw CSynErr(eee); |
| 140 |
if(!(str = AsgnColor(eee = str, "FocusFrameColor", |
| 141 |
&m_PluginTreeData.m_FocusFrameColor))) throw CSynErr(eee); |
| 142 |
if(!(str = EndBlock(eee = str))) throw CSynErr(eee, ERR_ENDBLOCK); |
| 143 |
|
| 144 |
if(!(str = BeginBlock(eee = str, "PopupMenu"))) throw CSynErr(eee); |
| 145 |
if(!(str = AsgnColor(eee = str, "DefaultFontColor", |
| 146 |
&m_PopupMenuData.m_DefaultFontColor))) throw CSynErr(eee); |
| 147 |
if(!(str = AsgnColor(eee = str, "DisabledFontColor", |
| 148 |
&m_PopupMenuData.m_DisabledFontColor))) throw CSynErr(eee); |
| 149 |
if(!(str = AsgnColor(eee = str, "DisabledShadowColor", |
| 150 |
&m_PopupMenuData.m_DisabledShadowColor))) throw CSynErr(eee); |
| 151 |
if(!(str = AsgnColor(eee = str, "SelectedBaseColor", |
| 152 |
m_PopupMenuData.m_SelectedBaseColor, 4, true))) throw CSynErr(eee); |
| 153 |
if(!(str = AsgnColor(eee = str, "SelectedFontColor", |
| 154 |
&m_PopupMenuData.m_SelectedFontColor))) throw CSynErr(eee); |
| 155 |
if(!(str = EndBlock(eee = str))) throw CSynErr(eee, ERR_ENDBLOCK); |
| 156 |
|
| 157 |
if(!(str = BeginBlock(eee = str, "Model"))) throw CSynErr(eee); |
| 158 |
if(!(str = AsgnString(eee = str, "ArrowModelFileName", |
| 159 |
&m_ModelData.m_ArrowModelFileName))) throw CSynErr(eee); |
| 160 |
if(!(str = AsgnFloat(eee = str, "ArrowModelScale", |
| 161 |
&m_ModelData.m_ArrowModelScale))) throw CSynErr(eee); |
| 162 |
if(!(str = AsgnString(eee = str, "LinkModelFileName", |
| 163 |
&m_ModelData.m_LinkModelFileName))) throw CSynErr(eee); |
| 164 |
if(!(str = AsgnFloat(eee = str, "LinkModelScale", |
| 165 |
&m_ModelData.m_LinkModelScale))) throw CSynErr(eee); |
| 166 |
if(!(str = AsgnString(eee = str, "SegmentModelFileName", |
| 167 |
&m_ModelData.m_SegmentModelFileName))) throw CSynErr(eee); |
| 168 |
if(!(str = AsgnFloat(eee = str, "SegmentModelScale", |
| 169 |
&m_ModelData.m_SegmentModelScale))) throw CSynErr(eee); |
| 170 |
if(!(str = AsgnString(eee = str, "CompassModelFileName", |
| 171 |
m_ModelData.m_CompassModelFileName, 2, false))) throw CSynErr(eee); |
| 172 |
if(!(str = AsgnFloat(eee = str, "CompassModelScale", |
| 173 |
m_ModelData.m_CompassModelScale, 2, false))) throw CSynErr(eee); |
| 174 |
if(!(str = AsgnString(eee = str, "WindDirModelFileName", |
| 175 |
&m_ModelData.m_WindDirModelFileName))) throw CSynErr(eee); |
| 176 |
if(!(str = AsgnFloat(eee = str, "WindDirModelScale", |
| 177 |
&m_ModelData.m_WindDirModelScale))) throw CSynErr(eee); |
| 178 |
if(!(str = EndBlock(eee = str))) throw CSynErr(eee, ERR_ENDBLOCK); |
| 179 |
|
| 180 |
if(!(str = BeginBlock(eee = str, "Sound"))) throw CSynErr(eee); |
| 181 |
if(!(str = AsgnString(eee = str, "MouseDownWaveFileName", |
| 182 |
&m_SoundData.m_MouseDownWaveFileName))) throw CSynErr(eee); |
| 183 |
if(!(str = AsgnString(eee = str, "MouseUpWaveFileName", |
| 184 |
&m_SoundData.m_MouseUpWaveFileName))) throw CSynErr(eee); |
| 185 |
if(!(str = AsgnString(eee = str, "ErrorWaveFileName", |
| 186 |
&m_SoundData.m_ErrorWaveFileName))) throw CSynErr(eee); |
| 187 |
if(!(str = AsgnString(eee = str, "ScreenShotWaveFileName", |
| 188 |
&m_SoundData.m_ScreenShotWaveFileName))) throw CSynErr(eee); |
| 189 |
if(!(str = AsgnString(eee = str, "VideoStartWaveFileName", |
| 190 |
&m_SoundData.m_VideoStartWaveFileName))) throw CSynErr(eee); |
| 191 |
if(!(str = AsgnString(eee = str, "VideoStopWaveFileName", |
| 192 |
&m_SoundData.m_VideoStopWaveFileName))) throw CSynErr(eee); |
| 193 |
if(!(str = EndBlock(eee = str))) throw CSynErr(eee, ERR_ENDBLOCK); |
| 194 |
|
| 195 |
if(*(eee = str)) throw CSynErr(eee); |
| 196 |
} |
| 197 |
catch(CSynErr err){ |
| 198 |
HandleError(&err); |
| 199 |
return false; |
| 200 |
} |
| 201 |
LOADED: |
| 202 |
m_InterfaceData.m_hFont = CreateFont(FONT_HEIGHT, 0, 0, 0, |
| 203 |
FW_REGULAR, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET, |
| 204 |
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, |
| 205 |
VARIABLE_PITCH|FF_MODERN, m_InterfaceData.m_FontName.c_str()); |
| 206 |
m_InterfaceTexture = g_TexList.Get(FALSE, m_InterfaceData.m_TexFileName.c_str(), 0, 1); |
| 207 |
m_FrameTexture = g_TexList.Get(FALSE, m_FrameData.m_FrameTexFileName.c_str(), 0, 1); |
| 208 |
for(i = 0; i<MODE_NUM; i++) m_IconTexture[i] = |
| 209 |
g_TexList.Get(FALSE, m_FrameData.m_IconTexFileName[i].c_str(), 0, 1); |
| 210 |
m_NormalCursorData.LoadData(); |
| 211 |
for(i = 0; i<4; i++) m_ResizeCursorData[i].LoadData(); |
| 212 |
if(*m_BackgroundData.m_ImageSize) m_WallpaperTexture = |
| 213 |
g_TexList.Get(FALSE, m_BackgroundData.m_TexFileName.c_str(), 0, 1); |
| 214 |
m_ArrowMesh = g_MeshList.Get(FALSE, m_ModelData.m_ArrowModelFileName.c_str()); |
| 215 |
ChDir(); |
| 216 |
m_LinkMesh = g_MeshList.Get(FALSE, m_ModelData.m_LinkModelFileName.c_str()); |
| 217 |
ChDir(); |
| 218 |
m_SegmentMesh = g_MeshList.Get(FALSE, m_ModelData.m_SegmentModelFileName.c_str()); |
| 219 |
ChDir(); |
| 220 |
for(i = 0; i<2; i++){ |
| 221 |
m_CompassMesh[i] = g_MeshList.Get( |
| 222 |
FALSE, m_ModelData.m_CompassModelFileName[i].c_str()); |
| 223 |
ChDir(); |
| 224 |
} |
| 225 |
m_WindDirMesh = g_MeshList.Get(FALSE, m_ModelData.m_WindDirModelFileName.c_str()); |
| 226 |
ChDir(); |
| 227 |
m_MouseDown.Load((char *)m_SoundData.m_MouseDownWaveFileName.c_str(), 4, false); |
| 228 |
m_MouseUp.Load((char *)m_SoundData.m_MouseUpWaveFileName.c_str(), 2, false); |
| 229 |
m_Error.Load((char *)m_SoundData.m_ErrorWaveFileName.c_str(), 1, false); |
| 230 |
m_ScreenShot.Load((char *)m_SoundData.m_ScreenShotWaveFileName.c_str(), 2, false); |
| 231 |
m_VideoStart.Load((char *)m_SoundData.m_VideoStartWaveFileName.c_str(), 1, false); |
| 232 |
m_VideoStop.Load((char *)m_SoundData.m_VideoStopWaveFileName.c_str(), 1, false); |
| 233 |
DELETE_A(m_Buffer); |
| 234 |
return true; |
| 235 |
} |
| 236 |
|
| 237 |
/* |
| 238 |
* プレビュー設定 |
| 239 |
*/ |
| 240 |
void CSkinPlugin::SetPreview(){ |
| 241 |
ms_PreviewState = true; |
| 242 |
if(g_Skin!=this){ |
| 243 |
g_Skin = this; |
| 244 |
g_StrTex->SetFont(m_InterfaceData.m_hFont); |
| 245 |
g_ArrowObject.SetMesh(m_ArrowMesh, V3ZERO, m_ModelData.m_ArrowModelScale); |
| 246 |
g_LinkObject.SetMesh(m_LinkMesh, V3ZERO, m_ModelData.m_LinkModelScale); |
| 247 |
g_SegmentObject.SetMesh(m_SegmentMesh, V3ZERO, m_ModelData.m_SegmentModelScale); |
| 248 |
int i; |
| 249 |
for(i = 0; i<2; i++) g_CompassObject[i].SetMesh( |
| 250 |
m_CompassMesh[i], V3ZERO, m_ModelData.m_CompassModelScale[i]); |
| 251 |
g_WindDirObject.SetMesh(m_WindDirMesh, V3ZERO, m_ModelData.m_WindDirModelScale); |
| 252 |
} |
| 253 |
if(!g_SkinSelectMode) return; |
| 254 |
string desc = g_Skin->GetBasicInfo(); |
| 255 |
desc += "\n"+g_Skin->GetDescription(); |
| 256 |
g_SkinSelectMode->SetProperty((char *)desc.c_str()); |
| 257 |
} |
| 258 |
|
| 259 |
/* |
| 260 |
* マウス PUSH 音 |
| 261 |
*/ |
| 262 |
void CSkinPlugin::MouseDown(){ |
| 263 |
if(g_ConfigMode->GetInterfaceSound()) m_MouseDown.Add(V3ZERO, INTERFACE_SOUND_VOLUME); |
| 264 |
} |
| 265 |
|
| 266 |
/* |
| 267 |
* マウス PULL 音 |
| 268 |
*/ |
| 269 |
void CSkinPlugin::MouseUp(){ |
| 270 |
if(g_ConfigMode->GetInterfaceSound()) m_MouseUp.Add(V3ZERO, INTERFACE_SOUND_VOLUME); |
| 271 |
} |
| 272 |
|
| 273 |
/* |
| 274 |
* エラー音 |
| 275 |
*/ |
| 276 |
void CSkinPlugin::Error(){ |
| 277 |
if(g_ConfigMode->GetInterfaceSound()) m_Error.Add(V3ZERO, INTERFACE_SOUND_VOLUME); |
| 278 |
} |
| 279 |
|
| 280 |
/* |
| 281 |
* スクリーンショット撮影音 |
| 282 |
*/ |
| 283 |
void CSkinPlugin::ScreenShot(){ |
| 284 |
if(g_ConfigMode->GetInterfaceSound()) m_ScreenShot.Add(V3ZERO, INTERFACE_SOUND_VOLUME); |
| 285 |
} |
| 286 |
|
| 287 |
/* |
| 288 |
* ビデオ撮影開始音 |
| 289 |
*/ |
| 290 |
void CSkinPlugin::VideoStart(){ |
| 291 |
if(g_ConfigMode->GetInterfaceSound()) m_VideoStart.Add(V3ZERO, INTERFACE_SOUND_VOLUME); |
| 292 |
} |
| 293 |
|
| 294 |
/* |
| 295 |
* ビデオ撮影停止音 |
| 296 |
*/ |
| 297 |
void CSkinPlugin::VideoStop(){ |
| 298 |
if(g_ConfigMode->GetInterfaceSound()) m_VideoStop.Add(V3ZERO, INTERFACE_SOUND_VOLUME); |
| 299 |
} |
| 300 |
|
| 301 |
/* |
| 302 |
* 背景描画 |
| 303 |
*/ |
| 304 |
void CSkinPlugin::DrawBackground( |
| 305 |
bool light // 背景ライト |
| 306 |
){ |
| 307 |
D3DCOLOR lc = light ? 0xffffffff : 0xff202020; |
| 308 |
D3DCOLOR bg = MultiplyColor(m_BackgroundData.m_BackgroundColor, lc); |
| 309 |
BeginScene(bg); |
| 310 |
if(*m_BackgroundData.m_ImageSize){ |
| 311 |
devSetTexture(0, m_WallpaperTexture); |
| 312 |
if(m_BackgroundData.m_ImageSize[0]<0) SetUVMap(0.0f, 0.0f, 1.0f, 1.0f); |
| 313 |
else SetUVMap(0.0f, 0.0f, |
| 314 |
(float)g_DispWidth/m_BackgroundData.m_ImageSize[0], |
| 315 |
(float)g_DispHeight/m_BackgroundData.m_ImageSize[1]); |
| 316 |
TexMap2DRect(0.0f, 0.0f, g_DispWidth, g_DispHeight, lc); |
| 317 |
} |
| 318 |
} |
| 319 |
|
| 320 |
/* |
| 321 |
* コンパススケール設定 |
| 322 |
*/ |
| 323 |
void CSkinPlugin::ScaleCompass( |
| 324 |
float scale // スケール |
| 325 |
){ |
| 326 |
int i; |
| 327 |
for(i = 0; i<2; i++) g_CompassObject[i].SetMesh( |
| 328 |
m_CompassMesh[i], V3ZERO, scale*m_ModelData.m_CompassModelScale[i]); |
| 329 |
g_WindDirObject.SetMesh(m_WindDirMesh, V3ZERO, scale*m_ModelData.m_WindDirModelScale); |
| 330 |
} |