| 1 |
#include "stdafx.h" |
| 2 |
#include "CWindowDivInfo.h" |
| 3 |
#include "CConfigMode.h" |
| 4 |
#include "CSceneryMode.h" |
| 5 |
#include "CSkinPlugin.h" |
| 6 |
#include "CScene.h" |
| 7 |
#include "CSaveFile.h" |
| 8 |
|
| 9 |
// ŕč |
| 10 |
const int DRAG_BAR_WIDTH = 1; |
| 11 |
|
| 12 |
CWindowInfo::CWindowInfo(){ |
| 13 |
m_Scene = NULL; |
| 14 |
m_Div = NULL; |
| 15 |
m_Camera.Init(200.0f, 2.0f, 5000.0f, true); |
| 16 |
} |
| 17 |
|
| 18 |
CWindowInfo::~CWindowInfo(){ |
| 19 |
Free(); |
| 20 |
} |
| 21 |
|
| 22 |
void CWindowInfo::Free(){ |
| 23 |
m_Scene = NULL; |
| 24 |
CDetectInfo tmp_detect_info; |
| 25 |
m_Camera.SetFocusInfo(tmp_detect_info); |
| 26 |
DELETE_V(m_Div); |
| 27 |
} |
| 28 |
|
| 29 |
CWindowInfo *CWindowInfo::GetPointWindow(int x, int y, int w, int h, const POINT& pos){ |
| 30 |
if(m_Div){ |
| 31 |
return m_Div->GetPointWindow(x, y, w, h, pos); |
| 32 |
}else if(x<=pos.x && pos.x<x+w && y<=pos.y && pos.y<y+h){ |
| 33 |
return this; |
| 34 |
} |
| 35 |
return NULL; |
| 36 |
} |
| 37 |
|
| 38 |
CWindowInfo *CWindowInfo::GetFirstLeaf(){ |
| 39 |
return m_Div ? m_Div->m_ChildWindow[0][0].GetFirstLeaf() : this; |
| 40 |
} |
| 41 |
|
| 42 |
void CWindowInfo::ApplyViewportAndCamera(){ |
| 43 |
SetViewport(m_PosX, m_PosY, m_Width, m_Height); |
| 44 |
m_Scene->Enter(false); |
| 45 |
m_Camera.Apply(false); |
| 46 |
} |
| 47 |
|
| 48 |
void CWindowInfo::RenderScene(int x, int y, int w, int h, CSceneryMode* mode, int opt){ |
| 49 |
m_PosX = x; m_PosY = y; |
| 50 |
m_Width = w; m_Height = h; |
| 51 |
if(m_Div){ |
| 52 |
m_Div->RenderScene(x, y, w, h, mode, opt); |
| 53 |
}else{ |
| 54 |
ApplyViewportAndCamera(); |
| 55 |
m_Scene = g_Scene; |
| 56 |
g_SaveFile->RenderScene(opt); |
| 57 |
sv3.pDev->EndScene(); |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
void CWindowInfo::OnDeleteScene(CScene *scene){ |
| 62 |
if(m_Scene==scene) m_Scene = g_Scene; |
| 63 |
if(m_Div){ |
| 64 |
m_Div->OnDeleteScene(scene); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
/* |
| 69 |
* Ç |
| 70 |
*/ |
| 71 |
char *CWindowInfo::Read( |
| 72 |
char *str // ÎŰśń |
| 73 |
){ |
| 74 |
char *eee; |
| 75 |
if(!(str = BeginBlock(eee = str, "WindowInfo"))) throw CSynErr(eee); |
| 76 |
bool is_div; |
| 77 |
if(!(str = AsgnYesNo(eee = str, "Divided", &is_div))) throw CSynErr(eee); |
| 78 |
if(is_div){ |
| 79 |
m_Div = new CWindowDivInfo; |
| 80 |
str = m_Div->Read(str); |
| 81 |
m_Scene = GetFirstLeaf()->GetScene(); |
| 82 |
}else{ |
| 83 |
if(!(str = AsgnPointer(eee = str, "Scene", (void **)&m_Scene))) throw CSynErr(eee); |
| 84 |
m_Scene = (CScene *)ReplaceAdr(m_Scene); |
| 85 |
str = m_Camera.Read(str); |
| 86 |
} |
| 87 |
if(!(str = EndBlock(eee = str))) throw CSynErr(eee, ERR_ENDBLOCK); |
| 88 |
return str; |
| 89 |
} |
| 90 |
|
| 91 |
/* |
| 92 |
* Űś |
| 93 |
*/ |
| 94 |
void CWindowInfo::Save( |
| 95 |
FILE *df, // t@C |
| 96 |
string indent // Cfg |
| 97 |
){ |
| 98 |
fprintf(df, "%sWindowInfo{\n", indent.c_str()); |
| 99 |
fprintf(df, "%s\tDivided = %s;\n", indent.c_str(), YESNO[m_Div!=NULL]); |
| 100 |
string indent2 = indent+"\t"; |
| 101 |
if(m_Div){ |
| 102 |
m_Div->Save(df, indent2); |
| 103 |
}else{ |
| 104 |
fprintf(df, "%s\tScene = %p;\n", indent.c_str(), m_Scene); |
| 105 |
m_Camera.Save(df, indent2); |
| 106 |
} |
| 107 |
fprintf(df, "%s}\n", indent.c_str()); |
| 108 |
} |
| 109 |
|
| 110 |
//////////////////////////////////////////////////////////////////////////////// |
| 111 |
//////////////////////////////////////////////////////////////////////////////// |
| 112 |
|
| 113 |
CWindowDivInfo **CWindowDivInfo::s_DragDivInfo = NULL; |
| 114 |
CWindowDivInfo *CWindowDivInfo::s_MoveDivInfo = NULL; |
| 115 |
CCamera *CWindowDivInfo::s_DragDivCamera = NULL; |
| 116 |
CScene **CWindowDivInfo::s_DragDivScene = NULL; |
| 117 |
int CWindowDivInfo::s_DragState = CWindowDivInfo::DRAG_STATE_NONE; |
| 118 |
int CWindowDivInfo::s_ShrinkState = CWindowDivInfo::DRAG_STATE_NONE; |
| 119 |
int CWindowDivInfo::s_ShrinkAnim = 0; |
| 120 |
int CWindowDivInfo::s_TargetPosX, CWindowDivInfo::s_TargetPosY; |
| 121 |
int CWindowDivInfo::s_TargetWidth, CWindowDivInfo::s_TargetHeight; |
| 122 |
|
| 123 |
void CWindowDivInfo::InitState(){ |
| 124 |
s_DragDivInfo = NULL; |
| 125 |
s_MoveDivInfo = NULL; |
| 126 |
s_DragDivCamera = NULL; |
| 127 |
s_DragDivScene = NULL; |
| 128 |
s_DragState = CWindowDivInfo::DRAG_STATE_NONE; |
| 129 |
s_ShrinkState = CWindowDivInfo::DRAG_STATE_NONE; |
| 130 |
} |
| 131 |
|
| 132 |
CWindowDivInfo::CWindowDivInfo(){ |
| 133 |
m_DragState = 0; |
| 134 |
m_HorzRatio = m_VertRatio = 0.f; |
| 135 |
} |
| 136 |
|
| 137 |
CWindowDivInfo::~CWindowDivInfo(){ |
| 138 |
} |
| 139 |
|
| 140 |
void CWindowDivInfo::CalcChildSize(int w, int h){ |
| 141 |
m_ChildWidth[0] = m_HorzRatio ? Round(w*m_HorzRatio) : w; |
| 142 |
m_ChildWidth[1] = w-m_ChildWidth[0]; |
| 143 |
m_ChildHeight[0] = m_VertRatio ? Round(h*m_VertRatio) : h; |
| 144 |
m_ChildHeight[1] = h-m_ChildHeight[0]; |
| 145 |
} |
| 146 |
|
| 147 |
int CWindowDivInfo::ScanInputSelf(CWindowDivInfo** info, int x, int y, int w, int h){ |
| 148 |
int ret = 1; |
| 149 |
int i; |
| 150 |
if(s_ShrinkState!=DRAG_STATE_NONE){ |
| 151 |
if(++s_ShrinkAnim<5){ |
| 152 |
if(s_ShrinkState&DRAG_STATE_VERT){ |
| 153 |
m_HorzRatio += m_HorzRatio<.5f ? -m_HorzRatio * .5f : (1.f-m_HorzRatio)*.5f; |
| 154 |
} |
| 155 |
if(s_ShrinkState&DRAG_STATE_HORZ){ |
| 156 |
m_VertRatio += m_VertRatio<.5f ? -m_VertRatio * .5f : (1.f-m_VertRatio)*.5f; |
| 157 |
} |
| 158 |
}else{ |
| 159 |
if(s_ShrinkState&DRAG_STATE_VERT){ |
| 160 |
for(i = 0; i<WIN_DIV_MAX; ++i){ |
| 161 |
if(m_HorzRatio<.5f){ |
| 162 |
m_ChildWindow[i][0].Free(); |
| 163 |
m_ChildWindow[i][0] = m_ChildWindow[i][1]; |
| 164 |
m_ChildWindow[i][1].m_Div = NULL; |
| 165 |
}else{ |
| 166 |
m_ChildWindow[i][1].Free(); |
| 167 |
} |
| 168 |
} |
| 169 |
m_HorzRatio = 0.f; |
| 170 |
} |
| 171 |
if(s_ShrinkState&DRAG_STATE_HORZ){ |
| 172 |
for(i = 0; i<WIN_DIV_MAX; ++i){ |
| 173 |
if(m_VertRatio<.5f){ |
| 174 |
m_ChildWindow[0][i].Free(); |
| 175 |
m_ChildWindow[0][i] = m_ChildWindow[1][i]; |
| 176 |
m_ChildWindow[1][i].m_Div = NULL; |
| 177 |
}else{ |
| 178 |
m_ChildWindow[1][i].Free(); |
| 179 |
} |
| 180 |
} |
| 181 |
m_VertRatio = 0.f; |
| 182 |
} |
| 183 |
if(!m_HorzRatio && !m_VertRatio){ |
| 184 |
CWindowInfo *p_wnd = &m_ChildWindow[0][0]; |
| 185 |
if(p_wnd->m_Div){ |
| 186 |
*info = p_wnd->m_Div; |
| 187 |
p_wnd->m_Div = NULL; |
| 188 |
}else{ |
| 189 |
*info = NULL; |
| 190 |
} |
| 191 |
p_wnd = p_wnd->GetFirstLeaf(); |
| 192 |
*s_DragDivCamera = p_wnd->m_Camera; |
| 193 |
*s_DragDivScene = p_wnd->m_Scene; |
| 194 |
delete this; |
| 195 |
g_ConfigMode->SetActiveWindow(NULL); |
| 196 |
ret = 2; |
| 197 |
} |
| 198 |
s_DragDivInfo = NULL; |
| 199 |
s_ShrinkState = DRAG_STATE_NONE; |
| 200 |
} |
| 201 |
}else{ |
| 202 |
POINT pos = g_Cursor.GetPos(); |
| 203 |
if(s_DragState&DRAG_STATE_HORZ){ |
| 204 |
const float min_frac = 1.f/h; |
| 205 |
m_VertRatio = (pos.y-y)*1.f/h; |
| 206 |
ValueArea(&m_VertRatio, min_frac, 1.f-min_frac); |
| 207 |
} |
| 208 |
if(s_DragState&DRAG_STATE_VERT){ |
| 209 |
const float min_frac = 1.f/w; |
| 210 |
m_HorzRatio = (pos.x-x)*1.f/w; |
| 211 |
ValueArea(&m_HorzRatio, min_frac, 1.f-min_frac); |
| 212 |
} |
| 213 |
if(GetButton(DIM_LEFT)<S_PUSH){ |
| 214 |
CalcChildSize(w, h); |
| 215 |
s_ShrinkState = DRAG_STATE_NONE; |
| 216 |
if(s_DragState&DRAG_STATE_VERT && (m_ChildWidth[0]<WIN_DIV_MIN_SIZE || m_ChildWidth[1]<WIN_DIV_MIN_SIZE)) s_ShrinkState |= DRAG_STATE_VERT; |
| 217 |
if(s_DragState&DRAG_STATE_HORZ && (m_ChildHeight[0]<WIN_DIV_MIN_SIZE || m_ChildHeight[1]<WIN_DIV_MIN_SIZE)) s_ShrinkState |= DRAG_STATE_HORZ; |
| 218 |
if(s_ShrinkState!=DRAG_STATE_NONE){ |
| 219 |
s_ShrinkAnim = 0; |
| 220 |
}else{ |
| 221 |
s_DragDivInfo = NULL; |
| 222 |
} |
| 223 |
} |
| 224 |
} |
| 225 |
return ret; |
| 226 |
} |
| 227 |
|
| 228 |
int CWindowDivInfo::ScanInput(CWindowDivInfo** info, int x, int y, int w, int h, CCamera *cam, CScene **scene){ |
| 229 |
s_MoveDivInfo = NULL; |
| 230 |
if(s_DragDivInfo && *s_DragDivInfo){ |
| 231 |
return (*s_DragDivInfo)->ScanInputSelf(s_DragDivInfo, s_TargetPosX, s_TargetPosY, s_TargetWidth, s_TargetHeight); |
| 232 |
}else{ |
| 233 |
return ScanInputRecursive(info, x, y, w, h, cam, scene); |
| 234 |
} |
| 235 |
} |
| 236 |
|
| 237 |
int CWindowDivInfo::ScanInputRecursive(CWindowDivInfo** info, int x, int y, int w, int h, CCamera *cam, CScene **scene){ |
| 238 |
int i, j; |
| 239 |
POINT pos = g_Cursor.GetPos(); |
| 240 |
if(x<=pos.x && pos.x<x+w && y<=pos.y && pos.y<y+h){ |
| 241 |
s_DragState = DRAG_STATE_NONE; |
| 242 |
if(*info){ |
| 243 |
(*info)->CalcChildSize(w, h); |
| 244 |
const int tx = x+(*info)->m_ChildWidth[0]; |
| 245 |
const int ty = y+(*info)->m_ChildHeight[0]; |
| 246 |
bool copy_h = false, swap_h = false; |
| 247 |
bool copy_v = false, swap_v = false; |
| 248 |
if((*info)->m_ChildWidth[1] && tx-WIN_DIV_MOVE_MARGIN<=pos.x && pos.x<=tx+WIN_DIV_MOVE_MARGIN){ |
| 249 |
if((*info)->m_ChildHeight[1] && ty-WIN_DIV_MOVE_MARGIN<=pos.y && pos.y<=ty+WIN_DIV_MOVE_MARGIN){ |
| 250 |
s_DragState = DRAG_STATE_HORZVERT; |
| 251 |
}else{ |
| 252 |
if(!(*info)->m_ChildHeight[1] && (pos.y<y+WIN_DIV_MARGIN || y+h-WIN_DIV_MARGIN<=pos.y)){ |
| 253 |
s_DragState = DRAG_STATE_HORZVERT; |
| 254 |
copy_v = true; |
| 255 |
swap_v = pos.y<y+WIN_DIV_MARGIN; |
| 256 |
}else{ |
| 257 |
s_DragState = DRAG_STATE_VERT; |
| 258 |
} |
| 259 |
} |
| 260 |
}else{ |
| 261 |
if((*info)->m_ChildHeight[1] && ty-WIN_DIV_MOVE_MARGIN<=pos.y && pos.y<=ty+WIN_DIV_MOVE_MARGIN){ |
| 262 |
if(!(*info)->m_ChildWidth[1] && (pos.x<x+WIN_DIV_MARGIN || x+w-WIN_DIV_MARGIN<=pos.x)){ |
| 263 |
s_DragState = DRAG_STATE_HORZVERT; |
| 264 |
copy_h = true; |
| 265 |
swap_h = pos.x<x+WIN_DIV_MARGIN; |
| 266 |
}else{ |
| 267 |
s_DragState = DRAG_STATE_HORZ; |
| 268 |
} |
| 269 |
}else{ |
| 270 |
for(i = 0; i<WIN_DIV_MAX; ++i){ |
| 271 |
if((*info)->m_ChildHeight[i]<=0) continue; |
| 272 |
const int cy = i ? ty : y; |
| 273 |
const int ch = (*info)->m_ChildHeight[i]; |
| 274 |
for(j = 0; j<WIN_DIV_MAX; ++j){ |
| 275 |
if((*info)->m_ChildWidth[j]<=0) continue; |
| 276 |
const int cx = j ? tx : x; |
| 277 |
const int cw = (*info)->m_ChildWidth[j]; |
| 278 |
CWindowInfo &wnd = (*info)->m_ChildWindow[i][j]; |
| 279 |
int ret = ScanInputRecursive(&wnd.m_Div, cx, cy, cw, ch, &wnd.m_Camera, &wnd.m_Scene); |
| 280 |
if(ret) return ret; |
| 281 |
} |
| 282 |
} |
| 283 |
return 0; |
| 284 |
} |
| 285 |
} |
| 286 |
if(s_DragState!=DRAG_STATE_NONE){ |
| 287 |
s_TargetPosX = x; |
| 288 |
s_TargetPosY = y; |
| 289 |
s_TargetWidth = w; |
| 290 |
s_TargetHeight = h; |
| 291 |
if(GetButton(DIM_LEFT)==S_PUSH){ |
| 292 |
g_Skin->MouseDown(); |
| 293 |
s_DragDivInfo = info; |
| 294 |
s_DragDivCamera = cam; |
| 295 |
s_DragDivScene = scene; |
| 296 |
if(copy_h){ |
| 297 |
for(i = 0; i<WIN_DIV_MAX; ++i){ |
| 298 |
(*info)->m_ChildWindow[i][1] = *(*info)->m_ChildWindow[i][0].GetFirstLeaf(); |
| 299 |
if(swap_h){ |
| 300 |
CWindowInfo t = (*info)->m_ChildWindow[i][1]; |
| 301 |
(*info)->m_ChildWindow[i][1] = (*info)->m_ChildWindow[i][0]; |
| 302 |
(*info)->m_ChildWindow[i][0] = t; |
| 303 |
} |
| 304 |
} |
| 305 |
if(swap_h) (*info)->m_HorzRatio = 1.f/w; |
| 306 |
} |
| 307 |
if(copy_v){ |
| 308 |
for(i = 0; i<WIN_DIV_MAX; ++i){ |
| 309 |
(*info)->m_ChildWindow[1][i] = *(*info)->m_ChildWindow[0][i].GetFirstLeaf(); |
| 310 |
if(swap_v){ |
| 311 |
CWindowInfo t = (*info)->m_ChildWindow[1][i]; |
| 312 |
(*info)->m_ChildWindow[1][i] = (*info)->m_ChildWindow[0][i]; |
| 313 |
(*info)->m_ChildWindow[0][i] = t; |
| 314 |
} |
| 315 |
} |
| 316 |
if(swap_v) (*info)->m_VertRatio = 1.f/h; |
| 317 |
} |
| 318 |
return 1; |
| 319 |
}else{ |
| 320 |
s_MoveDivInfo = *info; |
| 321 |
} |
| 322 |
} |
| 323 |
}else{ |
| 324 |
if(pos.x<x+WIN_DIV_MARGIN || x+w-WIN_DIV_MARGIN<=pos.x){ |
| 325 |
if(pos.y<y+WIN_DIV_MARGIN || y+h-WIN_DIV_MARGIN<=pos.y){ |
| 326 |
s_DragState = DRAG_STATE_HORZVERT; |
| 327 |
}else{ |
| 328 |
s_DragState = DRAG_STATE_VERT; |
| 329 |
} |
| 330 |
}else{ |
| 331 |
if(pos.y<y+WIN_DIV_MARGIN || y+h-WIN_DIV_MARGIN<=pos.y){ |
| 332 |
s_DragState = DRAG_STATE_HORZ; |
| 333 |
}else{ |
| 334 |
} |
| 335 |
} |
| 336 |
if(s_DragState!=DRAG_STATE_NONE){ |
| 337 |
s_TargetPosX = x; |
| 338 |
s_TargetPosY = y; |
| 339 |
s_TargetWidth = w; |
| 340 |
s_TargetHeight = h; |
| 341 |
if(GetButton(DIM_LEFT)==S_PUSH){ |
| 342 |
g_Skin->MouseDown(); |
| 343 |
*info = new CWindowDivInfo; |
| 344 |
(*info)->InitCamera(*cam, *scene); |
| 345 |
s_DragDivInfo = info; |
| 346 |
s_DragDivCamera = cam; |
| 347 |
s_DragDivScene= scene; |
| 348 |
return 1; |
| 349 |
} |
| 350 |
} |
| 351 |
} |
| 352 |
}else{ |
| 353 |
} |
| 354 |
return 0; |
| 355 |
} |
| 356 |
|
| 357 |
void CWindowDivInfo::RenderInterface(){ |
| 358 |
if(s_DragState==DRAG_STATE_NONE) return; |
| 359 |
POINT pos = g_Cursor.GetPos(); |
| 360 |
const D3DCOLOR rect_color = 0xffffff00; |
| 361 |
const D3DCOLOR div_color = 0xffff0000; |
| 362 |
const int tx1 = s_TargetPosX+WIN_DIV_MARGIN, tx2 = s_TargetPosX+s_TargetWidth-WIN_DIV_MARGIN; |
| 363 |
const int ty1 = s_TargetPosY+WIN_DIV_MARGIN, ty2 = s_TargetPosY+s_TargetHeight-WIN_DIV_MARGIN; |
| 364 |
Fill2DRect(s_TargetPosX, s_TargetPosY, s_TargetPosX+s_TargetWidth, ty1, rect_color); |
| 365 |
Fill2DRect(s_TargetPosX, ty2, s_TargetPosX+s_TargetWidth, s_TargetPosY+s_TargetHeight, rect_color); |
| 366 |
Fill2DRect(s_TargetPosX, ty1, tx1, ty2, rect_color); |
| 367 |
Fill2DRect(tx2, ty1, s_TargetPosX+s_TargetWidth, ty2, rect_color); |
| 368 |
if(s_MoveDivInfo){ |
| 369 |
}else{ |
| 370 |
if(s_DragDivInfo){ |
| 371 |
ValueArea((int*)&pos.x, s_TargetPosX, s_TargetPosX+s_TargetWidth-1); |
| 372 |
ValueArea((int*)&pos.y, s_TargetPosY, s_TargetPosY+s_TargetHeight-1); |
| 373 |
}else{ |
| 374 |
pos.x = pos.x<s_TargetPosX+s_TargetWidth/2 ? s_TargetPosX : s_TargetPosX+s_TargetWidth-1; |
| 375 |
pos.y = pos.y<s_TargetPosY+s_TargetHeight/2 ? s_TargetPosY : s_TargetPosY+s_TargetHeight-1; |
| 376 |
if(s_DragState&DRAG_STATE_HORZ){ |
| 377 |
Fill2DRect(s_TargetPosX, pos.y-DRAG_BAR_WIDTH, s_TargetPosX+s_TargetWidth, pos.y+DRAG_BAR_WIDTH+1, div_color); |
| 378 |
} |
| 379 |
if(s_DragState&DRAG_STATE_VERT){ |
| 380 |
Fill2DRect(pos.x-DRAG_BAR_WIDTH, s_TargetPosY, pos.x+DRAG_BAR_WIDTH+1, s_TargetPosY+s_TargetHeight, 0xffff0000); |
| 381 |
} |
| 382 |
} |
| 383 |
} |
| 384 |
} |
| 385 |
|
| 386 |
void CWindowDivInfo::InitCamera(const CCamera& cam, CScene *scene){ |
| 387 |
int i, j; |
| 388 |
for(i = 0; i<WIN_DIV_MAX; ++i){ |
| 389 |
for(j = 0; j<WIN_DIV_MAX; ++j){ |
| 390 |
CWindowInfo &wnd = m_ChildWindow[i][j]; |
| 391 |
wnd.SetCamera(cam); |
| 392 |
wnd.SetScene(scene); |
| 393 |
} |
| 394 |
} |
| 395 |
} |
| 396 |
|
| 397 |
void CWindowDivInfo::RenderInterfaceRecursive(int x, int y, int w, int h){ |
| 398 |
const bool dragging = s_DragDivInfo && *s_DragDivInfo==this; |
| 399 |
const bool div_horz = (s_DragState&DRAG_STATE_HORZ)!=0; |
| 400 |
const bool div_vert = (s_DragState&DRAG_STATE_VERT)!=0; |
| 401 |
D3DCOLOR div_color_horz = (dragging || s_MoveDivInfo==this) && div_horz ? 0xffff0000 : 0xff000000; |
| 402 |
D3DCOLOR div_color_vert = (dragging || s_MoveDivInfo==this) && div_vert ? 0xffff0000 : 0xff000000; |
| 403 |
CalcChildSize(w, h); |
| 404 |
int i, j; |
| 405 |
for(i = 0; i<2; ++i){ |
| 406 |
if(i==!div_vert && m_ChildHeight[0]>0 && m_ChildHeight[1]>0){ |
| 407 |
Fill2DRect(x, y+m_ChildHeight[0]-WIN_DIV_PADDING/2, x+w, y+m_ChildHeight[0]-WIN_DIV_PADDING/2+WIN_DIV_PADDING, div_color_horz); |
| 408 |
} |
| 409 |
if(i==!!div_vert && m_ChildWidth[0]>0 && m_ChildWidth[1]>0){ |
| 410 |
Fill2DRect(x+m_ChildWidth[0]-WIN_DIV_PADDING/2, y, x+m_ChildWidth[0]-WIN_DIV_PADDING/2+WIN_DIV_PADDING, y+h, div_color_vert); |
| 411 |
} |
| 412 |
} |
| 413 |
for(i = 0; i<WIN_DIV_MAX; ++i){ |
| 414 |
if(m_ChildHeight[i]<=0) continue; |
| 415 |
const int cy = i ? y+m_ChildHeight[i-1] : y; |
| 416 |
const int ch = m_ChildHeight[i]; |
| 417 |
for(j = 0; j<WIN_DIV_MAX; ++j){ |
| 418 |
if(m_ChildWidth[j]<=0) continue; |
| 419 |
const int cx = j ? x+m_ChildWidth[j-1] : x; |
| 420 |
const int cw = m_ChildWidth[j]; |
| 421 |
if(m_ChildWindow[i][j].m_Div){ |
| 422 |
m_ChildWindow[i][j].m_Div->RenderInterfaceRecursive(cx, cy, cw, ch); |
| 423 |
} |
| 424 |
} |
| 425 |
} |
| 426 |
} |
| 427 |
|
| 428 |
void CWindowDivInfo::RenderScene(int x, int y, int w, int h, CSceneryMode* mode, int opt){ |
| 429 |
CalcChildSize(w, h); |
| 430 |
int i, j; |
| 431 |
for(i = 0; i<WIN_DIV_MAX; ++i){ |
| 432 |
if(m_ChildHeight[i]<=0) continue; |
| 433 |
const int cy = i ? y+m_ChildHeight[i-1] : y; |
| 434 |
const int ch = m_ChildHeight[i]; |
| 435 |
for(j = 0; j<WIN_DIV_MAX; ++j){ |
| 436 |
if(m_ChildWidth[j]<=0) continue; |
| 437 |
const int cx = j ? x+m_ChildWidth[j-1] : x; |
| 438 |
const int cw = m_ChildWidth[j]; |
| 439 |
m_ChildWindow[i][j].RenderScene(cx, cy, cw, ch, mode, opt); |
| 440 |
} |
| 441 |
} |
| 442 |
} |
| 443 |
|
| 444 |
CWindowInfo *CWindowDivInfo::GetPointWindow(int x, int y, int w, int h, const POINT& pos){ |
| 445 |
CalcChildSize(w, h); |
| 446 |
int i, j; |
| 447 |
for(i = 0; i<WIN_DIV_MAX; ++i){ |
| 448 |
if(m_ChildHeight[i]<=0) continue; |
| 449 |
const int cy = i ? y+m_ChildHeight[i-1] : y; |
| 450 |
const int ch = m_ChildHeight[i]; |
| 451 |
for(j = 0; j<WIN_DIV_MAX; ++j){ |
| 452 |
if(m_ChildWidth[j]<=0) continue; |
| 453 |
const int cx = j ? x+m_ChildWidth[j-1] : x; |
| 454 |
const int cw = m_ChildWidth[j]; |
| 455 |
CWindowInfo *ret = m_ChildWindow[i][j].GetPointWindow(cx, cy, cw, ch, pos); |
| 456 |
if(ret) return ret; |
| 457 |
} |
| 458 |
} |
| 459 |
return NULL; |
| 460 |
} |
| 461 |
|
| 462 |
void CWindowDivInfo::OnDeleteScene(CScene *scene){ |
| 463 |
int i, j; |
| 464 |
for(i = 0; i<WIN_DIV_MAX; ++i){ |
| 465 |
for(j = 0; j<WIN_DIV_MAX; ++j){ |
| 466 |
m_ChildWindow[i][j].OnDeleteScene(scene); |
| 467 |
} |
| 468 |
} |
| 469 |
} |
| 470 |
|
| 471 |
/* |
| 472 |
* Ç |
| 473 |
*/ |
| 474 |
char *CWindowDivInfo::Read( |
| 475 |
char *str // ÎŰśń |
| 476 |
){ |
| 477 |
char *eee; |
| 478 |
if(!(str = BeginBlock(eee = str, "WindowDivInfo"))) throw CSynErr(eee); |
| 479 |
if(!(str = AsgnFloat(eee = str, "HorzRatio", &m_HorzRatio))) throw CSynErr(eee); |
| 480 |
if(!(str = AsgnFloat(eee = str, "VertRatio", &m_VertRatio))) throw CSynErr(eee); |
| 481 |
int i, j; |
| 482 |
for(i = 0; i<WIN_DIV_MAX; ++i){ |
| 483 |
if(i && !m_VertRatio) break; |
| 484 |
for(j = 0; j<WIN_DIV_MAX; ++j){ |
| 485 |
if(j && !m_HorzRatio) break; |
| 486 |
str = m_ChildWindow[i][j].Read(str); |
| 487 |
} |
| 488 |
} |
| 489 |
if(!(str = EndBlock(eee = str))) throw CSynErr(eee, ERR_ENDBLOCK); |
| 490 |
return str; |
| 491 |
} |
| 492 |
|
| 493 |
/* |
| 494 |
* Űś |
| 495 |
*/ |
| 496 |
void CWindowDivInfo::Save( |
| 497 |
FILE *df, // t@C |
| 498 |
string indent // Cfg |
| 499 |
){ |
| 500 |
fprintf(df, "%sWindowDivInfo{\n", indent.c_str()); |
| 501 |
fprintf(df, "%s\tHorzRatio = %f;\n", indent.c_str(), m_HorzRatio); |
| 502 |
fprintf(df, "%s\tVertRatio = %f;\n", indent.c_str(), m_VertRatio); |
| 503 |
string indent2 = indent+"\t"; |
| 504 |
int i, j; |
| 505 |
for(i = 0; i<WIN_DIV_MAX; ++i){ |
| 506 |
if(i && !m_VertRatio) break; |
| 507 |
for(j = 0; j<WIN_DIV_MAX; ++j){ |
| 508 |
if(j && !m_HorzRatio) break; |
| 509 |
m_ChildWindow[i][j].Save(df, indent2); |
| 510 |
} |
| 511 |
} |
| 512 |
fprintf(df, "%s}\n", indent.c_str()); |
| 513 |
} |