| 1 |
#include "stdafx.h" |
| 2 |
#include "CScene.h" |
| 3 |
#include "CStructEditMode.h" |
| 4 |
|
| 5 |
// 外部定数 |
| 6 |
extern const int CSR_MOVE_TSD; |
| 7 |
|
| 8 |
/* |
| 9 |
* コンストラクタ |
| 10 |
*/ |
| 11 |
CStructEditMode::CStructEditMode(){ |
| 12 |
} |
| 13 |
|
| 14 |
/* |
| 15 |
* デストラクタ |
| 16 |
*/ |
| 17 |
CStructEditMode::~CStructEditMode(){ |
| 18 |
} |
| 19 |
|
| 20 |
/* |
| 21 |
* モードを有効化 |
| 22 |
*/ |
| 23 |
void CStructEditMode::EnterCursorScenery(){ |
| 24 |
ms_ModeLabel = lang(EditStruct); |
| 25 |
m_DragState = 0; |
| 26 |
EnterStructEdit(); |
| 27 |
} |
| 28 |
|
| 29 |
/* |
| 30 |
* 入力チェック |
| 31 |
*/ |
| 32 |
void CStructEditMode::ScanInputCursorScenery(){ |
| 33 |
if(m_Interface.ScanInput()) return; |
| 34 |
if(g_NetworkInitialized){ |
| 35 |
GetCamera()->ScanInput(1); |
| 36 |
return; |
| 37 |
} |
| 38 |
switch(GetCamera()->ScanInput(3)){ |
| 39 |
case 10: |
| 40 |
m_DragState = 1; |
| 41 |
m_DragBegin = g_Cursor.GetVEC3(); |
| 42 |
break; |
| 43 |
case 11: |
| 44 |
switch(m_DragState){ |
| 45 |
case 1: |
| 46 |
if(V3Len(&(g_Cursor.GetVEC3()-m_DragBegin))<CSR_MOVE_TSD) break; |
| 47 |
m_DragState = 2; |
| 48 |
case 2: |
| 49 |
m_DragEnd = g_Cursor.GetVEC3(); |
| 50 |
ScanInputStructEdit(2, m_DragBegin, m_DragEnd); |
| 51 |
break; |
| 52 |
} |
| 53 |
break; |
| 54 |
default: |
| 55 |
switch(m_DragState){ |
| 56 |
case 0: |
| 57 |
ScanInputStructEdit(4, g_Cursor.GetVEC3(), V3ZERO); |
| 58 |
if(CModelInst::IsDetected()) |
| 59 |
CModelInst::GetDetectInfo().GetModelInst()->AddSelectFlag(1); |
| 60 |
break; |
| 61 |
case 1: |
| 62 |
ScanInputStructEdit(4, m_DragBegin, V3ZERO); |
| 63 |
if(CModelInst::IsDetected()) |
| 64 |
CModelInst::GetDetectInfo().GetModelInst()->AddSelectFlag(1); |
| 65 |
case 2: |
| 66 |
ScanInputStructEdit(3, V3ZERO, V3ZERO); |
| 67 |
break; |
| 68 |
} |
| 69 |
m_DragState = 0; |
| 70 |
if(GetKey(DIK_DELETE)==S_PUSH){ |
| 71 |
void PushUndoStack(); |
| 72 |
PushUndoStack(); |
| 73 |
Delete(); |
| 74 |
} |
| 75 |
break; |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
/* |
| 80 |
* 入力チェック |
| 81 |
*/ |
| 82 |
void CStructEditMode::ScanInputStructEdit( |
| 83 |
int mode, // モード |
| 84 |
VEC3 rect1, // 領域始点 |
| 85 |
VEC3 rect2 // 領域終点 |
| 86 |
){ |
| 87 |
g_Scene->ScanInputStruct(mode, rect1, rect2, true); |
| 88 |
} |
| 89 |
|
| 90 |
/* |
| 91 |
* 撤去 |
| 92 |
*/ |
| 93 |
void CStructEditMode::Delete(){ |
| 94 |
g_Scene->DeleteStruct(NULL); |
| 95 |
} |
| 96 |
|
| 97 |
/* |
| 98 |
* レンダリング |
| 99 |
*/ |
| 100 |
void CStructEditMode::RenderCursorScenery(){ |
| 101 |
if(ms_PhotoMode) return; |
| 102 |
if(g_NetworkInitialized){ |
| 103 |
devResetMatrix(); |
| 104 |
devSetLighting(FALSE); |
| 105 |
g_StrTex->RenderCenter(g_DispWidth/2, g_DispHeight/3, |
| 106 |
ScaleColor(0xffffffff, g_BlinkAlpha), ScaleColor(0xff000000, g_BlinkAlpha), |
| 107 |
lang(CannotEditInNetMode)); |
| 108 |
}else{ |
| 109 |
if(m_DragState==2) Draw2DRect( |
| 110 |
m_DragBegin.x, m_DragBegin.y, m_DragEnd.x, m_DragEnd.y, 0xffff0000); |
| 111 |
} |
| 112 |
} |